From gitlab at gitlab.haskell.org Wed Jul 1 11:41:38 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 01 Jul 2020 07:41:38 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Implement -XLexicalNegation (GHC Proposal #229) Message-ID: <5efc767255050_80b3f846a54be3c1126142@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 573cd33e by Vladislav Zavialov at 2020-07-01T07:41:24-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fe93d94f by Martin Handley at 2020-07-01T07:41:27-04:00 #17169: Clarify Fixed's Enum instance. - - - - - fa904335 by Simon Peyton Jones at 2020-07-01T07:41:28-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 127ee5cb by Hécate at 2020-07-01T07:41:30-04:00 Add most common return values for `os` and `arch` - - - - - a19466b0 by Ryan Scott at 2020-07-01T07:41:30-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 30 changed files: - aclocal.m4 - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - docs/users_guide/8.12.1-notes.rst - + docs/users_guide/exts/lexical_negation.rst - docs/users_guide/exts/negative_literals.rst - docs/users_guide/exts/syntax.rst - libraries/base/Data/Fixed.hs - libraries/base/System/Info.hs - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - testsuite/tests/driver/T4437.hs - + testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/LexicalNegation.hs - testsuite/tests/parser/should_compile/all.T - + testsuite/tests/parser/should_run/LexNegLit.hs - + testsuite/tests/parser/should_run/LexNegLit.stdout - testsuite/tests/parser/should_run/all.T - + testsuite/tests/th/T18388.hs - testsuite/tests/th/all.T - utils/haddock Changes: ===================================== aclocal.m4 ===================================== @@ -1919,7 +1919,9 @@ AC_MSG_CHECKING(for path to top of build tree) # GHC_CONVERT_CPU(cpu, target_var) # -------------------------------- -# converts cpu from gnu to ghc naming, and assigns the result to $target_var +# Converts cpu from gnu to ghc naming, and assigns the result to $target_var. +# Should you modify this list, you are invited to reflect the changes in +# `libraries/base/System/Info.hs`'s documentation. AC_DEFUN([GHC_CONVERT_CPU],[ case "$1" in aarch64*) ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1023,7 +1023,7 @@ etaInfoApp subst (Tick t e) eis etaInfoApp subst expr _ | (Var fun, _) <- collectArgs expr - , Var fun' <- lookupIdSubst (text "etaInfoApp" <+> ppr fun) subst fun + , Var fun' <- lookupIdSubst subst fun , isJoinId fun' = subst_expr subst expr @@ -1132,13 +1132,16 @@ mkEtaWW orig_n ppr_orig_expr in_scope orig_ty --------------- --- Don't use short-cutting substitution - we may be changing the types of join --- points, so applying the in-scope set is necessary --- TODO Check if we actually *are* changing any join points' types - +------------ subst_expr :: Subst -> CoreExpr -> CoreExpr -subst_expr = substExpr (text "GHC.Core.Opt.Arity:substExpr") +-- Apply a substitution to an expression. We use substExpr +-- not substExprSC (short-cutting substitution) because +-- we may be changing the types of join points, so applying +-- the in-scope set is necessary. +-- +-- ToDo: we could instead check if we actually *are* +-- changing any join points' types, and if not use substExprSC. +subst_expr = substExpr -------------- ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -775,7 +775,7 @@ csEnvSubst :: CSEnv -> Subst csEnvSubst = cs_subst lookupSubst :: CSEnv -> Id -> OutExpr -lookupSubst (CS { cs_subst = sub}) x = lookupIdSubst (text "CSE.lookupSubst") sub x +lookupSubst (CS { cs_subst = sub}) x = lookupIdSubst sub x extendCSSubst :: CSEnv -> Id -> CoreExpr -> CSEnv extendCSSubst cse x rhs = cse { cs_subst = extendSubst (cs_subst cse) x rhs } ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1804,7 +1804,7 @@ abstractFloats dflags top_lvl main_tvs floats body = ASSERT( notNull body_floats ) ASSERT( isNilOL (sfJoinFloats floats) ) do { (subst, float_binds) <- mapAccumLM abstract empty_subst body_floats - ; return (float_binds, GHC.Core.Subst.substExpr (text "abstract_floats1") subst body) } + ; return (float_binds, GHC.Core.Subst.substExpr subst body) } where is_top_lvl = isTopLevel top_lvl main_tv_set = mkVarSet main_tvs @@ -1818,7 +1818,7 @@ abstractFloats dflags top_lvl main_tvs floats body subst' = GHC.Core.Subst.extendIdSubst subst id poly_app ; return (subst', NonRec poly_id2 poly_rhs) } where - rhs' = GHC.Core.Subst.substExpr (text "abstract_floats2") subst rhs + rhs' = GHC.Core.Subst.substExpr subst rhs -- tvs_here: see Note [Which type variables to abstract over] tvs_here = scopedSort $ @@ -1831,8 +1831,7 @@ abstractFloats dflags top_lvl main_tvs floats body ; let subst' = GHC.Core.Subst.extendSubstList subst (ids `zip` poly_apps) poly_pairs = [ mk_poly2 poly_id tvs_here rhs' | (poly_id, rhs) <- poly_ids `zip` rhss - , let rhs' = GHC.Core.Subst.substExpr (text "abstract_floats") - subst' rhs ] + , let rhs' = GHC.Core.Subst.substExpr subst' rhs ] ; return (subst', Rec poly_pairs) } where (ids,rhss) = unzip prs ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -860,7 +860,7 @@ lookupHowBound :: ScEnv -> Id -> Maybe HowBound lookupHowBound env id = lookupVarEnv (sc_how_bound env) id scSubstId :: ScEnv -> Id -> CoreExpr -scSubstId env v = lookupIdSubst (text "scSubstId") (sc_subst env) v +scSubstId env v = lookupIdSubst (sc_subst env) v scSubstTy :: ScEnv -> Type -> Type scSubstTy env ty = substTy (sc_subst env) ty ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -1008,7 +1008,7 @@ instance Outputable SpecEnv where , text "interesting =" <+> ppr interesting ]) specVar :: SpecEnv -> Id -> CoreExpr -specVar env v = Core.lookupIdSubst (text "specVar") (se_subst env) v +specVar env v = Core.lookupIdSubst (se_subst env) v specExpr :: SpecEnv -> CoreExpr -> SpecM (CoreExpr, UsageDetails) ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -917,7 +917,7 @@ match_var renv@(RV { rv_tmpls = tmpls, rv_lcl = rn_env, rv_fltR = flt_env }) Var v2 | v1' == rnOccR rn_env v2 -> Just subst - | Var v2' <- lookupIdSubst (text "match_var") flt_env v2 + | Var v2' <- lookupIdSubst flt_env v2 , v1' == v2' -> Just subst @@ -965,7 +965,7 @@ match_tmpl_var renv@(RV { rv_lcl = rn_env, rv_fltR = flt_env }) where -- e2' is the result of applying flt_env to e2 e2' | isEmptyVarSet let_bndrs = e2 - | otherwise = substExpr (text "match_tmpl_var") flt_env e2 + | otherwise = substExpr flt_env e2 id_subst' = extendVarEnv (rs_id_subst subst) v1' e2' -- No further renaming to do on e2', ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -93,7 +93,7 @@ little dance in action; the full Simplifier is a lot more complicated. -} -simpleOptExpr :: DynFlags -> CoreExpr -> CoreExpr +simpleOptExpr :: HasDebugCallStack => DynFlags -> CoreExpr -> CoreExpr -- See Note [The simple optimiser] -- Do simple optimisation on an expression -- The optimisation is very straightforward: just @@ -125,7 +125,7 @@ simpleOptExpr dflags expr -- It's a bit painful to call exprFreeVars, because it makes -- three passes instead of two (occ-anal, and go) -simpleOptExprWith :: DynFlags -> Subst -> InExpr -> OutExpr +simpleOptExprWith :: HasDebugCallStack => DynFlags -> Subst -> InExpr -> OutExpr -- See Note [The simple optimiser] simpleOptExprWith dflags subst expr = simple_opt_expr init_env (occurAnalyseExpr expr) @@ -218,7 +218,7 @@ simple_opt_expr env expr | Just clo <- lookupVarEnv (soe_inl env) v = simple_opt_clo env clo | otherwise - = lookupIdSubst (text "simpleOptExpr") (soe_subst env) v + = lookupIdSubst (soe_subst env) v go (App e1 e2) = simple_app env e1 [(env,e2)] go (Type ty) = Type (substTy subst ty) @@ -293,7 +293,7 @@ mk_cast e co | isReflexiveCo co = e ---------------------- -- simple_app collects arguments for beta reduction -simple_app :: SimpleOptEnv -> InExpr -> [SimpleClo] -> CoreExpr +simple_app :: HasDebugCallStack => SimpleOptEnv -> InExpr -> [SimpleClo] -> CoreExpr simple_app env (Var v) as | Just (env', e) <- lookupVarEnv (soe_inl env) v @@ -306,7 +306,7 @@ simple_app env (Var v) as = simple_app (soeZapSubst env) (unfoldingTemplate unf) as | otherwise - , let out_fn = lookupIdSubst (text "simple_app") (soe_subst env) v + , let out_fn = lookupIdSubst (soe_subst env) v = finish_app env out_fn as simple_app env (App e1 e2) as @@ -1064,7 +1064,8 @@ data ConCont = CC [CoreExpr] Coercion -- -- We also return the incoming InScopeSet, augmented with -- the binders from any [FloatBind] that we return -exprIsConApp_maybe :: InScopeEnv -> CoreExpr +exprIsConApp_maybe :: HasDebugCallStack + => InScopeEnv -> CoreExpr -> Maybe (InScopeSet, [FloatBind], DataCon, [Type], [CoreExpr]) exprIsConApp_maybe (in_scope, id_unf) expr = go (Left in_scope) [] expr (CC [] (mkRepReflCo (exprType expr))) @@ -1118,7 +1119,7 @@ exprIsConApp_maybe (in_scope, id_unf) expr go (Right sub) floats (Var v) cont = go (Left (substInScope sub)) floats - (lookupIdSubst (text "exprIsConApp" <+> ppr expr) sub v) + (lookupIdSubst sub v) cont go (Left in_scope) floats (Var fun) cont@(CC args co) @@ -1141,7 +1142,7 @@ exprIsConApp_maybe (in_scope, id_unf) expr , bndrs `equalLength` args -- See Note [DFun arity check] , let subst = mkOpenSubst in_scope (bndrs `zip` args) = succeedWith in_scope floats $ - pushCoDataCon con (map (substExpr (text "exprIsConApp1") subst) dfun_args) co + pushCoDataCon con (map (substExpr subst) dfun_args) co -- Look through unfoldings, but only arity-zero one; -- if arity > 0 we are effectively inlining a function call, @@ -1180,7 +1181,7 @@ exprIsConApp_maybe (in_scope, id_unf) expr subst_co (Right s) co = GHC.Core.Subst.substCo s co subst_expr (Left {}) e = e - subst_expr (Right s) e = substExpr (text "exprIsConApp2") s e + subst_expr (Right s) e = substExpr s e subst_bndr msubst bndr = (Right subst', bndr') @@ -1461,7 +1462,7 @@ pushCoercionIntoLambda in_scope x e co subst = extendIdSubst (mkEmptySubst in_scope') x (mkCast (Var x') co1) - in Just (x', substExpr (text "pushCoercionIntoLambda") subst e `mkCast` co2) + in Just (x', substExpr subst e `mkCast` co2) | otherwise = pprTrace "exprIsLambda_maybe: Unexpected lambda in case" (ppr (Lam x e)) Nothing ===================================== compiler/GHC/Core/Subst.hs ===================================== @@ -246,13 +246,13 @@ extendSubstList subst [] = subst extendSubstList subst ((var,rhs):prs) = extendSubstList (extendSubst subst var rhs) prs -- | Find the substitution for an 'Id' in the 'Subst' -lookupIdSubst :: SDoc -> Subst -> Id -> CoreExpr -lookupIdSubst doc (Subst in_scope ids _ _) v +lookupIdSubst :: HasDebugCallStack => Subst -> Id -> CoreExpr +lookupIdSubst (Subst in_scope ids _ _) v | not (isLocalId v) = Var v | Just e <- lookupVarEnv ids v = e | Just v' <- lookupInScope in_scope v = Var v' -- Vital! See Note [Extending the Subst] - | otherwise = WARN( True, text "GHC.Core.Subst.lookupIdSubst" <+> doc <+> ppr v + | otherwise = WARN( True, text "GHC.Core.Subst.lookupIdSubst" <+> ppr v $$ ppr in_scope) Var v @@ -338,26 +338,25 @@ instance Outputable Subst where ************************************************************************ -} --- | Apply a substitution to an entire 'CoreExpr'. Remember, you may only --- apply the substitution /once/: +substExprSC :: HasDebugCallStack => Subst -> CoreExpr -> CoreExpr +-- Just like substExpr, but a no-op if the substitution is empty +substExprSC subst orig_expr + | isEmptySubst subst = orig_expr + | otherwise = -- pprTrace "enter subst-expr" (doc $$ ppr orig_expr) $ + substExpr subst orig_expr + +-- | substExpr applies a substitution to an entire 'CoreExpr'. Remember, +-- you may only apply the substitution /once/: -- See Note [Substitutions apply only once] in "GHC.Core.TyCo.Subst" -- -- Do *not* attempt to short-cut in the case of an empty substitution! -- See Note [Extending the Subst] -substExprSC :: SDoc -> Subst -> CoreExpr -> CoreExpr -substExprSC doc subst orig_expr - | isEmptySubst subst = orig_expr - | otherwise = -- pprTrace "enter subst-expr" (doc $$ ppr orig_expr) $ - subst_expr doc subst orig_expr - -substExpr :: SDoc -> Subst -> CoreExpr -> CoreExpr -substExpr doc subst orig_expr = subst_expr doc subst orig_expr - -subst_expr :: SDoc -> Subst -> CoreExpr -> CoreExpr -subst_expr doc subst expr +substExpr :: HasDebugCallStack => Subst -> CoreExpr -> CoreExpr + -- HasDebugCallStack so we can track failures in lookupIdSubst +substExpr subst expr = go expr where - go (Var v) = lookupIdSubst (doc $$ text "subst_expr") subst v + go (Var v) = lookupIdSubst subst v go (Type ty) = Type (substTy subst ty) go (Coercion co) = Coercion (substCo subst co) go (Lit lit) = Lit lit @@ -370,11 +369,11 @@ subst_expr doc subst expr -- lose a binder. We optimise the LHS of rules at -- construction time - go (Lam bndr body) = Lam bndr' (subst_expr doc subst' body) + go (Lam bndr body) = Lam bndr' (substExpr subst' body) where (subst', bndr') = substBndr subst bndr - go (Let bind body) = Let bind' (subst_expr doc subst' body) + go (Let bind body) = Let bind' (substExpr subst' body) where (subst', bind') = substBind subst bind @@ -382,13 +381,13 @@ subst_expr doc subst expr where (subst', bndr') = substBndr subst bndr - go_alt subst (con, bndrs, rhs) = (con, bndrs', subst_expr doc subst' rhs) + go_alt subst (con, bndrs, rhs) = (con, bndrs', substExpr subst' rhs) where (subst', bndrs') = substBndrs subst bndrs -- | Apply a substitution to an entire 'CoreBind', additionally returning an updated 'Subst' -- that should be used by subsequent substitutions. -substBind, substBindSC :: Subst -> CoreBind -> (Subst, CoreBind) +substBind, substBindSC :: HasDebugCallStack => Subst -> CoreBind -> (Subst, CoreBind) substBindSC subst bind -- Short-cut if the substitution is empty | not (isEmptySubst subst) @@ -405,10 +404,10 @@ substBindSC subst bind -- Short-cut if the substitution is empty rhss' | isEmptySubst subst' = rhss | otherwise - = map (subst_expr (text "substBindSC") subst') rhss + = map (substExpr subst') rhss substBind subst (NonRec bndr rhs) - = (subst', NonRec bndr' (subst_expr (text "substBind") subst rhs)) + = (subst', NonRec bndr' (substExpr subst rhs)) where (subst', bndr') = substBndr subst bndr @@ -417,7 +416,7 @@ substBind subst (Rec pairs) where (bndrs, rhss) = unzip pairs (subst', bndrs') = substRecBndrs subst bndrs - rhss' = map (subst_expr (text "substBind") subst') rhss + rhss' = map (substExpr subst') rhss -- | De-shadowing the program is sometimes a useful pre-pass. It can be done simply -- by running over the bindings with an empty substitution, because substitution @@ -638,7 +637,7 @@ substUnfolding subst df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) = df { df_bndrs = bndrs', df_args = args' } where (subst',bndrs') = substBndrs subst bndrs - args' = map (substExpr (text "subst-unf:dfun") subst') args + args' = map (substExpr subst') args substUnfolding subst unf@(CoreUnfolding { uf_tmpl = tmpl, uf_src = src }) -- Retain an InlineRule! @@ -648,14 +647,14 @@ substUnfolding subst unf@(CoreUnfolding { uf_tmpl = tmpl, uf_src = src }) = seqExpr new_tmpl `seq` unf { uf_tmpl = new_tmpl } where - new_tmpl = substExpr (text "subst-unf") subst tmpl + new_tmpl = substExpr subst tmpl substUnfolding _ unf = unf -- NoUnfolding, OtherCon ------------------ substIdOcc :: Subst -> Id -> Id -- These Ids should not be substituted to non-Ids -substIdOcc subst v = case lookupIdSubst (text "substIdOcc") subst v of +substIdOcc subst v = case lookupIdSubst subst v of Var v' -> v' other -> pprPanic "substIdOcc" (vcat [ppr v <+> ppr other, ppr subst]) @@ -693,12 +692,11 @@ substRule subst subst_ru_fn rule@(Rule { ru_bndrs = bndrs, ru_args = args , ru_fn = if is_local then subst_ru_fn fn_name else fn_name - , ru_args = map (substExpr doc subst') args - , ru_rhs = substExpr (text "foo") subst' rhs } + , ru_args = map (substExpr subst') args + , ru_rhs = substExpr subst' rhs } -- Do NOT optimise the RHS (previously we did simplOptExpr here) -- See Note [Substitute lazily] where - doc = text "subst-rule" <+> ppr fn_name (subst', bndrs') = substBndrs subst bndrs ------------------ @@ -707,7 +705,7 @@ substDVarSet subst fvs = mkDVarSet $ fst $ foldr (subst_fv subst) ([], emptyVarSet) $ dVarSetElems fvs where subst_fv subst fv acc - | isId fv = expr_fvs (lookupIdSubst (text "substDVarSet") subst fv) isLocalVar emptyVarSet $! acc + | isId fv = expr_fvs (lookupIdSubst subst fv) isLocalVar emptyVarSet $! acc | otherwise = tyCoFVsOfType (lookupTCvSubst subst fv) (const True) emptyVarSet $! acc ------------------ @@ -715,7 +713,7 @@ substTickish :: Subst -> Tickish Id -> Tickish Id substTickish subst (Breakpoint n ids) = Breakpoint n (map do_one ids) where - do_one = getIdFromTrivialExpr . lookupIdSubst (text "subst_tickish") subst + do_one = getIdFromTrivialExpr . lookupIdSubst subst substTickish _subst other = other {- Note [Substitute lazily] ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3784,6 +3784,7 @@ xFlagsDeps = [ flagSpec "JavaScriptFFI" LangExt.JavaScriptFFI, flagSpec "KindSignatures" LangExt.KindSignatures, flagSpec "LambdaCase" LangExt.LambdaCase, + flagSpec "LexicalNegation" LangExt.LexicalNegation, flagSpec "LiberalTypeSynonyms" LangExt.LiberalTypeSynonyms, flagSpec "LinearTypes" LangExt.LinearTypes, flagSpec "MagicHash" LangExt.MagicHash, ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -332,7 +332,7 @@ repTopDs group@(HsGroup { hs_valds = valds = notHandledL loc "Haddock documentation" empty hsScopedTvBinders :: HsValBinds GhcRn -> [Name] --- See Note [Scoped type variables in bindings] +-- See Note [Scoped type variables in quotes] hsScopedTvBinders binds = concatMap get_scoped_tvs sigs where @@ -350,58 +350,60 @@ get_scoped_tvs (L _ signature) = get_scoped_tvs_from_sig sig | otherwise = [] - where - get_scoped_tvs_from_sig :: LHsSigType GhcRn -> [Name] - get_scoped_tvs_from_sig sig - -- Both implicit and explicit quantified variables - -- We need the implicit ones for f :: forall (a::k). blah - -- here 'k' scopes too - | HsIB { hsib_ext = implicit_vars - , hsib_body = hs_ty } <- sig - , (explicit_vars, _) <- splitLHsForAllTyInvis hs_ty - = implicit_vars ++ hsLTyVarNames explicit_vars + +get_scoped_tvs_from_sig :: LHsSigType GhcRn -> [Name] +get_scoped_tvs_from_sig sig + -- Collect both implicit and explicit quantified variables, since + -- the types in instance heads, as well as `via` types in DerivingVia, can + -- bring implicitly quantified type variables into scope, e.g., + -- + -- instance Foo [a] where + -- m = n @a + -- + -- See also Note [Scoped type variables in quotes] + | HsIB { hsib_ext = implicit_vars + , hsib_body = hs_ty } <- sig + , (explicit_vars, _) <- splitLHsForAllTyInvis hs_ty + = implicit_vars ++ hsLTyVarNames explicit_vars {- Notes -Note [Scoped type variables in bindings] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider - f :: forall a. a -> a - f x = x::a -Here the 'forall a' brings 'a' into scope over the binding group. -To achieve this we +Note [Scoped type variables in quotes] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quoting declarations with scoped type variables requires some care. Consider: - a) Gensym a binding for 'a' at the same time as we do one for 'f' - collecting the relevant binders with hsScopedTvBinders + $([d| f :: forall a. a -> a + f x = x::a + |]) - b) When processing the 'forall', don't gensym +Here, the `forall a` brings `a` into scope over the binding group. This has +ramifications when desugaring the quote, as we must ensure that that the +desugared code binds `a` with `Language.Haskell.TH.newName` and refers to the +bound `a` type variable in the type signature and in the body of `f`. As a +result, the call to `newName` must occur before any part of the declaration for +`f` is processed. To achieve this, we: -The relevant places are signposted with references to this Note + (a) Gensym a binding for `a` at the same time as we do one for `f`, + collecting the relevant binders with the hsScopedTvBinders family of + functions. -Note [Scoped type variables in class and instance declarations] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Scoped type variables may occur in default methods and default -signatures. We need to bring the type variables in 'foralls' -into the scope of the method bindings. + (b) Use `addBinds` to bring these gensymmed bindings into scope over any + part of the code where the type variables scope. In the `f` example, + above, that means the type signature and the body of `f`. -Consider - class Foo a where - foo :: forall (b :: k). a -> Proxy b -> Proxy b - foo _ x = (x :: Proxy b) + (c) When processing the `forall`, /don't/ gensym the type variables. We have + already brought the type variables into scope in part (b), after all, so + gensymming them again would lead to shadowing. We use the rep_ty_sig + family of functions for processing types without gensymming the type + variables again. -We want to ensure that the 'b' in the type signature and the default -implementation are the same, so we do the following: + (d) Finally, we use wrapGenSyms to generate the Core for these scoped type + variables: - a) Before desugaring the signature and binding of 'foo', use - get_scoped_tvs to collect type variables in 'forall' and - create symbols for them. - b) Use 'addBinds' to bring these symbols into the scope of the type - signatures and bindings. - c) Use these symbols to generate Core for the class/instance declaration. + newName "a" >>= \a -> + ... -- process the type signature and body of `f` -Note that when desugaring the signatures, we lookup the type variables -from the scope rather than recreate symbols for them. See more details -in "rep_ty_sig" and in Trac#14885. +The relevant places are signposted with references to this Note. Note [Binders and occurrences] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -429,16 +431,16 @@ Note [Don't quantify implicit type variables in quotes] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you're not careful, it's surprisingly easy to take this quoted declaration: - [d| idProxy :: forall proxy (b :: k). proxy b -> proxy b - idProxy x = x + [d| id :: a -> a + id x = x |] and have Template Haskell turn it into this: - idProxy :: forall k proxy (b :: k). proxy b -> proxy b - idProxy x = x + id :: forall a. a -> a + id x = x -Notice that we explicitly quantified the variable `k`! The latter declaration +Notice that we explicitly quantified the variable `a`! The latter declaration isn't what the user wrote in the first place. Usually, the culprit behind these bugs is taking implicitly quantified type @@ -474,8 +476,8 @@ repTyClD (L loc (ClassDecl { tcdCtxt = cxt, tcdLName = cls, = do { cls1 <- lookupLOcc cls -- See note [Binders and occurrences] ; dec <- addQTyVarBinds tvs $ \bndrs -> do { cxt1 <- repLContext cxt - -- See Note [Scoped type variables in class and instance declarations] - ; (ss, sigs_binds) <- rep_sigs_binds sigs meth_binds + -- See Note [Scoped type variables in quotes] + ; (ss, sigs_binds) <- rep_meth_sigs_binds sigs meth_binds ; fds1 <- repLFunDeps fds ; ats1 <- repFamilyDecls ats ; atds1 <- mapM (repAssocTyFamDefaultD . unLoc) atds @@ -650,8 +652,8 @@ repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds -- do { cxt1 <- repLContext cxt ; inst_ty1 <- repLTy inst_ty - -- See Note [Scoped type variables in class and instance declarations] - ; (ss, sigs_binds) <- rep_sigs_binds sigs binds + -- See Note [Scoped type variables in quotes] + ; (ss, sigs_binds) <- rep_meth_sigs_binds sigs binds ; ats1 <- mapM (repTyFamInstD . unLoc) ats ; adts1 <- mapM (repDataFamInstD . unLoc) adts ; decls1 <- coreListM decTyConName (ats1 ++ adts1 ++ sigs_binds) @@ -664,9 +666,9 @@ repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds repStandaloneDerivD :: LDerivDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repStandaloneDerivD (L loc (DerivDecl { deriv_strategy = strat , deriv_type = ty })) - = do { dec <- addSimpleTyVarBinds tvs $ + = do { dec <- repDerivStrategy strat $ \strat' -> + addSimpleTyVarBinds tvs $ do { cxt' <- repLContext cxt - ; strat' <- repDerivStrategy strat ; inst_ty' <- repLTy inst_ty ; repDeriv strat' cxt' inst_ty' } ; return (loc, dec) } @@ -943,23 +945,23 @@ repDerivClause :: LHsDerivingClause GhcRn repDerivClause (L _ (HsDerivingClause { deriv_clause_strategy = dcs , deriv_clause_tys = L _ dct })) - = do MkC dcs' <- repDerivStrategy dcs - MkC dct' <- repListM typeTyConName (rep_deriv_ty . hsSigType) dct + = repDerivStrategy dcs $ \(MkC dcs') -> + do MkC dct' <- repListM typeTyConName (rep_deriv_ty . hsSigType) dct rep2 derivClauseName [dcs',dct'] where rep_deriv_ty :: LHsType GhcRn -> MetaM (Core (M TH.Type)) rep_deriv_ty ty = repLTy ty -rep_sigs_binds :: [LSig GhcRn] -> LHsBinds GhcRn - -> MetaM ([GenSymBind], [Core (M TH.Dec)]) +rep_meth_sigs_binds :: [LSig GhcRn] -> LHsBinds GhcRn + -> MetaM ([GenSymBind], [Core (M TH.Dec)]) -- Represent signatures and methods in class/instance declarations. --- See Note [Scoped type variables in class and instance declarations] +-- See Note [Scoped type variables in quotes] -- -- Why not use 'repBinds': we have already created symbols for methods in -- 'repTopDs' via 'hsGroupBinders'. However in 'repBinds', we recreate -- these fun_id via 'collectHsValBinders decs', which would lead to the -- instance declarations failing in TH. -rep_sigs_binds sigs binds +rep_meth_sigs_binds sigs binds = do { let tvs = concatMap get_scoped_tvs sigs ; ss <- mkGenSyms tvs ; sigs1 <- addBinds ss $ rep_sigs sigs @@ -993,30 +995,47 @@ rep_sig (L _ (SCCFunSig {})) = notHandled "SCC pragmas" empty rep_sig (L loc (CompleteMatchSig _ _st cls mty)) = rep_complete_sig cls mty loc +-- Desugar the explicit type variable binders in an 'LHsSigType', making +-- sure not to gensym them. +-- See Note [Scoped type variables in quotes] +-- and Note [Don't quantify implicit type variables in quotes] +rep_ty_sig_tvs :: [LHsTyVarBndr Specificity GhcRn] + -> MetaM (Core [M TH.TyVarBndrSpec]) +rep_ty_sig_tvs explicit_tvs + = let rep_in_scope_tv tv = do { name <- lookupBinder (hsLTyVarName tv) + ; repTyVarBndrWithKind tv name } in + repListM tyVarBndrSpecTyConName rep_in_scope_tv + explicit_tvs + -- NB: Don't pass any implicit type variables to repList above + -- See Note [Don't quantify implicit type variables in quotes] + +-- Desugar a top-level type signature. Unlike 'repHsSigType', this +-- deliberately avoids gensymming the type variables. +-- See Note [Scoped type variables in quotes] +-- and Note [Don't quantify implicit type variables in quotes] rep_ty_sig :: Name -> SrcSpan -> LHsSigType GhcRn -> Located Name -> MetaM (SrcSpan, Core (M TH.Dec)) --- Don't create the implicit and explicit variables when desugaring signatures, --- see Note [Scoped type variables in class and instance declarations]. --- and Note [Don't quantify implicit type variables in quotes] rep_ty_sig mk_sig loc sig_ty nm - | HsIB { hsib_body = hs_ty } <- sig_ty - , (explicit_tvs, ctxt, ty) <- splitLHsSigmaTyInvis hs_ty = do { nm1 <- lookupLOcc nm - ; let rep_in_scope_tv tv = do { name <- lookupBinder (hsLTyVarName tv) - ; repTyVarBndrWithKind tv name } - ; th_explicit_tvs <- repListM tyVarBndrSpecTyConName rep_in_scope_tv - explicit_tvs - - -- NB: Don't pass any implicit type variables to repList above - -- See Note [Don't quantify implicit type variables in quotes] + ; ty1 <- rep_ty_sig' sig_ty + ; sig <- repProto mk_sig nm1 ty1 + ; return (loc, sig) } +-- Desugar an 'LHsSigType', making sure not to gensym the type variables at +-- the front of the type signature. +-- See Note [Scoped type variables in quotes] +-- and Note [Don't quantify implicit type variables in quotes] +rep_ty_sig' :: LHsSigType GhcRn + -> MetaM (Core (M TH.Type)) +rep_ty_sig' sig_ty + | HsIB { hsib_body = hs_ty } <- sig_ty + , (explicit_tvs, ctxt, ty) <- splitLHsSigmaTyInvis hs_ty + = do { th_explicit_tvs <- rep_ty_sig_tvs explicit_tvs ; th_ctxt <- repLContext ctxt ; th_ty <- repLTy ty - ; ty1 <- if null explicit_tvs && null (unLoc ctxt) - then return th_ty - else repTForall th_explicit_tvs th_ctxt th_ty - ; sig <- repProto mk_sig nm1 ty1 - ; return (loc, sig) } + ; if null explicit_tvs && null (unLoc ctxt) + then return th_ty + else repTForall th_explicit_tvs th_ctxt th_ty } rep_patsyn_ty_sig :: SrcSpan -> LHsSigType GhcRn -> Located Name -> MetaM (SrcSpan, Core (M TH.Dec)) @@ -1024,19 +1043,14 @@ rep_patsyn_ty_sig :: SrcSpan -> LHsSigType GhcRn -> Located Name -- see Note [Pattern synonym type signatures and Template Haskell] in "GHC.ThToHs" -- -- Don't create the implicit and explicit variables when desugaring signatures, --- see Note [Scoped type variables in class and instance declarations] +-- see Note [Scoped type variables in quotes] -- and Note [Don't quantify implicit type variables in quotes] rep_patsyn_ty_sig loc sig_ty nm | HsIB { hsib_body = hs_ty } <- sig_ty , (univs, reqs, exis, provs, ty) <- splitLHsPatSynTy hs_ty = do { nm1 <- lookupLOcc nm - ; let rep_in_scope_tv tv = do { name <- lookupBinder (hsLTyVarName tv) - ; repTyVarBndrWithKind tv name } - ; th_univs <- repListM tyVarBndrSpecTyConName rep_in_scope_tv univs - ; th_exis <- repListM tyVarBndrSpecTyConName rep_in_scope_tv exis - - -- NB: Don't pass any implicit type variables to repList above - -- See Note [Don't quantify implicit type variables in quotes] + ; th_univs <- rep_ty_sig_tvs univs + ; th_exis <- rep_ty_sig_tvs exis ; th_reqs <- repLContext reqs ; th_provs <- repLContext provs @@ -1253,10 +1267,6 @@ repHsSigType (HsIB { hsib_ext = implicit_tvs then return th_ty else repTForall th_explicit_tvs th_ctxt th_ty } -repHsSigWcType :: LHsSigWcType GhcRn -> MetaM (Core (M TH.Type)) -repHsSigWcType (HsWC { hswc_body = sig1 }) - = repHsSigType sig1 - -- yield the representation of a list of types repLTys :: [LHsType GhcRn] -> MetaM [Core (M TH.Type)] repLTys tys = mapM repLTy tys @@ -1528,10 +1538,13 @@ repE (RecordUpd { rupd_expr = e, rupd_flds = flds }) fs <- repUpdFields flds; repRecUpd x fs } -repE (ExprWithTySig _ e ty) - = do { e1 <- repLE e - ; t1 <- repHsSigWcType ty +repE (ExprWithTySig _ e wc_ty) + = addSimpleTyVarBinds (get_scoped_tvs_from_sig sig_ty) $ + do { e1 <- repLE e + ; t1 <- rep_ty_sig' sig_ty ; repSigExp e1 t1 } + where + sig_ty = dropWildCards wc_ty repE (ArithSeq _ _ aseq) = case aseq of @@ -1734,7 +1747,7 @@ repBinds (HsValBinds _ decs) -- the binding group, because we are talking Names -- here, so we can safely treat it as a mutually -- recursive group - -- For hsScopedTvBinders see Note [Scoped type variables in bindings] + -- For hsScopedTvBinders see Note [Scoped type variables in quotes] ; ss <- mkGenSyms bndrs ; prs <- addBinds ss (rep_val_binds decs) ; core_list <- coreListM decTyConName @@ -2427,18 +2440,21 @@ repInst (MkC o) (MkC cxt) (MkC ty) (MkC ds) = rep2 instanceWithOverlapDName [o, cxt, ty, ds] repDerivStrategy :: Maybe (LDerivStrategy GhcRn) - -> MetaM (Core (Maybe (M TH.DerivStrategy))) -repDerivStrategy mds = + -> (Core (Maybe (M TH.DerivStrategy)) -> MetaM (Core (M a))) + -> MetaM (Core (M a)) +repDerivStrategy mds thing_inside = case mds of - Nothing -> nothing + Nothing -> thing_inside =<< nothing Just ds -> case unLoc ds of - StockStrategy -> just =<< repStockStrategy - AnyclassStrategy -> just =<< repAnyclassStrategy - NewtypeStrategy -> just =<< repNewtypeStrategy - ViaStrategy ty -> do ty' <- repLTy (hsSigType ty) + StockStrategy -> thing_inside =<< just =<< repStockStrategy + AnyclassStrategy -> thing_inside =<< just =<< repAnyclassStrategy + NewtypeStrategy -> thing_inside =<< just =<< repNewtypeStrategy + ViaStrategy ty -> addSimpleTyVarBinds (get_scoped_tvs_from_sig ty) $ + do ty' <- rep_ty_sig' ty via_strat <- repViaStrategy ty' - just via_strat + m_via_strat <- just via_strat + thing_inside m_via_strat where nothing = coreNothingM derivStrategyTyConName just = coreJustM derivStrategyTyConName ===================================== compiler/GHC/Parser.y ===================================== @@ -93,7 +93,7 @@ import GHC.Builtin.Types ( unitTyCon, unitDataCon, tupleTyCon, tupleDataCon, nil manyDataConTyCon) } -%expect 232 -- shift/reduce conflicts +%expect 234 -- shift/reduce conflicts {- Last updated: 08 June 2020 @@ -553,6 +553,7 @@ are the most common patterns, rewritten as regular expressions for clarity: '-' { L _ ITminus } PREFIX_TILDE { L _ ITtilde } PREFIX_BANG { L _ ITbang } + PREFIX_MINUS { L _ ITprefixminus } '*' { L _ (ITstar _) } '-<' { L _ (ITlarrowtail _) } -- for arrow notation '>-' { L _ (ITrarrowtail _) } -- for arrow notation @@ -703,10 +704,21 @@ litpkgname_segment :: { Located FastString } | CONID { sL1 $1 $ getCONID $1 } | special_id { $1 } +-- Parse a minus sign regardless of whether -XLexicalNegation is turned on or off. +-- See Note [Minus tokens] in GHC.Parser.Lexer +HYPHEN :: { [AddAnn] } + : '-' { [mj AnnMinus $1 ] } + | PREFIX_MINUS { [mj AnnMinus $1 ] } + | VARSYM {% if (getVARSYM $1 == fsLit "-") + then return [mj AnnMinus $1] + else do { addError (getLoc $1) $ text "Expected a hyphen" + ; return [] } } + + litpkgname :: { Located FastString } : litpkgname_segment { $1 } -- a bit of a hack, means p - b is parsed same as p-b, enough for now. - | litpkgname_segment '-' litpkgname { sLL $1 $> $ appendFS (unLoc $1) (consFS '-' (unLoc $3)) } + | litpkgname_segment HYPHEN litpkgname { sLL $1 $> $ appendFS (unLoc $1) (consFS '-' (unLoc $3)) } mayberns :: { Maybe [LRenaming] } : {- empty -} { Nothing } @@ -2738,12 +2750,12 @@ prag_e :: { Located ([AddAnn], HsPragE GhcPs) } HsPragSCC noExtField (getSCC_PRAGs $1) (StringLiteral NoSourceText (getVARID $2))) } - | '{-# GENERATED' STRING INTEGER ':' INTEGER '-' INTEGER ':' INTEGER '#-}' + | '{-# GENERATED' STRING INTEGER ':' INTEGER HYPHEN INTEGER ':' INTEGER '#-}' { let getINT = fromInteger . il_value . getINTEGER in sLL $1 $> $ ([mo $1,mj AnnVal $2 ,mj AnnVal $3,mj AnnColon $4 - ,mj AnnVal $5,mj AnnMinus $6 - ,mj AnnVal $7,mj AnnColon $8 + ,mj AnnVal $5] ++ $6 ++ + [mj AnnVal $7,mj AnnColon $8 ,mj AnnVal $9,mc $10], HsPragTick noExtField (getGENERATED_PRAGs $1) @@ -2789,6 +2801,9 @@ aexp :: { ECP } | PREFIX_BANG aexp { ECP $ runECP_PV $2 >>= \ $2 -> amms (mkHsBangPatPV (comb2 $1 $>) $2) [mj AnnBang $1] } + | PREFIX_MINUS aexp { ECP $ + runECP_PV $2 >>= \ $2 -> + amms (mkHsNegAppPV (comb2 $1 $>) $2) [mj AnnMinus $1] } | '\\' apat apats '->' exp { ECP $ ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -505,19 +505,19 @@ $tab { warnTab } 0[bB] @numspc @binary / { ifExtension BinaryLiteralsBit } { tok_num positive 2 2 binary } 0[oO] @numspc @octal { tok_num positive 2 2 octal } 0[xX] @numspc @hexadecimal { tok_num positive 2 2 hexadecimal } - @negative @decimal / { ifExtension NegativeLiteralsBit } { tok_num negative 1 1 decimal } - @negative 0[bB] @numspc @binary / { ifExtension NegativeLiteralsBit `alexAndPred` + @negative @decimal / { negLitPred } { tok_num negative 1 1 decimal } + @negative 0[bB] @numspc @binary / { negLitPred `alexAndPred` ifExtension BinaryLiteralsBit } { tok_num negative 3 3 binary } - @negative 0[oO] @numspc @octal / { ifExtension NegativeLiteralsBit } { tok_num negative 3 3 octal } - @negative 0[xX] @numspc @hexadecimal / { ifExtension NegativeLiteralsBit } { tok_num negative 3 3 hexadecimal } + @negative 0[oO] @numspc @octal / { negLitPred } { tok_num negative 3 3 octal } + @negative 0[xX] @numspc @hexadecimal / { negLitPred } { tok_num negative 3 3 hexadecimal } -- Normal rational literals (:: Fractional a => a, from Rational) @floating_point { tok_frac 0 tok_float } - @negative @floating_point / { ifExtension NegativeLiteralsBit } { tok_frac 0 tok_float } + @negative @floating_point / { negLitPred } { tok_frac 0 tok_float } 0[xX] @numspc @hex_floating_point / { ifExtension HexFloatLiteralsBit } { tok_frac 0 tok_hex_float } @negative 0[xX] @numspc @hex_floating_point / { ifExtension HexFloatLiteralsBit `alexAndPred` - ifExtension NegativeLiteralsBit } { tok_frac 0 tok_hex_float } + negLitPred } { tok_frac 0 tok_hex_float } } <0> { @@ -771,7 +771,8 @@ data Token | ITrarrow IsUnicodeSyntax | ITlolly IsUnicodeSyntax | ITdarrow IsUnicodeSyntax - | ITminus + | ITminus -- See Note [Minus tokens] + | ITprefixminus -- See Note [Minus tokens] | ITbang -- Prefix (!) only, e.g. f !x = rhs | ITtilde -- Prefix (~) only, e.g. f ~x = rhs | ITat -- Tight infix (@) only, e.g. f x at pat = rhs @@ -871,6 +872,37 @@ instance Outputable Token where ppr x = text (show x) +{- Note [Minus tokens] +~~~~~~~~~~~~~~~~~~~~~~ +A minus sign can be used in prefix form (-x) and infix form (a - b). + +When LexicalNegation is on: + * ITprefixminus represents the prefix form + * ITvarsym "-" represents the infix form + * ITminus is not used + +When LexicalNegation is off: + * ITminus represents all forms + * ITprefixminus is not used + * ITvarsym "-" is not used +-} + +{- Note [Why not LexicalNegationBit] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +One might wonder why we define NoLexicalNegationBit instead of +LexicalNegationBit. The problem lies in the following line in reservedSymsFM: + + ,("-", ITminus, NormalSyntax, xbit NoLexicalNegationBit) + +We want to generate ITminus only when LexicalNegation is off. How would one +do it if we had LexicalNegationBit? I (int-index) tried to use bitwise +complement: + + ,("-", ITminus, NormalSyntax, complement (xbit LexicalNegationBit)) + +This did not work, so I opted for NoLexicalNegationBit instead. +-} + -- the bitmap provided as the third component indicates whether the -- corresponding extension keyword is valid under the extension options @@ -975,7 +1007,7 @@ reservedSymsFM = listToUFM $ ,("<-", ITlarrow NormalSyntax, NormalSyntax, 0 ) ,("->", ITrarrow NormalSyntax, NormalSyntax, 0 ) ,("=>", ITdarrow NormalSyntax, NormalSyntax, 0 ) - ,("-", ITminus, NormalSyntax, 0 ) + ,("-", ITminus, NormalSyntax, xbit NoLexicalNegationBit) ,("*", ITstar NormalSyntax, NormalSyntax, xbit StarIsTypeBit) @@ -1156,6 +1188,27 @@ afterOptionalSpace buf p atEOL :: AlexAccPred ExtsBitmap atEOL _ _ _ (AI _ buf) = atEnd buf || currentChar buf == '\n' +-- Check if we should parse a negative literal (e.g. -123) as a single token. +negLitPred :: AlexAccPred ExtsBitmap +negLitPred = + negative_literals `alexOrPred` + (lexical_negation `alexAndPred` prefix_minus) + where + negative_literals = ifExtension NegativeLiteralsBit + + lexical_negation = + -- See Note [Why not LexicalNegationBit] + alexNotPred (ifExtension NoLexicalNegationBit) + + prefix_minus = + -- The condition for a prefix occurrence of an operator is: + -- + -- not precededByClosingToken && followedByOpeningToken + -- + -- but we don't check followedByOpeningToken here as it holds + -- simply because we immediately lex a literal after the minus. + alexNotPred precededByClosingToken + ifExtension :: ExtBits -> AlexAccPred ExtsBitmap ifExtension extBits bits _ _ _ = extBits `xtest` bits @@ -1483,6 +1536,9 @@ varsym_prefix = sym $ \exts s -> -> return ITdollar | ThQuotesBit `xtest` exts, s == fsLit "$$" -> return ITdollardollar + | s == fsLit "-" -- Only when LexicalNegation is on, otherwise we get ITminus and + -- don't hit this code path. See Note [Minus tokens] + -> return ITprefixminus | s == fsLit "!" -> return ITbang | s == fsLit "~" -> return ITtilde | otherwise -> return (ITvarsym s) @@ -2500,6 +2556,7 @@ data ExtBits | GadtSyntaxBit | ImportQualifiedPostBit | LinearTypesBit + | NoLexicalNegationBit -- See Note [Why not LexicalNegationBit] -- Flags that are updated once parsing starts | InRulePragBit @@ -2588,12 +2645,14 @@ mkParserFlags' warningFlags extensionFlags homeUnitId .|. GadtSyntaxBit `xoptBit` LangExt.GADTSyntax .|. ImportQualifiedPostBit `xoptBit` LangExt.ImportQualifiedPost .|. LinearTypesBit `xoptBit` LangExt.LinearTypes + .|. NoLexicalNegationBit `xoptNotBit` LangExt.LexicalNegation -- See Note [Why not LexicalNegationBit] optBits = HaddockBit `setBitIf` isHaddock .|. RawTokenStreamBit `setBitIf` rawTokStream .|. UsePosPragsBit `setBitIf` usePosPrags xoptBit bit ext = bit `setBitIf` EnumSet.member ext extensionFlags + xoptNotBit bit ext = bit `setBitIf` not (EnumSet.member ext extensionFlags) setBitIf :: ExtBits -> Bool -> ExtsBitmap b `setBitIf` cond | cond = xbit b ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -203,6 +203,16 @@ Language See :ref:`qualified-do-notation` for more details. +* :extension:`LexicalNegation` is a new extension that detects whether the + minus sign stands for negation during lexical analysis by checking for the + surrounding whitespace: :: + + a = x - y -- subtraction + b = f -x -- negation + + f = (- x) -- operator section + c = (-x) -- negation + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/lexical_negation.rst ===================================== @@ -0,0 +1,57 @@ +.. _lexical-negation: + +Lexical negation +---------------- + +.. extension:: LexicalNegation + :shortdesc: Use whitespace to determine whether the minus sign stands for + negation or subtraction. + + :since: 8.12.1 + + Detect if the minus sign stands for negation during lexical analysis by + checking for the surrounding whitespace. + +In Haskell 2010, the minus sign stands for negation when it has no left-hand +side. Consider ``x = - 5`` and ``y = 2 - 5``. In ``x``, there's no expression +between the ``=`` and ``-``, so the minus stands for negation, whereas in +``y``, there's ``2`` to the left of the minus, therefore it stands for +subtraction. + +This leads to certain syntactic anomalies: + +* ``(% x)`` is an operator section for any operator ``(%)`` except for ``(-)``. + ``(- x)`` is negated ``x`` rather than the right operator section of + subtraction. Consequently, it is impossible to write such a section, and + users are advised to write ``(subtract x)`` instead. + +* Negative numbers must be parenthesized when they appear in function argument + position. ``f (-5)`` is correct, whereas ``f -5`` is parsed as ``(-) f 5``. + +The latter issue is partly mitigated by :extension:`NegativeLiterals`. When it +is enabled, ``-5`` is parsed as negative 5 regardless of context, so ``f +-5`` works as expected. However, it only applies to literals, so ``f -x`` or +``f -(a*2)`` are still parsed as subtraction. + +With :extension:`LexicalNegation`, both anomalies are resolved: + +* ``(% x)`` is an operator section for any operator ``(%)``, no exceptions, as + long as there's whitespace between ``%`` and ``x``. + +* In ``f -x``, the ``-x`` is parsed as the negation of ``x`` for any + syntactically atomic expression ``x`` (variable, literal, or parenthesized + expression). + +* The prefix ``-`` binds tighter than any infix operator. ``-a % b`` is parsed + as ``(-a) % b`` regardless of the fixity of ``%``. + +This means that ``(- x)`` is the right operator section of subtraction, whereas +``(-x)`` is the negation of ``x``. Note that these expressions will often have +different types (``(- x)`` might have type ``Int -> Int`` while ``(-x)`` will +have type ``Int``), and so users mistaking one for the other will likely get a +compile error. + +Under :extension:`LexicalNegation`, negated literals are desugared without +``negate``. That is, ``-123`` stands for ``fromInteger (-123)`` rather than +``negate (fromInteger 123)``. This makes :extension:`LexicalNegation` a valid +replacement for :extension:`NegativeLiterals`. ===================================== docs/users_guide/exts/negative_literals.rst ===================================== @@ -27,5 +27,6 @@ as two tokens. One pitfall is that with :extension:`NegativeLiterals`, ``x-1`` will be parsed as ``x`` applied to the argument ``-1``, which is usually not what you want. ``x - 1`` or even ``x- 1`` can be used instead -for subtraction. +for subtraction. To avoid this, consider using :extension:`LexicalNegation` +instead. ===================================== docs/users_guide/exts/syntax.rst ===================================== @@ -25,3 +25,4 @@ Syntax block_arguments typed_holes arrows + lexical_negation ===================================== libraries/base/Data/Fixed.hs ===================================== @@ -94,6 +94,64 @@ withResolution :: (HasResolution a) => (Integer -> f a) -> f a withResolution foo = withType (foo . resolution) -- | @since 2.01 +-- +-- Recall that, for numeric types, 'succ' and 'pred' typically add and subtract +-- @1@, respectively. This is not true in the case of 'Fixed', whose successor +-- and predecessor functions intuitively return the "next" and "previous" values +-- in the enumeration. The results of these functions thus depend on the +-- resolution of the 'Fixed' value. For example, when enumerating values of +-- resolution @10^-3@ of @type Milli = Fixed E3@, +-- +-- @ +-- succ (0.000 :: Milli) == 1.001 +-- @ +-- +-- +-- and likewise +-- +-- @ +-- pred (0.000 :: Milli) == -0.001 +-- @ +-- +-- +-- In other words, 'succ' and 'pred' increment and decrement a fixed-precision +-- value by the least amount such that the value's resolution is unchanged. +-- For example, @10^-12@ is the smallest (positive) amount that can be added to +-- a value of @type Pico = Fixed E12@ without changing its resolution, and so +-- +-- @ +-- succ (0.000000000000 :: Pico) == 0.000000000001 +-- @ +-- +-- +-- and similarly +-- +-- @ +-- pred (0.000000000000 :: Pico) == -0.000000000001 +-- @ +-- +-- +-- This is worth bearing in mind when defining 'Fixed' arithmetic sequences. In +-- particular, you may be forgiven for thinking the sequence +-- +-- @ +-- [1..10] :: [Pico] +-- @ +-- +-- +-- evaluates to @[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] :: [Pico]@. +-- +-- However, this is not true. On the contrary, similarly to the above +-- implementations of 'succ' and 'pred', @enumFromTo :: Pico -> Pico -> [Pico]@ +-- has a "step size" of @10^-12 at . Hence, the list @[1..10] :: [Pico]@ has +-- the form +-- +-- @ +-- [1.000000000000, 1.00000000001, 1.00000000002, ..., 10.000000000000] +-- @ +-- +-- +-- and contains @9 * 10^12 + 1@ values. instance Enum (Fixed a) where succ (MkFixed a) = MkFixed (succ a) pred (MkFixed a) = MkFixed (pred a) ===================================== libraries/base/System/Info.hs ===================================== @@ -11,9 +11,11 @@ -- Stability : experimental -- Portability : portable -- --- Information about the characteristics of the host +-- Information about the characteristics of the host -- system lucky enough to run your program. -- +-- For a comprehensive listing of supported platforms, please refer to +-- https://gitlab.haskell.org/ghc/ghc/-/wikis/platforms ----------------------------------------------------------------------------- module System.Info @@ -28,6 +30,10 @@ import Data.Version -- | The version of 'compilerName' with which the program was compiled -- or is being interpreted. +-- +-- ==== __Example__ +-- > ghci> compilerVersion +-- > Version {versionBranch = [8,8], versionTags = []} compilerVersion :: Version compilerVersion = Version [major, minor] [] where (major, minor) = compilerVersionRaw `divMod` 100 @@ -35,15 +41,52 @@ compilerVersion = Version [major, minor] [] #include "ghcplatform.h" -- | The operating system on which the program is running. +-- Common values include: +-- +-- * "darwin" — macOS +-- * "freebsd" +-- * "linux" +-- * "linux-android" +-- * "mingw32" — Windows +-- * "netbsd" +-- * "openbsd" os :: String os = HOST_OS -- | The machine architecture on which the program is running. +-- Common values include: +-- +-- * "aarch64" +-- * "alpha" +-- * "arm" +-- * "hppa" +-- * "hppa1_1" +-- * "i386" +-- * "ia64" +-- * "m68k" +-- * "mips" +-- * "mipseb" +-- * "mipsel" +-- * "nios2" +-- * "powerpc" +-- * "powerpc64" +-- * "powerpc64le" +-- * "riscv32" +-- * "riscv64" +-- * "rs6000" +-- * "s390" +-- * "s390x" +-- * "sh4" +-- * "sparc" +-- * "sparc64" +-- * "vax" +-- * "x86_64" arch :: String arch = HOST_ARCH -- | The Haskell implementation with which the program was compiled -- or is being interpreted. +-- On the GHC platform, the value is "ghc". compilerName :: String compilerName = "ghc" ===================================== libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs ===================================== @@ -146,6 +146,7 @@ data Extension | ImportQualifiedPost | CUSKs | StandaloneKindSignatures + | LexicalNegation deriving (Eq, Enum, Show, Generic, Bounded) -- 'Ord' and 'Bounded' are provided for GHC API users (see discussions -- in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 and ===================================== testsuite/tests/driver/T4437.hs ===================================== @@ -42,6 +42,7 @@ expectedGhcOnlyExtensions = , "AlternativeLayoutRuleTransitional" , "LinearTypes" , "QualifiedDo" + , "LexicalNegation" ] expectedCabalOnlyExtensions :: [String] ===================================== testsuite/tests/parser/should_compile/LexNegVsNegLit.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE NegativeLiterals, LexicalNegation #-} + +module LexNegVsNegLit where + +-- NegativeLiterals specifies that we parse x-1 as x (-1), even though it's +-- considered a shortcoming. +-- +-- LexicalNegation does not change that. +-- +b :: Bool +b = even-1 -- parsed as: even (-1) + -- so it is well-typed. + -- + -- with LexicalNegation alone, we'd get (-) even 1, + -- but NegativeLiterals takes precedence here. + +-- See also: GHC Proposal #344 ===================================== testsuite/tests/parser/should_compile/LexicalNegation.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE LexicalNegation #-} + +module LexicalNegation where + +x :: Int +x = 42 + +negx :: Int +negx = f -x where f = (- 5) + +subx :: Int -> Int +subx = (- x) + +assertion1 :: Bool +assertion1 = (- x) -x == -(2*x) ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -152,6 +152,8 @@ test('proposal-229a', normal, compile, ['']) test('proposal-229b', normal, compile, ['']) test('proposal-229d', normal, compile, ['']) test('proposal-229e', normal, compile, ['']) +test('LexicalNegation', normal, compile, ['']) +test('LexNegVsNegLit', normal, compile, ['']) # We omit 'profasm' because it fails with: # Cannot load -prof objects when GHC is built with -dynamic ===================================== testsuite/tests/parser/should_run/LexNegLit.hs ===================================== @@ -0,0 +1,26 @@ +{-# LANGUAGE LexicalNegation #-} + +data FreeNum + = FromInteger Integer + | FromRational Rational + | Negate FreeNum + | FreeNum `Subtract` FreeNum + deriving (Show) + +instance Num FreeNum where + fromInteger = FromInteger + negate = Negate + (-) = Subtract + +instance Fractional FreeNum where + fromRational = FromRational + +main = do + print (-123 :: FreeNum) + print (-1.5 :: FreeNum) + print (let x = 5 in -x :: FreeNum) + print (5-1 :: FreeNum) -- unlike NegativeLiterals, we parse it as (5 - 1), not (5 (-1)) + print (-0 :: FreeNum) + print (-0.0 :: FreeNum) + print (-0o10 :: FreeNum) + print (-0x10 :: FreeNum) ===================================== testsuite/tests/parser/should_run/LexNegLit.stdout ===================================== @@ -0,0 +1,8 @@ +FromInteger (-123) +FromRational ((-3) % 2) +Negate (FromInteger 5) +FromInteger 5 `Subtract` FromInteger 1 +Negate (FromInteger 0) +Negate (FromRational (0 % 1)) +FromInteger (-8) +FromInteger (-16) ===================================== testsuite/tests/parser/should_run/all.T ===================================== @@ -18,3 +18,4 @@ test('CountParserDeps', [ only_ways(['normal']), extra_run_opts('"' + config.libdir + '"') ], compile_and_run, ['-package ghc']) +test('LexNegLit', normal, compile_and_run, ['']) ===================================== testsuite/tests/th/T18388.hs ===================================== @@ -0,0 +1,29 @@ +{-# LANGUAGE DerivingVia #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeApplications #-} +module T18388 where + +class C x y where + m :: x -> y -> y + +newtype Tagged x a = MkTagged a +instance C x (Tagged x a) where + m _ = id + +$([d| newtype Id1 a = MkId1 a + deriving (C x) via forall x. Tagged x a + + newtype Id2 a = MkId2 a + deriving (C x) via Tagged x a + |]) + +newtype List1 a = MkList1 [a] +newtype List2 a = MkList2 [a] +$([d| deriving via forall a. [a] instance Eq a => Eq (List1 a) |]) +$([d| deriving via [a] instance Eq a => Eq (List2 a) |]) + +$([d| f = id @a :: forall a. a -> a |]) ===================================== testsuite/tests/th/all.T ===================================== @@ -510,3 +510,4 @@ test('TH_StringLift', normal, compile, ['']) test('TH_BytesShowEqOrd', normal, compile_and_run, ['']) test('T18121', normal, compile, ['']) test('T18123', normal, compile, ['']) +test('T18388', normal, compile, ['']) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 54ed6ae2556dc787916e2d56ce0e99808af14e61 +Subproject commit 9bd65ee47a43529af2ad8e350fdd0c372bc5964c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/85310fb83fdb7d7294bd453026102fc42000bf14...a19466b036afae760728876855b434635314c4da -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/85310fb83fdb7d7294bd453026102fc42000bf14...a19466b036afae760728876855b434635314c4da You're receiving 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 Jul 1 11:42:11 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Wed, 01 Jul 2020 07:42:11 -0400 Subject: [Git][ghc/ghc][wip/andreask/T16012] 33 commits: Enable large address space optimization on windows. Message-ID: <5efc769397cae_80b3f84956d5b881135830@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/T16012 at Glasgow Haskell Compiler / GHC Commits: 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - c33d78ee by Andreas Klebinger at 2020-07-01T07:42:09-04:00 T16012: Be verbose on failure. - - - - - 30 changed files: - .gitlab/test-metrics.sh - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/SPARC/CodeGen/Base.hs - compiler/GHC/CmmToAsm/SPARC/Regs.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Class.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d7c4b3261ca22ee66103474ca31f5ff53d607169...c33d78ee4940e8b399fb0e09fc3bd9e9488b206f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d7c4b3261ca22ee66103474ca31f5ff53d607169...c33d78ee4940e8b399fb0e09fc3bd9e9488b206f You're receiving 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 Jul 1 12:05:24 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Wed, 01 Jul 2020 08:05:24 -0400 Subject: [Git][ghc/ghc][wip/andreask/typedUniqFM] Give Uniq[D]FM a phantom type for its key. Message-ID: <5efc7c04b9963_80bd7d702811374d4@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/typedUniqFM at Glasgow Haskell Compiler / GHC Commits: 3c78cbe7 by Andreas Klebinger at 2020-07-01T14:04:13+02:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - 30 changed files: - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Data/FastString/Env.hs - compiler/GHC/Data/Graph/Base.hs - compiler/GHC/Data/Graph/Color.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c78cbe71f7a2a20d8e444578a93c155afd856ee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c78cbe71f7a2a20d8e444578a93c155afd856ee You're receiving 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 Jul 1 12:07:28 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Wed, 01 Jul 2020 08:07:28 -0400 Subject: [Git][ghc/ghc][wip/andreask/typedUniqFM] Give Uniq[D]FM a phantom type for its key. Message-ID: <5efc7c80a8de0_80b3f84956d5b88113832@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/typedUniqFM at Glasgow Haskell Compiler / GHC Commits: 84bf48a4 by Andreas Klebinger at 2020-07-01T14:07:17+02:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - 30 changed files: - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Data/FastString/Env.hs - compiler/GHC/Data/Graph/Base.hs - compiler/GHC/Data/Graph/Color.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84bf48a488b9972505bfa9270f095d846a2917e1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84bf48a488b9972505bfa9270f095d846a2917e1 You're receiving 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 Jul 1 12:14:02 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Wed, 01 Jul 2020 08:14:02 -0400 Subject: [Git][ghc/ghc][wip/andreask/ghc-bangs] Also enable ScopedTypeVariables Message-ID: <5efc7e0a21ec4_80b3f8494c8fea8114217d@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/ghc-bangs at Glasgow Haskell Compiler / GHC Commits: c7258cd7 by Andreas Klebinger at 2020-07-01T14:13:50+02:00 Also enable ScopedTypeVariables - - - - - 2 changed files: - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -96,9 +96,6 @@ Library if flag(dynamic-system-linker) CPP-Options: -DCAN_LOAD_DLL - Default-Extensions: - BangPatterns - Other-Extensions: CPP DataKinds @@ -118,7 +115,6 @@ Library NondecreasingIndentation RankNTypes RecordWildCards - ScopedTypeVariables StandaloneDeriving Trustworthy TupleSections @@ -155,6 +151,8 @@ Library -- we use an explicit Prelude Default-Extensions: NoImplicitPrelude + ,BangPatterns + ,ScopedTypeVariables Exposed-Modules: GHC.Iface.Ext.Types ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -73,8 +73,6 @@ Executable ghc GHCi.UI.Monad GHCi.UI.Tags GHCi.Util - Default-Extensions: - BangPatterns Other-Extensions: FlexibleInstances LambdaCase @@ -103,3 +101,5 @@ Executable ghc -- GHCi can be used to load it all at once. Default-Extensions: NoImplicitPrelude + , ScopedTypeVariables + , BangPatterns \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c7258cd7fa9912fd8c362a10a47fdc2580cd26ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c7258cd7fa9912fd8c362a10a47fdc2580cd26ce You're receiving 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 Jul 1 15:56:36 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Wed, 01 Jul 2020 11:56:36 -0400 Subject: [Git][ghc/ghc][wip/haddock-accum] Accumulate Haddock comments in P (#17544, #17561, #8944) Message-ID: <5efcb23484357_80b3f84956d5b8811853a@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/haddock-accum at Glasgow Haskell Compiler / GHC Commits: 1c26dc4c by Vladislav Zavialov at 2020-07-01T18:56:09+03:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 22 changed files: - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/Stats.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Utils/Misc.hs - docs/users_guide/using-warnings.rst - testsuite/tests/ghc-api/T11579.hs - testsuite/tests/ghc-api/T11579.stdout - testsuite/tests/ghc-api/annotations/comments.stdout - testsuite/tests/haddock/should_compile_flag_haddock/T11768.hs - testsuite/tests/haddock/should_compile_flag_haddock/T11768.stderr - + testsuite/tests/haddock/should_compile_flag_haddock/T17544.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c26dc4caab798d9e1b70782841276e7702e76c3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c26dc4caab798d9e1b70782841276e7702e76c3 You're receiving 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 Jul 1 19:41:45 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 01 Jul 2020 15:41:45 -0400 Subject: [Git][ghc/ghc][master] Implement -XLexicalNegation (GHC Proposal #229) Message-ID: <5efce6f9666ff_80b3f846a54be3c1219083@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - 16 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - docs/users_guide/8.12.1-notes.rst - + docs/users_guide/exts/lexical_negation.rst - docs/users_guide/exts/negative_literals.rst - docs/users_guide/exts/syntax.rst - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - testsuite/tests/driver/T4437.hs - + testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/LexicalNegation.hs - testsuite/tests/parser/should_compile/all.T - + testsuite/tests/parser/should_run/LexNegLit.hs - + testsuite/tests/parser/should_run/LexNegLit.stdout - testsuite/tests/parser/should_run/all.T - utils/haddock Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3784,6 +3784,7 @@ xFlagsDeps = [ flagSpec "JavaScriptFFI" LangExt.JavaScriptFFI, flagSpec "KindSignatures" LangExt.KindSignatures, flagSpec "LambdaCase" LangExt.LambdaCase, + flagSpec "LexicalNegation" LangExt.LexicalNegation, flagSpec "LiberalTypeSynonyms" LangExt.LiberalTypeSynonyms, flagSpec "LinearTypes" LangExt.LinearTypes, flagSpec "MagicHash" LangExt.MagicHash, ===================================== compiler/GHC/Parser.y ===================================== @@ -93,7 +93,7 @@ import GHC.Builtin.Types ( unitTyCon, unitDataCon, tupleTyCon, tupleDataCon, nil manyDataConTyCon) } -%expect 232 -- shift/reduce conflicts +%expect 234 -- shift/reduce conflicts {- Last updated: 08 June 2020 @@ -553,6 +553,7 @@ are the most common patterns, rewritten as regular expressions for clarity: '-' { L _ ITminus } PREFIX_TILDE { L _ ITtilde } PREFIX_BANG { L _ ITbang } + PREFIX_MINUS { L _ ITprefixminus } '*' { L _ (ITstar _) } '-<' { L _ (ITlarrowtail _) } -- for arrow notation '>-' { L _ (ITrarrowtail _) } -- for arrow notation @@ -703,10 +704,21 @@ litpkgname_segment :: { Located FastString } | CONID { sL1 $1 $ getCONID $1 } | special_id { $1 } +-- Parse a minus sign regardless of whether -XLexicalNegation is turned on or off. +-- See Note [Minus tokens] in GHC.Parser.Lexer +HYPHEN :: { [AddAnn] } + : '-' { [mj AnnMinus $1 ] } + | PREFIX_MINUS { [mj AnnMinus $1 ] } + | VARSYM {% if (getVARSYM $1 == fsLit "-") + then return [mj AnnMinus $1] + else do { addError (getLoc $1) $ text "Expected a hyphen" + ; return [] } } + + litpkgname :: { Located FastString } : litpkgname_segment { $1 } -- a bit of a hack, means p - b is parsed same as p-b, enough for now. - | litpkgname_segment '-' litpkgname { sLL $1 $> $ appendFS (unLoc $1) (consFS '-' (unLoc $3)) } + | litpkgname_segment HYPHEN litpkgname { sLL $1 $> $ appendFS (unLoc $1) (consFS '-' (unLoc $3)) } mayberns :: { Maybe [LRenaming] } : {- empty -} { Nothing } @@ -2738,12 +2750,12 @@ prag_e :: { Located ([AddAnn], HsPragE GhcPs) } HsPragSCC noExtField (getSCC_PRAGs $1) (StringLiteral NoSourceText (getVARID $2))) } - | '{-# GENERATED' STRING INTEGER ':' INTEGER '-' INTEGER ':' INTEGER '#-}' + | '{-# GENERATED' STRING INTEGER ':' INTEGER HYPHEN INTEGER ':' INTEGER '#-}' { let getINT = fromInteger . il_value . getINTEGER in sLL $1 $> $ ([mo $1,mj AnnVal $2 ,mj AnnVal $3,mj AnnColon $4 - ,mj AnnVal $5,mj AnnMinus $6 - ,mj AnnVal $7,mj AnnColon $8 + ,mj AnnVal $5] ++ $6 ++ + [mj AnnVal $7,mj AnnColon $8 ,mj AnnVal $9,mc $10], HsPragTick noExtField (getGENERATED_PRAGs $1) @@ -2789,6 +2801,9 @@ aexp :: { ECP } | PREFIX_BANG aexp { ECP $ runECP_PV $2 >>= \ $2 -> amms (mkHsBangPatPV (comb2 $1 $>) $2) [mj AnnBang $1] } + | PREFIX_MINUS aexp { ECP $ + runECP_PV $2 >>= \ $2 -> + amms (mkHsNegAppPV (comb2 $1 $>) $2) [mj AnnMinus $1] } | '\\' apat apats '->' exp { ECP $ ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -505,19 +505,19 @@ $tab { warnTab } 0[bB] @numspc @binary / { ifExtension BinaryLiteralsBit } { tok_num positive 2 2 binary } 0[oO] @numspc @octal { tok_num positive 2 2 octal } 0[xX] @numspc @hexadecimal { tok_num positive 2 2 hexadecimal } - @negative @decimal / { ifExtension NegativeLiteralsBit } { tok_num negative 1 1 decimal } - @negative 0[bB] @numspc @binary / { ifExtension NegativeLiteralsBit `alexAndPred` + @negative @decimal / { negLitPred } { tok_num negative 1 1 decimal } + @negative 0[bB] @numspc @binary / { negLitPred `alexAndPred` ifExtension BinaryLiteralsBit } { tok_num negative 3 3 binary } - @negative 0[oO] @numspc @octal / { ifExtension NegativeLiteralsBit } { tok_num negative 3 3 octal } - @negative 0[xX] @numspc @hexadecimal / { ifExtension NegativeLiteralsBit } { tok_num negative 3 3 hexadecimal } + @negative 0[oO] @numspc @octal / { negLitPred } { tok_num negative 3 3 octal } + @negative 0[xX] @numspc @hexadecimal / { negLitPred } { tok_num negative 3 3 hexadecimal } -- Normal rational literals (:: Fractional a => a, from Rational) @floating_point { tok_frac 0 tok_float } - @negative @floating_point / { ifExtension NegativeLiteralsBit } { tok_frac 0 tok_float } + @negative @floating_point / { negLitPred } { tok_frac 0 tok_float } 0[xX] @numspc @hex_floating_point / { ifExtension HexFloatLiteralsBit } { tok_frac 0 tok_hex_float } @negative 0[xX] @numspc @hex_floating_point / { ifExtension HexFloatLiteralsBit `alexAndPred` - ifExtension NegativeLiteralsBit } { tok_frac 0 tok_hex_float } + negLitPred } { tok_frac 0 tok_hex_float } } <0> { @@ -771,7 +771,8 @@ data Token | ITrarrow IsUnicodeSyntax | ITlolly IsUnicodeSyntax | ITdarrow IsUnicodeSyntax - | ITminus + | ITminus -- See Note [Minus tokens] + | ITprefixminus -- See Note [Minus tokens] | ITbang -- Prefix (!) only, e.g. f !x = rhs | ITtilde -- Prefix (~) only, e.g. f ~x = rhs | ITat -- Tight infix (@) only, e.g. f x at pat = rhs @@ -871,6 +872,37 @@ instance Outputable Token where ppr x = text (show x) +{- Note [Minus tokens] +~~~~~~~~~~~~~~~~~~~~~~ +A minus sign can be used in prefix form (-x) and infix form (a - b). + +When LexicalNegation is on: + * ITprefixminus represents the prefix form + * ITvarsym "-" represents the infix form + * ITminus is not used + +When LexicalNegation is off: + * ITminus represents all forms + * ITprefixminus is not used + * ITvarsym "-" is not used +-} + +{- Note [Why not LexicalNegationBit] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +One might wonder why we define NoLexicalNegationBit instead of +LexicalNegationBit. The problem lies in the following line in reservedSymsFM: + + ,("-", ITminus, NormalSyntax, xbit NoLexicalNegationBit) + +We want to generate ITminus only when LexicalNegation is off. How would one +do it if we had LexicalNegationBit? I (int-index) tried to use bitwise +complement: + + ,("-", ITminus, NormalSyntax, complement (xbit LexicalNegationBit)) + +This did not work, so I opted for NoLexicalNegationBit instead. +-} + -- the bitmap provided as the third component indicates whether the -- corresponding extension keyword is valid under the extension options @@ -975,7 +1007,7 @@ reservedSymsFM = listToUFM $ ,("<-", ITlarrow NormalSyntax, NormalSyntax, 0 ) ,("->", ITrarrow NormalSyntax, NormalSyntax, 0 ) ,("=>", ITdarrow NormalSyntax, NormalSyntax, 0 ) - ,("-", ITminus, NormalSyntax, 0 ) + ,("-", ITminus, NormalSyntax, xbit NoLexicalNegationBit) ,("*", ITstar NormalSyntax, NormalSyntax, xbit StarIsTypeBit) @@ -1156,6 +1188,27 @@ afterOptionalSpace buf p atEOL :: AlexAccPred ExtsBitmap atEOL _ _ _ (AI _ buf) = atEnd buf || currentChar buf == '\n' +-- Check if we should parse a negative literal (e.g. -123) as a single token. +negLitPred :: AlexAccPred ExtsBitmap +negLitPred = + negative_literals `alexOrPred` + (lexical_negation `alexAndPred` prefix_minus) + where + negative_literals = ifExtension NegativeLiteralsBit + + lexical_negation = + -- See Note [Why not LexicalNegationBit] + alexNotPred (ifExtension NoLexicalNegationBit) + + prefix_minus = + -- The condition for a prefix occurrence of an operator is: + -- + -- not precededByClosingToken && followedByOpeningToken + -- + -- but we don't check followedByOpeningToken here as it holds + -- simply because we immediately lex a literal after the minus. + alexNotPred precededByClosingToken + ifExtension :: ExtBits -> AlexAccPred ExtsBitmap ifExtension extBits bits _ _ _ = extBits `xtest` bits @@ -1483,6 +1536,9 @@ varsym_prefix = sym $ \exts s -> -> return ITdollar | ThQuotesBit `xtest` exts, s == fsLit "$$" -> return ITdollardollar + | s == fsLit "-" -- Only when LexicalNegation is on, otherwise we get ITminus and + -- don't hit this code path. See Note [Minus tokens] + -> return ITprefixminus | s == fsLit "!" -> return ITbang | s == fsLit "~" -> return ITtilde | otherwise -> return (ITvarsym s) @@ -2500,6 +2556,7 @@ data ExtBits | GadtSyntaxBit | ImportQualifiedPostBit | LinearTypesBit + | NoLexicalNegationBit -- See Note [Why not LexicalNegationBit] -- Flags that are updated once parsing starts | InRulePragBit @@ -2588,12 +2645,14 @@ mkParserFlags' warningFlags extensionFlags homeUnitId .|. GadtSyntaxBit `xoptBit` LangExt.GADTSyntax .|. ImportQualifiedPostBit `xoptBit` LangExt.ImportQualifiedPost .|. LinearTypesBit `xoptBit` LangExt.LinearTypes + .|. NoLexicalNegationBit `xoptNotBit` LangExt.LexicalNegation -- See Note [Why not LexicalNegationBit] optBits = HaddockBit `setBitIf` isHaddock .|. RawTokenStreamBit `setBitIf` rawTokStream .|. UsePosPragsBit `setBitIf` usePosPrags xoptBit bit ext = bit `setBitIf` EnumSet.member ext extensionFlags + xoptNotBit bit ext = bit `setBitIf` not (EnumSet.member ext extensionFlags) setBitIf :: ExtBits -> Bool -> ExtsBitmap b `setBitIf` cond | cond = xbit b ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -203,6 +203,16 @@ Language See :ref:`qualified-do-notation` for more details. +* :extension:`LexicalNegation` is a new extension that detects whether the + minus sign stands for negation during lexical analysis by checking for the + surrounding whitespace: :: + + a = x - y -- subtraction + b = f -x -- negation + + f = (- x) -- operator section + c = (-x) -- negation + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/lexical_negation.rst ===================================== @@ -0,0 +1,57 @@ +.. _lexical-negation: + +Lexical negation +---------------- + +.. extension:: LexicalNegation + :shortdesc: Use whitespace to determine whether the minus sign stands for + negation or subtraction. + + :since: 8.12.1 + + Detect if the minus sign stands for negation during lexical analysis by + checking for the surrounding whitespace. + +In Haskell 2010, the minus sign stands for negation when it has no left-hand +side. Consider ``x = - 5`` and ``y = 2 - 5``. In ``x``, there's no expression +between the ``=`` and ``-``, so the minus stands for negation, whereas in +``y``, there's ``2`` to the left of the minus, therefore it stands for +subtraction. + +This leads to certain syntactic anomalies: + +* ``(% x)`` is an operator section for any operator ``(%)`` except for ``(-)``. + ``(- x)`` is negated ``x`` rather than the right operator section of + subtraction. Consequently, it is impossible to write such a section, and + users are advised to write ``(subtract x)`` instead. + +* Negative numbers must be parenthesized when they appear in function argument + position. ``f (-5)`` is correct, whereas ``f -5`` is parsed as ``(-) f 5``. + +The latter issue is partly mitigated by :extension:`NegativeLiterals`. When it +is enabled, ``-5`` is parsed as negative 5 regardless of context, so ``f +-5`` works as expected. However, it only applies to literals, so ``f -x`` or +``f -(a*2)`` are still parsed as subtraction. + +With :extension:`LexicalNegation`, both anomalies are resolved: + +* ``(% x)`` is an operator section for any operator ``(%)``, no exceptions, as + long as there's whitespace between ``%`` and ``x``. + +* In ``f -x``, the ``-x`` is parsed as the negation of ``x`` for any + syntactically atomic expression ``x`` (variable, literal, or parenthesized + expression). + +* The prefix ``-`` binds tighter than any infix operator. ``-a % b`` is parsed + as ``(-a) % b`` regardless of the fixity of ``%``. + +This means that ``(- x)`` is the right operator section of subtraction, whereas +``(-x)`` is the negation of ``x``. Note that these expressions will often have +different types (``(- x)`` might have type ``Int -> Int`` while ``(-x)`` will +have type ``Int``), and so users mistaking one for the other will likely get a +compile error. + +Under :extension:`LexicalNegation`, negated literals are desugared without +``negate``. That is, ``-123`` stands for ``fromInteger (-123)`` rather than +``negate (fromInteger 123)``. This makes :extension:`LexicalNegation` a valid +replacement for :extension:`NegativeLiterals`. ===================================== docs/users_guide/exts/negative_literals.rst ===================================== @@ -27,5 +27,6 @@ as two tokens. One pitfall is that with :extension:`NegativeLiterals`, ``x-1`` will be parsed as ``x`` applied to the argument ``-1``, which is usually not what you want. ``x - 1`` or even ``x- 1`` can be used instead -for subtraction. +for subtraction. To avoid this, consider using :extension:`LexicalNegation` +instead. ===================================== docs/users_guide/exts/syntax.rst ===================================== @@ -25,3 +25,4 @@ Syntax block_arguments typed_holes arrows + lexical_negation ===================================== libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs ===================================== @@ -146,6 +146,7 @@ data Extension | ImportQualifiedPost | CUSKs | StandaloneKindSignatures + | LexicalNegation deriving (Eq, Enum, Show, Generic, Bounded) -- 'Ord' and 'Bounded' are provided for GHC API users (see discussions -- in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 and ===================================== testsuite/tests/driver/T4437.hs ===================================== @@ -42,6 +42,7 @@ expectedGhcOnlyExtensions = , "AlternativeLayoutRuleTransitional" , "LinearTypes" , "QualifiedDo" + , "LexicalNegation" ] expectedCabalOnlyExtensions :: [String] ===================================== testsuite/tests/parser/should_compile/LexNegVsNegLit.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE NegativeLiterals, LexicalNegation #-} + +module LexNegVsNegLit where + +-- NegativeLiterals specifies that we parse x-1 as x (-1), even though it's +-- considered a shortcoming. +-- +-- LexicalNegation does not change that. +-- +b :: Bool +b = even-1 -- parsed as: even (-1) + -- so it is well-typed. + -- + -- with LexicalNegation alone, we'd get (-) even 1, + -- but NegativeLiterals takes precedence here. + +-- See also: GHC Proposal #344 ===================================== testsuite/tests/parser/should_compile/LexicalNegation.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE LexicalNegation #-} + +module LexicalNegation where + +x :: Int +x = 42 + +negx :: Int +negx = f -x where f = (- 5) + +subx :: Int -> Int +subx = (- x) + +assertion1 :: Bool +assertion1 = (- x) -x == -(2*x) ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -152,6 +152,8 @@ test('proposal-229a', normal, compile, ['']) test('proposal-229b', normal, compile, ['']) test('proposal-229d', normal, compile, ['']) test('proposal-229e', normal, compile, ['']) +test('LexicalNegation', normal, compile, ['']) +test('LexNegVsNegLit', normal, compile, ['']) # We omit 'profasm' because it fails with: # Cannot load -prof objects when GHC is built with -dynamic ===================================== testsuite/tests/parser/should_run/LexNegLit.hs ===================================== @@ -0,0 +1,26 @@ +{-# LANGUAGE LexicalNegation #-} + +data FreeNum + = FromInteger Integer + | FromRational Rational + | Negate FreeNum + | FreeNum `Subtract` FreeNum + deriving (Show) + +instance Num FreeNum where + fromInteger = FromInteger + negate = Negate + (-) = Subtract + +instance Fractional FreeNum where + fromRational = FromRational + +main = do + print (-123 :: FreeNum) + print (-1.5 :: FreeNum) + print (let x = 5 in -x :: FreeNum) + print (5-1 :: FreeNum) -- unlike NegativeLiterals, we parse it as (5 - 1), not (5 (-1)) + print (-0 :: FreeNum) + print (-0.0 :: FreeNum) + print (-0o10 :: FreeNum) + print (-0x10 :: FreeNum) ===================================== testsuite/tests/parser/should_run/LexNegLit.stdout ===================================== @@ -0,0 +1,8 @@ +FromInteger (-123) +FromRational ((-3) % 2) +Negate (FromInteger 5) +FromInteger 5 `Subtract` FromInteger 1 +Negate (FromInteger 0) +Negate (FromRational (0 % 1)) +FromInteger (-8) +FromInteger (-16) ===================================== testsuite/tests/parser/should_run/all.T ===================================== @@ -18,3 +18,4 @@ test('CountParserDeps', [ only_ways(['normal']), extra_run_opts('"' + config.libdir + '"') ], compile_and_run, ['-package ghc']) +test('LexNegLit', normal, compile_and_run, ['']) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 54ed6ae2556dc787916e2d56ce0e99808af14e61 +Subproject commit 9bd65ee47a43529af2ad8e350fdd0c372bc5964c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cbb6b62f54c77637e29bc66e3d1214541c347753 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cbb6b62f54c77637e29bc66e3d1214541c347753 You're receiving 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 Jul 1 19:42:20 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 01 Jul 2020 15:42:20 -0400 Subject: [Git][ghc/ghc][master] #17169: Clarify Fixed's Enum instance. Message-ID: <5efce71cb0346_80b3f84865795281222315@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - 1 changed file: - libraries/base/Data/Fixed.hs Changes: ===================================== libraries/base/Data/Fixed.hs ===================================== @@ -94,6 +94,64 @@ withResolution :: (HasResolution a) => (Integer -> f a) -> f a withResolution foo = withType (foo . resolution) -- | @since 2.01 +-- +-- Recall that, for numeric types, 'succ' and 'pred' typically add and subtract +-- @1@, respectively. This is not true in the case of 'Fixed', whose successor +-- and predecessor functions intuitively return the "next" and "previous" values +-- in the enumeration. The results of these functions thus depend on the +-- resolution of the 'Fixed' value. For example, when enumerating values of +-- resolution @10^-3@ of @type Milli = Fixed E3@, +-- +-- @ +-- succ (0.000 :: Milli) == 1.001 +-- @ +-- +-- +-- and likewise +-- +-- @ +-- pred (0.000 :: Milli) == -0.001 +-- @ +-- +-- +-- In other words, 'succ' and 'pred' increment and decrement a fixed-precision +-- value by the least amount such that the value's resolution is unchanged. +-- For example, @10^-12@ is the smallest (positive) amount that can be added to +-- a value of @type Pico = Fixed E12@ without changing its resolution, and so +-- +-- @ +-- succ (0.000000000000 :: Pico) == 0.000000000001 +-- @ +-- +-- +-- and similarly +-- +-- @ +-- pred (0.000000000000 :: Pico) == -0.000000000001 +-- @ +-- +-- +-- This is worth bearing in mind when defining 'Fixed' arithmetic sequences. In +-- particular, you may be forgiven for thinking the sequence +-- +-- @ +-- [1..10] :: [Pico] +-- @ +-- +-- +-- evaluates to @[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] :: [Pico]@. +-- +-- However, this is not true. On the contrary, similarly to the above +-- implementations of 'succ' and 'pred', @enumFromTo :: Pico -> Pico -> [Pico]@ +-- has a "step size" of @10^-12 at . Hence, the list @[1..10] :: [Pico]@ has +-- the form +-- +-- @ +-- [1.000000000000, 1.00000000001, 1.00000000002, ..., 10.000000000000] +-- @ +-- +-- +-- and contains @9 * 10^12 + 1@ values. instance Enum (Fixed a) where succ (MkFixed a) = MkFixed (succ a) pred (MkFixed a) = MkFixed (pred a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb5a0d01d575cdb830918a6a0406f385de2749c2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb5a0d01d575cdb830918a6a0406f385de2749c2 You're receiving 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 Jul 1 19:42:56 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 01 Jul 2020 15:42:56 -0400 Subject: [Git][ghc/ghc][master] Improve debug tracing for substitution Message-ID: <5efce7404ad53_80b3f84956d5b88122508d@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 8 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Subst.hs Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1023,7 +1023,7 @@ etaInfoApp subst (Tick t e) eis etaInfoApp subst expr _ | (Var fun, _) <- collectArgs expr - , Var fun' <- lookupIdSubst (text "etaInfoApp" <+> ppr fun) subst fun + , Var fun' <- lookupIdSubst subst fun , isJoinId fun' = subst_expr subst expr @@ -1132,13 +1132,16 @@ mkEtaWW orig_n ppr_orig_expr in_scope orig_ty --------------- --- Don't use short-cutting substitution - we may be changing the types of join --- points, so applying the in-scope set is necessary --- TODO Check if we actually *are* changing any join points' types - +------------ subst_expr :: Subst -> CoreExpr -> CoreExpr -subst_expr = substExpr (text "GHC.Core.Opt.Arity:substExpr") +-- Apply a substitution to an expression. We use substExpr +-- not substExprSC (short-cutting substitution) because +-- we may be changing the types of join points, so applying +-- the in-scope set is necessary. +-- +-- ToDo: we could instead check if we actually *are* +-- changing any join points' types, and if not use substExprSC. +subst_expr = substExpr -------------- ===================================== compiler/GHC/Core/Opt/CSE.hs ===================================== @@ -775,7 +775,7 @@ csEnvSubst :: CSEnv -> Subst csEnvSubst = cs_subst lookupSubst :: CSEnv -> Id -> OutExpr -lookupSubst (CS { cs_subst = sub}) x = lookupIdSubst (text "CSE.lookupSubst") sub x +lookupSubst (CS { cs_subst = sub}) x = lookupIdSubst sub x extendCSSubst :: CSEnv -> Id -> CoreExpr -> CSEnv extendCSSubst cse x rhs = cse { cs_subst = extendSubst (cs_subst cse) x rhs } ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1804,7 +1804,7 @@ abstractFloats dflags top_lvl main_tvs floats body = ASSERT( notNull body_floats ) ASSERT( isNilOL (sfJoinFloats floats) ) do { (subst, float_binds) <- mapAccumLM abstract empty_subst body_floats - ; return (float_binds, GHC.Core.Subst.substExpr (text "abstract_floats1") subst body) } + ; return (float_binds, GHC.Core.Subst.substExpr subst body) } where is_top_lvl = isTopLevel top_lvl main_tv_set = mkVarSet main_tvs @@ -1818,7 +1818,7 @@ abstractFloats dflags top_lvl main_tvs floats body subst' = GHC.Core.Subst.extendIdSubst subst id poly_app ; return (subst', NonRec poly_id2 poly_rhs) } where - rhs' = GHC.Core.Subst.substExpr (text "abstract_floats2") subst rhs + rhs' = GHC.Core.Subst.substExpr subst rhs -- tvs_here: see Note [Which type variables to abstract over] tvs_here = scopedSort $ @@ -1831,8 +1831,7 @@ abstractFloats dflags top_lvl main_tvs floats body ; let subst' = GHC.Core.Subst.extendSubstList subst (ids `zip` poly_apps) poly_pairs = [ mk_poly2 poly_id tvs_here rhs' | (poly_id, rhs) <- poly_ids `zip` rhss - , let rhs' = GHC.Core.Subst.substExpr (text "abstract_floats") - subst' rhs ] + , let rhs' = GHC.Core.Subst.substExpr subst' rhs ] ; return (subst', Rec poly_pairs) } where (ids,rhss) = unzip prs ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -860,7 +860,7 @@ lookupHowBound :: ScEnv -> Id -> Maybe HowBound lookupHowBound env id = lookupVarEnv (sc_how_bound env) id scSubstId :: ScEnv -> Id -> CoreExpr -scSubstId env v = lookupIdSubst (text "scSubstId") (sc_subst env) v +scSubstId env v = lookupIdSubst (sc_subst env) v scSubstTy :: ScEnv -> Type -> Type scSubstTy env ty = substTy (sc_subst env) ty ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -1008,7 +1008,7 @@ instance Outputable SpecEnv where , text "interesting =" <+> ppr interesting ]) specVar :: SpecEnv -> Id -> CoreExpr -specVar env v = Core.lookupIdSubst (text "specVar") (se_subst env) v +specVar env v = Core.lookupIdSubst (se_subst env) v specExpr :: SpecEnv -> CoreExpr -> SpecM (CoreExpr, UsageDetails) ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -917,7 +917,7 @@ match_var renv@(RV { rv_tmpls = tmpls, rv_lcl = rn_env, rv_fltR = flt_env }) Var v2 | v1' == rnOccR rn_env v2 -> Just subst - | Var v2' <- lookupIdSubst (text "match_var") flt_env v2 + | Var v2' <- lookupIdSubst flt_env v2 , v1' == v2' -> Just subst @@ -965,7 +965,7 @@ match_tmpl_var renv@(RV { rv_lcl = rn_env, rv_fltR = flt_env }) where -- e2' is the result of applying flt_env to e2 e2' | isEmptyVarSet let_bndrs = e2 - | otherwise = substExpr (text "match_tmpl_var") flt_env e2 + | otherwise = substExpr flt_env e2 id_subst' = extendVarEnv (rs_id_subst subst) v1' e2' -- No further renaming to do on e2', ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -93,7 +93,7 @@ little dance in action; the full Simplifier is a lot more complicated. -} -simpleOptExpr :: DynFlags -> CoreExpr -> CoreExpr +simpleOptExpr :: HasDebugCallStack => DynFlags -> CoreExpr -> CoreExpr -- See Note [The simple optimiser] -- Do simple optimisation on an expression -- The optimisation is very straightforward: just @@ -125,7 +125,7 @@ simpleOptExpr dflags expr -- It's a bit painful to call exprFreeVars, because it makes -- three passes instead of two (occ-anal, and go) -simpleOptExprWith :: DynFlags -> Subst -> InExpr -> OutExpr +simpleOptExprWith :: HasDebugCallStack => DynFlags -> Subst -> InExpr -> OutExpr -- See Note [The simple optimiser] simpleOptExprWith dflags subst expr = simple_opt_expr init_env (occurAnalyseExpr expr) @@ -218,7 +218,7 @@ simple_opt_expr env expr | Just clo <- lookupVarEnv (soe_inl env) v = simple_opt_clo env clo | otherwise - = lookupIdSubst (text "simpleOptExpr") (soe_subst env) v + = lookupIdSubst (soe_subst env) v go (App e1 e2) = simple_app env e1 [(env,e2)] go (Type ty) = Type (substTy subst ty) @@ -293,7 +293,7 @@ mk_cast e co | isReflexiveCo co = e ---------------------- -- simple_app collects arguments for beta reduction -simple_app :: SimpleOptEnv -> InExpr -> [SimpleClo] -> CoreExpr +simple_app :: HasDebugCallStack => SimpleOptEnv -> InExpr -> [SimpleClo] -> CoreExpr simple_app env (Var v) as | Just (env', e) <- lookupVarEnv (soe_inl env) v @@ -306,7 +306,7 @@ simple_app env (Var v) as = simple_app (soeZapSubst env) (unfoldingTemplate unf) as | otherwise - , let out_fn = lookupIdSubst (text "simple_app") (soe_subst env) v + , let out_fn = lookupIdSubst (soe_subst env) v = finish_app env out_fn as simple_app env (App e1 e2) as @@ -1064,7 +1064,8 @@ data ConCont = CC [CoreExpr] Coercion -- -- We also return the incoming InScopeSet, augmented with -- the binders from any [FloatBind] that we return -exprIsConApp_maybe :: InScopeEnv -> CoreExpr +exprIsConApp_maybe :: HasDebugCallStack + => InScopeEnv -> CoreExpr -> Maybe (InScopeSet, [FloatBind], DataCon, [Type], [CoreExpr]) exprIsConApp_maybe (in_scope, id_unf) expr = go (Left in_scope) [] expr (CC [] (mkRepReflCo (exprType expr))) @@ -1118,7 +1119,7 @@ exprIsConApp_maybe (in_scope, id_unf) expr go (Right sub) floats (Var v) cont = go (Left (substInScope sub)) floats - (lookupIdSubst (text "exprIsConApp" <+> ppr expr) sub v) + (lookupIdSubst sub v) cont go (Left in_scope) floats (Var fun) cont@(CC args co) @@ -1141,7 +1142,7 @@ exprIsConApp_maybe (in_scope, id_unf) expr , bndrs `equalLength` args -- See Note [DFun arity check] , let subst = mkOpenSubst in_scope (bndrs `zip` args) = succeedWith in_scope floats $ - pushCoDataCon con (map (substExpr (text "exprIsConApp1") subst) dfun_args) co + pushCoDataCon con (map (substExpr subst) dfun_args) co -- Look through unfoldings, but only arity-zero one; -- if arity > 0 we are effectively inlining a function call, @@ -1180,7 +1181,7 @@ exprIsConApp_maybe (in_scope, id_unf) expr subst_co (Right s) co = GHC.Core.Subst.substCo s co subst_expr (Left {}) e = e - subst_expr (Right s) e = substExpr (text "exprIsConApp2") s e + subst_expr (Right s) e = substExpr s e subst_bndr msubst bndr = (Right subst', bndr') @@ -1461,7 +1462,7 @@ pushCoercionIntoLambda in_scope x e co subst = extendIdSubst (mkEmptySubst in_scope') x (mkCast (Var x') co1) - in Just (x', substExpr (text "pushCoercionIntoLambda") subst e `mkCast` co2) + in Just (x', substExpr subst e `mkCast` co2) | otherwise = pprTrace "exprIsLambda_maybe: Unexpected lambda in case" (ppr (Lam x e)) Nothing ===================================== compiler/GHC/Core/Subst.hs ===================================== @@ -246,13 +246,13 @@ extendSubstList subst [] = subst extendSubstList subst ((var,rhs):prs) = extendSubstList (extendSubst subst var rhs) prs -- | Find the substitution for an 'Id' in the 'Subst' -lookupIdSubst :: SDoc -> Subst -> Id -> CoreExpr -lookupIdSubst doc (Subst in_scope ids _ _) v +lookupIdSubst :: HasDebugCallStack => Subst -> Id -> CoreExpr +lookupIdSubst (Subst in_scope ids _ _) v | not (isLocalId v) = Var v | Just e <- lookupVarEnv ids v = e | Just v' <- lookupInScope in_scope v = Var v' -- Vital! See Note [Extending the Subst] - | otherwise = WARN( True, text "GHC.Core.Subst.lookupIdSubst" <+> doc <+> ppr v + | otherwise = WARN( True, text "GHC.Core.Subst.lookupIdSubst" <+> ppr v $$ ppr in_scope) Var v @@ -338,26 +338,25 @@ instance Outputable Subst where ************************************************************************ -} --- | Apply a substitution to an entire 'CoreExpr'. Remember, you may only --- apply the substitution /once/: +substExprSC :: HasDebugCallStack => Subst -> CoreExpr -> CoreExpr +-- Just like substExpr, but a no-op if the substitution is empty +substExprSC subst orig_expr + | isEmptySubst subst = orig_expr + | otherwise = -- pprTrace "enter subst-expr" (doc $$ ppr orig_expr) $ + substExpr subst orig_expr + +-- | substExpr applies a substitution to an entire 'CoreExpr'. Remember, +-- you may only apply the substitution /once/: -- See Note [Substitutions apply only once] in "GHC.Core.TyCo.Subst" -- -- Do *not* attempt to short-cut in the case of an empty substitution! -- See Note [Extending the Subst] -substExprSC :: SDoc -> Subst -> CoreExpr -> CoreExpr -substExprSC doc subst orig_expr - | isEmptySubst subst = orig_expr - | otherwise = -- pprTrace "enter subst-expr" (doc $$ ppr orig_expr) $ - subst_expr doc subst orig_expr - -substExpr :: SDoc -> Subst -> CoreExpr -> CoreExpr -substExpr doc subst orig_expr = subst_expr doc subst orig_expr - -subst_expr :: SDoc -> Subst -> CoreExpr -> CoreExpr -subst_expr doc subst expr +substExpr :: HasDebugCallStack => Subst -> CoreExpr -> CoreExpr + -- HasDebugCallStack so we can track failures in lookupIdSubst +substExpr subst expr = go expr where - go (Var v) = lookupIdSubst (doc $$ text "subst_expr") subst v + go (Var v) = lookupIdSubst subst v go (Type ty) = Type (substTy subst ty) go (Coercion co) = Coercion (substCo subst co) go (Lit lit) = Lit lit @@ -370,11 +369,11 @@ subst_expr doc subst expr -- lose a binder. We optimise the LHS of rules at -- construction time - go (Lam bndr body) = Lam bndr' (subst_expr doc subst' body) + go (Lam bndr body) = Lam bndr' (substExpr subst' body) where (subst', bndr') = substBndr subst bndr - go (Let bind body) = Let bind' (subst_expr doc subst' body) + go (Let bind body) = Let bind' (substExpr subst' body) where (subst', bind') = substBind subst bind @@ -382,13 +381,13 @@ subst_expr doc subst expr where (subst', bndr') = substBndr subst bndr - go_alt subst (con, bndrs, rhs) = (con, bndrs', subst_expr doc subst' rhs) + go_alt subst (con, bndrs, rhs) = (con, bndrs', substExpr subst' rhs) where (subst', bndrs') = substBndrs subst bndrs -- | Apply a substitution to an entire 'CoreBind', additionally returning an updated 'Subst' -- that should be used by subsequent substitutions. -substBind, substBindSC :: Subst -> CoreBind -> (Subst, CoreBind) +substBind, substBindSC :: HasDebugCallStack => Subst -> CoreBind -> (Subst, CoreBind) substBindSC subst bind -- Short-cut if the substitution is empty | not (isEmptySubst subst) @@ -405,10 +404,10 @@ substBindSC subst bind -- Short-cut if the substitution is empty rhss' | isEmptySubst subst' = rhss | otherwise - = map (subst_expr (text "substBindSC") subst') rhss + = map (substExpr subst') rhss substBind subst (NonRec bndr rhs) - = (subst', NonRec bndr' (subst_expr (text "substBind") subst rhs)) + = (subst', NonRec bndr' (substExpr subst rhs)) where (subst', bndr') = substBndr subst bndr @@ -417,7 +416,7 @@ substBind subst (Rec pairs) where (bndrs, rhss) = unzip pairs (subst', bndrs') = substRecBndrs subst bndrs - rhss' = map (subst_expr (text "substBind") subst') rhss + rhss' = map (substExpr subst') rhss -- | De-shadowing the program is sometimes a useful pre-pass. It can be done simply -- by running over the bindings with an empty substitution, because substitution @@ -638,7 +637,7 @@ substUnfolding subst df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) = df { df_bndrs = bndrs', df_args = args' } where (subst',bndrs') = substBndrs subst bndrs - args' = map (substExpr (text "subst-unf:dfun") subst') args + args' = map (substExpr subst') args substUnfolding subst unf@(CoreUnfolding { uf_tmpl = tmpl, uf_src = src }) -- Retain an InlineRule! @@ -648,14 +647,14 @@ substUnfolding subst unf@(CoreUnfolding { uf_tmpl = tmpl, uf_src = src }) = seqExpr new_tmpl `seq` unf { uf_tmpl = new_tmpl } where - new_tmpl = substExpr (text "subst-unf") subst tmpl + new_tmpl = substExpr subst tmpl substUnfolding _ unf = unf -- NoUnfolding, OtherCon ------------------ substIdOcc :: Subst -> Id -> Id -- These Ids should not be substituted to non-Ids -substIdOcc subst v = case lookupIdSubst (text "substIdOcc") subst v of +substIdOcc subst v = case lookupIdSubst subst v of Var v' -> v' other -> pprPanic "substIdOcc" (vcat [ppr v <+> ppr other, ppr subst]) @@ -693,12 +692,11 @@ substRule subst subst_ru_fn rule@(Rule { ru_bndrs = bndrs, ru_args = args , ru_fn = if is_local then subst_ru_fn fn_name else fn_name - , ru_args = map (substExpr doc subst') args - , ru_rhs = substExpr (text "foo") subst' rhs } + , ru_args = map (substExpr subst') args + , ru_rhs = substExpr subst' rhs } -- Do NOT optimise the RHS (previously we did simplOptExpr here) -- See Note [Substitute lazily] where - doc = text "subst-rule" <+> ppr fn_name (subst', bndrs') = substBndrs subst bndrs ------------------ @@ -707,7 +705,7 @@ substDVarSet subst fvs = mkDVarSet $ fst $ foldr (subst_fv subst) ([], emptyVarSet) $ dVarSetElems fvs where subst_fv subst fv acc - | isId fv = expr_fvs (lookupIdSubst (text "substDVarSet") subst fv) isLocalVar emptyVarSet $! acc + | isId fv = expr_fvs (lookupIdSubst subst fv) isLocalVar emptyVarSet $! acc | otherwise = tyCoFVsOfType (lookupTCvSubst subst fv) (const True) emptyVarSet $! acc ------------------ @@ -715,7 +713,7 @@ substTickish :: Subst -> Tickish Id -> Tickish Id substTickish subst (Breakpoint n ids) = Breakpoint n (map do_one ids) where - do_one = getIdFromTrivialExpr . lookupIdSubst (text "subst_tickish") subst + do_one = getIdFromTrivialExpr . lookupIdSubst subst substTickish _subst other = other {- Note [Substitute lazily] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b316804dbafe1d0287fd33f656b7ce5711ec34f7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b316804dbafe1d0287fd33f656b7ce5711ec34f7 You're receiving 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 Jul 1 19:43:32 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 01 Jul 2020 15:43:32 -0400 Subject: [Git][ghc/ghc][master] Add most common return values for `os` and `arch` Message-ID: <5efce7641ac9e_80b3f8469a4048412275f7@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 2 changed files: - aclocal.m4 - libraries/base/System/Info.hs Changes: ===================================== aclocal.m4 ===================================== @@ -1919,7 +1919,9 @@ AC_MSG_CHECKING(for path to top of build tree) # GHC_CONVERT_CPU(cpu, target_var) # -------------------------------- -# converts cpu from gnu to ghc naming, and assigns the result to $target_var +# Converts cpu from gnu to ghc naming, and assigns the result to $target_var. +# Should you modify this list, you are invited to reflect the changes in +# `libraries/base/System/Info.hs`'s documentation. AC_DEFUN([GHC_CONVERT_CPU],[ case "$1" in aarch64*) ===================================== libraries/base/System/Info.hs ===================================== @@ -11,9 +11,11 @@ -- Stability : experimental -- Portability : portable -- --- Information about the characteristics of the host +-- Information about the characteristics of the host -- system lucky enough to run your program. -- +-- For a comprehensive listing of supported platforms, please refer to +-- https://gitlab.haskell.org/ghc/ghc/-/wikis/platforms ----------------------------------------------------------------------------- module System.Info @@ -28,6 +30,10 @@ import Data.Version -- | The version of 'compilerName' with which the program was compiled -- or is being interpreted. +-- +-- ==== __Example__ +-- > ghci> compilerVersion +-- > Version {versionBranch = [8,8], versionTags = []} compilerVersion :: Version compilerVersion = Version [major, minor] [] where (major, minor) = compilerVersionRaw `divMod` 100 @@ -35,15 +41,52 @@ compilerVersion = Version [major, minor] [] #include "ghcplatform.h" -- | The operating system on which the program is running. +-- Common values include: +-- +-- * "darwin" — macOS +-- * "freebsd" +-- * "linux" +-- * "linux-android" +-- * "mingw32" — Windows +-- * "netbsd" +-- * "openbsd" os :: String os = HOST_OS -- | The machine architecture on which the program is running. +-- Common values include: +-- +-- * "aarch64" +-- * "alpha" +-- * "arm" +-- * "hppa" +-- * "hppa1_1" +-- * "i386" +-- * "ia64" +-- * "m68k" +-- * "mips" +-- * "mipseb" +-- * "mipsel" +-- * "nios2" +-- * "powerpc" +-- * "powerpc64" +-- * "powerpc64le" +-- * "riscv32" +-- * "riscv64" +-- * "rs6000" +-- * "s390" +-- * "s390x" +-- * "sh4" +-- * "sparc" +-- * "sparc64" +-- * "vax" +-- * "x86_64" arch :: String arch = HOST_ARCH -- | The Haskell implementation with which the program was compiled -- or is being interpreted. +-- On the GHC platform, the value is "ghc". compilerName :: String compilerName = "ghc" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c9fabb82b39aed9e61c6b78c72312b20a568c68 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c9fabb82b39aed9e61c6b78c72312b20a568c68 You're receiving 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 Jul 1 19:44:09 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 01 Jul 2020 15:44:09 -0400 Subject: [Git][ghc/ghc][master] Desugar quoted uses of DerivingVia and expression type signatures properly Message-ID: <5efce7897f9e3_80b3f8469a4048412342bf@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 3 changed files: - compiler/GHC/HsToCore/Quote.hs - + testsuite/tests/th/T18388.hs - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -332,7 +332,7 @@ repTopDs group@(HsGroup { hs_valds = valds = notHandledL loc "Haddock documentation" empty hsScopedTvBinders :: HsValBinds GhcRn -> [Name] --- See Note [Scoped type variables in bindings] +-- See Note [Scoped type variables in quotes] hsScopedTvBinders binds = concatMap get_scoped_tvs sigs where @@ -350,58 +350,60 @@ get_scoped_tvs (L _ signature) = get_scoped_tvs_from_sig sig | otherwise = [] - where - get_scoped_tvs_from_sig :: LHsSigType GhcRn -> [Name] - get_scoped_tvs_from_sig sig - -- Both implicit and explicit quantified variables - -- We need the implicit ones for f :: forall (a::k). blah - -- here 'k' scopes too - | HsIB { hsib_ext = implicit_vars - , hsib_body = hs_ty } <- sig - , (explicit_vars, _) <- splitLHsForAllTyInvis hs_ty - = implicit_vars ++ hsLTyVarNames explicit_vars + +get_scoped_tvs_from_sig :: LHsSigType GhcRn -> [Name] +get_scoped_tvs_from_sig sig + -- Collect both implicit and explicit quantified variables, since + -- the types in instance heads, as well as `via` types in DerivingVia, can + -- bring implicitly quantified type variables into scope, e.g., + -- + -- instance Foo [a] where + -- m = n @a + -- + -- See also Note [Scoped type variables in quotes] + | HsIB { hsib_ext = implicit_vars + , hsib_body = hs_ty } <- sig + , (explicit_vars, _) <- splitLHsForAllTyInvis hs_ty + = implicit_vars ++ hsLTyVarNames explicit_vars {- Notes -Note [Scoped type variables in bindings] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider - f :: forall a. a -> a - f x = x::a -Here the 'forall a' brings 'a' into scope over the binding group. -To achieve this we +Note [Scoped type variables in quotes] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quoting declarations with scoped type variables requires some care. Consider: - a) Gensym a binding for 'a' at the same time as we do one for 'f' - collecting the relevant binders with hsScopedTvBinders + $([d| f :: forall a. a -> a + f x = x::a + |]) - b) When processing the 'forall', don't gensym +Here, the `forall a` brings `a` into scope over the binding group. This has +ramifications when desugaring the quote, as we must ensure that that the +desugared code binds `a` with `Language.Haskell.TH.newName` and refers to the +bound `a` type variable in the type signature and in the body of `f`. As a +result, the call to `newName` must occur before any part of the declaration for +`f` is processed. To achieve this, we: -The relevant places are signposted with references to this Note + (a) Gensym a binding for `a` at the same time as we do one for `f`, + collecting the relevant binders with the hsScopedTvBinders family of + functions. -Note [Scoped type variables in class and instance declarations] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Scoped type variables may occur in default methods and default -signatures. We need to bring the type variables in 'foralls' -into the scope of the method bindings. + (b) Use `addBinds` to bring these gensymmed bindings into scope over any + part of the code where the type variables scope. In the `f` example, + above, that means the type signature and the body of `f`. -Consider - class Foo a where - foo :: forall (b :: k). a -> Proxy b -> Proxy b - foo _ x = (x :: Proxy b) + (c) When processing the `forall`, /don't/ gensym the type variables. We have + already brought the type variables into scope in part (b), after all, so + gensymming them again would lead to shadowing. We use the rep_ty_sig + family of functions for processing types without gensymming the type + variables again. -We want to ensure that the 'b' in the type signature and the default -implementation are the same, so we do the following: + (d) Finally, we use wrapGenSyms to generate the Core for these scoped type + variables: - a) Before desugaring the signature and binding of 'foo', use - get_scoped_tvs to collect type variables in 'forall' and - create symbols for them. - b) Use 'addBinds' to bring these symbols into the scope of the type - signatures and bindings. - c) Use these symbols to generate Core for the class/instance declaration. + newName "a" >>= \a -> + ... -- process the type signature and body of `f` -Note that when desugaring the signatures, we lookup the type variables -from the scope rather than recreate symbols for them. See more details -in "rep_ty_sig" and in Trac#14885. +The relevant places are signposted with references to this Note. Note [Binders and occurrences] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -429,16 +431,16 @@ Note [Don't quantify implicit type variables in quotes] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you're not careful, it's surprisingly easy to take this quoted declaration: - [d| idProxy :: forall proxy (b :: k). proxy b -> proxy b - idProxy x = x + [d| id :: a -> a + id x = x |] and have Template Haskell turn it into this: - idProxy :: forall k proxy (b :: k). proxy b -> proxy b - idProxy x = x + id :: forall a. a -> a + id x = x -Notice that we explicitly quantified the variable `k`! The latter declaration +Notice that we explicitly quantified the variable `a`! The latter declaration isn't what the user wrote in the first place. Usually, the culprit behind these bugs is taking implicitly quantified type @@ -474,8 +476,8 @@ repTyClD (L loc (ClassDecl { tcdCtxt = cxt, tcdLName = cls, = do { cls1 <- lookupLOcc cls -- See note [Binders and occurrences] ; dec <- addQTyVarBinds tvs $ \bndrs -> do { cxt1 <- repLContext cxt - -- See Note [Scoped type variables in class and instance declarations] - ; (ss, sigs_binds) <- rep_sigs_binds sigs meth_binds + -- See Note [Scoped type variables in quotes] + ; (ss, sigs_binds) <- rep_meth_sigs_binds sigs meth_binds ; fds1 <- repLFunDeps fds ; ats1 <- repFamilyDecls ats ; atds1 <- mapM (repAssocTyFamDefaultD . unLoc) atds @@ -650,8 +652,8 @@ repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds -- do { cxt1 <- repLContext cxt ; inst_ty1 <- repLTy inst_ty - -- See Note [Scoped type variables in class and instance declarations] - ; (ss, sigs_binds) <- rep_sigs_binds sigs binds + -- See Note [Scoped type variables in quotes] + ; (ss, sigs_binds) <- rep_meth_sigs_binds sigs binds ; ats1 <- mapM (repTyFamInstD . unLoc) ats ; adts1 <- mapM (repDataFamInstD . unLoc) adts ; decls1 <- coreListM decTyConName (ats1 ++ adts1 ++ sigs_binds) @@ -664,9 +666,9 @@ repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds repStandaloneDerivD :: LDerivDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repStandaloneDerivD (L loc (DerivDecl { deriv_strategy = strat , deriv_type = ty })) - = do { dec <- addSimpleTyVarBinds tvs $ + = do { dec <- repDerivStrategy strat $ \strat' -> + addSimpleTyVarBinds tvs $ do { cxt' <- repLContext cxt - ; strat' <- repDerivStrategy strat ; inst_ty' <- repLTy inst_ty ; repDeriv strat' cxt' inst_ty' } ; return (loc, dec) } @@ -943,23 +945,23 @@ repDerivClause :: LHsDerivingClause GhcRn repDerivClause (L _ (HsDerivingClause { deriv_clause_strategy = dcs , deriv_clause_tys = L _ dct })) - = do MkC dcs' <- repDerivStrategy dcs - MkC dct' <- repListM typeTyConName (rep_deriv_ty . hsSigType) dct + = repDerivStrategy dcs $ \(MkC dcs') -> + do MkC dct' <- repListM typeTyConName (rep_deriv_ty . hsSigType) dct rep2 derivClauseName [dcs',dct'] where rep_deriv_ty :: LHsType GhcRn -> MetaM (Core (M TH.Type)) rep_deriv_ty ty = repLTy ty -rep_sigs_binds :: [LSig GhcRn] -> LHsBinds GhcRn - -> MetaM ([GenSymBind], [Core (M TH.Dec)]) +rep_meth_sigs_binds :: [LSig GhcRn] -> LHsBinds GhcRn + -> MetaM ([GenSymBind], [Core (M TH.Dec)]) -- Represent signatures and methods in class/instance declarations. --- See Note [Scoped type variables in class and instance declarations] +-- See Note [Scoped type variables in quotes] -- -- Why not use 'repBinds': we have already created symbols for methods in -- 'repTopDs' via 'hsGroupBinders'. However in 'repBinds', we recreate -- these fun_id via 'collectHsValBinders decs', which would lead to the -- instance declarations failing in TH. -rep_sigs_binds sigs binds +rep_meth_sigs_binds sigs binds = do { let tvs = concatMap get_scoped_tvs sigs ; ss <- mkGenSyms tvs ; sigs1 <- addBinds ss $ rep_sigs sigs @@ -993,30 +995,47 @@ rep_sig (L _ (SCCFunSig {})) = notHandled "SCC pragmas" empty rep_sig (L loc (CompleteMatchSig _ _st cls mty)) = rep_complete_sig cls mty loc +-- Desugar the explicit type variable binders in an 'LHsSigType', making +-- sure not to gensym them. +-- See Note [Scoped type variables in quotes] +-- and Note [Don't quantify implicit type variables in quotes] +rep_ty_sig_tvs :: [LHsTyVarBndr Specificity GhcRn] + -> MetaM (Core [M TH.TyVarBndrSpec]) +rep_ty_sig_tvs explicit_tvs + = let rep_in_scope_tv tv = do { name <- lookupBinder (hsLTyVarName tv) + ; repTyVarBndrWithKind tv name } in + repListM tyVarBndrSpecTyConName rep_in_scope_tv + explicit_tvs + -- NB: Don't pass any implicit type variables to repList above + -- See Note [Don't quantify implicit type variables in quotes] + +-- Desugar a top-level type signature. Unlike 'repHsSigType', this +-- deliberately avoids gensymming the type variables. +-- See Note [Scoped type variables in quotes] +-- and Note [Don't quantify implicit type variables in quotes] rep_ty_sig :: Name -> SrcSpan -> LHsSigType GhcRn -> Located Name -> MetaM (SrcSpan, Core (M TH.Dec)) --- Don't create the implicit and explicit variables when desugaring signatures, --- see Note [Scoped type variables in class and instance declarations]. --- and Note [Don't quantify implicit type variables in quotes] rep_ty_sig mk_sig loc sig_ty nm - | HsIB { hsib_body = hs_ty } <- sig_ty - , (explicit_tvs, ctxt, ty) <- splitLHsSigmaTyInvis hs_ty = do { nm1 <- lookupLOcc nm - ; let rep_in_scope_tv tv = do { name <- lookupBinder (hsLTyVarName tv) - ; repTyVarBndrWithKind tv name } - ; th_explicit_tvs <- repListM tyVarBndrSpecTyConName rep_in_scope_tv - explicit_tvs - - -- NB: Don't pass any implicit type variables to repList above - -- See Note [Don't quantify implicit type variables in quotes] + ; ty1 <- rep_ty_sig' sig_ty + ; sig <- repProto mk_sig nm1 ty1 + ; return (loc, sig) } +-- Desugar an 'LHsSigType', making sure not to gensym the type variables at +-- the front of the type signature. +-- See Note [Scoped type variables in quotes] +-- and Note [Don't quantify implicit type variables in quotes] +rep_ty_sig' :: LHsSigType GhcRn + -> MetaM (Core (M TH.Type)) +rep_ty_sig' sig_ty + | HsIB { hsib_body = hs_ty } <- sig_ty + , (explicit_tvs, ctxt, ty) <- splitLHsSigmaTyInvis hs_ty + = do { th_explicit_tvs <- rep_ty_sig_tvs explicit_tvs ; th_ctxt <- repLContext ctxt ; th_ty <- repLTy ty - ; ty1 <- if null explicit_tvs && null (unLoc ctxt) - then return th_ty - else repTForall th_explicit_tvs th_ctxt th_ty - ; sig <- repProto mk_sig nm1 ty1 - ; return (loc, sig) } + ; if null explicit_tvs && null (unLoc ctxt) + then return th_ty + else repTForall th_explicit_tvs th_ctxt th_ty } rep_patsyn_ty_sig :: SrcSpan -> LHsSigType GhcRn -> Located Name -> MetaM (SrcSpan, Core (M TH.Dec)) @@ -1024,19 +1043,14 @@ rep_patsyn_ty_sig :: SrcSpan -> LHsSigType GhcRn -> Located Name -- see Note [Pattern synonym type signatures and Template Haskell] in "GHC.ThToHs" -- -- Don't create the implicit and explicit variables when desugaring signatures, --- see Note [Scoped type variables in class and instance declarations] +-- see Note [Scoped type variables in quotes] -- and Note [Don't quantify implicit type variables in quotes] rep_patsyn_ty_sig loc sig_ty nm | HsIB { hsib_body = hs_ty } <- sig_ty , (univs, reqs, exis, provs, ty) <- splitLHsPatSynTy hs_ty = do { nm1 <- lookupLOcc nm - ; let rep_in_scope_tv tv = do { name <- lookupBinder (hsLTyVarName tv) - ; repTyVarBndrWithKind tv name } - ; th_univs <- repListM tyVarBndrSpecTyConName rep_in_scope_tv univs - ; th_exis <- repListM tyVarBndrSpecTyConName rep_in_scope_tv exis - - -- NB: Don't pass any implicit type variables to repList above - -- See Note [Don't quantify implicit type variables in quotes] + ; th_univs <- rep_ty_sig_tvs univs + ; th_exis <- rep_ty_sig_tvs exis ; th_reqs <- repLContext reqs ; th_provs <- repLContext provs @@ -1253,10 +1267,6 @@ repHsSigType (HsIB { hsib_ext = implicit_tvs then return th_ty else repTForall th_explicit_tvs th_ctxt th_ty } -repHsSigWcType :: LHsSigWcType GhcRn -> MetaM (Core (M TH.Type)) -repHsSigWcType (HsWC { hswc_body = sig1 }) - = repHsSigType sig1 - -- yield the representation of a list of types repLTys :: [LHsType GhcRn] -> MetaM [Core (M TH.Type)] repLTys tys = mapM repLTy tys @@ -1528,10 +1538,13 @@ repE (RecordUpd { rupd_expr = e, rupd_flds = flds }) fs <- repUpdFields flds; repRecUpd x fs } -repE (ExprWithTySig _ e ty) - = do { e1 <- repLE e - ; t1 <- repHsSigWcType ty +repE (ExprWithTySig _ e wc_ty) + = addSimpleTyVarBinds (get_scoped_tvs_from_sig sig_ty) $ + do { e1 <- repLE e + ; t1 <- rep_ty_sig' sig_ty ; repSigExp e1 t1 } + where + sig_ty = dropWildCards wc_ty repE (ArithSeq _ _ aseq) = case aseq of @@ -1734,7 +1747,7 @@ repBinds (HsValBinds _ decs) -- the binding group, because we are talking Names -- here, so we can safely treat it as a mutually -- recursive group - -- For hsScopedTvBinders see Note [Scoped type variables in bindings] + -- For hsScopedTvBinders see Note [Scoped type variables in quotes] ; ss <- mkGenSyms bndrs ; prs <- addBinds ss (rep_val_binds decs) ; core_list <- coreListM decTyConName @@ -2427,18 +2440,21 @@ repInst (MkC o) (MkC cxt) (MkC ty) (MkC ds) = rep2 instanceWithOverlapDName [o, cxt, ty, ds] repDerivStrategy :: Maybe (LDerivStrategy GhcRn) - -> MetaM (Core (Maybe (M TH.DerivStrategy))) -repDerivStrategy mds = + -> (Core (Maybe (M TH.DerivStrategy)) -> MetaM (Core (M a))) + -> MetaM (Core (M a)) +repDerivStrategy mds thing_inside = case mds of - Nothing -> nothing + Nothing -> thing_inside =<< nothing Just ds -> case unLoc ds of - StockStrategy -> just =<< repStockStrategy - AnyclassStrategy -> just =<< repAnyclassStrategy - NewtypeStrategy -> just =<< repNewtypeStrategy - ViaStrategy ty -> do ty' <- repLTy (hsSigType ty) + StockStrategy -> thing_inside =<< just =<< repStockStrategy + AnyclassStrategy -> thing_inside =<< just =<< repAnyclassStrategy + NewtypeStrategy -> thing_inside =<< just =<< repNewtypeStrategy + ViaStrategy ty -> addSimpleTyVarBinds (get_scoped_tvs_from_sig ty) $ + do ty' <- rep_ty_sig' ty via_strat <- repViaStrategy ty' - just via_strat + m_via_strat <- just via_strat + thing_inside m_via_strat where nothing = coreNothingM derivStrategyTyConName just = coreJustM derivStrategyTyConName ===================================== testsuite/tests/th/T18388.hs ===================================== @@ -0,0 +1,29 @@ +{-# LANGUAGE DerivingVia #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeApplications #-} +module T18388 where + +class C x y where + m :: x -> y -> y + +newtype Tagged x a = MkTagged a +instance C x (Tagged x a) where + m _ = id + +$([d| newtype Id1 a = MkId1 a + deriving (C x) via forall x. Tagged x a + + newtype Id2 a = MkId2 a + deriving (C x) via Tagged x a + |]) + +newtype List1 a = MkList1 [a] +newtype List2 a = MkList2 [a] +$([d| deriving via forall a. [a] instance Eq a => Eq (List1 a) |]) +$([d| deriving via [a] instance Eq a => Eq (List2 a) |]) + +$([d| f = id @a :: forall a. a -> a |]) ===================================== testsuite/tests/th/all.T ===================================== @@ -510,3 +510,4 @@ test('TH_StringLift', normal, compile, ['']) test('TH_BytesShowEqOrd', normal, compile_and_run, ['']) test('T18121', normal, compile, ['']) test('T18123', normal, compile, ['']) +test('T18388', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76d8cc744977d98f6a427b1816198709e2d2e856 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76d8cc744977d98f6a427b1816198709e2d2e856 You're receiving 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 Jul 1 20:07:54 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Wed, 01 Jul 2020 16:07:54 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/negative-literals Message-ID: <5efced1aa4acf_80b3f8490290e38123489f@gitlab.haskell.org.mail> Vladislav Zavialov pushed new branch wip/negative-literals at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/negative-literals You're receiving 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 Jul 1 20:14:48 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 01 Jul 2020 16:14:48 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Implement -XLexicalNegation (GHC Proposal #229) Message-ID: <5efceeb86321e_80b3f84956d5b881237989@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - ba7e904e by Andreas Klebinger at 2020-07-01T16:14:45-04:00 T16012: Be verbose on failure. - - - - - fa911250 by Ryan Scott at 2020-07-01T16:14:46-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 30 changed files: - aclocal.m4 - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - docs/users_guide/8.12.1-notes.rst - + docs/users_guide/exts/lexical_negation.rst - docs/users_guide/exts/negative_literals.rst - docs/users_guide/exts/syntax.rst - ghc/ghc-bin.cabal.in - libraries/base/Data/Fixed.hs - libraries/base/System/Info.hs - libraries/base/base.cabal - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - libraries/ghc-compact/ghc-compact.cabal - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-prim/ghc-prim.cabal - libraries/text - testsuite/tests/ado/ado004.stderr - testsuite/tests/backpack/should_compile/bkp16.stderr - testsuite/tests/dependent/should_compile/T14729.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a19466b036afae760728876855b434635314c4da...fa911250e4047c8b86dad19f0e4d0bdc143e2808 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a19466b036afae760728876855b434635314c4da...fa911250e4047c8b86dad19f0e4d0bdc143e2808 You're receiving 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 Jul 1 20:24:04 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Wed, 01 Jul 2020 16:24:04 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/lexical-negation Message-ID: <5efcf0e497f3_80b3f84698000ac124185d@gitlab.haskell.org.mail> Vladislav Zavialov deleted branch wip/lexical-negation 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 Jul 2 06:55:00 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 02 Jul 2020 02:55:00 -0400 Subject: [Git][ghc/ghc][master] T16012: Be verbose on failure. Message-ID: <5efd84c4ed943_80bf1893181260867@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - 2 changed files: - testsuite/tests/ghci/should_run/T16012.script - testsuite/tests/ghci/should_run/T16012.stdout Changes: ===================================== testsuite/tests/ghci/should_run/T16012.script ===================================== @@ -1,2 +1,6 @@ +-- We expect the allocation counter to be initialized to zero and to count down. +-- As ghc expressions are executed in their own thread a call to getAllocationCounter +-- should always return a reasonably low result. + n <- System.Mem.getAllocationCounter -(n < 0 && n >= -160000) +if (n < 0 && n >= -160000) then putStrLn "Alloction counter in expected range" else (putStrLn $ "Unexpected allocation counter result:" ++ show n) ===================================== testsuite/tests/ghci/should_run/T16012.stdout ===================================== @@ -1 +1 @@ -True +Alloction counter in expected range View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44d6a3352d708785b75aeb616bfc7efff839184e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44d6a3352d708785b75aeb616bfc7efff839184e You're receiving 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 Jul 2 06:55:35 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 02 Jul 2020 02:55:35 -0400 Subject: [Git][ghc/ghc][master] Bump ghc-prim version to 0.7.0 Message-ID: <5efd84e7a82b7_80b3f8494c8fea81264942@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 30 changed files: - ghc/ghc-bin.cabal.in - libraries/base/base.cabal - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-compact/ghc-compact.cabal - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-prim/ghc-prim.cabal - libraries/text - testsuite/tests/ado/ado004.stderr - testsuite/tests/backpack/should_compile/bkp16.stderr - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/determinism/determ021/determ021.stdout - testsuite/tests/driver/json2.stderr - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - testsuite/tests/indexed-types/should_compile/T3017.stderr - testsuite/tests/partial-sigs/should_compile/ADT.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr1.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr2.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr3.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr4.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr5.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr6.stderr - testsuite/tests/partial-sigs/should_compile/BoolToBool.stderr - testsuite/tests/partial-sigs/should_compile/DataFamilyInstanceLHS.stderr - testsuite/tests/partial-sigs/should_compile/Defaulting1MROn.stderr - testsuite/tests/partial-sigs/should_compile/Defaulting2MROff.stderr - testsuite/tests/partial-sigs/should_compile/Defaulting2MROn.stderr - testsuite/tests/partial-sigs/should_compile/Either.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f985333002c1690bf49debcc64fc65ed1d1de244 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f985333002c1690bf49debcc64fc65ed1d1de244 You're receiving 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 Jul 2 07:19:49 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Thu, 02 Jul 2020 03:19:49 -0400 Subject: [Git][ghc/ghc][wip/haddock-accum] 8 commits: Implement -XLexicalNegation (GHC Proposal #229) Message-ID: <5efd8a9548204_80b3f848657952812711c6@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/haddock-accum at Glasgow Haskell Compiler / GHC Commits: cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 6a48d5b2 by Vladislav Zavialov at 2020-07-02T10:18:17+03:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 20 changed files: - aclocal.m4 - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/Stats.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - 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/1c26dc4caab798d9e1b70782841276e7702e76c3...6a48d5b239f434a67aa7c4158c9fcb232cd13678 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1c26dc4caab798d9e1b70782841276e7702e76c3...6a48d5b239f434a67aa7c4158c9fcb232cd13678 You're receiving 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 Jul 2 07:26:24 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 02 Jul 2020 03:26:24 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: T16012: Be verbose on failure. Message-ID: <5efd8c203ce90_80b3f84956d5b8812777ee@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - d62b21b5 by Sylvain Henry at 2020-07-02T03:26:18-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - dc31cc3b by Sylvain Henry at 2020-07-02T03:26:20-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 30 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - ghc/ghc-bin.cabal.in - hadrian/src/Hadrian/Haskell/Cabal.hs - libraries/base/base.cabal - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-compact/ghc-compact.cabal - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-prim/ghc-prim.cabal - libraries/text - testsuite/tests/ado/ado004.stderr - testsuite/tests/backpack/should_compile/bkp16.stderr - + testsuite/tests/codeGen/should_compile/T15570.hs - testsuite/tests/codeGen/should_compile/all.T - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/determinism/determ021/determ021.stdout - testsuite/tests/driver/json2.stderr - testsuite/tests/ghci/should_run/T16012.script - testsuite/tests/ghci/should_run/T16012.stdout - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - testsuite/tests/indexed-types/should_compile/T3017.stderr - testsuite/tests/partial-sigs/should_compile/ADT.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr1.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr2.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr3.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr4.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr5.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr6.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fa911250e4047c8b86dad19f0e4d0bdc143e2808...dc31cc3bbc83ddd07ec5fd9197595226ce123d74 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fa911250e4047c8b86dad19f0e4d0bdc143e2808...dc31cc3bbc83ddd07ec5fd9197595226ce123d74 You're receiving 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 Jul 2 09:20:42 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Thu, 02 Jul 2020 05:20:42 -0400 Subject: [Git][ghc/ghc][wip/negative-literals] 3 commits: T16012: Be verbose on failure. Message-ID: <5efda6eaeae91_80bf1893181294235@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/negative-literals at Glasgow Haskell Compiler / GHC Commits: 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 37a35038 by Vladislav Zavialov at 2020-07-02T12:20:32+03:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. - - - - - 30 changed files: - compiler/GHC/Parser/Lexer.x - docs/users_guide/exts/negative_literals.rst - ghc/ghc-bin.cabal.in - libraries/base/base.cabal - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-compact/ghc-compact.cabal - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-prim/ghc-prim.cabal - libraries/text - testsuite/tests/ado/ado004.stderr - testsuite/tests/backpack/should_compile/bkp16.stderr - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/determinism/determ021/determ021.stdout - testsuite/tests/driver/json2.stderr - testsuite/tests/ghci/should_run/T16012.script - testsuite/tests/ghci/should_run/T16012.stdout - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - testsuite/tests/indexed-types/should_compile/T3017.stderr - − testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/NegativeLiterals.hs - testsuite/tests/parser/should_compile/all.T - testsuite/tests/partial-sigs/should_compile/ADT.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr1.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr2.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr3.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr4.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr5.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9134795d1c40423ce4a0a3c9dedab510ced79955...37a35038a961a3051c549d4aecc4e94588c354e5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9134795d1c40423ce4a0a3c9dedab510ced79955...37a35038a961a3051c549d4aecc4e94588c354e5 You're receiving 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 Jul 2 10:06:46 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Thu, 02 Jul 2020 06:06:46 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18341 Message-ID: <5efdb1b6a5b71_80b3f84956d5b8812974c5@gitlab.haskell.org.mail> Sebastian Graf pushed new branch wip/T18341 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18341 You're receiving 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 Jul 2 11:28:59 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Thu, 02 Jul 2020 07:28:59 -0400 Subject: [Git][ghc/ghc][wip/andreask/ghc-bangs] 40 commits: Enable large address space optimization on windows. Message-ID: <5efdc4fb5f16a_80b3f846a54be3c1305060@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/ghc-bangs at Glasgow Haskell Compiler / GHC Commits: 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - e7b09415 by Andreas Klebinger at 2020-07-02T13:28:47+02:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 30 changed files: - .gitlab/test-metrics.sh - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/SPARC/CodeGen/Base.hs - compiler/GHC/CmmToAsm/SPARC/Regs.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Class.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/FamInstEnv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c7258cd7fa9912fd8c362a10a47fdc2580cd26ce...e7b094156ee117785d54b4915236753223399264 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c7258cd7fa9912fd8c362a10a47fdc2580cd26ce...e7b094156ee117785d54b4915236753223399264 You're receiving 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 Jul 2 12:31:59 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Thu, 02 Jul 2020 08:31:59 -0400 Subject: [Git][ghc/ghc][wip/andreask/strict_dicts] 33 commits: Enable large address space optimization on windows. Message-ID: <5efdd3bfb2053_80bf18931813120b6@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/strict_dicts at Glasgow Haskell Compiler / GHC Commits: 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - edd339a8 by Andreas Klebinger at 2020-07-02T14:31:29+02:00 Enable strict dicts by default. - - - - - 30 changed files: - .gitlab/test-metrics.sh - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/SPARC/CodeGen/Base.hs - compiler/GHC/CmmToAsm/SPARC/Regs.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Class.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c57b6bb97c4ecc22ce0a41e35291d0a9adc70bb3...edd339a86e2bb88f760b668b20c6220408c44016 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c57b6bb97c4ecc22ce0a41e35291d0a9adc70bb3...edd339a86e2bb88f760b668b20c6220408c44016 You're receiving 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 Jul 2 13:58:45 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Thu, 02 Jul 2020 09:58:45 -0400 Subject: [Git][ghc/ghc][wip/T18341] 2 commits: Fix a few bugs Message-ID: <5efde8155666e_80bf1893181326629@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18341 at Glasgow Haskell Compiler / GHC Commits: f1cf8d5e by Sebastian Graf at 2020-07-02T15:54:13+02:00 Fix a few bugs - - - - - d1888d46 by Sebastian Graf at 2020-07-02T15:54:22+02:00 Accept tests - - - - - 4 changed files: - compiler/GHC/HsToCore/PmCheck.hs - compiler/GHC/HsToCore/PmCheck/Oracle.hs - testsuite/tests/pmcheck/should_compile/TooManyDeltas.hs - testsuite/tests/pmcheck/should_compile/TooManyDeltas.stderr Changes: ===================================== compiler/GHC/HsToCore/PmCheck.hs ===================================== @@ -992,19 +992,21 @@ checkGrdTree' (Rhs sdoc) deltas = do -- let x = e: Refine with x ~ e checkGrdTree' (Guard (PmLet x e) tree) deltas = do deltas' <- addPmCtDeltas deltas (PmCoreCt x e) + tracePm "check:Let" (ppr x <+> char '=' <+> ppr e) checkGrdTree' tree deltas' -- Bang x: Diverge on x ~ ⊥, refine with x /~ ⊥ checkGrdTree' (Guard (PmBang x) tree) deltas = do has_diverged <- addPmCtDeltas deltas (PmBotCt x) >>= isInhabited - tracePm "checkGrdTree':PmBang" (ppr deltas $$ ppr has_diverged $$ ppr x) deltas' <- addPmCtDeltas deltas (PmNotBotCt x) + tracePm "check:Bang" (ppr x <+> ppr has_diverged $$ ppr deltas') res <- checkGrdTree' tree deltas' pure res{ cr_clauses = applyWhen has_diverged mayDiverge (cr_clauses res) } -- Con: Fall through on x /~ K, refine with x ~ K ys and type info checkGrdTree' (Guard (PmCon x con tvs dicts args) tree) deltas = do unc_this <- addPmCtDeltas deltas (PmNotConCt x con) - tracePm "checkGrdTree'" (ppr deltas $$ ppr (pmConCts x con tvs dicts args)) - deltas' <- addPmCtsDeltas deltas (pmConCts x con tvs dicts args) + let cts = pmConCts x con tvs dicts args + tracePm "check:Con" (ppr cts) + deltas' <- addPmCtsDeltas deltas cts CheckResult tree' unc_inner prec <- checkGrdTree' tree deltas' limit <- maxPmCheckModels <$> getDynFlags let (prec', unc') = throttle limit deltas (unc_this Semi.<> unc_inner) @@ -1014,6 +1016,7 @@ checkGrdTree' (Guard (PmCon x con tvs dicts args) tree) deltas = do , cr_approx = prec Semi.<> prec' } -- Sequence: Thread residual uncovered sets from equation to equation checkGrdTree' (Sequence l r) unc_0 = do + tracePm "check:Sequence:l" (ppr l) CheckResult l' unc_1 prec_l <- checkGrdTree' l unc_0 CheckResult r' unc_2 prec_r <- checkGrdTree' r unc_1 pure CheckResult ===================================== compiler/GHC/HsToCore/PmCheck/Oracle.hs ===================================== @@ -518,7 +518,7 @@ tyIsSatisfiable recheck_complete_sets new_ty_cs = SC $ \delta -> Just ty_st' -> do let delta' = delta{ delta_ty_st = ty_st' } if recheck_complete_sets - then ensureAllPossibleMatchesInhabited delta' + then ensureAllInhabited delta' else pure (Just delta') @@ -705,13 +705,6 @@ initPossibleMatches ty_st vi at VI{ vi_ty = ty, vi_cache = NoPM } = do Just cs -> pure vi{ vi_ty = ty', vi_cache = PM (mkUniqDSet <$> cs) } initPossibleMatches _ vi = pure vi --- | @initLookupVarInfo ts x@ looks up the 'VarInfo' for @x@ in @ts@ and tries --- to initialise the 'vi_cache' component if it was 'NoPM' through --- 'initPossibleMatches'. -initLookupVarInfo :: Delta -> Id -> DsM VarInfo -initLookupVarInfo MkDelta{ delta_tm_st = ts, delta_ty_st = ty_st } x - = initPossibleMatches ty_st (lookupVarInfo ts x) - {- Note [COMPLETE sets on data families] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ User-defined COMPLETE sets involving data families are attached to the family @@ -919,8 +912,8 @@ addBotCt delta at MkDelta{ delta_tm_st = TmSt env reps } x = do -- that leads to a contradiction. -- See Note [TmState invariants]. addNotConCt :: Delta -> Id -> PmAltCon -> MaybeT DsM Delta -addNotConCt delta at MkDelta{ delta_tm_st = TmSt env reps } x nalt = do - vi@(VI _ pos neg _ pm) <- lift (initLookupVarInfo delta x) +addNotConCt delta at MkDelta{ delta_tm_st = ts@(TmSt env reps) } x nalt = do + let vi@(VI _ pos neg _ pm) = lookupVarInfo ts x -- 1. Bail out quickly when nalt contradicts a solution let contradicts nalt (cl, _tvs, _args) = eqPmAltCon cl nalt == Equal guard (not (any (contradicts nalt) pos)) @@ -932,13 +925,13 @@ addNotConCt delta at MkDelta{ delta_tm_st = TmSt env reps } x nalt = do -- See Note [Completeness checking with required Thetas] | hasRequiredTheta nalt = neg | otherwise = extendPmAltConSet neg nalt - let vi_ext = vi{ vi_neg = neg' } + let vi1 = vi{ vi_neg = neg' } -- 3. Make sure there's at least one other possible constructor - vi' <- case nalt of + vi2 <- case nalt of PmAltConLike cl - -> MaybeT (ensureInhabited delta vi_ext{ vi_cache = markMatched cl pm }) - _ -> pure vi_ext - pure delta{ delta_tm_st = TmSt (setEntrySDIE env x vi') reps } + -> MaybeT (ensureInhabited delta vi1{ vi_cache = markMatched cl pm }) + _ -> pure vi1 + pure delta{ delta_tm_st = TmSt (setEntrySDIE env x vi2) reps } hasRequiredTheta :: PmAltCon -> Bool hasRequiredTheta (PmAltConLike cl) = notNull req_theta @@ -1010,8 +1003,8 @@ addNotBotCt delta at MkDelta{ delta_tm_st = TmSt env reps } x = do Just True -> mzero -- There was x ~ ⊥. Contradiction! Just False -> pure delta -- There already is x /~ ⊥. Nothing left to do Nothing -> do -- We add x /~ ⊥ and test if x is still inhabited - vi' <- MaybeT $ ensureInhabited delta vi{ vi_bot = Just False } - pure delta{ delta_tm_st = TmSt (setEntrySDIE env y vi') reps} + vi <- MaybeT $ ensureInhabited delta vi{ vi_bot = Just False } + pure delta{ delta_tm_st = TmSt (setEntrySDIE env y vi) reps} ensureInhabited :: Delta -> VarInfo -> DsM (Maybe VarInfo) -- Returns (Just vi) if at least one member of each ConLike in the COMPLETE @@ -1024,7 +1017,9 @@ ensureInhabited :: Delta -> VarInfo -> DsM (Maybe VarInfo) -- avoids doing unnecessary work. ensureInhabited _ vi at VI{ vi_bot = Nothing } = pure (Just vi) ensureInhabited _ vi at VI{ vi_bot = Just True } = pure (Just vi) -ensureInhabited delta vi = fmap (set_cache vi) <$> test (vi_cache vi) -- This would be much less tedious with lenses +ensureInhabited delta vi = do + vi <- initPossibleMatches (delta_ty_st delta) vi + fmap (set_cache vi) <$> test (vi_cache vi) where set_cache vi cache = vi { vi_cache = cache } @@ -1059,7 +1054,7 @@ ensureInhabited delta vi = fmap (set_cache vi) <$> test (vi_cache vi) -- This wo -- No need to run the term oracle compared to pmIsSatisfiable fmap isJust <$> runSatisfiabilityCheck delta $ mconcat -- Important to pass False to tyIsSatisfiable here, so that we won't - -- recursively call ensureAllPossibleMatchesInhabited, leading to an + -- recursively call ensureAllInhabited, leading to an -- endless recursion. [ tyIsSatisfiable False ty_cs , tysAreNonVoid initRecTc strict_arg_tys @@ -1069,8 +1064,8 @@ ensureInhabited delta vi = fmap (set_cache vi) <$> test (vi_cache vi) -- This wo -- 'vi_cache', considering the current type information in 'Delta'. -- This check is necessary after having matched on a GADT con to weed out -- impossible matches. -ensureAllPossibleMatchesInhabited :: Delta -> DsM (Maybe Delta) -ensureAllPossibleMatchesInhabited delta at MkDelta{ delta_tm_st = TmSt env reps } +ensureAllInhabited :: Delta -> DsM (Maybe Delta) +ensureAllInhabited delta at MkDelta{ delta_tm_st = TmSt env reps } = runMaybeT (set_tm_cs_env delta <$> traverseSDIE go env) where set_tm_cs_env delta env = delta{ delta_tm_st = TmSt env reps } @@ -1136,8 +1131,8 @@ equate delta at MkDelta{ delta_tm_st = TmSt env reps } x y -- -- See Note [TmState invariants]. addConCt :: Delta -> Id -> PmAltCon -> [TyVar] -> [Id] -> MaybeT DsM Delta -addConCt delta at MkDelta{ delta_tm_st = TmSt env reps } x alt tvs args = do - VI ty pos neg bot cache <- lift (initLookupVarInfo delta x) +addConCt delta at MkDelta{ delta_tm_st = ts@(TmSt env reps) } x alt tvs args = do + let VI ty pos neg bot cache = lookupVarInfo ts x -- 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 @@ -1562,7 +1557,7 @@ provideEvidence = go go [] _ delta = pure [delta] go (x:xs) n delta = do tracePm "provideEvidence" (ppr x $$ ppr xs $$ ppr delta $$ ppr n) - VI _ pos neg _ _ <- initLookupVarInfo delta x + let VI _ pos neg _ _ = lookupVarInfo (delta_tm_st delta) x case pos of _:_ -> do -- All solutions must be valid at once. Try to find candidates for their @@ -1600,8 +1595,9 @@ provideEvidence = go Nothing -> pure [] Just (y, newty_delta) -> do -- Pick a COMPLETE set and instantiate it (n at max). Take care of ⊥. - pm <- vi_cache <$> initLookupVarInfo newty_delta y - mb_cls <- pickMinimalCompleteSet newty_delta pm + let vi = lookupVarInfo (delta_tm_st newty_delta) y + vi <- initPossibleMatches (delta_ty_st newty_delta) vi + mb_cls <- pickMinimalCompleteSet newty_delta (vi_cache vi) case uniqDSetToList <$> mb_cls of Just cls@(_:_) -> instantiate_cons y core_ty xs n newty_delta cls Just [] | not (canDiverge newty_delta y) -> pure [] ===================================== testsuite/tests/pmcheck/should_compile/TooManyDeltas.hs ===================================== @@ -3,8 +3,10 @@ -- As a result, these functions elicit the symptoms describe in the warnings -- message, e.g. -- - False positives on exhaustivity --- - Turns redundant into inaccessible clauses -- - Fails to report redundant matches +-- +-- We used to turn redundant into inaccessible clauses, but SG was unable to +-- produce a testcase. See the comment below. module TooManyDeltas where data T = A | B @@ -13,12 +15,19 @@ data T = A | B f :: T -> T -> () f A A = () +-- SG: As of July 2020, g doesn't reproduce anymore. +-- Because we treat constructor matches lazily and push data con match +-- strictness into a preceding bang guard, The single place that calls the +-- throttling function will not regress in laziness. Note that by throttling we +-- can only "forget" the x /~ K constraint from unc_this, not the preceding +-- x /~ ⊥ constraint. + -- | Reports that the third clause is inaccessible, when really it is -- redundant. g :: T -> T -> () g _ A = () g A A = () -- inaccessible, correctly flagged -g A A = () -- redundant, not inaccessible! +g A A = () -- redundant, used to be inaccessible (see above). g _ _ = () -- (this one is not about exhaustivity) -- | Fails to report that the second clause is redundant. ===================================== testsuite/tests/pmcheck/should_compile/TooManyDeltas.stderr ===================================== @@ -1,12 +1,12 @@ -TooManyDeltas.hs:14:1: warning: +TooManyDeltas.hs:16:1: warning: Pattern match checker ran into -fmax-pmcheck-models=0 limit, so • Redundant clauses might not be reported at all • Redundant clauses might be reported as inaccessible • Patterns reported as unmatched might actually be matched Increase the limit or resolve the warnings to suppress this message. -TooManyDeltas.hs:14:1: warning: [-Wincomplete-patterns (in -Wextra)] +TooManyDeltas.hs:16:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘f’: Patterns not matched: @@ -15,17 +15,17 @@ TooManyDeltas.hs:14:1: warning: [-Wincomplete-patterns (in -Wextra)] B A B B -TooManyDeltas.hs:19:1: warning: +TooManyDeltas.hs:28:1: warning: Pattern match checker ran into -fmax-pmcheck-models=0 limit, so • Redundant clauses might not be reported at all • Redundant clauses might be reported as inaccessible • Patterns reported as unmatched might actually be matched Increase the limit or resolve the warnings to suppress this message. -TooManyDeltas.hs:20:1: warning: [-Woverlapping-patterns (in -Wdefault)] +TooManyDeltas.hs:29:1: warning: [-Woverlapping-patterns (in -Wdefault)] Pattern match has inaccessible right hand side In an equation for ‘g’: g A A = ... -TooManyDeltas.hs:21:1: warning: [-Woverlapping-patterns (in -Wdefault)] - Pattern match has inaccessible right hand side +TooManyDeltas.hs:30:1: warning: [-Woverlapping-patterns (in -Wdefault)] + Pattern match is redundant In an equation for ‘g’: g A A = ... View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/874ab47e9924257eff4887a710a7c62dc51de854...d1888d46e4cbb27f7d0a3ba89bf4f69bfc5776f0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/874ab47e9924257eff4887a710a7c62dc51de854...d1888d46e4cbb27f7d0a3ba89bf4f69bfc5776f0 You're receiving 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 Jul 2 14:46:34 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 02 Jul 2020 10:46:34 -0400 Subject: [Git][ghc/ghc][master] Hadrian: fix PowerPC64le support (#17601) Message-ID: <5efdf34a3d54a_80b3f848657952813440ac@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 1 changed file: - hadrian/src/Hadrian/Haskell/Cabal.hs Changes: ===================================== hadrian/src/Hadrian/Haskell/Cabal.hs ===================================== @@ -59,9 +59,10 @@ pkgGenericDescription = fmap genericPackageDescription . readPackageData -- -- Inverse of 'Cabal.Distribution.Simple.GHC.ghcArchString'. cabalArchString :: String -> String -cabalArchString "powerpc" = "ppc" -cabalArchString "powerpc64" = "ppc64" -cabalArchString other = other +cabalArchString "powerpc" = "ppc" +cabalArchString "powerpc64" = "ppc64" +cabalArchString "powerpc64le" = "ppc64" +cabalArchString other = other -- | Cabal's rendering of an OS as used in its directory structure. -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23e4e04700f840e3c4e75ccb2085aea05bfb5318 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23e4e04700f840e3c4e75ccb2085aea05bfb5318 You're receiving 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 Jul 2 14:47:14 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 02 Jul 2020 10:47:14 -0400 Subject: [Git][ghc/ghc][master] NCG: correctly handle addresses with huge offsets (#15570) Message-ID: <5efdf3725aca8_80b3f846a54be3c13483f4@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 3 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - + testsuite/tests/codeGen/should_compile/T15570.hs - testsuite/tests/codeGen/should_compile/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -1241,71 +1241,89 @@ reg2reg format src dst = MOV format (OpReg src) (OpReg dst) -------------------------------------------------------------------------------- + +-- | Convert a 'CmmExpr' representing a memory address into an 'Amode'. +-- +-- An 'Amode' is a datatype representing a valid address form for the target +-- (e.g. "Base + Index + disp" or immediate) and the code to compute it. getAmode :: CmmExpr -> NatM Amode -getAmode e = do is32Bit <- is32BitPlatform - getAmode' is32Bit e +getAmode e = do + platform <- getPlatform + let is32Bit = target32Bit platform + + case e of + CmmRegOff r n + -> getAmode $ mangleIndexTree platform r n + + CmmMachOp (MO_Add W64) [CmmReg (CmmGlobal PicBaseReg), CmmLit displacement] + | not is32Bit + -> return $ Amode (ripRel (litToImm displacement)) nilOL + + -- This is all just ridiculous, since it carefully undoes + -- what mangleIndexTree has just done. + CmmMachOp (MO_Sub _rep) [x, CmmLit lit@(CmmInt i _)] + | is32BitLit is32Bit lit + -- ASSERT(rep == II32)??? + -> do + (x_reg, x_code) <- getSomeReg x + let off = ImmInt (-(fromInteger i)) + return (Amode (AddrBaseIndex (EABaseReg x_reg) EAIndexNone off) x_code) + + CmmMachOp (MO_Add _rep) [x, CmmLit lit] + | is32BitLit is32Bit lit + -- ASSERT(rep == II32)??? + -> do + (x_reg, x_code) <- getSomeReg x + let off = litToImm lit + return (Amode (AddrBaseIndex (EABaseReg x_reg) EAIndexNone off) x_code) + + -- Turn (lit1 << n + lit2) into (lit2 + lit1 << n) so it will be + -- recognised by the next rule. + CmmMachOp (MO_Add rep) [a@(CmmMachOp (MO_Shl _) _), b@(CmmLit _)] + -> getAmode (CmmMachOp (MO_Add rep) [b,a]) + + -- Matches: (x + offset) + (y << shift) + CmmMachOp (MO_Add _) [CmmRegOff x offset, CmmMachOp (MO_Shl _) [y, CmmLit (CmmInt shift _)]] + | shift == 0 || shift == 1 || shift == 2 || shift == 3 + -> x86_complex_amode (CmmReg x) y shift (fromIntegral offset) + + CmmMachOp (MO_Add _) [x, CmmMachOp (MO_Shl _) [y, CmmLit (CmmInt shift _)]] + | shift == 0 || shift == 1 || shift == 2 || shift == 3 + -> x86_complex_amode x y shift 0 + + CmmMachOp (MO_Add _) [x, CmmMachOp (MO_Add _) [CmmMachOp (MO_Shl _) + [y, CmmLit (CmmInt shift _)], CmmLit (CmmInt offset _)]] + | shift == 0 || shift == 1 || shift == 2 || shift == 3 + && is32BitInteger offset + -> x86_complex_amode x y shift offset + + CmmMachOp (MO_Add _) [x,y] + | not (isLit y) -- we already handle valid literals above. + -> x86_complex_amode x y 0 0 + + CmmLit lit + | is32BitLit is32Bit lit + -> return (Amode (ImmAddr (litToImm lit) 0) nilOL) + + -- Literal with offsets too big (> 32 bits) fails during the linking phase + -- (#15570). We already handled valid literals above so we don't have to + -- test anything here. + CmmLit (CmmLabelOff l off) + -> getAmode (CmmMachOp (MO_Add W64) [ CmmLit (CmmLabel l) + , CmmLit (CmmInt (fromIntegral off) W64) + ]) + CmmLit (CmmLabelDiffOff l1 l2 off w) + -> getAmode (CmmMachOp (MO_Add W64) [ CmmLit (CmmLabelDiffOff l1 l2 0 w) + , CmmLit (CmmInt (fromIntegral off) W64) + ]) + + -- in case we can't do something better, we just compute the expression + -- and put the result in a register + _ -> do + (reg,code) <- getSomeReg e + return (Amode (AddrBaseIndex (EABaseReg reg) EAIndexNone (ImmInt 0)) code) -getAmode' :: Bool -> CmmExpr -> NatM Amode -getAmode' _ (CmmRegOff r n) = do platform <- getPlatform - getAmode $ mangleIndexTree platform r n -getAmode' is32Bit (CmmMachOp (MO_Add W64) [CmmReg (CmmGlobal PicBaseReg), - CmmLit displacement]) - | not is32Bit - = return $ Amode (ripRel (litToImm displacement)) nilOL - - --- This is all just ridiculous, since it carefully undoes --- what mangleIndexTree has just done. -getAmode' is32Bit (CmmMachOp (MO_Sub _rep) [x, CmmLit lit@(CmmInt i _)]) - | is32BitLit is32Bit lit - -- ASSERT(rep == II32)??? - = do (x_reg, x_code) <- getSomeReg x - let off = ImmInt (-(fromInteger i)) - return (Amode (AddrBaseIndex (EABaseReg x_reg) EAIndexNone off) x_code) - -getAmode' is32Bit (CmmMachOp (MO_Add _rep) [x, CmmLit lit]) - | is32BitLit is32Bit lit - -- ASSERT(rep == II32)??? - = do (x_reg, x_code) <- getSomeReg x - let off = litToImm lit - return (Amode (AddrBaseIndex (EABaseReg x_reg) EAIndexNone off) x_code) - --- Turn (lit1 << n + lit2) into (lit2 + lit1 << n) so it will be --- recognised by the next rule. -getAmode' is32Bit (CmmMachOp (MO_Add rep) [a@(CmmMachOp (MO_Shl _) _), - b@(CmmLit _)]) - = getAmode' is32Bit (CmmMachOp (MO_Add rep) [b,a]) - --- Matches: (x + offset) + (y << shift) -getAmode' _ (CmmMachOp (MO_Add _) [CmmRegOff x offset, - CmmMachOp (MO_Shl _) - [y, CmmLit (CmmInt shift _)]]) - | shift == 0 || shift == 1 || shift == 2 || shift == 3 - = x86_complex_amode (CmmReg x) y shift (fromIntegral offset) - -getAmode' _ (CmmMachOp (MO_Add _) [x, CmmMachOp (MO_Shl _) - [y, CmmLit (CmmInt shift _)]]) - | shift == 0 || shift == 1 || shift == 2 || shift == 3 - = x86_complex_amode x y shift 0 - -getAmode' _ (CmmMachOp (MO_Add _) - [x, CmmMachOp (MO_Add _) - [CmmMachOp (MO_Shl _) [y, CmmLit (CmmInt shift _)], - CmmLit (CmmInt offset _)]]) - | shift == 0 || shift == 1 || shift == 2 || shift == 3 - && is32BitInteger offset - = x86_complex_amode x y shift offset - -getAmode' _ (CmmMachOp (MO_Add _) [x,y]) - = x86_complex_amode x y 0 0 - -getAmode' is32Bit (CmmLit lit) | is32BitLit is32Bit lit - = return (Amode (ImmAddr (litToImm lit) 0) nilOL) - -getAmode' _ expr = do - (reg,code) <- getSomeReg expr - return (Amode (AddrBaseIndex (EABaseReg reg) EAIndexNone (ImmInt 0)) code) -- | Like 'getAmode', but on 32-bit use simple register addressing -- (i.e. no index register). This stops us from running out of @@ -1510,11 +1528,17 @@ getRegOrMem e = do return (OpReg reg, code) is32BitLit :: Bool -> CmmLit -> Bool -is32BitLit is32Bit (CmmInt i W64) - | not is32Bit - = -- assume that labels are in the range 0-2^31-1: this assumes the +is32BitLit is32Bit lit + | not is32Bit = case lit of + CmmInt i W64 -> is32BitInteger i + -- assume that labels are in the range 0-2^31-1: this assumes the -- small memory model (see gcc docs, -mcmodel=small). - is32BitInteger i + CmmLabel _ -> True + -- however we can't assume that label offsets are in this range + -- (see #15570) + CmmLabelOff _ off -> is32BitInteger (fromIntegral off) + CmmLabelDiffOff _ _ off _ -> is32BitInteger (fromIntegral off) + _ -> True is32BitLit _ _ = True ===================================== testsuite/tests/codeGen/should_compile/T15570.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE MagicHash #-} +import GHC.Exts + +main :: IO () +main = print $ C# (indexCharOffAddr# "foo"# -9223372036854775808#) ===================================== testsuite/tests/codeGen/should_compile/all.T ===================================== @@ -91,3 +91,8 @@ test('T17648', normal, makefile_test, []) test('T17904', normal, compile, ['-O']) test('T18227A', normal, compile, ['']) test('T18227B', normal, compile, ['']) +test('T15570', + when(unregisterised(), skip), + compile, ['-Wno-overflowed-literals']) + # skipped with CmmToC because it generates a warning: + # warning: integer constant is so large that it is unsigned View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3cdd8d69f5c1d63137b9b56992bb9b74a6785459 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3cdd8d69f5c1d63137b9b56992bb9b74a6785459 You're receiving 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 Jul 2 15:17:59 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 02 Jul 2020 11:17:59 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Hadrian: fix PowerPC64le support (#17601) Message-ID: <5efdfaa735766_80b3f84901f1bd0137205d@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 86125c20 by Gabor Greif at 2020-07-02T11:17:51-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - ddfbf392 by Sylvain Henry at 2020-07-02T11:17:52-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 24 changed files: - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Ways.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Runtime/Heap/Layout.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/StgToCmm/Bind.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/StgToCmm/Layout.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToCmm/Prof.hs - hadrian/src/Hadrian/Haskell/Cabal.hs - + testsuite/tests/codeGen/should_compile/T15570.hs - testsuite/tests/codeGen/should_compile/all.T Changes: ===================================== aclocal.m4 ===================================== @@ -1875,7 +1875,6 @@ AC_DEFUN([FP_CURSES], [directory containing curses libraries])], [CURSES_LIB_DIRS=$withval]) - AC_SUBST(CURSES_INCLUDE_DIRS) AC_SUBST(CURSES_LIB_DIRS) ])# FP_CURSES ===================================== compiler/GHC.hs ===================================== @@ -605,10 +605,12 @@ setSessionDynFlags dflags = do then do let prog = pgm_i dflags ++ flavour + profiled = ways dflags `hasWay` WayProf + dynamic = ways dflags `hasWay` WayDyn flavour - | WayProf `S.member` ways dflags = "-prof" - | WayDyn `S.member` ways dflags = "-dyn" - | otherwise = "" + | profiled = "-prof" -- FIXME: can't we have both? + | dynamic = "-dyn" + | otherwise = "" msg = text "Starting " <> text prog tr <- if verbosity dflags >= 3 then return (logInfo dflags $ withPprStyle defaultDumpStyle msg) @@ -617,8 +619,8 @@ setSessionDynFlags dflags = do conf = IServConfig { iservConfProgram = prog , iservConfOpts = getOpts dflags opt_i - , iservConfProfiled = gopt Opt_SccProfilingOn dflags - , iservConfDynamic = WayDyn `S.member` ways dflags + , iservConfProfiled = profiled + , iservConfDynamic = dynamic , iservConfHook = createIservProcessHook (hooks dflags) , iservConfTrace = tr } ===================================== compiler/GHC/Cmm/Info.hs ===================================== @@ -405,7 +405,7 @@ mkStdInfoTable dflags (type_descr, closure_descr) cl_type srt layout_lit where platform = targetPlatform dflags prof_info - | gopt Opt_SccProfilingOn dflags = [type_descr, closure_descr] + | sccProfilingEnabled dflags = [type_descr, closure_descr] | otherwise = [] tag = CmmInt (fromIntegral cl_type) (halfWordWidth platform) @@ -565,7 +565,7 @@ stdInfoTableSizeW :: DynFlags -> WordOff -- It must vary in sync with mkStdInfoTable stdInfoTableSizeW dflags = fixedInfoTableSizeW - + if gopt Opt_SccProfilingOn dflags + + if sccProfilingEnabled dflags then profInfoTableSizeW else 0 ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1168,7 +1168,7 @@ reserveStackFrame psize preg body = do withUpdFrameOff frame body profilingInfo dflags desc_str ty_str - = if not (gopt Opt_SccProfilingOn dflags) + = if not (sccProfilingEnabled dflags) then NoProfilingInfo else ProfilingInfo (BS8.pack desc_str) (BS8.pack ty_str) ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -1241,71 +1241,89 @@ reg2reg format src dst = MOV format (OpReg src) (OpReg dst) -------------------------------------------------------------------------------- + +-- | Convert a 'CmmExpr' representing a memory address into an 'Amode'. +-- +-- An 'Amode' is a datatype representing a valid address form for the target +-- (e.g. "Base + Index + disp" or immediate) and the code to compute it. getAmode :: CmmExpr -> NatM Amode -getAmode e = do is32Bit <- is32BitPlatform - getAmode' is32Bit e +getAmode e = do + platform <- getPlatform + let is32Bit = target32Bit platform + + case e of + CmmRegOff r n + -> getAmode $ mangleIndexTree platform r n + + CmmMachOp (MO_Add W64) [CmmReg (CmmGlobal PicBaseReg), CmmLit displacement] + | not is32Bit + -> return $ Amode (ripRel (litToImm displacement)) nilOL + + -- This is all just ridiculous, since it carefully undoes + -- what mangleIndexTree has just done. + CmmMachOp (MO_Sub _rep) [x, CmmLit lit@(CmmInt i _)] + | is32BitLit is32Bit lit + -- ASSERT(rep == II32)??? + -> do + (x_reg, x_code) <- getSomeReg x + let off = ImmInt (-(fromInteger i)) + return (Amode (AddrBaseIndex (EABaseReg x_reg) EAIndexNone off) x_code) + + CmmMachOp (MO_Add _rep) [x, CmmLit lit] + | is32BitLit is32Bit lit + -- ASSERT(rep == II32)??? + -> do + (x_reg, x_code) <- getSomeReg x + let off = litToImm lit + return (Amode (AddrBaseIndex (EABaseReg x_reg) EAIndexNone off) x_code) + + -- Turn (lit1 << n + lit2) into (lit2 + lit1 << n) so it will be + -- recognised by the next rule. + CmmMachOp (MO_Add rep) [a@(CmmMachOp (MO_Shl _) _), b@(CmmLit _)] + -> getAmode (CmmMachOp (MO_Add rep) [b,a]) + + -- Matches: (x + offset) + (y << shift) + CmmMachOp (MO_Add _) [CmmRegOff x offset, CmmMachOp (MO_Shl _) [y, CmmLit (CmmInt shift _)]] + | shift == 0 || shift == 1 || shift == 2 || shift == 3 + -> x86_complex_amode (CmmReg x) y shift (fromIntegral offset) + + CmmMachOp (MO_Add _) [x, CmmMachOp (MO_Shl _) [y, CmmLit (CmmInt shift _)]] + | shift == 0 || shift == 1 || shift == 2 || shift == 3 + -> x86_complex_amode x y shift 0 + + CmmMachOp (MO_Add _) [x, CmmMachOp (MO_Add _) [CmmMachOp (MO_Shl _) + [y, CmmLit (CmmInt shift _)], CmmLit (CmmInt offset _)]] + | shift == 0 || shift == 1 || shift == 2 || shift == 3 + && is32BitInteger offset + -> x86_complex_amode x y shift offset + + CmmMachOp (MO_Add _) [x,y] + | not (isLit y) -- we already handle valid literals above. + -> x86_complex_amode x y 0 0 + + CmmLit lit + | is32BitLit is32Bit lit + -> return (Amode (ImmAddr (litToImm lit) 0) nilOL) + + -- Literal with offsets too big (> 32 bits) fails during the linking phase + -- (#15570). We already handled valid literals above so we don't have to + -- test anything here. + CmmLit (CmmLabelOff l off) + -> getAmode (CmmMachOp (MO_Add W64) [ CmmLit (CmmLabel l) + , CmmLit (CmmInt (fromIntegral off) W64) + ]) + CmmLit (CmmLabelDiffOff l1 l2 off w) + -> getAmode (CmmMachOp (MO_Add W64) [ CmmLit (CmmLabelDiffOff l1 l2 0 w) + , CmmLit (CmmInt (fromIntegral off) W64) + ]) + + -- in case we can't do something better, we just compute the expression + -- and put the result in a register + _ -> do + (reg,code) <- getSomeReg e + return (Amode (AddrBaseIndex (EABaseReg reg) EAIndexNone (ImmInt 0)) code) -getAmode' :: Bool -> CmmExpr -> NatM Amode -getAmode' _ (CmmRegOff r n) = do platform <- getPlatform - getAmode $ mangleIndexTree platform r n -getAmode' is32Bit (CmmMachOp (MO_Add W64) [CmmReg (CmmGlobal PicBaseReg), - CmmLit displacement]) - | not is32Bit - = return $ Amode (ripRel (litToImm displacement)) nilOL - - --- This is all just ridiculous, since it carefully undoes --- what mangleIndexTree has just done. -getAmode' is32Bit (CmmMachOp (MO_Sub _rep) [x, CmmLit lit@(CmmInt i _)]) - | is32BitLit is32Bit lit - -- ASSERT(rep == II32)??? - = do (x_reg, x_code) <- getSomeReg x - let off = ImmInt (-(fromInteger i)) - return (Amode (AddrBaseIndex (EABaseReg x_reg) EAIndexNone off) x_code) - -getAmode' is32Bit (CmmMachOp (MO_Add _rep) [x, CmmLit lit]) - | is32BitLit is32Bit lit - -- ASSERT(rep == II32)??? - = do (x_reg, x_code) <- getSomeReg x - let off = litToImm lit - return (Amode (AddrBaseIndex (EABaseReg x_reg) EAIndexNone off) x_code) - --- Turn (lit1 << n + lit2) into (lit2 + lit1 << n) so it will be --- recognised by the next rule. -getAmode' is32Bit (CmmMachOp (MO_Add rep) [a@(CmmMachOp (MO_Shl _) _), - b@(CmmLit _)]) - = getAmode' is32Bit (CmmMachOp (MO_Add rep) [b,a]) - --- Matches: (x + offset) + (y << shift) -getAmode' _ (CmmMachOp (MO_Add _) [CmmRegOff x offset, - CmmMachOp (MO_Shl _) - [y, CmmLit (CmmInt shift _)]]) - | shift == 0 || shift == 1 || shift == 2 || shift == 3 - = x86_complex_amode (CmmReg x) y shift (fromIntegral offset) - -getAmode' _ (CmmMachOp (MO_Add _) [x, CmmMachOp (MO_Shl _) - [y, CmmLit (CmmInt shift _)]]) - | shift == 0 || shift == 1 || shift == 2 || shift == 3 - = x86_complex_amode x y shift 0 - -getAmode' _ (CmmMachOp (MO_Add _) - [x, CmmMachOp (MO_Add _) - [CmmMachOp (MO_Shl _) [y, CmmLit (CmmInt shift _)], - CmmLit (CmmInt offset _)]]) - | shift == 0 || shift == 1 || shift == 2 || shift == 3 - && is32BitInteger offset - = x86_complex_amode x y shift offset - -getAmode' _ (CmmMachOp (MO_Add _) [x,y]) - = x86_complex_amode x y 0 0 - -getAmode' is32Bit (CmmLit lit) | is32BitLit is32Bit lit - = return (Amode (ImmAddr (litToImm lit) 0) nilOL) - -getAmode' _ expr = do - (reg,code) <- getSomeReg expr - return (Amode (AddrBaseIndex (EABaseReg reg) EAIndexNone (ImmInt 0)) code) -- | Like 'getAmode', but on 32-bit use simple register addressing -- (i.e. no index register). This stops us from running out of @@ -1510,11 +1528,17 @@ getRegOrMem e = do return (OpReg reg, code) is32BitLit :: Bool -> CmmLit -> Bool -is32BitLit is32Bit (CmmInt i W64) - | not is32Bit - = -- assume that labels are in the range 0-2^31-1: this assumes the +is32BitLit is32Bit lit + | not is32Bit = case lit of + CmmInt i W64 -> is32BitInteger i + -- assume that labels are in the range 0-2^31-1: this assumes the -- small memory model (see gcc docs, -mcmodel=small). - is32BitInteger i + CmmLabel _ -> True + -- however we can't assume that label offsets are in this range + -- (see #15570) + CmmLabelOff _ off -> is32BitInteger (fromIntegral off) + CmmLabelDiffOff _ _ off _ -> is32BitInteger (fromIntegral off) + _ -> True is32BitLit _ _ = True ===================================== compiler/GHC/Driver/CodeOutput.hs ===================================== @@ -275,11 +275,9 @@ outputForeignStubs_help fname doc_str header footer -- module; -- | Generate code to initialise cost centres -profilingInitCode :: DynFlags -> Module -> CollectedCCs -> SDoc -profilingInitCode dflags this_mod (local_CCs, singleton_CCSs) - = if not (gopt Opt_SccProfilingOn dflags) - then empty - else vcat +profilingInitCode :: Module -> CollectedCCs -> SDoc +profilingInitCode this_mod (local_CCs, singleton_CCSs) + = vcat $ map emit_cc_decl local_CCs ++ map emit_ccs_decl singleton_CCSs ++ [emit_cc_list local_CCs] ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -252,7 +252,6 @@ data GeneralFlag | Opt_PIE -- ^ @-fPIE@ | Opt_PICExecutable -- ^ @-pie@ | Opt_ExternalDynamicRefs - | Opt_SccProfilingOn | Opt_Ticky | Opt_Ticky_Allocd | Opt_Ticky_LNE ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -1412,7 +1412,9 @@ hscGenHardCode hsc_env cgguts location output_filename = do let cost_centre_info = (S.toList local_ccs ++ caf_ccs, caf_cc_stacks) - prof_init = profilingInitCode dflags this_mod cost_centre_info + prof_init + | sccProfilingEnabled dflags = profilingInitCode this_mod cost_centre_info + | otherwise = empty foreign_stubs = foreign_stubs0 `appendStubC` prof_init ------------------ Code generation ------------------ ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -42,6 +42,7 @@ module GHC.Driver.Session ( whenCannotGenerateDynamicToo, dynamicTooMkDynamicDynFlags, dynamicOutputFile, + sccProfilingEnabled, DynFlags(..), FlagSpec(..), HasDynFlags(..), ContainsDynFlags(..), @@ -5094,6 +5095,10 @@ isBmi2Enabled dflags = case platformArch (targetPlatform dflags) of ArchX86 -> bmiVersion dflags >= Just BMI2 _ -> False +-- | Indicate if cost-centre profiling is enabled +sccProfilingEnabled :: DynFlags -> Bool +sccProfilingEnabled dflags = ways dflags `hasWay` WayProf + -- ----------------------------------------------------------------------------- -- Linker/compiler information ===================================== compiler/GHC/Driver/Ways.hs ===================================== @@ -20,6 +20,7 @@ -- this compilation. module GHC.Driver.Ways ( Way(..) + , hasWay , allowed_combination , wayGeneralFlags , wayUnsetGeneralFlags @@ -60,12 +61,15 @@ data Way | WayDyn -- ^ Dynamic linking deriving (Eq, Ord, Show) +-- | Test if a ways is enabled +hasWay :: Set Way -> Way -> Bool +hasWay ws w = Set.member w ws -- | Check if a combination of ways is allowed allowed_combination :: Set Way -> Bool allowed_combination ways = not disallowed where - disallowed = or [ Set.member ways x && Set.member ways y + disallowed = or [ hasWay ways x && hasWay ways y | (x,y) <- couples ] -- List of disallowed couples of ways @@ -121,7 +125,7 @@ wayGeneralFlags _ WayDyn = [Opt_PIC, Opt_ExternalDynamicRefs] -- .so before loading the .so using the system linker. Since only -- PIC objects can be linked into a .so, we have to compile even -- modules of the main program with -fPIC when using -dynamic. -wayGeneralFlags _ WayProf = [Opt_SccProfilingOn] +wayGeneralFlags _ WayProf = [] wayGeneralFlags _ WayEventLog = [] -- | Turn these flags off when enabling this way ===================================== compiler/GHC/HsToCore/Coverage.hs ===================================== @@ -1040,7 +1040,7 @@ coveragePasses :: DynFlags -> [TickishType] coveragePasses dflags = ifa (breakpointsEnabled dflags) Breakpoints $ ifa (gopt Opt_Hpc dflags) HpcTicks $ - ifa (gopt Opt_SccProfilingOn dflags && + ifa (sccProfilingEnabled dflags && profAuto dflags /= NoProfAuto) ProfNotes $ ifa (debugLevel dflags > 0) SourceNotes [] where ifa f x xs | f = x:xs ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -813,7 +813,7 @@ dsExpr (HsRecFld {}) = panic "dsExpr:HsRecFld" ds_prag_expr :: HsPragE GhcTc -> LHsExpr GhcTc -> DsM CoreExpr ds_prag_expr (HsPragSCC _ _ cc) expr = do dflags <- getDynFlags - if gopt Opt_SccProfilingOn dflags + if sccProfilingEnabled dflags then do mod_name <- getModule count <- goptM Opt_ProfCountEntries ===================================== compiler/GHC/Iface/Recomp/Flags.hs ===================================== @@ -55,7 +55,7 @@ fingerprintDynFlags dflags at DynFlags{..} this_mod nameio = paths = [ hcSuf ] -- -fprof-auto etc. - prof = if gopt Opt_SccProfilingOn dflags then fromEnum profAuto else 0 + prof = if sccProfilingEnabled dflags then fromEnum profAuto else 0 -- Ticky ticky = ===================================== compiler/GHC/Runtime/Heap/Layout.hs ===================================== @@ -282,8 +282,8 @@ fixedHdrSizeW dflags = sTD_HDR_SIZE dflags + profHdrSize dflags -- (StgProfHeader in includes\/rts\/storage\/Closures.h) profHdrSize :: DynFlags -> WordOff profHdrSize dflags - | gopt Opt_SccProfilingOn dflags = pROF_HDR_SIZE dflags - | otherwise = 0 + | sccProfilingEnabled dflags = pROF_HDR_SIZE dflags + | otherwise = 0 -- | The garbage collector requires that every closure is at least as -- big as this. ===================================== compiler/GHC/Stg/Syntax.hs ===================================== @@ -805,7 +805,7 @@ pprStgRhs :: OutputablePass pass => GenStgRhs pass -> SDoc pprStgRhs (StgRhsClosure ext cc upd_flag args body) = sdocWithDynFlags $ \dflags -> - hang (hsep [if gopt Opt_SccProfilingOn dflags then ppr cc else empty, + hang (hsep [if sccProfilingEnabled dflags then ppr cc else empty, ppUnlessOption sdocSuppressStgExts (ppr ext), char '\\' <> ppr upd_flag, brackets (interppSP args)]) 4 (ppr body) ===================================== compiler/GHC/StgToCmm/Bind.hs ===================================== @@ -307,7 +307,7 @@ mkRhsClosure dflags bndr _cc , all (isGcPtrRep . idPrimRep . fromNonVoid) fvs , isUpdatable upd_flag , n_fvs <= mAX_SPEC_AP_SIZE dflags - , not (gopt Opt_SccProfilingOn dflags) + , not (sccProfilingEnabled dflags) -- not when profiling: we don't want to -- lose information about this particular -- thunk (e.g. its type) (#949) @@ -626,7 +626,7 @@ emitBlackHoleCode node = do -- Note the eager-blackholing check is here rather than in blackHoleOnEntry, -- because emitBlackHoleCode is called from GHC.Cmm.Parser. - let eager_blackholing = not (gopt Opt_SccProfilingOn dflags) + let eager_blackholing = not (sccProfilingEnabled dflags) && gopt Opt_EagerBlackHoling dflags -- Profiling needs slop filling (to support LDV -- profiling), so currently eager blackholing doesn't @@ -655,7 +655,7 @@ setupUpdate closure_info node body dflags <- getDynFlags let bh = blackHoleOnEntry closure_info && - not (gopt Opt_SccProfilingOn dflags) && + not (sccProfilingEnabled dflags) && gopt Opt_EagerBlackHoling dflags lbl | bh = mkBHUpdInfoLabel ===================================== compiler/GHC/StgToCmm/Closure.hs ===================================== @@ -381,7 +381,7 @@ nodeMustPointToIt dflags (LFThunk top no_fvs updatable NonStandardThunk _) = not no_fvs -- Self parameter || isNotTopLevel top -- Note [GC recovery] || updatable -- Need to push update frame - || gopt Opt_SccProfilingOn dflags + || sccProfilingEnabled dflags -- For the non-updatable (single-entry case): -- -- True if has fvs (in which case we need access to them, and we @@ -508,7 +508,7 @@ getCallMethod dflags _ id _ n_args v_args _cg_loc getCallMethod dflags name id (LFReEntrant _ arity _ _) n_args _v_args _cg_loc _self_loop_info | n_args == 0 -- No args at all - && not (gopt Opt_SccProfilingOn dflags) + && not (sccProfilingEnabled dflags) -- See Note [Evaluating functions with profiling] in rts/Apply.cmm = ASSERT( arity /= 0 ) ReturnIt | n_args < arity = SlowCall -- Not enough args @@ -859,7 +859,7 @@ enterIdLabel platform id c mkProfilingInfo :: DynFlags -> Id -> String -> ProfilingInfo mkProfilingInfo dflags id val_descr - | not (gopt Opt_SccProfilingOn dflags) = NoProfilingInfo + | not (sccProfilingEnabled dflags) = NoProfilingInfo | otherwise = ProfilingInfo ty_descr_w8 (BS8.pack val_descr) where ty_descr_w8 = BS8.pack (getTyDescription (idType id)) @@ -906,8 +906,8 @@ mkDataConInfoTable dflags data_con is_static ptr_wds nonptr_wds -- We keep the *zero-indexed* tag in the srt_len field -- of the info table of a data constructor. - prof | not (gopt Opt_SccProfilingOn dflags) = NoProfilingInfo - | otherwise = ProfilingInfo ty_descr val_descr + prof | not (sccProfilingEnabled dflags) = NoProfilingInfo + | otherwise = ProfilingInfo ty_descr val_descr ty_descr = BS8.pack $ occNameString $ getOccName $ dataConTyCon data_con val_descr = BS8.pack $ occNameString $ getOccName data_con ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -306,7 +306,7 @@ saveThreadState dflags = do spExpr, close_nursery, -- and save the current cost centre stack in the TSO when profiling: - if gopt Opt_SccProfilingOn dflags then + if sccProfilingEnabled dflags then mkStore (cmmOffset platform (CmmReg (CmmLocal tso)) (tso_CCCS dflags)) cccsExpr else mkNop ] @@ -421,7 +421,7 @@ loadThreadState dflags = do mkAssign hpAllocReg (zeroExpr platform), open_nursery, -- and load the current cost centre stack from the TSO when profiling: - if gopt Opt_SccProfilingOn dflags + if sccProfilingEnabled dflags then storeCurCCS (CmmLoad (cmmOffset platform (CmmReg (CmmLocal tso)) (tso_CCCS dflags)) (ccsType platform)) ===================================== compiler/GHC/StgToCmm/Layout.hs ===================================== @@ -367,7 +367,7 @@ just more arguments that we are passing on the stack (cml_args). slowArgs :: DynFlags -> [(ArgRep, Maybe CmmExpr)] -> [(ArgRep, Maybe CmmExpr)] slowArgs _ [] = [] slowArgs dflags args -- careful: reps contains voids (V), but args does not - | gopt Opt_SccProfilingOn dflags + | sccProfilingEnabled dflags = save_cccs ++ this_pat ++ slowArgs dflags rest_args | otherwise = this_pat ++ slowArgs dflags rest_args where ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -300,8 +300,8 @@ emitPrimOp dflags = \case GetCCSOfOp -> \[arg] -> opAllDone $ \[res] -> do let val - | gopt Opt_SccProfilingOn dflags = costCentreFrom dflags (cmmUntag dflags arg) - | otherwise = CmmLit (zeroCLit platform) + | sccProfilingEnabled dflags = costCentreFrom dflags (cmmUntag dflags arg) + | otherwise = CmmLit (zeroCLit platform) emitAssign (CmmLocal res) val GetCurrentCCSOp -> \[_] -> opAllDone $ \[res] -> do ===================================== compiler/GHC/StgToCmm/Prof.hs ===================================== @@ -76,15 +76,15 @@ costCentreFrom dflags cl = CmmLoad (cmmOffsetB platform cl (oFFSET_StgHeader_ccs -- | The profiling header words in a static closure staticProfHdr :: DynFlags -> CostCentreStack -> [CmmLit] staticProfHdr dflags ccs - | gopt Opt_SccProfilingOn dflags = [mkCCostCentreStack ccs, staticLdvInit platform] - | otherwise = [] + | sccProfilingEnabled dflags = [mkCCostCentreStack ccs, staticLdvInit platform] + | otherwise = [] where platform = targetPlatform dflags -- | Profiling header words in a dynamic closure dynProfHdr :: DynFlags -> CmmExpr -> [CmmExpr] dynProfHdr dflags ccs - | gopt Opt_SccProfilingOn dflags = [ccs, dynLdvInit dflags] - | otherwise = [] + | sccProfilingEnabled dflags = [ccs, dynLdvInit dflags] + | otherwise = [] -- | Initialise the profiling field of an update frame initUpdFrameProf :: CmmExpr -> FCode () @@ -130,7 +130,7 @@ saveCurrentCostCentre :: FCode (Maybe LocalReg) saveCurrentCostCentre = do dflags <- getDynFlags platform <- getPlatform - if not (gopt Opt_SccProfilingOn dflags) + if not (sccProfilingEnabled dflags) then return Nothing else do local_cc <- newTemp (ccType platform) emitAssign (CmmLocal local_cc) cccsExpr @@ -195,7 +195,7 @@ enterCostCentreFun ccs closure = ifProfiling :: FCode () -> FCode () ifProfiling code = do dflags <- getDynFlags - if gopt Opt_SccProfilingOn dflags + if sccProfilingEnabled dflags then code else return () @@ -207,7 +207,7 @@ initCostCentres :: CollectedCCs -> FCode () -- Emit the declarations initCostCentres (local_CCs, singleton_CCSs) = do dflags <- getDynFlags - when (gopt Opt_SccProfilingOn dflags) $ + when (sccProfilingEnabled dflags) $ do mapM_ emitCostCentreDecl local_CCs mapM_ emitCostCentreStackDecl singleton_CCSs @@ -277,7 +277,7 @@ emitSetCCC :: CostCentre -> Bool -> Bool -> FCode () emitSetCCC cc tick push = do dflags <- getDynFlags platform <- getPlatform - if not (gopt Opt_SccProfilingOn dflags) + if not (sccProfilingEnabled dflags) then return () else do tmp <- newTemp (ccsType platform) pushCostCentre tmp cccsExpr cc ===================================== hadrian/src/Hadrian/Haskell/Cabal.hs ===================================== @@ -59,9 +59,10 @@ pkgGenericDescription = fmap genericPackageDescription . readPackageData -- -- Inverse of 'Cabal.Distribution.Simple.GHC.ghcArchString'. cabalArchString :: String -> String -cabalArchString "powerpc" = "ppc" -cabalArchString "powerpc64" = "ppc64" -cabalArchString other = other +cabalArchString "powerpc" = "ppc" +cabalArchString "powerpc64" = "ppc64" +cabalArchString "powerpc64le" = "ppc64" +cabalArchString other = other -- | Cabal's rendering of an OS as used in its directory structure. -- ===================================== testsuite/tests/codeGen/should_compile/T15570.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE MagicHash #-} +import GHC.Exts + +main :: IO () +main = print $ C# (indexCharOffAddr# "foo"# -9223372036854775808#) ===================================== testsuite/tests/codeGen/should_compile/all.T ===================================== @@ -91,3 +91,8 @@ test('T17648', normal, makefile_test, []) test('T17904', normal, compile, ['-O']) test('T18227A', normal, compile, ['']) test('T18227B', normal, compile, ['']) +test('T15570', + when(unregisterised(), skip), + compile, ['-Wno-overflowed-literals']) + # skipped with CmmToC because it generates a warning: + # warning: integer constant is so large that it is unsigned View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dc31cc3bbc83ddd07ec5fd9197595226ce123d74...ddfbf39253815245653d39c941792859c2948521 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dc31cc3bbc83ddd07ec5fd9197595226ce123d74...ddfbf39253815245653d39c941792859c2948521 You're receiving 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 Jul 2 15:45:52 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Thu, 02 Jul 2020 11:45:52 -0400 Subject: [Git][ghc/ghc][wip/andreask/typedUniqFM] 51 commits: Switch from HscSource to IsBootInterface for module lookup in GhcMake Message-ID: <5efe013031a6f_80b3f84901f1bd013892a4@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/typedUniqFM at Glasgow Haskell Compiler / GHC Commits: 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - e05c7739 by Andreas Klebinger at 2020-07-02T17:45:35+02:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - 30 changed files: - .gitlab/test-metrics.sh - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/84bf48a488b9972505bfa9270f095d846a2917e1...e05c773906d1712b0e15de1272020c200cb9bd63 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/84bf48a488b9972505bfa9270f095d846a2917e1...e05c773906d1712b0e15de1272020c200cb9bd63 You're receiving 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 Jul 2 16:24:00 2020 From: gitlab at gitlab.haskell.org (Josh Meredith) Date: Thu, 02 Jul 2020 12:24:00 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/pluginExtFields Message-ID: <5efe0a20ed217_80b3f8490290e381396148@gitlab.haskell.org.mail> Josh Meredith pushed new branch wip/pluginExtFields at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/pluginExtFields You're receiving 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 Jul 3 00:08:04 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 02 Jul 2020 20:08:04 -0400 Subject: [Git][ghc/ghc][master] No need for CURSES_INCLUDE_DIRS Message-ID: <5efe76e492751_80b3f84900d22041459950@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - 1 changed file: - aclocal.m4 Changes: ===================================== aclocal.m4 ===================================== @@ -1875,7 +1875,6 @@ AC_DEFUN([FP_CURSES], [directory containing curses libraries])], [CURSES_LIB_DIRS=$withval]) - AC_SUBST(CURSES_INCLUDE_DIRS) AC_SUBST(CURSES_LIB_DIRS) ])# FP_CURSES View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d90b3ff02002ea25460d087dde56f69a9641096 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d90b3ff02002ea25460d087dde56f69a9641096 You're receiving 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 Jul 3 00:08:45 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 02 Jul 2020 20:08:45 -0400 Subject: [Git][ghc/ghc][master] Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function Message-ID: <5efe770d62007_80b3f8469a4048414648b4@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 19 changed files: - compiler/GHC.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Ways.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Runtime/Heap/Layout.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/StgToCmm/Bind.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/StgToCmm/Layout.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToCmm/Prof.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -605,10 +605,12 @@ setSessionDynFlags dflags = do then do let prog = pgm_i dflags ++ flavour + profiled = ways dflags `hasWay` WayProf + dynamic = ways dflags `hasWay` WayDyn flavour - | WayProf `S.member` ways dflags = "-prof" - | WayDyn `S.member` ways dflags = "-dyn" - | otherwise = "" + | profiled = "-prof" -- FIXME: can't we have both? + | dynamic = "-dyn" + | otherwise = "" msg = text "Starting " <> text prog tr <- if verbosity dflags >= 3 then return (logInfo dflags $ withPprStyle defaultDumpStyle msg) @@ -617,8 +619,8 @@ setSessionDynFlags dflags = do conf = IServConfig { iservConfProgram = prog , iservConfOpts = getOpts dflags opt_i - , iservConfProfiled = gopt Opt_SccProfilingOn dflags - , iservConfDynamic = WayDyn `S.member` ways dflags + , iservConfProfiled = profiled + , iservConfDynamic = dynamic , iservConfHook = createIservProcessHook (hooks dflags) , iservConfTrace = tr } ===================================== compiler/GHC/Cmm/Info.hs ===================================== @@ -405,7 +405,7 @@ mkStdInfoTable dflags (type_descr, closure_descr) cl_type srt layout_lit where platform = targetPlatform dflags prof_info - | gopt Opt_SccProfilingOn dflags = [type_descr, closure_descr] + | sccProfilingEnabled dflags = [type_descr, closure_descr] | otherwise = [] tag = CmmInt (fromIntegral cl_type) (halfWordWidth platform) @@ -565,7 +565,7 @@ stdInfoTableSizeW :: DynFlags -> WordOff -- It must vary in sync with mkStdInfoTable stdInfoTableSizeW dflags = fixedInfoTableSizeW - + if gopt Opt_SccProfilingOn dflags + + if sccProfilingEnabled dflags then profInfoTableSizeW else 0 ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1168,7 +1168,7 @@ reserveStackFrame psize preg body = do withUpdFrameOff frame body profilingInfo dflags desc_str ty_str - = if not (gopt Opt_SccProfilingOn dflags) + = if not (sccProfilingEnabled dflags) then NoProfilingInfo else ProfilingInfo (BS8.pack desc_str) (BS8.pack ty_str) ===================================== compiler/GHC/Driver/CodeOutput.hs ===================================== @@ -275,11 +275,9 @@ outputForeignStubs_help fname doc_str header footer -- module; -- | Generate code to initialise cost centres -profilingInitCode :: DynFlags -> Module -> CollectedCCs -> SDoc -profilingInitCode dflags this_mod (local_CCs, singleton_CCSs) - = if not (gopt Opt_SccProfilingOn dflags) - then empty - else vcat +profilingInitCode :: Module -> CollectedCCs -> SDoc +profilingInitCode this_mod (local_CCs, singleton_CCSs) + = vcat $ map emit_cc_decl local_CCs ++ map emit_ccs_decl singleton_CCSs ++ [emit_cc_list local_CCs] ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -252,7 +252,6 @@ data GeneralFlag | Opt_PIE -- ^ @-fPIE@ | Opt_PICExecutable -- ^ @-pie@ | Opt_ExternalDynamicRefs - | Opt_SccProfilingOn | Opt_Ticky | Opt_Ticky_Allocd | Opt_Ticky_LNE ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -1412,7 +1412,9 @@ hscGenHardCode hsc_env cgguts location output_filename = do let cost_centre_info = (S.toList local_ccs ++ caf_ccs, caf_cc_stacks) - prof_init = profilingInitCode dflags this_mod cost_centre_info + prof_init + | sccProfilingEnabled dflags = profilingInitCode this_mod cost_centre_info + | otherwise = empty foreign_stubs = foreign_stubs0 `appendStubC` prof_init ------------------ Code generation ------------------ ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -42,6 +42,7 @@ module GHC.Driver.Session ( whenCannotGenerateDynamicToo, dynamicTooMkDynamicDynFlags, dynamicOutputFile, + sccProfilingEnabled, DynFlags(..), FlagSpec(..), HasDynFlags(..), ContainsDynFlags(..), @@ -5094,6 +5095,10 @@ isBmi2Enabled dflags = case platformArch (targetPlatform dflags) of ArchX86 -> bmiVersion dflags >= Just BMI2 _ -> False +-- | Indicate if cost-centre profiling is enabled +sccProfilingEnabled :: DynFlags -> Bool +sccProfilingEnabled dflags = ways dflags `hasWay` WayProf + -- ----------------------------------------------------------------------------- -- Linker/compiler information ===================================== compiler/GHC/Driver/Ways.hs ===================================== @@ -20,6 +20,7 @@ -- this compilation. module GHC.Driver.Ways ( Way(..) + , hasWay , allowed_combination , wayGeneralFlags , wayUnsetGeneralFlags @@ -60,12 +61,15 @@ data Way | WayDyn -- ^ Dynamic linking deriving (Eq, Ord, Show) +-- | Test if a ways is enabled +hasWay :: Set Way -> Way -> Bool +hasWay ws w = Set.member w ws -- | Check if a combination of ways is allowed allowed_combination :: Set Way -> Bool allowed_combination ways = not disallowed where - disallowed = or [ Set.member ways x && Set.member ways y + disallowed = or [ hasWay ways x && hasWay ways y | (x,y) <- couples ] -- List of disallowed couples of ways @@ -121,7 +125,7 @@ wayGeneralFlags _ WayDyn = [Opt_PIC, Opt_ExternalDynamicRefs] -- .so before loading the .so using the system linker. Since only -- PIC objects can be linked into a .so, we have to compile even -- modules of the main program with -fPIC when using -dynamic. -wayGeneralFlags _ WayProf = [Opt_SccProfilingOn] +wayGeneralFlags _ WayProf = [] wayGeneralFlags _ WayEventLog = [] -- | Turn these flags off when enabling this way ===================================== compiler/GHC/HsToCore/Coverage.hs ===================================== @@ -1040,7 +1040,7 @@ coveragePasses :: DynFlags -> [TickishType] coveragePasses dflags = ifa (breakpointsEnabled dflags) Breakpoints $ ifa (gopt Opt_Hpc dflags) HpcTicks $ - ifa (gopt Opt_SccProfilingOn dflags && + ifa (sccProfilingEnabled dflags && profAuto dflags /= NoProfAuto) ProfNotes $ ifa (debugLevel dflags > 0) SourceNotes [] where ifa f x xs | f = x:xs ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -813,7 +813,7 @@ dsExpr (HsRecFld {}) = panic "dsExpr:HsRecFld" ds_prag_expr :: HsPragE GhcTc -> LHsExpr GhcTc -> DsM CoreExpr ds_prag_expr (HsPragSCC _ _ cc) expr = do dflags <- getDynFlags - if gopt Opt_SccProfilingOn dflags + if sccProfilingEnabled dflags then do mod_name <- getModule count <- goptM Opt_ProfCountEntries ===================================== compiler/GHC/Iface/Recomp/Flags.hs ===================================== @@ -55,7 +55,7 @@ fingerprintDynFlags dflags at DynFlags{..} this_mod nameio = paths = [ hcSuf ] -- -fprof-auto etc. - prof = if gopt Opt_SccProfilingOn dflags then fromEnum profAuto else 0 + prof = if sccProfilingEnabled dflags then fromEnum profAuto else 0 -- Ticky ticky = ===================================== compiler/GHC/Runtime/Heap/Layout.hs ===================================== @@ -282,8 +282,8 @@ fixedHdrSizeW dflags = sTD_HDR_SIZE dflags + profHdrSize dflags -- (StgProfHeader in includes\/rts\/storage\/Closures.h) profHdrSize :: DynFlags -> WordOff profHdrSize dflags - | gopt Opt_SccProfilingOn dflags = pROF_HDR_SIZE dflags - | otherwise = 0 + | sccProfilingEnabled dflags = pROF_HDR_SIZE dflags + | otherwise = 0 -- | The garbage collector requires that every closure is at least as -- big as this. ===================================== compiler/GHC/Stg/Syntax.hs ===================================== @@ -805,7 +805,7 @@ pprStgRhs :: OutputablePass pass => GenStgRhs pass -> SDoc pprStgRhs (StgRhsClosure ext cc upd_flag args body) = sdocWithDynFlags $ \dflags -> - hang (hsep [if gopt Opt_SccProfilingOn dflags then ppr cc else empty, + hang (hsep [if sccProfilingEnabled dflags then ppr cc else empty, ppUnlessOption sdocSuppressStgExts (ppr ext), char '\\' <> ppr upd_flag, brackets (interppSP args)]) 4 (ppr body) ===================================== compiler/GHC/StgToCmm/Bind.hs ===================================== @@ -307,7 +307,7 @@ mkRhsClosure dflags bndr _cc , all (isGcPtrRep . idPrimRep . fromNonVoid) fvs , isUpdatable upd_flag , n_fvs <= mAX_SPEC_AP_SIZE dflags - , not (gopt Opt_SccProfilingOn dflags) + , not (sccProfilingEnabled dflags) -- not when profiling: we don't want to -- lose information about this particular -- thunk (e.g. its type) (#949) @@ -626,7 +626,7 @@ emitBlackHoleCode node = do -- Note the eager-blackholing check is here rather than in blackHoleOnEntry, -- because emitBlackHoleCode is called from GHC.Cmm.Parser. - let eager_blackholing = not (gopt Opt_SccProfilingOn dflags) + let eager_blackholing = not (sccProfilingEnabled dflags) && gopt Opt_EagerBlackHoling dflags -- Profiling needs slop filling (to support LDV -- profiling), so currently eager blackholing doesn't @@ -655,7 +655,7 @@ setupUpdate closure_info node body dflags <- getDynFlags let bh = blackHoleOnEntry closure_info && - not (gopt Opt_SccProfilingOn dflags) && + not (sccProfilingEnabled dflags) && gopt Opt_EagerBlackHoling dflags lbl | bh = mkBHUpdInfoLabel ===================================== compiler/GHC/StgToCmm/Closure.hs ===================================== @@ -381,7 +381,7 @@ nodeMustPointToIt dflags (LFThunk top no_fvs updatable NonStandardThunk _) = not no_fvs -- Self parameter || isNotTopLevel top -- Note [GC recovery] || updatable -- Need to push update frame - || gopt Opt_SccProfilingOn dflags + || sccProfilingEnabled dflags -- For the non-updatable (single-entry case): -- -- True if has fvs (in which case we need access to them, and we @@ -508,7 +508,7 @@ getCallMethod dflags _ id _ n_args v_args _cg_loc getCallMethod dflags name id (LFReEntrant _ arity _ _) n_args _v_args _cg_loc _self_loop_info | n_args == 0 -- No args at all - && not (gopt Opt_SccProfilingOn dflags) + && not (sccProfilingEnabled dflags) -- See Note [Evaluating functions with profiling] in rts/Apply.cmm = ASSERT( arity /= 0 ) ReturnIt | n_args < arity = SlowCall -- Not enough args @@ -859,7 +859,7 @@ enterIdLabel platform id c mkProfilingInfo :: DynFlags -> Id -> String -> ProfilingInfo mkProfilingInfo dflags id val_descr - | not (gopt Opt_SccProfilingOn dflags) = NoProfilingInfo + | not (sccProfilingEnabled dflags) = NoProfilingInfo | otherwise = ProfilingInfo ty_descr_w8 (BS8.pack val_descr) where ty_descr_w8 = BS8.pack (getTyDescription (idType id)) @@ -906,8 +906,8 @@ mkDataConInfoTable dflags data_con is_static ptr_wds nonptr_wds -- We keep the *zero-indexed* tag in the srt_len field -- of the info table of a data constructor. - prof | not (gopt Opt_SccProfilingOn dflags) = NoProfilingInfo - | otherwise = ProfilingInfo ty_descr val_descr + prof | not (sccProfilingEnabled dflags) = NoProfilingInfo + | otherwise = ProfilingInfo ty_descr val_descr ty_descr = BS8.pack $ occNameString $ getOccName $ dataConTyCon data_con val_descr = BS8.pack $ occNameString $ getOccName data_con ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -306,7 +306,7 @@ saveThreadState dflags = do spExpr, close_nursery, -- and save the current cost centre stack in the TSO when profiling: - if gopt Opt_SccProfilingOn dflags then + if sccProfilingEnabled dflags then mkStore (cmmOffset platform (CmmReg (CmmLocal tso)) (tso_CCCS dflags)) cccsExpr else mkNop ] @@ -421,7 +421,7 @@ loadThreadState dflags = do mkAssign hpAllocReg (zeroExpr platform), open_nursery, -- and load the current cost centre stack from the TSO when profiling: - if gopt Opt_SccProfilingOn dflags + if sccProfilingEnabled dflags then storeCurCCS (CmmLoad (cmmOffset platform (CmmReg (CmmLocal tso)) (tso_CCCS dflags)) (ccsType platform)) ===================================== compiler/GHC/StgToCmm/Layout.hs ===================================== @@ -367,7 +367,7 @@ just more arguments that we are passing on the stack (cml_args). slowArgs :: DynFlags -> [(ArgRep, Maybe CmmExpr)] -> [(ArgRep, Maybe CmmExpr)] slowArgs _ [] = [] slowArgs dflags args -- careful: reps contains voids (V), but args does not - | gopt Opt_SccProfilingOn dflags + | sccProfilingEnabled dflags = save_cccs ++ this_pat ++ slowArgs dflags rest_args | otherwise = this_pat ++ slowArgs dflags rest_args where ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -300,8 +300,8 @@ emitPrimOp dflags = \case GetCCSOfOp -> \[arg] -> opAllDone $ \[res] -> do let val - | gopt Opt_SccProfilingOn dflags = costCentreFrom dflags (cmmUntag dflags arg) - | otherwise = CmmLit (zeroCLit platform) + | sccProfilingEnabled dflags = costCentreFrom dflags (cmmUntag dflags arg) + | otherwise = CmmLit (zeroCLit platform) emitAssign (CmmLocal res) val GetCurrentCCSOp -> \[_] -> opAllDone $ \[res] -> do ===================================== compiler/GHC/StgToCmm/Prof.hs ===================================== @@ -76,15 +76,15 @@ costCentreFrom dflags cl = CmmLoad (cmmOffsetB platform cl (oFFSET_StgHeader_ccs -- | The profiling header words in a static closure staticProfHdr :: DynFlags -> CostCentreStack -> [CmmLit] staticProfHdr dflags ccs - | gopt Opt_SccProfilingOn dflags = [mkCCostCentreStack ccs, staticLdvInit platform] - | otherwise = [] + | sccProfilingEnabled dflags = [mkCCostCentreStack ccs, staticLdvInit platform] + | otherwise = [] where platform = targetPlatform dflags -- | Profiling header words in a dynamic closure dynProfHdr :: DynFlags -> CmmExpr -> [CmmExpr] dynProfHdr dflags ccs - | gopt Opt_SccProfilingOn dflags = [ccs, dynLdvInit dflags] - | otherwise = [] + | sccProfilingEnabled dflags = [ccs, dynLdvInit dflags] + | otherwise = [] -- | Initialise the profiling field of an update frame initUpdFrameProf :: CmmExpr -> FCode () @@ -130,7 +130,7 @@ saveCurrentCostCentre :: FCode (Maybe LocalReg) saveCurrentCostCentre = do dflags <- getDynFlags platform <- getPlatform - if not (gopt Opt_SccProfilingOn dflags) + if not (sccProfilingEnabled dflags) then return Nothing else do local_cc <- newTemp (ccType platform) emitAssign (CmmLocal local_cc) cccsExpr @@ -195,7 +195,7 @@ enterCostCentreFun ccs closure = ifProfiling :: FCode () -> FCode () ifProfiling code = do dflags <- getDynFlags - if gopt Opt_SccProfilingOn dflags + if sccProfilingEnabled dflags then code else return () @@ -207,7 +207,7 @@ initCostCentres :: CollectedCCs -> FCode () -- Emit the declarations initCostCentres (local_CCs, singleton_CCSs) = do dflags <- getDynFlags - when (gopt Opt_SccProfilingOn dflags) $ + when (sccProfilingEnabled dflags) $ do mapM_ emitCostCentreDecl local_CCs mapM_ emitCostCentreStackDecl singleton_CCSs @@ -277,7 +277,7 @@ emitSetCCC :: CostCentre -> Bool -> Bool -> FCode () emitSetCCC cc tick push = do dflags <- getDynFlags platform <- getPlatform - if not (gopt Opt_SccProfilingOn dflags) + if not (sccProfilingEnabled dflags) then return () else do tmp <- newTemp (ccsType platform) pushCostCentre tmp cccsExpr cc View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f08d6316d3d19b627550d99b4364e9bf0b45c329 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f08d6316d3d19b627550d99b4364e9bf0b45c329 You're receiving 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 Jul 3 00:39:27 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 02 Jul 2020 20:39:27 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: No need for CURSES_INCLUDE_DIRS Message-ID: <5efe7e3f8acb8_80b3f8494c8fea814669ec@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 06d2baee by Ben Gamari at 2020-07-02T20:39:20-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - 5b971f91 by Ben Gamari at 2020-07-02T20:39:20-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 126686e5 by Valery Tolstov at 2020-07-02T20:39:20-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - 9e8fa44a by Sylvain Henry at 2020-07-02T20:39:22-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 23 changed files: - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Ways.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Runtime/Heap/Layout.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/StgToCmm/Bind.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/StgToCmm/Layout.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToCmm/Prof.hs - docs/users_guide/using-warnings.rst - rts/ProfHeap.c Changes: ===================================== aclocal.m4 ===================================== @@ -1875,7 +1875,6 @@ AC_DEFUN([FP_CURSES], [directory containing curses libraries])], [CURSES_LIB_DIRS=$withval]) - AC_SUBST(CURSES_INCLUDE_DIRS) AC_SUBST(CURSES_LIB_DIRS) ])# FP_CURSES ===================================== compiler/GHC.hs ===================================== @@ -605,10 +605,12 @@ setSessionDynFlags dflags = do then do let prog = pgm_i dflags ++ flavour + profiled = ways dflags `hasWay` WayProf + dynamic = ways dflags `hasWay` WayDyn flavour - | WayProf `S.member` ways dflags = "-prof" - | WayDyn `S.member` ways dflags = "-dyn" - | otherwise = "" + | profiled = "-prof" -- FIXME: can't we have both? + | dynamic = "-dyn" + | otherwise = "" msg = text "Starting " <> text prog tr <- if verbosity dflags >= 3 then return (logInfo dflags $ withPprStyle defaultDumpStyle msg) @@ -617,8 +619,8 @@ setSessionDynFlags dflags = do conf = IServConfig { iservConfProgram = prog , iservConfOpts = getOpts dflags opt_i - , iservConfProfiled = gopt Opt_SccProfilingOn dflags - , iservConfDynamic = WayDyn `S.member` ways dflags + , iservConfProfiled = profiled + , iservConfDynamic = dynamic , iservConfHook = createIservProcessHook (hooks dflags) , iservConfTrace = tr } ===================================== compiler/GHC/Cmm/Info.hs ===================================== @@ -405,7 +405,7 @@ mkStdInfoTable dflags (type_descr, closure_descr) cl_type srt layout_lit where platform = targetPlatform dflags prof_info - | gopt Opt_SccProfilingOn dflags = [type_descr, closure_descr] + | sccProfilingEnabled dflags = [type_descr, closure_descr] | otherwise = [] tag = CmmInt (fromIntegral cl_type) (halfWordWidth platform) @@ -565,7 +565,7 @@ stdInfoTableSizeW :: DynFlags -> WordOff -- It must vary in sync with mkStdInfoTable stdInfoTableSizeW dflags = fixedInfoTableSizeW - + if gopt Opt_SccProfilingOn dflags + + if sccProfilingEnabled dflags then profInfoTableSizeW else 0 ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1168,7 +1168,7 @@ reserveStackFrame psize preg body = do withUpdFrameOff frame body profilingInfo dflags desc_str ty_str - = if not (gopt Opt_SccProfilingOn dflags) + = if not (sccProfilingEnabled dflags) then NoProfilingInfo else ProfilingInfo (BS8.pack desc_str) (BS8.pack ty_str) ===================================== compiler/GHC/CmmToLlvm/Regs.hs ===================================== @@ -47,6 +47,8 @@ lmGlobalReg platform suf reg VanillaReg 6 _ -> wordGlobal $ "R6" ++ suf VanillaReg 7 _ -> wordGlobal $ "R7" ++ suf VanillaReg 8 _ -> wordGlobal $ "R8" ++ suf + VanillaReg 9 _ -> wordGlobal $ "R9" ++ suf + VanillaReg 10 _ -> wordGlobal $ "R10" ++ suf SpLim -> wordGlobal $ "SpLim" ++ suf FloatReg 1 -> floatGlobal $"F1" ++ suf FloatReg 2 -> floatGlobal $"F2" ++ suf ===================================== compiler/GHC/Driver/CodeOutput.hs ===================================== @@ -275,11 +275,9 @@ outputForeignStubs_help fname doc_str header footer -- module; -- | Generate code to initialise cost centres -profilingInitCode :: DynFlags -> Module -> CollectedCCs -> SDoc -profilingInitCode dflags this_mod (local_CCs, singleton_CCSs) - = if not (gopt Opt_SccProfilingOn dflags) - then empty - else vcat +profilingInitCode :: Module -> CollectedCCs -> SDoc +profilingInitCode this_mod (local_CCs, singleton_CCSs) + = vcat $ map emit_cc_decl local_CCs ++ map emit_ccs_decl singleton_CCSs ++ [emit_cc_list local_CCs] ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -252,7 +252,6 @@ data GeneralFlag | Opt_PIE -- ^ @-fPIE@ | Opt_PICExecutable -- ^ @-pie@ | Opt_ExternalDynamicRefs - | Opt_SccProfilingOn | Opt_Ticky | Opt_Ticky_Allocd | Opt_Ticky_LNE ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -1412,7 +1412,9 @@ hscGenHardCode hsc_env cgguts location output_filename = do let cost_centre_info = (S.toList local_ccs ++ caf_ccs, caf_cc_stacks) - prof_init = profilingInitCode dflags this_mod cost_centre_info + prof_init + | sccProfilingEnabled dflags = profilingInitCode this_mod cost_centre_info + | otherwise = empty foreign_stubs = foreign_stubs0 `appendStubC` prof_init ------------------ Code generation ------------------ ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -42,6 +42,7 @@ module GHC.Driver.Session ( whenCannotGenerateDynamicToo, dynamicTooMkDynamicDynFlags, dynamicOutputFile, + sccProfilingEnabled, DynFlags(..), FlagSpec(..), HasDynFlags(..), ContainsDynFlags(..), @@ -5094,6 +5095,10 @@ isBmi2Enabled dflags = case platformArch (targetPlatform dflags) of ArchX86 -> bmiVersion dflags >= Just BMI2 _ -> False +-- | Indicate if cost-centre profiling is enabled +sccProfilingEnabled :: DynFlags -> Bool +sccProfilingEnabled dflags = ways dflags `hasWay` WayProf + -- ----------------------------------------------------------------------------- -- Linker/compiler information ===================================== compiler/GHC/Driver/Ways.hs ===================================== @@ -20,6 +20,7 @@ -- this compilation. module GHC.Driver.Ways ( Way(..) + , hasWay , allowed_combination , wayGeneralFlags , wayUnsetGeneralFlags @@ -60,12 +61,15 @@ data Way | WayDyn -- ^ Dynamic linking deriving (Eq, Ord, Show) +-- | Test if a ways is enabled +hasWay :: Set Way -> Way -> Bool +hasWay ws w = Set.member w ws -- | Check if a combination of ways is allowed allowed_combination :: Set Way -> Bool allowed_combination ways = not disallowed where - disallowed = or [ Set.member ways x && Set.member ways y + disallowed = or [ hasWay ways x && hasWay ways y | (x,y) <- couples ] -- List of disallowed couples of ways @@ -121,7 +125,7 @@ wayGeneralFlags _ WayDyn = [Opt_PIC, Opt_ExternalDynamicRefs] -- .so before loading the .so using the system linker. Since only -- PIC objects can be linked into a .so, we have to compile even -- modules of the main program with -fPIC when using -dynamic. -wayGeneralFlags _ WayProf = [Opt_SccProfilingOn] +wayGeneralFlags _ WayProf = [] wayGeneralFlags _ WayEventLog = [] -- | Turn these flags off when enabling this way ===================================== compiler/GHC/HsToCore/Coverage.hs ===================================== @@ -1040,7 +1040,7 @@ coveragePasses :: DynFlags -> [TickishType] coveragePasses dflags = ifa (breakpointsEnabled dflags) Breakpoints $ ifa (gopt Opt_Hpc dflags) HpcTicks $ - ifa (gopt Opt_SccProfilingOn dflags && + ifa (sccProfilingEnabled dflags && profAuto dflags /= NoProfAuto) ProfNotes $ ifa (debugLevel dflags > 0) SourceNotes [] where ifa f x xs | f = x:xs ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -813,7 +813,7 @@ dsExpr (HsRecFld {}) = panic "dsExpr:HsRecFld" ds_prag_expr :: HsPragE GhcTc -> LHsExpr GhcTc -> DsM CoreExpr ds_prag_expr (HsPragSCC _ _ cc) expr = do dflags <- getDynFlags - if gopt Opt_SccProfilingOn dflags + if sccProfilingEnabled dflags then do mod_name <- getModule count <- goptM Opt_ProfCountEntries ===================================== compiler/GHC/Iface/Recomp/Flags.hs ===================================== @@ -55,7 +55,7 @@ fingerprintDynFlags dflags at DynFlags{..} this_mod nameio = paths = [ hcSuf ] -- -fprof-auto etc. - prof = if gopt Opt_SccProfilingOn dflags then fromEnum profAuto else 0 + prof = if sccProfilingEnabled dflags then fromEnum profAuto else 0 -- Ticky ticky = ===================================== compiler/GHC/Runtime/Heap/Layout.hs ===================================== @@ -282,8 +282,8 @@ fixedHdrSizeW dflags = sTD_HDR_SIZE dflags + profHdrSize dflags -- (StgProfHeader in includes\/rts\/storage\/Closures.h) profHdrSize :: DynFlags -> WordOff profHdrSize dflags - | gopt Opt_SccProfilingOn dflags = pROF_HDR_SIZE dflags - | otherwise = 0 + | sccProfilingEnabled dflags = pROF_HDR_SIZE dflags + | otherwise = 0 -- | The garbage collector requires that every closure is at least as -- big as this. ===================================== compiler/GHC/Stg/Syntax.hs ===================================== @@ -805,7 +805,7 @@ pprStgRhs :: OutputablePass pass => GenStgRhs pass -> SDoc pprStgRhs (StgRhsClosure ext cc upd_flag args body) = sdocWithDynFlags $ \dflags -> - hang (hsep [if gopt Opt_SccProfilingOn dflags then ppr cc else empty, + hang (hsep [if sccProfilingEnabled dflags then ppr cc else empty, ppUnlessOption sdocSuppressStgExts (ppr ext), char '\\' <> ppr upd_flag, brackets (interppSP args)]) 4 (ppr body) ===================================== compiler/GHC/StgToCmm/Bind.hs ===================================== @@ -307,7 +307,7 @@ mkRhsClosure dflags bndr _cc , all (isGcPtrRep . idPrimRep . fromNonVoid) fvs , isUpdatable upd_flag , n_fvs <= mAX_SPEC_AP_SIZE dflags - , not (gopt Opt_SccProfilingOn dflags) + , not (sccProfilingEnabled dflags) -- not when profiling: we don't want to -- lose information about this particular -- thunk (e.g. its type) (#949) @@ -626,7 +626,7 @@ emitBlackHoleCode node = do -- Note the eager-blackholing check is here rather than in blackHoleOnEntry, -- because emitBlackHoleCode is called from GHC.Cmm.Parser. - let eager_blackholing = not (gopt Opt_SccProfilingOn dflags) + let eager_blackholing = not (sccProfilingEnabled dflags) && gopt Opt_EagerBlackHoling dflags -- Profiling needs slop filling (to support LDV -- profiling), so currently eager blackholing doesn't @@ -655,7 +655,7 @@ setupUpdate closure_info node body dflags <- getDynFlags let bh = blackHoleOnEntry closure_info && - not (gopt Opt_SccProfilingOn dflags) && + not (sccProfilingEnabled dflags) && gopt Opt_EagerBlackHoling dflags lbl | bh = mkBHUpdInfoLabel ===================================== compiler/GHC/StgToCmm/Closure.hs ===================================== @@ -381,7 +381,7 @@ nodeMustPointToIt dflags (LFThunk top no_fvs updatable NonStandardThunk _) = not no_fvs -- Self parameter || isNotTopLevel top -- Note [GC recovery] || updatable -- Need to push update frame - || gopt Opt_SccProfilingOn dflags + || sccProfilingEnabled dflags -- For the non-updatable (single-entry case): -- -- True if has fvs (in which case we need access to them, and we @@ -508,7 +508,7 @@ getCallMethod dflags _ id _ n_args v_args _cg_loc getCallMethod dflags name id (LFReEntrant _ arity _ _) n_args _v_args _cg_loc _self_loop_info | n_args == 0 -- No args at all - && not (gopt Opt_SccProfilingOn dflags) + && not (sccProfilingEnabled dflags) -- See Note [Evaluating functions with profiling] in rts/Apply.cmm = ASSERT( arity /= 0 ) ReturnIt | n_args < arity = SlowCall -- Not enough args @@ -859,7 +859,7 @@ enterIdLabel platform id c mkProfilingInfo :: DynFlags -> Id -> String -> ProfilingInfo mkProfilingInfo dflags id val_descr - | not (gopt Opt_SccProfilingOn dflags) = NoProfilingInfo + | not (sccProfilingEnabled dflags) = NoProfilingInfo | otherwise = ProfilingInfo ty_descr_w8 (BS8.pack val_descr) where ty_descr_w8 = BS8.pack (getTyDescription (idType id)) @@ -906,8 +906,8 @@ mkDataConInfoTable dflags data_con is_static ptr_wds nonptr_wds -- We keep the *zero-indexed* tag in the srt_len field -- of the info table of a data constructor. - prof | not (gopt Opt_SccProfilingOn dflags) = NoProfilingInfo - | otherwise = ProfilingInfo ty_descr val_descr + prof | not (sccProfilingEnabled dflags) = NoProfilingInfo + | otherwise = ProfilingInfo ty_descr val_descr ty_descr = BS8.pack $ occNameString $ getOccName $ dataConTyCon data_con val_descr = BS8.pack $ occNameString $ getOccName data_con ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -306,7 +306,7 @@ saveThreadState dflags = do spExpr, close_nursery, -- and save the current cost centre stack in the TSO when profiling: - if gopt Opt_SccProfilingOn dflags then + if sccProfilingEnabled dflags then mkStore (cmmOffset platform (CmmReg (CmmLocal tso)) (tso_CCCS dflags)) cccsExpr else mkNop ] @@ -421,7 +421,7 @@ loadThreadState dflags = do mkAssign hpAllocReg (zeroExpr platform), open_nursery, -- and load the current cost centre stack from the TSO when profiling: - if gopt Opt_SccProfilingOn dflags + if sccProfilingEnabled dflags then storeCurCCS (CmmLoad (cmmOffset platform (CmmReg (CmmLocal tso)) (tso_CCCS dflags)) (ccsType platform)) ===================================== compiler/GHC/StgToCmm/Layout.hs ===================================== @@ -367,7 +367,7 @@ just more arguments that we are passing on the stack (cml_args). slowArgs :: DynFlags -> [(ArgRep, Maybe CmmExpr)] -> [(ArgRep, Maybe CmmExpr)] slowArgs _ [] = [] slowArgs dflags args -- careful: reps contains voids (V), but args does not - | gopt Opt_SccProfilingOn dflags + | sccProfilingEnabled dflags = save_cccs ++ this_pat ++ slowArgs dflags rest_args | otherwise = this_pat ++ slowArgs dflags rest_args where ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -300,8 +300,8 @@ emitPrimOp dflags = \case GetCCSOfOp -> \[arg] -> opAllDone $ \[res] -> do let val - | gopt Opt_SccProfilingOn dflags = costCentreFrom dflags (cmmUntag dflags arg) - | otherwise = CmmLit (zeroCLit platform) + | sccProfilingEnabled dflags = costCentreFrom dflags (cmmUntag dflags arg) + | otherwise = CmmLit (zeroCLit platform) emitAssign (CmmLocal res) val GetCurrentCCSOp -> \[_] -> opAllDone $ \[res] -> do ===================================== compiler/GHC/StgToCmm/Prof.hs ===================================== @@ -76,15 +76,15 @@ costCentreFrom dflags cl = CmmLoad (cmmOffsetB platform cl (oFFSET_StgHeader_ccs -- | The profiling header words in a static closure staticProfHdr :: DynFlags -> CostCentreStack -> [CmmLit] staticProfHdr dflags ccs - | gopt Opt_SccProfilingOn dflags = [mkCCostCentreStack ccs, staticLdvInit platform] - | otherwise = [] + | sccProfilingEnabled dflags = [mkCCostCentreStack ccs, staticLdvInit platform] + | otherwise = [] where platform = targetPlatform dflags -- | Profiling header words in a dynamic closure dynProfHdr :: DynFlags -> CmmExpr -> [CmmExpr] dynProfHdr dflags ccs - | gopt Opt_SccProfilingOn dflags = [ccs, dynLdvInit dflags] - | otherwise = [] + | sccProfilingEnabled dflags = [ccs, dynLdvInit dflags] + | otherwise = [] -- | Initialise the profiling field of an update frame initUpdFrameProf :: CmmExpr -> FCode () @@ -130,7 +130,7 @@ saveCurrentCostCentre :: FCode (Maybe LocalReg) saveCurrentCostCentre = do dflags <- getDynFlags platform <- getPlatform - if not (gopt Opt_SccProfilingOn dflags) + if not (sccProfilingEnabled dflags) then return Nothing else do local_cc <- newTemp (ccType platform) emitAssign (CmmLocal local_cc) cccsExpr @@ -195,7 +195,7 @@ enterCostCentreFun ccs closure = ifProfiling :: FCode () -> FCode () ifProfiling code = do dflags <- getDynFlags - if gopt Opt_SccProfilingOn dflags + if sccProfilingEnabled dflags then code else return () @@ -207,7 +207,7 @@ initCostCentres :: CollectedCCs -> FCode () -- Emit the declarations initCostCentres (local_CCs, singleton_CCSs) = do dflags <- getDynFlags - when (gopt Opt_SccProfilingOn dflags) $ + when (sccProfilingEnabled dflags) $ do mapM_ emitCostCentreDecl local_CCs mapM_ emitCostCentreStackDecl singleton_CCSs @@ -277,7 +277,7 @@ emitSetCCC :: CostCentre -> Bool -> Bool -> FCode () emitSetCCC cc tick push = do dflags <- getDynFlags platform <- getPlatform - if not (gopt Opt_SccProfilingOn dflags) + if not (sccProfilingEnabled dflags) then return () else do tmp <- newTemp (ccsType platform) pushCostCentre tmp cccsExpr cc ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -94,6 +94,11 @@ The following flags are simple ways to select standard "packages" of warnings: * :ghc-flag:`-Wpartial-fields` * :ghc-flag:`-Wmissed-specialisations` * :ghc-flag:`-Wall-missed-specialisations` + * :ghc-flag:`-Wcpp-undef` + * :ghc-flag:`-Wduplicate-constraints` + * :ghc-flag:`-Wmissing-deriving-strategies` + * :ghc-flag:`-Wunused-packages` + * :ghc-flag:`-Wunused-type-patterns` .. ghc-flag:: -Weverything :shortdesc: enable all warnings supported by GHC @@ -119,7 +124,6 @@ The following flags are simple ways to select standard "packages" of warnings: .. hlist:: :columns: 3 - * :ghc-flag:`-Wmissing-monadfail-instances` * :ghc-flag:`-Wsemigroup` * :ghc-flag:`-Wnoncanonical-monoid-instances` * :ghc-flag:`-Wstar-is-type` ===================================== rts/ProfHeap.c ===================================== @@ -347,6 +347,16 @@ LDV_recordDead( const StgClosure *c, uint32_t size ) STATIC_INLINE void initEra(Census *census) { + // N.B. When not LDV profiling we reinitialise the same Census over + // and over again. Consequently, we need to ensure that we free the + // resources from the previous census. + if (census->hash) { + freeHashTable(census->hash, NULL); + } + if (census->arena) { + arenaFree(census->arena); + } + census->hash = allocHashTable(); census->ctrs = NULL; census->arena = newArena(); @@ -498,18 +508,24 @@ initHeapProfiling(void) #if defined(PROFILING) if (doingLDVProfiling()) { era = 1; + n_censuses = 32; } else #endif { era = 0; + n_censuses = 1; } // max_era = 2^LDV_SHIFT max_era = 1 << LDV_SHIFT; - n_censuses = 32; censuses = stgMallocBytes(sizeof(Census) * n_censuses, "initHeapProfiling"); + // Ensure that arena and hash are NULL since otherwise initEra will attempt to free them. + for (unsigned int i=0; i < n_censuses; i++) { + censuses[i].arena = NULL; + censuses[i].hash = NULL; + } initEra( &censuses[era] ); /* initProfilingLogFile(); */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ddfbf39253815245653d39c941792859c2948521...9e8fa44adaaad66eb95ffbb5aa74f0c768d7134b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ddfbf39253815245653d39c941792859c2948521...9e8fa44adaaad66eb95ffbb5aa74f0c768d7134b You're receiving 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 Jul 3 01:17:48 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 02 Jul 2020 21:17:48 -0400 Subject: [Git][ghc/ghc][wip/T18328] 20 commits: Reject nested foralls/contexts in instance types more consistently Message-ID: <5efe873c76f58_80b104f1d601473322@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18328 at Glasgow Haskell Compiler / GHC Commits: 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 03c82238 by Simon Peyton Jones at 2020-07-02T21:17:46-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - 065da62f by Simon Peyton Jones at 2020-07-02T21:17:46-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - d33f1e76 by Simon Peyton Jones at 2020-07-02T21:17:46-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric decrease T3064 T3294 T12707 T13056 - - - - - 3db62d0d by Simon Peyton Jones at 2020-07-02T21:17:46-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - 3fcefa7a by Simon Peyton Jones at 2020-07-02T21:17:46-04:00 Comments only - - - - - 30 changed files: - .gitlab/test-metrics.sh - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Ways.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Module.hs - compiler/GHC/Runtime/Heap/Layout.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c576e73381f677a6f3a0fd13aca6d61360ac880...3fcefa7a0a39228f86b3770d9d6c7bc005f273b8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c576e73381f677a6f3a0fd13aca6d61360ac880...3fcefa7a0a39228f86b3770d9d6c7bc005f273b8 You're receiving 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 Jul 3 06:49:34 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 03 Jul 2020 02:49:34 -0400 Subject: [Git][ghc/ghc][master] 2 commits: rts/ProfHeap: Only allocate the Censuses that we need Message-ID: <5efed4feecef5_80b3f848a29e4d01487096@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 1 changed file: - rts/ProfHeap.c Changes: ===================================== rts/ProfHeap.c ===================================== @@ -347,6 +347,16 @@ LDV_recordDead( const StgClosure *c, uint32_t size ) STATIC_INLINE void initEra(Census *census) { + // N.B. When not LDV profiling we reinitialise the same Census over + // and over again. Consequently, we need to ensure that we free the + // resources from the previous census. + if (census->hash) { + freeHashTable(census->hash, NULL); + } + if (census->arena) { + arenaFree(census->arena); + } + census->hash = allocHashTable(); census->ctrs = NULL; census->arena = newArena(); @@ -498,18 +508,24 @@ initHeapProfiling(void) #if defined(PROFILING) if (doingLDVProfiling()) { era = 1; + n_censuses = 32; } else #endif { era = 0; + n_censuses = 1; } // max_era = 2^LDV_SHIFT max_era = 1 << LDV_SHIFT; - n_censuses = 32; censuses = stgMallocBytes(sizeof(Census) * n_censuses, "initHeapProfiling"); + // Ensure that arena and hash are NULL since otherwise initEra will attempt to free them. + for (unsigned int i=0; i < n_censuses; i++) { + censuses[i].arena = NULL; + censuses[i].hash = NULL; + } initEra( &censuses[era] ); /* initProfilingLogFile(); */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f08d6316d3d19b627550d99b4364e9bf0b45c329...b835112cbeaa6e34a8bae7b7697bdf2826edaa9a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f08d6316d3d19b627550d99b4364e9bf0b45c329...b835112cbeaa6e34a8bae7b7697bdf2826edaa9a You're receiving 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 Jul 3 06:50:08 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 03 Jul 2020 02:50:08 -0400 Subject: [Git][ghc/ghc][master] Mention flags that are not enabled by -Wall (#18372) Message-ID: <5efed5209ff64_80b3f84900d2204148811a@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - 1 changed file: - docs/users_guide/using-warnings.rst Changes: ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -94,6 +94,11 @@ The following flags are simple ways to select standard "packages" of warnings: * :ghc-flag:`-Wpartial-fields` * :ghc-flag:`-Wmissed-specialisations` * :ghc-flag:`-Wall-missed-specialisations` + * :ghc-flag:`-Wcpp-undef` + * :ghc-flag:`-Wduplicate-constraints` + * :ghc-flag:`-Wmissing-deriving-strategies` + * :ghc-flag:`-Wunused-packages` + * :ghc-flag:`-Wunused-type-patterns` .. ghc-flag:: -Weverything :shortdesc: enable all warnings supported by GHC @@ -119,7 +124,6 @@ The following flags are simple ways to select standard "packages" of warnings: .. hlist:: :columns: 3 - * :ghc-flag:`-Wmissing-monadfail-instances` * :ghc-flag:`-Wsemigroup` * :ghc-flag:`-Wnoncanonical-monoid-instances` * :ghc-flag:`-Wstar-is-type` View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34be6523a220b2be972b391d8ad26b75f7c26eb1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34be6523a220b2be972b391d8ad26b75f7c26eb1 You're receiving 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 Jul 3 06:50:45 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 03 Jul 2020 02:50:45 -0400 Subject: [Git][ghc/ghc][master] LLVM: support R9 and R10 registers Message-ID: <5efed54563367_80b3f8469dac1cc149101b@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 1 changed file: - compiler/GHC/CmmToLlvm/Regs.hs Changes: ===================================== compiler/GHC/CmmToLlvm/Regs.hs ===================================== @@ -47,6 +47,8 @@ lmGlobalReg platform suf reg VanillaReg 6 _ -> wordGlobal $ "R6" ++ suf VanillaReg 7 _ -> wordGlobal $ "R7" ++ suf VanillaReg 8 _ -> wordGlobal $ "R8" ++ suf + VanillaReg 9 _ -> wordGlobal $ "R9" ++ suf + VanillaReg 10 _ -> wordGlobal $ "R10" ++ suf SpLim -> wordGlobal $ "SpLim" ++ suf FloatReg 1 -> floatGlobal $"F1" ++ suf FloatReg 2 -> floatGlobal $"F2" ++ suf View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/edc8d22b2eea5d43dd6c3d0e4b2f85fc02ffa5ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/edc8d22b2eea5d43dd6c3d0e4b2f85fc02ffa5ce You're receiving 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 Jul 3 07:33:00 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 03 Jul 2020 03:33:00 -0400 Subject: [Git][ghc/ghc][wip/T18300] 48 commits: Enable large address space optimization on windows. Message-ID: <5efedf2c392e0_80bf00fa8c14970fb@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18300 at Glasgow Haskell Compiler / GHC Commits: 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - d7c1ba52 by Simon Peyton Jones at 2020-07-03T08:32:49+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 30 changed files: - .gitlab/test-metrics.sh - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/SPARC/CodeGen/Base.hs - compiler/GHC/CmmToAsm/SPARC/Regs.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Class.hs - compiler/GHC/Core/Coercion.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/32a50de133cf859931189b8eecbe9ad9ff1271cd...d7c1ba52036c9796faac8db6da80133d31888622 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/32a50de133cf859931189b8eecbe9ad9ff1271cd...d7c1ba52036c9796faac8db6da80133d31888622 You're receiving 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 Jul 3 07:38:57 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 03 Jul 2020 03:38:57 -0400 Subject: [Git][ghc/ghc][wip/T18300] Improve handling of data type return kinds Message-ID: <5efee09180c7f_80bf00fa8c1497825@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18300 at Glasgow Haskell Compiler / GHC Commits: 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 28 changed files: - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Instantiate.hs - docs/core-spec/CoreLint.ott - docs/core-spec/CoreSyn.ott - docs/core-spec/core-spec.mng - docs/core-spec/core-spec.pdf - + testsuite/tests/polykinds/T18300.hs - + testsuite/tests/polykinds/T18300.stderr - testsuite/tests/polykinds/all.T - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T18357.hs - + testsuite/tests/typecheck/should_fail/T18357.stderr - + testsuite/tests/typecheck/should_fail/T18357a.hs - + testsuite/tests/typecheck/should_fail/T18357a.stderr - + testsuite/tests/typecheck/should_fail/T18357b.hs - + testsuite/tests/typecheck/should_fail/T18357b.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Core/Coercion/Axiom.hs ===================================== @@ -184,9 +184,10 @@ Note [Storing compatibility] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ During axiom application, we need to be aware of which branches are compatible with which others. The full explanation is in Note [Compatibility] in -FamInstEnv. (The code is placed there to avoid a dependency from CoAxiom on -the unification algorithm.) Although we could theoretically compute -compatibility on the fly, this is silly, so we store it in a CoAxiom. +GHc.Core.FamInstEnv. (The code is placed there to avoid a dependency from +GHC.Core.Coercion.Axiom on the unification algorithm.) Although we could +theoretically compute compatibility on the fly, this is silly, so we store it +in a CoAxiom. Specifically, each branch refers to all other branches with which it is incompatible. This list might well be empty, and it will always be for the @@ -233,8 +234,8 @@ data CoAxBranch { cab_loc :: SrcSpan -- Location of the defining equation -- See Note [CoAxiom locations] , cab_tvs :: [TyVar] -- Bound type variables; not necessarily fresh - , cab_eta_tvs :: [TyVar] -- Eta-reduced tyvars -- See Note [CoAxBranch type variables] + , cab_eta_tvs :: [TyVar] -- Eta-reduced tyvars -- cab_tvs and cab_lhs may be eta-reduced; see -- Note [Eta reduction for data families] , cab_cvs :: [CoVar] -- Bound coercion variables ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -425,7 +425,7 @@ data DataCon -- NB: for a data instance, the original user result type may -- differ from the DataCon's representation TyCon. Example -- data instance T [a] where MkT :: a -> T [a] - -- The OrigResTy is T [a], but the dcRepTyCon might be :T123 + -- The dcOrigResTy is T [a], but the dcRepTyCon might be R:TList -- Now the strictness annotations and field labels of the constructor dcSrcBangs :: [HsSrcBang], @@ -1576,4 +1576,3 @@ splitDataProductType_maybe ty = Just (tycon, ty_args, con, dataConInstArgTys con ty_args) | otherwise = Nothing - ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -640,16 +640,13 @@ that Note. mkCoAxBranch :: [TyVar] -- original, possibly stale, tyvars -> [TyVar] -- Extra eta tyvars -> [CoVar] -- possibly stale covars - -> TyCon -- family/newtype TyCon (for error-checking only) -> [Type] -- LHS patterns -> Type -- RHS -> [Role] -> SrcSpan -> CoAxBranch -mkCoAxBranch tvs eta_tvs cvs ax_tc lhs rhs roles loc - = -- See Note [CoAxioms are homogeneous] in "GHC.Core.Coercion.Axiom" - ASSERT( typeKind (mkTyConApp ax_tc lhs) `eqType` typeKind rhs ) - CoAxBranch { cab_tvs = tvs' +mkCoAxBranch tvs eta_tvs cvs lhs rhs roles loc + = CoAxBranch { cab_tvs = tvs' , cab_eta_tvs = eta_tvs' , cab_cvs = cvs' , cab_lhs = tidyTypes env lhs @@ -703,7 +700,7 @@ mkSingleCoAxiom role ax_name tvs eta_tvs cvs fam_tc lhs_tys rhs_ty , co_ax_implicit = False , co_ax_branches = unbranched (branch { cab_incomps = [] }) } where - branch = mkCoAxBranch tvs eta_tvs cvs fam_tc lhs_tys rhs_ty + branch = mkCoAxBranch tvs eta_tvs cvs lhs_tys rhs_ty (map (const Nominal) tvs) (getSrcSpan ax_name) @@ -721,7 +718,7 @@ mkNewTypeCoAxiom name tycon tvs roles rhs_ty , co_ax_tc = tycon , co_ax_branches = unbranched (branch { cab_incomps = [] }) } where - branch = mkCoAxBranch tvs [] [] tycon (mkTyVarTys tvs) rhs_ty + branch = mkCoAxBranch tvs [] [] (mkTyVarTys tvs) rhs_ty roles (getSrcSpan name) {- ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -8,13 +8,12 @@ See Note [Core Lint guarantee]. -} {-# LANGUAGE CPP #-} -{-# LANGUAGE ViewPatterns #-} -{-# LANGUAGE ScopedTypeVariables, DeriveFunctor #-} +{-# LANGUAGE ViewPatterns, ScopedTypeVariables, DeriveFunctor, MultiWayIf #-} module GHC.Core.Lint ( lintCoreBindings, lintUnfolding, lintPassResult, lintInteractiveExpr, lintExpr, - lintAnnots, lintTypes, + lintAnnots, lintAxioms, -- ** Debug output endPass, endPassIO, @@ -36,7 +35,7 @@ import GHC.Types.Literal import GHC.Core.DataCon import GHC.Builtin.Types.Prim import GHC.Builtin.Types ( multiplicityTy ) -import GHC.Tc.Utils.TcType ( isFloatingTy ) +import GHC.Tc.Utils.TcType ( isFloatingTy, isTyFamFree ) import GHC.Types.Var as Var import GHC.Types.Var.Env import GHC.Types.Var.Set @@ -56,9 +55,10 @@ import GHC.Types.RepType import GHC.Core.TyCo.Rep -- checks validity of types/coercions import GHC.Core.TyCo.Subst import GHC.Core.TyCo.FVs -import GHC.Core.TyCo.Ppr ( pprTyVar ) +import GHC.Core.TyCo.Ppr ( pprTyVar, pprTyVars ) import GHC.Core.TyCon as TyCon import GHC.Core.Coercion.Axiom +import GHC.Core.Unify import GHC.Types.Basic import GHC.Utils.Error as Err import GHC.Data.List.SetOps @@ -76,7 +76,7 @@ import GHC.Driver.Session import Control.Monad import GHC.Utils.Monad import Data.Foldable ( toList ) -import Data.List.NonEmpty ( NonEmpty ) +import Data.List.NonEmpty ( NonEmpty(..), groupWith ) import Data.List ( partition ) import Data.Maybe import GHC.Data.Pair @@ -1587,18 +1587,6 @@ lintIdBndr top_lvl bind_site id thing_inside %************************************************************************ -} -lintTypes :: DynFlags - -> [TyCoVar] -- Treat these as in scope - -> [Type] - -> Maybe MsgDoc -- Nothing => OK -lintTypes dflags vars tys - | isEmptyBag errs = Nothing - | otherwise = Just (pprMessageBag errs) - where - (_warns, errs) = initL dflags (defaultLintFlags dflags) vars linter - linter = lintBinders LambdaBind vars $ \_ -> - mapM_ lintType tys - lintValueType :: Type -> LintM LintedType -- Types only, not kinds -- Check the type, and apply the substitution to it @@ -1617,7 +1605,7 @@ checkTyCon tc = checkL (not (isTcTyCon tc)) (text "Found TcTyCon:" <+> ppr tc) ------------------- -lintType :: LintedType -> LintM LintedType +lintType :: Type -> LintM LintedType -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] @@ -2342,6 +2330,175 @@ lintCoercion (HoleCo h) = do { addErrL $ text "Unfilled coercion hole:" <+> ppr h ; lintCoercion (CoVarCo (coHoleCoVar h)) } +{- +************************************************************************ +* * + Axioms +* * +************************************************************************ +-} + +lintAxioms :: DynFlags + -> [CoAxiom Branched] + -> WarnsAndErrs +lintAxioms dflags axioms + = initL dflags (defaultLintFlags dflags) [] $ + do { mapM_ lint_axiom axioms + ; let axiom_groups = groupWith coAxiomTyCon axioms + ; mapM_ lint_axiom_group axiom_groups } + +lint_axiom :: CoAxiom Branched -> LintM () +lint_axiom ax@(CoAxiom { co_ax_tc = tc, co_ax_branches = branches + , co_ax_role = ax_role }) + = addLoc (InAxiom ax) $ + do { mapM_ (lint_branch tc) branch_list + ; extra_checks } + where + branch_list = fromBranches branches + + extra_checks + | isNewTyCon tc + = do { CoAxBranch { cab_tvs = tvs + , cab_eta_tvs = eta_tvs + , cab_cvs = cvs + , cab_roles = roles + , cab_lhs = lhs_tys } + <- case branch_list of + [branch] -> return branch + _ -> failWithL (text "multi-branch axiom with newtype") + ; let ax_lhs = mkInfForAllTys tvs $ + mkTyConApp tc lhs_tys + nt_tvs = takeList tvs (tyConTyVars tc) + -- axiom may be eta-reduced: Note [Newtype eta] in GHC.Core.TyCon + nt_lhs = mkInfForAllTys nt_tvs $ + mkTyConApp tc (mkTyVarTys nt_tvs) + -- See Note [Newtype eta] in GHC.Core.TyCon + ; lintL (ax_lhs `eqType` nt_lhs) + (text "Newtype axiom LHS does not match newtype definition") + ; lintL (null cvs) + (text "Newtype axiom binds coercion variables") + ; lintL (null eta_tvs) -- See Note [Eta reduction for data families] + -- which is not about newtype axioms + (text "Newtype axiom has eta-tvs") + ; lintL (ax_role == Representational) + (text "Newtype axiom role not representational") + ; lintL (roles `equalLength` tvs) + (text "Newtype axiom roles list is the wrong length." $$ + text "roles:" <+> sep (map ppr roles)) + ; lintL (roles == takeList roles (tyConRoles tc)) + (vcat [ text "Newtype axiom roles do not match newtype tycon's." + , text "axiom roles:" <+> sep (map ppr roles) + , text "tycon roles:" <+> sep (map ppr (tyConRoles tc)) ]) + } + + | isFamilyTyCon tc + = do { if | isTypeFamilyTyCon tc + -> lintL (ax_role == Nominal) + (text "type family axiom is not nominal") + + | isDataFamilyTyCon tc + -> lintL (ax_role == Representational) + (text "data family axiom is not representational") + + | otherwise + -> addErrL (text "A family TyCon is neither a type family nor a data family:" <+> ppr tc) + + ; mapM_ (lint_family_branch tc) branch_list } + + | otherwise + = addErrL (text "Axiom tycon is neither a newtype nor a family.") + +lint_branch :: TyCon -> CoAxBranch -> LintM () +lint_branch ax_tc (CoAxBranch { cab_tvs = tvs, cab_cvs = cvs + , cab_lhs = lhs_args, cab_rhs = rhs }) + = lintBinders LambdaBind (tvs ++ cvs) $ \_ -> + do { let lhs = mkTyConApp ax_tc lhs_args + ; lhs' <- lintType lhs + ; rhs' <- lintType rhs + ; let lhs_kind = typeKind lhs' + rhs_kind = typeKind rhs' + ; lintL (lhs_kind `eqType` rhs_kind) $ + hang (text "Inhomogeneous axiom") + 2 (text "lhs:" <+> ppr lhs <+> dcolon <+> ppr lhs_kind $$ + text "rhs:" <+> ppr rhs <+> dcolon <+> ppr rhs_kind) } + +-- these checks do not apply to newtype axioms +lint_family_branch :: TyCon -> CoAxBranch -> LintM () +lint_family_branch fam_tc br@(CoAxBranch { cab_tvs = tvs + , cab_eta_tvs = eta_tvs + , cab_cvs = cvs + , cab_roles = roles + , cab_lhs = lhs + , cab_incomps = incomps }) + = do { lintL (isDataFamilyTyCon fam_tc || null eta_tvs) + (text "Type family axiom has eta-tvs") + ; lintL (all (`elemVarSet` tyCoVarsOfTypes lhs) tvs) + (text "Quantified variable in family axiom unused in LHS") + ; lintL (all isTyFamFree lhs) + (text "Type family application on LHS of family axiom") + ; lintL (all (== Nominal) roles) + (text "Non-nominal role in family axiom" $$ + text "roles:" <+> sep (map ppr roles)) + ; lintL (null cvs) + (text "Coercion variables bound in family axiom") + ; forM_ incomps $ \ br' -> + lintL (not (compatible_branches br br')) $ + text "Incorrect incompatible branch:" <+> ppr br' } + +lint_axiom_group :: NonEmpty (CoAxiom Branched) -> LintM () +lint_axiom_group (_ :| []) = return () +lint_axiom_group (ax :| axs) + = do { lintL (isOpenFamilyTyCon tc) + (text "Non-open-family with multiple axioms") + ; let all_pairs = [ (ax1, ax2) | ax1 <- all_axs + , ax2 <- all_axs ] + ; mapM_ (lint_axiom_pair tc) all_pairs } + where + all_axs = ax : axs + tc = coAxiomTyCon ax + +lint_axiom_pair :: TyCon -> (CoAxiom Branched, CoAxiom Branched) -> LintM () +lint_axiom_pair tc (ax1, ax2) + | Just br1@(CoAxBranch { cab_tvs = tvs1 + , cab_lhs = lhs1 + , cab_rhs = rhs1 }) <- coAxiomSingleBranch_maybe ax1 + , Just br2@(CoAxBranch { cab_tvs = tvs2 + , cab_lhs = lhs2 + , cab_rhs = rhs2 }) <- coAxiomSingleBranch_maybe ax2 + = lintL (compatible_branches br1 br2) $ + vcat [ hsep [ text "Axioms", ppr ax1, text "and", ppr ax2 + , text "are incompatible" ] + , text "tvs1 =" <+> pprTyVars tvs1 + , text "lhs1 =" <+> ppr (mkTyConApp tc lhs1) + , text "rhs1 =" <+> ppr rhs1 + , text "tvs2 =" <+> pprTyVars tvs2 + , text "lhs2 =" <+> ppr (mkTyConApp tc lhs2) + , text "rhs2 =" <+> ppr rhs2 ] + + | otherwise + = addErrL (text "Open type family axiom has more than one branch: either" <+> + ppr ax1 <+> text "or" <+> ppr ax2) + +compatible_branches :: CoAxBranch -> CoAxBranch -> Bool +-- True <=> branches are compatible. See Note [Compatibility] in GHC.Core.FamInstEnv. +compatible_branches (CoAxBranch { cab_tvs = tvs1 + , cab_lhs = lhs1 + , cab_rhs = rhs1 }) + (CoAxBranch { cab_tvs = tvs2 + , cab_lhs = lhs2 + , cab_rhs = rhs2 }) + = -- we need to freshen ax2 w.r.t. ax1 + -- do this by pretending tvs1 are in scope when processing tvs2 + let in_scope = mkInScopeSet (mkVarSet tvs1) + subst0 = mkEmptyTCvSubst in_scope + (subst, _) = substTyVarBndrs subst0 tvs2 + lhs2' = substTys subst lhs2 + rhs2' = substTy subst rhs2 + in + case tcUnifyTys (const BindMe) lhs1 lhs2' of + Just unifying_subst -> substTy unifying_subst rhs1 `eqType` + substTy unifying_subst rhs2' + Nothing -> True {- ************************************************************************ @@ -2539,6 +2696,7 @@ data LintLocInfo | TopLevelBindings | InType Type -- Inside a type | InCo Coercion -- Inside a coercion + | InAxiom (CoAxiom Branched) -- Inside a CoAxiom initL :: DynFlags -> LintFlags -> [Var] -> LintM a -> WarnsAndErrs -- Warnings and errors @@ -2822,6 +2980,34 @@ dumpLoc (InType ty) = (noSrcLoc, text "In the type" <+> quotes (ppr ty)) dumpLoc (InCo co) = (noSrcLoc, text "In the coercion" <+> quotes (ppr co)) +dumpLoc (InAxiom ax) + = (getSrcLoc ax_name, text "In the coercion axiom" <+> ppr ax_name <+> dcolon <+> pp_ax) + where + CoAxiom { co_ax_name = ax_name + , co_ax_tc = tc + , co_ax_role = ax_role + , co_ax_branches = branches } = ax + branch_list = fromBranches branches + + pp_ax + | [branch] <- branch_list + = pp_branch branch + + | otherwise + = braces $ vcat (map pp_branch branch_list) + + pp_branch (CoAxBranch { cab_tvs = tvs + , cab_cvs = cvs + , cab_lhs = lhs_tys + , cab_rhs = rhs_ty }) + = sep [ brackets (pprWithCommas pprTyVar (tvs ++ cvs)) <> dot + , ppr (mkTyConApp tc lhs_tys) + , text "~_" <> pp_role ax_role + , ppr rhs_ty ] + + pp_role Nominal = text "N" + pp_role Representational = text "R" + pp_role Phantom = text "P" pp_binders :: [Var] -> SDoc pp_binders bs = sep (punctuate comma (map pp_binder bs)) ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -293,7 +293,14 @@ See also Note [Wrappers for data instance tycons] in GHC.Types.Id.Make Indeed the latter type is unknown to the programmer. - There *is* an instance for (T Int) in the type-family instance - environment, but it is only used for overlap checking + environment, but it is looked up (via tcLookupDataFamilyInst) + in can_eq_nc (via tcTopNormaliseNewTypeTF_maybe) when trying to + solve representational equalities like + T Int ~R# Bool + Here we look up (T Int), convert it to R:TInt, and then unwrap the + newtype R:TInt. + + It is also looked up in reduceTyFamApp_maybe. - It's fine to have T in the LHS of a type function: type instance F (T a) = [a] @@ -1251,34 +1258,21 @@ example, newtype T a = MkT (a -> a) -the NewTyCon for T will contain nt_co = CoT where CoT t : T t ~ t -> t. - -In the case that the right hand side is a type application -ending with the same type variables as the left hand side, we -"eta-contract" the coercion. So if we had - - newtype S a = MkT [a] - -then we would generate the arity 0 axiom CoS : S ~ []. The -primary reason we do this is to make newtype deriving cleaner. +the NewTyCon for T will contain nt_co = CoT where CoT :: forall a. T a ~ a -> a. -In the paper we'd write - axiom CoT : (forall t. T t) ~ (forall t. [t]) -and then when we used CoT at a particular type, s, we'd say - CoT @ s -which encodes as (TyConApp instCoercionTyCon [TyConApp CoT [], s]) +We might also eta-contract the axiom: see Note [Newtype eta]. Note [Newtype eta] ~~~~~~~~~~~~~~~~~~ Consider newtype Parser a = MkParser (IO a) deriving Monad -Are these two types equal (to Core)? +Are these two types equal (that is, does a coercion exist between them)? Monad Parser Monad IO which we need to make the derived instance for Monad Parser. Well, yes. But to see that easily we eta-reduce the RHS type of -Parser, in this case to ([], Froogle), so that even unsaturated applications +Parser, in this case to IO, so that even unsaturated applications of Parser will work right. This eta reduction is done when the type constructor is built, and cached in NewTyCon. ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -70,7 +70,6 @@ module GHC.Core.Type ( getRuntimeRep_maybe, kindRep_maybe, kindRep, mkCastTy, mkCoercionTy, splitCastTy_maybe, - discardCast, userTypeError_maybe, pprUserTypeErrorTy, @@ -1402,20 +1401,6 @@ tyConBindersTyCoBinders = map to_tyb to_tyb (Bndr tv (NamedTCB vis)) = Named (Bndr tv vis) to_tyb (Bndr tv (AnonTCB af)) = Anon af (tymult (varType tv)) --- | Drop the cast on a type, if any. If there is no --- cast, just return the original type. This is rarely what --- you want. The CastTy data constructor (in "GHC.Core.TyCo.Rep") has the --- invariant that another CastTy is not inside. See the --- data constructor for a full description of this invariant. --- Since CastTy cannot be nested, the result of discardCast --- cannot be a CastTy. -discardCast :: Type -> Type -discardCast (CastTy ty _) = ASSERT(not (isCastTy ty)) ty - where - isCastTy CastTy{} = True - isCastTy _ = False -discardCast ty = ty - {- -------------------------------------------------------------------- ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -46,7 +46,8 @@ module GHC.Tc.Gen.HsType ( tcNamedWildCardBinders, tcHsLiftedType, tcHsOpenType, tcHsLiftedTypeNC, tcHsOpenTypeNC, - tcInferLHsType, tcInferLHsTypeUnsaturated, tcCheckLHsType, + tcInferLHsTypeKind, tcInferLHsType, tcInferLHsTypeUnsaturated, + tcCheckLHsType, tcHsMbContext, tcHsContext, tcLHsPredType, failIfEmitsConstraints, solveEqualities, -- useful re-export @@ -77,6 +78,7 @@ import GHC.Tc.Types.Origin import GHC.Core.Predicate import GHC.Tc.Types.Constraint import GHC.Tc.Utils.Env +import GHC.Tc.Utils.Instantiate( tcInstInvisibleTyBinders ) import GHC.Tc.Utils.TcMType import GHC.Tc.Validity import GHC.Tc.Utils.Unify @@ -87,7 +89,7 @@ import GHC.Core.TyCo.Rep import GHC.Core.TyCo.Ppr import GHC.Tc.Errors ( reportAllUnsolved ) import GHC.Tc.Utils.TcType -import GHC.Tc.Utils.Instantiate ( tcInstInvisibleTyBinders, tcInstInvisibleTyBinder ) +import GHC.Tc.Utils.Instantiate ( tcInstInvisibleTyBindersN, tcInstInvisibleTyBinder ) import GHC.Core.Type import GHC.Builtin.Types.Prim import GHC.Types.Name.Env @@ -617,12 +619,11 @@ tcHsOpenType, tcHsLiftedType, tcHsOpenTypeNC, tcHsLiftedTypeNC :: LHsType GhcRn -> TcM TcType -- Used for type signatures -- Do not do validity checking -tcHsOpenType ty = addTypeCtxt ty $ tcHsOpenTypeNC ty -tcHsLiftedType ty = addTypeCtxt ty $ tcHsLiftedTypeNC ty +tcHsOpenType hs_ty = addTypeCtxt hs_ty $ tcHsOpenTypeNC hs_ty +tcHsLiftedType hs_ty = addTypeCtxt hs_ty $ tcHsLiftedTypeNC hs_ty -tcHsOpenTypeNC ty = do { ek <- newOpenTypeKind - ; tcLHsType ty ek } -tcHsLiftedTypeNC ty = tcLHsType ty liftedTypeKind +tcHsOpenTypeNC hs_ty = do { ek <- newOpenTypeKind; tcLHsType hs_ty ek } +tcHsLiftedTypeNC hs_ty = tcLHsType hs_ty liftedTypeKind -- Like tcHsType, but takes an expected kind tcCheckLHsType :: LHsType GhcRn -> ContextKind -> TcM TcType @@ -632,15 +633,24 @@ tcCheckLHsType hs_ty exp_kind ; tcLHsType hs_ty ek } tcInferLHsType :: LHsType GhcRn -> TcM TcType --- Called from outside: set the context tcInferLHsType hs_ty - = addTypeCtxt hs_ty $ - do { (ty, _kind) <- tc_infer_lhs_type (mkMode TypeLevel) hs_ty + = do { (ty,_kind) <- tcInferLHsTypeKind hs_ty ; return ty } +tcInferLHsTypeKind :: LHsType GhcRn -> TcM (TcType, TcKind) +-- Called from outside: set the context +-- Eagerly instantiate any trailing invisible binders +tcInferLHsTypeKind lhs_ty@(L loc hs_ty) + = addTypeCtxt lhs_ty $ + setSrcSpan loc $ -- Cover the tcInstInvisibleTyBinders + do { (res_ty, res_kind) <- tc_infer_hs_type (mkMode TypeLevel) hs_ty + ; tcInstInvisibleTyBinders res_ty res_kind } + -- See Note [Do not always instantiate eagerly in types] + -- Used to check the argument of GHCi :kind -- Allow and report wildcards, e.g. :kind T _ -- Do not saturate family applications: see Note [Dealing with :kind] +-- Does not instantiate eagerly; See Note [Do not always instantiate eagerly in types] tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) tcInferLHsTypeUnsaturated hs_ty = addTypeCtxt hs_ty $ @@ -674,6 +684,19 @@ to switch off saturation. So tcInferLHsTypeUnsaturated does a little special case for top level applications. Actually the common case is a bare variable, as above. +Note [Do not always instantiate eagerly in types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Terms are eagerly instantiated. This means that if you say + + x = id + +then `id` gets instantiated to have type alpha -> alpha. The variable +alpha is then unconstrained and regeneralized. But we cannot do this +in types, as we have no type-level lambda. So, when we are sure +that we will not want to regeneralize later -- because we are done +checking a type, for example -- we can instantiate. But we do not +instantiate at variables, nor do we in tcInferLHsTypeUnsaturated, +which is used by :kind in GHCi. ************************************************************************ * * @@ -1648,14 +1671,14 @@ saturateFamApp :: TcType -> TcKind -> TcM (TcType, TcKind) -- tcTypeKind ty = kind -- -- If 'ty' is an unsaturated family application with trailing --- invisible arguments, instanttiate them. +-- invisible arguments, instantiate them. -- See Note [saturateFamApp] saturateFamApp ty kind | Just (tc, args) <- tcSplitTyConApp_maybe ty , mustBeSaturated tc , let n_to_inst = tyConArity tc - length args - = do { (extra_args, ki') <- tcInstInvisibleTyBinders n_to_inst kind + = do { (extra_args, ki') <- tcInstInvisibleTyBindersN n_to_inst kind ; return (ty `mkTcAppTys` extra_args, ki') } | otherwise = return (ty, kind) @@ -1712,7 +1735,7 @@ checkExpectedKind :: HasDebugCallStack checkExpectedKind hs_ty ty act_kind exp_kind = do { traceTc "checkExpectedKind" (ppr ty $$ ppr act_kind) - ; (new_args, act_kind') <- tcInstInvisibleTyBinders n_to_inst act_kind + ; (new_args, act_kind') <- tcInstInvisibleTyBindersN n_to_inst act_kind ; let origin = TypeEqOrigin { uo_actual = act_kind' , uo_expected = exp_kind @@ -1763,6 +1786,7 @@ tc_lhs_pred mode pred = tc_lhs_type mode pred constraintKind tcTyVar :: TcTyMode -> Name -> TcM (TcType, TcKind) -- See Note [Type checking recursive type and class declarations] -- in GHC.Tc.TyCl +-- This does not instantiate. See Note [Do not always instantiate eagerly in types] tcTyVar mode name -- Could be a tyvar, a tycon, or a datacon = do { traceTc "lk1" (ppr name) ; thing <- tcLookup name @@ -3293,12 +3317,18 @@ data DataSort -- 2. @k@ (where @k@ is a bare kind variable; see #12369) -- -- See also Note [Datatype return kinds] in "GHC.Tc.TyCl" -checkDataKindSig :: DataSort -> Kind -> TcM () -checkDataKindSig data_sort kind = do - dflags <- getDynFlags - traceTc "checkDataKindSig" (ppr kind) - checkTc (is_TYPE_or_Type dflags || is_kind_var) (err_msg dflags) +checkDataKindSig :: DataSort -> Kind -- any arguments in the kind are stripped off + -> TcM () +checkDataKindSig data_sort kind + = do { dflags <- getDynFlags + ; traceTc "checkDataKindSig" (ppr kind) + ; checkTc (is_TYPE_or_Type dflags || is_kind_var) + (err_msg dflags) } where + res_kind = snd (tcSplitPiTys kind) + -- Look for the result kind after + -- peeling off any foralls and arrows + pp_dec :: SDoc pp_dec = text $ case data_sort of @@ -3335,16 +3365,19 @@ checkDataKindSig data_sort kind = do -- have return kind `TYPE r` unconditionally (#16827). is_TYPE :: Bool - is_TYPE = tcIsRuntimeTypeKind kind + is_TYPE = tcIsRuntimeTypeKind res_kind + + is_Type :: Bool + is_Type = tcIsLiftedTypeKind res_kind is_TYPE_or_Type :: DynFlags -> Bool is_TYPE_or_Type dflags | tYPE_ok dflags = is_TYPE - | otherwise = tcIsLiftedTypeKind kind + | otherwise = is_Type -- In the particular case of a data family, permit a return kind of the -- form `:: k` (where `k` is a bare kind variable). is_kind_var :: Bool - is_kind_var | is_data_family = isJust (tcGetCastedTyVar_maybe kind) + is_kind_var | is_data_family = isJust (tcGetCastedTyVar_maybe res_kind) | otherwise = False err_msg :: DynFlags -> SDoc @@ -3353,7 +3386,7 @@ checkDataKindSig data_sort kind = do text "has non-" <> (if tYPE_ok dflags then text "TYPE" else ppr liftedTypeKind) , (if is_data_family then text "and non-variable" else empty) <+> - text "return kind" <+> quotes (ppr kind) ]) + text "return kind" <+> quotes (ppr res_kind) ]) , if not (tYPE_ok dflags) && is_TYPE && is_newtype && not (xopt LangExt.UnliftedNewtypes dflags) then text "Perhaps you intended to use UnliftedNewtypes" ===================================== compiler/GHC/Tc/Instance/Family.hs ===================================== @@ -18,7 +18,6 @@ import GHC.Driver.Types import GHC.Core.FamInstEnv import GHC.Core.InstEnv( roughMatchTcs ) import GHC.Core.Coercion -import GHC.Core.Lint import GHC.Tc.Types.Evidence import GHC.Iface.Load import GHC.Tc.Utils.Monad @@ -162,34 +161,13 @@ addressed yet. newFamInst :: FamFlavor -> CoAxiom Unbranched -> TcM FamInst -- Freshen the type variables of the FamInst branches newFamInst flavor axiom@(CoAxiom { co_ax_tc = fam_tc }) - = ASSERT2( tyCoVarsOfTypes lhs `subVarSet` tcv_set, text "lhs" <+> pp_ax ) - ASSERT2( lhs_kind `eqType` rhs_kind, text "kind" <+> pp_ax $$ ppr lhs_kind $$ ppr rhs_kind ) - -- We used to have an assertion that the tyvars of the RHS were bound - -- by tcv_set, but in error situations like F Int = a that isn't - -- true; a later check in checkValidFamInst rejects it - do { (subst, tvs') <- freshenTyVarBndrs tvs + = do { + -- Freshen the type variables + (subst, tvs') <- freshenTyVarBndrs tvs ; (subst, cvs') <- freshenCoVarBndrsX subst cvs - ; dflags <- getDynFlags ; let lhs' = substTys subst lhs rhs' = substTy subst rhs - tcvs' = tvs' ++ cvs' - ; ifErrsM (return ()) $ -- Don't lint when there are errors, because - -- errors might mean TcTyCons. - -- See Note [Recover from validity error] in GHC.Tc.TyCl - when (gopt Opt_DoCoreLinting dflags) $ - -- Check that the types involved in this instance are well formed. - -- Do /not/ expand type synonyms, for the reasons discussed in - -- Note [Linting type synonym applications]. - case lintTypes dflags tcvs' (rhs':lhs') of - Nothing -> pure () - Just fail_msg -> pprPanic "Core Lint error in newFamInst" $ - vcat [ fail_msg - , ppr fam_tc - , ppr subst - , ppr tvs' - , ppr cvs' - , ppr lhs' - , ppr rhs' ] + ; return (FamInst { fi_fam = tyConName fam_tc , fi_flavor = flavor , fi_tcs = roughMatchTcs lhs @@ -199,10 +177,6 @@ newFamInst flavor axiom@(CoAxiom { co_ax_tc = fam_tc }) , fi_rhs = rhs' , fi_axiom = axiom }) } where - lhs_kind = tcTypeKind (mkTyConApp fam_tc lhs) - rhs_kind = tcTypeKind rhs - tcv_set = mkVarSet (tvs ++ cvs) - pp_ax = pprCoAxiom axiom CoAxBranch { cab_tvs = tvs , cab_cvs = cvs , cab_lhs = lhs ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -268,6 +268,14 @@ tcRnModuleTcRnM hsc_env mod_sum then tcRnHsBootDecls hsc_src local_decls else {-# SCC "tcRnSrcDecls" #-} tcRnSrcDecls explicit_mod_hdr local_decls export_ies + + ; whenM (goptM Opt_DoCoreLinting) $ + do { let (warns, errs) = lintGblEnv (hsc_dflags hsc_env) tcg_env + ; mapBagM_ (addWarn NoReason) warns + ; mapBagM_ addErr errs + ; failIfErrsM } -- if we have a lint error, we're only + -- going to get in deeper trouble by proceeding + ; setGblEnv tcg_env $ do { -- Process the export list traceRn "rn4a: before exports" empty @@ -2896,7 +2904,7 @@ pprTcGblEnv (TcGblEnv { tcg_type_env = type_env, pprUFM (imp_dep_mods imports) (ppr . sort) , text "Dependent packages:" <+> ppr (S.toList $ imp_dep_pkgs imports)] - where -- The use of sort is just to reduce unnecessary + -- The use of sort is just to reduce unnecessary -- wobbling in testsuite output ppr_rules :: [LRuleDecl GhcTc] -> SDoc ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1791,6 +1791,272 @@ and take the wired-in information. That avoids complications. e.g. the need to make the data constructor worker name for a constraint tuple match the wired-in one +Note [Datatype return kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +There are several poorly lit corners around datatype/newtype return kinds. +This Note explains these. We cover data/newtype families and instances +in Note [Data family/instance return kinds]. + +data T a :: where ... -- See Point DT4 +newtype T a :: where ... -- See Point DT5 + +DT1 Where this applies: Only GADT syntax for data/newtype/instance declarations + can have declared return kinds. This Note does not apply to Haskell98 + syntax. + +DT2 Where these kinds come from: The return kind is part of the TyCon kind, gotten either + by checkInitialKind (standalone kind signature / CUSK) or + inferInitialKind. It is extracted by bindTyClTyVars in tcTyClDecl1. It is + then passed to tcDataDefn. + +DT3 Eta-expansion: Any forall-bound variables and function arguments in a result kind + become parameters to the type. That is, when we say + + data T a :: Type -> Type where ... + + we really mean for T to have two parameters. The second parameter + is produced by processing the return kind in etaExpandAlgTyCon, + called in tcDataDefn. + + See also Note [TyConBinders for the result kind signatures of a data type] + in GHC.Tc.Gen.HsType. + +DT4 Datatype return kind restriction: A data type return kind must end + in a type that, after type-synonym expansion, yields `TYPE LiftedRep`. By + "end in", we mean we strip any foralls and function arguments off before + checking. + + Examples: + data T1 :: Type -- good + data T2 :: Bool -> Type -- good + data T3 :: Bool -> forall k. Type -- strange, but still accepted + data T4 :: forall k. k -> Type -- good + data T5 :: Bool -- bad + data T6 :: Type -> Bool -- bad + + Exactly the same applies to data instance (but not data family) + declarations. Examples + data instance D1 :: Type -- good + data instance D2 :: Bool -> Type -- good + + We can "look through" type synonyms + type Star = Type + data T7 :: Bool -> Star -- good (synonym expansion ok) + type Arrow = (->) + data T8 :: Arrow Bool Type -- good (ditto) + + But we specifically do *not* do type family reduction here. + type family ARROW where + ARROW = (->) + data T9 :: ARROW Bool Type -- bad + + type family F a where + F Int = Bool + F Bool = Type + data T10 :: Bool -> F Bool -- bad + + The /principle/ here is that in the TyCon for a data type or data instance, + we must be able to lay out all the type-variable binders, one by one, until + we reach (TYPE xx). There is no place for a cast here. We could add one, + but let's not! + + This check is done in checkDataKindSig. For data declarations, this + call is in tcDataDefn; for data instances, this call is in tcDataFamInstDecl. + +DT5 Newtype return kind restriction. + If -XUnliftedNewtypes is not on, then newtypes are treated just + like datatypes --- see (4) above. + + If -XUnliftedNewtypes is on, then a newtype return kind must end in + TYPE xyz, for some xyz (after type synonym expansion). The "xyz" + may include type families, but the TYPE part must be visible + /without/ expanding type families (only synonyms). + + This kind is unified with the kind of the representation type (the + type of the one argument to the one constructor). See also steps + (2) and (3) of Note [Implementation of UnliftedNewtypes]. + + The checks are done in the same places as for datatypes. + Examples (assume -XUnliftedNewtypes): + + newtype N1 :: Type -- good + newtype N2 :: Bool -> Type -- good + newtype N3 :: forall r. Bool -> TYPE r -- good + + type family F (t :: Type) :: RuntimeRep + newtype N4 :: forall t -> TYPE (F t) -- good + + type family STAR where + STAR = Type + newtype N5 :: Bool -> STAR -- bad + +Note [Data family/instance return kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Within this note, understand "instance" to mean data or newtype +instance, and understand "family" to mean data family. No type +families or classes here. Some examples: + +data family T a :: -- See Point DF56 + +data instance T [a] :: where ... -- See Point DF2 +newtype instance T [a] :: where ... -- See Point DF2 + +Here is the Plan for Data Families: + +DF0 Where these kinds come from: + + Families: The return kind is either written in a standalone signature + or extracted from a family declaration in getInitialKind. + If a family declaration is missing a result kind, it is assumed to be + Type. This assumption is in getInitialKind for CUSKs or + get_fam_decl_initial_kind for non-signature & non-CUSK cases. + + Instances: The data family already has a known kind. The return kind + of an instance is then calculated by applying the data family tycon + to the patterns provided, as computed by the typeKind lhs_ty in the + end of tcDataFamInstHeader. In the case of an instance written in GADT + syntax, there are potentially *two* return kinds: the one computed from + applying the data family tycon to the patterns, and the one given by + the user. This second kind is checked by the tc_kind_sig function within + tcDataFamInstHeader. See also DF3, below. + +DF1 In a data/newtype instance, we treat the kind of the /data family/, + once instantiated, as the "master kind" for the representation + TyCon. For example: + data family T1 :: Type -> Type -> Type + data instance T1 Int :: F Bool -> Type where ... + The "master kind" for the representation TyCon R:T1Int comes + from T1, not from the signature on the data instance. It is as + if we declared + data R:T1Int :: Type -> Type where ... + See Note [Liberalising data family return kinds] for an alternative + plan. But this current plan is simple, and ensures that all instances + are simple instantiations of the master, without strange casts. + + An example with non-trivial instantiation: + data family T2 :: forall k. Type -> k + data instance T2 :: Type -> Type -> Type where ... + Here 'k' gets instantiated with (Type -> Type), driven by + the signature on the 'data instance'. (See also DT3 of + Note [Datatype return kinds] about eta-expansion, which applies here, + too; see tcDataFamInstDecl's call of etaExpandAlgTyCon.) + + A newtype example: + + data Color = Red | Blue + type family Interpret (x :: Color) :: RuntimeRep where + Interpret 'Red = 'IntRep + Interpret 'Blue = 'WordRep + data family Foo (x :: Color) :: TYPE (Interpret x) + newtype instance Foo 'Red :: TYPE IntRep where + FooRedC :: Int# -> Foo 'Red + + Here we get that Foo 'Red :: TYPE (Interpret Red), and our + representation newtype looks like + newtype R:FooRed :: TYPE (Interpret Red) where + FooRedC :: Int# -> R:FooRed + Remember: the master kind comes from the /family/ tycon. + +DF2 /After/ this instantiation, the return kind of the master kind + must obey the usual rules for data/newtype return kinds (DT4, DT5) + of Note [Datatype return kinds]. Examples: + data family T3 k :: k + data instance T3 Type where ... -- OK + data instance T3 (Type->Type) where ... -- OK + data instance T3 (F Int) where ... -- Not OK + +DF3 Any kind signatures on the data/newtype instance are checked for + equality with the master kind (and hence may guide instantiation) + but are otherwise ignored. So in the T1 example above, we check + that (F Int ~ Type) by unification; but otherwise ignore the + user-supplied signature from the /family/ not the /instance/. + + We must be sure to instantiate any trailing invisible binders + before doing this unification. See the call to tcInstInvisibleBinders + in tcDataFamInstHeader. For example: + data family D :: forall k. k + data instance D :: Type -- forall k. k <: Type + data instance D :: Type -> Type -- forall k. k <: Type -> Type + -- NB: these do not overlap + we must instantiate D before unifying with the signature in the + data instance declaration + +DF4 We also (redundantly) check that any user-specified return kind + signature in the data instance also obeys DT4/DT5. For example we + reject + data family T1 :: Type -> Type -> Type + data instance T1 Int :: Type -> F Int + even if (F Int ~ Type). We could omit this check, because we + use the master kind; but it seems more uniform to check it, again + with checkDataKindSig. + +DF5 Data /family/ return kind restrictions. Consider + data family D8 a :: F a + where F is a type family. No data/newtype instance can instantiate + this so that it obeys the rules of DT4 or DT5. So GHC proactively + rejects the data /family/ declaration if it can never satisfy (DT4)/(DT5). + Remember that a data family supports both data and newtype instances. + + More precisely, the return kind of a data family must be either + * TYPE xyz (for some type xyz) or + * a kind variable + Only in these cases can a data/newtype instance possibly satisfy (DT4)/(DT5). + This is checked by the call to checkDataKindSig in tcFamDecl1. Examples: + + data family D1 :: Type -- good + data family D2 :: Bool -> Type -- good + data family D3 k :: k -- good + data family D4 :: forall k -> k -- good + data family D5 :: forall k. k -> k -- good + data family D6 :: forall r. TYPE r -- good + data family D7 :: Bool -> STAR -- bad (see STAR from point 5) + +DF6 Two return kinds for instances: If an instance has two return kinds, + one from the family declaration and one from the instance declaration + (see point DF3 above), they are unified. More accurately, we make sure + that the kind of the applied data family is a subkind of the user-written + kind. GHC.Tc.Gen.HsType.checkExpectedKind normally does this check for types, but + that's overkill for our needs here. Instead, we just instantiate any + invisible binders in the (instantiated) kind of the data family + (called lhs_kind in tcDataFamInstHeader) with tcInstInvisibleTyBinders + and then unify the resulting kind with the kind written by the user. + This unification naturally produces a coercion, which we can drop, as + the kind annotation on the instance is redundant (except perhaps for + effects of unification). + + This all is Wrinkle (3) in Note [Implementation of UnliftedNewtypes]. + +Note [Liberalising data family return kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Could we allow this? + type family F a where { F Int = Type } + data family T a :: F a + data instance T Int where + MkT :: T Int + +In the 'data instance', T Int :: F Int, and F Int = Type, so all seems +well. But there are lots of complications: + +* The representation constructor R:TInt presumably has kind Type. + So the axiom connecting the two would have to look like + axTInt :: T Int ~ R:TInt |> sym axFInt + and that doesn't match expectation in DataFamInstTyCon + in AlgTyConFlav + +* The wrapper can't have type + $WMkT :: Int -> T Int + because T Int has the wrong kind. It would have to be + $WMkT :: Int -> (T Int) |> axFInt + +* The code for $WMkT would also be more complicated, needing + two coherence coercions. Try it! + +* Code for pattern matching would be complicated in an + exactly dual way. + +So yes, we could allow this, but we currently do not. That's +why we have DF2 in Note [Data family/instance return kinds]. + Note [Implementation of UnliftedNewtypes] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expected behavior of UnliftedNewtypes: @@ -1867,11 +2133,12 @@ Wrinkle: Consider (#17021, typecheck/should_fail/T17021) newtype T :: TYPE (Id LiftedRep) where MkT :: Int -> T - In the type of MkT, we must end with (Int |> TYPE (sym axId)) -> T, never Int -> (T |> - TYPE axId); otherwise, the result type of the constructor wouldn't match the - datatype. However, type-checking the HsType T might reasonably result in - (T |> hole). We thus must ensure that this cast is dropped, forcing the - type-checker to add one to the Int instead. + In the type of MkT, we must end with (Int |> TYPE (sym axId)) -> T, + never Int -> (T |> TYPE axId); otherwise, the result type of the + constructor wouldn't match the datatype. However, type-checking the + HsType T might reasonably result in (T |> hole). We thus must ensure + that this cast is dropped, forcing the type-checker to add one to + the Int instead. Why is it always safe to drop the cast? This result type is type-checked by tcHsOpenType, so its kind definitely looks like TYPE r, for some r. It is @@ -1883,7 +2150,7 @@ Wrinkle: Consider (#17021, typecheck/should_fail/T17021) Note that this is possible in the H98 case only for a data family, because the H98 syntax doesn't permit a kind signature on the newtype itself. -There are also some changes for deailng with families: +There are also some changes for dealing with families: 1. In tcFamDecl1, we suppress a tcIsLiftedTypeKind check if UnliftedNewtypes is on. This allows us to write things like: @@ -1905,7 +2172,7 @@ There are also some changes for deailng with families: we use that kind signature. 3. A data family and its newtype instance may be declared with slightly - different kinds. See point 7 in Note [Datatype return kinds]. + different kinds. See point DF6 in Note [Data family/instance return kinds] There's also a change in the renamer: @@ -2292,187 +2559,6 @@ Since the LHS of an associated type family default is always just variables, it won't contain any tycons. Accordingly, the patterns used in the substitution won't actually be knot-tied, even though we're in the knot. This is too delicate for my taste, but it works. - -Note [Datatype return kinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -There are several poorly lit corners around datatype/newtype return kinds. -This Note explains these. Within this note, always understand "instance" -to mean data or newtype instance, and understand "family" to mean data -family. No type families or classes here. Some examples: - -data T a :: where ... -- See Point 4 -newtype T a :: where ... -- See Point 5 - -data family T a :: -- See Point 6 - -data instance T [a] :: where ... -- See Point 4 -newtype instance T [a] :: where ... -- See Point 5 - -1. Where this applies: Only GADT syntax for data/newtype/instance declarations - can have declared return kinds. This Note does not apply to Haskell98 - syntax. - -2. Where these kinds come from: Return kinds are processed through several - different code paths: - - Data/newtypes: The return kind is part of the TyCon kind, gotten either - by checkInitialKind (standalone kind signature / CUSK) or - inferInitialKind. It is extracted by bindTyClTyVars in tcTyClDecl1. It is - then passed to tcDataDefn. - - Families: The return kind is either written in a standalone signature - or extracted from a family declaration in getInitialKind. - If a family declaration is missing a result kind, it is assumed to be - Type. This assumption is in getInitialKind for CUSKs or - get_fam_decl_initial_kind for non-signature & non-CUSK cases. - - Instances: The data family already has a known kind. The return kind - of an instance is then calculated by applying the data family tycon - to the patterns provided, as computed by the typeKind lhs_ty in the - end of tcDataFamInstHeader. In the case of an instance written in GADT - syntax, there are potentially *two* return kinds: the one computed from - applying the data family tycon to the patterns, and the one given by - the user. This second kind is checked by the tc_kind_sig function within - tcDataFamInstHeader. - -3. Eta-expansion: Any forall-bound variables and function arguments in a result kind - become parameters to the type. That is, when we say - - data T a :: Type -> Type where ... - - we really mean for T to have two parameters. The second parameter - is produced by processing the return kind in etaExpandAlgTyCon, - called in tcDataDefn for data/newtypes and in tcDataFamInstDecl - for instances. This is true for data families as well, though their - arity only matters for pretty-printing. - - See also Note [TyConBinders for the result kind signatures of a data type] - in GHC.Tc.Gen.HsType. - -4. Datatype return kind restriction: A data/data-instance return kind must end - in a type that, after type-synonym expansion, yields `TYPE LiftedRep`. By - "end in", we mean we strip any foralls and function arguments off before - checking: this remaining part of the type is returned from etaExpandAlgTyCon. - - Examples: - data T1 :: Type -- good - data T2 :: Bool -> Type -- good - data T3 :: Bool -> forall k. Type -- strange, but still accepted - data T4 :: forall k. k -> Type -- good - data T5 :: Bool -- bad - data T6 :: Type -> Bool -- bad - - Exactly the same applies to data instance (but not data family) - declarations. Examples - data instance D1 :: Type -- good - data instance D2 :: Boool -> Type -- good - - We can "look through" type synonyms - type Star = Type - data T7 :: Bool -> Star -- good (synonym expansion ok) - type Arrow = (->) - data T8 :: Arrow Bool Type -- good (ditto) - - But we specifically do *not* do type family reduction here. - type family ARROW where - ARROW = (->) - data T9 :: ARROW Bool Type -- bad - - type family F a where - F Int = Bool - F Bool = Type - data T10 :: Bool -> F Bool -- bad - - The /principle/ here is that in the TyCon for a data type or data instance, - we must be able to lay out all the type-variable binders, one by one, until - we reach (TYPE xx). There is no place for a cast here. We could add one, - but let's not! - - This check is done in checkDataKindSig. For data declarations, this - call is in tcDataDefn; for data instances, this call is in tcDataFamInstDecl. - -4a Because data instances in GADT syntax can have two return kinds (see - point (2) above), we must check both return kinds. The user-written return - kind is checked by the call to checkDataKindSig in tcDataFamInstDecl. Examples: - - data family D (a :: Nat) :: k -- good (see Point 6) - - data instance D 1 :: Type -- good - data instance D 2 :: F Bool -- bad - -5. Newtype return kind restriction: If -XUnliftedNewtypes is on, then - a newtype/newtype-instance return kind must end in TYPE xyz, for some - xyz (after type synonym expansion). The "xyz" may include type families, - but the TYPE part must be visible with expanding type families (only synonyms). - This kind is unified with the kind of the representation type (the type - of the one argument to the one constructor). See also steps (2) and (3) - of Note [Implementation of UnliftedNewtypes]. - - If -XUnliftedNewtypes is not on, then newtypes are treated just like datatypes. - - The checks are done in the same places as for datatypes. - Examples (assume -XUnliftedNewtypes): - - newtype N1 :: Type -- good - newtype N2 :: Bool -> Type -- good - newtype N3 :: forall r. Bool -> TYPE r -- good - - type family F (t :: Type) :: RuntimeRep - newtype N4 :: forall t -> TYPE (F t) -- good - - type family STAR where - STAR = Type - newtype N5 :: Bool -> STAR -- bad - -6. Family return kind restrictions: The return kind of a data family must - be either TYPE xyz (for some xyz) or a kind variable. The idea is that - instances may specialise the kind variable to fit one of the restrictions - above. This is checked by the call to checkDataKindSig in tcFamDecl1. - Examples: - - data family D1 :: Type -- good - data family D2 :: Bool -> Type -- good - data family D3 k :: k -- good - data family D4 :: forall k -> k -- good - data family D5 :: forall k. k -> k -- good - data family D6 :: forall r. TYPE r -- good - data family D7 :: Bool -> STAR -- bad (see STAR from point 5) - -7. Two return kinds for instances: If an instance has two return kinds, - one from the family declaration and one from the instance declaration - (see point (2) above), they are unified. More accurately, we make sure - that the kind of the applied data family is a subkind of the user-written - kind. GHC.Tc.Gen.HsType.checkExpectedKind normally does this check for types, but - that's overkill for our needs here. Instead, we just instantiate any - invisible binders in the (instantiated) kind of the data family - (called lhs_kind in tcDataFamInstHeader) with tcInstInvisibleTyBinders - and then unify the resulting kind with the kind written by the user. - This unification naturally produces a coercion, which we can drop, as - the kind annotation on the instance is redundant (except perhaps for - effects of unification). - - Example: - - data Color = Red | Blue - type family Interpret (x :: Color) :: RuntimeRep where - Interpret 'Red = 'IntRep - Interpret 'Blue = 'WordRep - data family Foo (x :: Color) :: TYPE (Interpret x) - newtype instance Foo 'Red :: TYPE IntRep where - FooRedC :: Int# -> Foo 'Red - - Here we get that Foo 'Red :: TYPE (Interpret Red) and we have to - unify the kind with TYPE IntRep. - - Example requiring subkinding: - - data family D :: forall k. k - data instance D :: Type -- forall k. k <: Type - data instance D :: Type -> Type -- forall k. k <: Type -> Type - -- NB: these do not overlap - - This all is Wrinkle (3) in Note [Implementation of UnliftedNewtypes]. - -} {- ********************************************************************* @@ -2502,8 +2588,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info -- When UnliftedNewtypes is enabled, we loosen this restriction -- on the return kind. See Note [Implementation of UnliftedNewtypes], wrinkle (1). -- See also Note [Datatype return kinds] - ; let (_, final_res_kind) = splitPiTys res_kind - ; checkDataKindSig DataFamilySort final_res_kind + ; checkDataKindSig DataFamilySort res_kind ; tc_rep_name <- newTyConRepName tc_name ; let inj = Injective $ replicate (length binders) True tycon = mkFamilyTyCon tc_name binders @@ -2798,7 +2883,7 @@ tcTyFamInstEqn fam_tc mb_clsinfo hs_pats hs_rhs_ty -- Don't print results they may be knot-tied -- (tcFamInstEqnGuts zonks to Type) - ; return (mkCoAxBranch qtvs [] [] fam_tc pats rhs_ty + ; return (mkCoAxBranch qtvs [] [] pats rhs_ty (map (const Nominal) qtvs) loc) } @@ -3170,8 +3255,8 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data } tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data - -- NB: don't use res_kind here, as it's ill-scoped. Instead, we get - -- the res_kind by typechecking the result type. + -- NB: don't use res_kind here, as it's ill-scoped. Instead, + -- we get the res_kind by typechecking the result type. (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms @@ -3188,16 +3273,12 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data bindImplicitTKBndrs_Skol implicit_tkv_nms $ bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext cxt - ; casted_res_ty <- tcHsOpenType hs_res_ty - ; res_ty <- if not debugIsOn then return $ discardCast casted_res_ty - else case splitCastTy_maybe casted_res_ty of - Just (ty, _) -> do unlifted_nts <- xoptM LangExt.UnliftedNewtypes - MASSERT( unlifted_nts ) - MASSERT( new_or_data == NewType ) - return ty - _ -> return casted_res_ty + ; (res_ty, res_kind) <- tcInferLHsTypeKind hs_res_ty + -- See Note [GADT return kinds] + -- See Note [Datatype return kinds] - ; let exp_kind = getArgExpKind new_or_data (typeKind res_ty) + ; let exp_kind = getArgExpKind new_or_data res_kind + ; btys <- tcConArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name @@ -3252,6 +3333,20 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data ; mapM buildOneDataCon names } +{- Note [GADT return kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + type family Star where Star = Type + data T :: Type where + MkT :: Int -> T + +If, for some stupid reason, tcInferLHsTypeKind on the return type of +MkT returned (T |> ax, Star), then the return-type check in +checkValidDataCon would reject the decl (although of course there is +nothing wrong with it). We are implicitly requiring tha +tcInferLHsTypeKind doesn't any gratuitous top-level casts. +-} + -- | Produce an "expected kind" for the arguments of a data/newtype. -- If the declaration is indeed for a newtype, -- then this expected kind will be the kind provided. Otherwise, @@ -3924,11 +4019,16 @@ checkValidDataCon dflags existential_ok tc con , ppr orig_res_ty <+> dcolon <+> ppr (tcTypeKind orig_res_ty)]) - ; checkTc (isJust (tcMatchTy res_ty_tmpl orig_res_ty)) + ; checkTc (isJust (tcMatchTyKi res_ty_tmpl orig_res_ty)) (badDataConTyCon con res_ty_tmpl) -- Note that checkTc aborts if it finds an error. This is -- critical to avoid panicking when we call dataConDisplayType -- on an un-rejiggable datacon! + -- Also NB that we match the *kind* as well as the *type* (#18357) + -- However, if the kind is the only thing that doesn't match, the + -- error message is terrible. E.g. test T18357b + -- type family Star where Star = Type + -- newtype T :: Type where MkT :: Int -> (T :: Star) ; traceTc "checkValidDataCon 2" (ppr data_con_display_type) ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -704,7 +704,6 @@ tcDataFamInstDecl mb_clsinfo tv_skol_env -- Check the result kind; it may come from a user-written signature. -- See Note [Datatype return kinds] in GHC.Tc.TyCl point 4(a) - ; checkDataKindSig (DataInstanceSort new_or_data) final_res_kind ; let extra_pats = map (mkTyVarTy . binderVar) extra_tcbs all_pats = pats `chkAppend` extra_pats orig_res_ty = mkTyConApp fam_tc all_pats @@ -713,10 +712,12 @@ tcDataFamInstDecl mb_clsinfo tv_skol_env ; traceTc "tcDataFamInstDecl" $ vcat [ text "Fam tycon:" <+> ppr fam_tc , text "Pats:" <+> ppr pats - , text "visibliities:" <+> ppr (tcbVisibilities fam_tc pats) + , text "visiblities:" <+> ppr (tcbVisibilities fam_tc pats) , text "all_pats:" <+> ppr all_pats , text "ty_binders" <+> ppr ty_binders , text "fam_tc_binders:" <+> ppr (tyConBinders fam_tc) + , text "res_kind:" <+> ppr res_kind + , text "final_res_kind:" <+> ppr final_res_kind , text "eta_pats" <+> ppr eta_pats , text "eta_tcbs" <+> ppr eta_tcbs ] @@ -734,9 +735,9 @@ tcDataFamInstDecl mb_clsinfo tv_skol_env NewType -> ASSERT( not (null data_cons) ) mkNewTyConRhs rep_tc_name rec_rep_tc (head data_cons) - ; let axiom = mkSingleCoAxiom Representational axiom_name - post_eta_qtvs eta_tvs [] fam_tc eta_pats - (mkTyConApp rep_tc (mkTyVarTys post_eta_qtvs)) + ; let ax_rhs = mkTyConApp rep_tc (mkTyVarTys post_eta_qtvs) + axiom = mkSingleCoAxiom Representational axiom_name + post_eta_qtvs eta_tvs [] fam_tc eta_pats ax_rhs parent = DataFamInstTyCon axiom fam_tc all_pats -- NB: Use the full ty_binders from the pats. See bullet toward @@ -851,13 +852,17 @@ tcDataFamInstHeader tcDataFamInstHeader mb_clsinfo fam_tc imp_vars mb_bndrs fixity hs_ctxt hs_pats m_ksig hs_cons new_or_data = do { traceTc "tcDataFamInstHeader {" (ppr fam_tc <+> ppr hs_pats) - ; (imp_tvs, (exp_tvs, (stupid_theta, lhs_ty, res_kind))) + ; (imp_tvs, (exp_tvs, (stupid_theta, lhs_ty, master_res_kind, instance_res_kind))) <- pushTcLevelM_ $ solveEqualities $ bindImplicitTKBndrs_Q_Skol imp_vars $ bindExplicitTKBndrs_Q_Skol AnyKind exp_bndrs $ do { stupid_theta <- tcHsContext hs_ctxt ; (lhs_ty, lhs_kind) <- tcFamTyPats fam_tc hs_pats + ; (lhs_applied_ty, lhs_applied_kind) + <- tcInstInvisibleTyBinders lhs_ty lhs_kind + -- See Note [Data family/instance return kinds] + -- in GHC.Tc.TyCl point (DF3) -- Ensure that the instance is consistent -- with its parent class @@ -869,21 +874,17 @@ tcDataFamInstHeader mb_clsinfo fam_tc imp_vars mb_bndrs fixity -- Add constraints from the data constructors ; kcConDecls new_or_data res_kind hs_cons - -- See Note [Datatype return kinds] in GHC.Tc.TyCl, point (7). - ; (lhs_extra_args, lhs_applied_kind) - <- tcInstInvisibleTyBinders (invisibleTyBndrCount lhs_kind) - lhs_kind - ; let lhs_applied_ty = lhs_ty `mkTcAppTys` lhs_extra_args - hs_lhs = nlHsTyConApp fixity (getName fam_tc) hs_pats + -- Check that the result kind of the TyCon applied to its args + -- is compatible with the explicit signature (or Type, if there + -- is none) + ; let hs_lhs = nlHsTyConApp fixity (getName fam_tc) hs_pats ; _ <- unifyKind (Just (unLoc hs_lhs)) lhs_applied_kind res_kind - -- Check that the result kind of the TyCon applied to its args - -- is compatible with the explicit signature (or Type, if there - -- is none) ; traceTc "tcDataFamInstHeader" $ vcat [ ppr fam_tc, ppr m_ksig, ppr lhs_applied_kind, ppr res_kind ] ; return ( stupid_theta , lhs_applied_ty + , lhs_applied_kind , res_kind ) } -- See GHC.Tc.TyCl Note [Generalising in tcFamTyPatsGuts] @@ -900,13 +901,17 @@ tcDataFamInstHeader mb_clsinfo fam_tc imp_vars mb_bndrs fixity ; (ze, qtvs) <- zonkTyBndrs qtvs ; lhs_ty <- zonkTcTypeToTypeX ze lhs_ty ; stupid_theta <- zonkTcTypesToTypesX ze stupid_theta - ; res_kind <- zonkTcTypeToTypeX ze res_kind + ; master_res_kind <- zonkTcTypeToTypeX ze master_res_kind + ; instance_res_kind <- zonkTcTypeToTypeX ze instance_res_kind -- We check that res_kind is OK with checkDataKindSig in -- tcDataFamInstDecl, after eta-expansion. We need to check that -- it's ok because res_kind can come from a user-written kind signature. -- See Note [Datatype return kinds], point (4a) + ; checkDataKindSig (DataInstanceSort new_or_data) master_res_kind + ; checkDataKindSig (DataInstanceSort new_or_data) instance_res_kind + -- Check that type patterns match the class instance head -- The call to splitTyConApp_maybe here is just an inlining of -- the body of unravelFamInstPats. @@ -914,7 +919,7 @@ tcDataFamInstHeader mb_clsinfo fam_tc imp_vars mb_bndrs fixity Just (_, pats) -> pure pats Nothing -> pprPanic "tcDataFamInstHeader" (ppr lhs_ty) - ; return (qtvs, pats, res_kind, stupid_theta) } + ; return (qtvs, pats, master_res_kind, stupid_theta) } where fam_name = tyConName fam_tc data_ctxt = DataKindCtxt fam_name @@ -973,7 +978,7 @@ however, so this Note aims to describe these subtleties: * The representation tycon Drep is parameterised over the free variables of the pattern, in no particular order. So there is no guarantee that 'p' and 'q' will come last in Drep's parameters, and - in the right order. So, if the /patterns/ of the family insatance + in the right order. So, if the /patterns/ of the family instance are eta-reducible, we re-order Drep's parameters to put the eta-reduced type variables last. ===================================== compiler/GHC/Tc/Types.hs ===================================== @@ -79,7 +79,10 @@ module GHC.Tc.Types( -- Role annotations RoleAnnotEnv, emptyRoleAnnotEnv, mkRoleAnnotEnv, - lookupRoleAnnot, getRoleAnnots + lookupRoleAnnot, getRoleAnnots, + + -- Linting + lintGblEnv ) where #include "HsVersions.h" @@ -93,6 +96,7 @@ import GHC.Tc.Types.Evidence import GHC.Core.Type import GHC.Core.TyCon ( TyCon, tyConKind ) import GHC.Core.PatSyn ( PatSyn ) +import GHC.Core.Lint ( lintAxioms ) import GHC.Types.Id ( idType, idName ) import GHC.Types.FieldLabel ( FieldLabel ) import GHC.Core.UsageEnv @@ -1738,3 +1742,16 @@ lookupRoleAnnot = lookupNameEnv getRoleAnnots :: [Name] -> RoleAnnotEnv -> [LRoleAnnotDecl GhcRn] getRoleAnnots bndrs role_env = mapMaybe (lookupRoleAnnot role_env) bndrs + +{- ********************************************************************* +* * + Linting a TcGblEnv +* * +********************************************************************* -} + +-- | Check the 'TcGblEnv' for consistency. Currently, only checks +-- axioms, but should check other aspects, too. +lintGblEnv :: DynFlags -> TcGblEnv -> (Bag SDoc, Bag SDoc) +lintGblEnv dflags tcg_env = lintAxioms dflags axioms + where + axioms = typeEnvCoAxioms (tcg_type_env tcg_env) ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -16,7 +16,7 @@ module GHC.Tc.Utils.Instantiate ( instCall, instDFunType, instStupidTheta, instTyVarsWith, newWanted, newWanteds, - tcInstInvisibleTyBinders, tcInstInvisibleTyBinder, + tcInstInvisibleTyBindersN, tcInstInvisibleTyBinders, tcInstInvisibleTyBinder, newOverloadedLit, mkOverLit, @@ -366,13 +366,19 @@ instStupidTheta orig theta * * ********************************************************************* -} --- | Instantiates up to n invisible binders --- Returns the instantiating types, and body kind -tcInstInvisibleTyBinders :: Int -> TcKind -> TcM ([TcType], TcKind) +-- | Given ty::forall k1 k2. k, instantiate all the invisible forall-binders +-- returning ty @kk1 @kk2 :: k[kk1/k1, kk2/k1] +tcInstInvisibleTyBinders :: TcType -> TcKind -> TcM (TcType, TcKind) +tcInstInvisibleTyBinders ty kind + = do { (extra_args, kind') <- tcInstInvisibleTyBindersN n_invis kind + ; return (mkAppTys ty extra_args, kind') } + where + n_invis = invisibleTyBndrCount kind -tcInstInvisibleTyBinders 0 kind +tcInstInvisibleTyBindersN :: Int -> TcKind -> TcM ([TcType], TcKind) +tcInstInvisibleTyBindersN 0 kind = return ([], kind) -tcInstInvisibleTyBinders n ty +tcInstInvisibleTyBindersN n ty = go n empty_subst ty where empty_subst = mkEmptyTCvSubst (mkInScopeSet (tyCoVarsOfType ty)) ===================================== docs/core-spec/CoreLint.ott ===================================== @@ -656,3 +656,43 @@ unify(, ) = subst subst(s) = subst(s') ----------------------------------------- :: CompatCoincident no_conflict(C, , ind1, ind2) + +defn |- axiom C ok :: :: lint_axiom :: 'Ax_' + {{ com Coercion axiom linting, \coderef{GHC/Core/Lint.hs}{lint\_axiom} }} + {{ tex \labeledjudge{axiom} [[C]] [[ok]] }} +by + +isNewTyCon T + = tyConRoles T + |-ty T : k0 + |-ty s : k0 +------------------------------ :: Newtype +|-axiom T_Rep forall . ( ~> s) ok + +isOpenTypeFamilyTyCon T +T |-branch b ok +------------------------------ :: OpenTypeFamily +|-axiom T_Nom b ok + +isClosedTypeFamilyTyCon T + +--------------------------- :: ClosedTypeFamily +|-axiom T_Nom ok + +isDataFamilyTyCon T +T |-branch b ok +--------------------------- :: DataFamily +|-axiom T_Rep b ok + +defn T |- branch b ok :: :: lint_family_branch :: 'Br_' + {{ com Type family branch linting, \coderef{GHC/Core/Lint.hs}{lint\_family\_branch} }} + {{ tex [[T]] \labeledjudge{branch} [[b]] [[ok]] }} +by + + + +fv() = + |-ty T : k0 + |-ty s : k0 +---------------------------------------------------------------- :: OK +T |-branch forall . ( ~> s) ok ===================================== docs/core-spec/CoreSyn.ott ===================================== @@ -52,10 +52,10 @@ l :: 'Label_' ::= {{ com Labels for join points, also \coderef{GHC/Types/Var.hs} vars :: 'Vars_' ::= {{ com List of variables }} | :: :: List - | fv ( t ) :: M :: fv_t - {{ tex \textit{fv}([[t]]) }} | fv ( e ) :: M :: fv_e {{ tex \textit{fv}([[e]]) }} + | fv ( types ) :: M :: fv_types + {{ tex \textit{fv}([[types]]) }} | empty :: M :: empty | vars1 \inter vars2 :: M :: intersection {{ tex [[vars1]] \cap [[vars2]] }} @@ -197,7 +197,7 @@ R {{ tex \rho }} :: 'Role_' ::= {{ com Roles, \coderef{GHC/Core/Coercion/Axiom.h axBranch, b :: 'CoAxBranch_' ::= {{ com Axiom branches, \coderef{GHC/Core/TyCon.hs}{CoAxBranch} }} | forall . ( ~> s ) :: :: CoAxBranch {{ com \ctor{CoAxBranch}: Axiom branch }} - | ( ) [ ind ] :: M :: lookup {{ com List lookup }} + | ( ) [ ind ] :: M :: lookup {{ com List lookup }} mu {{ tex \mu }} :: 'CoAxiomRule_' ::= {{ com CoAxiomRules, \coderef{GHC/Core/Coercion/Axiom.hs}{CoAxiomRule} }} | M ( I , role_list , R' ) :: :: CoAxiomRule {{ com Named rule, with parameter info }} @@ -376,6 +376,10 @@ terminals :: 'terminals_' ::= | dataConTyCon :: :: dataConTyCon {{ tex \textsf{dataConTyCon} }} | dataConRepType :: :: dataConRepType {{ tex \textsf{dataConRepType} }} | isNewTyCon :: :: isNewTyCon {{ tex \textsf{isNewTyCon} }} + | isOpenTypeFamilyTyCon :: :: isOpenTypeFamilyTyCon {{ tex \textsf{isOpenTypeFamilyTyCon} }} + | isClosedTypeFamilyTyCon :: :: isClosedTypeFamilyTyCon {{ tex \textsf{isClosedTypeFamilyTyCon} }} + | isDataFamilyTyCon :: :: isDataFamilyTyCon {{ tex \textsf{isDataFamilyTyCon} }} + | isTyFamFree :: :: isTyFamFree {{ tex \textsf{isTyFamFree} }} | Constraint :: :: Constraint {{ tex \textsf{Constraint} }} | TYPE :: :: TYPE {{ tex \textsf{TYPE} }} | RuntimeRep :: :: RuntimeRep {{ tex \textsf{RuntimeRep} }} @@ -449,6 +453,10 @@ formula :: 'formula_' ::= | G |- tylit lit : k :: :: lintTyLit {{ tex [[G]] \labeledjudge{tylit} [[lit]] : [[k]] }} | isNewTyCon T :: :: isNewTyCon + | isOpenTypeFamilyTyCon T :: :: isOpenTypeFamilyTyCon + | isClosedTypeFamilyTyCon T :: :: isClosedTypeFamilyTyCon + | isDataFamilyTyCon T :: :: isDataFamilyTyCon + | isTyFamFree t :: :: isTyFamFree | k1 elt { } :: :: kind_elt | e is_a_type :: :: is_a_type {{ tex \exists \tau \text{ s.t.~} [[e]] = \tau }} @@ -526,3 +534,4 @@ Expr_Coercion <= Subst_TmMapping Type_CastTy <= Var_IdOrTyVar +Expr_Type <= Vars_fv_e ===================================== docs/core-spec/core-spec.mng ===================================== @@ -573,6 +573,37 @@ taking care to map identical type family applications to the same fresh variable The algorithm $[[unify]]$ is implemented in \coderef{GHC/Core/Unify.hs}{tcUnifyTys}. It performs a standard unification, returning a substitution upon success. +\subsection{Axioms} + +After type-checking the type and class declarations of a file, the axioms +in the file are optionally linted. This is done from \coderef{GHC/Tc/Types.hs}{lintGblEnv}, +which calls \coderef{GHC/Core/Lint.hs}{lintAxioms}. That function ensures +the following judgement on each axiom: + +\ottdefnlintXXaxiom{} + +\ottdefnlintXXfamilyXXbranch{} + +In addition to these checks, the linter will also check several other conditions: + +\begin{itemize} +\item Every \texttt{CoAxBranch} has a \texttt{cab\_cvs} field. This is unused +currently and should always be empty. +\item Every \texttt{CoAxBranch} has a \texttt{cab\_eta\_tvs} field. This is used +only for data family instances, but is not involved in type correctness. (It is +used for pretty-printing.) The implemented linter checks to make sure this field +is empty for axioms that are not associated with data family instances. +\item Every \texttt{CoAxBranch} has a \texttt{cab\_incomps} field that stores +a list of incompatible branches. The implemented linter checks that these +branches are indeed incompatible with the current one. +\item The linter checks that newtypes are associated with exactly one axiom, +as are closed type families. +\item The linter checks that all instances of the same open family are compatible. +\end{itemize} + +A nice summary of the required checks is in Section F.1 of the \emph{Safe Coercions} +paper (JFP'16). + \section{Operational semantics} \subsection{Disclaimer} ===================================== docs/core-spec/core-spec.pdf ===================================== Binary files a/docs/core-spec/core-spec.pdf and b/docs/core-spec/core-spec.pdf differ ===================================== testsuite/tests/polykinds/T18300.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE GADTs, PolyKinds, DataKinds, TypeFamilies #-} + +module Foo where + +import GHC.Exts +import Data.Kind + +type family F a :: RuntimeRep +type instance F Int = 'LiftedRep + +data family T a :: TYPE (F a) + +data instance T Int where + MkT :: Int -> T Int + +-- ASSERT error in HEAD ===================================== testsuite/tests/polykinds/T18300.stderr ===================================== @@ -0,0 +1,4 @@ + +T18300.hs:13:1: error: + • Data instance has non-* return kind ‘TYPE (F Int)’ + • In the data instance declaration for ‘T’ ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -219,3 +219,4 @@ test('T16902', normal, compile_fail, ['']) test('CuskFam', normal, compile, ['']) test('T17841', normal, compile_fail, ['']) test('T17963', normal, compile_fail, ['']) +test('T18300', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -685,7 +685,7 @@ test('UnliftedNewtypesUnifySig', normal, compile, ['']) test('UnliftedNewtypesForall', normal, compile, ['']) test('UnlifNewUnify', normal, compile, ['']) test('UnliftedNewtypesLPFamily', normal, compile, ['']) -test('UnliftedNewtypesDifficultUnification', when(compiler_debugged(), expect_broken(18300)), compile, ['']) +test('UnliftedNewtypesDifficultUnification', normal, compile, ['']) test('T16832', normal, ghci_script, ['T16832.script']) test('T16995', normal, compile, ['']) test('T17007', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T18357.hs ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE StandaloneKindSignatures, TypeFamilies, GADTs, DataKinds #-} + +module T18357 where + +import Data.Kind + +type family Star where Star = Type + +type W :: Star +type W = T + +newtype T where + MkT :: Int -> W ===================================== testsuite/tests/typecheck/should_fail/T18357.stderr ===================================== @@ -0,0 +1,6 @@ + +T18357.hs:13:3: error: + • Data constructor ‘MkT’ returns type ‘W’ + instead of an instance of its parent type ‘T’ + • In the definition of data constructor ‘MkT’ + In the newtype declaration for ‘T’ ===================================== testsuite/tests/typecheck/should_fail/T18357a.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE PolyKinds, UnliftedNewtypes, StandaloneKindSignatures, TypeFamilies, GADTs, DataKinds #-} + +module T18357a where + +import Data.Kind +import GHC.Exts + +newtype T :: TYPE r where + MkT :: Int -> T + ===================================== testsuite/tests/typecheck/should_fail/T18357a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18357a.hs:9:10: error: + • Couldn't match kind ‘r’ with ‘'LiftedRep’ + Expected a type, but ‘Int’ has kind ‘*’ + • In the type ‘Int’ + In the definition of data constructor ‘MkT’ + In the newtype declaration for ‘T’ ===================================== testsuite/tests/typecheck/should_fail/T18357b.hs ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE UnliftedNewtypes, StandaloneKindSignatures, TypeFamilies, GADTs, DataKinds #-} + +module T18357b where + +import Data.Kind + +type family Star where Star = Type + +newtype T :: Type where + MkT :: Int -> (T :: Star) + +-- The error message is pretty terrible +-- but it probably nevery happens in practice ===================================== testsuite/tests/typecheck/should_fail/T18357b.stderr ===================================== @@ -0,0 +1,6 @@ + +T18357b.hs:10:3: error: + • Data constructor ‘MkT’ returns type ‘T’ + instead of an instance of its parent type ‘T’ + • In the definition of data constructor ‘MkT’ + In the newtype declaration for ‘T’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -575,3 +575,6 @@ test('ExplicitSpecificity7', normal, compile_fail, ['']) test('ExplicitSpecificity8', normal, compile_fail, ['']) test('ExplicitSpecificity9', normal, compile_fail, ['']) test('ExplicitSpecificity10', normal, compile_fail, ['']) +test('T18357', normal, compile_fail, ['']) +test('T18357a', normal, compile_fail, ['']) +test('T18357b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bf18646acbb5a59ad8716aedc32acfe2ead0f58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bf18646acbb5a59ad8716aedc32acfe2ead0f58 You're receiving 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 Jul 3 14:06:13 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 03 Jul 2020 10:06:13 -0400 Subject: [Git][ghc/ghc][wip/T18341] 7 commits: Add regression test for #18341 Message-ID: <5eff3b55b05f7_80b10c9858c1575943@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18341 at Glasgow Haskell Compiler / GHC Commits: b5848d19 by Sebastian Graf at 2020-07-02T16:06:13+02:00 Add regression test for #18341 - - - - - 65cfd0cd by Sebastian Graf at 2020-07-02T16:09:34+02:00 Add regression test for #17725 - - - - - 9cc7c0e7 by Sebastian Graf at 2020-07-02T16:37:03+02:00 Add regression test for #17378 - - - - - 1555fcbd by Sebastian Graf at 2020-07-02T17:14:48+02:00 Add regression test for #10183 - - - - - a275c6f1 by Sebastian Graf at 2020-07-02T17:16:15+02:00 Add regression test for #17729 - - - - - a3fe3572 by Sebastian Graf at 2020-07-02T17:29:41+02:00 Add regression test for fixed #18273 - - - - - 6f30cf6b by Sebastian Graf at 2020-07-03T16:06:06+02:00 Refactor ensureInhabited and resolve a scoping bug from the previous refactor - - - - - 12 changed files: - compiler/GHC/HsToCore/PmCheck.hs - compiler/GHC/HsToCore/PmCheck/Oracle.hs - + testsuite/tests/pmcheck/should_compile/T10183.hs - + testsuite/tests/pmcheck/should_compile/T17378.hs - + testsuite/tests/pmcheck/should_compile/T17725.hs - + testsuite/tests/pmcheck/should_compile/T17725.stderr - + testsuite/tests/pmcheck/should_compile/T17729.hs - + testsuite/tests/pmcheck/should_compile/T17729.stderr - + testsuite/tests/pmcheck/should_compile/T18273.hs - + testsuite/tests/pmcheck/should_compile/T18341.hs - + testsuite/tests/pmcheck/should_compile/T18341.stderr - testsuite/tests/pmcheck/should_compile/all.T Changes: ===================================== compiler/GHC/HsToCore/PmCheck.hs ===================================== @@ -1005,8 +1005,8 @@ checkGrdTree' (Guard (PmBang x) tree) deltas = do checkGrdTree' (Guard (PmCon x con tvs dicts args) tree) deltas = do unc_this <- addPmCtDeltas deltas (PmNotConCt x con) let cts = pmConCts x con tvs dicts args - tracePm "check:Con" (ppr cts) deltas' <- addPmCtsDeltas deltas cts + tracePm "check:Con" (ppr cts) CheckResult tree' unc_inner prec <- checkGrdTree' tree deltas' limit <- maxPmCheckModels <$> getDynFlags let (prec', unc') = throttle limit deltas (unc_this Semi.<> unc_inner) @@ -1018,6 +1018,7 @@ checkGrdTree' (Guard (PmCon x con tvs dicts args) tree) deltas = do checkGrdTree' (Sequence l r) unc_0 = do tracePm "check:Sequence:l" (ppr l) CheckResult l' unc_1 prec_l <- checkGrdTree' l unc_0 + tracePm "check:Sequence:r" (ppr r) CheckResult r' unc_2 prec_r <- checkGrdTree' r unc_1 pure CheckResult { cr_clauses = SequenceAnn l' r' ===================================== compiler/GHC/HsToCore/PmCheck/Oracle.hs ===================================== @@ -1015,42 +1015,44 @@ ensureInhabited :: Delta -> VarInfo -> DsM (Maybe VarInfo) -- NB: Does /not/ filter each ConLikeSet with the oracle; members may -- remain that do not statisfy it. This lazy approach just -- avoids doing unnecessary work. -ensureInhabited _ vi at VI{ vi_bot = Nothing } = pure (Just vi) -ensureInhabited _ vi at VI{ vi_bot = Just True } = pure (Just vi) -ensureInhabited delta vi = do - vi <- initPossibleMatches (delta_ty_st delta) vi - fmap (set_cache vi) <$> test (vi_cache vi) +ensureInhabited delta vi = case vi_bot vi of + Nothing -> pure (Just vi) -- The |-Bot rule from the paper + Just True -> pure (Just vi) + Just False -> initPossibleMatches (delta_ty_st delta) vi >>= inst_complete_sets where - set_cache vi cache = vi { vi_cache = cache } - - test NoPM = pure (Just NoPM) - test (PM ms) = runMaybeT (PM <$> traverse one_set ms) - - one_set cs = find_one_inh cs (uniqDSetToList cs) - - find_one_inh :: ConLikeSet -> [ConLike] -> MaybeT DsM ConLikeSet - -- (find_one_inh cs cls) iterates over cls, deleting from cs + -- | This is the |-Inst rule from the paper (section 4.5). Tries to + -- find an inhabitant in every complete set by instantiating with one their + -- constructors. If there is any complete set where we can't find an + -- inhabitant, the whole thing is uninhabited. + inst_complete_sets :: VarInfo -> DsM (Maybe VarInfo) + inst_complete_sets vi at VI{ vi_cache = NoPM } = pure (Just vi) + inst_complete_sets vi at VI{ vi_cache = PM ms } = runMaybeT $ do + ms <- traverse (\cs -> inst_complete_set vi cs (uniqDSetToList cs)) ms + pure vi{ vi_cache = PM ms } + + inst_complete_set :: VarInfo -> ConLikeSet -> [ConLike] -> MaybeT DsM ConLikeSet + -- (inst_complete_set cs cls) iterates over cls, deleting from cs -- any uninhabited elements of cls. Stop (returning Just cs) -- when you see an inhabited element; return Nothing if all -- are uninhabited - find_one_inh _ [] = mzero - find_one_inh cs (con:cons) = lift (inh_test con) >>= \case + inst_complete_set _ _ [] = mzero + inst_complete_set vi cs (con:cons) = lift (inst_and_test vi con) >>= \case True -> pure cs - False -> find_one_inh (delOneFromUniqDSet cs con) cons + False -> inst_complete_set vi (delOneFromUniqDSet cs con) cons - inh_test :: ConLike -> DsM Bool - -- @inh_test K@ Returns False if a non-bottom value @v::ty@ cannot possibly + inst_and_test :: VarInfo -> ConLike -> DsM Bool + -- @inst_and_test K@ Returns False if a non-bottom value @v::ty@ cannot possibly -- be of form @K _ _ _ at . Returning True is always sound. -- -- It's like 'DataCon.dataConCannotMatch', but more clever because it takes -- the facts in Delta into account. - inh_test con = do + inst_and_test vi con = do env <- dsGetFamInstEnvs case guessConLikeUnivTyArgsFromResTy env (vi_ty vi) con of Nothing -> pure True -- be conservative about this Just arg_tys -> do (_tvs, _vars, ty_cs, strict_arg_tys) <- mkOneConFull arg_tys con - tracePm "inh_test" (ppr con $$ ppr ty_cs) + tracePm "inst_and_test" (ppr con $$ ppr ty_cs) -- No need to run the term oracle compared to pmIsSatisfiable fmap isJust <$> runSatisfiabilityCheck delta $ mconcat -- Important to pass False to tyIsSatisfiable here, so that we won't ===================================== testsuite/tests/pmcheck/should_compile/T10183.hs ===================================== @@ -0,0 +1,22 @@ +{-# LANGUAGE GADTs, DataKinds, TypeOperators, UnicodeSyntax #-} + +module Foo where + +import GHC.TypeLits + +data List l t where + Nil ∷ List 0 t + (:-) ∷ t → List l t → List (l+1) t + +head' ∷ (1<=l) ⇒ List l t → t +head' (x :- _) = x + +data T a where + TT :: T Bool + TF :: T Int + +f :: T Bool -> Bool +f TT = True + +g :: (a ~ Bool) => T a -> Bool +g TT = True ===================================== testsuite/tests/pmcheck/should_compile/T17378.hs ===================================== @@ -0,0 +1,30 @@ +{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE EmptyCase #-} +module Lib where + +import Data.Type.Equality +import Data.Functor.Identity +import Data.Void + +f :: a :~: Int -> a :~: Bool -> () +f !_ x = case x of {} + +g :: Identity (a :~: Int) -> a :~: Bool -> () +g (Identity _) Refl = () + +data SMaybe a = SNothing + | SJust !a + +-- | Exhaustive. Note how in addition to @{(a,b) | b /~ True}@, the value set +-- @{(a,b) | y /~ SNothing, b ~ True}@ flows into the next equation, but @y@ is +-- no longer in scope. Normally, we have no way of matching on that without a +-- wildcard match, but in this case we refute @y ~ SJust z@ by unleashing type +-- evidence saying that @z@ must be 'Void' by matching on 'Void'. +h :: forall a. a :~: Void -> Bool -> () +h _ True | let y = undefined :: SMaybe a, SNothing <- y = () +h Refl False = () ===================================== testsuite/tests/pmcheck/should_compile/T17725.hs ===================================== @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-} +{-# LANGUAGE BangPatterns #-} +module Lib where + +newtype IInt = IInt Int + +f :: IInt -> Bool -> () +f !(IInt _) True = () +f (IInt 42) True = () +f _ _ = () ===================================== testsuite/tests/pmcheck/should_compile/T17725.stderr ===================================== @@ -0,0 +1,4 @@ + +T17725.hs:9:1: warning: [-Woverlapping-patterns (in -Wdefault)] + Pattern match is redundant + In an equation for ‘f’: f (IInt 42) True = ... ===================================== testsuite/tests/pmcheck/should_compile/T17729.hs ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE PatternSynonyms #-} +{-# OPTIONS_GHC -fforce-recomp -Wincomplete-patterns #-} + +incomplete :: Maybe a -> Bool +incomplete ma = case (ma, ()) of + (Nothing, _) -> False + +{-# COMPLETE Pat #-} +pattern Pat :: a -> b -> (a, b) +pattern Pat a b = (a, b) + +main :: IO () +main = print $ incomplete (Just ()) ===================================== testsuite/tests/pmcheck/should_compile/T17729.stderr ===================================== @@ -0,0 +1,4 @@ + +T17729.hs:5:17: warning: [-Wincomplete-patterns (in -Wextra)] + Pattern match(es) are non-exhaustive + In a case alternative: Patterns not matched: ((Just _), ()) ===================================== testsuite/tests/pmcheck/should_compile/T18273.hs ===================================== @@ -0,0 +1,41 @@ +{-# OPTIONS_GHC -fforce-recomp -Wincomplete-patterns #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE EmptyCase #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE TypeFamilies #-} + +module Bug where + +import Data.Kind +import Data.Void + +type SFalse = SBool 'False +type STrue = SBool 'True + +data SBool :: Bool -> Type where + SFalse :: SFalse + STrue :: STrue + +type family F (b :: Bool) :: Type where + F 'False = Void + F 'True = () + +data T (b :: Bool) + = MkT1 + | MkT2 !(F b) + +ex :: SBool b -> T b -> () +ex sb t = + case t of + MkT1 -> () + MkT2 f -> + case sb of + STrue -> f + +ex2 :: SBool b -> T b -> () +ex2 sb t = + case t of + MkT2 f -> + case sb of + STrue -> f + MkT1 -> () ===================================== testsuite/tests/pmcheck/should_compile/T18341.hs ===================================== @@ -0,0 +1,24 @@ +{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE MagicHash #-} + +module Lib where + +import GHC.Exts + +data T = MkT !Int {-# UNPACK #-} !Int Int# + +f :: T -> () +f (MkT _ _ _) | False = () -- inaccessible +f (MkT !_ _ _) | False = () -- redundant, not only inaccessible! +f _ = () + +g :: T -> () +g (MkT _ _ _) | False = () -- inaccessible +g (MkT _ !_ _) | False = () -- redundant, not only inaccessible! +g _ = () + +h :: T -> () +h (MkT _ _ _) | False = () -- inaccessible +h (MkT _ _ !_) | False = () -- redundant, not only inaccessible! +h _ = () ===================================== testsuite/tests/pmcheck/should_compile/T18341.stderr ===================================== @@ -0,0 +1,24 @@ + +T18341.hs:12:18: warning: [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘f’: f (MkT _ _ _) | False = ... + +T18341.hs:13:18: warning: [-Woverlapping-patterns (in -Wdefault)] + Pattern match is redundant + In an equation for ‘f’: f (MkT !_ _ _) | False = ... + +T18341.hs:17:18: warning: [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘g’: g (MkT _ _ _) | False = ... + +T18341.hs:18:18: warning: [-Woverlapping-patterns (in -Wdefault)] + Pattern match is redundant + In an equation for ‘g’: g (MkT _ !_ _) | False = ... + +T18341.hs:22:18: warning: [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘h’: h (MkT _ _ _) | False = ... + +T18341.hs:23:18: warning: [-Woverlapping-patterns (in -Wdefault)] + Pattern match is redundant + In an equation for ‘h’: h (MkT _ _ !_) | False = ... ===================================== testsuite/tests/pmcheck/should_compile/all.T ===================================== @@ -36,6 +36,8 @@ test('T9951b', [], compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T9951', [], compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T10183', [], compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T11303', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns +RTS -M1G -RTS']) test('T11276', collect_compiler_stats('bytes allocated',10), compile, @@ -106,12 +108,18 @@ test('T17357', expect_broken(17357), compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T17376', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T17378', normal, compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T17465', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T17646', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T17703', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T17725', normal, compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T17729', normal, compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T17783', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T17977', collect_compiler_stats('bytes allocated',10), compile, @@ -120,6 +128,10 @@ test('T17977b', collect_compiler_stats('bytes allocated',10), compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T18049', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T18273', normal, compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T18341', normal, compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) # Other tests test('pmc001', [], compile, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d1888d46e4cbb27f7d0a3ba89bf4f69bfc5776f0...6f30cf6b606dbf0e5eeee8106ae3155e5d494670 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d1888d46e4cbb27f7d0a3ba89bf4f69bfc5776f0...6f30cf6b606dbf0e5eeee8106ae3155e5d494670 You're receiving 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 Jul 3 14:23:19 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 03 Jul 2020 10:23:19 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: rts/ProfHeap: Only allocate the Censuses that we need Message-ID: <5eff3f5734494_80bf00fa8c1576537@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 64414d73 by Sylvain Henry at 2020-07-03T10:23:15-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 6e5ff48b by Hécate at 2020-07-03T10:23:17-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - 30 changed files: - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Driver.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Instantiate.hs - docs/core-spec/CoreLint.ott - docs/core-spec/CoreSyn.ott - docs/core-spec/core-spec.mng - docs/core-spec/core-spec.pdf - docs/users_guide/phases.rst - docs/users_guide/using-warnings.rst - hadrian/src/Rules/Generate.hs - includes/ghc.mk - rts/ProfHeap.c - + testsuite/tests/driver/FullGHCVersion.hs - + testsuite/tests/driver/FullGHCVersion.stdout - 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/9e8fa44adaaad66eb95ffbb5aa74f0c768d7134b...6e5ff48b4b9589de55161048092ae155c9c451c0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e8fa44adaaad66eb95ffbb5aa74f0c768d7134b...6e5ff48b4b9589de55161048092ae155c9c451c0 You're receiving 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 Jul 3 16:32:45 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 03 Jul 2020 12:32:45 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/mono-local-binds Message-ID: <5eff5dad94b9a_80b3f8490382cec1610535@gitlab.haskell.org.mail> Sebastian Graf pushed new branch wip/mono-local-binds at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/mono-local-binds You're receiving 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 Jul 3 19:36:01 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 03 Jul 2020 15:36:01 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/winio Message-ID: <5eff88a147595_80b11160f3816532b@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/winio at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/winio You're receiving 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 Jul 3 21:33:34 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 03 Jul 2020 17:33:34 -0400 Subject: [Git][ghc/ghc][master] Improve handling of data type return kinds Message-ID: <5effa42eedd63_80b3f8469a404841671327@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 28 changed files: - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Instantiate.hs - docs/core-spec/CoreLint.ott - docs/core-spec/CoreSyn.ott - docs/core-spec/core-spec.mng - docs/core-spec/core-spec.pdf - + testsuite/tests/polykinds/T18300.hs - + testsuite/tests/polykinds/T18300.stderr - testsuite/tests/polykinds/all.T - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T18357.hs - + testsuite/tests/typecheck/should_fail/T18357.stderr - + testsuite/tests/typecheck/should_fail/T18357a.hs - + testsuite/tests/typecheck/should_fail/T18357a.stderr - + testsuite/tests/typecheck/should_fail/T18357b.hs - + testsuite/tests/typecheck/should_fail/T18357b.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Core/Coercion/Axiom.hs ===================================== @@ -184,9 +184,10 @@ Note [Storing compatibility] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ During axiom application, we need to be aware of which branches are compatible with which others. The full explanation is in Note [Compatibility] in -FamInstEnv. (The code is placed there to avoid a dependency from CoAxiom on -the unification algorithm.) Although we could theoretically compute -compatibility on the fly, this is silly, so we store it in a CoAxiom. +GHc.Core.FamInstEnv. (The code is placed there to avoid a dependency from +GHC.Core.Coercion.Axiom on the unification algorithm.) Although we could +theoretically compute compatibility on the fly, this is silly, so we store it +in a CoAxiom. Specifically, each branch refers to all other branches with which it is incompatible. This list might well be empty, and it will always be for the @@ -233,8 +234,8 @@ data CoAxBranch { cab_loc :: SrcSpan -- Location of the defining equation -- See Note [CoAxiom locations] , cab_tvs :: [TyVar] -- Bound type variables; not necessarily fresh - , cab_eta_tvs :: [TyVar] -- Eta-reduced tyvars -- See Note [CoAxBranch type variables] + , cab_eta_tvs :: [TyVar] -- Eta-reduced tyvars -- cab_tvs and cab_lhs may be eta-reduced; see -- Note [Eta reduction for data families] , cab_cvs :: [CoVar] -- Bound coercion variables ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -425,7 +425,7 @@ data DataCon -- NB: for a data instance, the original user result type may -- differ from the DataCon's representation TyCon. Example -- data instance T [a] where MkT :: a -> T [a] - -- The OrigResTy is T [a], but the dcRepTyCon might be :T123 + -- The dcOrigResTy is T [a], but the dcRepTyCon might be R:TList -- Now the strictness annotations and field labels of the constructor dcSrcBangs :: [HsSrcBang], @@ -1576,4 +1576,3 @@ splitDataProductType_maybe ty = Just (tycon, ty_args, con, dataConInstArgTys con ty_args) | otherwise = Nothing - ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -640,16 +640,13 @@ that Note. mkCoAxBranch :: [TyVar] -- original, possibly stale, tyvars -> [TyVar] -- Extra eta tyvars -> [CoVar] -- possibly stale covars - -> TyCon -- family/newtype TyCon (for error-checking only) -> [Type] -- LHS patterns -> Type -- RHS -> [Role] -> SrcSpan -> CoAxBranch -mkCoAxBranch tvs eta_tvs cvs ax_tc lhs rhs roles loc - = -- See Note [CoAxioms are homogeneous] in "GHC.Core.Coercion.Axiom" - ASSERT( typeKind (mkTyConApp ax_tc lhs) `eqType` typeKind rhs ) - CoAxBranch { cab_tvs = tvs' +mkCoAxBranch tvs eta_tvs cvs lhs rhs roles loc + = CoAxBranch { cab_tvs = tvs' , cab_eta_tvs = eta_tvs' , cab_cvs = cvs' , cab_lhs = tidyTypes env lhs @@ -703,7 +700,7 @@ mkSingleCoAxiom role ax_name tvs eta_tvs cvs fam_tc lhs_tys rhs_ty , co_ax_implicit = False , co_ax_branches = unbranched (branch { cab_incomps = [] }) } where - branch = mkCoAxBranch tvs eta_tvs cvs fam_tc lhs_tys rhs_ty + branch = mkCoAxBranch tvs eta_tvs cvs lhs_tys rhs_ty (map (const Nominal) tvs) (getSrcSpan ax_name) @@ -721,7 +718,7 @@ mkNewTypeCoAxiom name tycon tvs roles rhs_ty , co_ax_tc = tycon , co_ax_branches = unbranched (branch { cab_incomps = [] }) } where - branch = mkCoAxBranch tvs [] [] tycon (mkTyVarTys tvs) rhs_ty + branch = mkCoAxBranch tvs [] [] (mkTyVarTys tvs) rhs_ty roles (getSrcSpan name) {- ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -8,13 +8,12 @@ See Note [Core Lint guarantee]. -} {-# LANGUAGE CPP #-} -{-# LANGUAGE ViewPatterns #-} -{-# LANGUAGE ScopedTypeVariables, DeriveFunctor #-} +{-# LANGUAGE ViewPatterns, ScopedTypeVariables, DeriveFunctor, MultiWayIf #-} module GHC.Core.Lint ( lintCoreBindings, lintUnfolding, lintPassResult, lintInteractiveExpr, lintExpr, - lintAnnots, lintTypes, + lintAnnots, lintAxioms, -- ** Debug output endPass, endPassIO, @@ -36,7 +35,7 @@ import GHC.Types.Literal import GHC.Core.DataCon import GHC.Builtin.Types.Prim import GHC.Builtin.Types ( multiplicityTy ) -import GHC.Tc.Utils.TcType ( isFloatingTy ) +import GHC.Tc.Utils.TcType ( isFloatingTy, isTyFamFree ) import GHC.Types.Var as Var import GHC.Types.Var.Env import GHC.Types.Var.Set @@ -56,9 +55,10 @@ import GHC.Types.RepType import GHC.Core.TyCo.Rep -- checks validity of types/coercions import GHC.Core.TyCo.Subst import GHC.Core.TyCo.FVs -import GHC.Core.TyCo.Ppr ( pprTyVar ) +import GHC.Core.TyCo.Ppr ( pprTyVar, pprTyVars ) import GHC.Core.TyCon as TyCon import GHC.Core.Coercion.Axiom +import GHC.Core.Unify import GHC.Types.Basic import GHC.Utils.Error as Err import GHC.Data.List.SetOps @@ -76,7 +76,7 @@ import GHC.Driver.Session import Control.Monad import GHC.Utils.Monad import Data.Foldable ( toList ) -import Data.List.NonEmpty ( NonEmpty ) +import Data.List.NonEmpty ( NonEmpty(..), groupWith ) import Data.List ( partition ) import Data.Maybe import GHC.Data.Pair @@ -1587,18 +1587,6 @@ lintIdBndr top_lvl bind_site id thing_inside %************************************************************************ -} -lintTypes :: DynFlags - -> [TyCoVar] -- Treat these as in scope - -> [Type] - -> Maybe MsgDoc -- Nothing => OK -lintTypes dflags vars tys - | isEmptyBag errs = Nothing - | otherwise = Just (pprMessageBag errs) - where - (_warns, errs) = initL dflags (defaultLintFlags dflags) vars linter - linter = lintBinders LambdaBind vars $ \_ -> - mapM_ lintType tys - lintValueType :: Type -> LintM LintedType -- Types only, not kinds -- Check the type, and apply the substitution to it @@ -1617,7 +1605,7 @@ checkTyCon tc = checkL (not (isTcTyCon tc)) (text "Found TcTyCon:" <+> ppr tc) ------------------- -lintType :: LintedType -> LintM LintedType +lintType :: Type -> LintM LintedType -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] @@ -2342,6 +2330,175 @@ lintCoercion (HoleCo h) = do { addErrL $ text "Unfilled coercion hole:" <+> ppr h ; lintCoercion (CoVarCo (coHoleCoVar h)) } +{- +************************************************************************ +* * + Axioms +* * +************************************************************************ +-} + +lintAxioms :: DynFlags + -> [CoAxiom Branched] + -> WarnsAndErrs +lintAxioms dflags axioms + = initL dflags (defaultLintFlags dflags) [] $ + do { mapM_ lint_axiom axioms + ; let axiom_groups = groupWith coAxiomTyCon axioms + ; mapM_ lint_axiom_group axiom_groups } + +lint_axiom :: CoAxiom Branched -> LintM () +lint_axiom ax@(CoAxiom { co_ax_tc = tc, co_ax_branches = branches + , co_ax_role = ax_role }) + = addLoc (InAxiom ax) $ + do { mapM_ (lint_branch tc) branch_list + ; extra_checks } + where + branch_list = fromBranches branches + + extra_checks + | isNewTyCon tc + = do { CoAxBranch { cab_tvs = tvs + , cab_eta_tvs = eta_tvs + , cab_cvs = cvs + , cab_roles = roles + , cab_lhs = lhs_tys } + <- case branch_list of + [branch] -> return branch + _ -> failWithL (text "multi-branch axiom with newtype") + ; let ax_lhs = mkInfForAllTys tvs $ + mkTyConApp tc lhs_tys + nt_tvs = takeList tvs (tyConTyVars tc) + -- axiom may be eta-reduced: Note [Newtype eta] in GHC.Core.TyCon + nt_lhs = mkInfForAllTys nt_tvs $ + mkTyConApp tc (mkTyVarTys nt_tvs) + -- See Note [Newtype eta] in GHC.Core.TyCon + ; lintL (ax_lhs `eqType` nt_lhs) + (text "Newtype axiom LHS does not match newtype definition") + ; lintL (null cvs) + (text "Newtype axiom binds coercion variables") + ; lintL (null eta_tvs) -- See Note [Eta reduction for data families] + -- which is not about newtype axioms + (text "Newtype axiom has eta-tvs") + ; lintL (ax_role == Representational) + (text "Newtype axiom role not representational") + ; lintL (roles `equalLength` tvs) + (text "Newtype axiom roles list is the wrong length." $$ + text "roles:" <+> sep (map ppr roles)) + ; lintL (roles == takeList roles (tyConRoles tc)) + (vcat [ text "Newtype axiom roles do not match newtype tycon's." + , text "axiom roles:" <+> sep (map ppr roles) + , text "tycon roles:" <+> sep (map ppr (tyConRoles tc)) ]) + } + + | isFamilyTyCon tc + = do { if | isTypeFamilyTyCon tc + -> lintL (ax_role == Nominal) + (text "type family axiom is not nominal") + + | isDataFamilyTyCon tc + -> lintL (ax_role == Representational) + (text "data family axiom is not representational") + + | otherwise + -> addErrL (text "A family TyCon is neither a type family nor a data family:" <+> ppr tc) + + ; mapM_ (lint_family_branch tc) branch_list } + + | otherwise + = addErrL (text "Axiom tycon is neither a newtype nor a family.") + +lint_branch :: TyCon -> CoAxBranch -> LintM () +lint_branch ax_tc (CoAxBranch { cab_tvs = tvs, cab_cvs = cvs + , cab_lhs = lhs_args, cab_rhs = rhs }) + = lintBinders LambdaBind (tvs ++ cvs) $ \_ -> + do { let lhs = mkTyConApp ax_tc lhs_args + ; lhs' <- lintType lhs + ; rhs' <- lintType rhs + ; let lhs_kind = typeKind lhs' + rhs_kind = typeKind rhs' + ; lintL (lhs_kind `eqType` rhs_kind) $ + hang (text "Inhomogeneous axiom") + 2 (text "lhs:" <+> ppr lhs <+> dcolon <+> ppr lhs_kind $$ + text "rhs:" <+> ppr rhs <+> dcolon <+> ppr rhs_kind) } + +-- these checks do not apply to newtype axioms +lint_family_branch :: TyCon -> CoAxBranch -> LintM () +lint_family_branch fam_tc br@(CoAxBranch { cab_tvs = tvs + , cab_eta_tvs = eta_tvs + , cab_cvs = cvs + , cab_roles = roles + , cab_lhs = lhs + , cab_incomps = incomps }) + = do { lintL (isDataFamilyTyCon fam_tc || null eta_tvs) + (text "Type family axiom has eta-tvs") + ; lintL (all (`elemVarSet` tyCoVarsOfTypes lhs) tvs) + (text "Quantified variable in family axiom unused in LHS") + ; lintL (all isTyFamFree lhs) + (text "Type family application on LHS of family axiom") + ; lintL (all (== Nominal) roles) + (text "Non-nominal role in family axiom" $$ + text "roles:" <+> sep (map ppr roles)) + ; lintL (null cvs) + (text "Coercion variables bound in family axiom") + ; forM_ incomps $ \ br' -> + lintL (not (compatible_branches br br')) $ + text "Incorrect incompatible branch:" <+> ppr br' } + +lint_axiom_group :: NonEmpty (CoAxiom Branched) -> LintM () +lint_axiom_group (_ :| []) = return () +lint_axiom_group (ax :| axs) + = do { lintL (isOpenFamilyTyCon tc) + (text "Non-open-family with multiple axioms") + ; let all_pairs = [ (ax1, ax2) | ax1 <- all_axs + , ax2 <- all_axs ] + ; mapM_ (lint_axiom_pair tc) all_pairs } + where + all_axs = ax : axs + tc = coAxiomTyCon ax + +lint_axiom_pair :: TyCon -> (CoAxiom Branched, CoAxiom Branched) -> LintM () +lint_axiom_pair tc (ax1, ax2) + | Just br1@(CoAxBranch { cab_tvs = tvs1 + , cab_lhs = lhs1 + , cab_rhs = rhs1 }) <- coAxiomSingleBranch_maybe ax1 + , Just br2@(CoAxBranch { cab_tvs = tvs2 + , cab_lhs = lhs2 + , cab_rhs = rhs2 }) <- coAxiomSingleBranch_maybe ax2 + = lintL (compatible_branches br1 br2) $ + vcat [ hsep [ text "Axioms", ppr ax1, text "and", ppr ax2 + , text "are incompatible" ] + , text "tvs1 =" <+> pprTyVars tvs1 + , text "lhs1 =" <+> ppr (mkTyConApp tc lhs1) + , text "rhs1 =" <+> ppr rhs1 + , text "tvs2 =" <+> pprTyVars tvs2 + , text "lhs2 =" <+> ppr (mkTyConApp tc lhs2) + , text "rhs2 =" <+> ppr rhs2 ] + + | otherwise + = addErrL (text "Open type family axiom has more than one branch: either" <+> + ppr ax1 <+> text "or" <+> ppr ax2) + +compatible_branches :: CoAxBranch -> CoAxBranch -> Bool +-- True <=> branches are compatible. See Note [Compatibility] in GHC.Core.FamInstEnv. +compatible_branches (CoAxBranch { cab_tvs = tvs1 + , cab_lhs = lhs1 + , cab_rhs = rhs1 }) + (CoAxBranch { cab_tvs = tvs2 + , cab_lhs = lhs2 + , cab_rhs = rhs2 }) + = -- we need to freshen ax2 w.r.t. ax1 + -- do this by pretending tvs1 are in scope when processing tvs2 + let in_scope = mkInScopeSet (mkVarSet tvs1) + subst0 = mkEmptyTCvSubst in_scope + (subst, _) = substTyVarBndrs subst0 tvs2 + lhs2' = substTys subst lhs2 + rhs2' = substTy subst rhs2 + in + case tcUnifyTys (const BindMe) lhs1 lhs2' of + Just unifying_subst -> substTy unifying_subst rhs1 `eqType` + substTy unifying_subst rhs2' + Nothing -> True {- ************************************************************************ @@ -2539,6 +2696,7 @@ data LintLocInfo | TopLevelBindings | InType Type -- Inside a type | InCo Coercion -- Inside a coercion + | InAxiom (CoAxiom Branched) -- Inside a CoAxiom initL :: DynFlags -> LintFlags -> [Var] -> LintM a -> WarnsAndErrs -- Warnings and errors @@ -2822,6 +2980,34 @@ dumpLoc (InType ty) = (noSrcLoc, text "In the type" <+> quotes (ppr ty)) dumpLoc (InCo co) = (noSrcLoc, text "In the coercion" <+> quotes (ppr co)) +dumpLoc (InAxiom ax) + = (getSrcLoc ax_name, text "In the coercion axiom" <+> ppr ax_name <+> dcolon <+> pp_ax) + where + CoAxiom { co_ax_name = ax_name + , co_ax_tc = tc + , co_ax_role = ax_role + , co_ax_branches = branches } = ax + branch_list = fromBranches branches + + pp_ax + | [branch] <- branch_list + = pp_branch branch + + | otherwise + = braces $ vcat (map pp_branch branch_list) + + pp_branch (CoAxBranch { cab_tvs = tvs + , cab_cvs = cvs + , cab_lhs = lhs_tys + , cab_rhs = rhs_ty }) + = sep [ brackets (pprWithCommas pprTyVar (tvs ++ cvs)) <> dot + , ppr (mkTyConApp tc lhs_tys) + , text "~_" <> pp_role ax_role + , ppr rhs_ty ] + + pp_role Nominal = text "N" + pp_role Representational = text "R" + pp_role Phantom = text "P" pp_binders :: [Var] -> SDoc pp_binders bs = sep (punctuate comma (map pp_binder bs)) ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -293,7 +293,14 @@ See also Note [Wrappers for data instance tycons] in GHC.Types.Id.Make Indeed the latter type is unknown to the programmer. - There *is* an instance for (T Int) in the type-family instance - environment, but it is only used for overlap checking + environment, but it is looked up (via tcLookupDataFamilyInst) + in can_eq_nc (via tcTopNormaliseNewTypeTF_maybe) when trying to + solve representational equalities like + T Int ~R# Bool + Here we look up (T Int), convert it to R:TInt, and then unwrap the + newtype R:TInt. + + It is also looked up in reduceTyFamApp_maybe. - It's fine to have T in the LHS of a type function: type instance F (T a) = [a] @@ -1251,34 +1258,21 @@ example, newtype T a = MkT (a -> a) -the NewTyCon for T will contain nt_co = CoT where CoT t : T t ~ t -> t. - -In the case that the right hand side is a type application -ending with the same type variables as the left hand side, we -"eta-contract" the coercion. So if we had - - newtype S a = MkT [a] - -then we would generate the arity 0 axiom CoS : S ~ []. The -primary reason we do this is to make newtype deriving cleaner. +the NewTyCon for T will contain nt_co = CoT where CoT :: forall a. T a ~ a -> a. -In the paper we'd write - axiom CoT : (forall t. T t) ~ (forall t. [t]) -and then when we used CoT at a particular type, s, we'd say - CoT @ s -which encodes as (TyConApp instCoercionTyCon [TyConApp CoT [], s]) +We might also eta-contract the axiom: see Note [Newtype eta]. Note [Newtype eta] ~~~~~~~~~~~~~~~~~~ Consider newtype Parser a = MkParser (IO a) deriving Monad -Are these two types equal (to Core)? +Are these two types equal (that is, does a coercion exist between them)? Monad Parser Monad IO which we need to make the derived instance for Monad Parser. Well, yes. But to see that easily we eta-reduce the RHS type of -Parser, in this case to ([], Froogle), so that even unsaturated applications +Parser, in this case to IO, so that even unsaturated applications of Parser will work right. This eta reduction is done when the type constructor is built, and cached in NewTyCon. ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -70,7 +70,6 @@ module GHC.Core.Type ( getRuntimeRep_maybe, kindRep_maybe, kindRep, mkCastTy, mkCoercionTy, splitCastTy_maybe, - discardCast, userTypeError_maybe, pprUserTypeErrorTy, @@ -1402,20 +1401,6 @@ tyConBindersTyCoBinders = map to_tyb to_tyb (Bndr tv (NamedTCB vis)) = Named (Bndr tv vis) to_tyb (Bndr tv (AnonTCB af)) = Anon af (tymult (varType tv)) --- | Drop the cast on a type, if any. If there is no --- cast, just return the original type. This is rarely what --- you want. The CastTy data constructor (in "GHC.Core.TyCo.Rep") has the --- invariant that another CastTy is not inside. See the --- data constructor for a full description of this invariant. --- Since CastTy cannot be nested, the result of discardCast --- cannot be a CastTy. -discardCast :: Type -> Type -discardCast (CastTy ty _) = ASSERT(not (isCastTy ty)) ty - where - isCastTy CastTy{} = True - isCastTy _ = False -discardCast ty = ty - {- -------------------------------------------------------------------- ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -46,7 +46,8 @@ module GHC.Tc.Gen.HsType ( tcNamedWildCardBinders, tcHsLiftedType, tcHsOpenType, tcHsLiftedTypeNC, tcHsOpenTypeNC, - tcInferLHsType, tcInferLHsTypeUnsaturated, tcCheckLHsType, + tcInferLHsTypeKind, tcInferLHsType, tcInferLHsTypeUnsaturated, + tcCheckLHsType, tcHsMbContext, tcHsContext, tcLHsPredType, failIfEmitsConstraints, solveEqualities, -- useful re-export @@ -77,6 +78,7 @@ import GHC.Tc.Types.Origin import GHC.Core.Predicate import GHC.Tc.Types.Constraint import GHC.Tc.Utils.Env +import GHC.Tc.Utils.Instantiate( tcInstInvisibleTyBinders ) import GHC.Tc.Utils.TcMType import GHC.Tc.Validity import GHC.Tc.Utils.Unify @@ -87,7 +89,7 @@ import GHC.Core.TyCo.Rep import GHC.Core.TyCo.Ppr import GHC.Tc.Errors ( reportAllUnsolved ) import GHC.Tc.Utils.TcType -import GHC.Tc.Utils.Instantiate ( tcInstInvisibleTyBinders, tcInstInvisibleTyBinder ) +import GHC.Tc.Utils.Instantiate ( tcInstInvisibleTyBindersN, tcInstInvisibleTyBinder ) import GHC.Core.Type import GHC.Builtin.Types.Prim import GHC.Types.Name.Env @@ -617,12 +619,11 @@ tcHsOpenType, tcHsLiftedType, tcHsOpenTypeNC, tcHsLiftedTypeNC :: LHsType GhcRn -> TcM TcType -- Used for type signatures -- Do not do validity checking -tcHsOpenType ty = addTypeCtxt ty $ tcHsOpenTypeNC ty -tcHsLiftedType ty = addTypeCtxt ty $ tcHsLiftedTypeNC ty +tcHsOpenType hs_ty = addTypeCtxt hs_ty $ tcHsOpenTypeNC hs_ty +tcHsLiftedType hs_ty = addTypeCtxt hs_ty $ tcHsLiftedTypeNC hs_ty -tcHsOpenTypeNC ty = do { ek <- newOpenTypeKind - ; tcLHsType ty ek } -tcHsLiftedTypeNC ty = tcLHsType ty liftedTypeKind +tcHsOpenTypeNC hs_ty = do { ek <- newOpenTypeKind; tcLHsType hs_ty ek } +tcHsLiftedTypeNC hs_ty = tcLHsType hs_ty liftedTypeKind -- Like tcHsType, but takes an expected kind tcCheckLHsType :: LHsType GhcRn -> ContextKind -> TcM TcType @@ -632,15 +633,24 @@ tcCheckLHsType hs_ty exp_kind ; tcLHsType hs_ty ek } tcInferLHsType :: LHsType GhcRn -> TcM TcType --- Called from outside: set the context tcInferLHsType hs_ty - = addTypeCtxt hs_ty $ - do { (ty, _kind) <- tc_infer_lhs_type (mkMode TypeLevel) hs_ty + = do { (ty,_kind) <- tcInferLHsTypeKind hs_ty ; return ty } +tcInferLHsTypeKind :: LHsType GhcRn -> TcM (TcType, TcKind) +-- Called from outside: set the context +-- Eagerly instantiate any trailing invisible binders +tcInferLHsTypeKind lhs_ty@(L loc hs_ty) + = addTypeCtxt lhs_ty $ + setSrcSpan loc $ -- Cover the tcInstInvisibleTyBinders + do { (res_ty, res_kind) <- tc_infer_hs_type (mkMode TypeLevel) hs_ty + ; tcInstInvisibleTyBinders res_ty res_kind } + -- See Note [Do not always instantiate eagerly in types] + -- Used to check the argument of GHCi :kind -- Allow and report wildcards, e.g. :kind T _ -- Do not saturate family applications: see Note [Dealing with :kind] +-- Does not instantiate eagerly; See Note [Do not always instantiate eagerly in types] tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) tcInferLHsTypeUnsaturated hs_ty = addTypeCtxt hs_ty $ @@ -674,6 +684,19 @@ to switch off saturation. So tcInferLHsTypeUnsaturated does a little special case for top level applications. Actually the common case is a bare variable, as above. +Note [Do not always instantiate eagerly in types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Terms are eagerly instantiated. This means that if you say + + x = id + +then `id` gets instantiated to have type alpha -> alpha. The variable +alpha is then unconstrained and regeneralized. But we cannot do this +in types, as we have no type-level lambda. So, when we are sure +that we will not want to regeneralize later -- because we are done +checking a type, for example -- we can instantiate. But we do not +instantiate at variables, nor do we in tcInferLHsTypeUnsaturated, +which is used by :kind in GHCi. ************************************************************************ * * @@ -1648,14 +1671,14 @@ saturateFamApp :: TcType -> TcKind -> TcM (TcType, TcKind) -- tcTypeKind ty = kind -- -- If 'ty' is an unsaturated family application with trailing --- invisible arguments, instanttiate them. +-- invisible arguments, instantiate them. -- See Note [saturateFamApp] saturateFamApp ty kind | Just (tc, args) <- tcSplitTyConApp_maybe ty , mustBeSaturated tc , let n_to_inst = tyConArity tc - length args - = do { (extra_args, ki') <- tcInstInvisibleTyBinders n_to_inst kind + = do { (extra_args, ki') <- tcInstInvisibleTyBindersN n_to_inst kind ; return (ty `mkTcAppTys` extra_args, ki') } | otherwise = return (ty, kind) @@ -1712,7 +1735,7 @@ checkExpectedKind :: HasDebugCallStack checkExpectedKind hs_ty ty act_kind exp_kind = do { traceTc "checkExpectedKind" (ppr ty $$ ppr act_kind) - ; (new_args, act_kind') <- tcInstInvisibleTyBinders n_to_inst act_kind + ; (new_args, act_kind') <- tcInstInvisibleTyBindersN n_to_inst act_kind ; let origin = TypeEqOrigin { uo_actual = act_kind' , uo_expected = exp_kind @@ -1763,6 +1786,7 @@ tc_lhs_pred mode pred = tc_lhs_type mode pred constraintKind tcTyVar :: TcTyMode -> Name -> TcM (TcType, TcKind) -- See Note [Type checking recursive type and class declarations] -- in GHC.Tc.TyCl +-- This does not instantiate. See Note [Do not always instantiate eagerly in types] tcTyVar mode name -- Could be a tyvar, a tycon, or a datacon = do { traceTc "lk1" (ppr name) ; thing <- tcLookup name @@ -3293,12 +3317,18 @@ data DataSort -- 2. @k@ (where @k@ is a bare kind variable; see #12369) -- -- See also Note [Datatype return kinds] in "GHC.Tc.TyCl" -checkDataKindSig :: DataSort -> Kind -> TcM () -checkDataKindSig data_sort kind = do - dflags <- getDynFlags - traceTc "checkDataKindSig" (ppr kind) - checkTc (is_TYPE_or_Type dflags || is_kind_var) (err_msg dflags) +checkDataKindSig :: DataSort -> Kind -- any arguments in the kind are stripped off + -> TcM () +checkDataKindSig data_sort kind + = do { dflags <- getDynFlags + ; traceTc "checkDataKindSig" (ppr kind) + ; checkTc (is_TYPE_or_Type dflags || is_kind_var) + (err_msg dflags) } where + res_kind = snd (tcSplitPiTys kind) + -- Look for the result kind after + -- peeling off any foralls and arrows + pp_dec :: SDoc pp_dec = text $ case data_sort of @@ -3335,16 +3365,19 @@ checkDataKindSig data_sort kind = do -- have return kind `TYPE r` unconditionally (#16827). is_TYPE :: Bool - is_TYPE = tcIsRuntimeTypeKind kind + is_TYPE = tcIsRuntimeTypeKind res_kind + + is_Type :: Bool + is_Type = tcIsLiftedTypeKind res_kind is_TYPE_or_Type :: DynFlags -> Bool is_TYPE_or_Type dflags | tYPE_ok dflags = is_TYPE - | otherwise = tcIsLiftedTypeKind kind + | otherwise = is_Type -- In the particular case of a data family, permit a return kind of the -- form `:: k` (where `k` is a bare kind variable). is_kind_var :: Bool - is_kind_var | is_data_family = isJust (tcGetCastedTyVar_maybe kind) + is_kind_var | is_data_family = isJust (tcGetCastedTyVar_maybe res_kind) | otherwise = False err_msg :: DynFlags -> SDoc @@ -3353,7 +3386,7 @@ checkDataKindSig data_sort kind = do text "has non-" <> (if tYPE_ok dflags then text "TYPE" else ppr liftedTypeKind) , (if is_data_family then text "and non-variable" else empty) <+> - text "return kind" <+> quotes (ppr kind) ]) + text "return kind" <+> quotes (ppr res_kind) ]) , if not (tYPE_ok dflags) && is_TYPE && is_newtype && not (xopt LangExt.UnliftedNewtypes dflags) then text "Perhaps you intended to use UnliftedNewtypes" ===================================== compiler/GHC/Tc/Instance/Family.hs ===================================== @@ -18,7 +18,6 @@ import GHC.Driver.Types import GHC.Core.FamInstEnv import GHC.Core.InstEnv( roughMatchTcs ) import GHC.Core.Coercion -import GHC.Core.Lint import GHC.Tc.Types.Evidence import GHC.Iface.Load import GHC.Tc.Utils.Monad @@ -162,34 +161,13 @@ addressed yet. newFamInst :: FamFlavor -> CoAxiom Unbranched -> TcM FamInst -- Freshen the type variables of the FamInst branches newFamInst flavor axiom@(CoAxiom { co_ax_tc = fam_tc }) - = ASSERT2( tyCoVarsOfTypes lhs `subVarSet` tcv_set, text "lhs" <+> pp_ax ) - ASSERT2( lhs_kind `eqType` rhs_kind, text "kind" <+> pp_ax $$ ppr lhs_kind $$ ppr rhs_kind ) - -- We used to have an assertion that the tyvars of the RHS were bound - -- by tcv_set, but in error situations like F Int = a that isn't - -- true; a later check in checkValidFamInst rejects it - do { (subst, tvs') <- freshenTyVarBndrs tvs + = do { + -- Freshen the type variables + (subst, tvs') <- freshenTyVarBndrs tvs ; (subst, cvs') <- freshenCoVarBndrsX subst cvs - ; dflags <- getDynFlags ; let lhs' = substTys subst lhs rhs' = substTy subst rhs - tcvs' = tvs' ++ cvs' - ; ifErrsM (return ()) $ -- Don't lint when there are errors, because - -- errors might mean TcTyCons. - -- See Note [Recover from validity error] in GHC.Tc.TyCl - when (gopt Opt_DoCoreLinting dflags) $ - -- Check that the types involved in this instance are well formed. - -- Do /not/ expand type synonyms, for the reasons discussed in - -- Note [Linting type synonym applications]. - case lintTypes dflags tcvs' (rhs':lhs') of - Nothing -> pure () - Just fail_msg -> pprPanic "Core Lint error in newFamInst" $ - vcat [ fail_msg - , ppr fam_tc - , ppr subst - , ppr tvs' - , ppr cvs' - , ppr lhs' - , ppr rhs' ] + ; return (FamInst { fi_fam = tyConName fam_tc , fi_flavor = flavor , fi_tcs = roughMatchTcs lhs @@ -199,10 +177,6 @@ newFamInst flavor axiom@(CoAxiom { co_ax_tc = fam_tc }) , fi_rhs = rhs' , fi_axiom = axiom }) } where - lhs_kind = tcTypeKind (mkTyConApp fam_tc lhs) - rhs_kind = tcTypeKind rhs - tcv_set = mkVarSet (tvs ++ cvs) - pp_ax = pprCoAxiom axiom CoAxBranch { cab_tvs = tvs , cab_cvs = cvs , cab_lhs = lhs ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -268,6 +268,14 @@ tcRnModuleTcRnM hsc_env mod_sum then tcRnHsBootDecls hsc_src local_decls else {-# SCC "tcRnSrcDecls" #-} tcRnSrcDecls explicit_mod_hdr local_decls export_ies + + ; whenM (goptM Opt_DoCoreLinting) $ + do { let (warns, errs) = lintGblEnv (hsc_dflags hsc_env) tcg_env + ; mapBagM_ (addWarn NoReason) warns + ; mapBagM_ addErr errs + ; failIfErrsM } -- if we have a lint error, we're only + -- going to get in deeper trouble by proceeding + ; setGblEnv tcg_env $ do { -- Process the export list traceRn "rn4a: before exports" empty @@ -2896,7 +2904,7 @@ pprTcGblEnv (TcGblEnv { tcg_type_env = type_env, pprUFM (imp_dep_mods imports) (ppr . sort) , text "Dependent packages:" <+> ppr (S.toList $ imp_dep_pkgs imports)] - where -- The use of sort is just to reduce unnecessary + -- The use of sort is just to reduce unnecessary -- wobbling in testsuite output ppr_rules :: [LRuleDecl GhcTc] -> SDoc ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1791,6 +1791,272 @@ and take the wired-in information. That avoids complications. e.g. the need to make the data constructor worker name for a constraint tuple match the wired-in one +Note [Datatype return kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +There are several poorly lit corners around datatype/newtype return kinds. +This Note explains these. We cover data/newtype families and instances +in Note [Data family/instance return kinds]. + +data T a :: where ... -- See Point DT4 +newtype T a :: where ... -- See Point DT5 + +DT1 Where this applies: Only GADT syntax for data/newtype/instance declarations + can have declared return kinds. This Note does not apply to Haskell98 + syntax. + +DT2 Where these kinds come from: The return kind is part of the TyCon kind, gotten either + by checkInitialKind (standalone kind signature / CUSK) or + inferInitialKind. It is extracted by bindTyClTyVars in tcTyClDecl1. It is + then passed to tcDataDefn. + +DT3 Eta-expansion: Any forall-bound variables and function arguments in a result kind + become parameters to the type. That is, when we say + + data T a :: Type -> Type where ... + + we really mean for T to have two parameters. The second parameter + is produced by processing the return kind in etaExpandAlgTyCon, + called in tcDataDefn. + + See also Note [TyConBinders for the result kind signatures of a data type] + in GHC.Tc.Gen.HsType. + +DT4 Datatype return kind restriction: A data type return kind must end + in a type that, after type-synonym expansion, yields `TYPE LiftedRep`. By + "end in", we mean we strip any foralls and function arguments off before + checking. + + Examples: + data T1 :: Type -- good + data T2 :: Bool -> Type -- good + data T3 :: Bool -> forall k. Type -- strange, but still accepted + data T4 :: forall k. k -> Type -- good + data T5 :: Bool -- bad + data T6 :: Type -> Bool -- bad + + Exactly the same applies to data instance (but not data family) + declarations. Examples + data instance D1 :: Type -- good + data instance D2 :: Bool -> Type -- good + + We can "look through" type synonyms + type Star = Type + data T7 :: Bool -> Star -- good (synonym expansion ok) + type Arrow = (->) + data T8 :: Arrow Bool Type -- good (ditto) + + But we specifically do *not* do type family reduction here. + type family ARROW where + ARROW = (->) + data T9 :: ARROW Bool Type -- bad + + type family F a where + F Int = Bool + F Bool = Type + data T10 :: Bool -> F Bool -- bad + + The /principle/ here is that in the TyCon for a data type or data instance, + we must be able to lay out all the type-variable binders, one by one, until + we reach (TYPE xx). There is no place for a cast here. We could add one, + but let's not! + + This check is done in checkDataKindSig. For data declarations, this + call is in tcDataDefn; for data instances, this call is in tcDataFamInstDecl. + +DT5 Newtype return kind restriction. + If -XUnliftedNewtypes is not on, then newtypes are treated just + like datatypes --- see (4) above. + + If -XUnliftedNewtypes is on, then a newtype return kind must end in + TYPE xyz, for some xyz (after type synonym expansion). The "xyz" + may include type families, but the TYPE part must be visible + /without/ expanding type families (only synonyms). + + This kind is unified with the kind of the representation type (the + type of the one argument to the one constructor). See also steps + (2) and (3) of Note [Implementation of UnliftedNewtypes]. + + The checks are done in the same places as for datatypes. + Examples (assume -XUnliftedNewtypes): + + newtype N1 :: Type -- good + newtype N2 :: Bool -> Type -- good + newtype N3 :: forall r. Bool -> TYPE r -- good + + type family F (t :: Type) :: RuntimeRep + newtype N4 :: forall t -> TYPE (F t) -- good + + type family STAR where + STAR = Type + newtype N5 :: Bool -> STAR -- bad + +Note [Data family/instance return kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Within this note, understand "instance" to mean data or newtype +instance, and understand "family" to mean data family. No type +families or classes here. Some examples: + +data family T a :: -- See Point DF56 + +data instance T [a] :: where ... -- See Point DF2 +newtype instance T [a] :: where ... -- See Point DF2 + +Here is the Plan for Data Families: + +DF0 Where these kinds come from: + + Families: The return kind is either written in a standalone signature + or extracted from a family declaration in getInitialKind. + If a family declaration is missing a result kind, it is assumed to be + Type. This assumption is in getInitialKind for CUSKs or + get_fam_decl_initial_kind for non-signature & non-CUSK cases. + + Instances: The data family already has a known kind. The return kind + of an instance is then calculated by applying the data family tycon + to the patterns provided, as computed by the typeKind lhs_ty in the + end of tcDataFamInstHeader. In the case of an instance written in GADT + syntax, there are potentially *two* return kinds: the one computed from + applying the data family tycon to the patterns, and the one given by + the user. This second kind is checked by the tc_kind_sig function within + tcDataFamInstHeader. See also DF3, below. + +DF1 In a data/newtype instance, we treat the kind of the /data family/, + once instantiated, as the "master kind" for the representation + TyCon. For example: + data family T1 :: Type -> Type -> Type + data instance T1 Int :: F Bool -> Type where ... + The "master kind" for the representation TyCon R:T1Int comes + from T1, not from the signature on the data instance. It is as + if we declared + data R:T1Int :: Type -> Type where ... + See Note [Liberalising data family return kinds] for an alternative + plan. But this current plan is simple, and ensures that all instances + are simple instantiations of the master, without strange casts. + + An example with non-trivial instantiation: + data family T2 :: forall k. Type -> k + data instance T2 :: Type -> Type -> Type where ... + Here 'k' gets instantiated with (Type -> Type), driven by + the signature on the 'data instance'. (See also DT3 of + Note [Datatype return kinds] about eta-expansion, which applies here, + too; see tcDataFamInstDecl's call of etaExpandAlgTyCon.) + + A newtype example: + + data Color = Red | Blue + type family Interpret (x :: Color) :: RuntimeRep where + Interpret 'Red = 'IntRep + Interpret 'Blue = 'WordRep + data family Foo (x :: Color) :: TYPE (Interpret x) + newtype instance Foo 'Red :: TYPE IntRep where + FooRedC :: Int# -> Foo 'Red + + Here we get that Foo 'Red :: TYPE (Interpret Red), and our + representation newtype looks like + newtype R:FooRed :: TYPE (Interpret Red) where + FooRedC :: Int# -> R:FooRed + Remember: the master kind comes from the /family/ tycon. + +DF2 /After/ this instantiation, the return kind of the master kind + must obey the usual rules for data/newtype return kinds (DT4, DT5) + of Note [Datatype return kinds]. Examples: + data family T3 k :: k + data instance T3 Type where ... -- OK + data instance T3 (Type->Type) where ... -- OK + data instance T3 (F Int) where ... -- Not OK + +DF3 Any kind signatures on the data/newtype instance are checked for + equality with the master kind (and hence may guide instantiation) + but are otherwise ignored. So in the T1 example above, we check + that (F Int ~ Type) by unification; but otherwise ignore the + user-supplied signature from the /family/ not the /instance/. + + We must be sure to instantiate any trailing invisible binders + before doing this unification. See the call to tcInstInvisibleBinders + in tcDataFamInstHeader. For example: + data family D :: forall k. k + data instance D :: Type -- forall k. k <: Type + data instance D :: Type -> Type -- forall k. k <: Type -> Type + -- NB: these do not overlap + we must instantiate D before unifying with the signature in the + data instance declaration + +DF4 We also (redundantly) check that any user-specified return kind + signature in the data instance also obeys DT4/DT5. For example we + reject + data family T1 :: Type -> Type -> Type + data instance T1 Int :: Type -> F Int + even if (F Int ~ Type). We could omit this check, because we + use the master kind; but it seems more uniform to check it, again + with checkDataKindSig. + +DF5 Data /family/ return kind restrictions. Consider + data family D8 a :: F a + where F is a type family. No data/newtype instance can instantiate + this so that it obeys the rules of DT4 or DT5. So GHC proactively + rejects the data /family/ declaration if it can never satisfy (DT4)/(DT5). + Remember that a data family supports both data and newtype instances. + + More precisely, the return kind of a data family must be either + * TYPE xyz (for some type xyz) or + * a kind variable + Only in these cases can a data/newtype instance possibly satisfy (DT4)/(DT5). + This is checked by the call to checkDataKindSig in tcFamDecl1. Examples: + + data family D1 :: Type -- good + data family D2 :: Bool -> Type -- good + data family D3 k :: k -- good + data family D4 :: forall k -> k -- good + data family D5 :: forall k. k -> k -- good + data family D6 :: forall r. TYPE r -- good + data family D7 :: Bool -> STAR -- bad (see STAR from point 5) + +DF6 Two return kinds for instances: If an instance has two return kinds, + one from the family declaration and one from the instance declaration + (see point DF3 above), they are unified. More accurately, we make sure + that the kind of the applied data family is a subkind of the user-written + kind. GHC.Tc.Gen.HsType.checkExpectedKind normally does this check for types, but + that's overkill for our needs here. Instead, we just instantiate any + invisible binders in the (instantiated) kind of the data family + (called lhs_kind in tcDataFamInstHeader) with tcInstInvisibleTyBinders + and then unify the resulting kind with the kind written by the user. + This unification naturally produces a coercion, which we can drop, as + the kind annotation on the instance is redundant (except perhaps for + effects of unification). + + This all is Wrinkle (3) in Note [Implementation of UnliftedNewtypes]. + +Note [Liberalising data family return kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Could we allow this? + type family F a where { F Int = Type } + data family T a :: F a + data instance T Int where + MkT :: T Int + +In the 'data instance', T Int :: F Int, and F Int = Type, so all seems +well. But there are lots of complications: + +* The representation constructor R:TInt presumably has kind Type. + So the axiom connecting the two would have to look like + axTInt :: T Int ~ R:TInt |> sym axFInt + and that doesn't match expectation in DataFamInstTyCon + in AlgTyConFlav + +* The wrapper can't have type + $WMkT :: Int -> T Int + because T Int has the wrong kind. It would have to be + $WMkT :: Int -> (T Int) |> axFInt + +* The code for $WMkT would also be more complicated, needing + two coherence coercions. Try it! + +* Code for pattern matching would be complicated in an + exactly dual way. + +So yes, we could allow this, but we currently do not. That's +why we have DF2 in Note [Data family/instance return kinds]. + Note [Implementation of UnliftedNewtypes] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expected behavior of UnliftedNewtypes: @@ -1867,11 +2133,12 @@ Wrinkle: Consider (#17021, typecheck/should_fail/T17021) newtype T :: TYPE (Id LiftedRep) where MkT :: Int -> T - In the type of MkT, we must end with (Int |> TYPE (sym axId)) -> T, never Int -> (T |> - TYPE axId); otherwise, the result type of the constructor wouldn't match the - datatype. However, type-checking the HsType T might reasonably result in - (T |> hole). We thus must ensure that this cast is dropped, forcing the - type-checker to add one to the Int instead. + In the type of MkT, we must end with (Int |> TYPE (sym axId)) -> T, + never Int -> (T |> TYPE axId); otherwise, the result type of the + constructor wouldn't match the datatype. However, type-checking the + HsType T might reasonably result in (T |> hole). We thus must ensure + that this cast is dropped, forcing the type-checker to add one to + the Int instead. Why is it always safe to drop the cast? This result type is type-checked by tcHsOpenType, so its kind definitely looks like TYPE r, for some r. It is @@ -1883,7 +2150,7 @@ Wrinkle: Consider (#17021, typecheck/should_fail/T17021) Note that this is possible in the H98 case only for a data family, because the H98 syntax doesn't permit a kind signature on the newtype itself. -There are also some changes for deailng with families: +There are also some changes for dealing with families: 1. In tcFamDecl1, we suppress a tcIsLiftedTypeKind check if UnliftedNewtypes is on. This allows us to write things like: @@ -1905,7 +2172,7 @@ There are also some changes for deailng with families: we use that kind signature. 3. A data family and its newtype instance may be declared with slightly - different kinds. See point 7 in Note [Datatype return kinds]. + different kinds. See point DF6 in Note [Data family/instance return kinds] There's also a change in the renamer: @@ -2292,187 +2559,6 @@ Since the LHS of an associated type family default is always just variables, it won't contain any tycons. Accordingly, the patterns used in the substitution won't actually be knot-tied, even though we're in the knot. This is too delicate for my taste, but it works. - -Note [Datatype return kinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -There are several poorly lit corners around datatype/newtype return kinds. -This Note explains these. Within this note, always understand "instance" -to mean data or newtype instance, and understand "family" to mean data -family. No type families or classes here. Some examples: - -data T a :: where ... -- See Point 4 -newtype T a :: where ... -- See Point 5 - -data family T a :: -- See Point 6 - -data instance T [a] :: where ... -- See Point 4 -newtype instance T [a] :: where ... -- See Point 5 - -1. Where this applies: Only GADT syntax for data/newtype/instance declarations - can have declared return kinds. This Note does not apply to Haskell98 - syntax. - -2. Where these kinds come from: Return kinds are processed through several - different code paths: - - Data/newtypes: The return kind is part of the TyCon kind, gotten either - by checkInitialKind (standalone kind signature / CUSK) or - inferInitialKind. It is extracted by bindTyClTyVars in tcTyClDecl1. It is - then passed to tcDataDefn. - - Families: The return kind is either written in a standalone signature - or extracted from a family declaration in getInitialKind. - If a family declaration is missing a result kind, it is assumed to be - Type. This assumption is in getInitialKind for CUSKs or - get_fam_decl_initial_kind for non-signature & non-CUSK cases. - - Instances: The data family already has a known kind. The return kind - of an instance is then calculated by applying the data family tycon - to the patterns provided, as computed by the typeKind lhs_ty in the - end of tcDataFamInstHeader. In the case of an instance written in GADT - syntax, there are potentially *two* return kinds: the one computed from - applying the data family tycon to the patterns, and the one given by - the user. This second kind is checked by the tc_kind_sig function within - tcDataFamInstHeader. - -3. Eta-expansion: Any forall-bound variables and function arguments in a result kind - become parameters to the type. That is, when we say - - data T a :: Type -> Type where ... - - we really mean for T to have two parameters. The second parameter - is produced by processing the return kind in etaExpandAlgTyCon, - called in tcDataDefn for data/newtypes and in tcDataFamInstDecl - for instances. This is true for data families as well, though their - arity only matters for pretty-printing. - - See also Note [TyConBinders for the result kind signatures of a data type] - in GHC.Tc.Gen.HsType. - -4. Datatype return kind restriction: A data/data-instance return kind must end - in a type that, after type-synonym expansion, yields `TYPE LiftedRep`. By - "end in", we mean we strip any foralls and function arguments off before - checking: this remaining part of the type is returned from etaExpandAlgTyCon. - - Examples: - data T1 :: Type -- good - data T2 :: Bool -> Type -- good - data T3 :: Bool -> forall k. Type -- strange, but still accepted - data T4 :: forall k. k -> Type -- good - data T5 :: Bool -- bad - data T6 :: Type -> Bool -- bad - - Exactly the same applies to data instance (but not data family) - declarations. Examples - data instance D1 :: Type -- good - data instance D2 :: Boool -> Type -- good - - We can "look through" type synonyms - type Star = Type - data T7 :: Bool -> Star -- good (synonym expansion ok) - type Arrow = (->) - data T8 :: Arrow Bool Type -- good (ditto) - - But we specifically do *not* do type family reduction here. - type family ARROW where - ARROW = (->) - data T9 :: ARROW Bool Type -- bad - - type family F a where - F Int = Bool - F Bool = Type - data T10 :: Bool -> F Bool -- bad - - The /principle/ here is that in the TyCon for a data type or data instance, - we must be able to lay out all the type-variable binders, one by one, until - we reach (TYPE xx). There is no place for a cast here. We could add one, - but let's not! - - This check is done in checkDataKindSig. For data declarations, this - call is in tcDataDefn; for data instances, this call is in tcDataFamInstDecl. - -4a Because data instances in GADT syntax can have two return kinds (see - point (2) above), we must check both return kinds. The user-written return - kind is checked by the call to checkDataKindSig in tcDataFamInstDecl. Examples: - - data family D (a :: Nat) :: k -- good (see Point 6) - - data instance D 1 :: Type -- good - data instance D 2 :: F Bool -- bad - -5. Newtype return kind restriction: If -XUnliftedNewtypes is on, then - a newtype/newtype-instance return kind must end in TYPE xyz, for some - xyz (after type synonym expansion). The "xyz" may include type families, - but the TYPE part must be visible with expanding type families (only synonyms). - This kind is unified with the kind of the representation type (the type - of the one argument to the one constructor). See also steps (2) and (3) - of Note [Implementation of UnliftedNewtypes]. - - If -XUnliftedNewtypes is not on, then newtypes are treated just like datatypes. - - The checks are done in the same places as for datatypes. - Examples (assume -XUnliftedNewtypes): - - newtype N1 :: Type -- good - newtype N2 :: Bool -> Type -- good - newtype N3 :: forall r. Bool -> TYPE r -- good - - type family F (t :: Type) :: RuntimeRep - newtype N4 :: forall t -> TYPE (F t) -- good - - type family STAR where - STAR = Type - newtype N5 :: Bool -> STAR -- bad - -6. Family return kind restrictions: The return kind of a data family must - be either TYPE xyz (for some xyz) or a kind variable. The idea is that - instances may specialise the kind variable to fit one of the restrictions - above. This is checked by the call to checkDataKindSig in tcFamDecl1. - Examples: - - data family D1 :: Type -- good - data family D2 :: Bool -> Type -- good - data family D3 k :: k -- good - data family D4 :: forall k -> k -- good - data family D5 :: forall k. k -> k -- good - data family D6 :: forall r. TYPE r -- good - data family D7 :: Bool -> STAR -- bad (see STAR from point 5) - -7. Two return kinds for instances: If an instance has two return kinds, - one from the family declaration and one from the instance declaration - (see point (2) above), they are unified. More accurately, we make sure - that the kind of the applied data family is a subkind of the user-written - kind. GHC.Tc.Gen.HsType.checkExpectedKind normally does this check for types, but - that's overkill for our needs here. Instead, we just instantiate any - invisible binders in the (instantiated) kind of the data family - (called lhs_kind in tcDataFamInstHeader) with tcInstInvisibleTyBinders - and then unify the resulting kind with the kind written by the user. - This unification naturally produces a coercion, which we can drop, as - the kind annotation on the instance is redundant (except perhaps for - effects of unification). - - Example: - - data Color = Red | Blue - type family Interpret (x :: Color) :: RuntimeRep where - Interpret 'Red = 'IntRep - Interpret 'Blue = 'WordRep - data family Foo (x :: Color) :: TYPE (Interpret x) - newtype instance Foo 'Red :: TYPE IntRep where - FooRedC :: Int# -> Foo 'Red - - Here we get that Foo 'Red :: TYPE (Interpret Red) and we have to - unify the kind with TYPE IntRep. - - Example requiring subkinding: - - data family D :: forall k. k - data instance D :: Type -- forall k. k <: Type - data instance D :: Type -> Type -- forall k. k <: Type -> Type - -- NB: these do not overlap - - This all is Wrinkle (3) in Note [Implementation of UnliftedNewtypes]. - -} {- ********************************************************************* @@ -2502,8 +2588,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info -- When UnliftedNewtypes is enabled, we loosen this restriction -- on the return kind. See Note [Implementation of UnliftedNewtypes], wrinkle (1). -- See also Note [Datatype return kinds] - ; let (_, final_res_kind) = splitPiTys res_kind - ; checkDataKindSig DataFamilySort final_res_kind + ; checkDataKindSig DataFamilySort res_kind ; tc_rep_name <- newTyConRepName tc_name ; let inj = Injective $ replicate (length binders) True tycon = mkFamilyTyCon tc_name binders @@ -2798,7 +2883,7 @@ tcTyFamInstEqn fam_tc mb_clsinfo hs_pats hs_rhs_ty -- Don't print results they may be knot-tied -- (tcFamInstEqnGuts zonks to Type) - ; return (mkCoAxBranch qtvs [] [] fam_tc pats rhs_ty + ; return (mkCoAxBranch qtvs [] [] pats rhs_ty (map (const Nominal) qtvs) loc) } @@ -3170,8 +3255,8 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data } tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data - -- NB: don't use res_kind here, as it's ill-scoped. Instead, we get - -- the res_kind by typechecking the result type. + -- NB: don't use res_kind here, as it's ill-scoped. Instead, + -- we get the res_kind by typechecking the result type. (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms @@ -3188,16 +3273,12 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data bindImplicitTKBndrs_Skol implicit_tkv_nms $ bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext cxt - ; casted_res_ty <- tcHsOpenType hs_res_ty - ; res_ty <- if not debugIsOn then return $ discardCast casted_res_ty - else case splitCastTy_maybe casted_res_ty of - Just (ty, _) -> do unlifted_nts <- xoptM LangExt.UnliftedNewtypes - MASSERT( unlifted_nts ) - MASSERT( new_or_data == NewType ) - return ty - _ -> return casted_res_ty + ; (res_ty, res_kind) <- tcInferLHsTypeKind hs_res_ty + -- See Note [GADT return kinds] + -- See Note [Datatype return kinds] - ; let exp_kind = getArgExpKind new_or_data (typeKind res_ty) + ; let exp_kind = getArgExpKind new_or_data res_kind + ; btys <- tcConArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name @@ -3252,6 +3333,20 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data ; mapM buildOneDataCon names } +{- Note [GADT return kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + type family Star where Star = Type + data T :: Type where + MkT :: Int -> T + +If, for some stupid reason, tcInferLHsTypeKind on the return type of +MkT returned (T |> ax, Star), then the return-type check in +checkValidDataCon would reject the decl (although of course there is +nothing wrong with it). We are implicitly requiring tha +tcInferLHsTypeKind doesn't any gratuitous top-level casts. +-} + -- | Produce an "expected kind" for the arguments of a data/newtype. -- If the declaration is indeed for a newtype, -- then this expected kind will be the kind provided. Otherwise, @@ -3924,11 +4019,16 @@ checkValidDataCon dflags existential_ok tc con , ppr orig_res_ty <+> dcolon <+> ppr (tcTypeKind orig_res_ty)]) - ; checkTc (isJust (tcMatchTy res_ty_tmpl orig_res_ty)) + ; checkTc (isJust (tcMatchTyKi res_ty_tmpl orig_res_ty)) (badDataConTyCon con res_ty_tmpl) -- Note that checkTc aborts if it finds an error. This is -- critical to avoid panicking when we call dataConDisplayType -- on an un-rejiggable datacon! + -- Also NB that we match the *kind* as well as the *type* (#18357) + -- However, if the kind is the only thing that doesn't match, the + -- error message is terrible. E.g. test T18357b + -- type family Star where Star = Type + -- newtype T :: Type where MkT :: Int -> (T :: Star) ; traceTc "checkValidDataCon 2" (ppr data_con_display_type) ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -704,7 +704,6 @@ tcDataFamInstDecl mb_clsinfo tv_skol_env -- Check the result kind; it may come from a user-written signature. -- See Note [Datatype return kinds] in GHC.Tc.TyCl point 4(a) - ; checkDataKindSig (DataInstanceSort new_or_data) final_res_kind ; let extra_pats = map (mkTyVarTy . binderVar) extra_tcbs all_pats = pats `chkAppend` extra_pats orig_res_ty = mkTyConApp fam_tc all_pats @@ -713,10 +712,12 @@ tcDataFamInstDecl mb_clsinfo tv_skol_env ; traceTc "tcDataFamInstDecl" $ vcat [ text "Fam tycon:" <+> ppr fam_tc , text "Pats:" <+> ppr pats - , text "visibliities:" <+> ppr (tcbVisibilities fam_tc pats) + , text "visiblities:" <+> ppr (tcbVisibilities fam_tc pats) , text "all_pats:" <+> ppr all_pats , text "ty_binders" <+> ppr ty_binders , text "fam_tc_binders:" <+> ppr (tyConBinders fam_tc) + , text "res_kind:" <+> ppr res_kind + , text "final_res_kind:" <+> ppr final_res_kind , text "eta_pats" <+> ppr eta_pats , text "eta_tcbs" <+> ppr eta_tcbs ] @@ -734,9 +735,9 @@ tcDataFamInstDecl mb_clsinfo tv_skol_env NewType -> ASSERT( not (null data_cons) ) mkNewTyConRhs rep_tc_name rec_rep_tc (head data_cons) - ; let axiom = mkSingleCoAxiom Representational axiom_name - post_eta_qtvs eta_tvs [] fam_tc eta_pats - (mkTyConApp rep_tc (mkTyVarTys post_eta_qtvs)) + ; let ax_rhs = mkTyConApp rep_tc (mkTyVarTys post_eta_qtvs) + axiom = mkSingleCoAxiom Representational axiom_name + post_eta_qtvs eta_tvs [] fam_tc eta_pats ax_rhs parent = DataFamInstTyCon axiom fam_tc all_pats -- NB: Use the full ty_binders from the pats. See bullet toward @@ -851,13 +852,17 @@ tcDataFamInstHeader tcDataFamInstHeader mb_clsinfo fam_tc imp_vars mb_bndrs fixity hs_ctxt hs_pats m_ksig hs_cons new_or_data = do { traceTc "tcDataFamInstHeader {" (ppr fam_tc <+> ppr hs_pats) - ; (imp_tvs, (exp_tvs, (stupid_theta, lhs_ty, res_kind))) + ; (imp_tvs, (exp_tvs, (stupid_theta, lhs_ty, master_res_kind, instance_res_kind))) <- pushTcLevelM_ $ solveEqualities $ bindImplicitTKBndrs_Q_Skol imp_vars $ bindExplicitTKBndrs_Q_Skol AnyKind exp_bndrs $ do { stupid_theta <- tcHsContext hs_ctxt ; (lhs_ty, lhs_kind) <- tcFamTyPats fam_tc hs_pats + ; (lhs_applied_ty, lhs_applied_kind) + <- tcInstInvisibleTyBinders lhs_ty lhs_kind + -- See Note [Data family/instance return kinds] + -- in GHC.Tc.TyCl point (DF3) -- Ensure that the instance is consistent -- with its parent class @@ -869,21 +874,17 @@ tcDataFamInstHeader mb_clsinfo fam_tc imp_vars mb_bndrs fixity -- Add constraints from the data constructors ; kcConDecls new_or_data res_kind hs_cons - -- See Note [Datatype return kinds] in GHC.Tc.TyCl, point (7). - ; (lhs_extra_args, lhs_applied_kind) - <- tcInstInvisibleTyBinders (invisibleTyBndrCount lhs_kind) - lhs_kind - ; let lhs_applied_ty = lhs_ty `mkTcAppTys` lhs_extra_args - hs_lhs = nlHsTyConApp fixity (getName fam_tc) hs_pats + -- Check that the result kind of the TyCon applied to its args + -- is compatible with the explicit signature (or Type, if there + -- is none) + ; let hs_lhs = nlHsTyConApp fixity (getName fam_tc) hs_pats ; _ <- unifyKind (Just (unLoc hs_lhs)) lhs_applied_kind res_kind - -- Check that the result kind of the TyCon applied to its args - -- is compatible with the explicit signature (or Type, if there - -- is none) ; traceTc "tcDataFamInstHeader" $ vcat [ ppr fam_tc, ppr m_ksig, ppr lhs_applied_kind, ppr res_kind ] ; return ( stupid_theta , lhs_applied_ty + , lhs_applied_kind , res_kind ) } -- See GHC.Tc.TyCl Note [Generalising in tcFamTyPatsGuts] @@ -900,13 +901,17 @@ tcDataFamInstHeader mb_clsinfo fam_tc imp_vars mb_bndrs fixity ; (ze, qtvs) <- zonkTyBndrs qtvs ; lhs_ty <- zonkTcTypeToTypeX ze lhs_ty ; stupid_theta <- zonkTcTypesToTypesX ze stupid_theta - ; res_kind <- zonkTcTypeToTypeX ze res_kind + ; master_res_kind <- zonkTcTypeToTypeX ze master_res_kind + ; instance_res_kind <- zonkTcTypeToTypeX ze instance_res_kind -- We check that res_kind is OK with checkDataKindSig in -- tcDataFamInstDecl, after eta-expansion. We need to check that -- it's ok because res_kind can come from a user-written kind signature. -- See Note [Datatype return kinds], point (4a) + ; checkDataKindSig (DataInstanceSort new_or_data) master_res_kind + ; checkDataKindSig (DataInstanceSort new_or_data) instance_res_kind + -- Check that type patterns match the class instance head -- The call to splitTyConApp_maybe here is just an inlining of -- the body of unravelFamInstPats. @@ -914,7 +919,7 @@ tcDataFamInstHeader mb_clsinfo fam_tc imp_vars mb_bndrs fixity Just (_, pats) -> pure pats Nothing -> pprPanic "tcDataFamInstHeader" (ppr lhs_ty) - ; return (qtvs, pats, res_kind, stupid_theta) } + ; return (qtvs, pats, master_res_kind, stupid_theta) } where fam_name = tyConName fam_tc data_ctxt = DataKindCtxt fam_name @@ -973,7 +978,7 @@ however, so this Note aims to describe these subtleties: * The representation tycon Drep is parameterised over the free variables of the pattern, in no particular order. So there is no guarantee that 'p' and 'q' will come last in Drep's parameters, and - in the right order. So, if the /patterns/ of the family insatance + in the right order. So, if the /patterns/ of the family instance are eta-reducible, we re-order Drep's parameters to put the eta-reduced type variables last. ===================================== compiler/GHC/Tc/Types.hs ===================================== @@ -79,7 +79,10 @@ module GHC.Tc.Types( -- Role annotations RoleAnnotEnv, emptyRoleAnnotEnv, mkRoleAnnotEnv, - lookupRoleAnnot, getRoleAnnots + lookupRoleAnnot, getRoleAnnots, + + -- Linting + lintGblEnv ) where #include "HsVersions.h" @@ -93,6 +96,7 @@ import GHC.Tc.Types.Evidence import GHC.Core.Type import GHC.Core.TyCon ( TyCon, tyConKind ) import GHC.Core.PatSyn ( PatSyn ) +import GHC.Core.Lint ( lintAxioms ) import GHC.Types.Id ( idType, idName ) import GHC.Types.FieldLabel ( FieldLabel ) import GHC.Core.UsageEnv @@ -1738,3 +1742,16 @@ lookupRoleAnnot = lookupNameEnv getRoleAnnots :: [Name] -> RoleAnnotEnv -> [LRoleAnnotDecl GhcRn] getRoleAnnots bndrs role_env = mapMaybe (lookupRoleAnnot role_env) bndrs + +{- ********************************************************************* +* * + Linting a TcGblEnv +* * +********************************************************************* -} + +-- | Check the 'TcGblEnv' for consistency. Currently, only checks +-- axioms, but should check other aspects, too. +lintGblEnv :: DynFlags -> TcGblEnv -> (Bag SDoc, Bag SDoc) +lintGblEnv dflags tcg_env = lintAxioms dflags axioms + where + axioms = typeEnvCoAxioms (tcg_type_env tcg_env) ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -16,7 +16,7 @@ module GHC.Tc.Utils.Instantiate ( instCall, instDFunType, instStupidTheta, instTyVarsWith, newWanted, newWanteds, - tcInstInvisibleTyBinders, tcInstInvisibleTyBinder, + tcInstInvisibleTyBindersN, tcInstInvisibleTyBinders, tcInstInvisibleTyBinder, newOverloadedLit, mkOverLit, @@ -366,13 +366,19 @@ instStupidTheta orig theta * * ********************************************************************* -} --- | Instantiates up to n invisible binders --- Returns the instantiating types, and body kind -tcInstInvisibleTyBinders :: Int -> TcKind -> TcM ([TcType], TcKind) +-- | Given ty::forall k1 k2. k, instantiate all the invisible forall-binders +-- returning ty @kk1 @kk2 :: k[kk1/k1, kk2/k1] +tcInstInvisibleTyBinders :: TcType -> TcKind -> TcM (TcType, TcKind) +tcInstInvisibleTyBinders ty kind + = do { (extra_args, kind') <- tcInstInvisibleTyBindersN n_invis kind + ; return (mkAppTys ty extra_args, kind') } + where + n_invis = invisibleTyBndrCount kind -tcInstInvisibleTyBinders 0 kind +tcInstInvisibleTyBindersN :: Int -> TcKind -> TcM ([TcType], TcKind) +tcInstInvisibleTyBindersN 0 kind = return ([], kind) -tcInstInvisibleTyBinders n ty +tcInstInvisibleTyBindersN n ty = go n empty_subst ty where empty_subst = mkEmptyTCvSubst (mkInScopeSet (tyCoVarsOfType ty)) ===================================== docs/core-spec/CoreLint.ott ===================================== @@ -656,3 +656,43 @@ unify(, ) = subst subst(s) = subst(s') ----------------------------------------- :: CompatCoincident no_conflict(C, , ind1, ind2) + +defn |- axiom C ok :: :: lint_axiom :: 'Ax_' + {{ com Coercion axiom linting, \coderef{GHC/Core/Lint.hs}{lint\_axiom} }} + {{ tex \labeledjudge{axiom} [[C]] [[ok]] }} +by + +isNewTyCon T + = tyConRoles T + |-ty T : k0 + |-ty s : k0 +------------------------------ :: Newtype +|-axiom T_Rep forall . ( ~> s) ok + +isOpenTypeFamilyTyCon T +T |-branch b ok +------------------------------ :: OpenTypeFamily +|-axiom T_Nom b ok + +isClosedTypeFamilyTyCon T + +--------------------------- :: ClosedTypeFamily +|-axiom T_Nom ok + +isDataFamilyTyCon T +T |-branch b ok +--------------------------- :: DataFamily +|-axiom T_Rep b ok + +defn T |- branch b ok :: :: lint_family_branch :: 'Br_' + {{ com Type family branch linting, \coderef{GHC/Core/Lint.hs}{lint\_family\_branch} }} + {{ tex [[T]] \labeledjudge{branch} [[b]] [[ok]] }} +by + + + +fv() = + |-ty T : k0 + |-ty s : k0 +---------------------------------------------------------------- :: OK +T |-branch forall . ( ~> s) ok ===================================== docs/core-spec/CoreSyn.ott ===================================== @@ -52,10 +52,10 @@ l :: 'Label_' ::= {{ com Labels for join points, also \coderef{GHC/Types/Var.hs} vars :: 'Vars_' ::= {{ com List of variables }} | :: :: List - | fv ( t ) :: M :: fv_t - {{ tex \textit{fv}([[t]]) }} | fv ( e ) :: M :: fv_e {{ tex \textit{fv}([[e]]) }} + | fv ( types ) :: M :: fv_types + {{ tex \textit{fv}([[types]]) }} | empty :: M :: empty | vars1 \inter vars2 :: M :: intersection {{ tex [[vars1]] \cap [[vars2]] }} @@ -197,7 +197,7 @@ R {{ tex \rho }} :: 'Role_' ::= {{ com Roles, \coderef{GHC/Core/Coercion/Axiom.h axBranch, b :: 'CoAxBranch_' ::= {{ com Axiom branches, \coderef{GHC/Core/TyCon.hs}{CoAxBranch} }} | forall . ( ~> s ) :: :: CoAxBranch {{ com \ctor{CoAxBranch}: Axiom branch }} - | ( ) [ ind ] :: M :: lookup {{ com List lookup }} + | ( ) [ ind ] :: M :: lookup {{ com List lookup }} mu {{ tex \mu }} :: 'CoAxiomRule_' ::= {{ com CoAxiomRules, \coderef{GHC/Core/Coercion/Axiom.hs}{CoAxiomRule} }} | M ( I , role_list , R' ) :: :: CoAxiomRule {{ com Named rule, with parameter info }} @@ -376,6 +376,10 @@ terminals :: 'terminals_' ::= | dataConTyCon :: :: dataConTyCon {{ tex \textsf{dataConTyCon} }} | dataConRepType :: :: dataConRepType {{ tex \textsf{dataConRepType} }} | isNewTyCon :: :: isNewTyCon {{ tex \textsf{isNewTyCon} }} + | isOpenTypeFamilyTyCon :: :: isOpenTypeFamilyTyCon {{ tex \textsf{isOpenTypeFamilyTyCon} }} + | isClosedTypeFamilyTyCon :: :: isClosedTypeFamilyTyCon {{ tex \textsf{isClosedTypeFamilyTyCon} }} + | isDataFamilyTyCon :: :: isDataFamilyTyCon {{ tex \textsf{isDataFamilyTyCon} }} + | isTyFamFree :: :: isTyFamFree {{ tex \textsf{isTyFamFree} }} | Constraint :: :: Constraint {{ tex \textsf{Constraint} }} | TYPE :: :: TYPE {{ tex \textsf{TYPE} }} | RuntimeRep :: :: RuntimeRep {{ tex \textsf{RuntimeRep} }} @@ -449,6 +453,10 @@ formula :: 'formula_' ::= | G |- tylit lit : k :: :: lintTyLit {{ tex [[G]] \labeledjudge{tylit} [[lit]] : [[k]] }} | isNewTyCon T :: :: isNewTyCon + | isOpenTypeFamilyTyCon T :: :: isOpenTypeFamilyTyCon + | isClosedTypeFamilyTyCon T :: :: isClosedTypeFamilyTyCon + | isDataFamilyTyCon T :: :: isDataFamilyTyCon + | isTyFamFree t :: :: isTyFamFree | k1 elt { } :: :: kind_elt | e is_a_type :: :: is_a_type {{ tex \exists \tau \text{ s.t.~} [[e]] = \tau }} @@ -526,3 +534,4 @@ Expr_Coercion <= Subst_TmMapping Type_CastTy <= Var_IdOrTyVar +Expr_Type <= Vars_fv_e ===================================== docs/core-spec/core-spec.mng ===================================== @@ -573,6 +573,37 @@ taking care to map identical type family applications to the same fresh variable The algorithm $[[unify]]$ is implemented in \coderef{GHC/Core/Unify.hs}{tcUnifyTys}. It performs a standard unification, returning a substitution upon success. +\subsection{Axioms} + +After type-checking the type and class declarations of a file, the axioms +in the file are optionally linted. This is done from \coderef{GHC/Tc/Types.hs}{lintGblEnv}, +which calls \coderef{GHC/Core/Lint.hs}{lintAxioms}. That function ensures +the following judgement on each axiom: + +\ottdefnlintXXaxiom{} + +\ottdefnlintXXfamilyXXbranch{} + +In addition to these checks, the linter will also check several other conditions: + +\begin{itemize} +\item Every \texttt{CoAxBranch} has a \texttt{cab\_cvs} field. This is unused +currently and should always be empty. +\item Every \texttt{CoAxBranch} has a \texttt{cab\_eta\_tvs} field. This is used +only for data family instances, but is not involved in type correctness. (It is +used for pretty-printing.) The implemented linter checks to make sure this field +is empty for axioms that are not associated with data family instances. +\item Every \texttt{CoAxBranch} has a \texttt{cab\_incomps} field that stores +a list of incompatible branches. The implemented linter checks that these +branches are indeed incompatible with the current one. +\item The linter checks that newtypes are associated with exactly one axiom, +as are closed type families. +\item The linter checks that all instances of the same open family are compatible. +\end{itemize} + +A nice summary of the required checks is in Section F.1 of the \emph{Safe Coercions} +paper (JFP'16). + \section{Operational semantics} \subsection{Disclaimer} ===================================== docs/core-spec/core-spec.pdf ===================================== Binary files a/docs/core-spec/core-spec.pdf and b/docs/core-spec/core-spec.pdf differ ===================================== testsuite/tests/polykinds/T18300.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE GADTs, PolyKinds, DataKinds, TypeFamilies #-} + +module Foo where + +import GHC.Exts +import Data.Kind + +type family F a :: RuntimeRep +type instance F Int = 'LiftedRep + +data family T a :: TYPE (F a) + +data instance T Int where + MkT :: Int -> T Int + +-- ASSERT error in HEAD ===================================== testsuite/tests/polykinds/T18300.stderr ===================================== @@ -0,0 +1,4 @@ + +T18300.hs:13:1: error: + • Data instance has non-* return kind ‘TYPE (F Int)’ + • In the data instance declaration for ‘T’ ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -219,3 +219,4 @@ test('T16902', normal, compile_fail, ['']) test('CuskFam', normal, compile, ['']) test('T17841', normal, compile_fail, ['']) test('T17963', normal, compile_fail, ['']) +test('T18300', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -685,7 +685,7 @@ test('UnliftedNewtypesUnifySig', normal, compile, ['']) test('UnliftedNewtypesForall', normal, compile, ['']) test('UnlifNewUnify', normal, compile, ['']) test('UnliftedNewtypesLPFamily', normal, compile, ['']) -test('UnliftedNewtypesDifficultUnification', when(compiler_debugged(), expect_broken(18300)), compile, ['']) +test('UnliftedNewtypesDifficultUnification', normal, compile, ['']) test('T16832', normal, ghci_script, ['T16832.script']) test('T16995', normal, compile, ['']) test('T17007', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T18357.hs ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE StandaloneKindSignatures, TypeFamilies, GADTs, DataKinds #-} + +module T18357 where + +import Data.Kind + +type family Star where Star = Type + +type W :: Star +type W = T + +newtype T where + MkT :: Int -> W ===================================== testsuite/tests/typecheck/should_fail/T18357.stderr ===================================== @@ -0,0 +1,6 @@ + +T18357.hs:13:3: error: + • Data constructor ‘MkT’ returns type ‘W’ + instead of an instance of its parent type ‘T’ + • In the definition of data constructor ‘MkT’ + In the newtype declaration for ‘T’ ===================================== testsuite/tests/typecheck/should_fail/T18357a.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE PolyKinds, UnliftedNewtypes, StandaloneKindSignatures, TypeFamilies, GADTs, DataKinds #-} + +module T18357a where + +import Data.Kind +import GHC.Exts + +newtype T :: TYPE r where + MkT :: Int -> T + ===================================== testsuite/tests/typecheck/should_fail/T18357a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18357a.hs:9:10: error: + • Couldn't match kind ‘r’ with ‘'LiftedRep’ + Expected a type, but ‘Int’ has kind ‘*’ + • In the type ‘Int’ + In the definition of data constructor ‘MkT’ + In the newtype declaration for ‘T’ ===================================== testsuite/tests/typecheck/should_fail/T18357b.hs ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE UnliftedNewtypes, StandaloneKindSignatures, TypeFamilies, GADTs, DataKinds #-} + +module T18357b where + +import Data.Kind + +type family Star where Star = Type + +newtype T :: Type where + MkT :: Int -> (T :: Star) + +-- The error message is pretty terrible +-- but it probably nevery happens in practice ===================================== testsuite/tests/typecheck/should_fail/T18357b.stderr ===================================== @@ -0,0 +1,6 @@ + +T18357b.hs:10:3: error: + • Data constructor ‘MkT’ returns type ‘T’ + instead of an instance of its parent type ‘T’ + • In the definition of data constructor ‘MkT’ + In the newtype declaration for ‘T’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -575,3 +575,6 @@ test('ExplicitSpecificity7', normal, compile_fail, ['']) test('ExplicitSpecificity8', normal, compile_fail, ['']) test('ExplicitSpecificity9', normal, compile_fail, ['']) test('ExplicitSpecificity10', normal, compile_fail, ['']) +test('T18357', normal, compile_fail, ['']) +test('T18357a', normal, compile_fail, ['']) +test('T18357b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bf18646acbb5a59ad8716aedc32acfe2ead0f58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bf18646acbb5a59ad8716aedc32acfe2ead0f58 You're receiving 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 Jul 3 21:34:06 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 03 Jul 2020 17:34:06 -0400 Subject: [Git][ghc/ghc][master] DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) Message-ID: <5effa44e5b14c_80b8a5320c16733ef@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 4 changed files: - compiler/GHC/Core/Opt/Driver.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs Changes: ===================================== compiler/GHC/Core/Opt/Driver.hs ===================================== @@ -18,7 +18,7 @@ import GHC.Driver.Types import GHC.Core.Opt.CSE ( cseProgram ) import GHC.Core.Rules ( mkRuleBase, unionRuleBase, extendRuleBaseList, ruleCheckProgram, addRuleInfo, - getRules ) + getRules, initRuleOpts ) import GHC.Core.Ppr ( pprCoreBindings, pprCoreExpr ) import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) import GHC.Types.Id.Info @@ -497,9 +497,10 @@ ruleCheckPass current_phase pat guts = ; vis_orphs <- getVisibleOrphanMods ; let rule_fn fn = getRules (RuleEnv rb vis_orphs) fn ++ (mg_rules guts) + ; let ropts = initRuleOpts dflags ; liftIO $ putLogMsg dflags NoReason Err.SevDump noSrcSpan $ withPprStyle defaultDumpStyle - (ruleCheckProgram current_phase pat + (ruleCheckProgram ropts current_phase pat rule_fn (mg_binds guts)) ; return guts } ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -50,7 +50,7 @@ import GHC.Core.Opt.Arity ( etaExpand ) import GHC.Core.SimpleOpt ( pushCoTyArg, pushCoValArg , joinPointBinding_maybe, joinPointBindings_maybe ) import GHC.Core.FVs ( mkRuleInfo ) -import GHC.Core.Rules ( lookupRule, getRules ) +import GHC.Core.Rules ( lookupRule, getRules, initRuleOpts ) import GHC.Types.Basic import GHC.Utils.Monad ( mapAccumLM, liftIO ) import GHC.Types.Var ( isTyCoVar ) @@ -2182,7 +2182,7 @@ tryRules env rules fn args call_cont ; return (Just (val_arg, Select dup new_bndr new_alts se cont)) } -} - | Just (rule, rule_rhs) <- lookupRule dflags (getUnfoldingInRuleMatch env) + | Just (rule, rule_rhs) <- lookupRule ropts (getUnfoldingInRuleMatch env) (activeRule (getMode env)) fn (argInfoAppArgs args) rules -- Fire a rule for the function @@ -2205,6 +2205,7 @@ tryRules env rules fn args call_cont ; return Nothing } where + ropts = initRuleOpts dflags dflags = seDynFlags env zapped_env = zapSubstEnv env -- See Note [zapSubstEnv] ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -1375,9 +1375,9 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs in_scope = Core.substInScope (se_subst env) - already_covered :: DynFlags -> [CoreRule] -> [CoreExpr] -> Bool - already_covered dflags new_rules args -- Note [Specialisations already covered] - = isJust (lookupRule dflags (in_scope, realIdUnfolding) + already_covered :: RuleOpts -> [CoreRule] -> [CoreExpr] -> Bool + already_covered ropts new_rules args -- Note [Specialisations already covered] + = isJust (lookupRule ropts (in_scope, realIdUnfolding) (const True) fn args (new_rules ++ existing_rules)) -- NB: we look both in the new_rules (generated by this invocation @@ -1409,8 +1409,9 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs -- return () ; dflags <- getDynFlags + ; let ropts = initRuleOpts dflags ; if not useful -- No useful specialisation - || already_covered dflags rules_acc rule_lhs_args + || already_covered ropts rules_acc rule_lhs_args then return spec_acc else do { -- Run the specialiser on the specialised RHS ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -23,7 +23,7 @@ module GHC.Core.Rules ( -- * Misc. CoreRule helpers rulesOfBinds, getRules, pprRulesForUser, - lookupRule, mkRule, roughTopNames + lookupRule, mkRule, roughTopNames, initRuleOpts ) where #include "HsVersions.h" @@ -375,14 +375,14 @@ pprRuleBase rules = pprUFM rules $ \rss -> -- supplied rules to this instance of an application in a given -- context, returning the rule applied and the resulting expression if -- successful. -lookupRule :: DynFlags -> InScopeEnv +lookupRule :: RuleOpts -> InScopeEnv -> (Activation -> Bool) -- When rule is active -> Id -> [CoreExpr] -> [CoreRule] -> Maybe (CoreRule, CoreExpr) -- See Note [Extra args in rule matching] -- See comments on matchRule -lookupRule dflags in_scope is_active fn args rules +lookupRule opts in_scope is_active fn args rules = -- pprTrace "matchRules" (ppr fn <+> ppr args $$ ppr rules ) $ case go [] rules of [] -> Nothing @@ -399,7 +399,7 @@ lookupRule dflags in_scope is_active fn args rules go :: [(CoreRule,CoreExpr)] -> [CoreRule] -> [(CoreRule,CoreExpr)] go ms [] = ms go ms (r:rs) - | Just e <- matchRule dflags in_scope is_active fn args' rough_args r + | Just e <- matchRule opts in_scope is_active fn args' rough_args r = go ((r,mkTicks ticks e):ms) rs | otherwise = -- pprTrace "match failed" (ppr r $$ ppr args $$ @@ -478,7 +478,7 @@ to lookupRule are the result of a lazy substitution -} ------------------------------------ -matchRule :: DynFlags -> InScopeEnv -> (Activation -> Bool) +matchRule :: RuleOpts -> InScopeEnv -> (Activation -> Bool) -> Id -> [CoreExpr] -> [Maybe Name] -> CoreRule -> Maybe CoreExpr @@ -504,15 +504,10 @@ matchRule :: DynFlags -> InScopeEnv -> (Activation -> Bool) -- Any 'surplus' arguments in the input are simply put on the end -- of the output. -matchRule dflags rule_env _is_active fn args _rough_args +matchRule opts rule_env _is_active fn args _rough_args (BuiltinRule { ru_try = match_fn }) -- Built-in rules can't be switched off, it seems - = let env = RuleOpts - { roPlatform = targetPlatform dflags - , roNumConstantFolding = gopt Opt_NumConstantFolding dflags - , roExcessRationalPrecision = gopt Opt_ExcessPrecision dflags - } - in case match_fn env rule_env fn args of + = case match_fn opts rule_env fn args of Nothing -> Nothing Just expr -> Just expr @@ -523,6 +518,16 @@ matchRule _ in_scope is_active _ args rough_args | ruleCantMatch tpl_tops rough_args = Nothing | otherwise = matchN in_scope rule_name tpl_vars tpl_args args rhs + +-- | Initialize RuleOpts from DynFlags +initRuleOpts :: DynFlags -> RuleOpts +initRuleOpts dflags = RuleOpts + { roPlatform = targetPlatform dflags + , roNumConstantFolding = gopt Opt_NumConstantFolding dflags + , roExcessRationalPrecision = gopt Opt_ExcessPrecision dflags + } + + --------------------------------------- matchN :: InScopeEnv -> RuleName -> [Var] -> [CoreExpr] @@ -1155,12 +1160,13 @@ is so important. -- | Report partial matches for rules beginning with the specified -- string for the purposes of error reporting -ruleCheckProgram :: CompilerPhase -- ^ Rule activation test +ruleCheckProgram :: RuleOpts -- ^ Rule options + -> CompilerPhase -- ^ Rule activation test -> String -- ^ Rule pattern -> (Id -> [CoreRule]) -- ^ Rules for an Id -> CoreProgram -- ^ Bindings to check in -> SDoc -- ^ Resulting check message -ruleCheckProgram phase rule_pat rules binds +ruleCheckProgram ropts phase rule_pat rules binds | isEmptyBag results = text "Rule check results: no rule application sites" | otherwise @@ -1173,7 +1179,9 @@ ruleCheckProgram phase rule_pat rules binds , rc_id_unf = idUnfolding -- Not quite right -- Should use activeUnfolding , rc_pattern = rule_pat - , rc_rules = rules } + , rc_rules = rules + , rc_ropts = ropts + } results = unionManyBags (map (ruleCheckBind env) binds) line = text (replicate 20 '-') @@ -1181,7 +1189,8 @@ data RuleCheckEnv = RuleCheckEnv { rc_is_active :: Activation -> Bool, rc_id_unf :: IdUnfoldingFun, rc_pattern :: String, - rc_rules :: Id -> [CoreRule] + rc_rules :: Id -> [CoreRule], + rc_ropts :: RuleOpts } ruleCheckBind :: RuleCheckEnv -> CoreBind -> Bag SDoc @@ -1228,16 +1237,15 @@ ruleAppCheck_help env fn args rules i_args = args `zip` [1::Int ..] rough_args = map roughTopName args - check_rule rule = sdocWithDynFlags $ \dflags -> - rule_herald rule <> colon <+> rule_info dflags rule + check_rule rule = rule_herald rule <> colon <+> rule_info (rc_ropts env) rule rule_herald (BuiltinRule { ru_name = name }) = text "Builtin rule" <+> doubleQuotes (ftext name) rule_herald (Rule { ru_name = name }) = text "Rule" <+> doubleQuotes (ftext name) - rule_info dflags rule - | Just _ <- matchRule dflags (emptyInScopeSet, rc_id_unf env) + rule_info opts rule + | Just _ <- matchRule opts (emptyInScopeSet, rc_id_unf env) noBlackList fn args rough_args rule = text "matches (which is very peculiar!)" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/41d2649288a5debcb4c8003e54b7d3072ab951c5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/41d2649288a5debcb4c8003e54b7d3072ab951c5 You're receiving 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 Jul 3 21:34:41 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 03 Jul 2020 17:34:41 -0400 Subject: [Git][ghc/ghc][master] Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version Message-ID: <5effa4715d0ed_80b3f849426b78816745f5@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - 6 changed files: - docs/users_guide/phases.rst - hadrian/src/Rules/Generate.hs - includes/ghc.mk - + testsuite/tests/driver/FullGHCVersion.hs - + testsuite/tests/driver/FullGHCVersion.stdout - testsuite/tests/driver/all.T Changes: ===================================== docs/users_guide/phases.rst ===================================== @@ -332,6 +332,13 @@ defined by your local GHC installation, the following trick is useful: source, including the C source generated from a Haskell module (i.e. ``.hs``, ``.lhs``, ``.c`` and ``.hc`` files). +``__GLASGOW_HASKELL_FULL_VERSION__`` + .. index:: + single: __GLASGOW_HASKELL_FULL_VERSION__ + This macro exposes the full version string. + For instance: ``__FULL_GHC_VERSION__==8.11.0.20200319``. + Its value comes from the ``ProjectVersion`` Autotools variable. + ``__GLASGOW_HASKELL_PATCHLEVEL1__``; \ ``__GLASGOW_HASKELL_PATCHLEVEL2__`` .. index:: single: __GLASGOW_HASKELL_PATCHLEVEL2__ ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -398,6 +398,7 @@ generateGhcAutoconfH = do generateGhcVersionH :: Expr String generateGhcVersionH = do trackGenerateHs + fullVersion <- getSetting ProjectVersion version <- getSetting ProjectVersionInt patchLevel1 <- getSetting ProjectPatchLevel1 patchLevel2 <- getSetting ProjectPatchLevel2 @@ -406,7 +407,10 @@ generateGhcVersionH = do , "#define __GHCVERSION_H__" , "" , "#if !defined(__GLASGOW_HASKELL__)" - , "# define __GLASGOW_HASKELL__ " ++ version + , "#define __GLASGOW_HASKELL__ " ++ version + , "#endif" + , "#if !defined(__GLASGOW_HASKELL_FULL_VERSION__)" + , "#define __GLASGOW_HASKELL_FULL_VERSION__ " ++ fullVersion , "#endif" , ""] ++ ===================================== includes/ghc.mk ===================================== @@ -75,6 +75,7 @@ $$(includes_$1_H_VERSION) : mk/project.mk | $$$$(dir $$$$@)/. @echo "#define __GHCVERSION_H__" >> $$@ @echo >> $$@ @echo "#define __GLASGOW_HASKELL__ $$(ProjectVersionInt)" >> $$@ + @echo "#define __GLASGOW_HASKELL_FULL_VERSION__ $$(ProjectVersion)" >> $$@ @echo >> $$@ @if [ -n "$$(ProjectPatchLevel1)" ]; then \ echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ $$(ProjectPatchLevel1)" >> $$@; \ ===================================== testsuite/tests/driver/FullGHCVersion.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE CPP #-} + +module Main where + +main :: IO () +#if defined(__GLASGOW_HASKELL_FULL_VERSION__) +main = putStrLn "__GLASGOW_HASKELL_FULL_VERSION__ is well-defined!" +#else +main = putStrLn "__GLASGOW_HASKELL_FULL_VERSION__ is not defined!" +#endif ===================================== testsuite/tests/driver/FullGHCVersion.stdout ===================================== @@ -0,0 +1 @@ +__GLASGOW_HASKELL_FULL_VERSION__ is well-defined! ===================================== testsuite/tests/driver/all.T ===================================== @@ -282,3 +282,4 @@ test('T16737', test('T17143', exit_code(1), run_command, ['{compiler} T17143.hs -S -fno-code']) test('T17786', unless(opsys('mingw32'), skip), makefile_test, []) test('T18369', normal, compile, ['-O']) +test('FullGHCVersion', normal, compile_and_run, ['-package ghc-boot']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7aa6ef110d8cc6626b1cf18d85a37cbac53e2795 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7aa6ef110d8cc6626b1cf18d85a37cbac53e2795 You're receiving 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 Jul 3 22:16:22 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 03 Jul 2020 18:16:22 -0400 Subject: [Git][ghc/ghc][wip/T18126] 134 commits: [linker] Adds void printLoadedObjects(void); Message-ID: <5effae36c640_80b3f84900d2204168212c@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 21acb35a by Simon Peyton Jones at 2020-06-27T00:11:19+01:00 Quick Look impredicativity This patch implements Quick Look impredicativity (see #18126). The main action in is in the new module GHC.Tc.Gen.App, which deals with typechecking function applications. Much code has moved from Tc.Gen.Expr into Tc.Gen.App, but Tc.Gen.App also includes the new Quick Look code: see the function quickLook. Still needs documentation, and error message review - - - - - eb21c23c by Simon Peyton Jones at 2020-07-03T23:10:36+01:00 Work in progres on QL ...and especially solveLocalEqualities - - - - - 30 changed files: - .gitlab/ci.sh - .gitmodules - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Ppr/Expr.hs - compiler/GHC/Cmm/ProcPoint.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/CFG.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f3897b2cceffdf9ebec0f4feaacdeeee63752824...eb21c23cee17db74e01ceebec95402f2c2aaa4ee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f3897b2cceffdf9ebec0f4feaacdeeee63752824...eb21c23cee17db74e01ceebec95402f2c2aaa4ee You're receiving 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 Jul 4 03:47:14 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 03 Jul 2020 23:47:14 -0400 Subject: [Git][ghc/ghc][wip/angerman/more-rtsSymbols] 99 commits: codeGen: Don't discard live case binders in unsafeEqualityProof logic Message-ID: <5efffbc2ec685_80b3f8490382cec1686438@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/more-rtsSymbols at Glasgow Haskell Compiler / GHC Commits: 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - 5bc6082f by Moritz Angermann at 2020-07-03T23:47:11-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 5cdd1379 by Moritz Angermann at 2020-07-03T23:47:11-04:00 better if guards. - - - - - 30 changed files: - .gitlab/test-metrics.sh - .gitmodules - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/ProcPoint.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d38b41b9b5854469db3575ce517c1c2481cb7d64...5cdd137944bc4faf4af6e66434f26e5cd0dbc707 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d38b41b9b5854469db3575ce517c1c2481cb7d64...5cdd137944bc4faf4af6e66434f26e5cd0dbc707 You're receiving 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 Jul 4 07:40:08 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sat, 04 Jul 2020 03:40:08 -0400 Subject: [Git][ghc/ghc][wip/angerman/fix-hadrian-cross-macos] 179 commits: gitlab-ci: Allow ARMv7 job to fail Message-ID: <5f003258a332c_80b3f84960bea1417002ec@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/fix-hadrian-cross-macos at Glasgow Haskell Compiler / GHC Commits: cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00 gitlab-ci: Allow ARMv7 job to fail Due to #18298. - - - - - 32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00 Clean up boot vs non-boot disambiguating types We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule. - - - - - c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00 docs: Add more details on InterruptibleFFI. Details from https://gitlab.haskell.org/ghc/ghc/issues/8684 and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430 - - - - - 1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00 Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr. MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd. This regression did not make it into a release of GHC. Here, the original behavior is restored, and FinalPtr is given the same treatment as PlainPtr. - - - - - 2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00 Fix documentation on type families not being extracted It looks like the location of the Names used for CoAxioms on type families are now located at their type constructors. Previously, Docs.hs thought the Names were located in the RHS, so the RealSrcSpan in the instanceMap and getInstLoc didn't match up. Fixes #18241 - - - - - 6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00 GHC.Hs.Instances: Compile with -O0 This module contains exclusively Data instances, which are going to be slow no matter what we do. Furthermore, they are incredibly slow to compile with optimisation (see #9557). Consequently we compile this with -O0. See #18254. - - - - - c330331a by nineonine at 2020-06-04T04:37:59-04:00 Add test for #17669 - - - - - cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00 rts: Add Windows-specific implementation of rtsSleep Previously we would use the POSIX path, which uses `nanosleep`. However, it turns out that `nanosleep` is provided by `libpthread` on Windows. In general we don't want to incur such a dependency. Avoid this by simply using `Sleep` on Windows. Fixes #18272. - - - - - ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00 compiler: Disable use of process jobs with process < 1.6.9 Due to #17926. - - - - - 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e712d748 by Moritz Angermann at 2020-07-04T11:56:50+08:00 Fix ar-stage0 having no at-file support in hadrian - - - - - 32e51687 by Moritz Angermann at 2020-07-04T11:59:12+08:00 No Undefined Oriented Programming - - - - - cabc766a by Moritz Angermann at 2020-07-04T11:59:12+08:00 fallback - - - - - 366acd5c by Moritz Angermann at 2020-07-04T11:59:12+08:00 add docs - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/test-metrics.sh - .gitmodules - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/41f9ae95b785bc57c6d104700cf2a407800e148b...366acd5cc26e504c9db63547e4cc5257e3f6740d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/41f9ae95b785bc57c6d104700cf2a407800e148b...366acd5cc26e504c9db63547e4cc5257e3f6740d You're receiving 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 Jul 4 15:17:41 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 04 Jul 2020 11:17:41 -0400 Subject: [Git][ghc/ghc][ghc-8.8] 2 commits: Bump bytestring submodule Message-ID: <5f009d956bbca_80b3f84960bea1417106c0@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC Commits: a0c5ab3f by GHC GitLab CI at 2020-07-04T14:19:15+00:00 Bump bytestring submodule - - - - - 3475384d by GHC GitLab CI at 2020-07-04T14:19:33+00:00 Bump Cabal submodule - - - - - 2 changed files: - libraries/Cabal - libraries/bytestring Changes: ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit bd07f0a095869b91a590d8a564f716a6a136818a +Subproject commit 8199c3f838a15fb9b7c8d3527603084b2474d877 ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 95fe6bdf13c9cc86c1c880164f7844d61d989574 +Subproject commit 1efc9c0964ba6d0366c4015accbd5ebd343826f6 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dbe8a5947aa5714777611260dafaaebd7fd0f822...3475384dc3ca2487869f816a143cbd3c15eac4ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dbe8a5947aa5714777611260dafaaebd7fd0f822...3475384dc3ca2487869f816a143cbd3c15eac4ad You're receiving 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 Jul 4 15:19:37 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 04 Jul 2020 11:19:37 -0400 Subject: [Git][ghc/ghc][ghc-8.8] Bump to 8.8.4, RELEASE=YES Message-ID: <5f009e0984029_80b3f8486100a781710894@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC Commits: b12faad0 by GHC GitLab CI at 2020-07-04T15:19:25+00:00 Bump to 8.8.4, RELEASE=YES - - - - - 1 changed file: - configure.ac Changes: ===================================== configure.ac ===================================== @@ -13,10 +13,10 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.3], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.4], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # 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 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b12faad0ad27b56cfc35ac1faef448b6f2245734 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b12faad0ad27b56cfc35ac1faef448b6f2245734 You're receiving 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 Jul 5 02:34:50 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 04 Jul 2020 22:34:50 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/explicit-perf-baseline Message-ID: <5f013c4acfca9_80b3f849426b78817500bc@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/explicit-perf-baseline You're receiving 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 Jul 5 04:02:09 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sun, 05 Jul 2020 00:02:09 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/angerman/aarch64-ncg Message-ID: <5f0150c124976_80b3f8496a302dc1759724@gitlab.haskell.org.mail> Moritz Angermann pushed new branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/angerman/aarch64-ncg You're receiving 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 Jul 5 14:44:38 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 05 Jul 2020 10:44:38 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) Message-ID: <5f01e7562bf5e_80bf189318179974@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - b23da188 by Chaitanya Koparkar at 2020-07-05T10:44:32-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - e5ba6faf by Adam Sandberg Ericsson at 2020-07-05T10:44:34-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 17 changed files: - compiler/GHC/Core/Opt/Driver.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - docs/users_guide/phases.rst - hadrian/src/Rules/Generate.hs - includes/ghc.mk - libraries/ghc-prim/GHC/Types.hs - rts/Linker.c - + testsuite/tests/driver/FullGHCVersion.hs - + testsuite/tests/driver/FullGHCVersion.stdout - testsuite/tests/driver/all.T - testsuite/tests/rts/linker/Makefile - + testsuite/tests/rts/linker/T7072-main.c - + testsuite/tests/rts/linker/T7072-obj.c - + testsuite/tests/rts/linker/T7072.stderr - testsuite/tests/rts/linker/all.T Changes: ===================================== compiler/GHC/Core/Opt/Driver.hs ===================================== @@ -18,7 +18,7 @@ import GHC.Driver.Types import GHC.Core.Opt.CSE ( cseProgram ) import GHC.Core.Rules ( mkRuleBase, unionRuleBase, extendRuleBaseList, ruleCheckProgram, addRuleInfo, - getRules ) + getRules, initRuleOpts ) import GHC.Core.Ppr ( pprCoreBindings, pprCoreExpr ) import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) import GHC.Types.Id.Info @@ -497,9 +497,10 @@ ruleCheckPass current_phase pat guts = ; vis_orphs <- getVisibleOrphanMods ; let rule_fn fn = getRules (RuleEnv rb vis_orphs) fn ++ (mg_rules guts) + ; let ropts = initRuleOpts dflags ; liftIO $ putLogMsg dflags NoReason Err.SevDump noSrcSpan $ withPprStyle defaultDumpStyle - (ruleCheckProgram current_phase pat + (ruleCheckProgram ropts current_phase pat rule_fn (mg_binds guts)) ; return guts } ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -50,7 +50,7 @@ import GHC.Core.Opt.Arity ( etaExpand ) import GHC.Core.SimpleOpt ( pushCoTyArg, pushCoValArg , joinPointBinding_maybe, joinPointBindings_maybe ) import GHC.Core.FVs ( mkRuleInfo ) -import GHC.Core.Rules ( lookupRule, getRules ) +import GHC.Core.Rules ( lookupRule, getRules, initRuleOpts ) import GHC.Types.Basic import GHC.Utils.Monad ( mapAccumLM, liftIO ) import GHC.Types.Var ( isTyCoVar ) @@ -2182,7 +2182,7 @@ tryRules env rules fn args call_cont ; return (Just (val_arg, Select dup new_bndr new_alts se cont)) } -} - | Just (rule, rule_rhs) <- lookupRule dflags (getUnfoldingInRuleMatch env) + | Just (rule, rule_rhs) <- lookupRule ropts (getUnfoldingInRuleMatch env) (activeRule (getMode env)) fn (argInfoAppArgs args) rules -- Fire a rule for the function @@ -2205,6 +2205,7 @@ tryRules env rules fn args call_cont ; return Nothing } where + ropts = initRuleOpts dflags dflags = seDynFlags env zapped_env = zapSubstEnv env -- See Note [zapSubstEnv] ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -1375,9 +1375,9 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs in_scope = Core.substInScope (se_subst env) - already_covered :: DynFlags -> [CoreRule] -> [CoreExpr] -> Bool - already_covered dflags new_rules args -- Note [Specialisations already covered] - = isJust (lookupRule dflags (in_scope, realIdUnfolding) + already_covered :: RuleOpts -> [CoreRule] -> [CoreExpr] -> Bool + already_covered ropts new_rules args -- Note [Specialisations already covered] + = isJust (lookupRule ropts (in_scope, realIdUnfolding) (const True) fn args (new_rules ++ existing_rules)) -- NB: we look both in the new_rules (generated by this invocation @@ -1409,8 +1409,9 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs -- return () ; dflags <- getDynFlags + ; let ropts = initRuleOpts dflags ; if not useful -- No useful specialisation - || already_covered dflags rules_acc rule_lhs_args + || already_covered ropts rules_acc rule_lhs_args then return spec_acc else do { -- Run the specialiser on the specialised RHS ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -23,7 +23,7 @@ module GHC.Core.Rules ( -- * Misc. CoreRule helpers rulesOfBinds, getRules, pprRulesForUser, - lookupRule, mkRule, roughTopNames + lookupRule, mkRule, roughTopNames, initRuleOpts ) where #include "HsVersions.h" @@ -375,14 +375,14 @@ pprRuleBase rules = pprUFM rules $ \rss -> -- supplied rules to this instance of an application in a given -- context, returning the rule applied and the resulting expression if -- successful. -lookupRule :: DynFlags -> InScopeEnv +lookupRule :: RuleOpts -> InScopeEnv -> (Activation -> Bool) -- When rule is active -> Id -> [CoreExpr] -> [CoreRule] -> Maybe (CoreRule, CoreExpr) -- See Note [Extra args in rule matching] -- See comments on matchRule -lookupRule dflags in_scope is_active fn args rules +lookupRule opts in_scope is_active fn args rules = -- pprTrace "matchRules" (ppr fn <+> ppr args $$ ppr rules ) $ case go [] rules of [] -> Nothing @@ -399,7 +399,7 @@ lookupRule dflags in_scope is_active fn args rules go :: [(CoreRule,CoreExpr)] -> [CoreRule] -> [(CoreRule,CoreExpr)] go ms [] = ms go ms (r:rs) - | Just e <- matchRule dflags in_scope is_active fn args' rough_args r + | Just e <- matchRule opts in_scope is_active fn args' rough_args r = go ((r,mkTicks ticks e):ms) rs | otherwise = -- pprTrace "match failed" (ppr r $$ ppr args $$ @@ -478,7 +478,7 @@ to lookupRule are the result of a lazy substitution -} ------------------------------------ -matchRule :: DynFlags -> InScopeEnv -> (Activation -> Bool) +matchRule :: RuleOpts -> InScopeEnv -> (Activation -> Bool) -> Id -> [CoreExpr] -> [Maybe Name] -> CoreRule -> Maybe CoreExpr @@ -504,15 +504,10 @@ matchRule :: DynFlags -> InScopeEnv -> (Activation -> Bool) -- Any 'surplus' arguments in the input are simply put on the end -- of the output. -matchRule dflags rule_env _is_active fn args _rough_args +matchRule opts rule_env _is_active fn args _rough_args (BuiltinRule { ru_try = match_fn }) -- Built-in rules can't be switched off, it seems - = let env = RuleOpts - { roPlatform = targetPlatform dflags - , roNumConstantFolding = gopt Opt_NumConstantFolding dflags - , roExcessRationalPrecision = gopt Opt_ExcessPrecision dflags - } - in case match_fn env rule_env fn args of + = case match_fn opts rule_env fn args of Nothing -> Nothing Just expr -> Just expr @@ -523,6 +518,16 @@ matchRule _ in_scope is_active _ args rough_args | ruleCantMatch tpl_tops rough_args = Nothing | otherwise = matchN in_scope rule_name tpl_vars tpl_args args rhs + +-- | Initialize RuleOpts from DynFlags +initRuleOpts :: DynFlags -> RuleOpts +initRuleOpts dflags = RuleOpts + { roPlatform = targetPlatform dflags + , roNumConstantFolding = gopt Opt_NumConstantFolding dflags + , roExcessRationalPrecision = gopt Opt_ExcessPrecision dflags + } + + --------------------------------------- matchN :: InScopeEnv -> RuleName -> [Var] -> [CoreExpr] @@ -1155,12 +1160,13 @@ is so important. -- | Report partial matches for rules beginning with the specified -- string for the purposes of error reporting -ruleCheckProgram :: CompilerPhase -- ^ Rule activation test +ruleCheckProgram :: RuleOpts -- ^ Rule options + -> CompilerPhase -- ^ Rule activation test -> String -- ^ Rule pattern -> (Id -> [CoreRule]) -- ^ Rules for an Id -> CoreProgram -- ^ Bindings to check in -> SDoc -- ^ Resulting check message -ruleCheckProgram phase rule_pat rules binds +ruleCheckProgram ropts phase rule_pat rules binds | isEmptyBag results = text "Rule check results: no rule application sites" | otherwise @@ -1173,7 +1179,9 @@ ruleCheckProgram phase rule_pat rules binds , rc_id_unf = idUnfolding -- Not quite right -- Should use activeUnfolding , rc_pattern = rule_pat - , rc_rules = rules } + , rc_rules = rules + , rc_ropts = ropts + } results = unionManyBags (map (ruleCheckBind env) binds) line = text (replicate 20 '-') @@ -1181,7 +1189,8 @@ data RuleCheckEnv = RuleCheckEnv { rc_is_active :: Activation -> Bool, rc_id_unf :: IdUnfoldingFun, rc_pattern :: String, - rc_rules :: Id -> [CoreRule] + rc_rules :: Id -> [CoreRule], + rc_ropts :: RuleOpts } ruleCheckBind :: RuleCheckEnv -> CoreBind -> Bag SDoc @@ -1228,16 +1237,15 @@ ruleAppCheck_help env fn args rules i_args = args `zip` [1::Int ..] rough_args = map roughTopName args - check_rule rule = sdocWithDynFlags $ \dflags -> - rule_herald rule <> colon <+> rule_info dflags rule + check_rule rule = rule_herald rule <> colon <+> rule_info (rc_ropts env) rule rule_herald (BuiltinRule { ru_name = name }) = text "Builtin rule" <+> doubleQuotes (ftext name) rule_herald (Rule { ru_name = name }) = text "Rule" <+> doubleQuotes (ftext name) - rule_info dflags rule - | Just _ <- matchRule dflags (emptyInScopeSet, rc_id_unf env) + rule_info opts rule + | Just _ <- matchRule opts (emptyInScopeSet, rc_id_unf env) noBlackList fn args rough_args rule = text "matches (which is very peculiar!)" ===================================== docs/users_guide/phases.rst ===================================== @@ -332,6 +332,13 @@ defined by your local GHC installation, the following trick is useful: source, including the C source generated from a Haskell module (i.e. ``.hs``, ``.lhs``, ``.c`` and ``.hc`` files). +``__GLASGOW_HASKELL_FULL_VERSION__`` + .. index:: + single: __GLASGOW_HASKELL_FULL_VERSION__ + This macro exposes the full version string. + For instance: ``__FULL_GHC_VERSION__==8.11.0.20200319``. + Its value comes from the ``ProjectVersion`` Autotools variable. + ``__GLASGOW_HASKELL_PATCHLEVEL1__``; \ ``__GLASGOW_HASKELL_PATCHLEVEL2__`` .. index:: single: __GLASGOW_HASKELL_PATCHLEVEL2__ ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -398,6 +398,7 @@ generateGhcAutoconfH = do generateGhcVersionH :: Expr String generateGhcVersionH = do trackGenerateHs + fullVersion <- getSetting ProjectVersion version <- getSetting ProjectVersionInt patchLevel1 <- getSetting ProjectPatchLevel1 patchLevel2 <- getSetting ProjectPatchLevel2 @@ -406,7 +407,10 @@ generateGhcVersionH = do , "#define __GHCVERSION_H__" , "" , "#if !defined(__GLASGOW_HASKELL__)" - , "# define __GLASGOW_HASKELL__ " ++ version + , "#define __GLASGOW_HASKELL__ " ++ version + , "#endif" + , "#if !defined(__GLASGOW_HASKELL_FULL_VERSION__)" + , "#define __GLASGOW_HASKELL_FULL_VERSION__ " ++ fullVersion , "#endif" , ""] ++ ===================================== includes/ghc.mk ===================================== @@ -75,6 +75,7 @@ $$(includes_$1_H_VERSION) : mk/project.mk | $$$$(dir $$$$@)/. @echo "#define __GHCVERSION_H__" >> $$@ @echo >> $$@ @echo "#define __GLASGOW_HASKELL__ $$(ProjectVersionInt)" >> $$@ + @echo "#define __GLASGOW_HASKELL_FULL_VERSION__ $$(ProjectVersion)" >> $$@ @echo >> $$@ @if [ -n "$$(ProjectPatchLevel1)" ]; then \ echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ $$(ProjectPatchLevel1)" >> $$@; \ ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -488,12 +488,12 @@ can't conveniently come up with an Addr#. #include "MachDeps.h" data Module = Module - TrName -- Package name - TrName -- Module name + TrName -- ^ Package name + TrName -- ^ Module name data TrName - = TrNameS Addr# -- Static - | TrNameD [Char] -- Dynamic + = TrNameS Addr# -- ^ Static + | TrNameD [Char] -- ^ Dynamic -- | A de Bruijn index for a binder within a 'KindRep'. type KindBndr = Int @@ -520,8 +520,9 @@ data TypeLitSort = TypeLitSymbol | TypeLitNat -- Show instance for TyCon found in GHC.Show -data TyCon = TyCon WORD64_TY WORD64_TY -- Fingerprint - Module -- Module in which this is defined - TrName -- Type constructor name - Int# -- How many kind variables do we accept? - KindRep -- A representation of the type's kind +data TyCon = TyCon WORD64_TY -- ^ Fingerprint (high) + WORD64_TY -- ^ Fingerprint (low) + Module -- ^ Module in which this is defined + TrName -- ^ Type constructor name + Int# -- ^ How many kind variables do we accept? + KindRep -- ^ A representation of the type's kind ===================================== rts/Linker.c ===================================== @@ -637,23 +637,51 @@ internal_dlsym(const char *symbol) { // We acquire dl_mutex as concurrent dl* calls may alter dlerror ACQUIRE_LOCK(&dl_mutex); + + // clears dlerror dlerror(); + // look in program first v = dlsym(dl_prog_handle, symbol); if (dlerror() == NULL) { RELEASE_LOCK(&dl_mutex); + IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in program\n", symbol)); return v; } for (o_so = openedSOs; o_so != NULL; o_so = o_so->next) { v = dlsym(o_so->handle, symbol); if (dlerror() == NULL) { + IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in shared object\n", symbol)); RELEASE_LOCK(&dl_mutex); return v; } } RELEASE_LOCK(&dl_mutex); - return v; + +# if defined(HAVE_SYS_STAT_H) && defined(linux_HOST_OS) && defined(__GLIBC__) + // HACK: GLIBC implements these functions with a great deal of trickery where + // they are either inlined at compile time to their corresponding + // __xxxx(SYS_VER, ...) function or direct syscalls, or resolved at + // link time via libc_nonshared.a. + // + // We borrow the approach that the LLVM JIT uses to resolve these + // symbols. See http://llvm.org/PR274 and #7072 for more info. + + IF_DEBUG(linker, debugBelch("internal_dlsym: looking for symbol '%s' in GLIBC special cases\n", symbol)); + + if (strcmp(symbol, "stat") == 0) return (void*)&stat; + if (strcmp(symbol, "fstat") == 0) return (void*)&fstat; + if (strcmp(symbol, "lstat") == 0) return (void*)&lstat; + if (strcmp(symbol, "stat64") == 0) return (void*)&stat64; + if (strcmp(symbol, "fstat64") == 0) return (void*)&fstat64; + if (strcmp(symbol, "lstat64") == 0) return (void*)&lstat64; + if (strcmp(symbol, "atexit") == 0) return (void*)&atexit; + if (strcmp(symbol, "mknod") == 0) return (void*)&mknod; +# endif + + // we failed to find the symbol + return NULL; } # endif @@ -829,13 +857,13 @@ SymbolAddr* lookupSymbol_ (SymbolName* lbl) SymbolAddr* lookupSymbol_ (SymbolName* lbl) { - IF_DEBUG(linker, debugBelch("lookupSymbol: looking up %s\n", lbl)); + IF_DEBUG(linker, debugBelch("lookupSymbol: looking up '%s'\n", lbl)); ASSERT(symhash != NULL); RtsSymbolInfo *pinfo; if (!ghciLookupSymbolInfo(symhash, lbl, &pinfo)) { - IF_DEBUG(linker, debugBelch("lookupSymbol: symbol not found\n")); + IF_DEBUG(linker, debugBelch("lookupSymbol: symbol '%s' not found, trying dlsym\n", lbl)); # if defined(OBJFORMAT_ELF) return internal_dlsym(lbl); ===================================== testsuite/tests/driver/FullGHCVersion.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE CPP #-} + +module Main where + +main :: IO () +#if defined(__GLASGOW_HASKELL_FULL_VERSION__) +main = putStrLn "__GLASGOW_HASKELL_FULL_VERSION__ is well-defined!" +#else +main = putStrLn "__GLASGOW_HASKELL_FULL_VERSION__ is not defined!" +#endif ===================================== testsuite/tests/driver/FullGHCVersion.stdout ===================================== @@ -0,0 +1 @@ +__GLASGOW_HASKELL_FULL_VERSION__ is well-defined! ===================================== testsuite/tests/driver/all.T ===================================== @@ -282,3 +282,4 @@ test('T16737', test('T17143', exit_code(1), run_command, ['{compiler} T17143.hs -S -fno-code']) test('T17786', unless(opsys('mingw32'), skip), makefile_test, []) test('T18369', normal, compile, ['-O']) +test('FullGHCVersion', normal, compile_and_run, ['-package ghc-boot']) ===================================== testsuite/tests/rts/linker/Makefile ===================================== @@ -96,3 +96,10 @@ linker_error3: "$(TEST_HC)" -c linker_error3.c -o linker_error3_o.o "$(TEST_HC)" linker_error3.o -o linker_error3 -no-hs-main -optc-g -debug -threaded ./linker_error3 linker_error3_o.o + +.PHONY: T7072 +T7072: + "$(TEST_HC)" -c T7072-obj.c -o T7072-obj.o + "$(TEST_HC)" -c T7072-main.c -o T7072-main.o + "$(TEST_HC)" T7072-main.c -o T7072-main -no-hs-main -debug + ./T7072-main T7072-obj.o ===================================== testsuite/tests/rts/linker/T7072-main.c ===================================== @@ -0,0 +1,39 @@ +#include "ghcconfig.h" +#include "Rts.h" +#include +#include + +int main (int argc, char *argv[]) +{ + int r; + char *obj; + + hs_init(&argc, &argv); + + initLinker_(0); + + // Load object file argv[1] repeatedly + + if (argc != 2) { + errorBelch("usage: T7072-main "); + exit(1); + } + + obj = argv[1]; + + r = loadObj(obj); + if (!r) { + debugBelch("loadObj(%s) failed\n", obj); + exit(1); + } + r = resolveObjs(); + if (!r) { + debugBelch("resolveObjs failed\n"); + unloadObj(obj); + exit(1); + } + debugBelch("loading succeeded"); + + hs_exit(); + return 0; +} ===================================== testsuite/tests/rts/linker/T7072-obj.c ===================================== @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +typedef int stat_func(const char*, struct stat*); + +stat_func *foo = &stat; + +void stat_test(void) +{ + struct stat buf; + + printf("About to stat-test.c\n"); + foo("stat-test.c", &buf); + printf("Done\n"); +} ===================================== testsuite/tests/rts/linker/T7072.stderr ===================================== @@ -0,0 +1 @@ +loading succeeded \ No newline at end of file ===================================== testsuite/tests/rts/linker/all.T ===================================== @@ -102,3 +102,10 @@ test('rdynamic', [ unless(opsys('linux') or opsys('mingw32'), skip) , omit_ways(['ghci']) ], compile_and_run, ['-rdynamic -package ghc']) + + +test('T7072', + [extra_files(['T7072-main.c', 'T7072-obj.c']), + unless(opsys('linux'), skip), + req_rts_linker], + makefile_test, ['T7072']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6e5ff48b4b9589de55161048092ae155c9c451c0...e5ba6faf2acb86f873f70c9040c008e0b5fea747 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6e5ff48b4b9589de55161048092ae155c9c451c0...e5ba6faf2acb86f873f70c9040c008e0b5fea747 You're receiving 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 Jul 5 15:16:01 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 11:16:01 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] gitlab-ci: Reintroduce workflow stanza Message-ID: <5f01eeb1f31da_80bf18931818038e8@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 88262e19 by Ben Gamari at 2020-07-05T11:15:47-04:00 gitlab-ci: Reintroduce workflow stanza - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -32,6 +32,15 @@ stages: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' +workflow: + # N.B. Don't run on wip/ branches, instead on run on merge requests. + rules: + - if: $CI_MERGE_REQUEST_ID + - if: $CI_COMMIT_TAG + - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + - if: '$CI_PIPELINE_SOURCE == "web"' + ############################################################ # Runner Tags ############################################################ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/88262e192e69fc71916d47cbdbd8bb7c9a8f1782 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/88262e192e69fc71916d47cbdbd8bb7c9a8f1782 You're receiving 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 Jul 5 15:32:28 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 11:32:28 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T12234 Message-ID: <5f01f28c79e8b_80b3f8490174d38180696c@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T12234 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T12234 You're receiving 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 Jul 5 16:07:48 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 12:07:48 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] 2 commits: testsuite: Allow baseline commit to be set explicitly Message-ID: <5f01fad4e9885_80b3f8490174d381836438@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: 52037aad by Ben Gamari at 2020-07-05T12:07:41-04:00 testsuite: Allow baseline commit to be set explicitly - - - - - 020fc776 by Ben Gamari at 2020-07-05T12:07:41-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 7 changed files: - .gitlab-ci.yml - hadrian/src/Settings/Builders/RunTest.hs - testsuite/driver/perf_notes.py - testsuite/driver/runtests.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/mk/test.mk Changes: ===================================== .gitlab-ci.yml ===================================== @@ -16,6 +16,9 @@ variables: GIT_SUBMODULE_STRATEGY: "recursive" + # Commit used by testsuite driver as performance baseline. + PERF_BASELINE_COMMIT: "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" + stages: - lint # Source linting - quick-build # A very quick smoke-test to weed out broken commits @@ -26,12 +29,26 @@ stages: - testing # head.hackage correctness and compiler performance testing - deploy # push documentation +# Note [The CI Story] +# ~~~~~~~~~~~~~~~~~~~ +# +# There are roughly three different types of pipelines: +# +# - marge-bot merges to `master`. Here we perform an exhaustive validation +# across all of the platforms which we support. In addition, we push +# performance metric notes upstream, providing a persistant record of the +# performance characteristics of the compiler. +# +# - merge requests. Here we perform a slightly less exhaustive battery of +# testing. Namely we omit some configurations (e.g. the unregisterised job). + + workflow: - # N.B.Don't run on wip/ branches, instead on run on merge requests. + # N.B. Don't run on wip/ branches, instead on run on merge requests. rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -78,6 +78,7 @@ runTestBuilderArgs = builder RunTest ? do <*> (maybe False (=="YES") <$> lookupEnv "OS") (testEnv, testMetricsFile) <- expr . liftIO $ (,) <$> lookupEnv "TEST_ENV" <*> lookupEnv "METRICS_FILE" + perfBaseline <- expr . liftIO $ lookupEnv "PERF_BASELINE_COMMIT" threads <- shakeThreads <$> expr getShakeOptions os <- getTestSetting TestHostOS @@ -141,6 +142,7 @@ runTestBuilderArgs = builder RunTest ? do , arg "--config", arg $ "timeout_prog=" ++ show (top -/- timeoutProg) , arg "--config", arg $ "stats_files_dir=" ++ statsFilesDir , arg $ "--threads=" ++ show threads + , emitWhenSet perfBaseline $ \commit -> arg ("--perf-baseline=" ++ show commit) , emitWhenSet testEnv $ \env -> arg ("--test-env=" ++ show env) , emitWhenSet testMetricsFile $ \file -> arg ("--metrics-file=" ++ file) , getTestArgs -- User-provided arguments from command line. ===================================== testsuite/driver/perf_notes.py ===================================== @@ -76,8 +76,7 @@ PerfStat = NamedTuple('PerfStat', [('test_env', TestEnv), # A baseline recovered form stored metrics. Baseline = NamedTuple('Baseline', [('perfStat', PerfStat), - ('commit', GitHash), - ('commitDepth', int)]) + ('commit', GitHash)]) class MetricChange(Enum): # The metric appears to have no baseline and is presumably a new test. @@ -402,7 +401,8 @@ def baseline_metric(commit: GitHash, name: TestName, test_env: TestEnv, metric: MetricName, - way: WayName + way: WayName, + baseline_commit: Optional[GitRef] ) -> Optional[Baseline]: # For performance reasons (in order to avoid calling commit_hash), we assert # commit is already a commit hash. @@ -418,11 +418,18 @@ def baseline_metric(commit: GitHash, def find_baseline(namespace: NoteNamespace, test_env: TestEnv ) -> Optional[Baseline]: + if baseline_commit is not None: + current_metric = get_commit_metric(namespace, baseline_commit, test_env, name, metric, way) + if current_metric is not None: + return Baseline(current_metric, baseline_commit) + else: + return None + for depth, current_commit in list(enumerate(commit_hashes))[1:]: # Check for a metric on this commit. current_metric = get_commit_metric(namespace, current_commit, test_env, name, metric, way) if current_metric is not None: - return Baseline(current_metric, current_commit, depth) + return Baseline(current_metric, current_commit) # Stop if there is an expected change at this commit. In that case # metrics on ancestor commits will not be a valid baseline. @@ -552,7 +559,7 @@ def check_stats_change(actual: PerfStat, result = passed() if not change_allowed: error = str(change) + ' from ' + baseline.perfStat.test_env + \ - ' baseline @ HEAD~' + str(baseline.commitDepth) + ' baseline @ %s' % baseline.commit print(actual.metric, error + ':') result = failBecause('stat ' + error, tag='stat') ===================================== testsuite/driver/runtests.py ===================================== @@ -27,7 +27,7 @@ from testutil import getStdout, Watcher, str_warn, str_info from testglobals import getConfig, ghc_env, getTestRun, TestConfig, \ TestOptions, brokens, PerfMetric from my_typing import TestName -from perf_notes import MetricChange, inside_git_repo, is_worktree_dirty, format_perf_stat +from perf_notes import MetricChange, GitRef, inside_git_repo, is_worktree_dirty, format_perf_stat from junit import junit import term_color from term_color import Color, colored @@ -70,6 +70,7 @@ parser.add_argument("--verbose", type=int, choices=[0,1,2,3,4,5], help="verbose parser.add_argument("--junit", type=argparse.FileType('wb'), help="output testsuite summary in JUnit format") parser.add_argument("--broken-test", action="append", default=[], help="a test name to mark as broken for this run") parser.add_argument("--test-env", default='local', help="Override default chosen test-env.") +parser.add_argument("--perf-baseline", type=GitRef, metavar='COMMIT', help="Baseline commit for performance comparsons.") perf_group.add_argument("--skip-perf-tests", action="store_true", help="skip performance tests") perf_group.add_argument("--only-perf-tests", action="store_true", help="Only do performance tests") @@ -101,6 +102,7 @@ config.metrics_file = args.metrics_file hasMetricsFile = config.metrics_file is not None config.summary_file = args.summary_file config.no_print_summary = args.no_print_summary +config.baseline_commit = args.perf_baseline if args.only: config.only = args.only @@ -422,6 +424,8 @@ else: # Dump metrics data. print("\nPerformance Metrics (test environment: {}):\n".format(config.test_env)) + if config.baseline_commit: + print('Performance baseline: %s\n' % config.baseline_commit) if any(t.metrics): tabulate_metrics(t.metrics) else: ===================================== testsuite/driver/testglobals.py ===================================== @@ -4,7 +4,7 @@ from my_typing import * from pathlib import Path -from perf_notes import MetricChange, PerfStat, Baseline, MetricOracles +from perf_notes import MetricChange, PerfStat, Baseline, MetricOracles, GitRef from datetime import datetime # ----------------------------------------------------------------------------- @@ -160,6 +160,9 @@ class TestConfig: # run. self.broken_tests = set() # type: Set[TestName] + # Baseline commit for performane metric comparisons. + self.baseline_commit = None # type: Optional[GitRef] + # Should we skip performance tests self.skip_perf_tests = False ===================================== testsuite/driver/testlib.py ===================================== @@ -477,7 +477,8 @@ def _collect_stats(name: TestName, opts, metrics, deviation, is_compiler_stats_t metric = '{}/{}'.format(tag, metric_name) def baselineByWay(way, target_commit, metric=metric): return Perf.baseline_metric( \ - target_commit, name, config.test_env, metric, way) + target_commit, name, config.test_env, metric, way, \ + config.baseline_commit ) opts.stats_range_fields[metric] = MetricOracles(baseline=baselineByWay, deviation=deviation) ===================================== testsuite/mk/test.mk ===================================== @@ -226,6 +226,10 @@ ifneq "$(VERBOSE)" "" RUNTEST_OPTS += --verbose=$(VERBOSE) endif +ifneq "$(PERF_TEST_BASELINE_COMMIT)" "" +RUNTEST_OPTS += --perf-baseline=$(PERF_TEST_BASELINE_COMMIT) +endif + ifeq "$(SKIP_PERF_TESTS)" "YES" RUNTEST_OPTS += --skip-perf-tests endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b0a1fa4f278300fdfa1081ef81d6e8e6056eadf9...020fc7769c33b35855ec20a5fad4961895596ed4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b0a1fa4f278300fdfa1081ef81d6e8e6056eadf9...020fc7769c33b35855ec20a5fad4961895596ed4 You're receiving 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 Jul 5 16:20:10 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 12:20:10 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18419 Message-ID: <5f01fdbaaaaf6_80b113262f018399c1@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T18419 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18419 You're receiving 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 Jul 5 16:33:50 2020 From: gitlab at gitlab.haskell.org (Josh Meredith) Date: Sun, 05 Jul 2020 12:33:50 -0400 Subject: [Git][ghc/ghc][wip/pluginExtFields] Fix cost centre position Message-ID: <5f0200ee7aedc_80b113262f018416a0@gitlab.haskell.org.mail> Josh Meredith pushed to branch wip/pluginExtFields at Glasgow Haskell Compiler / GHC Commits: cb00fc3a by Josh Meredith at 2020-07-06T02:33:08+10:00 Fix cost centre position - - - - - 1 changed file: - compiler/GHC/Driver/Main.hs Changes: ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -811,11 +811,10 @@ finish summary tc_result mb_old_hash = do (cg_guts, details) <- {-# SCC "CoreTidy" #-} liftIO $ tidyProgram hsc_env simplified_guts - !partial_iface <- liftIO $ - {-# SCC "GHC.Driver.Main.mkPartialIface" #-} + !partial_iface <- {-# SCC "GHC.Driver.Main.mkPartialIface" #-} -- This `force` saves 2M residency in test T10370 -- See Note [Avoiding space leaks in toIface*] for details. - force <$> (mkPartialIface hsc_env details simplified_guts) + liftIO $ force <$> (mkPartialIface hsc_env details simplified_guts) return HscRecomp { hscs_guts = cg_guts, hscs_mod_location = ms_location summary, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb00fc3a5750a61dc8bdaa9e6bb58442c2343236 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb00fc3a5750a61dc8bdaa9e6bb58442c2343236 You're receiving 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 Jul 5 16:37:25 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 12:37:25 -0400 Subject: [Git][ghc/ghc][wip/T18291] 157 commits: Always use rnImplicitBndrs to bring implicit tyvars into scope Message-ID: <5f0201c566963_80b3f8469a404841841916@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18291 at Glasgow Haskell Compiler / GHC Commits: a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - 3a5525b7 by Ben Gamari at 2020-07-05T12:36:44-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - b55674cc by Ben Gamari at 2020-07-05T12:37:16-04:00 testsuite: Add test for #18291 - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/test-metrics.sh - .gitmodules - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Ppr/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fae75e43568449cef86cf21af278c4efa33dac59...b55674ccd9dc975e01c3ad893b77f4248626fb46 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fae75e43568449cef86cf21af278c4efa33dac59...b55674ccd9dc975e01c3ad893b77f4248626fb46 You're receiving 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 Jul 5 17:50:51 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 13:50:51 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] 5 commits: Improve handling of data type return kinds Message-ID: <5f0212fbf2fac_80b113262f0185891f@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - 067ea370 by Ben Gamari at 2020-07-05T13:50:47-04:00 testsuite: Allow baseline commit to be set explicitly - - - - - 9636134e by Ben Gamari at 2020-07-05T13:50:47-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Driver.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Utils/Instantiate.hs - docs/core-spec/CoreLint.ott - docs/core-spec/CoreSyn.ott - docs/core-spec/core-spec.mng - docs/core-spec/core-spec.pdf - docs/users_guide/phases.rst - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Builders/RunTest.hs - includes/ghc.mk - testsuite/driver/perf_notes.py - testsuite/driver/runtests.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/020fc7769c33b35855ec20a5fad4961895596ed4...9636134e798e5964526dd0c5a82d025f8bf2518d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/020fc7769c33b35855ec20a5fad4961895596ed4...9636134e798e5964526dd0c5a82d025f8bf2518d You're receiving 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 Jul 5 18:16:13 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 14:16:13 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] testsuite: Refactor runtests.py Message-ID: <5f0218edb1ae4_80b3f84960bea14185962a@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: 21200f78 by Ben Gamari at 2020-07-05T14:15:04-04:00 testsuite: Refactor runtests.py Trying to bring some order to the chaos of this module. Starting by moving most code to `main` and breaking out local function bindings. - - - - - 1 changed file: - testsuite/driver/runtests.py Changes: ===================================== testsuite/driver/runtests.py ===================================== @@ -14,6 +14,7 @@ import tempfile import time import re import traceback +import datetime # We don't actually need subprocess in runtests.py, but: # * We do need it in testlibs.py @@ -26,22 +27,14 @@ import subprocess from testutil import getStdout, Watcher, str_warn, str_info from testglobals import getConfig, ghc_env, getTestRun, TestConfig, \ TestOptions, brokens, PerfMetric -from my_typing import TestName +from my_typing import TestName, List from perf_notes import MetricChange, GitRef, inside_git_repo, is_worktree_dirty, format_perf_stat +import perf_notes as Perf from junit import junit import term_color from term_color import Color, colored import cpu_features -# Readline sometimes spews out ANSI escapes for some values of TERM, -# which result in test failures. Thus set TERM to a nice, simple, safe -# value. -os.environ['TERM'] = 'vt100' -ghc_env['TERM'] = 'vt100' - -global config -config = getConfig() # get it from testglobals - def signal_handler(signal, frame): stopNow() @@ -49,189 +42,15 @@ def get_compiler_info() -> TestConfig: """ Overriddden by configuration file. """ raise NotImplementedError -# ----------------------------------------------------------------------------- -# cmd-line options - -parser = argparse.ArgumentParser(description="GHC's testsuite driver") -perf_group = parser.add_mutually_exclusive_group() - -parser.add_argument("-e", action='append', help="A string to execute from the command line.") -parser.add_argument("--config-file", action="append", help="config file") -parser.add_argument("--config", action='append', help="config field") -parser.add_argument("--rootdir", action='append', help="root of tree containing tests (default: .)") -parser.add_argument("--metrics-file", help="file in which to save (append) the performance test metrics. If omitted, git notes will be used.") -parser.add_argument("--summary-file", help="file in which to save the (human-readable) summary") -parser.add_argument("--no-print-summary", action="store_true", help="should we print the summary?") -parser.add_argument("--only", action="append", help="just this test (can be give multiple --only= flags)") -parser.add_argument("--way", action="append", help="just this way") -parser.add_argument("--skipway", action="append", help="skip this way") -parser.add_argument("--threads", type=int, help="threads to run simultaneously") -parser.add_argument("--verbose", type=int, choices=[0,1,2,3,4,5], help="verbose (Values 0 through 5 accepted)") -parser.add_argument("--junit", type=argparse.FileType('wb'), help="output testsuite summary in JUnit format") -parser.add_argument("--broken-test", action="append", default=[], help="a test name to mark as broken for this run") -parser.add_argument("--test-env", default='local', help="Override default chosen test-env.") -parser.add_argument("--perf-baseline", type=GitRef, metavar='COMMIT', help="Baseline commit for performance comparsons.") -perf_group.add_argument("--skip-perf-tests", action="store_true", help="skip performance tests") -perf_group.add_argument("--only-perf-tests", action="store_true", help="Only do performance tests") - -args = parser.parse_args() - -# Initialize variables that are set by the build system with -e -windows = False -darwin = False - -if args.e: - for e in args.e: - exec(e) - -if args.config_file: - for arg in args.config_file: - exec(open(arg).read()) - -if args.config: - for arg in args.config: - field, value = arg.split('=', 1) - setattr(config, field, value) - -all_ways = config.run_ways+config.compile_ways+config.other_ways - -if args.rootdir: - config.rootdirs = args.rootdir - -config.metrics_file = args.metrics_file -hasMetricsFile = config.metrics_file is not None -config.summary_file = args.summary_file -config.no_print_summary = args.no_print_summary -config.baseline_commit = args.perf_baseline - -if args.only: - config.only = args.only - config.run_only_some_tests = True - -if args.way: - for way in args.way: - if way not in all_ways: - print('WARNING: Unknown WAY %s in --way' % way) - else: - config.cmdline_ways += [way] - if way in config.other_ways: - config.run_ways += [way] - config.compile_ways += [way] - -if args.skipway: - for way in args.skipway: - if way not in all_ways: - print('WARNING: Unknown WAY %s in --skipway' % way) - - config.other_ways = [w for w in config.other_ways if w not in args.skipway] - config.run_ways = [w for w in config.run_ways if w not in args.skipway] - config.compile_ways = [w for w in config.compile_ways if w not in args.skipway] - -config.broken_tests |= {TestName(t) for t in args.broken_test} - -if args.threads: - config.threads = args.threads - config.use_threads = True - -if args.verbose is not None: - config.verbose = args.verbose - -# Note force skip perf tests: skip if this is not a git repo (estimated with inside_git_repo) -# and no metrics file is given. In this case there is no way to read the previous commit's -# perf test results, nor a way to store new perf test results. -forceSkipPerfTests = not hasMetricsFile and not inside_git_repo() -config.skip_perf_tests = args.skip_perf_tests or forceSkipPerfTests -config.only_perf_tests = args.only_perf_tests - -if args.test_env: - config.test_env = args.test_env - -config.cygwin = False -config.msys = False - -if windows: - h = os.popen('uname -s', 'r') - v = h.read() - h.close() - if v.startswith("CYGWIN"): - config.cygwin = True - elif v.startswith("MINGW") or v.startswith("MSYS"): -# msys gives "MINGW32" -# msys2 gives "MINGW_NT-6.2" or "MSYS_NT-6.3" - config.msys = True - else: - raise Exception("Can't detect Windows terminal type") - -# Try to use UTF8 -if windows: - import ctypes - # Windows and mingw* Python provide windll, msys2 python provides cdll. - if hasattr(ctypes, 'WinDLL'): - mydll = ctypes.WinDLL # type: ignore - else: - mydll = ctypes.CDLL - - # This actually leaves the terminal in codepage 65001 (UTF8) even - # after python terminates. We ought really remember the old codepage - # and set it back. - kernel32 = mydll('kernel32.dll') - if kernel32.SetConsoleCP(65001) == 0: - raise Exception("Failure calling SetConsoleCP(65001)") - if kernel32.SetConsoleOutputCP(65001) == 0: - raise Exception("Failure calling SetConsoleOutputCP(65001)") - - # register the interrupt handler - signal.signal(signal.SIGINT, signal_handler) -else: - # Try and find a utf8 locale to use - # First see if we already have a UTF8 locale - h = os.popen('locale | grep LC_CTYPE | grep -i utf', 'r') - v = h.read() - h.close() - if v == '': - # We don't, so now see if 'locale -a' works - h = os.popen('locale -a | grep -F .', 'r') - v = h.read() - h.close() - if v != '': - # If it does then use the first utf8 locale that is available - h = os.popen('locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') - v = h.readline().strip() - h.close() - if v != '': - os.environ['LC_ALL'] = v - ghc_env['LC_ALL'] = v - print("setting LC_ALL to", v) - else: - print('WARNING: No UTF8 locale found.') - print('You may get some spurious test failures.') - -# https://stackoverflow.com/a/22254892/1308058 -def supports_colors(): - """ - Returns True if the running system's terminal supports color, and False - otherwise. - """ - plat = sys.platform - supported_platform = plat != 'Pocket PC' and (plat != 'win32' or - 'ANSICON' in os.environ) - # isatty is not always implemented, #6223. - is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() - if not supported_platform or not is_a_tty: - return False - return True - -config.supports_colors = supports_colors() -term_color.enable_color = config.supports_colors - -# This has to come after arg parsing as the args can change the compiler -get_compiler_info() - -# Can't import this earlier as we need to know if threading will be -# enabled or not -from testlib import * +# Globals +config = getConfig() # get it from testglobals +windows = False # type: bool +cygwin = False # type: bool +darwin = False # type: bool +tempdir = '' # type: str -def format_path(path): +def format_path(path) -> str: + global config, windows if windows: if os.pathsep == ':': # If using msys2 python instead of mingw we have to change the drive @@ -246,101 +65,102 @@ def format_path(path): path = re.sub('\\\\', '/', path) return path -# On Windows we need to set $PATH to include the paths to all the DLLs -# in order for the dynamic library tests to work. -if windows or darwin: - pkginfo = getStdout([config.ghc_pkg, 'dump']) - topdir = config.libdir - if windows: - mingw = os.path.abspath(os.path.join(topdir, '../mingw/bin')) - mingw = format_path(mingw) - ghc_env['PATH'] = os.pathsep.join([ghc_env.get("PATH", ""), mingw]) - for line in pkginfo.split('\n'): - if line.startswith('library-dirs:'): - path = line.rstrip() - path = re.sub('^library-dirs: ', '', path) - # Use string.replace instead of re.sub, because re.sub - # interprets backslashes in the replacement string as - # escape sequences. - path = path.replace('$topdir', topdir) - if path.startswith('"'): - path = re.sub('^"(.*)"$', '\\1', path) - path = re.sub('\\\\(.)', '\\1', path) - if windows: - path = format_path(path) - ghc_env['PATH'] = os.pathsep.join([path, ghc_env.get("PATH", "")]) - else: - # darwin - ghc_env['DYLD_LIBRARY_PATH'] = os.pathsep.join([path, ghc_env.get("DYLD_LIBRARY_PATH", "")]) - -testopts_local.x = TestOptions() - -# if timeout == -1 then we try to calculate a sensible value -if config.timeout == -1: - config.timeout = int(read_no_crs(config.top + '/timeout/calibrate.out')) - -print('Timeout is ' + str(config.timeout)) -print('Known ways: ' + ', '.join(config.other_ways)) -print('Run ways: ' + ', '.join(config.run_ways)) -print('Compile ways: ' + ', '.join(config.compile_ways)) - -# Try get allowed performance changes from the git commit. -try: - config.allowed_perf_changes = Perf.get_allowed_perf_changes() -except subprocess.CalledProcessError: - print('Failed to get allowed metric changes from the HEAD git commit message.') - -print('Allowing performance changes in: ' + ', '.join(config.allowed_perf_changes.keys())) - -# ----------------------------------------------------------------------------- -# The main dude - -if config.rootdirs == []: - config.rootdirs = ['.'] - -t_files = list(findTFiles(config.rootdirs)) - -print('Found', len(t_files), '.T files...') - -t = getTestRun() # type: TestRun - -# Avoid cmd.exe built-in 'date' command on Windows -t.start_time = datetime.datetime.now() - -print('Beginning test run at', t.start_time.strftime("%c %Z")) - -# For reference -try: - print('Detected CPU features: ', cpu_features.get_cpu_features()) -except Exception as e: - print('Failed to detect CPU features: ', e) - -sys.stdout.flush() -# we output text, which cannot be unbuffered -sys.stdout = os.fdopen(sys.__stdout__.fileno(), "w") - -if config.local: - tempdir = '' -else: - # See note [Running tests in /tmp] - tempdir = tempfile.mkdtemp('', 'ghctest-') - - # opts.testdir should be quoted when used, to make sure the testsuite - # keeps working when it contains backward slashes, for example from - # using os.path.join. Windows native and mingw* python - # (/mingw64/bin/python) set `os.path.sep = '\\'`, while msys2 python - # (/bin/python, /usr/bin/python or /usr/local/bin/python) sets - # `os.path.sep = '/'`. - # To catch usage of unquoted opts.testdir early, insert some spaces into - # tempdir. - tempdir = os.path.join(tempdir, 'test spaces') +# https://stackoverflow.com/a/22254892/1308058 +def supports_colors(): + """ + Returns True if the running system's terminal supports color, and False + otherwise. + """ + plat = sys.platform + supported_platform = plat != 'Pocket PC' and (plat != 'win32' or + 'ANSICON' in os.environ) + # isatty is not always implemented, #6223. + is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() + if not supported_platform or not is_a_tty: + return False + return True -def cleanup_and_exit(exitcode): - if config.cleanup and tempdir: - shutil.rmtree(tempdir, ignore_errors=True) - exit(exitcode) +def setup_locale() -> None: + """ + Try to use UTF-8 + """ + global windows -def tabulate_metrics(metrics: List[PerfMetric]) -> None: + if windows: + import ctypes + # Windows and mingw* Python provide windll, msys2 python provides cdll. + if hasattr(ctypes, 'WinDLL'): + mydll = ctypes.WinDLL # type: ignore + else: + mydll = ctypes.CDLL + + # This actually leaves the terminal in codepage 65001 (UTF8) even + # after python terminates. We ought really remember the old codepage + # and set it back. + kernel32 = mydll('kernel32.dll') + if kernel32.SetConsoleCP(65001) == 0: + raise Exception("Failure calling SetConsoleCP(65001)") + if kernel32.SetConsoleOutputCP(65001) == 0: + raise Exception("Failure calling SetConsoleOutputCP(65001)") + + # register the interrupt handler + signal.signal(signal.SIGINT, signal_handler) + else: + # Try and find a utf8 locale to use + # First see if we already have a UTF8 locale + h = os.popen('locale | grep LC_CTYPE | grep -i utf', 'r') + v = h.read() + h.close() + if v == '': + # We don't, so now see if 'locale -a' works + h = os.popen('locale -a | grep -F .', 'r') + v = h.read() + h.close() + if v != '': + # If it does then use the first utf8 locale that is available + h = os.popen('locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') + v = h.readline().strip() + h.close() + if v != '': + os.environ['LC_ALL'] = v + ghc_env['LC_ALL'] = v + print("setting LC_ALL to", v) + else: + print('WARNING: No UTF8 locale found.') + print('You may get some spurious test failures.') + +def setup_path() -> None: + """ + On Windows we need to set $PATH to include the paths to all the DLLs + in order for the dynamic library tests to work. + """ + global windows, darwin + if windows or darwin: + pkginfo = getStdout([config.ghc_pkg, 'dump']) + topdir = config.libdir + if windows: + mingw = os.path.abspath(os.path.join(topdir, '../mingw/bin')) + mingw = format_path(mingw) + ghc_env['PATH'] = os.pathsep.join([ghc_env.get("PATH", ""), mingw]) + for line in pkginfo.split('\n'): + if line.startswith('library-dirs:'): + path = line.rstrip() + path = re.sub('^library-dirs: ', '', path) + # Use string.replace instead of re.sub, because re.sub + # interprets backslashes in the replacement string as + # escape sequences. + path = path.replace('$topdir', topdir) + if path.startswith('"'): + path = re.sub('^"(.*)"$', '\\1', path) + path = re.sub('\\\\(.)', '\\1', path) + if windows: + path = format_path(path) + ghc_env['PATH'] = os.pathsep.join([path, ghc_env.get("PATH", "")]) + else: + # darwin + ghc_env['DYLD_LIBRARY_PATH'] = os.pathsep.join([path, ghc_env.get("DYLD_LIBRARY_PATH", "")]) + +def tabulate_perf_metrics(metrics: List[PerfMetric]) -> None: for metric in sorted(metrics, key=lambda m: (m.stat.test, m.stat.way, m.stat.metric)): print("{test:24} {metric:40} {value:15.3f}".format( test = "{}({})".format(metric.stat.test, metric.stat.way), @@ -360,81 +180,21 @@ def tabulate_metrics(metrics: List[PerfMetric]) -> None: rel = rel )) -# First collect all the tests to be run -t_files_ok = True -for file in t_files: - if_verbose(2, '====> Scanning %s' % file) - newTestDir(tempdir, os.path.dirname(file)) - try: - with io.open(file, encoding='utf8') as f: - src = f.read() - - exec(src) - except Exception as e: - traceback.print_exc() - framework_fail(None, None, 'exception: %s' % e) - t_files_ok = False - -for name in config.only: - if t_files_ok: - # See Note [Mutating config.only] - framework_fail(name, None, 'test not found') - else: - # Let user fix .T file errors before reporting on unfound tests. - # The reason the test can not be found is likely because of those - # .T file errors. - pass - -if config.list_broken: - print('') - print('Broken tests:') - print('\n '.join('#{ticket}({a}/{b})'.format(ticket=ticket, a=a, b=b) - for ticket, a, b in brokens)) - print('') - - if t.framework_failures: - print('WARNING:', len(t.framework_failures), 'framework failures!') - print('') -else: - # completion watcher - watcher = Watcher(len(parallelTests)) - - # Now run all the tests - try: - for oneTest in parallelTests: - if stopping(): - break - oneTest(watcher) - - # wait for parallel tests to finish - if not stopping(): - watcher.wait() - - # Run the following tests purely sequential - config.use_threads = False - for oneTest in aloneTests: - if stopping(): - break - oneTest(watcher) - except KeyboardInterrupt: - pass - - # flush everything before we continue - sys.stdout.flush() - +def print_perf_summary(skip_perf_tests: bool, force_skip_perf_tests: bool) -> None: # Dump metrics data. + t = getTestRun() print("\nPerformance Metrics (test environment: {}):\n".format(config.test_env)) if config.baseline_commit: print('Performance baseline: %s\n' % config.baseline_commit) if any(t.metrics): - tabulate_metrics(t.metrics) + tabulate_perf_metrics(t.metrics) else: print("\nNone collected.") print("") - # Warn if had to force skip perf tests (see Note force skip perf tests). + # Warn if had to force skip perf tests (see Note [force skip perf tests]). spacing = " " - if forceSkipPerfTests and not args.skip_perf_tests: + if force_skip_perf_tests and not skip_perf_tests: print() print(str_warn('Skipping All Performance Tests') + ' `git` exited with non-zero exit code.') print(spacing + 'Git is required because performance test results are compared with ancestor git commits\' results (stored with git notes).') @@ -455,11 +215,11 @@ else: ' the missing metrics. Alternatively, a baseline may be' + \ ' recovered from ci results once fetched:\n\n' + \ spacing + 'git fetch ' + \ - 'https://gitlab.haskell.org/ghc/ghc-performance-notes.git' + \ - ' refs/notes/perf:refs/notes/' + Perf.CiNamespace + 'https://gitlab.haskell.org/ghc/ghc-performance-notes.git' + \ + ' refs/notes/perf:refs/notes/' + Perf.CiNamespace else: reason = "this is not a git repo so the previous git commit's" + \ - " metrics cannot be loaded from git notes:" + " metrics cannot be loaded from git notes:" fix = "" print() print(str_warn('Missing Baseline Metrics') + \ @@ -478,40 +238,309 @@ else: print(Perf.allow_changes_string([(m.change, m.stat) for m in t.metrics])) print('-' * 25) - summary(t, sys.stdout, config.no_print_summary, config.supports_colors) +def main() -> None: + global config, windows, darwin, tempdir + + # Readline sometimes spews out ANSI escapes for some values of TERM, + # which result in test failures. Thus set TERM to a nice, simple, safe + # value. + os.environ['TERM'] = 'vt100' + ghc_env['TERM'] = 'vt100' + + # ----------------------------------------------------------------------------- + # cmd-line options + + parser = argparse.ArgumentParser(description="GHC's testsuite driver") + perf_group = parser.add_mutually_exclusive_group() + + parser.add_argument("-e", action='append', help="A string to execute from the command line.") + parser.add_argument("--config-file", action="append", help="config file") + parser.add_argument("--config", action='append', help="config field") + parser.add_argument("--rootdir", action='append', help="root of tree containing tests (default: .)") + parser.add_argument("--metrics-file", help="file in which to save (append) the performance test metrics. If omitted, git notes will be used.") + parser.add_argument("--summary-file", help="file in which to save the (human-readable) summary") + parser.add_argument("--no-print-summary", action="store_true", help="should we print the summary?") + parser.add_argument("--only", action="append", help="just this test (can be give multiple --only= flags)") + parser.add_argument("--way", action="append", help="just this way") + parser.add_argument("--skipway", action="append", help="skip this way") + parser.add_argument("--threads", type=int, help="threads to run simultaneously") + parser.add_argument("--verbose", type=int, choices=[0,1,2,3,4,5], help="verbose (Values 0 through 5 accepted)") + parser.add_argument("--junit", type=argparse.FileType('wb'), help="output testsuite summary in JUnit format") + parser.add_argument("--broken-test", action="append", default=[], help="a test name to mark as broken for this run") + parser.add_argument("--test-env", default='local', help="Override default chosen test-env.") + parser.add_argument("--perf-baseline", type=GitRef, metavar='COMMIT', help="Baseline commit for performance comparsons.") + perf_group.add_argument("--skip-perf-tests", action="store_true", help="skip performance tests") + perf_group.add_argument("--only-perf-tests", action="store_true", help="Only do performance tests") + + args = parser.parse_args() + + # Initialize variables that are set by the build system with -e + windows = False + darwin = False + + if args.e: + for e in args.e: + exec(e) + + if args.config_file: + for arg in args.config_file: + exec(open(arg).read()) + + if args.config: + for arg in args.config: + field, value = arg.split('=', 1) + setattr(config, field, value) + + all_ways = config.run_ways+config.compile_ways+config.other_ways + + if args.rootdir: + config.rootdirs = args.rootdir + + config.metrics_file = args.metrics_file + hasMetricsFile = config.metrics_file is not None + config.summary_file = args.summary_file + config.no_print_summary = args.no_print_summary + config.baseline_commit = args.perf_baseline + + if args.only: + config.only = args.only + config.run_only_some_tests = True + + if args.way: + for way in args.way: + if way not in all_ways: + print('WARNING: Unknown WAY %s in --way' % way) + else: + config.cmdline_ways += [way] + if way in config.other_ways: + config.run_ways += [way] + config.compile_ways += [way] - # Write perf stats if any exist or if a metrics file is specified. - stats = [stat for (_, stat, __) in t.metrics] # type: List[PerfStat] - if hasMetricsFile: - print('Appending ' + str(len(stats)) + ' stats to file: ' + config.metrics_file) - with open(config.metrics_file, 'a') as f: - f.write("\n" + Perf.format_perf_stat(stats)) - elif inside_git_repo() and any(stats): - if is_worktree_dirty(): - print() - print(str_warn('Performance Metrics NOT Saved') + \ - ' working tree is dirty. Commit changes or use ' + \ - '--metrics-file to save metrics to a file.') + if args.skipway: + for way in args.skipway: + if way not in all_ways: + print('WARNING: Unknown WAY %s in --skipway' % way) + + config.other_ways = [w for w in config.other_ways if w not in args.skipway] + config.run_ways = [w for w in config.run_ways if w not in args.skipway] + config.compile_ways = [w for w in config.compile_ways if w not in args.skipway] + + config.broken_tests |= {TestName(t) for t in args.broken_test} + + if args.threads: + config.threads = args.threads + config.use_threads = True + + if args.verbose is not None: + config.verbose = args.verbose + + # Note [force skip perf tests] + # skip if this is not a git repo (estimated with inside_git_repo) + # and no metrics file is given. In this case there is no way to read the previous commit's + # perf test results, nor a way to store new perf test results. + force_skip_perf_tests = not hasMetricsFile and not inside_git_repo() + config.skip_perf_tests = args.skip_perf_tests or force_skip_perf_tests + config.only_perf_tests = args.only_perf_tests + + if args.test_env: + config.test_env = args.test_env + + config.cygwin = False + config.msys = False + + if windows: + h = os.popen('uname -s', 'r') + v = h.read() + h.close() + if v.startswith("CYGWIN"): + config.cygwin = True + elif v.startswith("MINGW") or v.startswith("MSYS"): + # msys gives "MINGW32" + # msys2 gives "MINGW_NT-6.2" or "MSYS_NT-6.3" + config.msys = True else: - Perf.append_perf_stat(stats) + raise Exception("Can't detect Windows terminal type") + + setup_locale() + + config.supports_colors = supports_colors() + term_color.enable_color = config.supports_colors + + # This has to come after arg parsing as the args can change the compiler + get_compiler_info() - # Write summary - if config.summary_file: - with open(config.summary_file, 'w') as f: - summary(t, f) + # Can't import this earlier as we need to know if threading will be + # enabled or not + import testlib - if args.junit: - junit(t).write(args.junit) + setup_path() -if len(t.unexpected_failures) > 0 or \ - len(t.unexpected_stat_failures) > 0 or \ - len(t.unexpected_passes) > 0 or \ - len(t.framework_failures) > 0: - exitcode = 1 -else: - exitcode = 0 + testlib.testopts_local.x = TestOptions() -cleanup_and_exit(exitcode) + # if timeout == -1 then we try to calculate a sensible value + if config.timeout == -1: + config.timeout = int(testlib.read_no_crs(config.top + '/timeout/calibrate.out')) + + print('Timeout is ' + str(config.timeout)) + print('Known ways: ' + ', '.join(config.other_ways)) + print('Run ways: ' + ', '.join(config.run_ways)) + print('Compile ways: ' + ', '.join(config.compile_ways)) + + # Try get allowed performance changes from the git commit. + try: + config.allowed_perf_changes = Perf.get_allowed_perf_changes() + except subprocess.CalledProcessError: + print('Failed to get allowed metric changes from the HEAD git commit message.') + + print('Allowing performance changes in: ' + ', '.join(config.allowed_perf_changes.keys())) + + # ----------------------------------------------------------------------------- + # The main dude + + if config.rootdirs == []: + config.rootdirs = ['.'] + + t_files = list(testlib.findTFiles(config.rootdirs)) + + print('Found', len(t_files), '.T files...') + + t = getTestRun() # type: testlib.TestRun + + # Avoid cmd.exe built-in 'date' command on Windows + t.start_time = datetime.datetime.now() + + print('Beginning test run at', t.start_time.strftime("%c %Z")) + + # For reference + try: + print('Detected CPU features: ', cpu_features.get_cpu_features()) + except Exception as e: + print('Failed to detect CPU features: ', e) + + sys.stdout.flush() + # we output text, which cannot be unbuffered + sys.stdout = os.fdopen(sys.__stdout__.fileno(), "w") + + if config.local: + tempdir = '' + else: + # See note [Running tests in /tmp] + tempdir = tempfile.mkdtemp('', 'ghctest-') + + # opts.testdir should be quoted when used, to make sure the testsuite + # keeps working when it contains backward slashes, for example from + # using os.path.join. Windows native and mingw* python + # (/mingw64/bin/python) set `os.path.sep = '\\'`, while msys2 python + # (/bin/python, /usr/bin/python or /usr/local/bin/python) sets + # `os.path.sep = '/'`. + # To catch usage of unquoted opts.testdir early, insert some spaces into + # tempdir. + tempdir = os.path.join(tempdir, 'test spaces') + + def cleanup_and_exit(exitcode: int): + if config.cleanup and tempdir: + shutil.rmtree(tempdir, ignore_errors=True) + exit(exitcode) + + # First collect all the tests to be run + t_files_ok = True + for file in t_files: + testlib.if_verbose(2, '====> Scanning %s' % file) + testlib.newTestDir(tempdir, os.path.dirname(file)) + try: + with io.open(file, encoding='utf8') as f: + src = f.read() + + exec(src) + except Exception as e: + traceback.print_exc() + testlib.framework_fail(None, None, 'exception: %s' % e) + t_files_ok = False + + for name in config.only: + if t_files_ok: + # See Note [Mutating config.only] + testlib.framework_fail(name, None, 'test not found') + else: + # Let user fix .T file errors before reporting on unfound tests. + # The reason the test can not be found is likely because of those + # .T file errors. + pass + + if config.list_broken: + print('') + print('Broken tests:') + print('\n '.join('#{ticket}({a}/{b})'.format(ticket=ticket, a=a, b=b) + for ticket, a, b in brokens)) + print('') + + if t.framework_failures: + print('WARNING:', len(t.framework_failures), 'framework failures!') + print('') + else: + # completion watcher + watcher = Watcher(len(testlib.parallelTests)) + + # Now run all the tests + try: + for oneTest in testlib.parallelTests: + if testlib.stopping(): + break + oneTest(watcher) + + # wait for parallel tests to finish + if not testlib.stopping(): + watcher.wait() + + # Run the following tests purely sequential + config.use_threads = False + for oneTest in testlib.aloneTests: + if testlib.stopping(): + break + oneTest(watcher) + except KeyboardInterrupt: + pass + + # flush everything before we continue + sys.stdout.flush() + + print_perf_summary( + force_skip_perf_tests=force_skip_perf_tests, + skip_perf_tests=args.skip_perf_tests) + testlib.summary(t, sys.stdout, config.no_print_summary, config.supports_colors) + + # Write perf stats if any exist or if a metrics file is specified. + stats = [stat for (_, stat, __) in t.metrics] # type: List[Perf.PerfStat] + if hasMetricsFile: + print('Appending ' + str(len(stats)) + ' stats to file: ' + config.metrics_file) + with open(config.metrics_file, 'a') as f: + f.write("\n" + Perf.format_perf_stat(stats)) + elif inside_git_repo() and any(stats): + if is_worktree_dirty(): + print() + print(str_warn('Performance Metrics NOT Saved') + \ + ' working tree is dirty. Commit changes or use ' + \ + '--metrics-file to save metrics to a file.') + else: + Perf.append_perf_stat(stats) + + # Write summary + if config.summary_file: + with open(config.summary_file, 'w') as f: + testlib.summary(t, f) + + if args.junit: + junit(t).write(args.junit) + + if len(t.unexpected_failures) > 0 or \ + len(t.unexpected_stat_failures) > 0 or \ + len(t.unexpected_passes) > 0 or \ + len(t.framework_failures) > 0: + exitcode = 1 + else: + exitcode = 0 + + cleanup_and_exit(exitcode) # Note [Running tests in /tmp] # @@ -544,3 +573,6 @@ cleanup_and_exit(exitcode) # # [1] # https://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/separate_compilation.html#output-files + +if __name__ == '__main__': + main() \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21200f783bb3c87b52bdb6e44d5b9cd4f7aae6ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21200f783bb3c87b52bdb6e44d5b9cd4f7aae6ba You're receiving 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 Jul 5 18:23:44 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 14:23:44 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] testsuite: Refactor runtests.py Message-ID: <5f021ab0bf746_80b3f8496a302dc1860115@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: 2680da51 by Ben Gamari at 2020-07-05T14:23:37-04:00 testsuite: Refactor runtests.py Trying to bring some order to the chaos of this module. Starting by moving most code to `main` and breaking out local function bindings. - - - - - 1 changed file: - testsuite/driver/runtests.py Changes: ===================================== testsuite/driver/runtests.py ===================================== @@ -14,6 +14,7 @@ import tempfile import time import re import traceback +import datetime # We don't actually need subprocess in runtests.py, but: # * We do need it in testlibs.py @@ -26,212 +27,26 @@ import subprocess from testutil import getStdout, Watcher, str_warn, str_info from testglobals import getConfig, ghc_env, getTestRun, TestConfig, \ TestOptions, brokens, PerfMetric -from my_typing import TestName +from my_typing import TestName, List from perf_notes import MetricChange, GitRef, inside_git_repo, is_worktree_dirty, format_perf_stat +import perf_notes as Perf from junit import junit import term_color from term_color import Color, colored import cpu_features -# Readline sometimes spews out ANSI escapes for some values of TERM, -# which result in test failures. Thus set TERM to a nice, simple, safe -# value. -os.environ['TERM'] = 'vt100' -ghc_env['TERM'] = 'vt100' - -global config -config = getConfig() # get it from testglobals - def signal_handler(signal, frame): stopNow() -def get_compiler_info() -> TestConfig: - """ Overriddden by configuration file. """ - raise NotImplementedError - -# ----------------------------------------------------------------------------- -# cmd-line options - -parser = argparse.ArgumentParser(description="GHC's testsuite driver") -perf_group = parser.add_mutually_exclusive_group() - -parser.add_argument("-e", action='append', help="A string to execute from the command line.") -parser.add_argument("--config-file", action="append", help="config file") -parser.add_argument("--config", action='append', help="config field") -parser.add_argument("--rootdir", action='append', help="root of tree containing tests (default: .)") -parser.add_argument("--metrics-file", help="file in which to save (append) the performance test metrics. If omitted, git notes will be used.") -parser.add_argument("--summary-file", help="file in which to save the (human-readable) summary") -parser.add_argument("--no-print-summary", action="store_true", help="should we print the summary?") -parser.add_argument("--only", action="append", help="just this test (can be give multiple --only= flags)") -parser.add_argument("--way", action="append", help="just this way") -parser.add_argument("--skipway", action="append", help="skip this way") -parser.add_argument("--threads", type=int, help="threads to run simultaneously") -parser.add_argument("--verbose", type=int, choices=[0,1,2,3,4,5], help="verbose (Values 0 through 5 accepted)") -parser.add_argument("--junit", type=argparse.FileType('wb'), help="output testsuite summary in JUnit format") -parser.add_argument("--broken-test", action="append", default=[], help="a test name to mark as broken for this run") -parser.add_argument("--test-env", default='local', help="Override default chosen test-env.") -parser.add_argument("--perf-baseline", type=GitRef, metavar='COMMIT', help="Baseline commit for performance comparsons.") -perf_group.add_argument("--skip-perf-tests", action="store_true", help="skip performance tests") -perf_group.add_argument("--only-perf-tests", action="store_true", help="Only do performance tests") - -args = parser.parse_args() - -# Initialize variables that are set by the build system with -e -windows = False -darwin = False - -if args.e: - for e in args.e: - exec(e) - -if args.config_file: - for arg in args.config_file: - exec(open(arg).read()) - -if args.config: - for arg in args.config: - field, value = arg.split('=', 1) - setattr(config, field, value) - -all_ways = config.run_ways+config.compile_ways+config.other_ways - -if args.rootdir: - config.rootdirs = args.rootdir - -config.metrics_file = args.metrics_file -hasMetricsFile = config.metrics_file is not None -config.summary_file = args.summary_file -config.no_print_summary = args.no_print_summary -config.baseline_commit = args.perf_baseline - -if args.only: - config.only = args.only - config.run_only_some_tests = True - -if args.way: - for way in args.way: - if way not in all_ways: - print('WARNING: Unknown WAY %s in --way' % way) - else: - config.cmdline_ways += [way] - if way in config.other_ways: - config.run_ways += [way] - config.compile_ways += [way] - -if args.skipway: - for way in args.skipway: - if way not in all_ways: - print('WARNING: Unknown WAY %s in --skipway' % way) - - config.other_ways = [w for w in config.other_ways if w not in args.skipway] - config.run_ways = [w for w in config.run_ways if w not in args.skipway] - config.compile_ways = [w for w in config.compile_ways if w not in args.skipway] - -config.broken_tests |= {TestName(t) for t in args.broken_test} - -if args.threads: - config.threads = args.threads - config.use_threads = True - -if args.verbose is not None: - config.verbose = args.verbose - -# Note force skip perf tests: skip if this is not a git repo (estimated with inside_git_repo) -# and no metrics file is given. In this case there is no way to read the previous commit's -# perf test results, nor a way to store new perf test results. -forceSkipPerfTests = not hasMetricsFile and not inside_git_repo() -config.skip_perf_tests = args.skip_perf_tests or forceSkipPerfTests -config.only_perf_tests = args.only_perf_tests - -if args.test_env: - config.test_env = args.test_env - -config.cygwin = False -config.msys = False - -if windows: - h = os.popen('uname -s', 'r') - v = h.read() - h.close() - if v.startswith("CYGWIN"): - config.cygwin = True - elif v.startswith("MINGW") or v.startswith("MSYS"): -# msys gives "MINGW32" -# msys2 gives "MINGW_NT-6.2" or "MSYS_NT-6.3" - config.msys = True - else: - raise Exception("Can't detect Windows terminal type") - -# Try to use UTF8 -if windows: - import ctypes - # Windows and mingw* Python provide windll, msys2 python provides cdll. - if hasattr(ctypes, 'WinDLL'): - mydll = ctypes.WinDLL # type: ignore - else: - mydll = ctypes.CDLL - - # This actually leaves the terminal in codepage 65001 (UTF8) even - # after python terminates. We ought really remember the old codepage - # and set it back. - kernel32 = mydll('kernel32.dll') - if kernel32.SetConsoleCP(65001) == 0: - raise Exception("Failure calling SetConsoleCP(65001)") - if kernel32.SetConsoleOutputCP(65001) == 0: - raise Exception("Failure calling SetConsoleOutputCP(65001)") - - # register the interrupt handler - signal.signal(signal.SIGINT, signal_handler) -else: - # Try and find a utf8 locale to use - # First see if we already have a UTF8 locale - h = os.popen('locale | grep LC_CTYPE | grep -i utf', 'r') - v = h.read() - h.close() - if v == '': - # We don't, so now see if 'locale -a' works - h = os.popen('locale -a | grep -F .', 'r') - v = h.read() - h.close() - if v != '': - # If it does then use the first utf8 locale that is available - h = os.popen('locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') - v = h.readline().strip() - h.close() - if v != '': - os.environ['LC_ALL'] = v - ghc_env['LC_ALL'] = v - print("setting LC_ALL to", v) - else: - print('WARNING: No UTF8 locale found.') - print('You may get some spurious test failures.') - -# https://stackoverflow.com/a/22254892/1308058 -def supports_colors(): - """ - Returns True if the running system's terminal supports color, and False - otherwise. - """ - plat = sys.platform - supported_platform = plat != 'Pocket PC' and (plat != 'win32' or - 'ANSICON' in os.environ) - # isatty is not always implemented, #6223. - is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() - if not supported_platform or not is_a_tty: - return False - return True - -config.supports_colors = supports_colors() -term_color.enable_color = config.supports_colors - -# This has to come after arg parsing as the args can change the compiler -get_compiler_info() - -# Can't import this earlier as we need to know if threading will be -# enabled or not -from testlib import * +# Globals +config = getConfig() # get it from testglobals +windows = False # type: bool +cygwin = False # type: bool +darwin = False # type: bool +tempdir = '' # type: str -def format_path(path): +def format_path(path) -> str: + global config, windows if windows: if os.pathsep == ':': # If using msys2 python instead of mingw we have to change the drive @@ -246,101 +61,102 @@ def format_path(path): path = re.sub('\\\\', '/', path) return path -# On Windows we need to set $PATH to include the paths to all the DLLs -# in order for the dynamic library tests to work. -if windows or darwin: - pkginfo = getStdout([config.ghc_pkg, 'dump']) - topdir = config.libdir - if windows: - mingw = os.path.abspath(os.path.join(topdir, '../mingw/bin')) - mingw = format_path(mingw) - ghc_env['PATH'] = os.pathsep.join([ghc_env.get("PATH", ""), mingw]) - for line in pkginfo.split('\n'): - if line.startswith('library-dirs:'): - path = line.rstrip() - path = re.sub('^library-dirs: ', '', path) - # Use string.replace instead of re.sub, because re.sub - # interprets backslashes in the replacement string as - # escape sequences. - path = path.replace('$topdir', topdir) - if path.startswith('"'): - path = re.sub('^"(.*)"$', '\\1', path) - path = re.sub('\\\\(.)', '\\1', path) - if windows: - path = format_path(path) - ghc_env['PATH'] = os.pathsep.join([path, ghc_env.get("PATH", "")]) - else: - # darwin - ghc_env['DYLD_LIBRARY_PATH'] = os.pathsep.join([path, ghc_env.get("DYLD_LIBRARY_PATH", "")]) - -testopts_local.x = TestOptions() - -# if timeout == -1 then we try to calculate a sensible value -if config.timeout == -1: - config.timeout = int(read_no_crs(config.top + '/timeout/calibrate.out')) - -print('Timeout is ' + str(config.timeout)) -print('Known ways: ' + ', '.join(config.other_ways)) -print('Run ways: ' + ', '.join(config.run_ways)) -print('Compile ways: ' + ', '.join(config.compile_ways)) - -# Try get allowed performance changes from the git commit. -try: - config.allowed_perf_changes = Perf.get_allowed_perf_changes() -except subprocess.CalledProcessError: - print('Failed to get allowed metric changes from the HEAD git commit message.') - -print('Allowing performance changes in: ' + ', '.join(config.allowed_perf_changes.keys())) - -# ----------------------------------------------------------------------------- -# The main dude - -if config.rootdirs == []: - config.rootdirs = ['.'] - -t_files = list(findTFiles(config.rootdirs)) - -print('Found', len(t_files), '.T files...') - -t = getTestRun() # type: TestRun - -# Avoid cmd.exe built-in 'date' command on Windows -t.start_time = datetime.datetime.now() - -print('Beginning test run at', t.start_time.strftime("%c %Z")) - -# For reference -try: - print('Detected CPU features: ', cpu_features.get_cpu_features()) -except Exception as e: - print('Failed to detect CPU features: ', e) - -sys.stdout.flush() -# we output text, which cannot be unbuffered -sys.stdout = os.fdopen(sys.__stdout__.fileno(), "w") - -if config.local: - tempdir = '' -else: - # See note [Running tests in /tmp] - tempdir = tempfile.mkdtemp('', 'ghctest-') - - # opts.testdir should be quoted when used, to make sure the testsuite - # keeps working when it contains backward slashes, for example from - # using os.path.join. Windows native and mingw* python - # (/mingw64/bin/python) set `os.path.sep = '\\'`, while msys2 python - # (/bin/python, /usr/bin/python or /usr/local/bin/python) sets - # `os.path.sep = '/'`. - # To catch usage of unquoted opts.testdir early, insert some spaces into - # tempdir. - tempdir = os.path.join(tempdir, 'test spaces') +# https://stackoverflow.com/a/22254892/1308058 +def supports_colors(): + """ + Returns True if the running system's terminal supports color, and False + otherwise. + """ + plat = sys.platform + supported_platform = plat != 'Pocket PC' and (plat != 'win32' or + 'ANSICON' in os.environ) + # isatty is not always implemented, #6223. + is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() + if not supported_platform or not is_a_tty: + return False + return True -def cleanup_and_exit(exitcode): - if config.cleanup and tempdir: - shutil.rmtree(tempdir, ignore_errors=True) - exit(exitcode) +def setup_locale() -> None: + """ + Try to use UTF-8 + """ + global windows -def tabulate_metrics(metrics: List[PerfMetric]) -> None: + if windows: + import ctypes + # Windows and mingw* Python provide windll, msys2 python provides cdll. + if hasattr(ctypes, 'WinDLL'): + mydll = ctypes.WinDLL # type: ignore + else: + mydll = ctypes.CDLL + + # This actually leaves the terminal in codepage 65001 (UTF8) even + # after python terminates. We ought really remember the old codepage + # and set it back. + kernel32 = mydll('kernel32.dll') + if kernel32.SetConsoleCP(65001) == 0: + raise Exception("Failure calling SetConsoleCP(65001)") + if kernel32.SetConsoleOutputCP(65001) == 0: + raise Exception("Failure calling SetConsoleOutputCP(65001)") + + # register the interrupt handler + signal.signal(signal.SIGINT, signal_handler) + else: + # Try and find a utf8 locale to use + # First see if we already have a UTF8 locale + h = os.popen('locale | grep LC_CTYPE | grep -i utf', 'r') + v = h.read() + h.close() + if v == '': + # We don't, so now see if 'locale -a' works + h = os.popen('locale -a | grep -F .', 'r') + v = h.read() + h.close() + if v != '': + # If it does then use the first utf8 locale that is available + h = os.popen('locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') + v = h.readline().strip() + h.close() + if v != '': + os.environ['LC_ALL'] = v + ghc_env['LC_ALL'] = v + print("setting LC_ALL to", v) + else: + print('WARNING: No UTF8 locale found.') + print('You may get some spurious test failures.') + +def setup_path() -> None: + """ + On Windows we need to set $PATH to include the paths to all the DLLs + in order for the dynamic library tests to work. + """ + global windows, darwin + if windows or darwin: + pkginfo = getStdout([config.ghc_pkg, 'dump']) + topdir = config.libdir + if windows: + mingw = os.path.abspath(os.path.join(topdir, '../mingw/bin')) + mingw = format_path(mingw) + ghc_env['PATH'] = os.pathsep.join([ghc_env.get("PATH", ""), mingw]) + for line in pkginfo.split('\n'): + if line.startswith('library-dirs:'): + path = line.rstrip() + path = re.sub('^library-dirs: ', '', path) + # Use string.replace instead of re.sub, because re.sub + # interprets backslashes in the replacement string as + # escape sequences. + path = path.replace('$topdir', topdir) + if path.startswith('"'): + path = re.sub('^"(.*)"$', '\\1', path) + path = re.sub('\\\\(.)', '\\1', path) + if windows: + path = format_path(path) + ghc_env['PATH'] = os.pathsep.join([path, ghc_env.get("PATH", "")]) + else: + # darwin + ghc_env['DYLD_LIBRARY_PATH'] = os.pathsep.join([path, ghc_env.get("DYLD_LIBRARY_PATH", "")]) + +def tabulate_perf_metrics(metrics: List[PerfMetric]) -> None: for metric in sorted(metrics, key=lambda m: (m.stat.test, m.stat.way, m.stat.metric)): print("{test:24} {metric:40} {value:15.3f}".format( test = "{}({})".format(metric.stat.test, metric.stat.way), @@ -360,81 +176,21 @@ def tabulate_metrics(metrics: List[PerfMetric]) -> None: rel = rel )) -# First collect all the tests to be run -t_files_ok = True -for file in t_files: - if_verbose(2, '====> Scanning %s' % file) - newTestDir(tempdir, os.path.dirname(file)) - try: - with io.open(file, encoding='utf8') as f: - src = f.read() - - exec(src) - except Exception as e: - traceback.print_exc() - framework_fail(None, None, 'exception: %s' % e) - t_files_ok = False - -for name in config.only: - if t_files_ok: - # See Note [Mutating config.only] - framework_fail(name, None, 'test not found') - else: - # Let user fix .T file errors before reporting on unfound tests. - # The reason the test can not be found is likely because of those - # .T file errors. - pass - -if config.list_broken: - print('') - print('Broken tests:') - print('\n '.join('#{ticket}({a}/{b})'.format(ticket=ticket, a=a, b=b) - for ticket, a, b in brokens)) - print('') - - if t.framework_failures: - print('WARNING:', len(t.framework_failures), 'framework failures!') - print('') -else: - # completion watcher - watcher = Watcher(len(parallelTests)) - - # Now run all the tests - try: - for oneTest in parallelTests: - if stopping(): - break - oneTest(watcher) - - # wait for parallel tests to finish - if not stopping(): - watcher.wait() - - # Run the following tests purely sequential - config.use_threads = False - for oneTest in aloneTests: - if stopping(): - break - oneTest(watcher) - except KeyboardInterrupt: - pass - - # flush everything before we continue - sys.stdout.flush() - +def print_perf_summary(skip_perf_tests: bool, force_skip_perf_tests: bool) -> None: # Dump metrics data. + t = getTestRun() print("\nPerformance Metrics (test environment: {}):\n".format(config.test_env)) if config.baseline_commit: print('Performance baseline: %s\n' % config.baseline_commit) if any(t.metrics): - tabulate_metrics(t.metrics) + tabulate_perf_metrics(t.metrics) else: print("\nNone collected.") print("") - # Warn if had to force skip perf tests (see Note force skip perf tests). + # Warn if had to force skip perf tests (see Note [force skip perf tests]). spacing = " " - if forceSkipPerfTests and not args.skip_perf_tests: + if force_skip_perf_tests and not skip_perf_tests: print() print(str_warn('Skipping All Performance Tests') + ' `git` exited with non-zero exit code.') print(spacing + 'Git is required because performance test results are compared with ancestor git commits\' results (stored with git notes).') @@ -455,11 +211,11 @@ else: ' the missing metrics. Alternatively, a baseline may be' + \ ' recovered from ci results once fetched:\n\n' + \ spacing + 'git fetch ' + \ - 'https://gitlab.haskell.org/ghc/ghc-performance-notes.git' + \ - ' refs/notes/perf:refs/notes/' + Perf.CiNamespace + 'https://gitlab.haskell.org/ghc/ghc-performance-notes.git' + \ + ' refs/notes/perf:refs/notes/' + Perf.CiNamespace else: reason = "this is not a git repo so the previous git commit's" + \ - " metrics cannot be loaded from git notes:" + " metrics cannot be loaded from git notes:" fix = "" print() print(str_warn('Missing Baseline Metrics') + \ @@ -478,40 +234,314 @@ else: print(Perf.allow_changes_string([(m.change, m.stat) for m in t.metrics])) print('-' * 25) - summary(t, sys.stdout, config.no_print_summary, config.supports_colors) +def main() -> None: + global config, windows, darwin, tempdir + + # Readline sometimes spews out ANSI escapes for some values of TERM, + # which result in test failures. Thus set TERM to a nice, simple, safe + # value. + os.environ['TERM'] = 'vt100' + ghc_env['TERM'] = 'vt100' + + def get_compiler_info() -> TestConfig: + """ Overriddden by configuration file. """ + raise NotImplementedError + + + # ----------------------------------------------------------------------------- + # cmd-line options + + parser = argparse.ArgumentParser(description="GHC's testsuite driver") + perf_group = parser.add_mutually_exclusive_group() + + parser.add_argument("-e", action='append', help="A string to execute from the command line.") + parser.add_argument("--config-file", action="append", help="config file") + parser.add_argument("--config", action='append', help="config field") + parser.add_argument("--rootdir", action='append', help="root of tree containing tests (default: .)") + parser.add_argument("--metrics-file", help="file in which to save (append) the performance test metrics. If omitted, git notes will be used.") + parser.add_argument("--summary-file", help="file in which to save the (human-readable) summary") + parser.add_argument("--no-print-summary", action="store_true", help="should we print the summary?") + parser.add_argument("--only", action="append", help="just this test (can be give multiple --only= flags)") + parser.add_argument("--way", action="append", help="just this way") + parser.add_argument("--skipway", action="append", help="skip this way") + parser.add_argument("--threads", type=int, help="threads to run simultaneously") + parser.add_argument("--verbose", type=int, choices=[0,1,2,3,4,5], help="verbose (Values 0 through 5 accepted)") + parser.add_argument("--junit", type=argparse.FileType('wb'), help="output testsuite summary in JUnit format") + parser.add_argument("--broken-test", action="append", default=[], help="a test name to mark as broken for this run") + parser.add_argument("--test-env", default='local', help="Override default chosen test-env.") + parser.add_argument("--perf-baseline", type=GitRef, metavar='COMMIT', help="Baseline commit for performance comparsons.") + perf_group.add_argument("--skip-perf-tests", action="store_true", help="skip performance tests") + perf_group.add_argument("--only-perf-tests", action="store_true", help="Only do performance tests") + + args = parser.parse_args() + + # Initialize variables that are set by the build system with -e + windows = False + darwin = False + + if args.e: + for e in args.e: + exec(e) + + if args.config_file: + for arg in args.config_file: + exec(open(arg).read()) + + if args.config: + for arg in args.config: + field, value = arg.split('=', 1) + setattr(config, field, value) + + all_ways = config.run_ways+config.compile_ways+config.other_ways + + if args.rootdir: + config.rootdirs = args.rootdir + + config.metrics_file = args.metrics_file + hasMetricsFile = config.metrics_file is not None + config.summary_file = args.summary_file + config.no_print_summary = args.no_print_summary + config.baseline_commit = args.perf_baseline + + if args.only: + config.only = args.only + config.run_only_some_tests = True + + if args.way: + for way in args.way: + if way not in all_ways: + print('WARNING: Unknown WAY %s in --way' % way) + else: + config.cmdline_ways += [way] + if way in config.other_ways: + config.run_ways += [way] + config.compile_ways += [way] - # Write perf stats if any exist or if a metrics file is specified. - stats = [stat for (_, stat, __) in t.metrics] # type: List[PerfStat] - if hasMetricsFile: - print('Appending ' + str(len(stats)) + ' stats to file: ' + config.metrics_file) - with open(config.metrics_file, 'a') as f: - f.write("\n" + Perf.format_perf_stat(stats)) - elif inside_git_repo() and any(stats): - if is_worktree_dirty(): - print() - print(str_warn('Performance Metrics NOT Saved') + \ - ' working tree is dirty. Commit changes or use ' + \ - '--metrics-file to save metrics to a file.') + if args.skipway: + for way in args.skipway: + if way not in all_ways: + print('WARNING: Unknown WAY %s in --skipway' % way) + + config.other_ways = [w for w in config.other_ways if w not in args.skipway] + config.run_ways = [w for w in config.run_ways if w not in args.skipway] + config.compile_ways = [w for w in config.compile_ways if w not in args.skipway] + + config.broken_tests |= {TestName(t) for t in args.broken_test} + + if args.threads: + config.threads = args.threads + config.use_threads = True + + if args.verbose is not None: + config.verbose = args.verbose + + # Note [force skip perf tests] + # skip if this is not a git repo (estimated with inside_git_repo) + # and no metrics file is given. In this case there is no way to read the previous commit's + # perf test results, nor a way to store new perf test results. + force_skip_perf_tests = not hasMetricsFile and not inside_git_repo() + config.skip_perf_tests = args.skip_perf_tests or force_skip_perf_tests + config.only_perf_tests = args.only_perf_tests + + if args.test_env: + config.test_env = args.test_env + + config.cygwin = False + config.msys = False + + if windows: + h = os.popen('uname -s', 'r') + v = h.read() + h.close() + if v.startswith("CYGWIN"): + config.cygwin = True + elif v.startswith("MINGW") or v.startswith("MSYS"): + # msys gives "MINGW32" + # msys2 gives "MINGW_NT-6.2" or "MSYS_NT-6.3" + config.msys = True else: - Perf.append_perf_stat(stats) + raise Exception("Can't detect Windows terminal type") + + setup_locale() + + config.supports_colors = supports_colors() + term_color.enable_color = config.supports_colors + + # This has to come after arg parsing as the args can change the compiler + get_compiler_info() - # Write summary - if config.summary_file: - with open(config.summary_file, 'w') as f: - summary(t, f) + # Can't import this earlier as we need to know if threading will be + # enabled or not + import testlib - if args.junit: - junit(t).write(args.junit) + setup_path() -if len(t.unexpected_failures) > 0 or \ - len(t.unexpected_stat_failures) > 0 or \ - len(t.unexpected_passes) > 0 or \ - len(t.framework_failures) > 0: - exitcode = 1 -else: - exitcode = 0 + testlib.testopts_local.x = TestOptions() -cleanup_and_exit(exitcode) + # if timeout == -1 then we try to calculate a sensible value + if config.timeout == -1: + config.timeout = int(testlib.read_no_crs(config.top + '/timeout/calibrate.out')) + + print('Timeout is ' + str(config.timeout)) + print('Known ways: ' + ', '.join(config.other_ways)) + print('Run ways: ' + ', '.join(config.run_ways)) + print('Compile ways: ' + ', '.join(config.compile_ways)) + + # Try get allowed performance changes from the git commit. + try: + config.allowed_perf_changes = Perf.get_allowed_perf_changes() + except subprocess.CalledProcessError: + print('Failed to get allowed metric changes from the HEAD git commit message.') + + print('Allowing performance changes in: ' + ', '.join(config.allowed_perf_changes.keys())) + + # ----------------------------------------------------------------------------- + # The main dude + + if config.rootdirs == []: + config.rootdirs = ['.'] + + t_files = list(testlib.findTFiles(config.rootdirs)) + + print('Found', len(t_files), '.T files...') + + t = getTestRun() # type: testlib.TestRun + + # Avoid cmd.exe built-in 'date' command on Windows + t.start_time = datetime.datetime.now() + + print('Beginning test run at', t.start_time.strftime("%c %Z")) + + # For reference + try: + print('Detected CPU features: ', cpu_features.get_cpu_features()) + except Exception as e: + print('Failed to detect CPU features: ', e) + + sys.stdout.flush() + # we output text, which cannot be unbuffered + sys.stdout = os.fdopen(sys.__stdout__.fileno(), "w") + + if config.local: + tempdir = '' + else: + # See note [Running tests in /tmp] + tempdir = tempfile.mkdtemp('', 'ghctest-') + + # opts.testdir should be quoted when used, to make sure the testsuite + # keeps working when it contains backward slashes, for example from + # using os.path.join. Windows native and mingw* python + # (/mingw64/bin/python) set `os.path.sep = '\\'`, while msys2 python + # (/bin/python, /usr/bin/python or /usr/local/bin/python) sets + # `os.path.sep = '/'`. + # To catch usage of unquoted opts.testdir early, insert some spaces into + # tempdir. + tempdir = os.path.join(tempdir, 'test spaces') + + def cleanup_and_exit(exitcode: int): + if config.cleanup and tempdir: + shutil.rmtree(tempdir, ignore_errors=True) + exit(exitcode) + + # First collect all the tests to be run + t_files_ok = True + for file in t_files: + testlib.if_verbose(2, '====> Scanning %s' % file) + testlib.newTestDir(tempdir, os.path.dirname(file)) + try: + with io.open(file, encoding='utf8') as f: + src = f.read() + + exec(src) + except Exception as e: + traceback.print_exc() + testlib.framework_fail(None, None, 'exception: %s' % e) + t_files_ok = False + + for name in config.only: + if t_files_ok: + # See Note [Mutating config.only] + testlib.framework_fail(name, None, 'test not found') + else: + # Let user fix .T file errors before reporting on unfound tests. + # The reason the test can not be found is likely because of those + # .T file errors. + pass + + if config.list_broken: + print('') + print('Broken tests:') + print('\n '.join('#{ticket}({a}/{b})'.format(ticket=ticket, a=a, b=b) + for ticket, a, b in brokens)) + print('') + + if t.framework_failures: + print('WARNING:', len(t.framework_failures), 'framework failures!') + print('') + else: + # completion watcher + watcher = Watcher(len(testlib.parallelTests)) + + # Now run all the tests + try: + for oneTest in testlib.parallelTests: + if testlib.stopping(): + break + oneTest(watcher) + + # wait for parallel tests to finish + if not testlib.stopping(): + watcher.wait() + + # Run the following tests purely sequential + config.use_threads = False + for oneTest in testlib.aloneTests: + if testlib.stopping(): + break + oneTest(watcher) + except KeyboardInterrupt: + pass + + # flush everything before we continue + sys.stdout.flush() + + print_perf_summary( + force_skip_perf_tests=force_skip_perf_tests, + skip_perf_tests=args.skip_perf_tests) + testlib.summary(t, sys.stdout, config.no_print_summary, config.supports_colors) + + # Write perf stats if any exist or if a metrics file is specified. + stats = [stat for (_, stat, __) in t.metrics] # type: List[Perf.PerfStat] + if hasMetricsFile: + print('Appending ' + str(len(stats)) + ' stats to file: ' + config.metrics_file) + with open(config.metrics_file, 'a') as f: + f.write("\n" + Perf.format_perf_stat(stats)) + elif inside_git_repo() and any(stats): + if is_worktree_dirty(): + print() + print(str_warn('Performance Metrics NOT Saved') + \ + ' working tree is dirty. Commit changes or use ' + \ + '--metrics-file to save metrics to a file.') + else: + Perf.append_perf_stat(stats) + + # Write summary + if config.summary_file: + with open(config.summary_file, 'w') as f: + testlib.summary(t, f) + + if args.junit: + junit(t).write(args.junit) + + if len(t.unexpected_failures) > 0 or \ + len(t.unexpected_stat_failures) > 0 or \ + len(t.unexpected_passes) > 0 or \ + len(t.framework_failures) > 0: + exitcode = 1 + else: + exitcode = 0 + + cleanup_and_exit(exitcode) # Note [Running tests in /tmp] # @@ -544,3 +574,6 @@ cleanup_and_exit(exitcode) # # [1] # https://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/separate_compilation.html#output-files + +if __name__ == '__main__': + main() \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2680da517ec368e3f13867c2e1a7b79e6d193b4b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2680da517ec368e3f13867c2e1a7b79e6d193b4b You're receiving 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 Jul 5 19:56:20 2020 From: gitlab at gitlab.haskell.org (Gabor Greif) Date: Sun, 05 Jul 2020 15:56:20 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ggreif-libtool Message-ID: <5f0230649bb0e_80b3f84960bea1418611de@gitlab.haskell.org.mail> Gabor Greif pushed new branch wip/ggreif-libtool at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ggreif-libtool You're receiving 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 Jul 5 21:04:46 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sun, 05 Jul 2020 17:04:46 -0400 Subject: [Git][ghc/ghc][wip/az/exactprint] Proof of Concept implementation of in-tree API Annotations Message-ID: <5f02406eb7e48_80b3f849c2be408186432@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/exactprint at Glasgow Haskell Compiler / GHC Commits: 195c9d4f by Alan Zimmerman at 2020-07-05T22:03:02+01:00 Proof of Concept implementation of in-tree API Annotations This MR introduces a possible machinery to introduce API Annotations into the TTG extension points. It is intended to be a concrete example for discussion. It still needs to process comments. ---- Work in progress, adding more TTG extensions for annotations. And fixing ppr round-trip tests by being able to blank out in-tree annotations, as done with SrcSpans. This is needed for the case of class Foo a where for which current ppr does not print the "where". Rename AA to AddApiAnn and AA to AddAnn Add XConPatIn and XConPatOut Rebase ---- First pass at bringing in LocatedA for API anns in locations Treatment of ECP in parsing is provisional at this stage, leads to some horribly stuff in Parser.y and RdrHsSyn. It is an extensive but not invasive change. I think (AZ). Locally it reports some parsing tests using less memory. Add ApiAnns to the HsExpr data structure. rebase. Change HsMatchContext and HsStmtContext to use an id, not a GhcPass parameter. Add ApiAnns to Hs/Types Rebase Rebased 2020-03-25 WIP on in-tree annotations Includes updating HsModule Imports LocateA ImportDecl so we can hang AnnSemi off it A whole bunch of stuff more InjectivityAnn and FamEqn now have annotations in them Add annotations to context srcspan ---- In-tree annotations: LHsDecl and LHsBind LocatedA ---- WIP on in-tree annotations ---- in-tree annotations: LHsType is now LocatedA ---- FunDeps is now also a HS data type ---- WIP. Added LocatedA to Pat, Expr, Decl And worked some more through Parser.y ---- LStmt now Located ---- Finished working through Parser.y, tests seem ok failures relate to annotations. Adding test infrastructure for check-exact Like check-ppr, but checking for an exact reproduction of the parsed source file. Starting to work on actual exact printer Bring in ApiAnnName As an alternative for LocatedA, to be used for names only. Carrying extra name adornments, such as locations of backticks, parens, etc. Working on changing ApiAnnName to accurately reflect actual usage Get rid of AnnApiName in favour of LocatedN Working on check-exact. Making progress Working on the ghc-exact bit Progress, can reproduce the first Test.hs file. Move API Annotations out of the extensions to annotations - - - - - 20 changed files: - .gitmodules - compiler/GHC.hs - compiler/GHC/Data/BooleanFormula.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - + compiler/GHC/Hs/Exact.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Expr.hs-boot - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Stats.hs - compiler/GHC/Hs/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/195c9d4ffa8b39b4acdf66770d17051ae5ed4337 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/195c9d4ffa8b39b4acdf66770d17051ae5ed4337 You're receiving 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 Jul 5 23:14:15 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 19:14:15 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] 2 commits: testsuite: Refactor compiler configuration Message-ID: <5f025ec76ac36_80b3f84960bea141872631@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: 8617a7ff by Ben Gamari at 2020-07-05T17:25:53-04:00 testsuite: Refactor compiler configuration - - - - - 1678340e by Ben Gamari at 2020-07-05T19:13:59-04:00 Further refactoring - - - - - 8 changed files: - hadrian/src/Settings/Builders/RunTest.hs - − testsuite/config/ghc - + testsuite/config/testsuite_config.py - testsuite/driver/runtests.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/mk/test.mk - testsuite/tests/concurrent/prog002/all.T Changes: ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -105,38 +105,38 @@ runTestBuilderArgs = builder RunTest ? do , pure [ "--rootdir=" ++ testdir | testdir <- rootdirs ] , arg "-e", arg $ "windows=" ++ show windowsHost , arg "-e", arg $ "darwin=" ++ show osxHost - , arg "-e", arg $ "config.local=False" - , arg "-e", arg $ "config.cleanup=" ++ show (not keepFiles) - , arg "-e", arg $ "config.accept=" ++ show accept - , arg "-e", arg $ "config.accept_platform=" ++ show acceptPlatform - , arg "-e", arg $ "config.accept_os=" ++ show acceptOS - , arg "-e", arg $ "config.exeext=" ++ quote (if null exe then "" else "."<>exe) - , arg "-e", arg $ "config.compiler_debugged=" ++ + , arg "--config", arg $ "local=False" + , arg "--config", arg $ "cleanup=" ++ show (not keepFiles) + , arg "--config", arg $ "accept=" ++ show accept + , arg "--config", arg $ "accept_platform=" ++ show acceptPlatform + , arg "--config", arg $ "accept_os=" ++ show acceptOS + , arg "--config", arg $ "exeext=" ++ quote (if null exe then "" else "."<>exe) + , arg "--config", arg $ "compiler_debugged=" ++ show debugged , arg "-e", arg $ asBool "ghc_with_native_codegen=" withNativeCodeGen - , arg "-e", arg $ "config.have_interp=" ++ show withInterpreter - , arg "-e", arg $ "config.unregisterised=" ++ show unregisterised + , arg "--config", arg $ "have_interp=" ++ show withInterpreter + , arg "--config", arg $ "unregisterised=" ++ show unregisterised - , arg "-e", arg $ "ghc_compiler_always_flags=" ++ quote ghcFlags - , arg "-e", arg $ asBool "ghc_with_dynamic_rts=" (hasRtsWay "dyn") - , arg "-e", arg $ asBool "ghc_with_threaded_rts=" (hasRtsWay "thr") - , arg "-e", arg $ asBool "config.have_vanilla=" (hasLibWay vanilla) - , arg "-e", arg $ asBool "config.have_dynamic=" (hasLibWay dynamic) - , arg "-e", arg $ asBool "config.have_profiling=" (hasLibWay profiling) - , arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) - , arg "-e", arg $ asBool "ghc_with_smp=" withSMP - , arg "-e", arg $ asBool "ghc_with_llvm=" withLlvm + , arg "--extra-hc-flag", arg (quote ghcFlags) + , arg "--config", arg $ asBool "ghc_with_dynamic_rts=" (hasRtsWay "dyn") + , arg "--config", arg $ asBool "ghc_with_threaded_rts=" (hasRtsWay "thr") + , arg "--config", arg $ asBool "have_vanilla=" (hasLibWay vanilla) + , arg "--config", arg $ asBool "have_dynamic=" (hasLibWay dynamic) + , arg "--config", arg $ asBool "have_profiling=" (hasLibWay profiling) + , arg "--config", arg $ asBool "have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) + , arg "--config", arg $ asBool "ghc_with_smp=" withSMP + , arg "--config", arg $ asBool "ghc_with_llvm=" withLlvm - , arg "-e", arg $ "config.ghc_dynamic_by_default=" ++ show hasDynamicByDefault - , arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic + , arg "--config", arg $ "ghc_dynamic_by_default=" ++ show hasDynamicByDefault + , arg "--config", arg $ "ghc_dynamic=" ++ show hasDynamic - , arg "-e", arg $ "config.top=" ++ show (top -/- "testsuite") - , arg "-e", arg $ "config.wordsize=" ++ show wordsize - , arg "-e", arg $ "config.os=" ++ show os - , arg "-e", arg $ "config.arch=" ++ show arch - , arg "-e", arg $ "config.platform=" ++ show platform + , arg "--config", arg $ "top=" ++ show (top -/- "testsuite") + , arg "--config", arg $ "wordsize=" ++ show wordsize + , arg "--config", arg $ "os=" ++ show os + , arg "--config", arg $ "arch=" ++ show arch + , arg "--config", arg $ "platform=" ++ show platform , arg "--config", arg $ "gs=gs" -- Use the default value as in test.mk , arg "--config", arg $ "timeout_prog=" ++ show (top -/- timeoutProg) ===================================== testsuite/config/ghc deleted ===================================== @@ -1,266 +0,0 @@ -# vim: set filetype=python: - -import re - -# Testsuite configuration setup for GHC -# -# This file is Python source -# -config.compiler_always_flags = ghc_compiler_always_flags.split() - -# By default, the 'normal' and 'hpc' ways are enabled. In addition, certain -# ways are enabled automatically if this GHC supports them. Ways that fall in -# this group are 'optasm', 'optllvm', 'profasm', 'threaded1', 'threaded2', -# 'profthreaded', 'ghci', and whichever of 'static/dyn' is not this GHC's -# default mode. Other ways should be set explicitly from .T files. -config.compile_ways = ['normal', 'hpc'] -config.run_ways = ['normal', 'hpc'] - -# ways that are not enabled by default, but can always be invoked explicitly -config.other_ways = ['prof', 'normal_h', - 'prof_hc_hb','prof_hb', - 'prof_hd','prof_hy','prof_hr', - 'sanity', - 'threaded1_ls', 'threaded2_hT', 'debug_numa', - 'llvm', 'debugllvm', - 'profllvm', 'profoptllvm', 'profthreadedllvm', - 'debug', - 'ghci-ext', 'ghci-ext-prof', - 'ext-interp', - 'nonmoving', - 'nonmoving_thr', - 'nonmoving_thr_ghc', - 'compacting_gc', - ] - -if ghc_with_native_codegen: - config.compile_ways.append('optasm') - config.run_ways.append('optasm') - -if config.have_profiling: - config.compile_ways.append('profasm') - config.run_ways.append('profasm') - -if config.have_interp: - config.run_ways.append('ghci') - -if ghc_with_threaded_rts: - config.run_ways.append('threaded1') - if ghc_with_smp: - config.have_smp = True - config.run_ways.append('threaded2') - if config.speed == 0: - config.run_ways.append('nonmoving_thr') - -if ghc_with_dynamic_rts: - config.have_shared_libs = True - -if config.ghc_dynamic_by_default and config.have_vanilla == 1: - config.run_ways.append('static') -else: - if ghc_with_dynamic_rts: - config.run_ways.append('dyn') - -if (config.have_profiling and ghc_with_threaded_rts): - config.run_ways.append('profthreaded') - -if (ghc_with_llvm and not config.unregisterised): - config.compile_ways.append('optllvm') - config.run_ways.append('optllvm') - -config.way_flags = { - 'normal' : [], - 'normal_h' : [], - 'g1' : [], - 'nursery_chunks' : [], - 'debug_numa' : ['-threaded', '-debug'], - 'optasm' : ['-O', '-fasm'], - 'llvm' : ['-fllvm'], - 'optllvm' : ['-O', '-fllvm'], - 'debugllvm' : ['-fllvm', '-keep-llvm-files'], - 'prof' : ['-prof', '-static', '-fprof-auto', '-fasm'], - 'prof_no_auto' : ['-prof', '-static', '-fasm'], - 'profasm' : ['-O', '-prof', '-static', '-fprof-auto'], - 'profthreaded' : ['-O', '-prof', '-static', '-fprof-auto', '-threaded'], - 'ghci' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '+RTS', '-I0.1', '-RTS'] + (['-fghci-leak-check'] if not config.compiler_debugged else []), - 'sanity' : ['-debug'], - 'threaded1' : ['-threaded', '-debug'], - 'threaded1_ls' : ['-threaded', '-debug'], - 'threaded2' : ['-O', '-threaded', '-eventlog'], - 'threaded2_hT' : ['-O', '-threaded'], - 'hpc' : ['-O', '-fhpc'], - 'prof_hc_hb' : ['-O', '-prof', '-static', '-fprof-auto'], - 'prof_hb' : ['-O', '-prof', '-static', '-fprof-auto'], - 'prof_hd' : ['-O', '-prof', '-static', '-fprof-auto'], - 'prof_hy' : ['-O', '-prof', '-static', '-fprof-auto'], - 'prof_hr' : ['-O', '-prof', '-static', '-fprof-auto'], - 'dyn' : ['-O', '-dynamic'], - 'static' : ['-O', '-static'], - 'debug' : ['-O', '-g', '-dannot-lint'], - # llvm variants... - 'profllvm' : ['-prof', '-static', '-fprof-auto', '-fllvm'], - 'profoptllvm' : ['-O', '-prof', '-static', '-fprof-auto', '-fllvm'], - 'profthreadedllvm' : ['-O', '-prof', '-static', '-fprof-auto', '-threaded', '-fllvm'], - 'ghci-ext' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '-fexternal-interpreter', '+RTS', '-I0.1', '-RTS'], - 'ghci-ext-prof' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '-fexternal-interpreter', '-prof', '+RTS', '-I0.1', '-RTS'], - 'ext-interp' : ['-fexternal-interpreter'], - 'nonmoving' : [], - 'nonmoving_thr': ['-threaded'], - 'nonmoving_thr_ghc': ['+RTS', '-xn', '-N2', '-RTS', '-threaded'], - 'compacting_gc': [], - } - -config.way_rts_flags = { - 'normal' : [], - 'normal_h' : ['-h'], # works without -prof - 'g1' : ['-G1'], - 'nursery_chunks' : ['-n32k'], - 'debug_numa' : ['-N2', '--debug-numa=2'], - 'optasm' : [], - 'llvm' : [], - 'optllvm' : [], - 'debugllvm' : [], - 'prof' : ['-p'], - 'prof_no_auto' : ['-p'], - 'profasm' : ['-hc', '-p'], # test heap profiling too - 'profthreaded' : ['-p'], - 'ghci' : [], - 'sanity' : ['-DS'], - 'threaded1' : [], - 'threaded1_ls' : ['-ls'], - 'threaded2' : ['-N2', '-ls'], - 'threaded2_hT' : ['-N2', '-hT'], - 'hpc' : [], - 'prof_hc_hb' : ['-hc', '-hbvoid'], - 'prof_hb' : ['-hb'], - 'prof_hd' : ['-hd'], - 'prof_hy' : ['-hy'], - 'prof_hr' : ['-hr'], - 'dyn' : [], - 'static' : [], - 'debug' : [], - # llvm variants... - 'profllvm' : ['-p'], - 'profoptllvm' : ['-hc', '-p'], - 'profthreadedllvm' : ['-p'], - 'ghci-ext' : [], - 'ghci-ext-prof' : [], - 'ext-interp' : [], - 'nonmoving' : ['-xn'], - 'nonmoving_thr' : ['-xn', '-N2'], - 'nonmoving_thr_ghc': ['-xn', '-N2'], - 'compacting_gc': ['-c'], - } - -# Useful classes of ways that can be used with only_ways(), omit_ways() and -# expect_broken_for(). - -prof_ways = [x[0] for x in config.way_flags.items() - if '-prof' in x[1]] - -threaded_ways = [x[0] for x in config.way_flags.items() - if '-threaded' in x[1] or 'ghci' == x[0]] - -# Ways which run with multiple capabilities -concurrent_ways = [name for name, flags in config.way_flags.items() - if '-threaded' in flags or 'ghci' == name - if '-N2' in config.way_rts_flags.get(name, [])] - -opt_ways = [x[0] for x in config.way_flags.items() - if '-O' in x[1]] - -llvm_ways = [x[0] for x in config.way_flags.items() - if '-fflvm' in x[1]] - - -def get_compiler_info(): - s = getStdout([config.compiler, '--info']) - s = re.sub('[\r\n]', '', s) - compilerInfoDict = dict(eval(s)) - s = getStdout([config.compiler, '+RTS', '--info']) - s = re.sub('[\r\n]', '', s) - rtsInfoDict = dict(eval(s)) - - config.have_ncg = compilerInfoDict.get("Have native code generator", "NO") == "YES" - - # Whether GHC itself was built using the LLVM backend. We need to know this - # since some tests in ext-interp fail when stage2 ghc is built using - # LLVM. See #16087. - # - # The condition here is a bit approximate: we assume that if stage2 doesn't - # have the NCG and isn't unregisterised then it must be using the LLVM - # backend by default. - config.ghc_built_by_llvm = not config.have_ncg and not config.unregisterised - - config.have_RTS_linker = compilerInfoDict.get("target has RTS linker", "NO") == "YES" - # external interpreter needs RTS linker support - # If the field is not present (GHC 8.0 and earlier), assume we don't - # have -fexternal-interpreter (though GHC 8.0 actually does) - # so we can still run most tests. - config.have_ext_interp = compilerInfoDict.get("target has RTS linker", "NO") == "YES" - - # See Note [Replacing backward slashes in config.libdir]. - config.libdir = compilerInfoDict['LibDir'].replace('\\', '/') - - if re.match(".*_p(_.*|$)", rtsInfoDict["RTS way"]): - config.compiler_profiled = True - else: - config.compiler_profiled = False - - try: - config.package_conf_cache_file = compilerInfoDict["Global Package DB"] + '/package.cache' - except: - config.package_conf_cache_file = '' - - # See Note [WayFlags] - if config.ghc_dynamic: - config.ghc_th_way_flags = "-dynamic" - config.ghci_way_flags = "-dynamic" - config.plugin_way_flags = "-dynamic" - config.ghc_th_way = "dyn" - config.ghc_plugin_way = "dyn" - elif config.compiler_profiled: - config.ghc_th_way_flags = "-prof" - config.ghci_way_flags = "-prof" - config.plugin_way_flags = "-prof" - config.ghc_th_way = "prof" - config.ghc_plugin_way = "prof" - else: - config.ghc_th_way_flags = "-static" - config.ghci_way_flags = "-static" - config.plugin_way_flags = "-static" - config.ghc_th_way = "normal" - config.ghc_plugin_way = "normal" - -# Note [Replacing backward slashes in config.libdir] -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# We *do* need to replace backslashes in config.libdir, for the following -# reason: -# -# * Tests use config.libdir as follows: -# -# extra_run_opts('"' + config.libdir + '"') -# -# The double quotes are there because config.libdir might contain -# spaces. -# -# * This string is then written /as is/ to .genscript in -# testlib.interpreter_run: -# -# script.write(':set args ' + opts.extra_run_opts + '\n') -# -# * But GHCi expects the arguments to ':set args' to be proper Haskell -# strings (when they are quoted), with backslashes escaped. Since -# config.libdir contains single backslash characters, tests such as T5313 -# will fail for WAY=ghci with "Pattern match failure in do expression". -# -# Arguably the above code for writing `:set args` should be smarter. This -# is tricky to get right though, because in GHCI `:set args foo\bar` (no -# double quotes) works perfectly fine, and is interpreted as the Haskell -# string "foo\\bar". Therefore, simply escaping all backward slashes in -# opts.extra_run_opts before concatenating it with ':set args' is not right -# either. -# -# Replacing backslashes to forward slashes in config.libdir works around the -# problem. ===================================== testsuite/config/testsuite_config.py ===================================== @@ -0,0 +1,276 @@ +# vim: set filetype=python: + +import re + +class TestsuiteConfig: + @staticmethod + def init_config(config: TestConfig) + raise NotImplemented + + @staticmethod + def get_compiler_info(config: TestConfig) -> None: + raise NotImplemented + +class GHCTestsuiteConfig(TestsuiteConfig): + """ + Testsuite configuration setup for GHC + """ + + @staticmethod + def init_config(config: TestConfig): + # By default, the 'normal' and 'hpc' ways are enabled. In addition, certain + # ways are enabled automatically if this GHC supports them. Ways that fall in + # this group are 'optasm', 'optllvm', 'profasm', 'threaded1', 'threaded2', + # 'profthreaded', 'ghci', and whichever of 'static/dyn' is not this GHC's + # default mode. Other ways should be set explicitly from .T files. + config.compile_ways = ['normal', 'hpc'] + config.run_ways = ['normal', 'hpc'] + + # ways that are not enabled by default, but can always be invoked explicitly + config.other_ways = ['prof', 'normal_h', + 'prof_hc_hb','prof_hb', + 'prof_hd','prof_hy','prof_hr', + 'sanity', + 'threaded1_ls', 'threaded2_hT', 'debug_numa', + 'llvm', 'debugllvm', + 'profllvm', 'profoptllvm', 'profthreadedllvm', + 'debug', + 'ghci-ext', 'ghci-ext-prof', + 'ext-interp', + 'nonmoving', + 'nonmoving_thr', + 'nonmoving_thr_ghc', + 'compacting_gc', + ] + + if config.ghc_with_native_codegen: + config.compile_ways.append('optasm') + config.run_ways.append('optasm') + + if config.have_profiling: + config.compile_ways.append('profasm') + config.run_ways.append('profasm') + + if config.have_interp: + config.run_ways.append('ghci') + + if config.ghc_with_threaded_rts: + config.run_ways.append('threaded1') + if config.ghc_with_smp: + config.have_smp = True + config.run_ways.append('threaded2') + if config.speed == 0: + config.run_ways.append('nonmoving_thr') + + if config.ghc_with_dynamic_rts: + config.have_shared_libs = True + + if config.ghc_dynamic_by_default and config.have_vanilla == 1: + config.run_ways.append('static') + else: + if config.ghc_with_dynamic_rts: + config.run_ways.append('dyn') + + if (config.have_profiling and ghc_with_threaded_rts): + config.run_ways.append('profthreaded') + + if (ghc_with_llvm and not config.unregisterised): + config.compile_ways.append('optllvm') + config.run_ways.append('optllvm') + + config.way_flags = { + 'normal' : [], + 'normal_h' : [], + 'g1' : [], + 'nursery_chunks' : [], + 'debug_numa' : ['-threaded', '-debug'], + 'optasm' : ['-O', '-fasm'], + 'llvm' : ['-fllvm'], + 'optllvm' : ['-O', '-fllvm'], + 'debugllvm' : ['-fllvm', '-keep-llvm-files'], + 'prof' : ['-prof', '-static', '-fprof-auto', '-fasm'], + 'prof_no_auto' : ['-prof', '-static', '-fasm'], + 'profasm' : ['-O', '-prof', '-static', '-fprof-auto'], + 'profthreaded' : ['-O', '-prof', '-static', '-fprof-auto', '-threaded'], + 'ghci' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '+RTS', '-I0.1', '-RTS'] + (['-fghci-leak-check'] if not config.compiler_debugged else []), + 'sanity' : ['-debug'], + 'threaded1' : ['-threaded', '-debug'], + 'threaded1_ls' : ['-threaded', '-debug'], + 'threaded2' : ['-O', '-threaded', '-eventlog'], + 'threaded2_hT' : ['-O', '-threaded'], + 'hpc' : ['-O', '-fhpc'], + 'prof_hc_hb' : ['-O', '-prof', '-static', '-fprof-auto'], + 'prof_hb' : ['-O', '-prof', '-static', '-fprof-auto'], + 'prof_hd' : ['-O', '-prof', '-static', '-fprof-auto'], + 'prof_hy' : ['-O', '-prof', '-static', '-fprof-auto'], + 'prof_hr' : ['-O', '-prof', '-static', '-fprof-auto'], + 'dyn' : ['-O', '-dynamic'], + 'static' : ['-O', '-static'], + 'debug' : ['-O', '-g', '-dannot-lint'], + # llvm variants... + 'profllvm' : ['-prof', '-static', '-fprof-auto', '-fllvm'], + 'profoptllvm' : ['-O', '-prof', '-static', '-fprof-auto', '-fllvm'], + 'profthreadedllvm' : ['-O', '-prof', '-static', '-fprof-auto', '-threaded', '-fllvm'], + 'ghci-ext' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '-fexternal-interpreter', '+RTS', '-I0.1', '-RTS'], + 'ghci-ext-prof' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '-fexternal-interpreter', '-prof', '+RTS', '-I0.1', '-RTS'], + 'ext-interp' : ['-fexternal-interpreter'], + 'nonmoving' : [], + 'nonmoving_thr': ['-threaded'], + 'nonmoving_thr_ghc': ['+RTS', '-xn', '-N2', '-RTS', '-threaded'], + 'compacting_gc': [], + } + + config.way_rts_flags = { + 'normal' : [], + 'normal_h' : ['-h'], # works without -prof + 'g1' : ['-G1'], + 'nursery_chunks' : ['-n32k'], + 'debug_numa' : ['-N2', '--debug-numa=2'], + 'optasm' : [], + 'llvm' : [], + 'optllvm' : [], + 'debugllvm' : [], + 'prof' : ['-p'], + 'prof_no_auto' : ['-p'], + 'profasm' : ['-hc', '-p'], # test heap profiling too + 'profthreaded' : ['-p'], + 'ghci' : [], + 'sanity' : ['-DS'], + 'threaded1' : [], + 'threaded1_ls' : ['-ls'], + 'threaded2' : ['-N2', '-ls'], + 'threaded2_hT' : ['-N2', '-hT'], + 'hpc' : [], + 'prof_hc_hb' : ['-hc', '-hbvoid'], + 'prof_hb' : ['-hb'], + 'prof_hd' : ['-hd'], + 'prof_hy' : ['-hy'], + 'prof_hr' : ['-hr'], + 'dyn' : [], + 'static' : [], + 'debug' : [], + # llvm variants... + 'profllvm' : ['-p'], + 'profoptllvm' : ['-hc', '-p'], + 'profthreadedllvm' : ['-p'], + 'ghci-ext' : [], + 'ghci-ext-prof' : [], + 'ext-interp' : [], + 'nonmoving' : ['-xn'], + 'nonmoving_thr' : ['-xn', '-N2'], + 'nonmoving_thr_ghc': ['-xn', '-N2'], + 'compacting_gc': ['-c'], + } + + # Useful classes of ways that can be used with only_ways(), omit_ways() and + # expect_broken_for(). + + prof_ways = [x[0] for x in config.way_flags.items() + if '-prof' in x[1]] + + threaded_ways = [x[0] for x in config.way_flags.items() + if '-threaded' in x[1] or 'ghci' == x[0]] + + # Ways which run with multiple capabilities + concurrent_ways = [name for name, flags in config.way_flags.items() + if '-threaded' in flags or 'ghci' == name + if '-N2' in config.way_rts_flags.get(name, [])] + + opt_ways = [x[0] for x in config.way_flags.items() + if '-O' in x[1]] + + llvm_ways = [x[0] for x in config.way_flags.items() + if '-fflvm' in x[1]] + + @staticmethod + def get_compiler_info(): + s = getStdout([config.compiler, '--info']) + s = re.sub('[\r\n]', '', s) + compilerInfoDict = dict(eval(s)) + s = getStdout([config.compiler, '+RTS', '--info']) + s = re.sub('[\r\n]', '', s) + rtsInfoDict = dict(eval(s)) + + config.have_ncg = compilerInfoDict.get("Have native code generator", "NO") == "YES" + + # Whether GHC itself was built using the LLVM backend. We need to know this + # since some tests in ext-interp fail when stage2 ghc is built using + # LLVM. See #16087. + # + # The condition here is a bit approximate: we assume that if stage2 doesn't + # have the NCG and isn't unregisterised then it must be using the LLVM + # backend by default. + config.ghc_built_by_llvm = not config.have_ncg and not config.unregisterised + + config.have_RTS_linker = compilerInfoDict.get("target has RTS linker", "NO") == "YES" + # external interpreter needs RTS linker support + # If the field is not present (GHC 8.0 and earlier), assume we don't + # have -fexternal-interpreter (though GHC 8.0 actually does) + # so we can still run most tests. + config.have_ext_interp = compilerInfoDict.get("target has RTS linker", "NO") == "YES" + + # See Note [Replacing backward slashes in config.libdir]. + config.libdir = compilerInfoDict['LibDir'].replace('\\', '/') + + if re.match(".*_p(_.*|$)", rtsInfoDict["RTS way"]): + config.compiler_profiled = True + else: + config.compiler_profiled = False + + try: + config.package_conf_cache_file = compilerInfoDict["Global Package DB"] + '/package.cache' + except: + config.package_conf_cache_file = '' + + # See Note [WayFlags] + if config.ghc_dynamic: + config.ghc_th_way_flags = "-dynamic" + config.ghci_way_flags = "-dynamic" + config.plugin_way_flags = "-dynamic" + config.ghc_th_way = "dyn" + config.ghc_plugin_way = "dyn" + elif config.compiler_profiled: + config.ghc_th_way_flags = "-prof" + config.ghci_way_flags = "-prof" + config.plugin_way_flags = "-prof" + config.ghc_th_way = "prof" + config.ghc_plugin_way = "prof" + else: + config.ghc_th_way_flags = "-static" + config.ghci_way_flags = "-static" + config.plugin_way_flags = "-static" + config.ghc_th_way = "normal" + config.ghc_plugin_way = "normal" + +# Note [Replacing backward slashes in config.libdir] +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# We *do* need to replace backslashes in config.libdir, for the following +# reason: +# +# * Tests use config.libdir as follows: +# +# extra_run_opts('"' + config.libdir + '"') +# +# The double quotes are there because config.libdir might contain +# spaces. +# +# * This string is then written /as is/ to .genscript in +# testlib.interpreter_run: +# +# script.write(':set args ' + opts.extra_run_opts + '\n') +# +# * But GHCi expects the arguments to ':set args' to be proper Haskell +# strings (when they are quoted), with backslashes escaped. Since +# config.libdir contains single backslash characters, tests such as T5313 +# will fail for WAY=ghci with "Pattern match failure in do expression". +# +# Arguably the above code for writing `:set args` should be smarter. This +# is tricky to get right though, because in GHCI `:set args foo\bar` (no +# double quotes) works perfectly fine, and is interpreted as the Haskell +# string "foo\\bar". Therefore, simply escaping all backward slashes in +# opts.extra_run_opts before concatenating it with ':set args' is not right +# either. +# +# Replacing backslashes to forward slashes in config.libdir works around the +# problem. ===================================== testsuite/driver/runtests.py ===================================== @@ -5,6 +5,7 @@ # import argparse +from copy import copy import signal import sys import os @@ -30,6 +31,7 @@ from testglobals import getConfig, ghc_env, getTestRun, TestConfig, \ from my_typing import TestName, List from perf_notes import MetricChange, GitRef, inside_git_repo, is_worktree_dirty, format_perf_stat import perf_notes as Perf +import testsuite_config from junit import junit import term_color from term_color import Color, colored @@ -243,11 +245,6 @@ def main() -> None: os.environ['TERM'] = 'vt100' ghc_env['TERM'] = 'vt100' - def get_compiler_info() -> TestConfig: - """ Overriddden by configuration file. """ - raise NotImplementedError - - # ----------------------------------------------------------------------------- # cmd-line options @@ -268,6 +265,7 @@ def main() -> None: parser.add_argument("--verbose", type=int, choices=[0,1,2,3,4,5], help="verbose (Values 0 through 5 accepted)") parser.add_argument("--junit", type=argparse.FileType('wb'), help="output testsuite summary in JUnit format") parser.add_argument("--broken-test", action="append", default=[], help="a test name to mark as broken for this run") + parser.add_argument('--extra-hc-flag', action="append", default=[], help="extra flags to pass to the Haskell compiler") parser.add_argument("--test-env", default='local', help="Override default chosen test-env.") parser.add_argument("--perf-baseline", type=GitRef, metavar='COMMIT', help="Baseline commit for performance comparsons.") perf_group.add_argument("--skip-perf-tests", action="store_true", help="skip performance tests") @@ -283,9 +281,8 @@ def main() -> None: for e in args.e: exec(e) - if args.config_file: - for arg in args.config_file: - exec(open(arg).read()) + ts_config = testsuite_config.GHCTestsuiteConfig + ts_config_globals = ts_config.init_config(config) if args.config: for arg in args.config: @@ -297,6 +294,8 @@ def main() -> None: if args.rootdir: config.rootdirs = args.rootdir + config.compiler_always_flags = args.extra_hc_flag + config.metrics_file = args.metrics_file hasMetricsFile = config.metrics_file is not None config.summary_file = args.summary_file @@ -368,7 +367,7 @@ def main() -> None: term_color.enable_color = config.supports_colors # This has to come after arg parsing as the args can change the compiler - get_compiler_info() + ts_config.get_compiler_info(config) # Can't import this earlier as we need to know if threading will be # enabled or not @@ -445,6 +444,8 @@ def main() -> None: # First collect all the tests to be run t_files_ok = True + test_globals = copy(testlib.__dict__) + test_globals.update(ts_config_globals) for file in t_files: testlib.if_verbose(2, '====> Scanning %s' % file) testlib.newTestDir(tempdir, os.path.dirname(file)) @@ -452,7 +453,7 @@ def main() -> None: with io.open(file, encoding='utf8') as f: src = f.read() - exec(src) + exec(src, test_globals) except Exception as e: traceback.print_exc() testlib.framework_fail(None, None, 'exception: %s' % e) ===================================== testsuite/driver/testglobals.py ===================================== @@ -189,6 +189,13 @@ class TestConfig: # I have no idea what this does self.package_conf_cache_file = None # type: Optional[Path] + self.ghc_compiler_always_flags = [] # type: List[str] + self.ghc_with_native_codegen = False + self.ghc_dynamic_by_default = False + self.ghc_with_dynamic_rts = False + self.ghc_with_threaded_rts = False + self.ghc_with_smp = False + self.ghc_with_llvm = False global config config = TestConfig() ===================================== testsuite/driver/testlib.py ===================================== @@ -502,6 +502,9 @@ def doing_ghci() -> bool: def ghc_dynamic() -> bool: return config.ghc_dynamic +def ghc_with_threaded_rts() -> bool: + return config.ghc_with_threaded_rts + def fast() -> bool: return config.speed == 2 ===================================== testsuite/mk/test.mk ===================================== @@ -79,18 +79,18 @@ else dllext = .so endif -RUNTEST_OPTS += -e "ghc_compiler_always_flags='$(TEST_HC_OPTS)'" +RUNTEST_OPTS += --extra-hc-flag='$(TEST_HC_OPTS)' ifeq "$(GhcDebugged)" "YES" -RUNTEST_OPTS += -e "config.compiler_debugged=True" +RUNTEST_OPTS += --config "compiler_debugged=True" else -RUNTEST_OPTS += -e "config.compiler_debugged=False" +RUNTEST_OPTS += --config "compiler_debugged=False" endif ifeq "$(GhcWithNativeCodeGen)" "YES" -RUNTEST_OPTS += -e ghc_with_native_codegen=True +RUNTEST_OPTS += --config "ghc_with_native_codegen=True" else -RUNTEST_OPTS += -e ghc_with_native_codegen=False +RUNTEST_OPTS += --config "ghc_with_native_codegen=False" endif GHC_PRIM_LIBDIR := $(subst library-dirs: ,,$(shell "$(GHC_PKG)" field ghc-prim library-dirs --simple-output)) @@ -105,21 +105,21 @@ HAVE_READELF := $(shell if readelf --version > /dev/null 2> /dev/null; then echo BIGNUM_GMP := $(shell "$(GHC_PKG)" field ghc-bignum exposed-modules | grep GMP) ifeq "$(HAVE_VANILLA)" "YES" -RUNTEST_OPTS += -e config.have_vanilla=True +RUNTEST_OPTS += --config have_vanilla=True else -RUNTEST_OPTS += -e config.have_vanilla=False +RUNTEST_OPTS += --config have_vanilla=False endif ifeq "$(HAVE_DYNAMIC)" "YES" -RUNTEST_OPTS += -e config.have_dynamic=True +RUNTEST_OPTS += --config have_dynamic=True else -RUNTEST_OPTS += -e config.have_dynamic=False +RUNTEST_OPTS += --config have_dynamic=False endif ifeq "$(HAVE_PROFILING)" "YES" -RUNTEST_OPTS += -e config.have_profiling=True +RUNTEST_OPTS += --config have_profiling=True else -RUNTEST_OPTS += -e config.have_profiling=False +RUNTEST_OPTS += --config have_profiling=False endif ifeq "$(filter thr, $(GhcRTSWays))" "thr" @@ -135,50 +135,50 @@ RUNTEST_OPTS += -e ghc_with_dynamic_rts=False endif ifeq "$(GhcWithInterpreter)" "NO" -RUNTEST_OPTS += -e config.have_interp=False +RUNTEST_OPTS += --config have_interp=False else ifeq "$(GhcStage)" "1" -RUNTEST_OPTS += -e config.have_interp=False +RUNTEST_OPTS += --config have_interp=False else -RUNTEST_OPTS += -e config.have_interp=True +RUNTEST_OPTS += --config have_interp=True endif ifeq "$(GhcUnregisterised)" "YES" -RUNTEST_OPTS += -e config.unregisterised=True +RUNTEST_OPTS += --config unregisterised=True else -RUNTEST_OPTS += -e config.unregisterised=False +RUNTEST_OPTS += --config unregisterised=False endif ifeq "$(HAVE_GDB)" "YES" -RUNTEST_OPTS += -e config.have_gdb=True +RUNTEST_OPTS += --config have_gdb=True else -RUNTEST_OPTS += -e config.have_gdb=False +RUNTEST_OPTS += --config have_gdb=False endif ifeq "$(HAVE_READELF)" "YES" -RUNTEST_OPTS += -e config.have_readelf=True +RUNTEST_OPTS += --config have_readelf=True else -RUNTEST_OPTS += -e config.have_readelf=False +RUNTEST_OPTS += --config have_readelf=False endif ifeq "$(BIGNUM_GMP)" "" -RUNTEST_OPTS += -e config.have_fast_bignum=False +RUNTEST_OPTS += --config have_fast_bignum=False else -RUNTEST_OPTS += -e config.have_fast_bignum=True +RUNTEST_OPTS += --config have_fast_bignum=True endif ifeq "$(GhcDynamicByDefault)" "YES" -RUNTEST_OPTS += -e config.ghc_dynamic_by_default=True +RUNTEST_OPTS += --config ghc_dynamic_by_default=True CABAL_MINIMAL_BUILD = --enable-shared --disable-library-vanilla else -RUNTEST_OPTS += -e config.ghc_dynamic_by_default=False +RUNTEST_OPTS += --config ghc_dynamic_by_default=False CABAL_MINIMAL_BUILD = --enable-library-vanilla --disable-shared endif ifeq "$(GhcDynamic)" "YES" -RUNTEST_OPTS += -e config.ghc_dynamic=True +RUNTEST_OPTS += --config ghc_dynamic=True CABAL_PLUGIN_BUILD = --enable-shared --disable-library-vanilla else -RUNTEST_OPTS += -e config.ghc_dynamic=False +RUNTEST_OPTS += --config ghc_dynamic=False CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared endif @@ -213,9 +213,9 @@ RUNTEST_OPTS += -e darwin=False endif ifeq "$(IN_TREE_COMPILER)" "YES" -RUNTEST_OPTS += -e config.in_tree_compiler=True +RUNTEST_OPTS += --config in_tree_compiler=True else -RUNTEST_OPTS += -e config.in_tree_compiler=False +RUNTEST_OPTS += --config in_tree_compiler=False endif ifneq "$(THREADS)" "" @@ -243,20 +243,20 @@ RUNTEST_OPTS += --test-env="$(TEST_ENV)" endif ifeq "$(CLEANUP)" "0" -RUNTEST_OPTS += -e config.cleanup=False +RUNTEST_OPTS += --config cleanup=False else ifeq "$(CLEANUP)" "NO" -RUNTEST_OPTS += -e config.cleanup=False +RUNTEST_OPTS += --config cleanup=False else -RUNTEST_OPTS += -e config.cleanup=True +RUNTEST_OPTS += --config cleanup=True endif ifeq "$(LOCAL)" "0" # See Note [Running tests in /tmp]. -RUNTEST_OPTS += -e config.local=False +RUNTEST_OPTS += --config local=False else ifeq "$(LOCAL)" "NO" -RUNTEST_OPTS += -e config.local=False +RUNTEST_OPTS += --config local=False else -RUNTEST_OPTS += -e config.local=True +RUNTEST_OPTS += --config local=True endif RUNTEST_OPTS += \ @@ -315,30 +315,30 @@ RUNTEST_OPTS += \ $(EXTRA_RUNTEST_OPTS) ifeq "$(list_broken)" "YES" -set_list_broken = -e config.list_broken=True +set_list_broken = --config list_broken=True else set_list_broken = endif # See Note [validate and testsuite speed] in toplevel Makefile. ifneq "$(SPEED)" "" -setspeed = -e config.speed="$(SPEED)" +setspeed = --config speed="$(SPEED)" else ifeq "$(fast)" "YES" # Backward compatibility. Maybe some people are running 'make accept fast=YES'? -setspeed = -e config.speed=2 +setspeed = --config speed=2 else setspeed = endif ifeq "$(accept)" "YES" -setaccept = -e config.accept=True +setaccept = --config accept=True ifeq "$(PLATFORM)" "YES" -setaccept += -e config.accept_platform=True +setaccept += --config accept_platform=True endif ifeq "$(OS)" "YES" -setaccept += -e config.accept_os=True +setaccept += --config accept_os=True endif else ===================================== testsuite/tests/concurrent/prog002/all.T ===================================== @@ -1,7 +1,7 @@ # Test for bug #713, results in crashes in GHC prior to 20060315 with +RTS -N2 # Add 'threaded2_hT' so that we have at least one test for bug #5127 -if ghc_with_threaded_rts and ghc_with_smp: +if ghc_with_threaded_rts(): ways = ['threaded2_hT'] else: ways = [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2680da517ec368e3f13867c2e1a7b79e6d193b4b...1678340e6ef8265e5342abd6677371f8654b06cc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2680da517ec368e3f13867c2e1a7b79e6d193b4b...1678340e6ef8265e5342abd6677371f8654b06cc You're receiving 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 Jul 5 23:16:58 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 19:16:58 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] Further refactoring Message-ID: <5f025f6ab5df_80b3f84960bea141873391@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: 33f843d7 by Ben Gamari at 2020-07-05T19:16:49-04:00 Further refactoring - - - - - 7 changed files: - hadrian/src/Settings/Builders/RunTest.hs - testsuite/driver/runtests.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/config/testsuite_config.py → testsuite/driver/testsuite_config.py - testsuite/mk/test.mk - testsuite/tests/concurrent/prog002/all.T Changes: ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -105,38 +105,38 @@ runTestBuilderArgs = builder RunTest ? do , pure [ "--rootdir=" ++ testdir | testdir <- rootdirs ] , arg "-e", arg $ "windows=" ++ show windowsHost , arg "-e", arg $ "darwin=" ++ show osxHost - , arg "-e", arg $ "config.local=False" - , arg "-e", arg $ "config.cleanup=" ++ show (not keepFiles) - , arg "-e", arg $ "config.accept=" ++ show accept - , arg "-e", arg $ "config.accept_platform=" ++ show acceptPlatform - , arg "-e", arg $ "config.accept_os=" ++ show acceptOS - , arg "-e", arg $ "config.exeext=" ++ quote (if null exe then "" else "."<>exe) - , arg "-e", arg $ "config.compiler_debugged=" ++ + , arg "--config", arg $ "local=False" + , arg "--config", arg $ "cleanup=" ++ show (not keepFiles) + , arg "--config", arg $ "accept=" ++ show accept + , arg "--config", arg $ "accept_platform=" ++ show acceptPlatform + , arg "--config", arg $ "accept_os=" ++ show acceptOS + , arg "--config", arg $ "exeext=" ++ quote (if null exe then "" else "."<>exe) + , arg "--config", arg $ "compiler_debugged=" ++ show debugged , arg "-e", arg $ asBool "ghc_with_native_codegen=" withNativeCodeGen - , arg "-e", arg $ "config.have_interp=" ++ show withInterpreter - , arg "-e", arg $ "config.unregisterised=" ++ show unregisterised + , arg "--config", arg $ "have_interp=" ++ show withInterpreter + , arg "--config", arg $ "unregisterised=" ++ show unregisterised - , arg "-e", arg $ "ghc_compiler_always_flags=" ++ quote ghcFlags - , arg "-e", arg $ asBool "ghc_with_dynamic_rts=" (hasRtsWay "dyn") - , arg "-e", arg $ asBool "ghc_with_threaded_rts=" (hasRtsWay "thr") - , arg "-e", arg $ asBool "config.have_vanilla=" (hasLibWay vanilla) - , arg "-e", arg $ asBool "config.have_dynamic=" (hasLibWay dynamic) - , arg "-e", arg $ asBool "config.have_profiling=" (hasLibWay profiling) - , arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) - , arg "-e", arg $ asBool "ghc_with_smp=" withSMP - , arg "-e", arg $ asBool "ghc_with_llvm=" withLlvm + , arg "--extra-hc-flag", arg (quote ghcFlags) + , arg "--config", arg $ asBool "ghc_with_dynamic_rts=" (hasRtsWay "dyn") + , arg "--config", arg $ asBool "ghc_with_threaded_rts=" (hasRtsWay "thr") + , arg "--config", arg $ asBool "have_vanilla=" (hasLibWay vanilla) + , arg "--config", arg $ asBool "have_dynamic=" (hasLibWay dynamic) + , arg "--config", arg $ asBool "have_profiling=" (hasLibWay profiling) + , arg "--config", arg $ asBool "have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) + , arg "--config", arg $ asBool "ghc_with_smp=" withSMP + , arg "--config", arg $ asBool "ghc_with_llvm=" withLlvm - , arg "-e", arg $ "config.ghc_dynamic_by_default=" ++ show hasDynamicByDefault - , arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic + , arg "--config", arg $ "ghc_dynamic_by_default=" ++ show hasDynamicByDefault + , arg "--config", arg $ "ghc_dynamic=" ++ show hasDynamic - , arg "-e", arg $ "config.top=" ++ show (top -/- "testsuite") - , arg "-e", arg $ "config.wordsize=" ++ show wordsize - , arg "-e", arg $ "config.os=" ++ show os - , arg "-e", arg $ "config.arch=" ++ show arch - , arg "-e", arg $ "config.platform=" ++ show platform + , arg "--config", arg $ "top=" ++ show (top -/- "testsuite") + , arg "--config", arg $ "wordsize=" ++ show wordsize + , arg "--config", arg $ "os=" ++ show os + , arg "--config", arg $ "arch=" ++ show arch + , arg "--config", arg $ "platform=" ++ show platform , arg "--config", arg $ "gs=gs" -- Use the default value as in test.mk , arg "--config", arg $ "timeout_prog=" ++ show (top -/- timeoutProg) ===================================== testsuite/driver/runtests.py ===================================== @@ -5,6 +5,7 @@ # import argparse +from copy import copy import signal import sys import os @@ -264,6 +265,7 @@ def main() -> None: parser.add_argument("--verbose", type=int, choices=[0,1,2,3,4,5], help="verbose (Values 0 through 5 accepted)") parser.add_argument("--junit", type=argparse.FileType('wb'), help="output testsuite summary in JUnit format") parser.add_argument("--broken-test", action="append", default=[], help="a test name to mark as broken for this run") + parser.add_argument('--extra-hc-flag', action="append", default=[], help="extra flags to pass to the Haskell compiler") parser.add_argument("--test-env", default='local', help="Override default chosen test-env.") parser.add_argument("--perf-baseline", type=GitRef, metavar='COMMIT', help="Baseline commit for performance comparsons.") perf_group.add_argument("--skip-perf-tests", action="store_true", help="skip performance tests") @@ -280,7 +282,7 @@ def main() -> None: exec(e) ts_config = testsuite_config.GHCTestsuiteConfig - ts_config.init_config() + ts_config_globals = ts_config.init_config(config) if args.config: for arg in args.config: @@ -292,6 +294,8 @@ def main() -> None: if args.rootdir: config.rootdirs = args.rootdir + config.compiler_always_flags = args.extra_hc_flag + config.metrics_file = args.metrics_file hasMetricsFile = config.metrics_file is not None config.summary_file = args.summary_file @@ -440,6 +444,8 @@ def main() -> None: # First collect all the tests to be run t_files_ok = True + test_globals = copy(testlib.__dict__) + test_globals.update(ts_config_globals) for file in t_files: testlib.if_verbose(2, '====> Scanning %s' % file) testlib.newTestDir(tempdir, os.path.dirname(file)) @@ -447,7 +453,7 @@ def main() -> None: with io.open(file, encoding='utf8') as f: src = f.read() - exec(src) + exec(src, test_globals) except Exception as e: traceback.print_exc() testlib.framework_fail(None, None, 'exception: %s' % e) ===================================== testsuite/driver/testglobals.py ===================================== @@ -189,6 +189,13 @@ class TestConfig: # I have no idea what this does self.package_conf_cache_file = None # type: Optional[Path] + self.ghc_compiler_always_flags = [] # type: List[str] + self.ghc_with_native_codegen = False + self.ghc_dynamic_by_default = False + self.ghc_with_dynamic_rts = False + self.ghc_with_threaded_rts = False + self.ghc_with_smp = False + self.ghc_with_llvm = False global config config = TestConfig() ===================================== testsuite/driver/testlib.py ===================================== @@ -502,6 +502,9 @@ def doing_ghci() -> bool: def ghc_dynamic() -> bool: return config.ghc_dynamic +def ghc_with_threaded_rts() -> bool: + return config.ghc_with_threaded_rts + def fast() -> bool: return config.speed == 2 ===================================== testsuite/config/testsuite_config.py → testsuite/driver/testsuite_config.py ===================================== @@ -1,10 +1,12 @@ # vim: set filetype=python: import re +from testglobals import TestConfig +from testutil import getStdout class TestsuiteConfig: @staticmethod - def init_config(config: TestConfig) + def init_config(config: TestConfig) -> None: raise NotImplemented @staticmethod @@ -18,8 +20,6 @@ class GHCTestsuiteConfig(TestsuiteConfig): @staticmethod def init_config(config: TestConfig): - config.compiler_always_flags = ghc_compiler_always_flags.split() - # By default, the 'normal' and 'hpc' ways are enabled. In addition, certain # ways are enabled automatically if this GHC supports them. Ways that fall in # this group are 'optasm', 'optllvm', 'profasm', 'threaded1', 'threaded2', @@ -45,7 +45,7 @@ class GHCTestsuiteConfig(TestsuiteConfig): 'compacting_gc', ] - if ghc_with_native_codegen: + if config.ghc_with_native_codegen: config.compile_ways.append('optasm') config.run_ways.append('optasm') @@ -56,27 +56,27 @@ class GHCTestsuiteConfig(TestsuiteConfig): if config.have_interp: config.run_ways.append('ghci') - if ghc_with_threaded_rts: + if config.ghc_with_threaded_rts: config.run_ways.append('threaded1') - if ghc_with_smp: + if config.ghc_with_smp: config.have_smp = True config.run_ways.append('threaded2') if config.speed == 0: config.run_ways.append('nonmoving_thr') - if ghc_with_dynamic_rts: + if config.ghc_with_dynamic_rts: config.have_shared_libs = True if config.ghc_dynamic_by_default and config.have_vanilla == 1: config.run_ways.append('static') else: - if ghc_with_dynamic_rts: + if config.ghc_with_dynamic_rts: config.run_ways.append('dyn') if (config.have_profiling and ghc_with_threaded_rts): config.run_ways.append('profthreaded') - if (ghc_with_llvm and not config.unregisterised): + if (config.ghc_with_llvm and not config.unregisterised): config.compile_ways.append('optllvm') config.run_ways.append('optllvm') @@ -166,26 +166,31 @@ class GHCTestsuiteConfig(TestsuiteConfig): # Useful classes of ways that can be used with only_ways(), omit_ways() and # expect_broken_for(). - - prof_ways = [x[0] for x in config.way_flags.items() - if '-prof' in x[1]] - - threaded_ways = [x[0] for x in config.way_flags.items() - if '-threaded' in x[1] or 'ghci' == x[0]] - - # Ways which run with multiple capabilities - concurrent_ways = [name for name, flags in config.way_flags.items() - if '-threaded' in flags or 'ghci' == name - if '-N2' in config.way_rts_flags.get(name, [])] - - opt_ways = [x[0] for x in config.way_flags.items() - if '-O' in x[1]] - - llvm_ways = [x[0] for x in config.way_flags.items() - if '-fflvm' in x[1]] + # + # These are injected into the global scope which the tests are + # evaluated within. + globals = { + 'prof_ways' : [x[0] for x in config.way_flags.items() + if '-prof' in x[1]], + + 'threaded_ways' : [x[0] for x in config.way_flags.items() + if '-threaded' in x[1] or 'ghci' == x[0]], + + # Ways which run with multiple capabilities + 'concurrent_ways' : [name for name, flags in config.way_flags.items() + if '-threaded' in flags or 'ghci' == name + if '-N2' in config.way_rts_flags.get(name, [])], + + 'opt_ways' : [x[0] for x in config.way_flags.items() + if '-O' in x[1]], + + 'llvm_ways' : [x[0] for x in config.way_flags.items() + if '-fflvm' in x[1]], + } + return globals @staticmethod - def get_compiler_info(): + def get_compiler_info(config): s = getStdout([config.compiler, '--info']) s = re.sub('[\r\n]', '', s) compilerInfoDict = dict(eval(s)) ===================================== testsuite/mk/test.mk ===================================== @@ -79,18 +79,18 @@ else dllext = .so endif -RUNTEST_OPTS += -e "ghc_compiler_always_flags='$(TEST_HC_OPTS)'" +RUNTEST_OPTS += --extra-hc-flag='$(TEST_HC_OPTS)' ifeq "$(GhcDebugged)" "YES" -RUNTEST_OPTS += -e "config.compiler_debugged=True" +RUNTEST_OPTS += --config "compiler_debugged=True" else -RUNTEST_OPTS += -e "config.compiler_debugged=False" +RUNTEST_OPTS += --config "compiler_debugged=False" endif ifeq "$(GhcWithNativeCodeGen)" "YES" -RUNTEST_OPTS += -e ghc_with_native_codegen=True +RUNTEST_OPTS += --config "ghc_with_native_codegen=True" else -RUNTEST_OPTS += -e ghc_with_native_codegen=False +RUNTEST_OPTS += --config "ghc_with_native_codegen=False" endif GHC_PRIM_LIBDIR := $(subst library-dirs: ,,$(shell "$(GHC_PKG)" field ghc-prim library-dirs --simple-output)) @@ -105,21 +105,21 @@ HAVE_READELF := $(shell if readelf --version > /dev/null 2> /dev/null; then echo BIGNUM_GMP := $(shell "$(GHC_PKG)" field ghc-bignum exposed-modules | grep GMP) ifeq "$(HAVE_VANILLA)" "YES" -RUNTEST_OPTS += -e config.have_vanilla=True +RUNTEST_OPTS += --config have_vanilla=True else -RUNTEST_OPTS += -e config.have_vanilla=False +RUNTEST_OPTS += --config have_vanilla=False endif ifeq "$(HAVE_DYNAMIC)" "YES" -RUNTEST_OPTS += -e config.have_dynamic=True +RUNTEST_OPTS += --config have_dynamic=True else -RUNTEST_OPTS += -e config.have_dynamic=False +RUNTEST_OPTS += --config have_dynamic=False endif ifeq "$(HAVE_PROFILING)" "YES" -RUNTEST_OPTS += -e config.have_profiling=True +RUNTEST_OPTS += --config have_profiling=True else -RUNTEST_OPTS += -e config.have_profiling=False +RUNTEST_OPTS += --config have_profiling=False endif ifeq "$(filter thr, $(GhcRTSWays))" "thr" @@ -135,50 +135,50 @@ RUNTEST_OPTS += -e ghc_with_dynamic_rts=False endif ifeq "$(GhcWithInterpreter)" "NO" -RUNTEST_OPTS += -e config.have_interp=False +RUNTEST_OPTS += --config have_interp=False else ifeq "$(GhcStage)" "1" -RUNTEST_OPTS += -e config.have_interp=False +RUNTEST_OPTS += --config have_interp=False else -RUNTEST_OPTS += -e config.have_interp=True +RUNTEST_OPTS += --config have_interp=True endif ifeq "$(GhcUnregisterised)" "YES" -RUNTEST_OPTS += -e config.unregisterised=True +RUNTEST_OPTS += --config unregisterised=True else -RUNTEST_OPTS += -e config.unregisterised=False +RUNTEST_OPTS += --config unregisterised=False endif ifeq "$(HAVE_GDB)" "YES" -RUNTEST_OPTS += -e config.have_gdb=True +RUNTEST_OPTS += --config have_gdb=True else -RUNTEST_OPTS += -e config.have_gdb=False +RUNTEST_OPTS += --config have_gdb=False endif ifeq "$(HAVE_READELF)" "YES" -RUNTEST_OPTS += -e config.have_readelf=True +RUNTEST_OPTS += --config have_readelf=True else -RUNTEST_OPTS += -e config.have_readelf=False +RUNTEST_OPTS += --config have_readelf=False endif ifeq "$(BIGNUM_GMP)" "" -RUNTEST_OPTS += -e config.have_fast_bignum=False +RUNTEST_OPTS += --config have_fast_bignum=False else -RUNTEST_OPTS += -e config.have_fast_bignum=True +RUNTEST_OPTS += --config have_fast_bignum=True endif ifeq "$(GhcDynamicByDefault)" "YES" -RUNTEST_OPTS += -e config.ghc_dynamic_by_default=True +RUNTEST_OPTS += --config ghc_dynamic_by_default=True CABAL_MINIMAL_BUILD = --enable-shared --disable-library-vanilla else -RUNTEST_OPTS += -e config.ghc_dynamic_by_default=False +RUNTEST_OPTS += --config ghc_dynamic_by_default=False CABAL_MINIMAL_BUILD = --enable-library-vanilla --disable-shared endif ifeq "$(GhcDynamic)" "YES" -RUNTEST_OPTS += -e config.ghc_dynamic=True +RUNTEST_OPTS += --config ghc_dynamic=True CABAL_PLUGIN_BUILD = --enable-shared --disable-library-vanilla else -RUNTEST_OPTS += -e config.ghc_dynamic=False +RUNTEST_OPTS += --config ghc_dynamic=False CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared endif @@ -213,9 +213,9 @@ RUNTEST_OPTS += -e darwin=False endif ifeq "$(IN_TREE_COMPILER)" "YES" -RUNTEST_OPTS += -e config.in_tree_compiler=True +RUNTEST_OPTS += --config in_tree_compiler=True else -RUNTEST_OPTS += -e config.in_tree_compiler=False +RUNTEST_OPTS += --config in_tree_compiler=False endif ifneq "$(THREADS)" "" @@ -243,20 +243,20 @@ RUNTEST_OPTS += --test-env="$(TEST_ENV)" endif ifeq "$(CLEANUP)" "0" -RUNTEST_OPTS += -e config.cleanup=False +RUNTEST_OPTS += --config cleanup=False else ifeq "$(CLEANUP)" "NO" -RUNTEST_OPTS += -e config.cleanup=False +RUNTEST_OPTS += --config cleanup=False else -RUNTEST_OPTS += -e config.cleanup=True +RUNTEST_OPTS += --config cleanup=True endif ifeq "$(LOCAL)" "0" # See Note [Running tests in /tmp]. -RUNTEST_OPTS += -e config.local=False +RUNTEST_OPTS += --config local=False else ifeq "$(LOCAL)" "NO" -RUNTEST_OPTS += -e config.local=False +RUNTEST_OPTS += --config local=False else -RUNTEST_OPTS += -e config.local=True +RUNTEST_OPTS += --config local=True endif RUNTEST_OPTS += \ @@ -315,30 +315,30 @@ RUNTEST_OPTS += \ $(EXTRA_RUNTEST_OPTS) ifeq "$(list_broken)" "YES" -set_list_broken = -e config.list_broken=True +set_list_broken = --config list_broken=True else set_list_broken = endif # See Note [validate and testsuite speed] in toplevel Makefile. ifneq "$(SPEED)" "" -setspeed = -e config.speed="$(SPEED)" +setspeed = --config speed="$(SPEED)" else ifeq "$(fast)" "YES" # Backward compatibility. Maybe some people are running 'make accept fast=YES'? -setspeed = -e config.speed=2 +setspeed = --config speed=2 else setspeed = endif ifeq "$(accept)" "YES" -setaccept = -e config.accept=True +setaccept = --config accept=True ifeq "$(PLATFORM)" "YES" -setaccept += -e config.accept_platform=True +setaccept += --config accept_platform=True endif ifeq "$(OS)" "YES" -setaccept += -e config.accept_os=True +setaccept += --config accept_os=True endif else ===================================== testsuite/tests/concurrent/prog002/all.T ===================================== @@ -1,7 +1,7 @@ # Test for bug #713, results in crashes in GHC prior to 20060315 with +RTS -N2 # Add 'threaded2_hT' so that we have at least one test for bug #5127 -if ghc_with_threaded_rts and ghc_with_smp: +if ghc_with_threaded_rts(): ways = ['threaded2_hT'] else: ways = [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33f843d7e9466beebac1913b033f0e71f39491e3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33f843d7e9466beebac1913b033f0e71f39491e3 You're receiving 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 Jul 5 23:29:51 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 19:29:51 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] Further refactoring Message-ID: <5f02626f583df_80b3f849c2be4081874440@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: 869bfae0 by Ben Gamari at 2020-07-05T19:29:41-04:00 Further refactoring - - - - - 7 changed files: - hadrian/src/Settings/Builders/RunTest.hs - testsuite/driver/runtests.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/config/testsuite_config.py → testsuite/driver/testsuite_config.py - testsuite/mk/test.mk - testsuite/tests/concurrent/prog002/all.T Changes: ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -105,38 +105,38 @@ runTestBuilderArgs = builder RunTest ? do , pure [ "--rootdir=" ++ testdir | testdir <- rootdirs ] , arg "-e", arg $ "windows=" ++ show windowsHost , arg "-e", arg $ "darwin=" ++ show osxHost - , arg "-e", arg $ "config.local=False" - , arg "-e", arg $ "config.cleanup=" ++ show (not keepFiles) - , arg "-e", arg $ "config.accept=" ++ show accept - , arg "-e", arg $ "config.accept_platform=" ++ show acceptPlatform - , arg "-e", arg $ "config.accept_os=" ++ show acceptOS - , arg "-e", arg $ "config.exeext=" ++ quote (if null exe then "" else "."<>exe) - , arg "-e", arg $ "config.compiler_debugged=" ++ + , arg "--config", arg $ "local=False" + , arg "--config", arg $ "cleanup=" ++ show (not keepFiles) + , arg "--config", arg $ "accept=" ++ show accept + , arg "--config", arg $ "accept_platform=" ++ show acceptPlatform + , arg "--config", arg $ "accept_os=" ++ show acceptOS + , arg "--config", arg $ "exeext=" ++ quote (if null exe then "" else "."<>exe) + , arg "--config", arg $ "compiler_debugged=" ++ show debugged , arg "-e", arg $ asBool "ghc_with_native_codegen=" withNativeCodeGen - , arg "-e", arg $ "config.have_interp=" ++ show withInterpreter - , arg "-e", arg $ "config.unregisterised=" ++ show unregisterised + , arg "--config", arg $ "have_interp=" ++ show withInterpreter + , arg "--config", arg $ "unregisterised=" ++ show unregisterised - , arg "-e", arg $ "ghc_compiler_always_flags=" ++ quote ghcFlags - , arg "-e", arg $ asBool "ghc_with_dynamic_rts=" (hasRtsWay "dyn") - , arg "-e", arg $ asBool "ghc_with_threaded_rts=" (hasRtsWay "thr") - , arg "-e", arg $ asBool "config.have_vanilla=" (hasLibWay vanilla) - , arg "-e", arg $ asBool "config.have_dynamic=" (hasLibWay dynamic) - , arg "-e", arg $ asBool "config.have_profiling=" (hasLibWay profiling) - , arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) - , arg "-e", arg $ asBool "ghc_with_smp=" withSMP - , arg "-e", arg $ asBool "ghc_with_llvm=" withLlvm + , arg "--extra-hc-flag", arg (quote ghcFlags) + , arg "--config", arg $ asBool "ghc_with_dynamic_rts=" (hasRtsWay "dyn") + , arg "--config", arg $ asBool "ghc_with_threaded_rts=" (hasRtsWay "thr") + , arg "--config", arg $ asBool "have_vanilla=" (hasLibWay vanilla) + , arg "--config", arg $ asBool "have_dynamic=" (hasLibWay dynamic) + , arg "--config", arg $ asBool "have_profiling=" (hasLibWay profiling) + , arg "--config", arg $ asBool "have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) + , arg "--config", arg $ asBool "ghc_with_smp=" withSMP + , arg "--config", arg $ asBool "ghc_with_llvm=" withLlvm - , arg "-e", arg $ "config.ghc_dynamic_by_default=" ++ show hasDynamicByDefault - , arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic + , arg "--config", arg $ "ghc_dynamic_by_default=" ++ show hasDynamicByDefault + , arg "--config", arg $ "ghc_dynamic=" ++ show hasDynamic - , arg "-e", arg $ "config.top=" ++ show (top -/- "testsuite") - , arg "-e", arg $ "config.wordsize=" ++ show wordsize - , arg "-e", arg $ "config.os=" ++ show os - , arg "-e", arg $ "config.arch=" ++ show arch - , arg "-e", arg $ "config.platform=" ++ show platform + , arg "--config", arg $ "top=" ++ show (top -/- "testsuite") + , arg "--config", arg $ "wordsize=" ++ show wordsize + , arg "--config", arg $ "os=" ++ show os + , arg "--config", arg $ "arch=" ++ show arch + , arg "--config", arg $ "platform=" ++ show platform , arg "--config", arg $ "gs=gs" -- Use the default value as in test.mk , arg "--config", arg $ "timeout_prog=" ++ show (top -/- timeoutProg) ===================================== testsuite/driver/runtests.py ===================================== @@ -5,6 +5,7 @@ # import argparse +from copy import copy import signal import sys import os @@ -264,6 +265,7 @@ def main() -> None: parser.add_argument("--verbose", type=int, choices=[0,1,2,3,4,5], help="verbose (Values 0 through 5 accepted)") parser.add_argument("--junit", type=argparse.FileType('wb'), help="output testsuite summary in JUnit format") parser.add_argument("--broken-test", action="append", default=[], help="a test name to mark as broken for this run") + parser.add_argument('--extra-hc-flag', action="append", default=[], help="extra flags to pass to the Haskell compiler") parser.add_argument("--test-env", default='local', help="Override default chosen test-env.") parser.add_argument("--perf-baseline", type=GitRef, metavar='COMMIT', help="Baseline commit for performance comparsons.") perf_group.add_argument("--skip-perf-tests", action="store_true", help="skip performance tests") @@ -280,7 +282,7 @@ def main() -> None: exec(e) ts_config = testsuite_config.GHCTestsuiteConfig - ts_config.init_config() + ts_config_globals = ts_config.init_config(config) if args.config: for arg in args.config: @@ -292,6 +294,8 @@ def main() -> None: if args.rootdir: config.rootdirs = args.rootdir + config.compiler_always_flags = args.extra_hc_flag + config.metrics_file = args.metrics_file hasMetricsFile = config.metrics_file is not None config.summary_file = args.summary_file @@ -440,6 +444,8 @@ def main() -> None: # First collect all the tests to be run t_files_ok = True + test_globals = copy(testlib.__dict__) + test_globals.update(ts_config_globals) for file in t_files: testlib.if_verbose(2, '====> Scanning %s' % file) testlib.newTestDir(tempdir, os.path.dirname(file)) @@ -447,7 +453,7 @@ def main() -> None: with io.open(file, encoding='utf8') as f: src = f.read() - exec(src) + exec(src, test_globals) except Exception as e: traceback.print_exc() testlib.framework_fail(None, None, 'exception: %s' % e) ===================================== testsuite/driver/testglobals.py ===================================== @@ -189,6 +189,13 @@ class TestConfig: # I have no idea what this does self.package_conf_cache_file = None # type: Optional[Path] + self.ghc_compiler_always_flags = [] # type: List[str] + self.ghc_with_native_codegen = False + self.ghc_dynamic_by_default = False + self.ghc_with_dynamic_rts = False + self.ghc_with_threaded_rts = False + self.ghc_with_smp = False + self.ghc_with_llvm = False global config config = TestConfig() ===================================== testsuite/driver/testlib.py ===================================== @@ -502,6 +502,9 @@ def doing_ghci() -> bool: def ghc_dynamic() -> bool: return config.ghc_dynamic +def ghc_with_threaded_rts() -> bool: + return config.ghc_with_threaded_rts + def fast() -> bool: return config.speed == 2 ===================================== testsuite/config/testsuite_config.py → testsuite/driver/testsuite_config.py ===================================== @@ -1,10 +1,12 @@ # vim: set filetype=python: import re +from testglobals import TestConfig, WayName +from testutil import getStdout class TestsuiteConfig: @staticmethod - def init_config(config: TestConfig) + def init_config(config: TestConfig) -> None: raise NotImplemented @staticmethod @@ -18,18 +20,19 @@ class GHCTestsuiteConfig(TestsuiteConfig): @staticmethod def init_config(config: TestConfig): - config.compiler_always_flags = ghc_compiler_always_flags.split() + WayNames = lambda xs: [ WayName(x) for x in xs ] # By default, the 'normal' and 'hpc' ways are enabled. In addition, certain # ways are enabled automatically if this GHC supports them. Ways that fall in # this group are 'optasm', 'optllvm', 'profasm', 'threaded1', 'threaded2', # 'profthreaded', 'ghci', and whichever of 'static/dyn' is not this GHC's # default mode. Other ways should be set explicitly from .T files. - config.compile_ways = ['normal', 'hpc'] - config.run_ways = ['normal', 'hpc'] + config.compile_ways = WayNames(['normal', 'hpc']) + config.run_ways = WayNames(['normal', 'hpc']) # ways that are not enabled by default, but can always be invoked explicitly - config.other_ways = ['prof', 'normal_h', + config.other_ways = WayNames([ + 'prof', 'normal_h', 'prof_hc_hb','prof_hb', 'prof_hd','prof_hy','prof_hr', 'sanity', @@ -43,44 +46,45 @@ class GHCTestsuiteConfig(TestsuiteConfig): 'nonmoving_thr', 'nonmoving_thr_ghc', 'compacting_gc', - ] + ]) - if ghc_with_native_codegen: - config.compile_ways.append('optasm') - config.run_ways.append('optasm') + if config.ghc_with_native_codegen: + config.compile_ways.append(WayName('optasm')) + config.run_ways.append(WayName('optasm')) if config.have_profiling: - config.compile_ways.append('profasm') - config.run_ways.append('profasm') + config.compile_ways.append(WayName('profasm')) + config.run_ways.append(WayName('profasm')) if config.have_interp: - config.run_ways.append('ghci') + config.run_ways.append(WayName('ghci')) - if ghc_with_threaded_rts: - config.run_ways.append('threaded1') - if ghc_with_smp: + if config.ghc_with_threaded_rts: + config.run_ways.append(WayName('threaded1')) + if config.ghc_with_smp: config.have_smp = True - config.run_ways.append('threaded2') + config.run_ways.append(WayName('threaded2')) if config.speed == 0: - config.run_ways.append('nonmoving_thr') + config.run_ways.append(WayName('nonmoving_thr')) - if ghc_with_dynamic_rts: + if config.ghc_with_dynamic_rts: config.have_shared_libs = True if config.ghc_dynamic_by_default and config.have_vanilla == 1: - config.run_ways.append('static') + config.run_ways.append(WayName('static')) else: - if ghc_with_dynamic_rts: - config.run_ways.append('dyn') + if config.ghc_with_dynamic_rts: + config.run_ways.append(WayName('dyn')) - if (config.have_profiling and ghc_with_threaded_rts): - config.run_ways.append('profthreaded') + if (config.have_profiling and config.ghc_with_threaded_rts): + config.run_ways.append(WayName('profthreaded')) - if (ghc_with_llvm and not config.unregisterised): - config.compile_ways.append('optllvm') - config.run_ways.append('optllvm') + if (config.ghc_with_llvm and not config.unregisterised): + config.compile_ways.append(WayName('optllvm')) + config.run_ways.append(WayName('optllvm')) - config.way_flags = { + WayFlags = lambda d: { WayName(k): v for k, v in d.items() } + config.way_flags = WayFlags({ 'normal' : [], 'normal_h' : [], 'g1' : [], @@ -120,9 +124,9 @@ class GHCTestsuiteConfig(TestsuiteConfig): 'nonmoving_thr': ['-threaded'], 'nonmoving_thr_ghc': ['+RTS', '-xn', '-N2', '-RTS', '-threaded'], 'compacting_gc': [], - } + }) - config.way_rts_flags = { + config.way_rts_flags = WayFlags({ 'normal' : [], 'normal_h' : ['-h'], # works without -prof 'g1' : ['-G1'], @@ -162,30 +166,35 @@ class GHCTestsuiteConfig(TestsuiteConfig): 'nonmoving_thr' : ['-xn', '-N2'], 'nonmoving_thr_ghc': ['-xn', '-N2'], 'compacting_gc': ['-c'], - } + }) # Useful classes of ways that can be used with only_ways(), omit_ways() and # expect_broken_for(). - - prof_ways = [x[0] for x in config.way_flags.items() - if '-prof' in x[1]] - - threaded_ways = [x[0] for x in config.way_flags.items() - if '-threaded' in x[1] or 'ghci' == x[0]] - - # Ways which run with multiple capabilities - concurrent_ways = [name for name, flags in config.way_flags.items() - if '-threaded' in flags or 'ghci' == name - if '-N2' in config.way_rts_flags.get(name, [])] - - opt_ways = [x[0] for x in config.way_flags.items() - if '-O' in x[1]] - - llvm_ways = [x[0] for x in config.way_flags.items() - if '-fflvm' in x[1]] + # + # These are injected into the global scope which the tests are + # evaluated within. + globals = { + 'prof_ways' : [x[0] for x in config.way_flags.items() + if '-prof' in x[1]], + + 'threaded_ways' : [x[0] for x in config.way_flags.items() + if '-threaded' in x[1] or 'ghci' == x[0]], + + # Ways which run with multiple capabilities + 'concurrent_ways' : [name for name, flags in config.way_flags.items() + if '-threaded' in flags or 'ghci' == name + if '-N2' in config.way_rts_flags.get(name, [])], + + 'opt_ways' : [x[0] for x in config.way_flags.items() + if '-O' in x[1]], + + 'llvm_ways' : [x[0] for x in config.way_flags.items() + if '-fflvm' in x[1]], + } + return globals @staticmethod - def get_compiler_info(): + def get_compiler_info(config): s = getStdout([config.compiler, '--info']) s = re.sub('[\r\n]', '', s) compilerInfoDict = dict(eval(s)) ===================================== testsuite/mk/test.mk ===================================== @@ -79,18 +79,18 @@ else dllext = .so endif -RUNTEST_OPTS += -e "ghc_compiler_always_flags='$(TEST_HC_OPTS)'" +RUNTEST_OPTS += --extra-hc-flag='$(TEST_HC_OPTS)' ifeq "$(GhcDebugged)" "YES" -RUNTEST_OPTS += -e "config.compiler_debugged=True" +RUNTEST_OPTS += --config "compiler_debugged=True" else -RUNTEST_OPTS += -e "config.compiler_debugged=False" +RUNTEST_OPTS += --config "compiler_debugged=False" endif ifeq "$(GhcWithNativeCodeGen)" "YES" -RUNTEST_OPTS += -e ghc_with_native_codegen=True +RUNTEST_OPTS += --config "ghc_with_native_codegen=True" else -RUNTEST_OPTS += -e ghc_with_native_codegen=False +RUNTEST_OPTS += --config "ghc_with_native_codegen=False" endif GHC_PRIM_LIBDIR := $(subst library-dirs: ,,$(shell "$(GHC_PKG)" field ghc-prim library-dirs --simple-output)) @@ -105,21 +105,21 @@ HAVE_READELF := $(shell if readelf --version > /dev/null 2> /dev/null; then echo BIGNUM_GMP := $(shell "$(GHC_PKG)" field ghc-bignum exposed-modules | grep GMP) ifeq "$(HAVE_VANILLA)" "YES" -RUNTEST_OPTS += -e config.have_vanilla=True +RUNTEST_OPTS += --config have_vanilla=True else -RUNTEST_OPTS += -e config.have_vanilla=False +RUNTEST_OPTS += --config have_vanilla=False endif ifeq "$(HAVE_DYNAMIC)" "YES" -RUNTEST_OPTS += -e config.have_dynamic=True +RUNTEST_OPTS += --config have_dynamic=True else -RUNTEST_OPTS += -e config.have_dynamic=False +RUNTEST_OPTS += --config have_dynamic=False endif ifeq "$(HAVE_PROFILING)" "YES" -RUNTEST_OPTS += -e config.have_profiling=True +RUNTEST_OPTS += --config have_profiling=True else -RUNTEST_OPTS += -e config.have_profiling=False +RUNTEST_OPTS += --config have_profiling=False endif ifeq "$(filter thr, $(GhcRTSWays))" "thr" @@ -135,50 +135,50 @@ RUNTEST_OPTS += -e ghc_with_dynamic_rts=False endif ifeq "$(GhcWithInterpreter)" "NO" -RUNTEST_OPTS += -e config.have_interp=False +RUNTEST_OPTS += --config have_interp=False else ifeq "$(GhcStage)" "1" -RUNTEST_OPTS += -e config.have_interp=False +RUNTEST_OPTS += --config have_interp=False else -RUNTEST_OPTS += -e config.have_interp=True +RUNTEST_OPTS += --config have_interp=True endif ifeq "$(GhcUnregisterised)" "YES" -RUNTEST_OPTS += -e config.unregisterised=True +RUNTEST_OPTS += --config unregisterised=True else -RUNTEST_OPTS += -e config.unregisterised=False +RUNTEST_OPTS += --config unregisterised=False endif ifeq "$(HAVE_GDB)" "YES" -RUNTEST_OPTS += -e config.have_gdb=True +RUNTEST_OPTS += --config have_gdb=True else -RUNTEST_OPTS += -e config.have_gdb=False +RUNTEST_OPTS += --config have_gdb=False endif ifeq "$(HAVE_READELF)" "YES" -RUNTEST_OPTS += -e config.have_readelf=True +RUNTEST_OPTS += --config have_readelf=True else -RUNTEST_OPTS += -e config.have_readelf=False +RUNTEST_OPTS += --config have_readelf=False endif ifeq "$(BIGNUM_GMP)" "" -RUNTEST_OPTS += -e config.have_fast_bignum=False +RUNTEST_OPTS += --config have_fast_bignum=False else -RUNTEST_OPTS += -e config.have_fast_bignum=True +RUNTEST_OPTS += --config have_fast_bignum=True endif ifeq "$(GhcDynamicByDefault)" "YES" -RUNTEST_OPTS += -e config.ghc_dynamic_by_default=True +RUNTEST_OPTS += --config ghc_dynamic_by_default=True CABAL_MINIMAL_BUILD = --enable-shared --disable-library-vanilla else -RUNTEST_OPTS += -e config.ghc_dynamic_by_default=False +RUNTEST_OPTS += --config ghc_dynamic_by_default=False CABAL_MINIMAL_BUILD = --enable-library-vanilla --disable-shared endif ifeq "$(GhcDynamic)" "YES" -RUNTEST_OPTS += -e config.ghc_dynamic=True +RUNTEST_OPTS += --config ghc_dynamic=True CABAL_PLUGIN_BUILD = --enable-shared --disable-library-vanilla else -RUNTEST_OPTS += -e config.ghc_dynamic=False +RUNTEST_OPTS += --config ghc_dynamic=False CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared endif @@ -213,9 +213,9 @@ RUNTEST_OPTS += -e darwin=False endif ifeq "$(IN_TREE_COMPILER)" "YES" -RUNTEST_OPTS += -e config.in_tree_compiler=True +RUNTEST_OPTS += --config in_tree_compiler=True else -RUNTEST_OPTS += -e config.in_tree_compiler=False +RUNTEST_OPTS += --config in_tree_compiler=False endif ifneq "$(THREADS)" "" @@ -243,20 +243,20 @@ RUNTEST_OPTS += --test-env="$(TEST_ENV)" endif ifeq "$(CLEANUP)" "0" -RUNTEST_OPTS += -e config.cleanup=False +RUNTEST_OPTS += --config cleanup=False else ifeq "$(CLEANUP)" "NO" -RUNTEST_OPTS += -e config.cleanup=False +RUNTEST_OPTS += --config cleanup=False else -RUNTEST_OPTS += -e config.cleanup=True +RUNTEST_OPTS += --config cleanup=True endif ifeq "$(LOCAL)" "0" # See Note [Running tests in /tmp]. -RUNTEST_OPTS += -e config.local=False +RUNTEST_OPTS += --config local=False else ifeq "$(LOCAL)" "NO" -RUNTEST_OPTS += -e config.local=False +RUNTEST_OPTS += --config local=False else -RUNTEST_OPTS += -e config.local=True +RUNTEST_OPTS += --config local=True endif RUNTEST_OPTS += \ @@ -315,30 +315,30 @@ RUNTEST_OPTS += \ $(EXTRA_RUNTEST_OPTS) ifeq "$(list_broken)" "YES" -set_list_broken = -e config.list_broken=True +set_list_broken = --config list_broken=True else set_list_broken = endif # See Note [validate and testsuite speed] in toplevel Makefile. ifneq "$(SPEED)" "" -setspeed = -e config.speed="$(SPEED)" +setspeed = --config speed="$(SPEED)" else ifeq "$(fast)" "YES" # Backward compatibility. Maybe some people are running 'make accept fast=YES'? -setspeed = -e config.speed=2 +setspeed = --config speed=2 else setspeed = endif ifeq "$(accept)" "YES" -setaccept = -e config.accept=True +setaccept = --config accept=True ifeq "$(PLATFORM)" "YES" -setaccept += -e config.accept_platform=True +setaccept += --config accept_platform=True endif ifeq "$(OS)" "YES" -setaccept += -e config.accept_os=True +setaccept += --config accept_os=True endif else ===================================== testsuite/tests/concurrent/prog002/all.T ===================================== @@ -1,7 +1,7 @@ # Test for bug #713, results in crashes in GHC prior to 20060315 with +RTS -N2 # Add 'threaded2_hT' so that we have at least one test for bug #5127 -if ghc_with_threaded_rts and ghc_with_smp: +if ghc_with_threaded_rts(): ways = ['threaded2_hT'] else: ways = [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/869bfae05eabe64292b63cc59598ebb0b09a4377 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/869bfae05eabe64292b63cc59598ebb0b09a4377 You're receiving 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 Jul 6 00:26:11 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Sun, 05 Jul 2020 20:26:11 -0400 Subject: [Git][ghc/ghc][wip/andreask/typedUniqFM] 12 commits: Hadrian: fix PowerPC64le support (#17601) Message-ID: <5f026fa3e5728_80b3f849c2be408187915c@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/typedUniqFM at Glasgow Haskell Compiler / GHC Commits: 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - 04c082b0 by Andreas Klebinger at 2020-07-06T02:26:01+02:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - 30 changed files: - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e05c773906d1712b0e15de1272020c200cb9bd63...04c082b0763ba66dd862f9b04833e1d4e4561f25 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e05c773906d1712b0e15de1272020c200cb9bd63...04c082b0763ba66dd862f9b04833e1d4e4561f25 You're receiving 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 Jul 6 00:40:36 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Sun, 05 Jul 2020 20:40:36 -0400 Subject: [Git][ghc/ghc][wip/andreask/dmdAnal_dflags] 62 commits: Switch from HscSource to IsBootInterface for module lookup in GhcMake Message-ID: <5f027304a476e_80b3f8469a40484188585c@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/dmdAnal_dflags at Glasgow Haskell Compiler / GHC Commits: 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - 2856bbe1 by Andreas Klebinger at 2020-07-05T20:40:33-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 30 changed files: - .gitlab/test-metrics.sh - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/SPARC/CodeGen/Base.hs - compiler/GHC/CmmToAsm/SPARC/Regs.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Regs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91174cc9fc42eb3c00382c03917dfe694d8467f7...2856bbe1ffd06a5ed0b721a2a89b4c4cc1b9a494 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91174cc9fc42eb3c00382c03917dfe694d8467f7...2856bbe1ffd06a5ed0b721a2a89b4c4cc1b9a494 You're receiving 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 Jul 6 01:23:33 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 21:23:33 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] Fix it Message-ID: <5f027d15564ee_80b3f8486100a781888545@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: e3e762b6 by Ben Gamari at 2020-07-05T21:23:26-04:00 Fix it - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -1945,7 +1945,8 @@ def check_prof_ok(name: TestName, way: WayName) -> bool: def compare_outputs(way: WayName, kind: str, normaliser: OutputNormalizer, - expected_file, actual_file, diff_file=None, + expected_file: str, actual_file: str, + diff_file: Optional[str]=None, whitespace_normaliser: OutputNormalizer=lambda x:x) -> bool: expected_path = in_srcdir(expected_file) @@ -2000,18 +2001,19 @@ def compare_outputs(way: WayName, if_verbose(1, 'Test is expected to fail. Not accepting new output.') return False elif config.accept and actual_raw: + suffix = '' if config.accept_platform: if_verbose(1, 'Accepting new output for platform "' + config.platform + '".') - expected_path += '-' + config.platform + suffix += '-' + config.platform elif config.accept_os: if_verbose(1, 'Accepting new output for os "' + config.os + '".') - expected_path += '-' + config.os + suffix += '-' + config.os else: if_verbose(1, 'Accepting new output.') - write_file(expected_path, actual_raw) + write_file(str(expected_path) + suffix, actual_raw) return True elif config.accept: if_verbose(1, 'No output. Deleting "{0}".'.format(expected_path)) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3e762b635fd3609f91e07a318e5bcd4c14d6c8a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3e762b635fd3609f91e07a318e5bcd4c14d6c8a You're receiving 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 Jul 6 02:16:50 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 22:16:50 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] Things Message-ID: <5f028992b4bf0_80b3f8496a302dc1891576@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: 4b559f04 by Ben Gamari at 2020-07-05T22:16:44-04:00 Things - - - - - 4 changed files: - hadrian/src/Settings/Builders/RunTest.hs - testsuite/driver/runtests.py - testsuite/driver/testlib.py - testsuite/mk/test.mk Changes: ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -105,38 +105,38 @@ runTestBuilderArgs = builder RunTest ? do , pure [ "--rootdir=" ++ testdir | testdir <- rootdirs ] , arg "-e", arg $ "windows=" ++ show windowsHost , arg "-e", arg $ "darwin=" ++ show osxHost - , arg "--config", arg $ "local=False" - , arg "--config", arg $ "cleanup=" ++ show (not keepFiles) - , arg "--config", arg $ "accept=" ++ show accept - , arg "--config", arg $ "accept_platform=" ++ show acceptPlatform - , arg "--config", arg $ "accept_os=" ++ show acceptOS - , arg "--config", arg $ "exeext=" ++ quote (if null exe then "" else "."<>exe) - , arg "--config", arg $ "compiler_debugged=" ++ + , arg "-e", arg $ "config.local=False" + , arg "-e", arg $ "config.cleanup=" ++ show (not keepFiles) + , arg "-e", arg $ "config.accept=" ++ show accept + , arg "-e", arg $ "config.accept_platform=" ++ show acceptPlatform + , arg "-e", arg $ "config.accept_os=" ++ show acceptOS + , arg "-e", arg $ "config.exeext=" ++ quote (if null exe then "" else "."<>exe) + , arg "-e", arg $ "config.compiler_debugged=" ++ show debugged , arg "-e", arg $ asBool "ghc_with_native_codegen=" withNativeCodeGen - , arg "--config", arg $ "have_interp=" ++ show withInterpreter - , arg "--config", arg $ "unregisterised=" ++ show unregisterised + , arg "-e", arg $ "config.have_interp=" ++ show withInterpreter + , arg "-e", arg $ "config.unregisterised=" ++ show unregisterised - , arg "--extra-hc-flag", arg (quote ghcFlags) - , arg "--config", arg $ asBool "ghc_with_dynamic_rts=" (hasRtsWay "dyn") - , arg "--config", arg $ asBool "ghc_with_threaded_rts=" (hasRtsWay "thr") - , arg "--config", arg $ asBool "have_vanilla=" (hasLibWay vanilla) - , arg "--config", arg $ asBool "have_dynamic=" (hasLibWay dynamic) - , arg "--config", arg $ asBool "have_profiling=" (hasLibWay profiling) - , arg "--config", arg $ asBool "have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) - , arg "--config", arg $ asBool "ghc_with_smp=" withSMP - , arg "--config", arg $ asBool "ghc_with_llvm=" withLlvm + , arg "-e", arg $ "ghc_compiler_always_flags=" ++ quote ghcFlags + , arg "-e", arg $ asBool "ghc_with_dynamic_rts=" (hasRtsWay "dyn") + , arg "-e", arg $ asBool "ghc_with_threaded_rts=" (hasRtsWay "thr") + , arg "-e", arg $ asBool "config.have_vanilla=" (hasLibWay vanilla) + , arg "-e", arg $ asBool "config.have_dynamic=" (hasLibWay dynamic) + , arg "-e", arg $ asBool "config.have_profiling=" (hasLibWay profiling) + , arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) + , arg "-e", arg $ asBool "ghc_with_smp=" withSMP + , arg "-e", arg $ asBool "ghc_with_llvm=" withLlvm - , arg "--config", arg $ "ghc_dynamic_by_default=" ++ show hasDynamicByDefault - , arg "--config", arg $ "ghc_dynamic=" ++ show hasDynamic + , arg "-e", arg $ "config.ghc_dynamic_by_default=" ++ show hasDynamicByDefault + , arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic - , arg "--config", arg $ "top=" ++ show (top -/- "testsuite") - , arg "--config", arg $ "wordsize=" ++ show wordsize - , arg "--config", arg $ "os=" ++ show os - , arg "--config", arg $ "arch=" ++ show arch - , arg "--config", arg $ "platform=" ++ show platform + , arg "-e", arg $ "config.top=" ++ show (top -/- "testsuite") + , arg "-e", arg $ "config.wordsize=" ++ show wordsize + , arg "-e", arg $ "config.os=" ++ show os + , arg "-e", arg $ "config.arch=" ++ show arch + , arg "-e", arg $ "config.platform=" ++ show platform , arg "--config", arg $ "gs=gs" -- Use the default value as in test.mk , arg "--config", arg $ "timeout_prog=" ++ show (top -/- timeoutProg) ===================================== testsuite/driver/runtests.py ===================================== @@ -294,7 +294,11 @@ def main() -> None: if args.rootdir: config.rootdirs = args.rootdir - config.compiler_always_flags = args.extra_hc_flag + config.compiler_always_flags = [ + flag + for flags in args.extra_hc_flag + for flag in flags.split() + ] config.metrics_file = args.metrics_file hasMetricsFile = config.metrics_file is not None ===================================== testsuite/driver/testlib.py ===================================== @@ -2013,7 +2013,7 @@ def compare_outputs(way: WayName, else: if_verbose(1, 'Accepting new output.') - write_file(str(expected_path) + suffix, actual_raw) + write_file(expected_path.with_suffix(expected_path.suffix + suffix), actual_raw) return True elif config.accept: if_verbose(1, 'No output. Deleting "{0}".'.format(expected_path)) ===================================== testsuite/mk/test.mk ===================================== @@ -79,18 +79,18 @@ else dllext = .so endif -RUNTEST_OPTS += --extra-hc-flag='$(TEST_HC_OPTS)' +RUNTEST_OPTS += -e "ghc_compiler_always_flags='$(TEST_HC_OPTS)'" ifeq "$(GhcDebugged)" "YES" -RUNTEST_OPTS += --config "compiler_debugged=True" +RUNTEST_OPTS += -e "config.compiler_debugged=True" else -RUNTEST_OPTS += --config "compiler_debugged=False" +RUNTEST_OPTS += -e "config.compiler_debugged=False" endif ifeq "$(GhcWithNativeCodeGen)" "YES" -RUNTEST_OPTS += --config "ghc_with_native_codegen=True" +RUNTEST_OPTS += -e ghc_with_native_codegen=True else -RUNTEST_OPTS += --config "ghc_with_native_codegen=False" +RUNTEST_OPTS += -e ghc_with_native_codegen=False endif GHC_PRIM_LIBDIR := $(subst library-dirs: ,,$(shell "$(GHC_PKG)" field ghc-prim library-dirs --simple-output)) @@ -105,21 +105,21 @@ HAVE_READELF := $(shell if readelf --version > /dev/null 2> /dev/null; then echo BIGNUM_GMP := $(shell "$(GHC_PKG)" field ghc-bignum exposed-modules | grep GMP) ifeq "$(HAVE_VANILLA)" "YES" -RUNTEST_OPTS += --config have_vanilla=True +RUNTEST_OPTS += -e config.have_vanilla=True else -RUNTEST_OPTS += --config have_vanilla=False +RUNTEST_OPTS += -e config.have_vanilla=False endif ifeq "$(HAVE_DYNAMIC)" "YES" -RUNTEST_OPTS += --config have_dynamic=True +RUNTEST_OPTS += -e config.have_dynamic=True else -RUNTEST_OPTS += --config have_dynamic=False +RUNTEST_OPTS += -e config.have_dynamic=False endif ifeq "$(HAVE_PROFILING)" "YES" -RUNTEST_OPTS += --config have_profiling=True +RUNTEST_OPTS += -e config.have_profiling=True else -RUNTEST_OPTS += --config have_profiling=False +RUNTEST_OPTS += -e config.have_profiling=False endif ifeq "$(filter thr, $(GhcRTSWays))" "thr" @@ -135,50 +135,50 @@ RUNTEST_OPTS += -e ghc_with_dynamic_rts=False endif ifeq "$(GhcWithInterpreter)" "NO" -RUNTEST_OPTS += --config have_interp=False +RUNTEST_OPTS += -e config.have_interp=False else ifeq "$(GhcStage)" "1" -RUNTEST_OPTS += --config have_interp=False +RUNTEST_OPTS += -e config.have_interp=False else -RUNTEST_OPTS += --config have_interp=True +RUNTEST_OPTS += -e config.have_interp=True endif ifeq "$(GhcUnregisterised)" "YES" -RUNTEST_OPTS += --config unregisterised=True +RUNTEST_OPTS += -e config.unregisterised=True else -RUNTEST_OPTS += --config unregisterised=False +RUNTEST_OPTS += -e config.unregisterised=False endif ifeq "$(HAVE_GDB)" "YES" -RUNTEST_OPTS += --config have_gdb=True +RUNTEST_OPTS += -e config.have_gdb=True else -RUNTEST_OPTS += --config have_gdb=False +RUNTEST_OPTS += -e config.have_gdb=False endif ifeq "$(HAVE_READELF)" "YES" -RUNTEST_OPTS += --config have_readelf=True +RUNTEST_OPTS += -e config.have_readelf=True else -RUNTEST_OPTS += --config have_readelf=False +RUNTEST_OPTS += -e config.have_readelf=False endif ifeq "$(BIGNUM_GMP)" "" -RUNTEST_OPTS += --config have_fast_bignum=False +RUNTEST_OPTS += -e config.have_fast_bignum=False else -RUNTEST_OPTS += --config have_fast_bignum=True +RUNTEST_OPTS += -e config.have_fast_bignum=True endif ifeq "$(GhcDynamicByDefault)" "YES" -RUNTEST_OPTS += --config ghc_dynamic_by_default=True +RUNTEST_OPTS += -e config.ghc_dynamic_by_default=True CABAL_MINIMAL_BUILD = --enable-shared --disable-library-vanilla else -RUNTEST_OPTS += --config ghc_dynamic_by_default=False +RUNTEST_OPTS += -e config.ghc_dynamic_by_default=False CABAL_MINIMAL_BUILD = --enable-library-vanilla --disable-shared endif ifeq "$(GhcDynamic)" "YES" -RUNTEST_OPTS += --config ghc_dynamic=True +RUNTEST_OPTS += -e config.ghc_dynamic=True CABAL_PLUGIN_BUILD = --enable-shared --disable-library-vanilla else -RUNTEST_OPTS += --config ghc_dynamic=False +RUNTEST_OPTS += -e config.ghc_dynamic=False CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared endif @@ -213,9 +213,9 @@ RUNTEST_OPTS += -e darwin=False endif ifeq "$(IN_TREE_COMPILER)" "YES" -RUNTEST_OPTS += --config in_tree_compiler=True +RUNTEST_OPTS += -e config.in_tree_compiler=True else -RUNTEST_OPTS += --config in_tree_compiler=False +RUNTEST_OPTS += -e config.in_tree_compiler=False endif ifneq "$(THREADS)" "" @@ -243,20 +243,20 @@ RUNTEST_OPTS += --test-env="$(TEST_ENV)" endif ifeq "$(CLEANUP)" "0" -RUNTEST_OPTS += --config cleanup=False +RUNTEST_OPTS += -e config.cleanup=False else ifeq "$(CLEANUP)" "NO" -RUNTEST_OPTS += --config cleanup=False +RUNTEST_OPTS += -e config.cleanup=False else -RUNTEST_OPTS += --config cleanup=True +RUNTEST_OPTS += -e config.cleanup=True endif ifeq "$(LOCAL)" "0" # See Note [Running tests in /tmp]. -RUNTEST_OPTS += --config local=False +RUNTEST_OPTS += -e config.local=False else ifeq "$(LOCAL)" "NO" -RUNTEST_OPTS += --config local=False +RUNTEST_OPTS += -e config.local=False else -RUNTEST_OPTS += --config local=True +RUNTEST_OPTS += -e config.local=True endif RUNTEST_OPTS += \ @@ -315,30 +315,30 @@ RUNTEST_OPTS += \ $(EXTRA_RUNTEST_OPTS) ifeq "$(list_broken)" "YES" -set_list_broken = --config list_broken=True +set_list_broken = -e config.list_broken=True else set_list_broken = endif # See Note [validate and testsuite speed] in toplevel Makefile. ifneq "$(SPEED)" "" -setspeed = --config speed="$(SPEED)" +setspeed = -e config.speed="$(SPEED)" else ifeq "$(fast)" "YES" # Backward compatibility. Maybe some people are running 'make accept fast=YES'? -setspeed = --config speed=2 +setspeed = -e config.speed=2 else setspeed = endif ifeq "$(accept)" "YES" -setaccept = --config accept=True +setaccept = -e config.accept=True ifeq "$(PLATFORM)" "YES" -setaccept += --config accept_platform=True +setaccept += -e config.accept_platform=True endif ifeq "$(OS)" "YES" -setaccept += --config accept_os=True +setaccept += -e config.accept_os=True endif else View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4b559f04ab0ea6737e88717ff363d101535aedfa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4b559f04ab0ea6737e88717ff363d101535aedfa You're receiving 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 Jul 6 02:24:14 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 05 Jul 2020 22:24:14 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] hi Message-ID: <5f028b4e5d62e_80bf1893181892233@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: 2b239b32 by Ben Gamari at 2020-07-05T22:24:08-04:00 hi - - - - - 2 changed files: - hadrian/src/Settings/Builders/RunTest.hs - testsuite/mk/test.mk Changes: ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -103,6 +103,7 @@ runTestBuilderArgs = builder RunTest ? do -- TODO: set CABAL_MINIMAL_BUILD/CABAL_PLUGIN_BUILD mconcat [ arg $ "testsuite/driver/runtests.py" , pure [ "--rootdir=" ++ testdir | testdir <- rootdirs ] + , arg "--extra-hc-flag", arg ghcFlags , arg "-e", arg $ "windows=" ++ show windowsHost , arg "-e", arg $ "darwin=" ++ show osxHost , arg "-e", arg $ "config.local=False" @@ -111,23 +112,20 @@ runTestBuilderArgs = builder RunTest ? do , arg "-e", arg $ "config.accept_platform=" ++ show acceptPlatform , arg "-e", arg $ "config.accept_os=" ++ show acceptOS , arg "-e", arg $ "config.exeext=" ++ quote (if null exe then "" else "."<>exe) - , arg "-e", arg $ "config.compiler_debugged=" ++ - show debugged + , arg "-e", arg $ "config.compiler_debugged=" ++ show debugged , arg "-e", arg $ asBool "ghc_with_native_codegen=" withNativeCodeGen , arg "-e", arg $ "config.have_interp=" ++ show withInterpreter , arg "-e", arg $ "config.unregisterised=" ++ show unregisterised - , arg "-e", arg $ "ghc_compiler_always_flags=" ++ quote ghcFlags - , arg "-e", arg $ asBool "ghc_with_dynamic_rts=" (hasRtsWay "dyn") - , arg "-e", arg $ asBool "ghc_with_threaded_rts=" (hasRtsWay "thr") + , arg "-e", arg $ asBool "config.ghc_with_dynamic_rts=" (hasRtsWay "dyn") + , arg "-e", arg $ asBool "config.ghc_with_threaded_rts=" (hasRtsWay "thr") , arg "-e", arg $ asBool "config.have_vanilla=" (hasLibWay vanilla) , arg "-e", arg $ asBool "config.have_dynamic=" (hasLibWay dynamic) , arg "-e", arg $ asBool "config.have_profiling=" (hasLibWay profiling) , arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) - , arg "-e", arg $ asBool "ghc_with_smp=" withSMP - , arg "-e", arg $ asBool "ghc_with_llvm=" withLlvm - + , arg "-e", arg $ asBool "config.ghc_with_smp=" withSMP + , arg "-e", arg $ asBool "config.ghc_with_llvm=" withLlvm , arg "-e", arg $ "config.ghc_dynamic_by_default=" ++ show hasDynamicByDefault , arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic ===================================== testsuite/mk/test.mk ===================================== @@ -79,7 +79,7 @@ else dllext = .so endif -RUNTEST_OPTS += -e "ghc_compiler_always_flags='$(TEST_HC_OPTS)'" +RUNTEST_OPTS += --extra-hc-flag "$(TEST_HC_OPTS)" ifeq "$(GhcDebugged)" "YES" RUNTEST_OPTS += -e "config.compiler_debugged=True" @@ -123,15 +123,15 @@ RUNTEST_OPTS += -e config.have_profiling=False endif ifeq "$(filter thr, $(GhcRTSWays))" "thr" -RUNTEST_OPTS += -e ghc_with_threaded_rts=True +RUNTEST_OPTS += -e config.ghc_with_threaded_rts=True else -RUNTEST_OPTS += -e ghc_with_threaded_rts=False +RUNTEST_OPTS += -e config.ghc_with_threaded_rts=False endif ifeq "$(filter dyn, $(GhcRTSWays))" "dyn" -RUNTEST_OPTS += -e ghc_with_dynamic_rts=True +RUNTEST_OPTS += -e config.ghc_with_dynamic_rts=True else -RUNTEST_OPTS += -e ghc_with_dynamic_rts=False +RUNTEST_OPTS += -e config.ghc_with_dynamic_rts=False endif ifeq "$(GhcWithInterpreter)" "NO" @@ -183,21 +183,21 @@ CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared endif ifeq "$(GhcWithSMP)" "YES" -RUNTEST_OPTS += -e ghc_with_smp=True +RUNTEST_OPTS += -e config.ghc_with_smp=True else -RUNTEST_OPTS += -e ghc_with_smp=False +RUNTEST_OPTS += -e config.ghc_with_smp=False endif # Does the LLVM backend work? ifeq "$(LLC)" "" -RUNTEST_OPTS += -e ghc_with_llvm=False +RUNTEST_OPTS += -e config.ghc_with_llvm=False else ifeq "$(TargetARCH_CPP)" "powerpc" -RUNTEST_OPTS += -e ghc_with_llvm=False +RUNTEST_OPTS += -e config.ghc_with_llvm=False else ifneq "$(LLC)" "llc" # If we have a real detected value for LLVM, then it really ought to work -RUNTEST_OPTS += -e ghc_with_llvm=True +RUNTEST_OPTS += -e config.ghc_with_llvm=True else -RUNTEST_OPTS += -e ghc_with_llvm=False +RUNTEST_OPTS += -e config.ghc_with_llvm=False endif ifeq "$(WINDOWS)" "YES" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b239b32cf53fccfb8240eab48ea5566daf74be6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b239b32cf53fccfb8240eab48ea5566daf74be6 You're receiving 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 Jul 6 03:02:25 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sun, 05 Jul 2020 23:02:25 -0400 Subject: [Git][ghc/ghc][wip/angerman/out-of-range-reloc] 171 commits: [linker] Adds void printLoadedObjects(void); Message-ID: <5f0294411cfa2_80b3f8496a302dc189818b@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/out-of-range-reloc at Glasgow Haskell Compiler / GHC Commits: 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - 7fa6d2cd by Moritz Angermann at 2020-07-05T23:02:19-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - 2ee6fb2b by Moritz Angermann at 2020-07-05T23:02:19-04:00 Cleanup - - - - - 4a5696d8 by Moritz Angermann at 2020-07-05T23:02:19-04:00 Cleanup (2) - - - - - 59e10d7f by Moritz Angermann at 2020-07-05T23:02:19-04:00 kill duplicate prot. It's an argument now. - - - - - 40a18fa2 by Moritz Angermann at 2020-07-05T23:02:19-04:00 Fixup MachO mmapForLinker call. - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/test-metrics.sh - .gitmodules - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Ppr/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a777a0e242a69c1d07721ebe891ca42975b050e5...40a18fa2c30427e9e31fc6a8f5b5c32dddcdb3e7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a777a0e242a69c1d07721ebe891ca42975b050e5...40a18fa2c30427e9e31fc6a8f5b5c32dddcdb3e7 You're receiving 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 Jul 6 03:05:41 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sun, 05 Jul 2020 23:05:41 -0400 Subject: [Git][ghc/ghc][wip/angerman/out-of-range-reloc] Drop aarch64_target check from rts/Linker.c Message-ID: <5f0295057be1c_80b3f8468eee38818985d3@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/out-of-range-reloc at Glasgow Haskell Compiler / GHC Commits: b91af6d1 by Moritz Angermann at 2020-07-06T11:05:26+08:00 Drop aarch64_target check from rts/Linker.c - - - - - 1 changed file: - rts/Linker.c Changes: ===================================== rts/Linker.c ===================================== @@ -188,7 +188,7 @@ int ocTryLoad( ObjectCode* oc ); * * MAP_32BIT not available on OpenBSD/amd64 */ -#if defined(MAP_32BIT) && (defined(x86_64_HOST_ARCH) || (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH))) +#if defined(MAP_32BIT) && (defined(x86_64_HOST_ARCH) || defined(aarch64_HOST_ARCH)) #define MAP_LOW_MEM #define TRY_MAP_32BIT MAP_32BIT #else View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b91af6d1ae1e8cd27121b34430796aa298164ecf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b91af6d1ae1e8cd27121b34430796aa298164ecf You're receiving 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 Jul 6 12:09:15 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Mon, 06 Jul 2020 08:09:15 -0400 Subject: [Git][ghc/ghc][wip/andreask/strict_dicts] 19 commits: Implement -XLexicalNegation (GHC Proposal #229) Message-ID: <5f03146b60d0c_80b113262f01947432@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/strict_dicts at Glasgow Haskell Compiler / GHC Commits: cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - 3a60e34a by Andreas Klebinger at 2020-07-06T14:01:39+02:00 Enable strict dicts by default. - - - - - 30 changed files: - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Driver.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Ways.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/edd339a86e2bb88f760b668b20c6220408c44016...3a60e34a0a78f6917b03d960f3393058cbb83b7f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/edd339a86e2bb88f760b668b20c6220408c44016...3a60e34a0a78f6917b03d960f3393058cbb83b7f You're receiving 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 Jul 6 12:19:21 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 06 Jul 2020 08:19:21 -0400 Subject: [Git][ghc/ghc][wip/angerman/more-rtsSymbols] Fix (1) Message-ID: <5f0316c9ec29c_80b3f849c2be408195182@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/more-rtsSymbols at Glasgow Haskell Compiler / GHC Commits: efa72a2c by Moritz Angermann at 2020-07-06T20:19:04+08:00 Fix (1) - - - - - 1 changed file: - rts/RtsSymbols.c Changes: ===================================== rts/RtsSymbols.c ===================================== @@ -1143,7 +1143,7 @@ SymI_NeedsProto(__floatunsitf) #if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) -#define RTS_LIBGCC_SYMBOLS LIBGCC_SYMBOLS_32 +#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 #elif defined(__GNUC__) && SIZEOF_VOID_P == 8 && defined(aarch64_HOST_OS) #define RTS_LIBGCC_SYMBOLS \ RTS_LIBGCC_SYMBOLS_64 \ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/efa72a2cc69ecef3087d9893ce6746bd2c41fc08 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/efa72a2cc69ecef3087d9893ce6746bd2c41fc08 You're receiving 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 Jul 6 12:31:54 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Mon, 06 Jul 2020 08:31:54 -0400 Subject: [Git][ghc/ghc][wip/mono-local-binds] Turn on -XMonoLocalBinds by default Message-ID: <5f0319ba6419d_80b3f8486100a781954088@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/mono-local-binds at Glasgow Haskell Compiler / GHC Commits: d216a2c8 by Sebastian Graf at 2020-07-06T14:31:10+02:00 Turn on -XMonoLocalBinds by default And fix the resulting type errors. - - - - - 7 changed files: - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/SysTools.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/CmmToAsm/Reg/Linear.hs ===================================== @@ -202,7 +202,7 @@ regAlloc _ (CmmProc _ _ _ _) -- an entry in the block map or it is the first block. -- linearRegAlloc - :: (Outputable instr, Instruction instr) + :: forall instr . (Outputable instr, Instruction instr) => NCGConfig -> [BlockId] -- ^ entry points -> BlockMap RegSet @@ -228,6 +228,8 @@ linearRegAlloc config entry_ids block_live sccs ArchJavaScript -> panic "linearRegAlloc ArchJavaScript" ArchUnknown -> panic "linearRegAlloc ArchUnknown" where + go :: (FR regs, Outputable regs) + => regs -> UniqSM ([NatBasicBlock instr], RegAllocStats, Int) go f = linearRegAlloc' config f entry_ids block_live sccs platform = ncgPlatform config @@ -953,4 +955,3 @@ loadTemp vreg (ReadMem slot) hreg spills loadTemp _ _ _ spills = return spills - ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -2320,6 +2320,7 @@ lintCoercion this@(AxiomRuleCo ax cos) Nothing -> err "Malformed use of AxiomRuleCo" [ ppr this ] Just _ -> return (AxiomRuleCo ax cos') } where + err :: forall a. String -> [SDoc] -> LintM a err m xs = failWithL $ hang (text m) 2 $ vcat (text "Rule:" <+> ppr (coaxrName ax) : xs) ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -1940,7 +1940,7 @@ completeCall env var cont log_inlining $ sep [text "Inlining done:", nest 4 (ppr var)] | otherwise - = liftIO $ log_inlining $ + = log_inlining $ sep [text "Inlining done: " <> ppr var, nest 4 (vcat [text "Inlined fn: " <+> nest 2 (ppr unfolding), text "Cont: " <+> ppr cont])] ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1366,7 +1366,8 @@ parUpsweep_one mod home_mod_map comp_graph_loops lcl_dflags mHscMessage cleanup -- -- There better had not be any cyclic groups here -- we check for them. upsweep - :: GhcMonad m + :: forall m + . GhcMonad m => Maybe Messager -> HomePackageTable -- ^ HPT from last time round (pruned) -> StableModules -- ^ stable modules (see checkStability) @@ -1408,8 +1409,7 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do return (Failed, done') upsweep' - :: GhcMonad m - => HomePackageTable + :: HomePackageTable -> ModuleGraph -> [SCC ModSummary] -> Int ===================================== compiler/GHC/Runtime/Linker.hs ===================================== @@ -1132,6 +1132,7 @@ unload_wkr hsc_env keep_linkables pls at PersistentLinkerState{..} = do -- Note that we want to remove all *local* -- (i.e. non-isExternal) names too (these are the -- temporary bindings from the command line). + keep_name :: (Name, a) -> Bool keep_name (n,_) = isExternalName n && nameModule n `elemModuleSet` bcos_retained ===================================== compiler/GHC/SysTools.hs ===================================== @@ -8,7 +8,7 @@ ----------------------------------------------------------------------------- -} -{-# LANGUAGE CPP, MultiWayIf, ScopedTypeVariables #-} +{-# LANGUAGE CPP, MultiWayIf, ScopedTypeVariables, NoMonoLocalBinds #-} module GHC.SysTools ( -- * Initialisation @@ -141,6 +141,7 @@ lazyInitLlvmConfig top_dir passes <- readAndParse "llvm-passes" id return $ LlvmConfig { llvmTargets = targets, llvmPasses = passes } where + -- This one has a really complicated type, hence -XNoMonoLocalBinds readAndParse name builder = do let llvmConfigFile = top_dir name llvmConfigStr <- readFile llvmConfigFile ===================================== compiler/ghc.cabal.in ===================================== @@ -153,6 +153,7 @@ Library -- we use an explicit Prelude Default-Extensions: NoImplicitPrelude + MonoLocalBinds Exposed-Modules: GHC.Iface.Ext.Types View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d216a2c818235cfa1cbd0756b146223e08430d59 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d216a2c818235cfa1cbd0756b146223e08430d59 You're receiving 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 Jul 6 13:41:43 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 06 Jul 2020 09:41:43 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/angerman/cross-test-suite Message-ID: <5f032a17222e2_80b3f8496a302dc196354c@gitlab.haskell.org.mail> Moritz Angermann pushed new branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/angerman/cross-test-suite You're receiving 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 Jul 6 16:15:32 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 06 Jul 2020 12:15:32 -0400 Subject: [Git][ghc/ghc][ghc-8.8] gitlab-ci: Reintroduce workflow stanza Message-ID: <5f034e24b7fd2_80b3f84960bea141985151@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC Commits: ac697a44 by Ben Gamari at 2020-07-06T12:15:24-04:00 gitlab-ci: Reintroduce workflow stanza - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -32,6 +32,15 @@ stages: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' +workflow: + # N.B. Don't run on wip/ branches, instead on run on merge requests. + rules: + - if: $CI_MERGE_REQUEST_ID + - if: $CI_COMMIT_TAG + - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + - if: '$CI_PIPELINE_SOURCE == "web"' + ############################################################ # Runner Tags ############################################################ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac697a44ffb216cb351468b1b0e9ddb84de1495a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac697a44ffb216cb351468b1b0e9ddb84de1495a You're receiving 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 Jul 6 17:51:47 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 06 Jul 2020 13:51:47 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/simon-perf Message-ID: <5f0364b32195a_80b3f84941e98a019993ee@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/simon-perf at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/simon-perf You're receiving 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 Jul 6 18:35:57 2020 From: gitlab at gitlab.haskell.org (John Ericson) Date: Mon, 06 Jul 2020 14:35:57 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/int64-everywhere Message-ID: <5f036f0da5f05_80b1167d5c0200706f@gitlab.haskell.org.mail> John Ericson pushed new branch wip/int64-everywhere at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int64-everywhere You're receiving 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 Jul 6 18:40:07 2020 From: gitlab at gitlab.haskell.org (John Ericson) Date: Mon, 06 Jul 2020 14:40:07 -0400 Subject: [Git][ghc/ghc][wip/int64-everywhere] Inline INT64 and WORD64 macros in primops.txt.pp Message-ID: <5f037007a6c12_80b3f848695b13c2007291@gitlab.haskell.org.mail> John Ericson pushed to branch wip/int64-everywhere at Glasgow Haskell Compiler / GHC Commits: 5e03d64d by John Ericson at 2020-07-06T14:39:38-04:00 Inline INT64 and WORD64 macros in primops.txt.pp The definition is now unconditional so there is no reason for that CPP. - - - - - 1 changed file: - compiler/GHC/Builtin/primops.txt.pp Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -62,8 +62,8 @@ -- 3-tuple in the list of 3-tuples. That is, the vector attribute allows us to -- define a family of types or primops. Vector support also adds three new -- keywords: VECTOR, SCALAR, and VECTUPLE. These keywords are expanded to types --- derived from the 3-tuple. For the 3-tuple , VECTOR expands to --- Int64X2#, SCALAR expands to INT64, and VECTUPLE expands to (# INT64, INT64 +-- derived from the 3-tuple. For the 3-tuple , VECTOR expands to +-- Int64X2#, SCALAR expands to Int64#, and VECTUPLE expands to (# Int64#, Int64# -- #). defaults @@ -172,10 +172,6 @@ section "The word size story." #define INT32 Int# #define WORD32 Word# --- TODO inline -#define INT64 Int64# -#define WORD64 Word64# - -- This type won't be exported directly (since there is no concrete -- syntax for this sort of export) so we'll have to manually patch -- export lists in both GHC and Haddock. @@ -828,7 +824,7 @@ primop PopCnt16Op "popCnt16#" Monadic Word# -> Word# {Count the number of set bits in the lower 16 bits of a word.} primop PopCnt32Op "popCnt32#" Monadic Word# -> Word# {Count the number of set bits in the lower 32 bits of a word.} -primop PopCnt64Op "popCnt64#" GenPrimOp WORD64 -> Word# +primop PopCnt64Op "popCnt64#" GenPrimOp Word64# -> Word# {Count the number of set bits in a 64-bit word.} primop PopCntOp "popCnt#" Monadic Word# -> Word# {Count the number of set bits in a word.} @@ -839,7 +835,7 @@ primop Pdep16Op "pdep16#" Dyadic Word# -> Word# -> Word# {Deposit bits to lower 16 bits of a word at locations specified by a mask.} primop Pdep32Op "pdep32#" Dyadic Word# -> Word# -> Word# {Deposit bits to lower 32 bits of a word at locations specified by a mask.} -primop Pdep64Op "pdep64#" GenPrimOp WORD64 -> WORD64 -> WORD64 +primop Pdep64Op "pdep64#" GenPrimOp Word64# -> Word64# -> Word64# {Deposit bits to a word at locations specified by a mask.} primop PdepOp "pdep#" Dyadic Word# -> Word# -> Word# {Deposit bits to a word at locations specified by a mask.} @@ -850,7 +846,7 @@ primop Pext16Op "pext16#" Dyadic Word# -> Word# -> Word# {Extract bits from lower 16 bits of a word at locations specified by a mask.} primop Pext32Op "pext32#" Dyadic Word# -> Word# -> Word# {Extract bits from lower 32 bits of a word at locations specified by a mask.} -primop Pext64Op "pext64#" GenPrimOp WORD64 -> WORD64 -> WORD64 +primop Pext64Op "pext64#" GenPrimOp Word64# -> Word64# -> Word64# {Extract bits from a word at locations specified by a mask.} primop PextOp "pext#" Dyadic Word# -> Word# -> Word# {Extract bits from a word at locations specified by a mask.} @@ -861,7 +857,7 @@ primop Clz16Op "clz16#" Monadic Word# -> Word# {Count leading zeros in the lower 16 bits of a word.} primop Clz32Op "clz32#" Monadic Word# -> Word# {Count leading zeros in the lower 32 bits of a word.} -primop Clz64Op "clz64#" GenPrimOp WORD64 -> Word# +primop Clz64Op "clz64#" GenPrimOp Word64# -> Word# {Count leading zeros in a 64-bit word.} primop ClzOp "clz#" Monadic Word# -> Word# {Count leading zeros in a word.} @@ -872,7 +868,7 @@ primop Ctz16Op "ctz16#" Monadic Word# -> Word# {Count trailing zeros in the lower 16 bits of a word.} primop Ctz32Op "ctz32#" Monadic Word# -> Word# {Count trailing zeros in the lower 32 bits of a word.} -primop Ctz64Op "ctz64#" GenPrimOp WORD64 -> Word# +primop Ctz64Op "ctz64#" GenPrimOp Word64# -> Word# {Count trailing zeros in a 64-bit word.} primop CtzOp "ctz#" Monadic Word# -> Word# {Count trailing zeros in a word.} @@ -881,7 +877,7 @@ primop BSwap16Op "byteSwap16#" Monadic Word# -> Word# {Swap bytes in the lower 16 bits of a word. The higher bytes are undefined. } primop BSwap32Op "byteSwap32#" Monadic Word# -> Word# {Swap bytes in the lower 32 bits of a word. The higher bytes are undefined. } -primop BSwap64Op "byteSwap64#" Monadic WORD64 -> WORD64 +primop BSwap64Op "byteSwap64#" Monadic Word64# -> Word64# {Swap bytes in a 64 bits of a word.} primop BSwapOp "byteSwap#" Monadic Word# -> Word# {Swap bytes in a word.} @@ -892,7 +888,7 @@ primop BRev16Op "bitReverse16#" Monadic Word# -> Word# {Reverse the order of the bits in a 16-bit word.} primop BRev32Op "bitReverse32#" Monadic Word# -> Word# {Reverse the order of the bits in a 32-bit word.} -primop BRev64Op "bitReverse64#" Monadic WORD64 -> WORD64 +primop BRev64Op "bitReverse64#" Monadic Word64# -> Word64# {Reverse the order of the bits in a 64-bit word.} primop BRevOp "bitReverse#" Monadic Word# -> Word# {Reverse the order of the bits in a word.} @@ -1071,7 +1067,7 @@ primop DoubleDecode_2IntOp "decodeDouble_2Int#" GenPrimOp with out_of_line = True primop DoubleDecode_Int64Op "decodeDouble_Int64#" GenPrimOp - Double# -> (# INT64, Int# #) + Double# -> (# Int64#, Int# #) {Decode {\tt Double\#} into mantissa and base-2 exponent.} with out_of_line = True @@ -1712,7 +1708,7 @@ primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp with can_fail = True primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp - ByteArray# -> Int# -> INT64 + ByteArray# -> Int# -> Int64# {Read 64-bit integer; offset in 64-bit words.} with can_fail = True @@ -1732,7 +1728,7 @@ primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp with can_fail = True primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp - ByteArray# -> Int# -> WORD64 + ByteArray# -> Int# -> Word64# {Read 64-bit word; offset in 64-bit words.} with can_fail = True @@ -1777,7 +1773,7 @@ primop IndexByteArrayOp_Word8AsInt32 "indexWord8ArrayAsInt32#" GenPrimOp with can_fail = True primop IndexByteArrayOp_Word8AsInt64 "indexWord8ArrayAsInt64#" GenPrimOp - ByteArray# -> Int# -> INT64 + ByteArray# -> Int# -> Int64# {Read 64-bit int; offset in bytes.} with can_fail = True @@ -1797,7 +1793,7 @@ primop IndexByteArrayOp_Word8AsWord32 "indexWord8ArrayAsWord32#" GenPrimOp with can_fail = True primop IndexByteArrayOp_Word8AsWord64 "indexWord8ArrayAsWord64#" GenPrimOp - ByteArray# -> Int# -> WORD64 + ByteArray# -> Int# -> Word64# {Read 64-bit word; offset in bytes.} with can_fail = True @@ -1866,7 +1862,7 @@ primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp can_fail = True primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) + MutableByteArray# s -> Int# -> State# s -> (# State# s, Int64# #) with has_side_effects = True can_fail = True @@ -1886,7 +1882,7 @@ primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp can_fail = True primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) + MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64# #) with has_side_effects = True can_fail = True @@ -1931,7 +1927,7 @@ primop ReadByteArrayOp_Word8AsInt32 "readWord8ArrayAsInt32#" GenPrimOp can_fail = True primop ReadByteArrayOp_Word8AsInt64 "readWord8ArrayAsInt64#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) + MutableByteArray# s -> Int# -> State# s -> (# State# s, Int64# #) with has_side_effects = True can_fail = True @@ -1951,7 +1947,7 @@ primop ReadByteArrayOp_Word8AsWord32 "readWord8ArrayAsWord32#" GenPrimOp can_fail = True primop ReadByteArrayOp_Word8AsWord64 "readWord8ArrayAsWord64#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) + MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64# #) with has_side_effects = True can_fail = True @@ -2018,7 +2014,7 @@ primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp can_fail = True primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp - MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s + MutableByteArray# s -> Int# -> Int64# -> State# s -> State# s with can_fail = True has_side_effects = True @@ -2038,7 +2034,7 @@ primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp can_fail = True primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp - MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s + MutableByteArray# s -> Int# -> Word64# -> State# s -> State# s with has_side_effects = True can_fail = True @@ -2083,7 +2079,7 @@ primop WriteByteArrayOp_Word8AsInt32 "writeWord8ArrayAsInt32#" GenPrimOp can_fail = True primop WriteByteArrayOp_Word8AsInt64 "writeWord8ArrayAsInt64#" GenPrimOp - MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s + MutableByteArray# s -> Int# -> Int64# -> State# s -> State# s with has_side_effects = True can_fail = True @@ -2103,7 +2099,7 @@ primop WriteByteArrayOp_Word8AsWord32 "writeWord8ArrayAsWord32#" GenPrimOp can_fail = True primop WriteByteArrayOp_Word8AsWord64 "writeWord8ArrayAsWord64#" GenPrimOp - MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s + MutableByteArray# s -> Int# -> Word64# -> State# s -> State# s with has_side_effects = True can_fail = True @@ -2462,7 +2458,7 @@ primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp with can_fail = True primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp - Addr# -> Int# -> INT64 + Addr# -> Int# -> Int64# with can_fail = True primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp @@ -2478,7 +2474,7 @@ primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp with can_fail = True primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp - Addr# -> Int# -> WORD64 + Addr# -> Int# -> Word64# with can_fail = True primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp @@ -2539,7 +2535,7 @@ primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp can_fail = True primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp - Addr# -> Int# -> State# s -> (# State# s, INT64 #) + Addr# -> Int# -> State# s -> (# State# s, Int64# #) with has_side_effects = True can_fail = True @@ -2559,7 +2555,7 @@ primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp can_fail = True primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp - Addr# -> Int# -> State# s -> (# State# s, WORD64 #) + Addr# -> Int# -> State# s -> (# State# s, Word64# #) with has_side_effects = True can_fail = True @@ -2619,7 +2615,7 @@ primop WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp can_fail = True primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp - Addr# -> Int# -> INT64 -> State# s -> State# s + Addr# -> Int# -> Int64# -> State# s -> State# s with has_side_effects = True can_fail = True @@ -2639,7 +2635,7 @@ primop WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp can_fail = True primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp - Addr# -> Int# -> WORD64 -> State# s -> State# s + Addr# -> Int# -> Word64# -> State# s -> State# s with has_side_effects = True can_fail = True @@ -3619,7 +3615,7 @@ primop TraceMarkerOp "traceMarker#" GenPrimOp out_of_line = True primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp - INT64 -> State# RealWorld -> State# RealWorld + Int64# -> State# RealWorld -> State# RealWorld { Sets the allocation counter for the current thread to the given value. } with has_side_effects = True @@ -3650,20 +3646,20 @@ section "SIMD Vectors" ------------------------------------------------------------------------ #define ALL_VECTOR_TYPES \ - [,,, \ - ,,,, \ - ,,,, \ - ,,,, \ - ,,,, \ - ,,,, \ + [,,, \ + ,,,, \ + ,,,, \ + ,,,, \ + ,,,, \ + ,,,, \ ,, \ ,, \ ,,] #define SIGNED_VECTOR_TYPES \ - [,,, \ - ,,,, \ - ,,,, \ + [,,, \ + ,,,, \ + ,,,, \ ,, \ ,, \ ,,] @@ -3674,12 +3670,12 @@ section "SIMD Vectors" ,,] #define INT_VECTOR_TYPES \ - [,,, \ - ,,,, \ - ,,,, \ - ,,,, \ - ,,,, \ - ,,,,] + [,,, \ + ,,,, \ + ,,,, \ + ,,,, \ + ,,,, \ + ,,,,] primtype VECTOR with llvm_only = True View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e03d64df48b1f26ac872a89dd20072796669504 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e03d64df48b1f26ac872a89dd20072796669504 You're receiving 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 Jul 6 18:41:38 2020 From: gitlab at gitlab.haskell.org (John Ericson) Date: Mon, 06 Jul 2020 14:41:38 -0400 Subject: [Git][ghc/ghc][wip/int64-everywhere] 2 commits: Make fixed-size `Int32#` and `Int64#` Message-ID: <5f0370622ca74_80bda8bdb42007447@gitlab.haskell.org.mail> John Ericson pushed to branch wip/int64-everywhere at Glasgow Haskell Compiler / GHC Commits: 753932b2 by John Ericson at 2020-07-06T14:40:32-04:00 Make fixed-size `Int32#` and `Int64#` The boxed Int64 uses Int64#, but Int32# still uses Int#. The 32-bit case is less pressing to change because it is not a source of brittle CPP---it is the same thing on all platforms. We need Int64/Word64 constant folding to avoid the let/app restriction on Core, so that is implemented now. 32-bit constant unfolding and 32-bit literals are left as follow-up. This is the bulk of #11953 - - - - - 8d518022 by John Ericson at 2020-07-06T14:40:57-04:00 Inline INT64 and WORD64 macros in primops.txt.pp The definition is now unconditional so there is no reason for that CPP. - - - - - 28 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/HsToCore/Match/Literal.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Utils/Outputable.hs - includes/stg/Prim.h - libraries/base/GHC/Exts.hs - libraries/base/GHC/Float.hs - libraries/base/GHC/Float/ConversionUtils.hs - libraries/base/GHC/Float/RealFracMethods.hs - libraries/base/GHC/Int.hs - libraries/base/GHC/StaticPtr.hs - libraries/base/GHC/Word.hs - libraries/binary - libraries/bytestring - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs - libraries/ghc-prim/GHC/Classes.hs - − libraries/ghc-prim/GHC/IntWord64.hs - libraries/ghc-prim/GHC/Prim/Ext.hs - libraries/ghc-prim/GHC/Types.hs - libraries/ghc-prim/cbits/atomic.c - − libraries/ghc-prim/cbits/longlong.c - libraries/ghc-prim/ghc-prim.cabal - rts/package.conf.in Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -62,8 +62,8 @@ -- 3-tuple in the list of 3-tuples. That is, the vector attribute allows us to -- define a family of types or primops. Vector support also adds three new -- keywords: VECTOR, SCALAR, and VECTUPLE. These keywords are expanded to types --- derived from the 3-tuple. For the 3-tuple , VECTOR expands to --- Int64X2#, SCALAR expands to INT64, and VECTUPLE expands to (# INT64, INT64 +-- derived from the 3-tuple. For the 3-tuple , VECTOR expands to +-- Int64X2#, SCALAR expands to Int64#, and VECTUPLE expands to (# Int64#, Int64# -- #). defaults @@ -118,8 +118,6 @@ defaults -- description fields should be legal latex. Descriptions can contain -- matched pairs of embedded curly brackets. -#include "MachDeps.h" - section "The word size story." {Haskell98 specifies that signed integers (type {\tt Int}) must contain at least 30 bits. GHC always implements {\tt @@ -141,22 +139,12 @@ section "The word size story." In addition, GHC supports families of explicit-sized integers and words at 8, 16, 32, and 64 bits, with the usual arithmetic operations, comparisons, and a range of - conversions. The 8-bit and 16-bit sizes are always + conversions. The fixed-size integers and words are always represented as {\tt Int\#} and {\tt Word\#}, and the operations implemented in terms of the primops on these types, with suitable range restrictions on the results (using - the {\tt narrow$n$Int\#} and {\tt narrow$n$Word\#} families - of primops. The 32-bit sizes are represented using {\tt - Int\#} and {\tt Word\#} when {\tt WORD\_SIZE\_IN\_BITS} - $\geq$ 32; otherwise, these are represented using distinct - primitive types {\tt Int32\#} and {\tt Word32\#}. These (when - needed) have a complete set of corresponding operations; - however, nearly all of these are implemented as external C - functions rather than as primops. Exactly the same story - applies to the 64-bit sizes. All of these details are hidden - under the {\tt PrelInt} and {\tt PrelWord} modules, which use - {\tt \#if}-defs to invoke the appropriate types and - operators. + the {\tt intToInt$n$\#} and {\tt wordToWord$n$\#} families of + primops. Word size also matters for the families of primops for indexing/reading/writing fixed-size quantities at offsets @@ -179,18 +167,11 @@ section "The word size story." so are not available in this case. } -- Define synonyms for indexing ops. +-- TODO use Int32# once we have `data Int = I# Int#` for all N. #define INT32 Int# #define WORD32 Word# -#if WORD_SIZE_IN_BITS < 64 -#define INT64 Int64# -#define WORD64 Word64# -#else -#define INT64 Int# -#define WORD64 Word# -#endif - -- This type won't be exported directly (since there is no concrete -- syntax for this sort of export) so we'll have to manually patch -- export lists in both GHC and Haddock. @@ -235,8 +216,8 @@ section "Int8#" primtype Int8# -primop Int8Extend "extendInt8#" GenPrimOp Int8# -> Int# -primop Int8Narrow "narrowInt8#" GenPrimOp Int# -> Int8# +primop Int8ToInt "int8ToInt#" GenPrimOp Int8# -> Int# +primop IntToInt8 "intToInt8#" GenPrimOp Int# -> Int8# primop Int8NegOp "negateInt8#" Monadic Int8# -> Int8# @@ -271,13 +252,13 @@ primop Int8NeOp "neInt8#" Compare Int8# -> Int8# -> Int# ------------------------------------------------------------------------ section "Word8#" - {Operations on 8-bit unsigned integers.} + {Operations on 8-bit unsigned words.} ------------------------------------------------------------------------ primtype Word8# -primop Word8Extend "extendWord8#" GenPrimOp Word8# -> Word# -primop Word8Narrow "narrowWord8#" GenPrimOp Word# -> Word8# +primop Word8ToWord "word8ToWord#" GenPrimOp Word8# -> Word# +primop WordToWord8 "wordToWord8#" GenPrimOp Word# -> Word8# primop Word8NotOp "notWord8#" Monadic Word8# -> Word8# @@ -317,8 +298,8 @@ section "Int16#" primtype Int16# -primop Int16Extend "extendInt16#" GenPrimOp Int16# -> Int# -primop Int16Narrow "narrowInt16#" GenPrimOp Int# -> Int16# +primop Int16ToInt "int16ToInt#" GenPrimOp Int16# -> Int# +primop IntToInt16 "intToInt16#" GenPrimOp Int# -> Int16# primop Int16NegOp "negateInt16#" Monadic Int16# -> Int16# @@ -353,13 +334,13 @@ primop Int16NeOp "neInt16#" Compare Int16# -> Int16# -> Int# ------------------------------------------------------------------------ section "Word16#" - {Operations on 16-bit unsigned integers.} + {Operations on 16-bit unsigned words.} ------------------------------------------------------------------------ primtype Word16# -primop Word16Extend "extendWord16#" GenPrimOp Word16# -> Word# -primop Word16Narrow "narrowWord16#" GenPrimOp Word# -> Word16# +primop Word16ToWord "word16ToWord#" GenPrimOp Word16# -> Word# +primop WordToWord16 "wordToWord16#" GenPrimOp Word# -> Word16# primop Word16NotOp "notWord16#" Monadic Word16# -> Word16# @@ -392,26 +373,213 @@ primop Word16LeOp "leWord16#" Compare Word16# -> Word16# -> Int# primop Word16LtOp "ltWord16#" Compare Word16# -> Word16# -> Int# primop Word16NeOp "neWord16#" Compare Word16# -> Word16# -> Int# -#if WORD_SIZE_IN_BITS < 64 +------------------------------------------------------------------------ +section "Int32#" + {Operations on 32-bit integers.} +------------------------------------------------------------------------ + +primtype Int32# + +primop Int32ToInt "int32ToInt#" GenPrimOp Int32# -> Int# +primop IntToInt32 "intToInt32#" GenPrimOp Int# -> Int32# + +primop Int32NegOp "negateInt32#" Monadic Int32# -> Int32# + +primop Int32AddOp "plusInt32#" Dyadic Int32# -> Int32# -> Int32# + with + commutable = True + +primop Int32SubOp "subInt32#" Dyadic Int32# -> Int32# -> Int32# + +primop Int32MulOp "timesInt32#" Dyadic Int32# -> Int32# -> Int32# + with + commutable = True + +primop Int32QuotOp "quotInt32#" Dyadic Int32# -> Int32# -> Int32# + with + can_fail = True + +primop Int32RemOp "remInt32#" Dyadic Int32# -> Int32# -> Int32# + with + can_fail = True + +primop Int32QuotRemOp "quotRemInt32#" GenPrimOp Int32# -> Int32# -> (# Int32#, Int32# #) + with + can_fail = True + +primop Int32SllOp "uncheckedIShiftL32#" GenPrimOp Int32# -> Int# -> Int32# +primop Int32SraOp "uncheckedIShiftRA32#" GenPrimOp Int32# -> Int# -> Int32# +primop Int32SrlOp "uncheckedIShiftRL32#" GenPrimOp Int32# -> Int# -> Int32# + +primop Int32ToWord32Op "int32ToWord32#" GenPrimOp Int32# -> Word32# + with code_size = 0 + +primop Int32EqOp "eqInt32#" Compare Int32# -> Int32# -> Int# +primop Int32GeOp "geInt32#" Compare Int32# -> Int32# -> Int# +primop Int32GtOp "gtInt32#" Compare Int32# -> Int32# -> Int# +primop Int32LeOp "leInt32#" Compare Int32# -> Int32# -> Int# +primop Int32LtOp "ltInt32#" Compare Int32# -> Int32# -> Int# +primop Int32NeOp "neInt32#" Compare Int32# -> Int32# -> Int# + +------------------------------------------------------------------------ +section "Word32#" + {Operations on 32-bit unsigned words.} +------------------------------------------------------------------------ + +primtype Word32# + +primop Word32ToWord "word32ToWord#" GenPrimOp Word32# -> Word# +primop WordToWord32 "wordToWord32#" GenPrimOp Word# -> Word32# + +primop Word32AddOp "plusWord32#" Dyadic Word32# -> Word32# -> Word32# + with + commutable = True + +primop Word32SubOp "subWord32#" Dyadic Word32# -> Word32# -> Word32# + +primop Word32MulOp "timesWord32#" Dyadic Word32# -> Word32# -> Word32# + with + commutable = True + +primop Word32QuotOp "quotWord32#" Dyadic Word32# -> Word32# -> Word32# + with + can_fail = True + +primop Word32RemOp "remWord32#" Dyadic Word32# -> Word32# -> Word32# + with + can_fail = True + +primop Word32QuotRemOp "quotRemWord32#" GenPrimOp Word32# -> Word32# -> (# Word32#, Word32# #) + with + can_fail = True + +primop Word32AndOp "and32#" Dyadic Word32# -> Word32# -> Word32# + with commutable = True + +primop Word32OrOp "or32#" Dyadic Word32# -> Word32# -> Word32# + with commutable = True + +primop Word32XorOp "xor32#" Dyadic Word32# -> Word32# -> Word32# + with commutable = True + +primop Word32NotOp "not32#" Monadic Word32# -> Word32# + +primop Word32SllOp "uncheckedShiftL32#" GenPrimOp Word32# -> Int# -> Word32# +primop Word32SrlOp "uncheckedShiftRL32#" GenPrimOp Word32# -> Int# -> Word32# + +primop Word32ToInt32Op "word32ToInt32#" GenPrimOp Word32# -> Int32# + with code_size = 0 + +primop Word32EqOp "eqWord32#" Compare Word32# -> Word32# -> Int# +primop Word32GeOp "geWord32#" Compare Word32# -> Word32# -> Int# +primop Word32GtOp "gtWord32#" Compare Word32# -> Word32# -> Int# +primop Word32LeOp "leWord32#" Compare Word32# -> Word32# -> Int# +primop Word32LtOp "ltWord32#" Compare Word32# -> Word32# -> Int# +primop Word32NeOp "neWord32#" Compare Word32# -> Word32# -> Int# + ------------------------------------------------------------------------ section "Int64#" - {Operations on 64-bit unsigned words. This type is only used - if plain {\tt Int\#} has less than 64 bits. In any case, the operations - are not primops; they are implemented (if needed) as ccalls instead.} + {Operations on 64-bit integers.} ------------------------------------------------------------------------ primtype Int64# +primop Int64ToInt "int64ToInt#" GenPrimOp Int64# -> Int# +primop IntToInt64 "intToInt64#" GenPrimOp Int# -> Int64# + +primop Int64NegOp "negateInt64#" Monadic Int64# -> Int64# + +primop Int64AddOp "plusInt64#" Dyadic Int64# -> Int64# -> Int64# + with + commutable = True + +primop Int64SubOp "subInt64#" Dyadic Int64# -> Int64# -> Int64# + +primop Int64MulOp "timesInt64#" Dyadic Int64# -> Int64# -> Int64# + with + commutable = True + +primop Int64QuotOp "quotInt64#" Dyadic Int64# -> Int64# -> Int64# + with + can_fail = True + +primop Int64RemOp "remInt64#" Dyadic Int64# -> Int64# -> Int64# + with + can_fail = True + +primop Int64QuotRemOp "quotRemInt64#" GenPrimOp Int64# -> Int64# -> (# Int64#, Int64# #) + with + can_fail = True + +primop Int64SllOp "uncheckedIShiftL64#" GenPrimOp Int64# -> Int# -> Int64# +primop Int64SraOp "uncheckedIShiftRA64#" GenPrimOp Int64# -> Int# -> Int64# +primop Int64SrlOp "uncheckedIShiftRL64#" GenPrimOp Int64# -> Int# -> Int64# + +primop Int64ToWord64Op "int64ToWord64#" GenPrimOp Int64# -> Word64# + with code_size = 0 + +primop Int64EqOp "eqInt64#" Compare Int64# -> Int64# -> Int# +primop Int64GeOp "geInt64#" Compare Int64# -> Int64# -> Int# +primop Int64GtOp "gtInt64#" Compare Int64# -> Int64# -> Int# +primop Int64LeOp "leInt64#" Compare Int64# -> Int64# -> Int# +primop Int64LtOp "ltInt64#" Compare Int64# -> Int64# -> Int# +primop Int64NeOp "neInt64#" Compare Int64# -> Int64# -> Int# + ------------------------------------------------------------------------ section "Word64#" - {Operations on 64-bit unsigned words. This type is only used - if plain {\tt Word\#} has less than 64 bits. In any case, the operations - are not primops; they are implemented (if needed) as ccalls instead.} + {Operations on 64-bit unsigned words.} ------------------------------------------------------------------------ primtype Word64# -#endif +primop Word64ToWord "word64ToWord#" GenPrimOp Word64# -> Word# +primop WordToWord64 "wordToWord64#" GenPrimOp Word# -> Word64# + +primop Word64AddOp "plusWord64#" Dyadic Word64# -> Word64# -> Word64# + with + commutable = True + +primop Word64SubOp "subWord64#" Dyadic Word64# -> Word64# -> Word64# + +primop Word64MulOp "timesWord64#" Dyadic Word64# -> Word64# -> Word64# + with + commutable = True + +primop Word64QuotOp "quotWord64#" Dyadic Word64# -> Word64# -> Word64# + with + can_fail = True + +primop Word64RemOp "remWord64#" Dyadic Word64# -> Word64# -> Word64# + with + can_fail = True + +primop Word64QuotRemOp "quotRemWord64#" GenPrimOp Word64# -> Word64# -> (# Word64#, Word64# #) + with + can_fail = True + +primop Word64AndOp "and64#" Dyadic Word64# -> Word64# -> Word64# + with commutable = True + +primop Word64OrOp "or64#" Dyadic Word64# -> Word64# -> Word64# + with commutable = True + +primop Word64XorOp "xor64#" Dyadic Word64# -> Word64# -> Word64# + with commutable = True + +primop Word64NotOp "not64#" Monadic Word64# -> Word64# + +primop Word64SllOp "uncheckedShiftL64#" GenPrimOp Word64# -> Int# -> Word64# +primop Word64SrlOp "uncheckedShiftRL64#" GenPrimOp Word64# -> Int# -> Word64# + +primop Word64ToInt64Op "word64ToInt64#" GenPrimOp Word64# -> Int64# + with code_size = 0 + +primop Word64EqOp "eqWord64#" Compare Word64# -> Word64# -> Int# +primop Word64GeOp "geWord64#" Compare Word64# -> Word64# -> Int# +primop Word64GtOp "gtWord64#" Compare Word64# -> Word64# -> Int# +primop Word64LeOp "leWord64#" Compare Word64# -> Word64# -> Int# +primop Word64LtOp "ltWord64#" Compare Word64# -> Word64# -> Int# +primop Word64NeOp "neWord64#" Compare Word64# -> Word64# -> Int# ------------------------------------------------------------------------ section "Int#" @@ -484,19 +652,19 @@ primop IntQuotRemOp "quotRemInt#" GenPrimOp {Rounds towards zero.} with can_fail = True -primop AndIOp "andI#" Dyadic Int# -> Int# -> Int# +primop IntAndOp "andI#" Dyadic Int# -> Int# -> Int# {Bitwise "and".} with commutable = True -primop OrIOp "orI#" Dyadic Int# -> Int# -> Int# +primop IntOrOp "orI#" Dyadic Int# -> Int# -> Int# {Bitwise "or".} with commutable = True -primop XorIOp "xorI#" Dyadic Int# -> Int# -> Int# +primop IntXorOp "xorI#" Dyadic Int# -> Int# -> Int# {Bitwise "xor".} with commutable = True -primop NotIOp "notI#" Monadic Int# -> Int# +primop IntNotOp "notI#" Monadic Int# -> Int# {Bitwise "not", also known as the binary complement.} primop IntNegOp "negateInt#" Monadic Int# -> Int# @@ -556,13 +724,13 @@ primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double# primop Word2FloatOp "word2Float#" GenPrimOp Word# -> Float# primop Word2DoubleOp "word2Double#" GenPrimOp Word# -> Double# -primop ISllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int# +primop IntSllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int# {Shift left. Result undefined if shift amount is not in the range 0 to word size - 1 inclusive.} -primop ISraOp "uncheckedIShiftRA#" GenPrimOp Int# -> Int# -> Int# +primop IntSraOp "uncheckedIShiftRA#" GenPrimOp Int# -> Int# -> Int# {Shift right arithmetic. Result undefined if shift amount is not in the range 0 to word size - 1 inclusive.} -primop ISrlOp "uncheckedIShiftRL#" GenPrimOp Int# -> Int# -> Int# +primop IntSrlOp "uncheckedIShiftRL#" GenPrimOp Int# -> Int# -> Int# {Shift right logical. Result undefined if shift amount is not in the range 0 to word size - 1 inclusive.} @@ -622,21 +790,21 @@ primop WordQuotRem2Op "quotRemWord2#" GenPrimOp Requires that high word < divisor.} with can_fail = True -primop AndOp "and#" Dyadic Word# -> Word# -> Word# +primop WordAndOp "and#" Dyadic Word# -> Word# -> Word# with commutable = True -primop OrOp "or#" Dyadic Word# -> Word# -> Word# +primop WordOrOp "or#" Dyadic Word# -> Word# -> Word# with commutable = True -primop XorOp "xor#" Dyadic Word# -> Word# -> Word# +primop WordXorOp "xor#" Dyadic Word# -> Word# -> Word# with commutable = True -primop NotOp "not#" Monadic Word# -> Word# +primop WordNotOp "not#" Monadic Word# -> Word# -primop SllOp "uncheckedShiftL#" GenPrimOp Word# -> Int# -> Word# +primop WordSllOp "uncheckedShiftL#" GenPrimOp Word# -> Int# -> Word# {Shift left logical. Result undefined if shift amount is not in the range 0 to word size - 1 inclusive.} -primop SrlOp "uncheckedShiftRL#" GenPrimOp Word# -> Int# -> Word# +primop WordSrlOp "uncheckedShiftRL#" GenPrimOp Word# -> Int# -> Word# {Shift right logical. Result undefined if shift amount is not in the range 0 to word size - 1 inclusive.} @@ -656,7 +824,7 @@ primop PopCnt16Op "popCnt16#" Monadic Word# -> Word# {Count the number of set bits in the lower 16 bits of a word.} primop PopCnt32Op "popCnt32#" Monadic Word# -> Word# {Count the number of set bits in the lower 32 bits of a word.} -primop PopCnt64Op "popCnt64#" GenPrimOp WORD64 -> Word# +primop PopCnt64Op "popCnt64#" GenPrimOp Word64# -> Word# {Count the number of set bits in a 64-bit word.} primop PopCntOp "popCnt#" Monadic Word# -> Word# {Count the number of set bits in a word.} @@ -667,7 +835,7 @@ primop Pdep16Op "pdep16#" Dyadic Word# -> Word# -> Word# {Deposit bits to lower 16 bits of a word at locations specified by a mask.} primop Pdep32Op "pdep32#" Dyadic Word# -> Word# -> Word# {Deposit bits to lower 32 bits of a word at locations specified by a mask.} -primop Pdep64Op "pdep64#" GenPrimOp WORD64 -> WORD64 -> WORD64 +primop Pdep64Op "pdep64#" GenPrimOp Word64# -> Word64# -> Word64# {Deposit bits to a word at locations specified by a mask.} primop PdepOp "pdep#" Dyadic Word# -> Word# -> Word# {Deposit bits to a word at locations specified by a mask.} @@ -678,7 +846,7 @@ primop Pext16Op "pext16#" Dyadic Word# -> Word# -> Word# {Extract bits from lower 16 bits of a word at locations specified by a mask.} primop Pext32Op "pext32#" Dyadic Word# -> Word# -> Word# {Extract bits from lower 32 bits of a word at locations specified by a mask.} -primop Pext64Op "pext64#" GenPrimOp WORD64 -> WORD64 -> WORD64 +primop Pext64Op "pext64#" GenPrimOp Word64# -> Word64# -> Word64# {Extract bits from a word at locations specified by a mask.} primop PextOp "pext#" Dyadic Word# -> Word# -> Word# {Extract bits from a word at locations specified by a mask.} @@ -689,7 +857,7 @@ primop Clz16Op "clz16#" Monadic Word# -> Word# {Count leading zeros in the lower 16 bits of a word.} primop Clz32Op "clz32#" Monadic Word# -> Word# {Count leading zeros in the lower 32 bits of a word.} -primop Clz64Op "clz64#" GenPrimOp WORD64 -> Word# +primop Clz64Op "clz64#" GenPrimOp Word64# -> Word# {Count leading zeros in a 64-bit word.} primop ClzOp "clz#" Monadic Word# -> Word# {Count leading zeros in a word.} @@ -700,7 +868,7 @@ primop Ctz16Op "ctz16#" Monadic Word# -> Word# {Count trailing zeros in the lower 16 bits of a word.} primop Ctz32Op "ctz32#" Monadic Word# -> Word# {Count trailing zeros in the lower 32 bits of a word.} -primop Ctz64Op "ctz64#" GenPrimOp WORD64 -> Word# +primop Ctz64Op "ctz64#" GenPrimOp Word64# -> Word# {Count trailing zeros in a 64-bit word.} primop CtzOp "ctz#" Monadic Word# -> Word# {Count trailing zeros in a word.} @@ -709,7 +877,7 @@ primop BSwap16Op "byteSwap16#" Monadic Word# -> Word# {Swap bytes in the lower 16 bits of a word. The higher bytes are undefined. } primop BSwap32Op "byteSwap32#" Monadic Word# -> Word# {Swap bytes in the lower 32 bits of a word. The higher bytes are undefined. } -primop BSwap64Op "byteSwap64#" Monadic WORD64 -> WORD64 +primop BSwap64Op "byteSwap64#" Monadic Word64# -> Word64# {Swap bytes in a 64 bits of a word.} primop BSwapOp "byteSwap#" Monadic Word# -> Word# {Swap bytes in a word.} @@ -720,7 +888,7 @@ primop BRev16Op "bitReverse16#" Monadic Word# -> Word# {Reverse the order of the bits in a 16-bit word.} primop BRev32Op "bitReverse32#" Monadic Word# -> Word# {Reverse the order of the bits in a 32-bit word.} -primop BRev64Op "bitReverse64#" Monadic WORD64 -> WORD64 +primop BRev64Op "bitReverse64#" Monadic Word64# -> Word64# {Reverse the order of the bits in a 64-bit word.} primop BRevOp "bitReverse#" Monadic Word# -> Word# {Reverse the order of the bits in a word.} @@ -899,7 +1067,7 @@ primop DoubleDecode_2IntOp "decodeDouble_2Int#" GenPrimOp with out_of_line = True primop DoubleDecode_Int64Op "decodeDouble_Int64#" GenPrimOp - Double# -> (# INT64, Int# #) + Double# -> (# Int64#, Int# #) {Decode {\tt Double\#} into mantissa and base-2 exponent.} with out_of_line = True @@ -1540,7 +1708,7 @@ primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp with can_fail = True primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp - ByteArray# -> Int# -> INT64 + ByteArray# -> Int# -> Int64# {Read 64-bit integer; offset in 64-bit words.} with can_fail = True @@ -1560,7 +1728,7 @@ primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp with can_fail = True primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp - ByteArray# -> Int# -> WORD64 + ByteArray# -> Int# -> Word64# {Read 64-bit word; offset in 64-bit words.} with can_fail = True @@ -1605,7 +1773,7 @@ primop IndexByteArrayOp_Word8AsInt32 "indexWord8ArrayAsInt32#" GenPrimOp with can_fail = True primop IndexByteArrayOp_Word8AsInt64 "indexWord8ArrayAsInt64#" GenPrimOp - ByteArray# -> Int# -> INT64 + ByteArray# -> Int# -> Int64# {Read 64-bit int; offset in bytes.} with can_fail = True @@ -1625,7 +1793,7 @@ primop IndexByteArrayOp_Word8AsWord32 "indexWord8ArrayAsWord32#" GenPrimOp with can_fail = True primop IndexByteArrayOp_Word8AsWord64 "indexWord8ArrayAsWord64#" GenPrimOp - ByteArray# -> Int# -> WORD64 + ByteArray# -> Int# -> Word64# {Read 64-bit word; offset in bytes.} with can_fail = True @@ -1694,7 +1862,7 @@ primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp can_fail = True primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) + MutableByteArray# s -> Int# -> State# s -> (# State# s, Int64# #) with has_side_effects = True can_fail = True @@ -1714,7 +1882,7 @@ primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp can_fail = True primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) + MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64# #) with has_side_effects = True can_fail = True @@ -1759,7 +1927,7 @@ primop ReadByteArrayOp_Word8AsInt32 "readWord8ArrayAsInt32#" GenPrimOp can_fail = True primop ReadByteArrayOp_Word8AsInt64 "readWord8ArrayAsInt64#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) + MutableByteArray# s -> Int# -> State# s -> (# State# s, Int64# #) with has_side_effects = True can_fail = True @@ -1779,7 +1947,7 @@ primop ReadByteArrayOp_Word8AsWord32 "readWord8ArrayAsWord32#" GenPrimOp can_fail = True primop ReadByteArrayOp_Word8AsWord64 "readWord8ArrayAsWord64#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) + MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64# #) with has_side_effects = True can_fail = True @@ -1846,7 +2014,7 @@ primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp can_fail = True primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp - MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s + MutableByteArray# s -> Int# -> Int64# -> State# s -> State# s with can_fail = True has_side_effects = True @@ -1866,7 +2034,7 @@ primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp can_fail = True primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp - MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s + MutableByteArray# s -> Int# -> Word64# -> State# s -> State# s with has_side_effects = True can_fail = True @@ -1911,7 +2079,7 @@ primop WriteByteArrayOp_Word8AsInt32 "writeWord8ArrayAsInt32#" GenPrimOp can_fail = True primop WriteByteArrayOp_Word8AsInt64 "writeWord8ArrayAsInt64#" GenPrimOp - MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s + MutableByteArray# s -> Int# -> Int64# -> State# s -> State# s with has_side_effects = True can_fail = True @@ -1931,7 +2099,7 @@ primop WriteByteArrayOp_Word8AsWord32 "writeWord8ArrayAsWord32#" GenPrimOp can_fail = True primop WriteByteArrayOp_Word8AsWord64 "writeWord8ArrayAsWord64#" GenPrimOp - MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s + MutableByteArray# s -> Int# -> Word64# -> State# s -> State# s with has_side_effects = True can_fail = True @@ -2290,7 +2458,7 @@ primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp with can_fail = True primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp - Addr# -> Int# -> INT64 + Addr# -> Int# -> Int64# with can_fail = True primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp @@ -2306,7 +2474,7 @@ primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp with can_fail = True primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp - Addr# -> Int# -> WORD64 + Addr# -> Int# -> Word64# with can_fail = True primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp @@ -2367,7 +2535,7 @@ primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp can_fail = True primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp - Addr# -> Int# -> State# s -> (# State# s, INT64 #) + Addr# -> Int# -> State# s -> (# State# s, Int64# #) with has_side_effects = True can_fail = True @@ -2387,7 +2555,7 @@ primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp can_fail = True primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp - Addr# -> Int# -> State# s -> (# State# s, WORD64 #) + Addr# -> Int# -> State# s -> (# State# s, Word64# #) with has_side_effects = True can_fail = True @@ -2447,7 +2615,7 @@ primop WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp can_fail = True primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp - Addr# -> Int# -> INT64 -> State# s -> State# s + Addr# -> Int# -> Int64# -> State# s -> State# s with has_side_effects = True can_fail = True @@ -2467,7 +2635,7 @@ primop WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp can_fail = True primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp - Addr# -> Int# -> WORD64 -> State# s -> State# s + Addr# -> Int# -> Word64# -> State# s -> State# s with has_side_effects = True can_fail = True @@ -3447,7 +3615,7 @@ primop TraceMarkerOp "traceMarker#" GenPrimOp out_of_line = True primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp - INT64 -> State# RealWorld -> State# RealWorld + Int64# -> State# RealWorld -> State# RealWorld { Sets the allocation counter for the current thread to the given value. } with has_side_effects = True @@ -3478,20 +3646,20 @@ section "SIMD Vectors" ------------------------------------------------------------------------ #define ALL_VECTOR_TYPES \ - [,,, \ - ,,,, \ - ,,,, \ - ,,,, \ - ,,,, \ - ,,,, \ + [,,, \ + ,,,, \ + ,,,, \ + ,,,, \ + ,,,, \ + ,,,, \ ,, \ ,, \ ,,] #define SIGNED_VECTOR_TYPES \ - [,,, \ - ,,,, \ - ,,,, \ + [,,, \ + ,,,, \ + ,,,, \ ,, \ ,, \ ,,] @@ -3502,12 +3670,12 @@ section "SIMD Vectors" ,,] #define INT_VECTOR_TYPES \ - [,,, \ - ,,,, \ - ,,,, \ - ,,,, \ - ,,,, \ - ,,,,] + [,,, \ + ,,,, \ + ,,,, \ + ,,,, \ + ,,,, \ + ,,,,] primtype VECTOR with llvm_only = True ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -66,6 +66,7 @@ import GHC.Core.Coercion (mkUnbranchedAxInstCo,mkSymCo,Role(..)) import Control.Applicative ( Alternative(..) ) import Control.Monad +import Data.Functor (($>)) import Data.Bits as Bits import qualified Data.ByteString as BS import Data.Int @@ -95,6 +96,77 @@ primOpRules nm = \case TagToEnumOp -> mkPrimOpRule nm 2 [ tagToEnumRule ] DataToTagOp -> mkPrimOpRule nm 2 [ dataToTagRule ] + -- Int64 operations + Int64AddOp -> mkPrimOpRule nm 2 [ binaryLit (int64Op2 (+)) + , identity zeroI64 + , numFoldingRules Int64AddOp $ const int64PrimOps + ] + Int64SubOp -> mkPrimOpRule nm 2 [ binaryLit (int64Op2 (-)) + , rightIdentity zeroI64 + , equalArgs $> Lit zeroI64 + , numFoldingRules Int64SubOp $ const int64PrimOps + ] + Int64MulOp -> mkPrimOpRule nm 2 [ binaryLit (int64Op2 (*)) + , zeroElem $ \_ -> zeroI64 + , identity oneI64 + , numFoldingRules Int64MulOp $ const int64PrimOps + ] + Int64QuotOp -> mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (int64Op2 quot) + , leftZero $ \_ -> zeroI64 + , rightIdentity oneI64 + , equalArgs $> Lit oneI64 ] + Int64RemOp -> mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (int64Op2 rem) + , leftZero $ \_ -> zeroI64 + , do l <- getLiteral 1 + guard $ l == oneI64 + pure $ Lit zeroI64 + , equalArgs $> Lit zeroI64 + , equalArgs $> Lit zeroI64 ] + Int64NegOp -> mkPrimOpRule nm 1 [ unaryLit negOp + , inversePrimOp Int64NegOp ] + Int64SllOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftL) + , rightIdentity zeroI64 ] + Int64SraOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftR) + , rightIdentity zeroI64 ] + Int64SrlOp -> mkPrimOpRule nm 2 [ shiftRule shiftRightLogical + , rightIdentity zeroI64 ] + + -- Word64 operations + Word64AddOp -> mkPrimOpRule nm 2 [ binaryLit (word64Op2 (+)) + , identity zeroW64 + , numFoldingRules Word64AddOp $ const word64PrimOps + ] + Word64SubOp -> mkPrimOpRule nm 2 [ binaryLit (word64Op2 (-)) + , rightIdentity zeroW64 + , equalArgs $> Lit zeroW64 + , numFoldingRules Word64SubOp $ const word64PrimOps + ] + Word64MulOp -> mkPrimOpRule nm 2 [ binaryLit (word64Op2 (*)) + , identity oneW64 + , numFoldingRules Word64MulOp $ const word64PrimOps + ] + Word64QuotOp-> mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (word64Op2 quot) + , rightIdentity oneW64 ] + Word64RemOp -> mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (word64Op2 rem) + , leftZero $ \_ -> zeroW64 + , do l <- getLiteral 1 + guard $ l == oneW64 + pure $ Lit zeroW64 + , equalArgs $> Lit zeroW64 ] + Word64AndOp -> mkPrimOpRule nm 2 [ binaryLit (word64Op2 (.&.)) + , idempotent + , zeroElem $ \_ -> zeroW64 ] + Word64OrOp -> mkPrimOpRule nm 2 [ binaryLit (word64Op2 (.|.)) + , idempotent + , identity zeroW64 ] + Word64XorOp -> mkPrimOpRule nm 2 [ binaryLit (word64Op2 xor) + , identity zeroW64 + , equalArgs $> Lit zeroW64 ] + Word64NotOp -> mkPrimOpRule nm 1 [ unaryLit complementOp + , inversePrimOp Word64NotOp ] + Word64SllOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftL) ] + Word64SrlOp -> mkPrimOpRule nm 2 [ shiftRule shiftRightLogical ] + -- Int operations IntAddOp -> mkPrimOpRule nm 2 [ binaryLit (intOp2 (+)) , identityPlatform zeroi @@ -127,24 +199,24 @@ primOpRules nm = \case retLit zeroi , equalArgs >> retLit zeroi , equalArgs >> retLit zeroi ] - AndIOp -> mkPrimOpRule nm 2 [ binaryLit (intOp2 (.&.)) + IntAndOp -> mkPrimOpRule nm 2 [ binaryLit (intOp2 (.&.)) , idempotent , zeroElem zeroi ] - OrIOp -> mkPrimOpRule nm 2 [ binaryLit (intOp2 (.|.)) + IntOrOp -> mkPrimOpRule nm 2 [ binaryLit (intOp2 (.|.)) , idempotent , identityPlatform zeroi ] - XorIOp -> mkPrimOpRule nm 2 [ binaryLit (intOp2 xor) + IntXorOp -> mkPrimOpRule nm 2 [ binaryLit (intOp2 xor) , identityPlatform zeroi , equalArgs >> retLit zeroi ] - NotIOp -> mkPrimOpRule nm 1 [ unaryLit complementOp - , inversePrimOp NotIOp ] + IntNotOp -> mkPrimOpRule nm 1 [ unaryLit complementOp + , inversePrimOp IntNotOp ] IntNegOp -> mkPrimOpRule nm 1 [ unaryLit negOp , inversePrimOp IntNegOp ] - ISllOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftL) + IntSllOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftL) , rightIdentityPlatform zeroi ] - ISraOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftR) + IntSraOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftR) , rightIdentityPlatform zeroi ] - ISrlOp -> mkPrimOpRule nm 2 [ shiftRule shiftRightLogical + IntSrlOp -> mkPrimOpRule nm 2 [ shiftRule shiftRightLogical , rightIdentityPlatform zeroi ] -- Word operations @@ -175,21 +247,25 @@ primOpRules nm = \case guard (l == onew platform) retLit zerow , equalArgs >> retLit zerow ] - AndOp -> mkPrimOpRule nm 2 [ binaryLit (wordOp2 (.&.)) + WordAndOp -> mkPrimOpRule nm 2 [ binaryLit (wordOp2 (.&.)) , idempotent , zeroElem zerow ] - OrOp -> mkPrimOpRule nm 2 [ binaryLit (wordOp2 (.|.)) + WordOrOp -> mkPrimOpRule nm 2 [ binaryLit (wordOp2 (.|.)) , idempotent , identityPlatform zerow ] - XorOp -> mkPrimOpRule nm 2 [ binaryLit (wordOp2 xor) + WordXorOp -> mkPrimOpRule nm 2 [ binaryLit (wordOp2 xor) , identityPlatform zerow , equalArgs >> retLit zerow ] - NotOp -> mkPrimOpRule nm 1 [ unaryLit complementOp - , inversePrimOp NotOp ] - SllOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftL) ] - SrlOp -> mkPrimOpRule nm 2 [ shiftRule shiftRightLogical ] + WordNotOp -> mkPrimOpRule nm 1 [ unaryLit complementOp + , inversePrimOp WordNotOp ] + WordSllOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftL) ] + WordSrlOp -> mkPrimOpRule nm 2 [ shiftRule shiftRightLogical ] -- coercions + Word64ToInt64Op-> mkPrimOpRule nm 1 [ liftLitPlatform $ const word64ToInt64Lit + , inversePrimOp Int64ToWord64Op ] + Int64ToWord64Op-> mkPrimOpRule nm 1 [ liftLitPlatform $ const int64ToWord64Lit + , inversePrimOp Word64ToInt64Op ] Word2IntOp -> mkPrimOpRule nm 1 [ liftLitPlatform word2IntLit , inversePrimOp Int2WordOp ] Int2WordOp -> mkPrimOpRule nm 1 [ liftLitPlatform int2WordLit @@ -198,34 +274,34 @@ primOpRules nm = \case , subsumedByPrimOp Narrow8IntOp , Narrow8IntOp `subsumesPrimOp` Narrow16IntOp , Narrow8IntOp `subsumesPrimOp` Narrow32IntOp - , narrowSubsumesAnd AndIOp Narrow8IntOp 8 ] + , narrowSubsumesAnd IntAndOp Narrow8IntOp 8 ] Narrow16IntOp -> mkPrimOpRule nm 1 [ liftLit narrow16IntLit , subsumedByPrimOp Narrow8IntOp , subsumedByPrimOp Narrow16IntOp , Narrow16IntOp `subsumesPrimOp` Narrow32IntOp - , narrowSubsumesAnd AndIOp Narrow16IntOp 16 ] + , narrowSubsumesAnd IntAndOp Narrow16IntOp 16 ] Narrow32IntOp -> mkPrimOpRule nm 1 [ liftLit narrow32IntLit , subsumedByPrimOp Narrow8IntOp , subsumedByPrimOp Narrow16IntOp , subsumedByPrimOp Narrow32IntOp , removeOp32 - , narrowSubsumesAnd AndIOp Narrow32IntOp 32 ] + , narrowSubsumesAnd IntAndOp Narrow32IntOp 32 ] Narrow8WordOp -> mkPrimOpRule nm 1 [ liftLit narrow8WordLit , subsumedByPrimOp Narrow8WordOp , Narrow8WordOp `subsumesPrimOp` Narrow16WordOp , Narrow8WordOp `subsumesPrimOp` Narrow32WordOp - , narrowSubsumesAnd AndOp Narrow8WordOp 8 ] + , narrowSubsumesAnd WordAndOp Narrow8WordOp 8 ] Narrow16WordOp -> mkPrimOpRule nm 1 [ liftLit narrow16WordLit , subsumedByPrimOp Narrow8WordOp , subsumedByPrimOp Narrow16WordOp , Narrow16WordOp `subsumesPrimOp` Narrow32WordOp - , narrowSubsumesAnd AndOp Narrow16WordOp 16 ] + , narrowSubsumesAnd WordAndOp Narrow16WordOp 16 ] Narrow32WordOp -> mkPrimOpRule nm 1 [ liftLit narrow32WordLit , subsumedByPrimOp Narrow8WordOp , subsumedByPrimOp Narrow16WordOp , subsumedByPrimOp Narrow32WordOp , removeOp32 - , narrowSubsumesAnd AndOp Narrow32WordOp 32 ] + , narrowSubsumesAnd WordAndOp Narrow32WordOp 32 ] OrdOp -> mkPrimOpRule nm 1 [ liftLit char2IntLit , inversePrimOp ChrOp ] ChrOp -> mkPrimOpRule nm 1 [ do [Lit lit] <- getArgs @@ -379,6 +455,12 @@ onei platform = mkLitInt platform 1 zerow platform = mkLitWord platform 0 onew platform = mkLitWord platform 1 +zeroI64, oneI64, zeroW64, oneW64 :: Literal +zeroI64 = mkLitInt64 0 +oneI64 = mkLitInt64 1 +zeroW64 = mkLitWord64 0 +oneW64 = mkLitWord64 1 + zerof, onef, twof, zerod, oned, twod :: Literal zerof = mkLitFloat 0.0 onef = mkLitFloat 1.0 @@ -420,6 +502,14 @@ complementOp env (LitNumber nt i) = Just (Lit (mkLitNumberWrap (roPlatform env) nt (complement i))) complementOp _ _ = Nothing +int64Op2 + :: (Integral a, Integral b) + => (a -> b -> Integer) + -> RuleOpts -> Literal -> Literal -> Maybe CoreExpr +int64Op2 op _ (LitNumber LitNumInt64 i1) (LitNumber LitNumInt64 i2) = + int64Result (fromInteger i1 `op` fromInteger i2) +int64Op2 _ _ _ _ = Nothing -- Could find LitLit + intOp2 :: (Integral a, Integral b) => (a -> b -> Integer) -> RuleOpts -> Literal -> Literal -> Maybe CoreExpr @@ -460,6 +550,14 @@ retLitNoC l = do platform <- getPlatform let ty = literalType lit return $ mkCoreUbxTup [ty, ty] [Lit lit, Lit (zeroi platform)] +word64Op2 + :: (Integral a, Integral b) + => (a -> b -> Integer) + -> RuleOpts -> Literal -> Literal -> Maybe CoreExpr +word64Op2 op _ (LitNumber LitNumWord64 i1) (LitNumber LitNumWord64 i2) = + word64Result (fromInteger i1 `op` fromInteger i2) +word64Op2 _ _ _ _ = Nothing -- Could find LitLit + wordOp2 :: (Integral a, Integral b) => (a -> b -> Integer) -> RuleOpts -> Literal -> Literal -> Maybe CoreExpr @@ -477,8 +575,8 @@ wordOpC2 _ _ _ _ = Nothing shiftRule :: (Platform -> Integer -> Int -> Integer) -> RuleM CoreExpr -- Shifts take an Int; hence third arg of op is Int -- Used for shift primops --- ISllOp, ISraOp, ISrlOp :: Word# -> Int# -> Word# --- SllOp, SrlOp :: Word# -> Int# -> Word# +-- IntSllOp, IntSraOp, IntSrlOp :: Word# -> Int# -> Word# +-- SllOp, SrlOp :: Word# -> Int# -> Word# shiftRule shift_op = do { platform <- getPlatform ; [e1, Lit (LitNumber LitNumInt shift_len)] <- getArgs @@ -604,6 +702,14 @@ isMaxBound platform (LitNumber nt i) = case nt of LitNumInteger -> False isMaxBound _ _ = False +-- | Create an Int literal expression while ensuring the given Integer is in the +-- target Int range +int64Result :: Integer -> Maybe CoreExpr +int64Result result = Just (int64Result' result) + +int64Result' :: Integer -> CoreExpr +int64Result' result = Lit (mkLitInt64Wrap result) + -- | Create an Int literal expression while ensuring the given Integer is in the -- target Int range intResult :: Platform -> Integer -> Maybe CoreExpr @@ -622,6 +728,14 @@ intCResult platform result = Just (mkPair [Lit lit, Lit c]) (lit, b) = mkLitIntWrapC platform result c = if b then onei platform else zeroi platform +-- | Create a Word literal expression while ensuring the given Integer is in the +-- target Word range +word64Result :: Integer -> Maybe CoreExpr +word64Result result = Just (word64Result' result) + +word64Result' :: Integer -> CoreExpr +word64Result' result = Lit (mkLitWord64Wrap result) + -- | Create a Word literal expression while ensuring the given Integer is in the -- target Word range wordResult :: Platform -> Integer -> Maybe CoreExpr @@ -753,7 +867,7 @@ transform the invalid shift into an "obviously incorrect" value. There are two cases: -- Shifting fixed-width things: the primops ISll, Sll, etc +- Shifting fixed-width things: the primops IntSll, Sll, etc These are handled by shiftRule. We are happy to shift by any amount up to wordSize but no more. @@ -1283,7 +1397,7 @@ builtinRules enableBignumRules [arg, Lit (LitNumber LitNumInt d)] <- getArgs Just n <- return $ exactLog2 d platform <- getPlatform - return $ Var (mkPrimOpId ISraOp) `App` arg `App` mkIntVal platform n + return $ Var (mkPrimOpId IntSraOp) `App` arg `App` mkIntVal platform n ], mkBasicRule modIntName 2 $ msum @@ -1293,7 +1407,7 @@ builtinRules enableBignumRules [arg, Lit (LitNumber LitNumInt d)] <- getArgs Just _ <- return $ exactLog2 d platform <- getPlatform - return $ Var (mkPrimOpId AndIOp) + return $ Var (mkPrimOpId IntAndOp) `App` arg `App` mkIntVal platform (d - 1) ] ] @@ -1978,16 +2092,22 @@ pattern (:-:) :: Arg CoreBndr -> Arg CoreBndr -> CoreExpr pattern x :-: y <- BinOpApp x (isSubOp -> True) y isSubOp :: PrimOp -> Bool +isSubOp Int64SubOp = True +isSubOp Word64SubOp = True isSubOp IntSubOp = True isSubOp WordSubOp = True isSubOp _ = False isAddOp :: PrimOp -> Bool +isAddOp Int64AddOp = True +isAddOp Word64AddOp = True isAddOp IntAddOp = True isAddOp WordAddOp = True isAddOp _ = False isMulOp :: PrimOp -> Bool +isMulOp Int64MulOp = True +isMulOp Word64MulOp = True isMulOp IntMulOp = True isMulOp WordMulOp = True isMulOp _ = False @@ -2002,6 +2122,22 @@ data PrimOps = PrimOps , mkL :: Integer -> CoreExpr -- ^ Create a literal value } +int64PrimOps :: PrimOps +int64PrimOps = PrimOps + { add = \x y -> BinOpApp x Int64AddOp y + , sub = \x y -> BinOpApp x Int64SubOp y + , mul = \x y -> BinOpApp x Int64MulOp y + , mkL = int64Result' + } + +word64PrimOps :: PrimOps +word64PrimOps = PrimOps + { add = \x y -> BinOpApp x Word64AddOp y + , sub = \x y -> BinOpApp x Word64SubOp y + , mul = \x y -> BinOpApp x Word64MulOp y + , mkL = word64Result' + } + intPrimOps :: Platform -> PrimOps intPrimOps platform = PrimOps { add = \x y -> BinOpApp x IntAddOp y @@ -2099,8 +2235,8 @@ adjustDyadicRight op lit IntAddOp -> Just (\y -> y-lit ) WordSubOp -> Just (\y -> y+lit ) IntSubOp -> Just (\y -> y+lit ) - XorOp -> Just (\y -> y `xor` lit) - XorIOp -> Just (\y -> y `xor` lit) + WordXorOp -> Just (\y -> y `xor` lit) + IntXorOp -> Just (\y -> y `xor` lit) _ -> Nothing adjustDyadicLeft :: Integer -> PrimOp -> Maybe (Integer -> Integer) @@ -2111,8 +2247,8 @@ adjustDyadicLeft lit op IntAddOp -> Just (\y -> y-lit ) WordSubOp -> Just (\y -> lit-y ) IntSubOp -> Just (\y -> lit-y ) - XorOp -> Just (\y -> y `xor` lit) - XorIOp -> Just (\y -> y `xor` lit) + WordXorOp -> Just (\y -> y `xor` lit) + IntXorOp -> Just (\y -> y `xor` lit) _ -> Nothing @@ -2120,8 +2256,8 @@ adjustUnary :: PrimOp -> Maybe (Integer -> Integer) -- Given (op x) return a function 'f' s.t. f (op x) = x adjustUnary op = case op of - NotOp -> Just (\y -> complement y) - NotIOp -> Just (\y -> complement y) + WordNotOp -> Just (\y -> complement y) + IntNotOp -> Just (\y -> complement y) IntNegOp -> Just (\y -> negate y ) _ -> Nothing ===================================== compiler/GHC/HsToCore/Match/Literal.hs ===================================== @@ -96,8 +96,8 @@ dsLit l = do HsCharPrim _ c -> return (Lit (LitChar c)) HsIntPrim _ i -> return (Lit (mkLitIntWrap platform i)) HsWordPrim _ w -> return (Lit (mkLitWordWrap platform w)) - HsInt64Prim _ i -> return (Lit (mkLitInt64Wrap platform i)) - HsWord64Prim _ w -> return (Lit (mkLitWord64Wrap platform w)) + HsInt64Prim _ i -> return (Lit (mkLitInt64Wrap i)) + HsWord64Prim _ w -> return (Lit (mkLitWord64Wrap w)) HsFloatPrim _ f -> return (Lit (LitFloat (fl_value f))) HsDoublePrim _ d -> return (Lit (LitDouble (fl_value d))) HsChar _ c -> return (mkCharExpr c) @@ -493,8 +493,8 @@ hsLitKey :: Platform -> HsLit GhcTc -> Literal -- HsLit does not. hsLitKey platform (HsIntPrim _ i) = mkLitIntWrap platform i hsLitKey platform (HsWordPrim _ w) = mkLitWordWrap platform w -hsLitKey platform (HsInt64Prim _ i) = mkLitInt64Wrap platform i -hsLitKey platform (HsWord64Prim _ w) = mkLitWord64Wrap platform w +hsLitKey _ (HsInt64Prim _ i) = mkLitInt64Wrap i +hsLitKey _ (HsWord64Prim _ w) = mkLitWord64Wrap w hsLitKey _ (HsCharPrim _ c) = mkLitChar c hsLitKey _ (HsFloatPrim _ f) = mkLitFloat (fl_value f) hsLitKey _ (HsDoublePrim _ d) = mkLitDouble (fl_value d) ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1067,6 +1067,10 @@ emitPrimOp dflags = \case -- The rest just translate straightforwardly + Int64ToWord64Op -> \args -> opNop args + Word64ToInt64Op -> \args -> opNop args + Int32ToWord32Op -> \args -> opNop args + Word32ToInt32Op -> \args -> opNop args Int2WordOp -> \args -> opNop args Word2IntOp -> \args -> opNop args Int2AddrOp -> \args -> opNop args @@ -1135,12 +1139,12 @@ emitPrimOp dflags = \case AddrEqOp -> \args -> opTranslate args (mo_wordEq platform) AddrNeOp -> \args -> opTranslate args (mo_wordNe platform) - AndOp -> \args -> opTranslate args (mo_wordAnd platform) - OrOp -> \args -> opTranslate args (mo_wordOr platform) - XorOp -> \args -> opTranslate args (mo_wordXor platform) - NotOp -> \args -> opTranslate args (mo_wordNot platform) - SllOp -> \args -> opTranslate args (mo_wordShl platform) - SrlOp -> \args -> opTranslate args (mo_wordUShr platform) + WordAndOp -> \args -> opTranslate args (mo_wordAnd platform) + WordOrOp -> \args -> opTranslate args (mo_wordOr platform) + WordXorOp -> \args -> opTranslate args (mo_wordXor platform) + WordNotOp -> \args -> opTranslate args (mo_wordNot platform) + WordSllOp -> \args -> opTranslate args (mo_wordShl platform) + WordSrlOp -> \args -> opTranslate args (mo_wordUShr platform) AddrRemOp -> \args -> opTranslate args (mo_wordURem platform) @@ -1157,13 +1161,13 @@ emitPrimOp dflags = \case IntGtOp -> \args -> opTranslate args (mo_wordSGt platform) IntLtOp -> \args -> opTranslate args (mo_wordSLt platform) - AndIOp -> \args -> opTranslate args (mo_wordAnd platform) - OrIOp -> \args -> opTranslate args (mo_wordOr platform) - XorIOp -> \args -> opTranslate args (mo_wordXor platform) - NotIOp -> \args -> opTranslate args (mo_wordNot platform) - ISllOp -> \args -> opTranslate args (mo_wordShl platform) - ISraOp -> \args -> opTranslate args (mo_wordSShr platform) - ISrlOp -> \args -> opTranslate args (mo_wordUShr platform) + IntAndOp -> \args -> opTranslate args (mo_wordAnd platform) + IntOrOp -> \args -> opTranslate args (mo_wordOr platform) + IntXorOp -> \args -> opTranslate args (mo_wordXor platform) + IntNotOp -> \args -> opTranslate args (mo_wordNot platform) + IntSllOp -> \args -> opTranslate args (mo_wordShl platform) + IntSraOp -> \args -> opTranslate args (mo_wordSShr platform) + IntSrlOp -> \args -> opTranslate args (mo_wordUShr platform) -- Native word unsigned ops @@ -1183,8 +1187,8 @@ emitPrimOp dflags = \case -- Int8# signed ops - Int8Extend -> \args -> opTranslate args (MO_SS_Conv W8 (wordWidth platform)) - Int8Narrow -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W8) + Int8ToInt -> \args -> opTranslate args (MO_SS_Conv W8 (wordWidth platform)) + IntToInt8 -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W8) Int8NegOp -> \args -> opTranslate args (MO_S_Neg W8) Int8AddOp -> \args -> opTranslate args (MO_Add W8) Int8SubOp -> \args -> opTranslate args (MO_Sub W8) @@ -1201,8 +1205,8 @@ emitPrimOp dflags = \case -- Word8# unsigned ops - Word8Extend -> \args -> opTranslate args (MO_UU_Conv W8 (wordWidth platform)) - Word8Narrow -> \args -> opTranslate args (MO_UU_Conv (wordWidth platform) W8) + Word8ToWord -> \args -> opTranslate args (MO_UU_Conv W8 (wordWidth platform)) + WordToWord8 -> \args -> opTranslate args (MO_UU_Conv (wordWidth platform) W8) Word8NotOp -> \args -> opTranslate args (MO_Not W8) Word8AddOp -> \args -> opTranslate args (MO_Add W8) Word8SubOp -> \args -> opTranslate args (MO_Sub W8) @@ -1219,8 +1223,8 @@ emitPrimOp dflags = \case -- Int16# signed ops - Int16Extend -> \args -> opTranslate args (MO_SS_Conv W16 (wordWidth platform)) - Int16Narrow -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W16) + Int16ToInt -> \args -> opTranslate args (MO_SS_Conv W16 (wordWidth platform)) + IntToInt16 -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W16) Int16NegOp -> \args -> opTranslate args (MO_S_Neg W16) Int16AddOp -> \args -> opTranslate args (MO_Add W16) Int16SubOp -> \args -> opTranslate args (MO_Sub W16) @@ -1237,8 +1241,8 @@ emitPrimOp dflags = \case -- Word16# unsigned ops - Word16Extend -> \args -> opTranslate args (MO_UU_Conv W16 (wordWidth platform)) - Word16Narrow -> \args -> opTranslate args (MO_UU_Conv (wordWidth platform) W16) + Word16ToWord -> \args -> opTranslate args (MO_UU_Conv W16 (wordWidth platform)) + WordToWord16 -> \args -> opTranslate args (MO_UU_Conv (wordWidth platform) W16) Word16NotOp -> \args -> opTranslate args (MO_Not W16) Word16AddOp -> \args -> opTranslate args (MO_Add W16) Word16SubOp -> \args -> opTranslate args (MO_Sub W16) @@ -1253,6 +1257,98 @@ emitPrimOp dflags = \case Word16LtOp -> \args -> opTranslate args (MO_U_Lt W16) Word16NeOp -> \args -> opTranslate args (MO_Ne W16) +-- Int32# signed ops + + Int32ToInt -> \args -> opTranslate args (MO_SS_Conv W32 (wordWidth platform)) + IntToInt32 -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W32) + Int32NegOp -> \args -> opTranslate args (MO_S_Neg W32) + Int32AddOp -> \args -> opTranslate args (MO_Add W32) + Int32SubOp -> \args -> opTranslate args (MO_Sub W32) + Int32MulOp -> \args -> opTranslate args (MO_Mul W32) + Int32QuotOp -> \args -> opTranslate args (MO_S_Quot W32) + Int32RemOp -> \args -> opTranslate args (MO_S_Rem W32) + + Int32SllOp -> \args -> opTranslate args (MO_Shl W32) + Int32SraOp -> \args -> opTranslate args (MO_S_Shr W32) + Int32SrlOp -> \args -> opTranslate args (MO_U_Shr W32) + + Int32EqOp -> \args -> opTranslate args (MO_Eq W32) + Int32GeOp -> \args -> opTranslate args (MO_S_Ge W32) + Int32GtOp -> \args -> opTranslate args (MO_S_Gt W32) + Int32LeOp -> \args -> opTranslate args (MO_S_Le W32) + Int32LtOp -> \args -> opTranslate args (MO_S_Lt W32) + Int32NeOp -> \args -> opTranslate args (MO_Ne W32) + +-- Word32# unsigned ops + + Word32ToWord -> \args -> opTranslate args (MO_UU_Conv W32 (wordWidth platform)) + WordToWord32 -> \args -> opTranslate args (MO_UU_Conv (wordWidth platform) W32) + Word32AddOp -> \args -> opTranslate args (MO_Add W32) + Word32SubOp -> \args -> opTranslate args (MO_Sub W32) + Word32MulOp -> \args -> opTranslate args (MO_Mul W32) + Word32QuotOp -> \args -> opTranslate args (MO_U_Quot W32) + Word32RemOp -> \args -> opTranslate args (MO_U_Rem W32) + + Word32AndOp -> \args -> opTranslate args (MO_And W32) + Word32OrOp -> \args -> opTranslate args (MO_Or W32) + Word32XorOp -> \args -> opTranslate args (MO_Xor W32) + Word32NotOp -> \args -> opTranslate args (MO_Not W32) + Word32SllOp -> \args -> opTranslate args (MO_Shl W32) + Word32SrlOp -> \args -> opTranslate args (MO_U_Shr W32) + + Word32EqOp -> \args -> opTranslate args (MO_Eq W32) + Word32GeOp -> \args -> opTranslate args (MO_U_Ge W32) + Word32GtOp -> \args -> opTranslate args (MO_U_Gt W32) + Word32LeOp -> \args -> opTranslate args (MO_U_Le W32) + Word32LtOp -> \args -> opTranslate args (MO_U_Lt W32) + Word32NeOp -> \args -> opTranslate args (MO_Ne W32) + +-- Int64# signed ops + + Int64ToInt -> \args -> opTranslate args (MO_SS_Conv W64 (wordWidth platform)) + IntToInt64 -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W64) + Int64NegOp -> \args -> opTranslate args (MO_S_Neg W64) + Int64AddOp -> \args -> opTranslate args (MO_Add W64) + Int64SubOp -> \args -> opTranslate args (MO_Sub W64) + Int64MulOp -> \args -> opTranslate args (MO_Mul W64) + Int64QuotOp -> \args -> opTranslate args (MO_S_Quot W64) + Int64RemOp -> \args -> opTranslate args (MO_S_Rem W64) + + Int64SllOp -> \args -> opTranslate args (MO_Shl W64) + Int64SraOp -> \args -> opTranslate args (MO_S_Shr W64) + Int64SrlOp -> \args -> opTranslate args (MO_U_Shr W64) + + Int64EqOp -> \args -> opTranslate args (MO_Eq W64) + Int64GeOp -> \args -> opTranslate args (MO_S_Ge W64) + Int64GtOp -> \args -> opTranslate args (MO_S_Gt W64) + Int64LeOp -> \args -> opTranslate args (MO_S_Le W64) + Int64LtOp -> \args -> opTranslate args (MO_S_Lt W64) + Int64NeOp -> \args -> opTranslate args (MO_Ne W64) + +-- Word64# unsigned ops + + Word64ToWord -> \args -> opTranslate args (MO_UU_Conv W64 (wordWidth platform)) + WordToWord64 -> \args -> opTranslate args (MO_UU_Conv (wordWidth platform) W64) + Word64AddOp -> \args -> opTranslate args (MO_Add W64) + Word64SubOp -> \args -> opTranslate args (MO_Sub W64) + Word64MulOp -> \args -> opTranslate args (MO_Mul W64) + Word64QuotOp -> \args -> opTranslate args (MO_U_Quot W64) + Word64RemOp -> \args -> opTranslate args (MO_U_Rem W64) + + Word64AndOp -> \args -> opTranslate args (MO_And W64) + Word64OrOp -> \args -> opTranslate args (MO_Or W64) + Word64XorOp -> \args -> opTranslate args (MO_Xor W64) + Word64NotOp -> \args -> opTranslate args (MO_Not W64) + Word64SllOp -> \args -> opTranslate args (MO_Shl W64) + Word64SrlOp -> \args -> opTranslate args (MO_U_Shr W64) + + Word64EqOp -> \args -> opTranslate args (MO_Eq W64) + Word64GeOp -> \args -> opTranslate args (MO_U_Ge W64) + Word64GtOp -> \args -> opTranslate args (MO_U_Gt W64) + Word64LeOp -> \args -> opTranslate args (MO_U_Le W64) + Word64LtOp -> \args -> opTranslate args (MO_U_Lt W64) + Word64NeOp -> \args -> opTranslate args (MO_Ne W64) + -- Char# ops CharEqOp -> \args -> opTranslate args (MO_Eq (wordWidth platform)) @@ -1357,6 +1453,16 @@ emitPrimOp dflags = \case then Left (MO_S_QuotRem W16) else Right (genericIntQuotRemOp W16) + Int32QuotRemOp -> \args -> opCallishHandledLater args $ + if ncg && (x86ish || ppc) && not (quotRemCanBeOptimized args) + then Left (MO_S_QuotRem W32) + else Right (genericIntQuotRemOp W32) + + Int64QuotRemOp -> \args -> opCallishHandledLater args $ + if ncg && (x86ish || ppc) && not (quotRemCanBeOptimized args) + then Left (MO_S_QuotRem W64) + else Right (genericIntQuotRemOp W64) + WordQuotRemOp -> \args -> opCallishHandledLater args $ if ncg && (x86ish || ppc) && not (quotRemCanBeOptimized args) then Left (MO_U_QuotRem (wordWidth platform)) @@ -1377,6 +1483,16 @@ emitPrimOp dflags = \case then Left (MO_U_QuotRem W16) else Right (genericWordQuotRemOp W16) + Word32QuotRemOp -> \args -> opCallishHandledLater args $ + if ncg && (x86ish || ppc) && not (quotRemCanBeOptimized args) + then Left (MO_U_QuotRem W32) + else Right (genericWordQuotRemOp W32) + + Word64QuotRemOp -> \args -> opCallishHandledLater args $ + if ncg && (x86ish || ppc) && not (quotRemCanBeOptimized args) + then Left (MO_U_QuotRem W64) + else Right (genericWordQuotRemOp W64) + WordAdd2Op -> \args -> opCallishHandledLater args $ if (ncg && (x86ish || ppc)) || llvm then Left (MO_Add2 (wordWidth platform)) ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -1503,14 +1503,21 @@ gfoldl_RDR, gunfold_RDR, toConstr_RDR, dataTypeOf_RDR, mkConstr_RDR, eqInt_RDR , ltInt_RDR , geInt_RDR , gtInt_RDR , leInt_RDR , eqInt8_RDR , ltInt8_RDR , geInt8_RDR , gtInt8_RDR , leInt8_RDR , eqInt16_RDR , ltInt16_RDR , geInt16_RDR , gtInt16_RDR , leInt16_RDR , + eqInt32_RDR , ltInt32_RDR , geInt32_RDR , gtInt32_RDR , leInt32_RDR , + eqInt64_RDR , ltInt64_RDR , geInt64_RDR , gtInt64_RDR , leInt64_RDR , eqWord_RDR , ltWord_RDR , geWord_RDR , gtWord_RDR , leWord_RDR , eqWord8_RDR , ltWord8_RDR , geWord8_RDR , gtWord8_RDR , leWord8_RDR , eqWord16_RDR, ltWord16_RDR, geWord16_RDR, gtWord16_RDR, leWord16_RDR, + eqWord32_RDR, ltWord32_RDR, geWord32_RDR, gtWord32_RDR, leWord32_RDR, + eqWord64_RDR, ltWord64_RDR, geWord64_RDR, gtWord64_RDR, leWord64_RDR, eqAddr_RDR , ltAddr_RDR , geAddr_RDR , gtAddr_RDR , leAddr_RDR , eqFloat_RDR , ltFloat_RDR , geFloat_RDR , gtFloat_RDR , leFloat_RDR , eqDouble_RDR, ltDouble_RDR, geDouble_RDR, gtDouble_RDR, leDouble_RDR, - extendWord8_RDR, extendInt8_RDR, - extendWord16_RDR, extendInt16_RDR :: RdrName + word8ToWord_RDR , int8ToInt_RDR , + word16ToWord_RDR, int16ToInt_RDR, + word32ToWord_RDR, int32ToInt_RDR, + word64ToWord_RDR, int64ToInt_RDR + :: RdrName gfoldl_RDR = varQual_RDR gENERICS (fsLit "gfoldl") gunfold_RDR = varQual_RDR gENERICS (fsLit "gunfold") toConstr_RDR = varQual_RDR gENERICS (fsLit "toConstr") @@ -1551,6 +1558,18 @@ leInt16_RDR = varQual_RDR gHC_PRIM (fsLit "leInt16#") gtInt16_RDR = varQual_RDR gHC_PRIM (fsLit "gtInt16#" ) geInt16_RDR = varQual_RDR gHC_PRIM (fsLit "geInt16#") +eqInt32_RDR = varQual_RDR gHC_PRIM (fsLit "eqInt32#") +ltInt32_RDR = varQual_RDR gHC_PRIM (fsLit "ltInt32#" ) +leInt32_RDR = varQual_RDR gHC_PRIM (fsLit "leInt32#") +gtInt32_RDR = varQual_RDR gHC_PRIM (fsLit "gtInt32#" ) +geInt32_RDR = varQual_RDR gHC_PRIM (fsLit "geInt32#") + +eqInt64_RDR = varQual_RDR gHC_PRIM (fsLit "eqInt64#") +ltInt64_RDR = varQual_RDR gHC_PRIM (fsLit "ltInt64#" ) +leInt64_RDR = varQual_RDR gHC_PRIM (fsLit "leInt64#") +gtInt64_RDR = varQual_RDR gHC_PRIM (fsLit "gtInt64#" ) +geInt64_RDR = varQual_RDR gHC_PRIM (fsLit "geInt64#") + eqWord_RDR = varQual_RDR gHC_PRIM (fsLit "eqWord#") ltWord_RDR = varQual_RDR gHC_PRIM (fsLit "ltWord#") leWord_RDR = varQual_RDR gHC_PRIM (fsLit "leWord#") @@ -1569,6 +1588,18 @@ leWord16_RDR = varQual_RDR gHC_PRIM (fsLit "leWord16#") gtWord16_RDR = varQual_RDR gHC_PRIM (fsLit "gtWord16#" ) geWord16_RDR = varQual_RDR gHC_PRIM (fsLit "geWord16#") +eqWord32_RDR = varQual_RDR gHC_PRIM (fsLit "eqWord32#") +ltWord32_RDR = varQual_RDR gHC_PRIM (fsLit "ltWord32#" ) +leWord32_RDR = varQual_RDR gHC_PRIM (fsLit "leWord32#") +gtWord32_RDR = varQual_RDR gHC_PRIM (fsLit "gtWord32#" ) +geWord32_RDR = varQual_RDR gHC_PRIM (fsLit "geWord32#") + +eqWord64_RDR = varQual_RDR gHC_PRIM (fsLit "eqWord64#") +ltWord64_RDR = varQual_RDR gHC_PRIM (fsLit "ltWord64#" ) +leWord64_RDR = varQual_RDR gHC_PRIM (fsLit "leWord64#") +gtWord64_RDR = varQual_RDR gHC_PRIM (fsLit "gtWord64#" ) +geWord64_RDR = varQual_RDR gHC_PRIM (fsLit "geWord64#") + eqAddr_RDR = varQual_RDR gHC_PRIM (fsLit "eqAddr#") ltAddr_RDR = varQual_RDR gHC_PRIM (fsLit "ltAddr#") leAddr_RDR = varQual_RDR gHC_PRIM (fsLit "leAddr#") @@ -1587,12 +1618,17 @@ leDouble_RDR = varQual_RDR gHC_PRIM (fsLit "<=##") gtDouble_RDR = varQual_RDR gHC_PRIM (fsLit ">##" ) geDouble_RDR = varQual_RDR gHC_PRIM (fsLit ">=##") -extendWord8_RDR = varQual_RDR gHC_PRIM (fsLit "extendWord8#") -extendInt8_RDR = varQual_RDR gHC_PRIM (fsLit "extendInt8#") +word8ToWord_RDR = varQual_RDR gHC_PRIM (fsLit "word8ToWord#") +int8ToInt_RDR = varQual_RDR gHC_PRIM (fsLit "int8ToInt#") -extendWord16_RDR = varQual_RDR gHC_PRIM (fsLit "extendWord16#") -extendInt16_RDR = varQual_RDR gHC_PRIM (fsLit "extendInt16#") +word16ToWord_RDR = varQual_RDR gHC_PRIM (fsLit "word16ToWord#") +int16ToInt_RDR = varQual_RDR gHC_PRIM (fsLit "int16ToInt#") +word32ToWord_RDR = varQual_RDR gHC_PRIM (fsLit "word32ToWord#") +int32ToInt_RDR = varQual_RDR gHC_PRIM (fsLit "int32ToInt#") + +word64ToWord_RDR = varQual_RDR gHC_PRIM (fsLit "word64ToWord#") +int64ToInt_RDR = varQual_RDR gHC_PRIM (fsLit "int64ToInt#") {- ************************************************************************ @@ -2258,12 +2294,20 @@ ordOpTbl , eqInt8_RDR , geInt8_RDR , gtInt8_RDR )) ,(int16PrimTy , (ltInt16_RDR , leInt16_RDR , eqInt16_RDR , geInt16_RDR , gtInt16_RDR )) + ,(int32PrimTy , (ltInt32_RDR , leInt32_RDR + , eqInt32_RDR , geInt32_RDR , gtInt32_RDR )) + ,(int64PrimTy , (ltInt64_RDR , leInt64_RDR + , eqInt64_RDR , geInt64_RDR , gtInt64_RDR )) ,(wordPrimTy , (ltWord_RDR , leWord_RDR , eqWord_RDR , geWord_RDR , gtWord_RDR )) ,(word8PrimTy , (ltWord8_RDR , leWord8_RDR , eqWord8_RDR , geWord8_RDR , gtWord8_RDR )) ,(word16PrimTy, (ltWord16_RDR, leWord16_RDR , eqWord16_RDR, geWord16_RDR, gtWord16_RDR )) + ,(word32PrimTy, (ltWord32_RDR, leWord32_RDR + , eqWord32_RDR, geWord32_RDR, gtWord32_RDR )) + ,(word64PrimTy, (ltWord64_RDR, leWord64_RDR + , eqWord64_RDR, geWord64_RDR, gtWord64_RDR )) ,(addrPrimTy , (ltAddr_RDR , leAddr_RDR , eqAddr_RDR , geAddr_RDR , gtAddr_RDR )) ,(floatPrimTy , (ltFloat_RDR , leFloat_RDR @@ -2283,16 +2327,28 @@ boxConTbl = , (doublePrimTy, nlHsApp (nlHsVar $ getRdrName doubleDataCon)) , (int8PrimTy, nlHsApp (nlHsVar $ getRdrName intDataCon) - . nlHsApp (nlHsVar extendInt8_RDR)) + . nlHsApp (nlHsVar int8ToInt_RDR)) , (word8PrimTy, nlHsApp (nlHsVar $ getRdrName wordDataCon) - . nlHsApp (nlHsVar extendWord8_RDR)) + . nlHsApp (nlHsVar word8ToWord_RDR)) , (int16PrimTy, nlHsApp (nlHsVar $ getRdrName intDataCon) - . nlHsApp (nlHsVar extendInt16_RDR)) + . nlHsApp (nlHsVar int16ToInt_RDR)) , (word16PrimTy, nlHsApp (nlHsVar $ getRdrName wordDataCon) - . nlHsApp (nlHsVar extendWord16_RDR)) + . nlHsApp (nlHsVar word16ToWord_RDR)) + , (int32PrimTy, + nlHsApp (nlHsVar $ getRdrName intDataCon) + . nlHsApp (nlHsVar int32ToInt_RDR)) + , (word32PrimTy, + nlHsApp (nlHsVar $ getRdrName wordDataCon) + . nlHsApp (nlHsVar word32ToWord_RDR)) + , (int64PrimTy, + nlHsApp (nlHsVar $ getRdrName intDataCon) + . nlHsApp (nlHsVar int64ToInt_RDR)) + , (word64PrimTy, + nlHsApp (nlHsVar $ getRdrName wordDataCon) + . nlHsApp (nlHsVar word64ToWord_RDR)) ] @@ -2312,10 +2368,14 @@ postfixModTbl primConvTbl :: [(Type, String)] primConvTbl = - [ (int8PrimTy, "narrowInt8#") - , (word8PrimTy, "narrowWord8#") - , (int16PrimTy, "narrowInt16#") - , (word16PrimTy, "narrowWord16#") + [ (int8PrimTy, "intToInt8#") + , (word8PrimTy, "wordToWord8#") + , (int16PrimTy, "intToInt16#") + , (word16PrimTy, "wordToWord16#") + , (int32PrimTy, "intToInt32#") + , (word32PrimTy, "wordToWord32#") + , (int64PrimTy, "intToInt64#") + , (word64PrimTy, "wordToWord64#") ] litConTbl :: [(Type, LHsExpr GhcPs -> LHsExpr GhcPs)] ===================================== compiler/GHC/Tc/Instance/Typeable.hs ===================================== @@ -623,8 +623,8 @@ mkTyConRepTyConRHS :: TypeableStuff -> TypeRepTodo -> LHsExpr GhcTc mkTyConRepTyConRHS (Stuff {..}) todo tycon kind_rep = nlHsDataCon trTyConDataCon - `nlHsApp` nlHsLit (word64 platform high) - `nlHsApp` nlHsLit (word64 platform low) + `nlHsApp` nlHsLit (word64 high) + `nlHsApp` nlHsLit (word64 low) `nlHsApp` mod_rep_expr todo `nlHsApp` trNameLit (mkFastString tycon_str) `nlHsApp` nlHsLit (int n_kind_vars) @@ -645,10 +645,8 @@ mkTyConRepTyConRHS (Stuff {..}) todo tycon kind_rep int :: Int -> HsLit GhcTc int n = HsIntPrim (SourceText $ show n) (toInteger n) -word64 :: Platform -> Word64 -> HsLit GhcTc -word64 platform n = case platformWordSize platform of - PW4 -> HsWord64Prim NoSourceText (toInteger n) - PW8 -> HsWordPrim NoSourceText (toInteger n) +word64 :: Word64 -> HsLit GhcTc +word64 n = HsWord64Prim NoSourceText (toInteger n) {- Note [Representing TyCon kinds: KindRep] ===================================== compiler/GHC/Types/Literal.hs ===================================== @@ -39,6 +39,7 @@ module GHC.Types.Literal , litValue, isLitValue, isLitValue_maybe, mapLitValue -- ** Coercions + , word64ToInt64Lit, int64ToWord64Lit , word2IntLit, int2WordLit , narrowLit , narrow8IntLit, narrow16IntLit, narrow32IntLit @@ -287,17 +288,28 @@ Int/Word range. wrapLitNumber :: Platform -> Literal -> Literal wrapLitNumber platform v@(LitNumber nt i) = case nt of LitNumInt -> case platformWordSize platform of - PW4 -> LitNumber nt (toInteger (fromIntegral i :: Int32)) - PW8 -> LitNumber nt (toInteger (fromIntegral i :: Int64)) + PW4 -> int32 + PW8 -> int64 LitNumWord -> case platformWordSize platform of - PW4 -> LitNumber nt (toInteger (fromIntegral i :: Word32)) - PW8 -> LitNumber nt (toInteger (fromIntegral i :: Word64)) - LitNumInt64 -> LitNumber nt (toInteger (fromIntegral i :: Int64)) - LitNumWord64 -> LitNumber nt (toInteger (fromIntegral i :: Word64)) + PW4 -> word32 + PW8 -> word64 + LitNumInt64 -> int64 + LitNumWord64 -> word64 LitNumInteger -> v LitNumNatural -> v + where + int32 = LitNumber nt $ wrapInt32 i + word32 = LitNumber nt $ wrapWord32 i + int64 = LitNumber nt $ wrapInt64 i + word64 = LitNumber nt $ wrapWord64 i wrapLitNumber _ x = x +wrapInt32, wrapWord32, wrapInt64, wrapWord64 :: Integer -> Integer +wrapInt32 i = toInteger (fromIntegral i :: Int32) +wrapWord32 i = toInteger (fromIntegral i :: Int32) +wrapInt64 i = toInteger (fromIntegral i :: Int64) +wrapWord64 i = toInteger (fromIntegral i :: Int64) + -- | Create a numeric 'Literal' of the given type mkLitNumberWrap :: Platform -> LitNumType -> Integer -> Literal mkLitNumberWrap platform nt i = wrapLitNumber platform (LitNumber nt i) @@ -372,8 +384,8 @@ mkLitInt64 x = ASSERT2( inInt64Range x, integer x ) (mkLitInt64Unchecked x) -- | Creates a 'Literal' of type @Int64#@. -- If the argument is out of the range, it is wrapped. -mkLitInt64Wrap :: Platform -> Integer -> Literal -mkLitInt64Wrap platform i = wrapLitNumber platform $ mkLitInt64Unchecked i +mkLitInt64Wrap :: Integer -> Literal +mkLitInt64Wrap = mkLitInt64Unchecked . wrapInt64 -- | Creates a 'Literal' of type @Int64#@ without checking its range. mkLitInt64Unchecked :: Integer -> Literal @@ -385,8 +397,8 @@ mkLitWord64 x = ASSERT2( inWord64Range x, integer x ) (mkLitWord64Unchecked x) -- | Creates a 'Literal' of type @Word64#@. -- If the argument is out of the range, it is wrapped. -mkLitWord64Wrap :: Platform -> Integer -> Literal -mkLitWord64Wrap platform i = wrapLitNumber platform $ mkLitWord64Unchecked i +mkLitWord64Wrap :: Integer -> Literal +mkLitWord64Wrap = mkLitWord64Unchecked . wrapWord64 -- | Creates a 'Literal' of type @Word64#@ without checking its range. mkLitWord64Unchecked :: Integer -> Literal @@ -478,7 +490,30 @@ narrow8IntLit, narrow16IntLit, narrow32IntLit, float2DoubleLit, double2FloatLit :: Literal -> Literal +maxBoundInt64, maxBoundWord64 :: Integer +maxBoundInt64 = toInteger (maxBound :: Int64) +maxBoundWord64 = toInteger (maxBound :: Word64) + +word64ToInt64Lit, int64ToWord64Lit :: Literal -> Literal + +word64ToInt64Lit (LitNumber LitNumWord64 w) + -- Map Word64 range [max_int64+1, max_word64] + -- to Int64 range [min_int64 , -1] + -- Range [0,max_int64] has the same representation with both Int64 and Word64 + | w > maxBoundInt64 = mkLitInt64 $ w - maxBoundWord64 - 1 + | otherwise = mkLitInt64 w +word64ToInt64Lit l = pprPanic "word64ToInt64Lit" (ppr l) + +int64ToWord64Lit (LitNumber LitNumInt64 i) + -- Map Int64 range [min_int64 , -1] + -- to Word64 range [max_int64+1, max_word64] + -- Range [0,max_int64] has the same representation with both Int64 and Word64 + | i < 0 = mkLitWord64 $ 1 + maxBoundWord64 + i + | otherwise = mkLitWord64 i +int64ToWord64Lit l = pprPanic "int64ToWord64Lit" (ppr l) + word2IntLit, int2WordLit :: Platform -> Literal -> Literal + word2IntLit platform (LitNumber LitNumWord w) -- Map Word range [max_int+1, max_word] -- to Int range [min_int , -1] ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -54,10 +54,12 @@ module GHC.Utils.Outputable ( pprInfixVar, pprPrefixVar, pprHsChar, pprHsString, pprHsBytes, - primFloatSuffix, primCharSuffix, primWordSuffix, primDoubleSuffix, - primInt64Suffix, primWord64Suffix, primIntSuffix, + primFloatSuffix, primCharSuffix, primDoubleSuffix, + primInt64Suffix, primWord64Suffix, + primIntSuffix, primWordSuffix, - pprPrimChar, pprPrimInt, pprPrimWord, pprPrimInt64, pprPrimWord64, + pprPrimChar, pprPrimInt, pprPrimWord, + pprPrimInt64, pprPrimWord64, pprFastFilePath, pprFilePathString, @@ -1014,8 +1016,9 @@ pprHsBytes bs = let escaped = concatMap escape $ BS.unpack bs -- Postfix modifiers for unboxed literals. -- See Note [Printing of literals in Core] in "GHC.Types.Literal". -primCharSuffix, primFloatSuffix, primIntSuffix :: SDoc -primDoubleSuffix, primWordSuffix, primInt64Suffix, primWord64Suffix :: SDoc +primCharSuffix, primFloatSuffix, primDoubleSuffix, + primIntSuffix, primWordSuffix, + primInt64Suffix, primWord64Suffix :: SDoc primCharSuffix = char '#' primFloatSuffix = char '#' primIntSuffix = char '#' @@ -1026,7 +1029,8 @@ primWord64Suffix = text "L##" -- | Special combinator for showing unboxed literals. pprPrimChar :: Char -> SDoc -pprPrimInt, pprPrimWord, pprPrimInt64, pprPrimWord64 :: Integer -> SDoc +pprPrimInt, pprPrimWord, + pprPrimInt64, pprPrimWord64 :: Integer -> SDoc pprPrimChar c = pprHsChar c <> primCharSuffix pprPrimInt i = integer i <> primIntSuffix pprPrimWord w = word w <> primWordSuffix ===================================== includes/stg/Prim.h ===================================== @@ -68,8 +68,6 @@ StgWord16 hs_bitrev16(StgWord16 x); StgWord32 hs_bitrev32(StgWord32 x); StgWord64 hs_bitrev64(StgWord64 x); -/* TODO: longlong.c */ - /* libraries/ghc-prim/cbits/pdep.c */ StgWord64 hs_pdep64(StgWord64 src, StgWord64 mask); StgWord hs_pdep32(StgWord src, StgWord mask); ===================================== libraries/base/GHC/Exts.hs ===================================== @@ -34,8 +34,6 @@ module GHC.Exts module GHC.Prim, module GHC.Prim.Ext, shiftL#, shiftRL#, iShiftL#, iShiftRA#, iShiftRL#, - uncheckedShiftL64#, uncheckedShiftRL64#, - uncheckedIShiftL64#, uncheckedIShiftRA64#, isTrue#, -- * Compat wrapper @@ -111,8 +109,8 @@ import GHC.Prim hiding ( coerce, TYPE ) import qualified GHC.Prim import qualified GHC.Prim.Ext import GHC.Base hiding ( coerce ) -import GHC.Word -import GHC.Int +import GHC.Word () +import GHC.Int () import GHC.Ptr import GHC.Stack ===================================== libraries/base/GHC/Float.hs ===================================== @@ -1421,11 +1421,7 @@ castWord64ToDouble :: Word64 -> Double castWord64ToDouble (W64# w) = D# (stgWord64ToDouble w) foreign import prim "stg_word64ToDoublezh" -#if WORD_SIZE_IN_BITS == 64 - stgWord64ToDouble :: Word# -> Double# -#else stgWord64ToDouble :: Word64# -> Double# -#endif -- | @'castFloatToWord64' f@ does a bit-for-bit copy from a floating-point value @@ -1438,8 +1434,4 @@ castDoubleToWord64 :: Double -> Word64 castDoubleToWord64 (D# d#) = W64# (stgDoubleToWord64 d#) foreign import prim "stg_doubleToWord64zh" -#if WORD_SIZE_IN_BITS == 64 - stgDoubleToWord64 :: Double# -> Word# -#else stgDoubleToWord64 :: Double# -> Word64# -#endif ===================================== libraries/base/GHC/Float/ConversionUtils.hs ===================================== @@ -23,9 +23,6 @@ module GHC.Float.ConversionUtils ( elimZerosInteger, elimZerosInt# ) where import GHC.Base import GHC.Num.Integer -#if WORD_SIZE_IN_BITS < 64 -import GHC.IntWord64 -#endif default () ===================================== libraries/base/GHC/Float/RealFracMethods.hs ===================================== @@ -1,5 +1,5 @@ {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE CPP, MagicHash, UnboxedTuples, NoImplicitPrelude #-} +{-# LANGUAGE MagicHash, UnboxedTuples, NoImplicitPrelude #-} {-# OPTIONS_HADDOCK not-home #-} ----------------------------------------------------------------------------- @@ -19,8 +19,6 @@ -- ----------------------------------------------------------------------------- -#include "MachDeps.h" - module GHC.Float.RealFracMethods ( -- * Double methods -- ** Integer results @@ -59,30 +57,6 @@ import GHC.Num.Integer import GHC.Base import GHC.Num () -#if WORD_SIZE_IN_BITS < 64 - -import GHC.IntWord64 - -#define TO64 integerToInt64# -#define FROM64 integerFromInt64# -#define MINUS64 minusInt64# -#define NEGATE64 negateInt64# - -#else - -#define TO64 integerToInt# -#define FROM64 IS -#define MINUS64 ( -# ) -#define NEGATE64 negateInt# - -uncheckedIShiftRA64# :: Int# -> Int# -> Int# -uncheckedIShiftRA64# = uncheckedIShiftRA# - -uncheckedIShiftL64# :: Int# -> Int# -> Int# -uncheckedIShiftL64# = uncheckedIShiftL# - -#endif - default () ------------------------------------------------------------------------------ @@ -237,21 +211,21 @@ properFractionDoubleInteger v@(D# x) = case negateInt# e of s | isTrue# (s ># 52#) -> (0, v) | m < 0 -> - case TO64 (integerNegate m) of + case integerToInt64# (integerNegate m) of n -> case n `uncheckedIShiftRA64#` s of k -> - (FROM64 (NEGATE64 k), - case MINUS64 n (k `uncheckedIShiftL64#` s) of + (integerFromInt64# (negateInt64# k), + case subInt64# n (k `uncheckedIShiftL64#` s) of r -> - D# (integerEncodeDouble# (FROM64 (NEGATE64 r)) e)) + D# (integerEncodeDouble# (integerFromInt64# (negateInt64# r)) e)) | otherwise -> - case TO64 m of + case integerToInt64# m of n -> case n `uncheckedIShiftRA64#` s of - k -> (FROM64 k, - case MINUS64 n (k `uncheckedIShiftL64#` s) of - r -> D# (integerEncodeDouble# (FROM64 r) e)) + k -> (integerFromInt64# k, + case subInt64# n (k `uncheckedIShiftL64#` s) of + r -> D# (integerEncodeDouble# (integerFromInt64# r) e)) | otherwise -> (integerShiftL# m (int2Word# e), D# 0.0##) {-# INLINE truncateDoubleInteger #-} @@ -271,8 +245,8 @@ floorDoubleInteger (D# x) = case negateInt# e of s | isTrue# (s ># 52#) -> if m < 0 then (-1) else 0 | otherwise -> - case TO64 m of - n -> FROM64 (n `uncheckedIShiftRA64#` s) + case integerToInt64# m of + n -> integerFromInt64# (n `uncheckedIShiftRA64#` s) | otherwise -> integerShiftL# m (int2Word# e) {-# INLINE ceilingDoubleInteger #-} @@ -313,8 +287,8 @@ double2Integer (D# x) = case integerDecodeDouble# x of (# m, e #) | isTrue# (e <# 0#) -> - case TO64 m of - n -> FROM64 (n `uncheckedIShiftRA64#` negateInt# e) + case integerToInt64# m of + n -> integerFromInt64# (n `uncheckedIShiftRA64#` negateInt# e) | otherwise -> integerShiftL# m (int2Word# e) {-# INLINE float2Integer #-} ===================================== libraries/base/GHC/Int.hs ===================================== @@ -34,10 +34,6 @@ module GHC.Int ( import Data.Bits import Data.Maybe -#if WORD_SIZE_IN_BITS < 64 -import GHC.IntWord64 -#endif - import GHC.Base import GHC.Enum import GHC.Num @@ -694,8 +690,6 @@ instance Ix Int32 where -- type Int64 ------------------------------------------------------------------------ -#if WORD_SIZE_IN_BITS < 64 - data {-# CTYPE "HsInt64" #-} Int64 = I64# Int64# -- ^ 64-bit signed integer type @@ -735,7 +729,7 @@ instance Show Int64 where -- | @since 2.01 instance Num Int64 where (I64# x#) + (I64# y#) = I64# (x# `plusInt64#` y#) - (I64# x#) - (I64# y#) = I64# (x# `minusInt64#` y#) + (I64# x#) - (I64# y#) = I64# (x# `subInt64#` y#) (I64# x#) * (I64# y#) = I64# (x# `timesInt64#` y#) negate (I64# x#) = I64# (negateInt64# x#) abs x | x >= 0 = x @@ -807,9 +801,9 @@ divInt64#, modInt64# :: Int64# -> Int64# -> Int64# -- Define div in terms of quot, being careful to avoid overflow (#7233) x# `divInt64#` y# | isTrue# (x# `gtInt64#` zero) && isTrue# (y# `ltInt64#` zero) - = ((x# `minusInt64#` one) `quotInt64#` y#) `minusInt64#` one + = ((x# `subInt64#` one) `quotInt64#` y#) `subInt64#` one | isTrue# (x# `ltInt64#` zero) && isTrue# (y# `gtInt64#` zero) - = ((x# `plusInt64#` one) `quotInt64#` y#) `minusInt64#` one + = ((x# `plusInt64#` one) `quotInt64#` y#) `subInt64#` one | otherwise = x# `quotInt64#` y# where @@ -895,210 +889,14 @@ a `iShiftRA64#` b | isTrue# (b >=# 64#) = if isTrue# (a `ltInt64#` (intToInt64# -- No RULES for RealFrac methods if Int is smaller than Int64, we can't -- go through Int and whether going through Integer is faster is uncertain. -#else - --- Int64 is represented in the same way as Int. --- Operations may assume and must ensure that it holds only values --- from its logical range. - -data {-# CTYPE "HsInt64" #-} Int64 = I64# Int# --- ^ 64-bit signed integer type - --- See GHC.Classes#matching_overloaded_methods_in_rules --- | @since 2.01 -instance Eq Int64 where - (==) = eqInt64 - (/=) = neInt64 - -eqInt64, neInt64 :: Int64 -> Int64 -> Bool -eqInt64 (I64# x) (I64# y) = isTrue# (x ==# y) -neInt64 (I64# x) (I64# y) = isTrue# (x /=# y) -{-# INLINE [1] eqInt64 #-} -{-# INLINE [1] neInt64 #-} - --- | @since 2.01 -instance Ord Int64 where - (<) = ltInt64 - (<=) = leInt64 - (>=) = geInt64 - (>) = gtInt64 - -{-# INLINE [1] gtInt64 #-} -{-# INLINE [1] geInt64 #-} -{-# INLINE [1] ltInt64 #-} -{-# INLINE [1] leInt64 #-} -gtInt64, geInt64, ltInt64, leInt64 :: Int64 -> Int64 -> Bool -(I64# x) `gtInt64` (I64# y) = isTrue# (x ># y) -(I64# x) `geInt64` (I64# y) = isTrue# (x >=# y) -(I64# x) `ltInt64` (I64# y) = isTrue# (x <# y) -(I64# x) `leInt64` (I64# y) = isTrue# (x <=# y) - --- | @since 2.01 -instance Show Int64 where - showsPrec p x = showsPrec p (fromIntegral x :: Int) - --- | @since 2.01 -instance Num Int64 where - (I64# x#) + (I64# y#) = I64# (x# +# y#) - (I64# x#) - (I64# y#) = I64# (x# -# y#) - (I64# x#) * (I64# y#) = I64# (x# *# y#) - negate (I64# x#) = I64# (negateInt# x#) - abs x | x >= 0 = x - | otherwise = negate x - signum x | x > 0 = 1 - signum 0 = 0 - signum _ = -1 - fromInteger i = I64# (integerToInt# i) - --- | @since 2.01 -instance Enum Int64 where - succ x - | x /= maxBound = x + 1 - | otherwise = succError "Int64" - pred x - | x /= minBound = x - 1 - | otherwise = predError "Int64" - toEnum (I# i#) = I64# i# - fromEnum (I64# x#) = I# x# - enumFrom = boundedEnumFrom - enumFromThen = boundedEnumFromThen - --- | @since 2.01 -instance Integral Int64 where - quot x@(I64# x#) y@(I64# y#) - | y == 0 = divZeroError - | y == (-1) && x == minBound = overflowError -- Note [Order of tests] - | otherwise = I64# (x# `quotInt#` y#) - rem (I64# x#) y@(I64# y#) - | y == 0 = divZeroError - -- The quotRem CPU instruction fails for minBound `quotRem` -1, - -- but minBound `rem` -1 is well-defined (0). We therefore - -- special-case it. - | y == (-1) = 0 - | otherwise = I64# (x# `remInt#` y#) - div x@(I64# x#) y@(I64# y#) - | y == 0 = divZeroError - | y == (-1) && x == minBound = overflowError -- Note [Order of tests] - | otherwise = I64# (x# `divInt#` y#) - mod (I64# x#) y@(I64# y#) - | y == 0 = divZeroError - -- The divMod CPU instruction fails for minBound `divMod` -1, - -- but minBound `mod` -1 is well-defined (0). We therefore - -- special-case it. - | y == (-1) = 0 - | otherwise = I64# (x# `modInt#` y#) - quotRem x@(I64# x#) y@(I64# y#) - | y == 0 = divZeroError - -- Note [Order of tests] - | y == (-1) && x == minBound = (overflowError, 0) - | otherwise = case x# `quotRemInt#` y# of - (# q, r #) -> - (I64# q, I64# r) - divMod x@(I64# x#) y@(I64# y#) - | y == 0 = divZeroError - -- Note [Order of tests] - | y == (-1) && x == minBound = (overflowError, 0) - | otherwise = case x# `divModInt#` y# of - (# d, m #) -> - (I64# d, I64# m) - toInteger (I64# x#) = IS x# - --- | @since 2.01 -instance Read Int64 where - readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s] - --- | @since 2.01 -instance Bits Int64 where - {-# INLINE shift #-} - {-# INLINE bit #-} - {-# INLINE testBit #-} - {-# INLINE popCount #-} - - (I64# x#) .&. (I64# y#) = I64# (x# `andI#` y#) - (I64# x#) .|. (I64# y#) = I64# (x# `orI#` y#) - (I64# x#) `xor` (I64# y#) = I64# (x# `xorI#` y#) - complement (I64# x#) = I64# (notI# x#) - (I64# x#) `shift` (I# i#) - | isTrue# (i# >=# 0#) = I64# (x# `iShiftL#` i#) - | otherwise = I64# (x# `iShiftRA#` negateInt# i#) - (I64# x#) `shiftL` (I# i#) - | isTrue# (i# >=# 0#) = I64# (x# `iShiftL#` i#) - | otherwise = overflowError - (I64# x#) `unsafeShiftL` (I# i#) = I64# (x# `uncheckedIShiftL#` i#) - (I64# x#) `shiftR` (I# i#) - | isTrue# (i# >=# 0#) = I64# (x# `iShiftRA#` i#) - | otherwise = overflowError - (I64# x#) `unsafeShiftR` (I# i#) = I64# (x# `uncheckedIShiftRA#` i#) - (I64# x#) `rotate` (I# i#) - | isTrue# (i'# ==# 0#) - = I64# x# - | otherwise - = I64# (word2Int# ((x'# `uncheckedShiftL#` i'#) `or#` - (x'# `uncheckedShiftRL#` (64# -# i'#)))) - where - !x'# = int2Word# x# - !i'# = word2Int# (int2Word# i# `and#` 63##) - bitSizeMaybe i = Just (finiteBitSize i) - bitSize i = finiteBitSize i - isSigned _ = True - popCount (I64# x#) = I# (word2Int# (popCnt64# (int2Word# x#))) - bit = bitDefault - testBit = testBitDefault - -{-# RULES -"fromIntegral/a->Int64" fromIntegral = \x -> case fromIntegral x of I# x# -> I64# x# -"fromIntegral/Int64->a" fromIntegral = \(I64# x#) -> fromIntegral (I# x#) - #-} - -{-# RULES -"properFraction/Float->(Int64,Float)" - properFraction = \x -> - case properFraction x of { - (n, y) -> ((fromIntegral :: Int -> Int64) n, y :: Float) } -"truncate/Float->Int64" - truncate = (fromIntegral :: Int -> Int64) . (truncate :: Float -> Int) -"floor/Float->Int64" - floor = (fromIntegral :: Int -> Int64) . (floor :: Float -> Int) -"ceiling/Float->Int64" - ceiling = (fromIntegral :: Int -> Int64) . (ceiling :: Float -> Int) -"round/Float->Int64" - round = (fromIntegral :: Int -> Int64) . (round :: Float -> Int) - #-} - -{-# RULES -"properFraction/Double->(Int64,Double)" - properFraction = \x -> - case properFraction x of { - (n, y) -> ((fromIntegral :: Int -> Int64) n, y :: Double) } -"truncate/Double->Int64" - truncate = (fromIntegral :: Int -> Int64) . (truncate :: Double -> Int) -"floor/Double->Int64" - floor = (fromIntegral :: Int -> Int64) . (floor :: Double -> Int) -"ceiling/Double->Int64" - ceiling = (fromIntegral :: Int -> Int64) . (ceiling :: Double -> Int) -"round/Double->Int64" - round = (fromIntegral :: Int -> Int64) . (round :: Double -> Int) - #-} - -uncheckedIShiftL64# :: Int# -> Int# -> Int# -uncheckedIShiftL64# = uncheckedIShiftL# - -uncheckedIShiftRA64# :: Int# -> Int# -> Int# -uncheckedIShiftRA64# = uncheckedIShiftRA# -#endif -- | @since 4.6.0.0 instance FiniteBits Int64 where {-# INLINE countLeadingZeros #-} {-# INLINE countTrailingZeros #-} finiteBitSize _ = 64 -#if WORD_SIZE_IN_BITS < 64 countLeadingZeros (I64# x#) = I# (word2Int# (clz64# (int64ToWord64# x#))) countTrailingZeros (I64# x#) = I# (word2Int# (ctz64# (int64ToWord64# x#))) -#else - countLeadingZeros (I64# x#) = I# (word2Int# (clz64# (int2Word# x#))) - countTrailingZeros (I64# x#) = I# (word2Int# (ctz64# (int2Word# x#))) -#endif -- | @since 2.01 instance Real Int64 where ===================================== libraries/base/GHC/StaticPtr.hs ===================================== @@ -59,14 +59,9 @@ import GHC.Word (Word64(..)) #include "MachDeps.h" -- | A reference to a value of type @a at . -#if WORD_SIZE_IN_BITS < 64 data StaticPtr a = StaticPtr Word64# Word64# -- The flattened Fingerprint is -- convenient in the compiler. StaticPtrInfo a -#else -data StaticPtr a = StaticPtr Word# Word# - StaticPtrInfo a -#endif -- | Dereferences a static pointer. deRefStaticPtr :: StaticPtr a -> a deRefStaticPtr (StaticPtr _ _ _ v) = v ===================================== libraries/base/GHC/Word.hs ===================================== @@ -49,10 +49,6 @@ module GHC.Word ( import Data.Bits import Data.Maybe -#if WORD_SIZE_IN_BITS < 64 -import GHC.IntWord64 -#endif - import GHC.Base import GHC.Enum import GHC.Num @@ -685,8 +681,6 @@ byteSwap32 (W32# w#) = W32# (narrow32Word# (byteSwap32# w#)) -- type Word64 ------------------------------------------------------------------------ -#if WORD_SIZE_IN_BITS < 64 - data {-# CTYPE "HsWord64" #-} Word64 = W64# Word64# -- ^ 64-bit unsigned integer type @@ -722,7 +716,7 @@ gtWord64, geWord64, ltWord64, leWord64 :: Word64 -> Word64 -> Bool -- | @since 2.01 instance Num Word64 where (W64# x#) + (W64# y#) = W64# (int64ToWord64# (word64ToInt64# x# `plusInt64#` word64ToInt64# y#)) - (W64# x#) - (W64# y#) = W64# (int64ToWord64# (word64ToInt64# x# `minusInt64#` word64ToInt64# y#)) + (W64# x#) - (W64# y#) = W64# (int64ToWord64# (word64ToInt64# x# `subInt64#` word64ToInt64# y#)) (W64# x#) * (W64# y#) = W64# (int64ToWord64# (word64ToInt64# x# `timesInt64#` word64ToInt64# y#)) negate (W64# x#) = W64# (int64ToWord64# (negateInt64# (word64ToInt64# x#))) abs x = x @@ -828,184 +822,13 @@ a `shiftRL64#` b | isTrue# (b >=# 64#) = wordToWord64# 0## "fromIntegral/Word64->Word64" fromIntegral = id :: Word64 -> Word64 #-} -#else - --- Word64 is represented in the same way as Word. --- Operations may assume and must ensure that it holds only values --- from its logical range. - -data {-# CTYPE "HsWord64" #-} Word64 = W64# Word# --- ^ 64-bit unsigned integer type - --- See GHC.Classes#matching_overloaded_methods_in_rules --- | @since 2.01 -instance Eq Word64 where - (==) = eqWord64 - (/=) = neWord64 - -eqWord64, neWord64 :: Word64 -> Word64 -> Bool -eqWord64 (W64# x) (W64# y) = isTrue# (x `eqWord#` y) -neWord64 (W64# x) (W64# y) = isTrue# (x `neWord#` y) -{-# INLINE [1] eqWord64 #-} -{-# INLINE [1] neWord64 #-} - --- | @since 2.01 -instance Ord Word64 where - (<) = ltWord64 - (<=) = leWord64 - (>=) = geWord64 - (>) = gtWord64 - -{-# INLINE [1] gtWord64 #-} -{-# INLINE [1] geWord64 #-} -{-# INLINE [1] ltWord64 #-} -{-# INLINE [1] leWord64 #-} -gtWord64, geWord64, ltWord64, leWord64 :: Word64 -> Word64 -> Bool -(W64# x) `gtWord64` (W64# y) = isTrue# (x `gtWord#` y) -(W64# x) `geWord64` (W64# y) = isTrue# (x `geWord#` y) -(W64# x) `ltWord64` (W64# y) = isTrue# (x `ltWord#` y) -(W64# x) `leWord64` (W64# y) = isTrue# (x `leWord#` y) - --- | @since 2.01 -instance Num Word64 where - (W64# x#) + (W64# y#) = W64# (x# `plusWord#` y#) - (W64# x#) - (W64# y#) = W64# (x# `minusWord#` y#) - (W64# x#) * (W64# y#) = W64# (x# `timesWord#` y#) - negate (W64# x#) = W64# (int2Word# (negateInt# (word2Int# x#))) - abs x = x - signum 0 = 0 - signum _ = 1 - fromInteger i = W64# (integerToWord# i) - --- | @since 2.01 -instance Enum Word64 where - succ x - | x /= maxBound = x + 1 - | otherwise = succError "Word64" - pred x - | x /= minBound = x - 1 - | otherwise = predError "Word64" - toEnum i@(I# i#) - | i >= 0 = W64# (int2Word# i#) - | otherwise = toEnumError "Word64" i (minBound::Word64, maxBound::Word64) - fromEnum x@(W64# x#) - | x <= fromIntegral (maxBound::Int) - = I# (word2Int# x#) - | otherwise = fromEnumError "Word64" x - -#if WORD_SIZE_IN_BITS < 64 - enumFrom = integralEnumFrom - enumFromThen = integralEnumFromThen - enumFromTo = integralEnumFromTo - enumFromThenTo = integralEnumFromThenTo -#else - -- See Note [Stable Unfolding for list producers] in GHC.Enum - {-# INLINABLE enumFrom #-} - enumFrom w - = map wordToWord64 - $ enumFrom (word64ToWord w) - - -- See Note [Stable Unfolding for list producers] in GHC.Enum - {-# INLINABLE enumFromThen #-} - enumFromThen w s - = map wordToWord64 - $ enumFromThen (word64ToWord w) (word64ToWord s) - - -- See Note [Stable Unfolding for list producers] in GHC.Enum - {-# INLINABLE enumFromTo #-} - enumFromTo w1 w2 - = map wordToWord64 - $ enumFromTo (word64ToWord w1) (word64ToWord w2) - - -- See Note [Stable Unfolding for list producers] in GHC.Enum - {-# INLINABLE enumFromThenTo #-} - enumFromThenTo w1 s w2 - = map wordToWord64 - $ enumFromThenTo (word64ToWord w1) (word64ToWord s) (word64ToWord w2) - -word64ToWord :: Word64 -> Word -word64ToWord (W64# w#) = (W# w#) - -wordToWord64 :: Word -> Word64 -wordToWord64 (W# w#) = (W64# w#) -#endif - - --- | @since 2.01 -instance Integral Word64 where - quot (W64# x#) y@(W64# y#) - | y /= 0 = W64# (x# `quotWord#` y#) - | otherwise = divZeroError - rem (W64# x#) y@(W64# y#) - | y /= 0 = W64# (x# `remWord#` y#) - | otherwise = divZeroError - div (W64# x#) y@(W64# y#) - | y /= 0 = W64# (x# `quotWord#` y#) - | otherwise = divZeroError - mod (W64# x#) y@(W64# y#) - | y /= 0 = W64# (x# `remWord#` y#) - | otherwise = divZeroError - quotRem (W64# x#) y@(W64# y#) - | y /= 0 = case x# `quotRemWord#` y# of - (# q, r #) -> - (W64# q, W64# r) - | otherwise = divZeroError - divMod (W64# x#) y@(W64# y#) - | y /= 0 = (W64# (x# `quotWord#` y#), W64# (x# `remWord#` y#)) - | otherwise = divZeroError - toInteger (W64# x#) - | isTrue# (i# >=# 0#) = IS i# - | otherwise = integerFromWord# x# - where - !i# = word2Int# x# - --- | @since 2.01 -instance Bits Word64 where - {-# INLINE shift #-} - {-# INLINE bit #-} - {-# INLINE testBit #-} - {-# INLINE popCount #-} - - (W64# x#) .&. (W64# y#) = W64# (x# `and#` y#) - (W64# x#) .|. (W64# y#) = W64# (x# `or#` y#) - (W64# x#) `xor` (W64# y#) = W64# (x# `xor#` y#) - complement (W64# x#) = W64# (x# `xor#` mb#) - where !(W64# mb#) = maxBound - (W64# x#) `shift` (I# i#) - | isTrue# (i# >=# 0#) = W64# (x# `shiftL#` i#) - | otherwise = W64# (x# `shiftRL#` negateInt# i#) - (W64# x#) `shiftL` (I# i#) - | isTrue# (i# >=# 0#) = W64# (x# `shiftL#` i#) - | otherwise = overflowError - (W64# x#) `unsafeShiftL` (I# i#) = W64# (x# `uncheckedShiftL#` i#) - (W64# x#) `shiftR` (I# i#) - | isTrue# (i# >=# 0#) = W64# (x# `shiftRL#` i#) - | otherwise = overflowError - (W64# x#) `unsafeShiftR` (I# i#) = W64# (x# `uncheckedShiftRL#` i#) - (W64# x#) `rotate` (I# i#) - | isTrue# (i'# ==# 0#) = W64# x# - | otherwise = W64# ((x# `uncheckedShiftL#` i'#) `or#` - (x# `uncheckedShiftRL#` (64# -# i'#))) - where - !i'# = word2Int# (int2Word# i# `and#` 63##) - bitSizeMaybe i = Just (finiteBitSize i) - bitSize i = finiteBitSize i - isSigned _ = False - popCount (W64# x#) = I# (word2Int# (popCnt64# x#)) - bit = bitDefault - testBit = testBitDefault +#if WORD_SIZE_IN_BITS == 64 {-# RULES -"fromIntegral/a->Word64" fromIntegral = \x -> case fromIntegral x of W# x# -> W64# x# -"fromIntegral/Word64->a" fromIntegral = \(W64# x#) -> fromIntegral (W# x#) +"fromIntegral/a->Word64" fromIntegral = \x -> case fromIntegral x of W# x# -> W64# (wordToWord64# x#) +"fromIntegral/Word64->a" fromIntegral = \(W64# x#) -> fromIntegral (W# (word64ToWord# x#)) #-} -uncheckedShiftL64# :: Word# -> Int# -> Word# -uncheckedShiftL64# = uncheckedShiftL# - -uncheckedShiftRL64# :: Word# -> Int# -> Word# -uncheckedShiftRL64# = uncheckedShiftRL# - #endif -- | @since 4.6.0.0 @@ -1038,13 +861,8 @@ instance Ix Word64 where -- | Reverse order of bytes in 'Word64'. -- -- @since 4.7.0.0 -#if WORD_SIZE_IN_BITS < 64 byteSwap64 :: Word64 -> Word64 byteSwap64 (W64# w#) = W64# (byteSwap64# w#) -#else -byteSwap64 :: Word64 -> Word64 -byteSwap64 (W64# w#) = W64# (byteSwap# w#) -#endif -- | Reverse the order of the bits in a 'Word8'. -- @@ -1067,13 +885,8 @@ bitReverse32 (W32# w#) = W32# (narrow32Word# (bitReverse32# w#)) -- | Reverse the order of the bits in a 'Word64'. -- -- @since 4.12.0.0 -#if WORD_SIZE_IN_BITS < 64 bitReverse64 :: Word64 -> Word64 bitReverse64 (W64# w#) = W64# (bitReverse64# w#) -#else -bitReverse64 :: Word64 -> Word64 -bitReverse64 (W64# w#) = W64# (bitReverse# w#) -#endif ------------------------------------------------------------------------------- ===================================== libraries/binary ===================================== @@ -1 +1 @@ -Subproject commit dfaf780596328c9184758452b78288e8f405fcc1 +Subproject commit 6dc8fa9cb4f51fb4253925f02b78478784d6bbbe ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit e6cb01e2ec0bfdd19298418c85f220925a9fa307 +Subproject commit 8e50cfe3321107638dcf5e14a9c0d3cebe5bbf1c ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -24,10 +24,6 @@ import GHC.Magic import GHC.Num.Primitives import GHC.Num.WordArray -#if WORD_SIZE_IN_BITS < 64 -import GHC.IntWord64 -#endif - #if defined(BIGNUM_CHECK) import GHC.Num.BigNat.Check @@ -246,8 +242,6 @@ bigNatToInt# a bigNatToInt :: BigNat -> Int bigNatToInt bn = I# (bigNatToInt# bn) -#if WORD_SIZE_IN_BITS == 32 - -- | Convert a Word64# into a BigNat on 32-bit architectures bigNatFromWord64# :: Word64# -> BigNat bigNatFromWord64# w64 = bigNatFromWord2# wh# wl# @@ -266,8 +260,6 @@ bigNatToWord64# b in uncheckedShiftL64# wh 32# `or64#` wl else wl -#endif - -- | Encode (# BigNat mantissa, Int# exponent #) into a Double# bigNatEncodeDouble# :: BigNat -> Int# -> Double# bigNatEncodeDouble# a e ===================================== libraries/ghc-bignum/src/GHC/Num/Integer.hs ===================================== @@ -32,10 +32,6 @@ import GHC.Num.Primitives import GHC.Num.BigNat import GHC.Num.Natural -#if WORD_SIZE_IN_BITS < 64 -import GHC.IntWord64 -#endif - default () -- | Arbitrary precision integers. In contrast with fixed-size integral types @@ -974,8 +970,6 @@ integerIsPowerOf2# (IS i) integerIsPowerOf2# (IN _) = (# () | #) integerIsPowerOf2# (IP w) = bigNatIsPowerOf2# w -#if WORD_SIZE_IN_BITS == 32 - -- | Convert an Int64# into an Integer on 32-bit architectures integerFromInt64# :: Int64# -> Integer {-# NOINLINE integerFromInt64# #-} @@ -1013,14 +1007,6 @@ integerToWord64# (IS i) = int64ToWord64# (intToInt64# i) integerToWord64# (IP b) = bigNatToWord64# b integerToWord64# (IN b) = int64ToWord64# (negateInt64# (word64ToInt64# (bigNatToWord64# b))) -#else - --- | Convert an Int64# into an Integer on 64-bit architectures -integerFromInt64# :: Int# -> Integer -integerFromInt64# !x = IS x - -#endif - ---------------------------------------------------------------------------- -- Conversions to/from floating point ---------------------------------------------------------------------------- ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -55,7 +55,6 @@ module GHC.Classes( -- GHC.Magic is used in some derived instances import GHC.Magic () -import GHC.IntWord64 import GHC.Prim import GHC.Tuple import GHC.CString (unpackCString#) @@ -279,7 +278,6 @@ eqInt, neInt :: Int -> Int -> Bool (I# x) `eqInt` (I# y) = isTrue# (x ==# y) (I# x) `neInt` (I# y) = isTrue# (x /=# y) -#if WORD_SIZE_IN_BITS < 64 instance Eq TyCon where (==) (TyCon hi1 lo1 _ _ _ _) (TyCon hi2 lo2 _ _ _ _) = isTrue# (hi1 `eqWord64#` hi2) && isTrue# (lo1 `eqWord64#` lo2) @@ -290,18 +288,6 @@ instance Ord TyCon where | isTrue# (lo1 `gtWord64#` lo2) = GT | isTrue# (lo1 `ltWord64#` lo2) = LT | True = EQ -#else -instance Eq TyCon where - (==) (TyCon hi1 lo1 _ _ _ _) (TyCon hi2 lo2 _ _ _ _) - = isTrue# (hi1 `eqWord#` hi2) && isTrue# (lo1 `eqWord#` lo2) -instance Ord TyCon where - compare (TyCon hi1 lo1 _ _ _ _) (TyCon hi2 lo2 _ _ _ _) - | isTrue# (hi1 `gtWord#` hi2) = GT - | isTrue# (hi1 `ltWord#` hi2) = LT - | isTrue# (lo1 `gtWord#` lo2) = GT - | isTrue# (lo1 `ltWord#` lo2) = LT - | True = EQ -#endif -- | The 'Ord' class is used for totally ordered datatypes. ===================================== libraries/ghc-prim/GHC/IntWord64.hs deleted ===================================== @@ -1,74 +0,0 @@ -{-# LANGUAGE CPP, MagicHash, NoImplicitPrelude, UnliftedFFITypes #-} -{-# OPTIONS_HADDOCK not-home #-} ------------------------------------------------------------------------------ --- | --- Module : GHC.IntWord64 --- Copyright : (c) The University of Glasgow, 1997-2008 --- License : see libraries/ghc-prim/LICENSE --- --- Maintainer : cvs-ghc at haskell.org --- Stability : internal --- Portability : non-portable (GHC Extensions) --- --- Primitive operations on Int64# and Word64# on platforms where --- WORD_SIZE_IN_BITS < 64. --- ------------------------------------------------------------------------------ - -#include "MachDeps.h" - -module GHC.IntWord64 ( -#if WORD_SIZE_IN_BITS < 64 - Int64#, Word64#, module GHC.IntWord64 -#endif - ) where - -import GHC.Types () -- Make implicit dependency known to build system - -#if WORD_SIZE_IN_BITS < 64 - -import GHC.Prim - -foreign import ccall unsafe "hs_eqWord64" eqWord64# :: Word64# -> Word64# -> Int# -foreign import ccall unsafe "hs_neWord64" neWord64# :: Word64# -> Word64# -> Int# -foreign import ccall unsafe "hs_ltWord64" ltWord64# :: Word64# -> Word64# -> Int# -foreign import ccall unsafe "hs_leWord64" leWord64# :: Word64# -> Word64# -> Int# -foreign import ccall unsafe "hs_gtWord64" gtWord64# :: Word64# -> Word64# -> Int# -foreign import ccall unsafe "hs_geWord64" geWord64# :: Word64# -> Word64# -> Int# - -foreign import ccall unsafe "hs_eqInt64" eqInt64# :: Int64# -> Int64# -> Int# -foreign import ccall unsafe "hs_neInt64" neInt64# :: Int64# -> Int64# -> Int# -foreign import ccall unsafe "hs_ltInt64" ltInt64# :: Int64# -> Int64# -> Int# -foreign import ccall unsafe "hs_leInt64" leInt64# :: Int64# -> Int64# -> Int# -foreign import ccall unsafe "hs_gtInt64" gtInt64# :: Int64# -> Int64# -> Int# -foreign import ccall unsafe "hs_geInt64" geInt64# :: Int64# -> Int64# -> Int# -foreign import ccall unsafe "hs_quotInt64" quotInt64# :: Int64# -> Int64# -> Int64# -foreign import ccall unsafe "hs_remInt64" remInt64# :: Int64# -> Int64# -> Int64# - -foreign import ccall unsafe "hs_plusInt64" plusInt64# :: Int64# -> Int64# -> Int64# -foreign import ccall unsafe "hs_minusInt64" minusInt64# :: Int64# -> Int64# -> Int64# -foreign import ccall unsafe "hs_timesInt64" timesInt64# :: Int64# -> Int64# -> Int64# -foreign import ccall unsafe "hs_negateInt64" negateInt64# :: Int64# -> Int64# -foreign import ccall unsafe "hs_quotWord64" quotWord64# :: Word64# -> Word64# -> Word64# -foreign import ccall unsafe "hs_remWord64" remWord64# :: Word64# -> Word64# -> Word64# - -foreign import ccall unsafe "hs_and64" and64# :: Word64# -> Word64# -> Word64# -foreign import ccall unsafe "hs_or64" or64# :: Word64# -> Word64# -> Word64# -foreign import ccall unsafe "hs_xor64" xor64# :: Word64# -> Word64# -> Word64# -foreign import ccall unsafe "hs_not64" not64# :: Word64# -> Word64# - -foreign import ccall unsafe "hs_uncheckedShiftL64" uncheckedShiftL64# :: Word64# -> Int# -> Word64# -foreign import ccall unsafe "hs_uncheckedShiftRL64" uncheckedShiftRL64# :: Word64# -> Int# -> Word64# -foreign import ccall unsafe "hs_uncheckedIShiftL64" uncheckedIShiftL64# :: Int64# -> Int# -> Int64# -foreign import ccall unsafe "hs_uncheckedIShiftRA64" uncheckedIShiftRA64# :: Int64# -> Int# -> Int64# -foreign import ccall unsafe "hs_uncheckedIShiftRL64" uncheckedIShiftRL64# :: Int64# -> Int# -> Int64# - -foreign import ccall unsafe "hs_int64ToWord64" int64ToWord64# :: Int64# -> Word64# -foreign import ccall unsafe "hs_word64ToInt64" word64ToInt64# :: Word64# -> Int64# -foreign import ccall unsafe "hs_intToInt64" intToInt64# :: Int# -> Int64# -foreign import ccall unsafe "hs_int64ToInt" int64ToInt# :: Int64# -> Int# -foreign import ccall unsafe "hs_wordToWord64" wordToWord64# :: Word# -> Word64# -foreign import ccall unsafe "hs_word64ToWord" word64ToWord# :: Word64# -> Word# - -#endif - ===================================== libraries/ghc-prim/GHC/Prim/Ext.hs ===================================== @@ -26,17 +26,14 @@ -- are described over there. module GHC.Prim.Ext ( - -- 64-bit bit aliases - INT64 - , WORD64 + -- * Misc + getThreadAllocationCounter# -- * Delay\/wait operations #if defined(mingw32_HOST_OS) , asyncRead# , asyncWrite# , asyncDoProc# #endif - -- * Misc - , getThreadAllocationCounter# ) where import GHC.Prim @@ -44,24 +41,6 @@ import GHC.Types () -- Make implicit dependency known to build system default () -- Double and Integer aren't available yet ------------------------------------------------------------------------- --- 64-bit bit aliases ------------------------------------------------------------------------- - -type INT64 = -#if WORD_SIZE_IN_BITS < 64 - Int64# -#else - Int# -#endif - -type WORD64 = -#if WORD_SIZE_IN_BITS < 64 - Word64# -#else - Word# -#endif - ------------------------------------------------------------------------ -- Delay/wait operations ------------------------------------------------------------------------ @@ -102,4 +81,4 @@ foreign import prim "stg_asyncDoProczh" asyncDoProc# -- | Retrieves the allocation counter for the current thread. foreign import prim "stg_getThreadAllocationCounterzh" getThreadAllocationCounter# :: State# RealWorld - -> (# State# RealWorld, INT64 #) + -> (# State# RealWorld, Int64# #) ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -1,5 +1,5 @@ {-# LANGUAGE MagicHash, NoImplicitPrelude, TypeFamilies, UnboxedTuples, - MultiParamTypeClasses, RoleAnnotations, CPP, TypeOperators, + MultiParamTypeClasses, RoleAnnotations, TypeOperators, PolyKinds, NegativeLiterals, DataKinds #-} -- NegativeLiterals: see Note [Fixity of (->)] ----------------------------------------------------------------------------- @@ -485,8 +485,6 @@ or Module (for example when deserialising a TypeRep), in which case we can't conveniently come up with an Addr#. -} -#include "MachDeps.h" - data Module = Module TrName -- Package name TrName -- Module name @@ -498,12 +496,6 @@ data TrName -- | A de Bruijn index for a binder within a 'KindRep'. type KindBndr = Int -#if WORD_SIZE_IN_BITS < 64 -#define WORD64_TY Word64# -#else -#define WORD64_TY Word# -#endif - -- | The representation produced by GHC for conjuring up the kind of a -- 'Data.Typeable.TypeRep'. @@ -520,7 +512,7 @@ data TypeLitSort = TypeLitSymbol | TypeLitNat -- Show instance for TyCon found in GHC.Show -data TyCon = TyCon WORD64_TY WORD64_TY -- Fingerprint +data TyCon = TyCon Word64# Word64# -- Fingerprint Module -- Module in which this is defined TrName -- Type constructor name Int# -- How many kind variables do we accept? ===================================== libraries/ghc-prim/cbits/atomic.c ===================================== @@ -33,14 +33,12 @@ hs_atomic_add32(StgWord x, StgWord val) return __sync_fetch_and_add((volatile StgWord32 *) x, (StgWord32) val); } -#if WORD_SIZE_IN_BITS == 64 extern StgWord64 hs_atomic_add64(StgWord x, StgWord64 val); StgWord64 hs_atomic_add64(StgWord x, StgWord64 val) { return __sync_fetch_and_add((volatile StgWord64 *) x, val); } -#endif // FetchSubByteArrayOp_Int @@ -65,14 +63,12 @@ hs_atomic_sub32(StgWord x, StgWord val) return __sync_fetch_and_sub((volatile StgWord32 *) x, (StgWord32) val); } -#if WORD_SIZE_IN_BITS == 64 extern StgWord64 hs_atomic_sub64(StgWord x, StgWord64 val); StgWord64 hs_atomic_sub64(StgWord x, StgWord64 val) { return __sync_fetch_and_sub((volatile StgWord64 *) x, val); } -#endif // FetchAndByteArrayOp_Int @@ -97,14 +93,12 @@ hs_atomic_and32(StgWord x, StgWord val) return __sync_fetch_and_and((volatile StgWord32 *) x, (StgWord32) val); } -#if WORD_SIZE_IN_BITS == 64 extern StgWord64 hs_atomic_and64(StgWord x, StgWord64 val); StgWord64 hs_atomic_and64(StgWord x, StgWord64 val) { return __sync_fetch_and_and((volatile StgWord64 *) x, val); } -#endif // FetchNandByteArrayOp_Int @@ -207,7 +201,6 @@ hs_atomic_nand32(StgWord x, StgWord val) #endif } -#if WORD_SIZE_IN_BITS == 64 extern StgWord64 hs_atomic_nand64(StgWord x, StgWord64 val); StgWord64 hs_atomic_nand64(StgWord x, StgWord64 val) @@ -218,7 +211,6 @@ hs_atomic_nand64(StgWord x, StgWord64 val) CAS_NAND((volatile StgWord64 *) x, val); #endif } -#endif #pragma GCC diagnostic pop @@ -245,14 +237,12 @@ hs_atomic_or32(StgWord x, StgWord val) return __sync_fetch_and_or((volatile StgWord32 *) x, (StgWord32) val); } -#if WORD_SIZE_IN_BITS == 64 extern StgWord64 hs_atomic_or64(StgWord x, StgWord64 val); StgWord64 hs_atomic_or64(StgWord x, StgWord64 val) { return __sync_fetch_and_or((volatile StgWord64 *) x, val); } -#endif // FetchXorByteArrayOp_Int @@ -277,14 +267,12 @@ hs_atomic_xor32(StgWord x, StgWord val) return __sync_fetch_and_xor((volatile StgWord32 *) x, (StgWord32) val); } -#if WORD_SIZE_IN_BITS == 64 extern StgWord64 hs_atomic_xor64(StgWord x, StgWord64 val); StgWord64 hs_atomic_xor64(StgWord x, StgWord64 val) { return __sync_fetch_and_xor((volatile StgWord64 *) x, val); } -#endif // CasByteArrayOp_Int @@ -309,14 +297,12 @@ hs_cmpxchg32(StgWord x, StgWord old, StgWord new) return __sync_val_compare_and_swap((volatile StgWord32 *) x, (StgWord32) old, (StgWord32) new); } -#if WORD_SIZE_IN_BITS == 64 extern StgWord hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new); StgWord hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new) { return __sync_val_compare_and_swap((volatile StgWord64 *) x, old, new); } -#endif // Atomic exchange operations ===================================== libraries/ghc-prim/cbits/longlong.c deleted ===================================== @@ -1,89 +0,0 @@ -/* ----------------------------------------------------------------------------- - * $Id: longlong.c,v 1.4 2002/12/13 14:23:42 simonmar Exp $ - * - * (c) The GHC Team, 1998-1999 - * - * Primitive operations over (64-bit) long longs - * (only used on 32-bit platforms.) - * - * ---------------------------------------------------------------------------*/ - - -/* -Miscellaneous primitive operations on HsInt64 and HsWord64s. -N.B. These are not primops! - -Instead of going the normal (boring) route of making the list -of primitive operations even longer to cope with operations -over 64-bit entities, we implement them instead 'out-of-line'. - -The primitive ops get their own routine (in C) that implements -the operation, requiring the caller to _ccall_ out. This has -performance implications of course, but we currently don't -expect intensive use of either Int64 or Word64 types. - -The exceptions to the rule are primops that cast to and from -64-bit entities (these are defined in PrimOps.h) -*/ - -#include "Rts.h" - -#if WORD_SIZE_IN_BITS < 64 - -/* Relational operators */ - -HsInt hs_gtWord64 (HsWord64 a, HsWord64 b) {return a > b;} -HsInt hs_geWord64 (HsWord64 a, HsWord64 b) {return a >= b;} -HsInt hs_eqWord64 (HsWord64 a, HsWord64 b) {return a == b;} -HsInt hs_neWord64 (HsWord64 a, HsWord64 b) {return a != b;} -HsInt hs_ltWord64 (HsWord64 a, HsWord64 b) {return a < b;} -HsInt hs_leWord64 (HsWord64 a, HsWord64 b) {return a <= b;} - -HsInt hs_gtInt64 (HsInt64 a, HsInt64 b) {return a > b;} -HsInt hs_geInt64 (HsInt64 a, HsInt64 b) {return a >= b;} -HsInt hs_eqInt64 (HsInt64 a, HsInt64 b) {return a == b;} -HsInt hs_neInt64 (HsInt64 a, HsInt64 b) {return a != b;} -HsInt hs_ltInt64 (HsInt64 a, HsInt64 b) {return a < b;} -HsInt hs_leInt64 (HsInt64 a, HsInt64 b) {return a <= b;} - -/* Arithmetic operators */ - -HsWord64 hs_remWord64 (HsWord64 a, HsWord64 b) {return a % b;} -HsWord64 hs_quotWord64 (HsWord64 a, HsWord64 b) {return a / b;} - -HsInt64 hs_remInt64 (HsInt64 a, HsInt64 b) {return a % b;} -HsInt64 hs_quotInt64 (HsInt64 a, HsInt64 b) {return a / b;} -HsInt64 hs_negateInt64 (HsInt64 a) {return -a;} -HsInt64 hs_plusInt64 (HsInt64 a, HsInt64 b) {return a + b;} -HsInt64 hs_minusInt64 (HsInt64 a, HsInt64 b) {return a - b;} -HsInt64 hs_timesInt64 (HsInt64 a, HsInt64 b) {return a * b;} - -/* Logical operators: */ - -HsWord64 hs_and64 (HsWord64 a, HsWord64 b) {return a & b;} -HsWord64 hs_or64 (HsWord64 a, HsWord64 b) {return a | b;} -HsWord64 hs_xor64 (HsWord64 a, HsWord64 b) {return a ^ b;} -HsWord64 hs_not64 (HsWord64 a) {return ~a;} - -HsWord64 hs_uncheckedShiftL64 (HsWord64 a, HsInt b) {return a << b;} -HsWord64 hs_uncheckedShiftRL64 (HsWord64 a, HsInt b) {return a >> b;} -/* Right shifting of signed quantities is not portable in C, so - the behaviour you'll get from using these primops depends - on the whatever your C compiler is doing. ToDo: fix. -- sof 8/98 -*/ -HsInt64 hs_uncheckedIShiftL64 (HsInt64 a, HsInt b) {return a << b;} -HsInt64 hs_uncheckedIShiftRA64 (HsInt64 a, HsInt b) {return a >> b;} -HsInt64 hs_uncheckedIShiftRL64 (HsInt64 a, HsInt b) - {return (HsInt64) ((HsWord64) a >> b);} - -/* Casting between longs and longer longs. -*/ - -HsInt64 hs_intToInt64 (HsInt i) {return (HsInt64) i;} -HsInt hs_int64ToInt (HsInt64 i) {return (HsInt) i;} -HsWord64 hs_int64ToWord64 (HsInt64 i) {return (HsWord64) i;} -HsWord64 hs_wordToWord64 (HsWord w) {return (HsWord64) w;} -HsWord hs_word64ToWord (HsWord64 w) {return (HsWord) w;} -HsInt64 hs_word64ToInt64 (HsWord64 w) {return (HsInt64) w;} - -#endif /* SUPPORT_LONG_LONGS */ ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -43,7 +43,6 @@ Library GHC.CString GHC.Classes GHC.Debug - GHC.IntWord64 GHC.Magic GHC.Prim.Ext GHC.Prim.Panic @@ -81,7 +80,6 @@ Library cbits/clz.c cbits/ctz.c cbits/debug.c - cbits/longlong.c cbits/pdep.c cbits/pext.c cbits/popcnt.c ===================================== rts/package.conf.in ===================================== @@ -129,45 +129,31 @@ ld-options: , "-Wl,-u,_hs_atomic_add8" , "-Wl,-u,_hs_atomic_add16" , "-Wl,-u,_hs_atomic_add32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,_hs_atomic_add64" -#endif , "-Wl,-u,_hs_atomic_sub8" , "-Wl,-u,_hs_atomic_sub16" , "-Wl,-u,_hs_atomic_sub32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,_hs_atomic_sub64" -#endif , "-Wl,-u,_hs_atomic_and8" , "-Wl,-u,_hs_atomic_and16" , "-Wl,-u,_hs_atomic_and32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,_hs_atomic_and64" -#endif , "-Wl,-u,_hs_atomic_nand8" , "-Wl,-u,_hs_atomic_nand16" , "-Wl,-u,_hs_atomic_nand32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,_hs_atomic_nand64" -#endif , "-Wl,-u,_hs_atomic_or8" , "-Wl,-u,_hs_atomic_or16" , "-Wl,-u,_hs_atomic_or32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,_hs_atomic_or64" -#endif , "-Wl,-u,_hs_atomic_xor8" , "-Wl,-u,_hs_atomic_xor16" , "-Wl,-u,_hs_atomic_xor32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,_hs_atomic_xor64" -#endif , "-Wl,-u,_hs_cmpxchg8" , "-Wl,-u,_hs_cmpxchg16" , "-Wl,-u,_hs_cmpxchg32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,_hs_cmpxchg64" -#endif , "-Wl,-u,_hs_xchg8" , "-Wl,-u,_hs_xchg16" , "-Wl,-u,_hs_xchg32" @@ -175,15 +161,11 @@ ld-options: , "-Wl,-u,_hs_atomicread8" , "-Wl,-u,_hs_atomicread16" , "-Wl,-u,_hs_atomicread32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,_hs_atomicread64" -#endif , "-Wl,-u,_hs_atomicwrite8" , "-Wl,-u,_hs_atomicwrite16" , "-Wl,-u,_hs_atomicwrite32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,_hs_atomicwrite64" -#endif #if defined(DEBUG) /* This symbol is useful in gdb, but not referred to anywhere, * so we need to force it to be included in the binary. */ @@ -238,45 +220,31 @@ ld-options: , "-Wl,-u,hs_atomic_add8" , "-Wl,-u,hs_atomic_add16" , "-Wl,-u,hs_atomic_add32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,hs_atomic_add64" -#endif , "-Wl,-u,hs_atomic_sub8" , "-Wl,-u,hs_atomic_sub16" , "-Wl,-u,hs_atomic_sub32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,hs_atomic_sub64" -#endif , "-Wl,-u,hs_atomic_and8" , "-Wl,-u,hs_atomic_and16" , "-Wl,-u,hs_atomic_and32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,hs_atomic_and64" -#endif , "-Wl,-u,hs_atomic_nand8" , "-Wl,-u,hs_atomic_nand16" , "-Wl,-u,hs_atomic_nand32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,hs_atomic_nand64" -#endif , "-Wl,-u,hs_atomic_or8" , "-Wl,-u,hs_atomic_or16" , "-Wl,-u,hs_atomic_or32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,hs_atomic_or64" -#endif , "-Wl,-u,hs_atomic_xor8" , "-Wl,-u,hs_atomic_xor16" , "-Wl,-u,hs_atomic_xor32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,hs_atomic_xor64" -#endif , "-Wl,-u,hs_cmpxchg8" , "-Wl,-u,hs_cmpxchg16" , "-Wl,-u,hs_cmpxchg32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,hs_cmpxchg64" -#endif , "-Wl,-u,hs_xchg8" , "-Wl,-u,hs_xchg16" , "-Wl,-u,hs_xchg32" @@ -284,15 +252,11 @@ ld-options: , "-Wl,-u,hs_atomicread8" , "-Wl,-u,hs_atomicread16" , "-Wl,-u,hs_atomicread32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,hs_atomicread64" -#endif , "-Wl,-u,hs_atomicwrite8" , "-Wl,-u,hs_atomicwrite16" , "-Wl,-u,hs_atomicwrite32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,hs_atomicwrite64" -#endif #if defined(DEBUG) /* This symbol is useful in gdb, but not referred to anywhere, * so we need to force it to be included in the binary. */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e03d64df48b1f26ac872a89dd20072796669504...8d5180226e68bd952da9a3a3f2ce6077fe5abce6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e03d64df48b1f26ac872a89dd20072796669504...8d5180226e68bd952da9a3a3f2ce6077fe5abce6 You're receiving 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 Jul 7 02:18:16 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 06 Jul 2020 22:18:16 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] platform backwards compat, until libraries are patched. Message-ID: <5f03db68d1843_80b3f846a0d2e3c205323f@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 7c14198c by Moritz Angermann at 2020-07-07T10:18:00+08:00 platform backwards compat, until libraries are patched. - - - - - 3 changed files: - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/mk/test.mk Changes: ===================================== testsuite/driver/testglobals.py ===================================== @@ -73,6 +73,7 @@ class TestConfig: self.no_print_summary = False # What platform are we running on? + self.platform = '' # XXX This needs to die eventually once all access to `platform` has been relinquished from the test-suite self.targetPlatform = '' self.hostPlatform = '' self.os = '' ===================================== testsuite/driver/testlib.py ===================================== @@ -508,6 +508,10 @@ def ghc_dynamic() -> bool: def fast() -> bool: return config.speed == 2 +# XXX: This needs to be removed once no remnants of platform are left. +def platform( plat: str ) -> bool: + return targetPlatform( plat ) + def targetPlatform( plat: str ) -> bool: return config.targetPlatform == plat ===================================== testsuite/mk/test.mk ===================================== @@ -267,6 +267,7 @@ endif RUNTEST_OPTS += \ --rootdir=. \ --config-file=$(CONFIG) \ + -e 'config.platform="$(TARGETPLATFORM)"' \ # XXX This needs to be removed -e 'config.targetPlatform="$(TARGETPLATFORM)"' \ -e 'config.hostPlatform="$(HOSTPLATFORM)"' \ -e 'config.os="$(TargetOS_CPP)"' \ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7c14198c5b64efd51a87d132fe562b0ef667f612 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7c14198c5b64efd51a87d132fe562b0ef667f612 You're receiving 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 Jul 7 02:49:15 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 06 Jul 2020 22:49:15 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] unbreak test.mk Message-ID: <5f03e2ab76a52_80b3f848695b13c2054973@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 1c919c36 by Moritz Angermann at 2020-07-07T10:48:56+08:00 unbreak test.mk - - - - - 1 changed file: - testsuite/mk/test.mk Changes: ===================================== testsuite/mk/test.mk ===================================== @@ -264,10 +264,12 @@ else RUNTEST_OPTS += -e config.local=True endif +# XXX config.platform needs to be removed once all libraries have been updated +# to use targetPlatform. RUNTEST_OPTS += \ --rootdir=. \ --config-file=$(CONFIG) \ - -e 'config.platform="$(TARGETPLATFORM)"' \ # XXX This needs to be removed + -e 'config.platform="$(TARGETPLATFORM)"' \ -e 'config.targetPlatform="$(TARGETPLATFORM)"' \ -e 'config.hostPlatform="$(HOSTPLATFORM)"' \ -e 'config.os="$(TargetOS_CPP)"' \ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c919c3665bdeca77cc1c09d657f1b2c77d201d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c919c3665bdeca77cc1c09d657f1b2c77d201d5 You're receiving 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 Jul 7 02:54:41 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 06 Jul 2020 22:54:41 -0400 Subject: [Git][ghc/ghc][wip/angerman/more-rtsSymbols] AArch32 symbols only on aarch32. Message-ID: <5f03e3f1c8eb2_80b3f84924c2fb02055210@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/more-rtsSymbols at Glasgow Haskell Compiler / GHC Commits: c58ea25c by Moritz Angermann at 2020-07-07T10:54:21+08:00 AArch32 symbols only on aarch32. - - - - - 1 changed file: - rts/RtsSymbols.c Changes: ===================================== rts/RtsSymbols.c ===================================== @@ -1071,7 +1071,8 @@ /* SymI_NeedsProto(__popcountti2) */ \ /* These functions return the number of bits set in a. */\ SymI_NeedsProto(__bswapsi2) \ - SymI_NeedsProto(__bswapdi2) \ + SymI_NeedsProto(__bswapdi2) +#define RTS_LIBGCC_SYMBOLS_aarch32 \ /* armv6l */\ /* TODO: should check for __ARM_EABI__ */\ SymI_NeedsProto(__aeabi_d2f) \ @@ -1142,12 +1143,12 @@ SymI_NeedsProto(__floatsitf) \ SymI_NeedsProto(__floatunsitf) -#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) +#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && defined(arm_HOST_OS) +#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 RTS_LIBGCC_SYMBOLS_aarch32 +#elif defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) #define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 #elif defined(__GNUC__) && SIZEOF_VOID_P == 8 && defined(aarch64_HOST_OS) -#define RTS_LIBGCC_SYMBOLS \ - RTS_LIBGCC_SYMBOLS_64 \ - RTS_LIBGCC_SYMBOLS_aarch64 +#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 RTS_LIBGCC_SYMBOLS_aarch64 #elif defined(__GNUC__) && SIZEOF_VOID_P == 8 #define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 #else View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c58ea25c581c8209ed774153d4aa671ef73faf86 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c58ea25c581c8209ed774153d4aa671ef73faf86 You're receiving 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 Jul 7 04:42:07 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 07 Jul 2020 00:42:07 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] default TEST_WRAPPER Message-ID: <5f03fd1ff87b_80b3f848695b13c20615b4@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 53975a99 by Moritz Angermann at 2020-07-07T12:41:50+08:00 default TEST_WRAPPER - - - - - 1 changed file: - testsuite/mk/test.mk Changes: ===================================== testsuite/mk/test.mk ===================================== @@ -27,6 +27,9 @@ RUNTESTS = $(TOP)/driver/runtests.py COMPILER = ghc CONFIG = $(TOP)/config/$(COMPILER) +# if no TEST_WRAPPER is set, use exec +TEST_WRAPPER ?= exec + ifeq "$(GhcUnregisterised)" "YES" # Otherwise C backend generates many warnings about # imcompatible proto casts for GCC's buitins: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/53975a999cb70d6290732ed885dc92a12f411acf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/53975a999cb70d6290732ed885dc92a12f411acf You're receiving 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 Jul 7 06:44:24 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 07 Jul 2020 02:44:24 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] m( Message-ID: <5f0419c8a82fe_80b3f848695b13c20693e3@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: d142e4f4 by Moritz Angermann at 2020-07-07T14:44:06+08:00 m( - - - - - 1 changed file: - testsuite/mk/test.mk Changes: ===================================== testsuite/mk/test.mk ===================================== @@ -29,6 +29,7 @@ CONFIG = $(TOP)/config/$(COMPILER) # if no TEST_WRAPPER is set, use exec TEST_WRAPPER ?= exec +export TEST_WRAPPER ifeq "$(GhcUnregisterised)" "YES" # Otherwise C backend generates many warnings about View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d142e4f43c89685e97771b79a93fc9800abeaa54 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d142e4f43c89685e97771b79a93fc9800abeaa54 You're receiving 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 Jul 7 15:13:58 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Tue, 07 Jul 2020 11:13:58 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/remove_dict_field_flag Message-ID: <5f04913673c8a_80b3f84a03bbfc82118871@gitlab.haskell.org.mail> Andreas Klebinger pushed new branch wip/andreask/remove_dict_field_flag at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/remove_dict_field_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 Tue Jul 7 17:27:32 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 07 Jul 2020 13:27:32 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 23 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f04b084ec0eb_80b3f84a03bbfc82132665@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 01067501 by Chaitanya Koparkar at 2020-07-07T13:27:06-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - d27c8bd8 by John Ericson at 2020-07-07T13:27:08-04:00 Support `timesInt2#` in LLVM backend - - - - - 78815fd7 by John Ericson at 2020-07-07T13:27:08-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 861050c2 by John Ericson at 2020-07-07T13:27:08-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 3d91b786 by John Ericson at 2020-07-07T13:27:08-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - ea1e892f by Sylvain Henry at 2020-07-07T13:27:08-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - c462f952 by Moritz Angermann at 2020-07-07T13:27:09-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 69e6698a by Moritz Angermann at 2020-07-07T13:27:09-04:00 better if guards. - - - - - 48f17014 by Moritz Angermann at 2020-07-07T13:27:09-04:00 Fix (1) - - - - - 4127601d by Moritz Angermann at 2020-07-07T13:27:09-04:00 AArch32 symbols only on aarch32. - - - - - a0185596 by Adam Sandberg Ericsson at 2020-07-07T13:27:11-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - 30ec7def by Stefan Schulze Frielinghaus at 2020-07-07T13:27:12-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - f8e47d85 by Andreas Klebinger at 2020-07-07T13:27:13-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - bc274996 by Adam Sandberg Ericsson at 2020-07-07T13:27:14-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - b48c5f2d by Adam Sandberg Ericsson at 2020-07-07T13:27:15-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 2cac580c by Adam Sandberg Ericsson at 2020-07-07T13:27:17-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 153cf880 by Ben Gamari at 2020-07-07T13:27:17-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 01c99258 by Gabor Greif at 2020-07-07T13:27:17-04:00 When running libtool, report it as such - - - - - ef66d340 by Sylvain Henry at 2020-07-07T13:27:21-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 6e9fa87d by Sylvain Henry at 2020-07-07T13:27:23-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - a5d09c4b by Sylvain Henry at 2020-07-07T13:27:23-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 72fe4277 by Sylvain Henry at 2020-07-07T13:27:24-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - ba37d315 by Krzysztof Gogolewski at 2020-07-07T13:27:28-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 30 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Data/FastString/Env.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e5ba6faf2acb86f873f70c9040c008e0b5fea747...ba37d3152c1a6843f96b1eb89994c06e43e69577 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e5ba6faf2acb86f873f70c9040c008e0b5fea747...ba37d3152c1a6843f96b1eb89994c06e43e69577 You're receiving 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 Jul 7 17:56:22 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 07 Jul 2020 13:56:22 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 22 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f04b74663b04_80b3f84924c2fb0215984c@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 30 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Unit/Types.hs - configure.ac - docs/users_guide/8.12.1-notes.rst - docs/users_guide/phases.rst - docs/users_guide/shared_libs.rst - hadrian/.gitignore - hadrian/ghci-cabal → hadrian/ghci-cabal.in - hadrian/ghci-stack → hadrian/ghci-stack.in - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Default.hs - hadrian/src/Target.hs - libraries/base/GHC/Natural.hs - libraries/base/tests/all.T - libraries/base/tests/isValidNatural.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs - libraries/ghc-bignum/src/GHC/Num/Natural.hs - libraries/ghc-prim/GHC/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba37d3152c1a6843f96b1eb89994c06e43e69577...204f3f5ddec56403bfb12e74291b3b1d14824138 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba37d3152c1a6843f96b1eb89994c06e43e69577...204f3f5ddec56403bfb12e74291b3b1d14824138 You're receiving 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 Jul 8 01:09:20 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 07 Jul 2020 21:09:20 -0400 Subject: [Git][ghc/ghc][master] 22 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f051cc011bb9_80b3f848695b13c22069d1@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 30 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Unit/Types.hs - configure.ac - docs/users_guide/8.12.1-notes.rst - docs/users_guide/phases.rst - docs/users_guide/shared_libs.rst - hadrian/.gitignore - hadrian/ghci-cabal → hadrian/ghci-cabal.in - hadrian/ghci-stack → hadrian/ghci-stack.in - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Default.hs - hadrian/src/Target.hs - libraries/base/GHC/Natural.hs - libraries/base/tests/all.T - libraries/base/tests/isValidNatural.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs - libraries/ghc-bignum/src/GHC/Num/Natural.hs - libraries/ghc-prim/GHC/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7aa6ef110d8cc6626b1cf18d85a37cbac53e2795...204f3f5ddec56403bfb12e74291b3b1d14824138 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7aa6ef110d8cc6626b1cf18d85a37cbac53e2795...204f3f5ddec56403bfb12e74291b3b1d14824138 You're receiving 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 Jul 8 05:22:04 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 08 Jul 2020 01:22:04 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 5 commits: Address Takenobu's comments Message-ID: <5f0557fc4976_80b3f84941e98a022524bf@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 41759181 by Moritz Angermann at 2020-07-08T05:18:47+00:00 Address Takenobu's comments - - - - - 4692ebf1 by Moritz Angermann at 2020-07-08T05:18:48+00:00 Fix floating points handling of NaNs - - - - - 32e76545 by Moritz Angermann at 2020-07-08T05:18:48+00:00 Add basic Graph Coloring support - - - - - 5f47aed6 by Moritz Angermann at 2020-07-08T05:18:48+00:00 Drop debug - - - - - 312e7d5e by Moritz Angermann at 2020-07-08T05:18:48+00:00 Add primops_match.cmm testsuite - - - - - 10 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - tests/compiler/cmm/primops_math.cmm Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -106,9 +106,9 @@ cmmTopCodeGen -- Thus we'll have to deal with either CmmProc ... cmmTopCodeGen cmm@(CmmProc info lab live graph) = do config <- getConfig - when (ncgVerbosity config > 1) $ do - traceM $ "-- -------------------------- cmmTopGen (CmmProc) -------------------------- --\n" - ++ showSDocUnsafe (ppr cmm) + -- do + -- traceM $ "-- -------------------------- cmmTopGen (CmmProc) -------------------------- --\n" + -- ++ showSDocUnsafe (ppr cmm) let blocks = toBlockListEntryFirst graph (nat_blocks,statics) <- mapAndUnzipM basicBlockCodeGen blocks @@ -129,9 +129,9 @@ cmmTopCodeGen cmm@(CmmProc info lab live graph) = do -- ... or CmmData. Do we want to align this? cmmTopCodeGen cmm@(CmmData sec dat) = do config <- getConfig - when (ncgVerbosity config > 1) $ do - traceM $ "-- -------------------------- cmmTopGen (CmmData) -------------------------- --\n" - ++ showSDocUnsafe (ppr cmm) + -- do + -- traceM $ "-- -------------------------- cmmTopGen (CmmData) -------------------------- --\n" + -- ++ showSDocUnsafe (ppr cmm) return [CmmData sec dat] -- no translation, we just use CmmStatic -- So we need BasicBlockCodeGen @@ -142,9 +142,9 @@ basicBlockCodeGen basicBlockCodeGen block = do config <- getConfig - when (ncgVerbosity config > 1) $ do - traceM $ "-- --------------------------- basicBlockCodeGen --------------------------- --\n" - ++ showSDocUnsafe (ppr block) + -- do + -- traceM $ "-- --------------------------- basicBlockCodeGen --------------------------- --\n" + -- ++ showSDocUnsafe (ppr block) let (_, nodes, tail) = blockSplit block id = entryLabel block stmts = blockToList nodes @@ -669,10 +669,15 @@ getRegister' config plat expr MO_F_Eq w -> floatCond w (\d x y -> toOL [ CMP x y, CSET d EQ ]) MO_F_Ne w -> floatCond w (\d x y -> toOL [ CMP x y, CSET d NE ]) - MO_F_Ge w -> floatCond w (\d x y -> toOL [ CMP x y, CSET d SGE ]) - MO_F_Le w -> floatCond w (\d x y -> toOL [ CMP x y, CSET d SLE ]) - MO_F_Gt w -> floatCond w (\d x y -> toOL [ CMP x y, CSET d SGT ]) - MO_F_Lt w -> floatCond w (\d x y -> toOL [ CMP x y, CSET d SLT ]) + -- careful with the floating point operations. + -- SLE is effectively LE or unordered (NaN) + -- SLT is the same. ULE, and ULT will not return true for NaN. + -- This is a bit counter intutive. Don't let yourself be fooled by + -- the S/U prefix for floats, it's only meaningful for integers. + MO_F_Ge w -> floatCond w (\d x y -> toOL [ CMP x y, CSET d OGE ]) + MO_F_Le w -> floatCond w (\d x y -> toOL [ CMP x y, CSET d OLE ]) -- x <= y <=> y > x + MO_F_Gt w -> floatCond w (\d x y -> toOL [ CMP x y, CSET d OGT ]) + 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 -> intOp w (\d x y -> unitOL $ AND d x y) ===================================== compiler/GHC/CmmToAsm/AArch64/Cond.hs ===================================== @@ -4,6 +4,37 @@ import GHC.Prelude import GHC.Utils.Panic +-- XXX: This appears to go a bit overboard? Maybe we should stick with what LLVM +-- settled on for fcmp? +-- false: always yields false, regardless of operands. +-- oeq: yields true if both operands are not a QNAN and op1 is equal to op2. +-- ogt: yields true if both operands are not a QNAN and op1 is greater than op2. +-- oge: yields true if both operands are not a QNAN and op1 is greater than or equal to op2. +-- olt: yields true if both operands are not a QNAN and op1 is less than op2. +-- ole: yields true if both operands are not a QNAN and op1 is less than or equal to op2. +-- one: yields true if both operands are not a QNAN and op1 is not equal to op2. +-- ord: yields true if both operands are not a QNAN. +-- ueq: yields true if either operand is a QNAN or op1 is equal to op2. +-- ugt: yields true if either operand is a QNAN or op1 is greater than op2. +-- uge: yields true if either operand is a QNAN or op1 is greater than or equal to op2. +-- ult: yields true if either operand is a QNAN or op1 is less than op2. +-- ule: yields true if either operand is a QNAN or op1 is less than or equal to op2. +-- une: yields true if either operand is a QNAN or op1 is not equal to op2. +-- uno: yields true if either operand is a QNAN. +-- true: always yields true, regardless of operands. +-- +-- LLVMs icmp knows about: +-- eq: yields true if the operands are equal, false otherwise. No sign interpretation is necessary or performed. +-- ne: yields true if the operands are unequal, false otherwise. No sign interpretation is necessary or performed. +-- ugt: interprets the operands as unsigned values and yields true if op1 is greater than op2. +-- uge: interprets the operands as unsigned values and yields true if op1 is greater than or equal to op2. +-- ult: interprets the operands as unsigned values and yields true if op1 is less than op2. +-- ule: interprets the operands as unsigned values and yields true if op1 is less than or equal to op2. +-- sgt: interprets the operands as signed values and yields true if op1 is greater than op2. +-- sge: interprets the operands as signed values and yields true if op1 is greater than or equal to op2. +-- slt: interprets the operands as signed values and yields true if op1 is less than op2. +-- sle: interprets the operands as signed values and yields true if op1 is less than or equal to op2. + data Cond = ALWAYS -- b.al | EQ -- b.eq @@ -18,6 +49,16 @@ data Cond | ULE -- b.ls | UGE -- b.hs | UGT -- b.hi + -- ordered + | OLT -- b.mi + | OLE -- b.ls + | OGE -- b.ge + | OGT -- b.gt + -- unordered + | UOLT -- b.lt + | UOLE -- b.le + | UOGE -- b.pl + | UOGT -- b.hi -- others | NEVER -- ne | VS -- oVerflow set ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -320,7 +320,10 @@ pprReg w r = case r of where ppr_reg_no :: Width -> Int -> SDoc - ppr_reg_no _ 31 = text "sp" + ppr_reg_no w 31 + | w == W64 = text "sp" + | w == W32 = test "wsp" + ppr_reg_no w i | i < 0, w == W32 = text "wzr" | i < 0, w == W64 = text "xzr" @@ -468,20 +471,26 @@ pprBcond c = text "b." <> pprCond c pprCond :: Cond -> SDoc pprCond c = case c of - ALWAYS -> text "al" - EQ -> text "eq" - NE -> text "ne" - - SLT -> text "lt" - SLE -> text "le" - SGE -> text "ge" - SGT -> text "gt" - - ULT -> text "lo" - ULE -> text "ls" - UGE -> text "hs" - UGT -> text "hi" - - NEVER -> text "ne" - VS -> text "vs" - VC -> text "vc" \ No newline at end of file + ALWAYS -> text "al" -- Always + EQ -> text "eq" -- Equal + NE -> text "ne" -- Not Equal + + SLT -> text "lt" -- Signed less than ; Less than, or unordered + SLE -> text "le" -- Signed less than or equal ; Less than or equal, or unordered + SGE -> text "ge" -- Signed greater than or equal ; Greater than or equal + SGT -> text "gt" -- Signed greater than ; Greater than + + ULT -> text "lo" -- Carry clear/ unsigned lower ; less than + ULE -> text "ls" -- Unsigned lower or same ; Less than or equal + UGE -> text "hs" -- Carry set/unsigned higher or same ; Greater than or equal, or unordered + UGT -> text "hi" -- Unsigned higher ; Greater than, or unordered + + NEVER -> text "ne" -- Never + VS -> text "vs" -- Overflow ; Unordered (at least one NaN operand) + VC -> text "vc" -- No overflow ; Not unordered + + -- Orderd variants. Respecting NaN. + OLT -> text "mi" + OLE -> text "ls" + OGE -> text "ge" + OGT -> text "gt" \ No newline at end of file ===================================== compiler/GHC/CmmToAsm/Config.hs ===================================== @@ -15,7 +15,6 @@ data NCGConfig = NCGConfig { ncgPlatform :: !Platform -- ^ Target platform , ncgProcAlignment :: !(Maybe Int) -- ^ Mandatory proc alignment , ncgDebugLevel :: !Int -- ^ Debug level - , ncgVerbosity :: !Int -- ^ Verbosity level , ncgExternalDynamicRefs :: !Bool -- ^ Generate code to link against dynamic libraries , ncgPIC :: !Bool -- ^ Enable Position-Independent Code , ncgInlineThresholdMemcpy :: !Word -- ^ If inlining `memcpy` produces less than this threshold (in pseudo-instruction unit), do it ===================================== compiler/GHC/CmmToAsm/Monad.hs ===================================== @@ -151,7 +151,6 @@ initConfig dflags = NCGConfig { ncgPlatform = targetPlatform dflags , ncgProcAlignment = cmmProcAlignment dflags , ncgDebugLevel = debugLevel dflags - , ncgVerbosity = verbosity dflags , ncgExternalDynamicRefs = gopt Opt_ExternalDynamicRefs dflags , ncgPIC = positionIndependent dflags , ncgInlineThresholdMemcpy = fromIntegral $ maxInlineMemcpyInsns dflags ===================================== compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs ===================================== @@ -115,7 +115,10 @@ trivColorable platform virtualRegSqueeze realRegSqueeze RcInteger conflicts excl ArchSPARC64 -> panic "trivColorable ArchSPARC64" ArchPPC_64 _ -> 15 ArchARM _ _ _ -> panic "trivColorable ArchARM" - ArchAArch64 -> panic "trivColorable ArchAArch64" + -- We should be able to allocate *a lot* more in princple. + -- essentially all 32 - SP, so 31, we'd trash the link reg + -- as well as the platform and all others though. + ArchAArch64 -> 18 ArchAlpha -> panic "trivColorable ArchAlpha" ArchMipseb -> panic "trivColorable ArchMipseb" ArchMipsel -> panic "trivColorable ArchMipsel" @@ -146,7 +149,10 @@ trivColorable platform virtualRegSqueeze realRegSqueeze RcFloat conflicts exclus ArchSPARC64 -> panic "trivColorable ArchSPARC64" ArchPPC_64 _ -> 0 ArchARM _ _ _ -> panic "trivColorable ArchARM" - ArchAArch64 -> panic "trivColorable ArchAArch64" + -- we can in princple address all the float regs as + -- segments. So we could have 64 Float regs. Or + -- 128 Half regs, or even 256 Byte regs. + ArchAArch64 -> 0 ArchAlpha -> panic "trivColorable ArchAlpha" ArchMipseb -> panic "trivColorable ArchMipseb" ArchMipsel -> panic "trivColorable ArchMipsel" @@ -179,7 +185,7 @@ trivColorable platform virtualRegSqueeze realRegSqueeze RcDouble conflicts exclu ArchSPARC64 -> panic "trivColorable ArchSPARC64" ArchPPC_64 _ -> 20 ArchARM _ _ _ -> panic "trivColorable ArchARM" - ArchAArch64 -> panic "trivColorable ArchAArch64" + ArchAArch64 -> 32 ArchAlpha -> panic "trivColorable ArchAlpha" ArchMipseb -> panic "trivColorable ArchMipseb" ArchMipsel -> panic "trivColorable ArchMipsel" ===================================== compiler/GHC/CmmToAsm/Reg/Linear.hs ===================================== @@ -352,7 +352,7 @@ processBlock block_live (BasicBlock id instrs) -- | Load the freeregs and current reg assignment into the RegM state -- for the basic block with this BlockId. -initBlock :: (HasCallStack, FR freeRegs) +initBlock :: FR freeRegs => BlockId -> BlockMap RegSet -> RegM freeRegs () initBlock id block_live = do platform <- getPlatform @@ -489,7 +489,7 @@ isInReg src assig | Just (InReg _) <- lookupUFM assig src = True | otherwise = False -genRaInsn :: (HasCallStack, OutputableRegConstraint freeRegs instr) +genRaInsn :: (OutputableRegConstraint freeRegs instr) => BlockMap RegSet -> [instr] -> BlockId @@ -512,33 +512,27 @@ genRaInsn block_live new_instrs block_id instr r_dying w_dying = do let real_read = nub [ rr | (RegReal rr) <- read] let virt_read = nub [ vr | (RegVirtual vr) <- read ] - config <- getConfig - when (ncgVerbosity config > 1) $ do - freeregs <- getFreeRegsR - assig <- getAssigR - - pprTraceM "genRaInsn" - ( text "block = " <+> ppr block_id - $$ text "instruction = " <+> ppr instr - $$ text "r_dying = " <+> ppr r_dying - $$ text "w_dying = " <+> ppr w_dying - $$ text "read = " <+> ppr real_read <+> ppr virt_read - $$ text "written = " <+> ppr real_written <+> ppr virt_written - $$ text "freeregs = " <+> ppr freeregs - $$ text "assign = " <+> ppr assig) -{- - $ do --} +-- do +-- freeregs <- getFreeRegsR +-- assig <- getAssigR + +-- pprTraceM "genRaInsn" +-- ( text "block = " <+> ppr block_id +-- $$ text "instruction = " <+> ppr instr +-- $$ text "r_dying = " <+> ppr r_dying +-- $$ text "w_dying = " <+> ppr w_dying +-- $$ text "read = " <+> ppr real_read <+> ppr virt_read +-- $$ text "written = " <+> ppr real_written <+> ppr virt_written +-- $$ text "freeregs = " <+> ppr freeregs +-- $$ text "assign = " <+> ppr assig) -- (a), (b) allocate real regs for all regs read by this instruction. (r_spills, r_allocd) <- allocateRegsAndSpill True{-reading-} virt_read [] [] virt_read - when (ncgVerbosity config > 1) $ do pprTraceM "ganRaInsn" (text "(c)") -- (c) save any temporaries which will be clobbered by this instruction clobber_saves <- saveClobberedTemps real_written r_dying - when (ncgVerbosity config > 1) $ do pprTraceM "ganRaInsn" (text "(d)") -- (d) Update block map for new destinations -- NB. do this before removing dead regs from the assignment, because -- these dead regs might in fact be live in the jump targets (they're @@ -553,26 +547,21 @@ genRaInsn block_live new_instrs block_id instr r_dying w_dying = do -- when (not $ null fixup_blocks) $ -- pprTrace "fixup_blocks" (ppr fixup_blocks) (return ()) - when (ncgVerbosity config > 1) $ pprTraceM "ganRaInsn" (text "(e)") -- (e) Delete all register assignments for temps which are read -- (only) and die here. Update the free register list. releaseRegs r_dying - when (ncgVerbosity config > 1) $ pprTraceM "ganRaInsn" (text "(f)") -- (f) Mark regs which are clobbered as unallocatable clobberRegs real_written - when (ncgVerbosity config > 1) $ pprTraceM "ganRaInsn" (text "(g)") -- (g) Allocate registers for temporaries *written* (only) (w_spills, w_allocd) <- allocateRegsAndSpill False{-writing-} virt_written [] [] virt_written - when (ncgVerbosity config > 1) $ pprTraceM "ganRaInsn" (text "(h)") -- (h) Release registers for temps which are written here and not -- used again. releaseRegs w_dying - when (ncgVerbosity config > 1) $ pprTraceM "ganRaInsn" (text "(i)") let -- (i) Patch the instruction patch_map @@ -589,7 +578,6 @@ genRaInsn block_live new_instrs block_id instr r_dying w_dying = do Nothing -> x Just y -> y - when (ncgVerbosity config > 1) $ do pprTraceM "ganRaInsn" (text "(j)") -- (j) free up stack slots for dead spilled regs -- TODO (can't be bothered right now) @@ -614,7 +602,7 @@ genRaInsn block_live new_instrs block_id instr r_dying w_dying = do -- ----------------------------------------------------------------------------- -- releaseRegs -releaseRegs :: (HasCallStack, FR freeRegs) => [Reg] -> RegM freeRegs () +releaseRegs :: FR freeRegs => [Reg] -> RegM freeRegs () releaseRegs regs = do platform <- getPlatform assig <- getAssigR @@ -625,7 +613,6 @@ releaseRegs regs = do -- fltRegs = frGetFreeRegs platform RcFloat free :: [RealReg] -- dblRegs = frGetFreeRegs platform RcDouble free :: [RealReg] -- allFreeRegs = gpRegs ++ fltRegs ++ dblRegs --- when (ncgVerbosity config > 1) $ do pprTraceM "releaseRegs" (text "allFreeRegs =" <+> ppr allFreeRegs) let loop assig !free [] = do setAssigR assig; setFreeRegsR free; return () -- loop assig !free (RegReal rr : rs) | rr `elem` allFreeRegs = loop assig free rs @@ -655,7 +642,7 @@ releaseRegs regs = do -- saveClobberedTemps - :: (HasCallStack, Instruction instr, FR freeRegs) + :: (Instruction instr, FR freeRegs) => [RealReg] -- real registers clobbered by this instruction -> [Reg] -- registers which are no longer live after this insn -> RegM freeRegs [instr] -- return: instructions to spill any temps that will @@ -721,7 +708,7 @@ saveClobberedTemps clobbered dying -- | Mark all these real regs as allocated, -- and kick out their vreg assignments. -- -clobberRegs :: (HasCallStack, FR freeRegs) => [RealReg] -> RegM freeRegs () +clobberRegs :: FR freeRegs => [RealReg] -> RegM freeRegs () clobberRegs [] = return () @@ -730,8 +717,6 @@ clobberRegs clobbered freeregs <- getFreeRegsR config <- getConfig - when (ncgVerbosity config > 1) $ do pprTraceM "clobberRegs" (ppr $ text "freeregs =" <+> text (show freeregs) - $$ text "clobbered =" <+> ppr clobbered) let gpRegs = frGetFreeRegs platform RcInteger freeregs :: [RealReg] fltRegs = frGetFreeRegs platform RcFloat freeregs :: [RealReg] @@ -740,11 +725,6 @@ clobberRegs clobbered let extra_clobbered = [ r | r <- clobbered , r `elem` (gpRegs ++ fltRegs ++ dblRegs) ] - when (ncgVerbosity config > 1) $ do pprTraceM "clobberRegs" (ppr $ text "gpRegs =" <+> ppr gpRegs - $$ text "fltRegs =" <+> ppr fltRegs - $$ text "dblRegs =" <+> ppr dblRegs - $$ text "filterd =" <+> ppr extra_clobbered) - setFreeRegsR $! foldl' (flip $ frAllocateReg platform) freeregs extra_clobbered -- setFreeRegsR $! foldl' (flip $ frAllocateReg platform) freeregs clobbered @@ -859,7 +839,7 @@ findPrefRealReg vreg = do -- reading is redundant with reason, but we keep it around because it's -- convenient and it maintains the recursive structure of the allocator. -- EZY -allocRegsAndSpill_spill :: (HasCallStack, FR freeRegs, Instruction instr, Outputable instr) +allocRegsAndSpill_spill :: (FR freeRegs, Instruction instr, Outputable instr) => Bool -> [VirtualReg] -> [instr] ===================================== compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs ===================================== @@ -14,11 +14,35 @@ import Data.Bits import Debug.Trace import GHC.Stack --- AArch64 has 32 64bit general purpose register x0..x31 --- AArch64 has 32 128bit floating point registers v0..v31 +-- AArch64 has 32 64bit general purpose register r0..r30, and zr/sp +-- AArch64 has 32 128bit floating point registers v0..v31 as part of the NEON +-- extension in Armv8-A. +-- +-- Armv8-A is a fundamental change to the Arm architecture. It supports the +-- 64-bit Execution state called “AArch64”, and a new 64-bit instruction set +-- “A64”. To provide compatibility with the Armv7-A (32-bit architecture) +-- instruction set, a 32-bit variant of Armv8-A “AArch32” is provided. Most of +-- existing Armv7-A code can be run in the AArch32 execution state of Armv8-A. +-- -- these can be addresses as q/d/s/h/b 0..31, or v.f[idx] -- where size is 64, 32, 16, 8, ... and the index i allows us -- to access the given part. +-- +-- History of Arm Adv SIMD +-- .---------------------------------------------------------------------------. +-- | Armv6 | Armv7-A | Armv8-A AArch64 | +-- | SIMD extension | NEON | NEON | +-- |===========================================================================| +-- | - Operates on 32-bit | - Separate reg. bank, | - Separate reg. bank, | +-- | GP ARM registers | 32x64-bit NEON regs | 32x128-bit NEON regs | +-- | - 8-bit/16-bit integer | - 8/16/32/64-bit int | - 8/16/32/64-bit int | +-- | | - Single percision fp | - Single percision fp | +-- | | | - Double precision fp | +-- | | | - Single/Double fp are | +-- | | | IEEE compliant | +-- | - 2x16-bit/4x8-bit ops | - Up to 16x8-bit ops | - Up to 16x8-bit ops | +-- | per instruction | per instruction | per instruction | +-- '---------------------------------------------------------------------------' data FreeRegs = FreeRegs !Word32 !Word32 ===================================== compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs ===================================== @@ -17,7 +17,6 @@ import GHC.Platform.Reg.Class import GHC.CmmToAsm.Config import GHC.Utils.Panic import GHC.Platform -import GHC.Stack -- ----------------------------------------------------------------------------- -- The free register set @@ -43,10 +42,10 @@ import qualified GHC.CmmToAsm.X86.Instr as X86.Instr import qualified GHC.CmmToAsm.AArch64.Instr as AArch64.Instr class Show freeRegs => FR freeRegs where - frAllocateReg :: HasCallStack => Platform -> RealReg -> freeRegs -> freeRegs - frGetFreeRegs :: HasCallStack => Platform -> RegClass -> freeRegs -> [RealReg] - frInitFreeRegs :: HasCallStack => Platform -> freeRegs - frReleaseReg :: HasCallStack => Platform -> RealReg -> freeRegs -> freeRegs + frAllocateReg :: Platform -> RealReg -> freeRegs -> freeRegs + frGetFreeRegs :: Platform -> RegClass -> freeRegs -> [RealReg] + frInitFreeRegs :: Platform -> freeRegs + frReleaseReg :: Platform -> RealReg -> freeRegs -> freeRegs instance FR X86.FreeRegs where frAllocateReg = \_ -> X86.allocateReg ===================================== tests/compiler/cmm/primops_math.cmm ===================================== @@ -104,5 +104,8 @@ main () { R3 = R1 `shra` R2; foreign "C" printf("%d shra %d => %d", R1, R2, R3); + + + foreign "C" exit(0::I64); } \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/494802169966f93fd5dcaaa9237a093b16cca7cb...312e7d5e713d901f595df7ab875b8d10f0cb63ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/494802169966f93fd5dcaaa9237a093b16cca7cb...312e7d5e713d901f595df7ab875b8d10f0cb63ad You're receiving 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 Jul 8 05:30:20 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 08 Jul 2020 01:30:20 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/angerman/fix-int-gmp Message-ID: <5f0559ece1c7a_80b3f8490174d3822532be@gitlab.haskell.org.mail> Moritz Angermann pushed new branch wip/angerman/fix-int-gmp at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/angerman/fix-int-gmp You're receiving 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 Jul 8 12:50:20 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 08 Jul 2020 08:50:20 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 2 commits: Fix -NaN for real this time. Message-ID: <5f05c10ce380b_80b3f848695b13c2289415@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 59c2bf31 by Moritz Angermann at 2020-07-08T12:14:51+00:00 Fix -NaN for real this time. - - - - - a5b00b4c by Moritz Angermann at 2020-07-08T12:21:24+00:00 Adds nan test. - - - - - 3 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - + tests/compiler/cmm/nan.cmm Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -813,10 +813,10 @@ genCondJump bid expr MO_F_Eq w -> fbcond w EQ MO_F_Ne w -> fbcond w NE - MO_F_Gt w -> fbcond w SGT - MO_F_Ge w -> fbcond w SGE - MO_F_Lt w -> fbcond w SLT - MO_F_Le w -> fbcond w SLE + MO_F_Gt w -> fbcond w OGT + MO_F_Ge w -> fbcond w OGE + MO_F_Lt w -> fbcond w OLT + MO_F_Le w -> fbcond w OLE MO_Eq w -> bcond w EQ MO_Ne w -> bcond w NE ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -322,7 +322,7 @@ pprReg w r = case r of ppr_reg_no :: Width -> Int -> SDoc ppr_reg_no w 31 | w == W64 = text "sp" - | w == W32 = test "wsp" + | w == W32 = text "wsp" ppr_reg_no w i | i < 0, w == W32 = text "wzr" ===================================== tests/compiler/cmm/nan.cmm ===================================== @@ -0,0 +1,51 @@ +// RUN: "$HC" -cpp -dcmm-lint -keep-s-file -c "$1" && cat "${1%%.*}.s" | FileCheck "$1" -check-prefix=CHECK-A64 +// RUN: "$HC" -no-hs-main "${1%%.*}.o" -o "${1%%.*}.exe" +// RUN: "$EXEC" "${1%%.cmm}.exe" | FileCheck "$1" -check-prefix=CHECK-RUN-A64 + +#include "Cmm.h" +#include "Types.h" + +// CHECK-A64: .globl main +// CHECK-A64: main: + +main () { + F64 y; + I64 z; + + D1 = 0.0 - 7.0; + + (y) = foreign "C" sqrt(D1); + + (z) = foreign "C" isDoubleNaN(y); + + // CHECK-RUN-A64: sqrt(-7.000000) = nan + // CHECK-RUN-A64: isDoubleNaN(nan) = 1 + foreign "C" printf("sqrt(%f) = %f\n", D1, y); + foreign "C" printf("isDoubleNaN(%f) = %d\n", y, z); + + // CHECK-RUN-A64: nan < 0 = 0 + foreign "C" printf("%f < 0 = %d\n", y, y `flt` 0.0); + // CHECK-RUN-A64: nan > 0 = 0 + foreign "C" printf("%f > 0 = %d\n", y, y `fgt` 0.0); + // CHECK-RUN-A64: nan <= 0 = 0 + foreign "C" printf("%f <= 0 = %d\n", y, y `fle` 0.0); + // CHECK-RUN-A64: nan >= 0 = 0 + foreign "C" printf("%f >= 0 = %d\n", y, y `fge` 0.0); + // CHECK-RUN-A64: nan == 0 = 0 + foreign "C" printf("%f == 0 = %d\n", y, y `feq` 0.0); + // CHECK-RUN-A64: nan /= 0 = 1 + foreign "C" printf("%f /= 0 = %d\n", y, y `fne` 0.0); + + F64 x; + x = 0.0; y = 0.0; + foreign "C" printf("%f / %f = %d\n", x, y, x `fquot` y); + + // CHECK-RUN-A64: nan >= 0 + if((x `fquot` y) < x) { + foreign "C" printf("%f < %f\n", x `fquot` y, x); + } else { + foreign "C" printf("%f >= %f\n", x `fquot` y, x); + } + + foreign "C" exit(0::I64); +} \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/312e7d5e713d901f595df7ab875b8d10f0cb63ad...a5b00b4cd8db15ca91ebac52554b3399d4f14d82 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/312e7d5e713d901f595df7ab875b8d10f0cb63ad...a5b00b4cd8db15ca91ebac52554b3399d4f14d82 You're receiving 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 Jul 8 13:19:21 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 08 Jul 2020 09:19:21 -0400 Subject: [Git][ghc/ghc][wip/angerman/out-of-range-reloc] 28 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f05c7d962b8f_80b3f84924c2fb02301939@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/out-of-range-reloc at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - f2c0efbd by Moritz Angermann at 2020-07-08T09:19:20-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - f367417f by Moritz Angermann at 2020-07-08T09:19:20-04:00 Cleanup - - - - - ffb0a4d9 by Moritz Angermann at 2020-07-08T09:19:20-04:00 Cleanup (2) - - - - - 1324a16d by Moritz Angermann at 2020-07-08T09:19:20-04:00 kill duplicate prot. It's an argument now. - - - - - 27d94aa8 by Moritz Angermann at 2020-07-08T09:19:20-04:00 Fixup MachO mmapForLinker call. - - - - - b7e6c894 by Moritz Angermann at 2020-07-08T09:19:20-04:00 Drop aarch64_target check from rts/Linker.c - - - - - 30 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Unit/Types.hs - configure.ac - docs/users_guide/8.12.1-notes.rst - docs/users_guide/phases.rst - docs/users_guide/shared_libs.rst - hadrian/.gitignore - hadrian/ghci-cabal → hadrian/ghci-cabal.in - hadrian/ghci-stack → hadrian/ghci-stack.in - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Default.hs - hadrian/src/Target.hs - libraries/base/GHC/Natural.hs - libraries/base/tests/all.T - libraries/base/tests/isValidNatural.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs - libraries/ghc-bignum/src/GHC/Num/Natural.hs - libraries/ghc-prim/GHC/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b91af6d1ae1e8cd27121b34430796aa298164ecf...b7e6c894a23ce937151c68a83b48740b6f385808 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b91af6d1ae1e8cd27121b34430796aa298164ecf...b7e6c894a23ce937151c68a83b48740b6f385808 You're receiving 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 Jul 8 13:21:58 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 08 Jul 2020 09:21:58 -0400 Subject: [Git][ghc/ghc][wip/angerman/fix-int-gmp] fix gmp selection Message-ID: <5f05c876a0a5a_80b3f84924c14f82302351@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/fix-int-gmp at Glasgow Haskell Compiler / GHC Commits: d4bc3c0e by Moritz Angermann at 2020-07-08T21:21:19+08:00 fix gmp selection - - - - - 1 changed file: - libraries/ghc-bignum/gmp/ghc.mk Changes: ===================================== libraries/ghc-bignum/gmp/ghc.mk ===================================== @@ -77,11 +77,13 @@ endif endif UseIntreeGmp = NO +ifeq "$(GMP_ENABLED)" "YES" ifneq "$(HaveLibGmp)" "YES" ifneq "$(HaveFrameworkGMP)" "YES" UseIntreeGmp = YES endif endif +endif # gmp_wrappers.c includes "ghc-gmp.h" libraries/ghc-bignum/cbits/gmp_wrappers.c: libraries/ghc-bignum/include/ghc-gmp.h View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d4bc3c0eaf345a3ff020fa71ee97c6e8546a33a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d4bc3c0eaf345a3ff020fa71ee97c6e8546a33a8 You're receiving 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 Jul 8 13:51:30 2020 From: gitlab at gitlab.haskell.org (John Ericson) Date: Wed, 08 Jul 2020 09:51:30 -0400 Subject: [Git][ghc/ghc][wip/int64-everywhere] 24 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f05cf627620c_80b3f8496a302dc2310652@gitlab.haskell.org.mail> John Ericson pushed to branch wip/int64-everywhere at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 1c8c433e by John Ericson at 2020-07-08T09:49:18-04:00 Make fixed-size `Int32#` and `Int64#` The boxed Int64 uses Int64#, but Int32# still uses Int#. The 32-bit case is less pressing to change because it is not a source of brittle CPP---it is the same thing on all platforms. We need Int64/Word64 constant folding to avoid the let/app restriction on Core, so that is implemented now. 32-bit constant unfolding and 32-bit literals are left as follow-up. This is the bulk of #11953 - - - - - 7ce44c8d by John Ericson at 2020-07-08T09:49:18-04:00 Inline INT64 and WORD64 macros in primops.txt.pp The definition is now unconditional so there is no reason for that CPP. - - - - - 27 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Match/Literal.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Unit/Types.hs - compiler/GHC/Utils/Outputable.hs - configure.ac - docs/users_guide/8.12.1-notes.rst - docs/users_guide/phases.rst - docs/users_guide/shared_libs.rst - hadrian/.gitignore - hadrian/ghci-cabal → hadrian/ghci-cabal.in - hadrian/ghci-stack → hadrian/ghci-stack.in - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/Cabal.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8d5180226e68bd952da9a3a3f2ce6077fe5abce6...7ce44c8d42151401dac9bf1bd86789bb86f3d10b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8d5180226e68bd952da9a3a3f2ce6077fe5abce6...7ce44c8d42151401dac9bf1bd86789bb86f3d10b You're receiving 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 Jul 8 14:45:49 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 08 Jul 2020 10:45:49 -0400 Subject: [Git][ghc/ghc][wip/backports] Add "-Iw" RTS flag for minimum wait between idle GCs (#11134) Message-ID: <5f05dc1d9f35b_80b3f84924c14f82317011@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: 04dce498 by Kevin Buhr at 2020-07-08T10:45:43-04:00 Add "-Iw" RTS flag for minimum wait between idle GCs (#11134) This wasn't originally slated for 8.10 but the documentation part of this patch snuck into the ghc-8.10 branch via a backport. Instead of backing out the documentation and causing further user confusion I've opted just to backport this functional change as well. (cherry picked from commit 859ebdd446eda446d38708a587503c255b58c4c6) - - - - - 3 changed files: - includes/rts/Flags.h - rts/RtsFlags.c - rts/Timer.c Changes: ===================================== includes/rts/Flags.h ===================================== @@ -66,6 +66,7 @@ typedef struct _GC_FLAGS { bool ringBell; Time idleGCDelayTime; /* units: TIME_RESOLUTION */ + Time interIdleGCWait; /* units: TIME_RESOLUTION */ bool doIdleGC; Time longGCSync; /* units: TIME_RESOLUTION */ ===================================== rts/RtsFlags.c ===================================== @@ -164,6 +164,7 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.compactThreshold = 30.0; RtsFlags.GcFlags.sweep = false; RtsFlags.GcFlags.idleGCDelayTime = USToTime(300000); // 300ms + RtsFlags.GcFlags.interIdleGCWait = 0; #if defined(THREADED_RTS) RtsFlags.GcFlags.doIdleGC = true; #else @@ -1180,19 +1181,33 @@ error = true; break; case 'I': /* idle GC delay */ - OPTION_UNSAFE; - if (rts_argv[arg][2] == '\0') { - /* use default */ - } else { - Time t = fsecondsToTime(atof(rts_argv[arg]+2)); - if (t == 0) { - RtsFlags.GcFlags.doIdleGC = false; - } else { - RtsFlags.GcFlags.doIdleGC = true; - RtsFlags.GcFlags.idleGCDelayTime = t; - } - } - break; + OPTION_UNSAFE; + switch (rts_argv[arg][2]) { + /* minimum inter-idle GC wait time */ + case 'w': + if (rts_argv[arg][3] == '\0') { + /* use default */ + } else { + RtsFlags.GcFlags.interIdleGCWait = fsecondsToTime(atof(rts_argv[arg]+3)); + } + break; + /* idle delay before GC */ + case '\0': + /* use default */ + break; + default: + { + Time t = fsecondsToTime(atof(rts_argv[arg]+2)); + if (t == 0) { + RtsFlags.GcFlags.doIdleGC = false; + } else { + RtsFlags.GcFlags.doIdleGC = true; + RtsFlags.GcFlags.idleGCDelayTime = t; + } + } + break; + } + break; case 'T': OPTION_SAFE; ===================================== rts/Timer.c ===================================== @@ -28,8 +28,11 @@ /* ticks left before next pre-emptive context switch */ static int ticks_to_ctxt_switch = 0; -/* idle ticks left before we perform a GC */ -static int ticks_to_gc = 0; +/* idle ticks left before GC allowed */ +static int idle_ticks_to_gc = 0; + +/* inter-idle GC ticks left before GC allowed */ +static int inter_gc_ticks_to_gc = 0; /* * Function: handle_tick() @@ -53,18 +56,21 @@ handle_tick(int unused STG_UNUSED) /* * If we've been inactive for idleGCDelayTime (set by +RTS * -I), tell the scheduler to wake up and do a GC, to check - * for threads that are deadlocked. + * for threads that are deadlocked. However, ensure we wait + * at least interIdleGCWait (+RTS -Iw) between idle GCs. */ switch (recent_activity) { case ACTIVITY_YES: recent_activity = ACTIVITY_MAYBE_NO; - ticks_to_gc = RtsFlags.GcFlags.idleGCDelayTime / - RtsFlags.MiscFlags.tickInterval; + idle_ticks_to_gc = RtsFlags.GcFlags.idleGCDelayTime / + RtsFlags.MiscFlags.tickInterval; break; case ACTIVITY_MAYBE_NO: - if (ticks_to_gc == 0) { + if (idle_ticks_to_gc == 0 && inter_gc_ticks_to_gc == 0) { if (RtsFlags.GcFlags.doIdleGC) { recent_activity = ACTIVITY_INACTIVE; + inter_gc_ticks_to_gc = RtsFlags.GcFlags.interIdleGCWait / + RtsFlags.MiscFlags.tickInterval; #if defined(THREADED_RTS) wakeUpRts(); // The scheduler will call stopTimer() when it has done @@ -86,7 +92,8 @@ handle_tick(int unused STG_UNUSED) #endif } } else { - ticks_to_gc--; + if (idle_ticks_to_gc) idle_ticks_to_gc--; + if (inter_gc_ticks_to_gc) inter_gc_ticks_to_gc--; } break; default: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04dce49825c5124d942846902d97b42c33ca26e7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04dce49825c5124d942846902d97b42c33ca26e7 You're receiving 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 Jul 8 15:38:14 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 08 Jul 2020 11:38:14 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] 8 commits: Bump bytestring submodule Message-ID: <5f05e86685fe2_80b3f84955fd7ec23334fa@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: a0c5ab3f by GHC GitLab CI at 2020-07-04T14:19:15+00:00 Bump bytestring submodule - - - - - 3475384d by GHC GitLab CI at 2020-07-04T14:19:33+00:00 Bump Cabal submodule - - - - - b12faad0 by GHC GitLab CI at 2020-07-04T15:19:25+00:00 Bump to 8.8.4, RELEASE=YES - - - - - ac697a44 by Ben Gamari at 2020-07-06T12:15:24-04:00 gitlab-ci: Reintroduce workflow stanza - - - - - fc1bd787 by Moritz Angermann at 2020-07-08T11:22:36-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf (cherry picked from commit 4a158ffc4e0ac250897aefaf6caf03eb5f688182) - - - - - 1f2a440a by Moritz Angermann at 2020-07-08T11:26:40-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. (cherry picked from commit 3fd12af1eaafe304e5916bc1fcfdf31709d360b8) - - - - - ade1b738 by Travis Whitaker at 2020-07-08T11:34:57-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. (cherry picked from commit 67738db10010fd28a8e997b5c8f83ea591b88a0e) - - - - - 2900ab4f by Moritz Angermann at 2020-07-08T11:37:55-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. (cherry picked from commit b455074875d3c8fd3a5787e01dc6f922f3a97bc2) - - - - - 12 changed files: - .gitlab-ci.yml - compiler/ghc.mk - configure.ac - ghc/ghc.mk - hadrian/cfg/system.config.in - hadrian/src/Expression.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-prim/ghc-prim.cabal - mk/config.mk.in - rts/linker/LoadArchive.c - rts/linker/elf_reloc_aarch64.c Changes: ===================================== .gitlab-ci.yml ===================================== @@ -32,6 +32,15 @@ stages: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' +workflow: + # N.B. Don't run on wip/ branches, instead on run on merge requests. + rules: + - if: $CI_MERGE_REQUEST_ID + - if: $CI_COMMIT_TAG + - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + - if: '$CI_PIPELINE_SOURCE == "web"' + ############################################################ # Runner Tags ############################################################ ===================================== compiler/ghc.mk ===================================== @@ -326,6 +326,12 @@ ifeq "$(GhcThreaded)" "YES" compiler_stage2_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS endif +# If the bootstrapping GHC supplies the threaded RTS, then we can have a +# threaded stage 1 too. +ifeq "$(GhcThreadedRts)" "YES" +compiler_stage1_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS +endif + ifeq "$(GhcWithNativeCodeGen)" "YES" compiler_stage1_CONFIGURE_OPTS += --flags=ncg compiler_stage2_CONFIGURE_OPTS += --flags=ncg ===================================== configure.ac ===================================== @@ -13,10 +13,10 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.3], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.4], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # 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 @@ -127,6 +127,9 @@ dnl CC_STAGE0 is like the "previous" variable CC (inherited by CC_STAGE[123]) dnl but instead used by stage0 for bootstrapping stage1 AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)]) +dnl RTS ways supplied by the bootstrapping compiler. +AC_ARG_VAR(RTS_WAYS_STAGE0, [RTS ways]) + if test "$WithGhc" != ""; then FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl @@ -150,6 +153,17 @@ if test "$WithGhc" != ""; then BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command]) BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) + BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) + + dnl Check whether or not the bootstrapping GHC has a threaded RTS. This + dnl determines whether or not we can have a threaded stage 1. + dnl See Note [Linking ghc-bin against threaded stage0 RTS] in + dnl hadrian/src/Settings/Packages.hs for details. + if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null; then + AC_SUBST(GhcThreadedRts, YES) + else + AC_SUBST(GhcThreadedRts, NO) + fi fi dnl ** Must have GHC to build GHC @@ -1372,6 +1386,7 @@ Configure completed successfully. echo "\ Bootstrapping using : $WithGhc which is version : $GhcVersion + with threaded RTS? : $GhcThreadedRts " if test "x$CC_LLVM_BACKEND" = "x1"; then ===================================== ghc/ghc.mk ===================================== @@ -63,6 +63,13 @@ ghc_stage2_MORE_HC_OPTS += -threaded ghc_stage3_MORE_HC_OPTS += -threaded endif +# If stage 0 supplies a threaded RTS, we can use it for stage 1. +# See Note [Linking ghc-bin against threaded stage0 RTS] in +# hadrian/src/Settings/Packages.hs for details. +ifeq "$(GhcThreadedRts)" "YES" +ghc_stage1_MORE_HC_OPTS += -threaded +endif + ifeq "$(GhcProfiled)" "YES" ghc_stage2_PROGRAM_WAY = p endif @@ -120,16 +127,11 @@ ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(compiler_stage2_p_LIB) ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_p_LIB)) endif -# Modules here import HsVersions.h, so we need ghc_boot_platform.h -$(ghc_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H) -$(ghc_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H) -$(ghc_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H) - all_ghc_stage1 : $(GHC_STAGE1) all_ghc_stage2 : $(GHC_STAGE2) all_ghc_stage3 : $(GHC_STAGE3) -$(INPLACE_LIB)/settings : settings +$(INPLACE_LIB)/settings : $(includes_SETTINGS) "$(CP)" $< $@ $(INPLACE_LIB)/llvm-targets : llvm-targets @@ -154,12 +156,6 @@ $(GHC_STAGE1) : | $(GHC_DEPENDENCIES) $(GHC_STAGE2) : | $(GHC_DEPENDENCIES) $(GHC_STAGE3) : | $(GHC_DEPENDENCIES) -ifeq "$(GhcUnregisterised)" "NO" -$(GHC_STAGE1) : | $$(ghc-split_INPLACE) -$(GHC_STAGE2) : | $$(ghc-split_INPLACE) -$(GHC_STAGE3) : | $$(ghc-split_INPLACE) -endif - ifeq "$(Windows_Host)" "YES" $(GHC_STAGE1) : | $$(touchy_INPLACE) $(GHC_STAGE2) : | $$(touchy_INPLACE) @@ -174,7 +170,7 @@ $(GHC_STAGE2) : $(foreach w,$(GhcLibWays),libraries/base/dist-install/build/GHC/ endif -INSTALL_LIBS += settings +INSTALL_LIBS += $(includes_SETTINGS) INSTALL_LIBS += llvm-targets INSTALL_LIBS += llvm-passes ===================================== hadrian/cfg/system.config.in ===================================== @@ -77,6 +77,8 @@ ghc-major-version = @GhcMajVersion@ ghc-minor-version = @GhcMinVersion@ ghc-patch-level = @GhcPatchLevel@ +bootstrap-threaded-rts = @GhcThreadedRts@ + supports-this-unit-id = @SUPPORTS_THIS_UNIT_ID@ project-name = @ProjectName@ ===================================== hadrian/src/Expression.hs ===================================== @@ -26,6 +26,7 @@ import Base import Builder import Context hiding (stage, package, way) import Expression.Type +import Oracles.Flag import Hadrian.Expression hiding (Expr, Predicate, Args) import Hadrian.Haskell.Cabal.Type import Hadrian.Oracles.Cabal @@ -99,6 +100,13 @@ stage2 = stage Stage2 notStage0 :: Predicate notStage0 = notM stage0 +-- | Whether or not the bootstrapping compiler provides a threaded RTS. We need +-- to know this when building stage 1, since stage 1 links against the +-- compiler's RTS ways. See Note [Linking ghc-bin against threaded stage0 RTS] +-- in Settings.Packages for details. +threadedBootstrapper :: Predicate +threadedBootstrapper = expr (flag BootstrapThreadedRts) + -- | Is a certain package /not/ built right now? notPackage :: Package -> Predicate notPackage = notM . package ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -21,6 +21,7 @@ data Flag = ArSupportsAtFile | WithLibdw | HaveLibMingwEx | UseSystemFfi + | BootstrapThreadedRts -- Note, if a flag is set to empty string we treat it as set to NO. This seems -- fragile, but some flags do behave like this, e.g. GccIsClang. @@ -39,6 +40,7 @@ flag f = do WithLibdw -> "with-libdw" HaveLibMingwEx -> "have-lib-mingw-ex" UseSystemFfi -> "use-system-ffi" + BootstrapThreadedRts -> "bootstrap-threaded-rts" value <- lookupValueOrError configFile key when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag " ++ quote (key ++ " = " ++ value) ++ " cannot be parsed." ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -53,10 +53,15 @@ packageArgs = do , arg "--disable-library-for-ghci" , anyTargetOs ["openbsd"] ? arg "--ld-options=-E" , flag GhcUnregisterised ? arg "--ghc-option=-DNO_REGS" - , notM ghcWithSMP ? arg "--ghc-option=-DNOSMP" - , notM ghcWithSMP ? arg "--ghc-option=-optc-DNOSMP" + , notM targetSupportsSMP ? arg "--ghc-option=-DNOSMP" + , notM targetSupportsSMP ? arg "--ghc-option=-optc-DNOSMP" + -- When building stage 1 or later, use thread-safe RTS functions if + -- the configuration calls for a threaded GHC. , (any (wayUnit Threaded) rtsWays) ? notStage0 ? arg "--ghc-option=-optc-DTHREADED_RTS" + -- When building stage 1, use thread-safe RTS functions if the + -- bootstrapping (stage 0) compiler provides a threaded RTS way. + , stage0 ? threadedBootstrapper ? arg "--ghc-option=-optc-DTHREADED_RTS" , ghcWithInterpreter ? ghcEnableTablesNextToCode ? notM (flag GhcUnregisterised) ? @@ -85,10 +90,27 @@ packageArgs = do , builder (Cabal Flags) ? mconcat [ ghcWithInterpreter ? notStage0 ? arg "ghci" , flag CrossCompiling ? arg "-terminfo" - -- the 'threaded' flag is True by default, but - -- let's record explicitly that we link all ghc - -- executables with the threaded runtime. - , arg "threaded" ] ] + -- Note [Linking ghc-bin against threaded stage0 RTS] + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- We must maintain the invariant that GHCs linked with '-threaded' + -- are built with '-optc=-DTHREADED_RTS', otherwise we'll end up + -- with a GHC that can use the threaded runtime, but contains some + -- non-thread-safe functions. See + -- https://gitlab.haskell.org/ghc/ghc/issues/18024 for an example of + -- the sort of issues this can cause. + , ifM stage0 + -- We build a threaded stage 1 if the bootstrapping compiler + -- supports it. + (ifM threadedBootstrapper + (arg "threaded") + (arg "-threaded")) + -- We build a threaded stage N, N>1 if the configuration calls + -- for it. + (ifM (ghcThreaded <$> expr flavour) + (arg "threaded") + (arg "-threaded")) + ] + ] -------------------------------- ghcPkg -------------------------------- , package ghcPkg ? ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -66,6 +66,11 @@ Library -- on Windows. Required because of mingw32. extra-libraries: user32, mingw32, mingwex + if os(linux) + -- we need libm, but for musl and other's we might need libc, as libm + -- is just an empty shell. + extra-libraries: c, m + c-sources: cbits/atomic.c cbits/bswap.c ===================================== mk/config.mk.in ===================================== @@ -199,6 +199,9 @@ endif # `GhcUnregisterised` mode doesn't allow that. GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO)) +# Whether or not the bootstrapping GHC supplies a threaded RTS. +GhcThreadedRts = @GhcThreadedRts@ + # Whether to include GHCi in the compiler. Depends on whether the RTS linker # has support for this OS/ARCH combination. ===================================== rts/linker/LoadArchive.c ===================================== @@ -461,6 +461,7 @@ static HsInt loadArchive_ (pathchar *path) /* TODO: Stop relying on file extensions to determine input formats. Instead try to match file headers. See Trac #13103. */ isObject = (thisFileNameSize >= 2 && strncmp(fileName + thisFileNameSize - 2, ".o" , 2) == 0) + || (thisFileNameSize >= 3 && strncmp(fileName + thisFileNameSize - 3, ".lo" , 3) == 0) || (thisFileNameSize >= 4 && strncmp(fileName + thisFileNameSize - 4, ".p_o", 4) == 0) || (thisFileNameSize >= 4 && strncmp(fileName + thisFileNameSize - 4, ".obj", 4) == 0); ===================================== rts/linker/elf_reloc_aarch64.c ===================================== @@ -90,12 +90,14 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) { // ... hi ] [ Rd ] // // imm64 = SignExtend(hi:lo:0x000,64) - assert(isInt64(32, addend)); + // Range is 21 bits + the 12 page relative bits + // known to be 0. -2^32 <= X < 2^32 + assert(isInt64(21+12, addend)); assert((addend & 0xfff) == 0); /* page relative */ *(inst_t *)P = (*(inst_t *)P & 0x9f00001f) - | (inst_t) (((uint64_t) addend << 17) & 0x60000000) - | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0); + | (inst_t) (((uint64_t) addend << 17) & 0x60000000) + | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0); break; } /* - control flow relocations */ @@ -108,8 +110,8 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) { break; } case COMPAT_R_AARCH64_ADR_GOT_PAGE: { - - assert(isInt64(32, addend)); /* X in range */ + /* range is -2^32 <= X < 2^32 */ + assert(isInt64(21+12, addend)); /* X in range */ assert((addend & 0xfff) == 0); /* page relative */ *(inst_t *)P = (*(inst_t *)P & 0x9f00001f) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/88262e192e69fc71916d47cbdbd8bb7c9a8f1782...2900ab4fd9118d542a3ccac830fdce046288d71f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/88262e192e69fc71916d47cbdbd8bb7c9a8f1782...2900ab4fd9118d542a3ccac830fdce046288d71f You're receiving 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 Jul 8 15:53:57 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 08 Jul 2020 11:53:57 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] 9 commits: Revert "Bump to 8.8.4, RELEASE=YES" Message-ID: <5f05ec15592f7_80b3f849ba1b94023458a5@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 31e2bfbf by Ben Gamari at 2020-07-08T11:53:43-04:00 Revert "Bump to 8.8.4, RELEASE=YES" This reverts commit b12faad0ad27b56cfc35ac1faef448b6f2245734. - - - - - 8eb55fc9 by Moritz Angermann at 2020-07-08T11:53:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf (cherry picked from commit 4a158ffc4e0ac250897aefaf6caf03eb5f688182) - - - - - 146ef07e by Moritz Angermann at 2020-07-08T11:53:43-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. (cherry picked from commit 3fd12af1eaafe304e5916bc1fcfdf31709d360b8) - - - - - 53c82980 by Travis Whitaker at 2020-07-08T11:53:43-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. (cherry picked from commit 67738db10010fd28a8e997b5c8f83ea591b88a0e) - - - - - f4161d07 by Moritz Angermann at 2020-07-08T11:53:43-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. (cherry picked from commit b455074875d3c8fd3a5787e01dc6f922f3a97bc2) - - - - - 23f233ab by Artem Pelenitsyn at 2020-07-08T11:53:43-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. (cherry picked from commit af5e3a885ddd09dd5f550552c535af3661ff3dbf) - - - - - 797766f1 by Ryan Scott at 2020-07-08T11:53:43-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. (cherry picked from commit 66bd24d197251b9907cbffba3d5d8a3f5e3c2e80) - - - - - 6115e5c2 by Ben Gamari at 2020-07-08T11:53:43-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 (cherry picked from commit c00c81a507d31b6d51e89f00d1e4c83f71c7d382) - - - - - 30a56132 by GHC GitLab CI at 2020-07-08T11:53:48-04:00 Bump to 8.8.4, RELEASE=YES - - - - - 22 changed files: - compiler/ghc.mk - compiler/prelude/PrelNames.hs - compiler/prelude/TysWiredIn.hs - configure.ac - ghc/ghc.mk - hadrian/cfg/system.config.in - hadrian/src/Expression.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Packages.hs - libraries/Cabal - libraries/base/GHC/Float.hs - libraries/bytestring - + libraries/ghc-compact/tests/T16992.hs - + libraries/ghc-compact/tests/T16992.stdout - libraries/ghc-compact/tests/all.T - libraries/ghc-prim/ghc-prim.cabal - mk/config.mk.in - rts/linker/LoadArchive.c - rts/linker/elf_reloc_aarch64.c - rts/sm/CNF.c - + testsuite/tests/typecheck/should_compile/T18185.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/ghc.mk ===================================== @@ -326,6 +326,12 @@ ifeq "$(GhcThreaded)" "YES" compiler_stage2_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS endif +# If the bootstrapping GHC supplies the threaded RTS, then we can have a +# threaded stage 1 too. +ifeq "$(GhcThreadedRts)" "YES" +compiler_stage1_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS +endif + ifeq "$(GhcWithNativeCodeGen)" "YES" compiler_stage1_CONFIGURE_OPTS += --flags=ncg compiler_stage2_CONFIGURE_OPTS += --flags=ncg ===================================== compiler/prelude/PrelNames.hs ===================================== @@ -420,10 +420,6 @@ basicKnownKeyNames -- Annotation type checking toAnnotationWrapperName - -- The Ordering type - , orderingTyConName - , ordLTDataConName, ordEQDataConName, ordGTDataConName - -- The SPEC type for SpecConstr , specTyConName ===================================== compiler/prelude/TysWiredIn.hs ===================================== @@ -197,8 +197,11 @@ names in PrelNames, so they use wTcQual, wDataQual, etc -- that occurs in this list that name will be assigned the wired-in key we -- define here. -- --- Because of their infinite nature, this list excludes tuples, Any and implicit --- parameter TyCons (see Note [Built-in syntax and the OrigNameCache]). +-- Because of their infinite nature, this list excludes +-- * tuples, including boxed, unboxed and constraint tuples +--- (mkTupleTyCon, unitTyCon, pairTyCon) +-- * unboxed sums (sumTyCon) +-- See Note [Infinite families of known-key names] in GHC.Builtin.Names -- -- See also Note [Known-key names] wiredInTyCons :: [TyCon] @@ -219,6 +222,7 @@ wiredInTyCons = [ -- Units are not treated like other tuples, because then , wordTyCon , word8TyCon , listTyCon + , orderingTyCon , maybeTyCon , heqTyCon , eqTyCon ===================================== configure.ac ===================================== @@ -127,6 +127,9 @@ dnl CC_STAGE0 is like the "previous" variable CC (inherited by CC_STAGE[123]) dnl but instead used by stage0 for bootstrapping stage1 AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)]) +dnl RTS ways supplied by the bootstrapping compiler. +AC_ARG_VAR(RTS_WAYS_STAGE0, [RTS ways]) + if test "$WithGhc" != ""; then FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl @@ -150,6 +153,17 @@ if test "$WithGhc" != ""; then BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command]) BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) + BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) + + dnl Check whether or not the bootstrapping GHC has a threaded RTS. This + dnl determines whether or not we can have a threaded stage 1. + dnl See Note [Linking ghc-bin against threaded stage0 RTS] in + dnl hadrian/src/Settings/Packages.hs for details. + if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null; then + AC_SUBST(GhcThreadedRts, YES) + else + AC_SUBST(GhcThreadedRts, NO) + fi fi dnl ** Must have GHC to build GHC @@ -1372,6 +1386,7 @@ Configure completed successfully. echo "\ Bootstrapping using : $WithGhc which is version : $GhcVersion + with threaded RTS? : $GhcThreadedRts " if test "x$CC_LLVM_BACKEND" = "x1"; then ===================================== ghc/ghc.mk ===================================== @@ -63,6 +63,13 @@ ghc_stage2_MORE_HC_OPTS += -threaded ghc_stage3_MORE_HC_OPTS += -threaded endif +# If stage 0 supplies a threaded RTS, we can use it for stage 1. +# See Note [Linking ghc-bin against threaded stage0 RTS] in +# hadrian/src/Settings/Packages.hs for details. +ifeq "$(GhcThreadedRts)" "YES" +ghc_stage1_MORE_HC_OPTS += -threaded +endif + ifeq "$(GhcProfiled)" "YES" ghc_stage2_PROGRAM_WAY = p endif @@ -120,16 +127,11 @@ ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(compiler_stage2_p_LIB) ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_p_LIB)) endif -# Modules here import HsVersions.h, so we need ghc_boot_platform.h -$(ghc_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H) -$(ghc_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H) -$(ghc_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H) - all_ghc_stage1 : $(GHC_STAGE1) all_ghc_stage2 : $(GHC_STAGE2) all_ghc_stage3 : $(GHC_STAGE3) -$(INPLACE_LIB)/settings : settings +$(INPLACE_LIB)/settings : $(includes_SETTINGS) "$(CP)" $< $@ $(INPLACE_LIB)/llvm-targets : llvm-targets @@ -154,12 +156,6 @@ $(GHC_STAGE1) : | $(GHC_DEPENDENCIES) $(GHC_STAGE2) : | $(GHC_DEPENDENCIES) $(GHC_STAGE3) : | $(GHC_DEPENDENCIES) -ifeq "$(GhcUnregisterised)" "NO" -$(GHC_STAGE1) : | $$(ghc-split_INPLACE) -$(GHC_STAGE2) : | $$(ghc-split_INPLACE) -$(GHC_STAGE3) : | $$(ghc-split_INPLACE) -endif - ifeq "$(Windows_Host)" "YES" $(GHC_STAGE1) : | $$(touchy_INPLACE) $(GHC_STAGE2) : | $$(touchy_INPLACE) @@ -174,7 +170,7 @@ $(GHC_STAGE2) : $(foreach w,$(GhcLibWays),libraries/base/dist-install/build/GHC/ endif -INSTALL_LIBS += settings +INSTALL_LIBS += $(includes_SETTINGS) INSTALL_LIBS += llvm-targets INSTALL_LIBS += llvm-passes ===================================== hadrian/cfg/system.config.in ===================================== @@ -77,6 +77,8 @@ ghc-major-version = @GhcMajVersion@ ghc-minor-version = @GhcMinVersion@ ghc-patch-level = @GhcPatchLevel@ +bootstrap-threaded-rts = @GhcThreadedRts@ + supports-this-unit-id = @SUPPORTS_THIS_UNIT_ID@ project-name = @ProjectName@ ===================================== hadrian/src/Expression.hs ===================================== @@ -26,6 +26,7 @@ import Base import Builder import Context hiding (stage, package, way) import Expression.Type +import Oracles.Flag import Hadrian.Expression hiding (Expr, Predicate, Args) import Hadrian.Haskell.Cabal.Type import Hadrian.Oracles.Cabal @@ -99,6 +100,13 @@ stage2 = stage Stage2 notStage0 :: Predicate notStage0 = notM stage0 +-- | Whether or not the bootstrapping compiler provides a threaded RTS. We need +-- to know this when building stage 1, since stage 1 links against the +-- compiler's RTS ways. See Note [Linking ghc-bin against threaded stage0 RTS] +-- in Settings.Packages for details. +threadedBootstrapper :: Predicate +threadedBootstrapper = expr (flag BootstrapThreadedRts) + -- | Is a certain package /not/ built right now? notPackage :: Package -> Predicate notPackage = notM . package ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -21,6 +21,7 @@ data Flag = ArSupportsAtFile | WithLibdw | HaveLibMingwEx | UseSystemFfi + | BootstrapThreadedRts -- Note, if a flag is set to empty string we treat it as set to NO. This seems -- fragile, but some flags do behave like this, e.g. GccIsClang. @@ -39,6 +40,7 @@ flag f = do WithLibdw -> "with-libdw" HaveLibMingwEx -> "have-lib-mingw-ex" UseSystemFfi -> "use-system-ffi" + BootstrapThreadedRts -> "bootstrap-threaded-rts" value <- lookupValueOrError configFile key when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag " ++ quote (key ++ " = " ++ value) ++ " cannot be parsed." ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -53,10 +53,15 @@ packageArgs = do , arg "--disable-library-for-ghci" , anyTargetOs ["openbsd"] ? arg "--ld-options=-E" , flag GhcUnregisterised ? arg "--ghc-option=-DNO_REGS" - , notM ghcWithSMP ? arg "--ghc-option=-DNOSMP" - , notM ghcWithSMP ? arg "--ghc-option=-optc-DNOSMP" + , notM targetSupportsSMP ? arg "--ghc-option=-DNOSMP" + , notM targetSupportsSMP ? arg "--ghc-option=-optc-DNOSMP" + -- When building stage 1 or later, use thread-safe RTS functions if + -- the configuration calls for a threaded GHC. , (any (wayUnit Threaded) rtsWays) ? notStage0 ? arg "--ghc-option=-optc-DTHREADED_RTS" + -- When building stage 1, use thread-safe RTS functions if the + -- bootstrapping (stage 0) compiler provides a threaded RTS way. + , stage0 ? threadedBootstrapper ? arg "--ghc-option=-optc-DTHREADED_RTS" , ghcWithInterpreter ? ghcEnableTablesNextToCode ? notM (flag GhcUnregisterised) ? @@ -85,10 +90,27 @@ packageArgs = do , builder (Cabal Flags) ? mconcat [ ghcWithInterpreter ? notStage0 ? arg "ghci" , flag CrossCompiling ? arg "-terminfo" - -- the 'threaded' flag is True by default, but - -- let's record explicitly that we link all ghc - -- executables with the threaded runtime. - , arg "threaded" ] ] + -- Note [Linking ghc-bin against threaded stage0 RTS] + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- We must maintain the invariant that GHCs linked with '-threaded' + -- are built with '-optc=-DTHREADED_RTS', otherwise we'll end up + -- with a GHC that can use the threaded runtime, but contains some + -- non-thread-safe functions. See + -- https://gitlab.haskell.org/ghc/ghc/issues/18024 for an example of + -- the sort of issues this can cause. + , ifM stage0 + -- We build a threaded stage 1 if the bootstrapping compiler + -- supports it. + (ifM threadedBootstrapper + (arg "threaded") + (arg "-threaded")) + -- We build a threaded stage N, N>1 if the configuration calls + -- for it. + (ifM (ghcThreaded <$> expr flavour) + (arg "threaded") + (arg "-threaded")) + ] + ] -------------------------------- ghcPkg -------------------------------- , package ghcPkg ? ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit 8199c3f838a15fb9b7c8d3527603084b2474d877 +Subproject commit bd07f0a095869b91a590d8a564f716a6a136818a ===================================== libraries/base/GHC/Float.hs ===================================== @@ -141,6 +141,14 @@ class (Fractional a) => Floating a where log1pexp x = log1p (exp x) log1mexp x = log1p (negate (exp x)) +-- | Default implementation for @'log1mexp'@ requiring @'Ord'@ to test +-- against a threshold to decide which implementation variant to use. +log1mexpOrd :: (Ord a, Floating a) => a -> a +{-# INLINE log1mexpOrd #-} +log1mexpOrd a + | a > -(log 2) = log (negate (expm1 a)) + | otherwise = log1p (negate (exp a)) + -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat a where @@ -398,9 +406,7 @@ instance Floating Float where log1p = log1pFloat expm1 = expm1Float - log1mexp a - | a <= log 2 = log (negate (expm1Float a)) - | otherwise = log1pFloat (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pFloat (exp a) @@ -539,9 +545,7 @@ instance Floating Double where log1p = log1pDouble expm1 = expm1Double - log1mexp a - | a <= log 2 = log (negate (expm1Double a)) - | otherwise = log1pDouble (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pDouble (exp a) ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 1efc9c0964ba6d0366c4015accbd5ebd343826f6 +Subproject commit 95fe6bdf13c9cc86c1c880164f7844d61d989574 ===================================== libraries/ghc-compact/tests/T16992.hs ===================================== @@ -0,0 +1,22 @@ +import Data.Bifunctor +import Foreign.Ptr +import qualified Data.ByteString as BS +import qualified Data.ByteString.Unsafe as BS +import qualified GHC.Compact as Compact +import qualified GHC.Compact.Serialized as CompactSerialize + +-- | Minimal test case for reproducing compactFixupPointers# bug for large compact regions. +-- See Issue #16992. +main :: IO () +main = do + let + large = 1024 * 1024 * 128 + largeString = replicate large 'A' + + region <- Compact.compact largeString + + Just deserialized <- CompactSerialize.withSerializedCompact region $ \s -> do + blks <- mapM (BS.unsafePackCStringLen . bimap castPtr fromIntegral) (CompactSerialize.serializedCompactBlockList s) + CompactSerialize.importCompactByteStrings s blks + + print (Compact.getCompact deserialized == largeString) ===================================== libraries/ghc-compact/tests/T16992.stdout ===================================== @@ -0,0 +1 @@ +True ===================================== libraries/ghc-compact/tests/all.T ===================================== @@ -22,3 +22,8 @@ test('compact_share', omit_ways(['ghci', 'profasm', 'profthreaded']), test('compact_bench', [ ignore_stdout, extra_run_opts('100') ], compile_and_run, ['']) test('T17044', normal, compile_and_run, ['']) +# N.B. Sanity check times out due to large list. +test('T16992', [when(wordsize(32), skip), # Resource limit exceeded on 32-bit + high_memory_usage, + run_timeout_multiplier(5), + omit_ways(['sanity'])], compile_and_run, ['']) ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -66,6 +66,11 @@ Library -- on Windows. Required because of mingw32. extra-libraries: user32, mingw32, mingwex + if os(linux) + -- we need libm, but for musl and other's we might need libc, as libm + -- is just an empty shell. + extra-libraries: c, m + c-sources: cbits/atomic.c cbits/bswap.c ===================================== mk/config.mk.in ===================================== @@ -199,6 +199,9 @@ endif # `GhcUnregisterised` mode doesn't allow that. GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO)) +# Whether or not the bootstrapping GHC supplies a threaded RTS. +GhcThreadedRts = @GhcThreadedRts@ + # Whether to include GHCi in the compiler. Depends on whether the RTS linker # has support for this OS/ARCH combination. ===================================== rts/linker/LoadArchive.c ===================================== @@ -461,6 +461,7 @@ static HsInt loadArchive_ (pathchar *path) /* TODO: Stop relying on file extensions to determine input formats. Instead try to match file headers. See Trac #13103. */ isObject = (thisFileNameSize >= 2 && strncmp(fileName + thisFileNameSize - 2, ".o" , 2) == 0) + || (thisFileNameSize >= 3 && strncmp(fileName + thisFileNameSize - 3, ".lo" , 3) == 0) || (thisFileNameSize >= 4 && strncmp(fileName + thisFileNameSize - 4, ".p_o", 4) == 0) || (thisFileNameSize >= 4 && strncmp(fileName + thisFileNameSize - 4, ".obj", 4) == 0); ===================================== rts/linker/elf_reloc_aarch64.c ===================================== @@ -90,12 +90,14 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) { // ... hi ] [ Rd ] // // imm64 = SignExtend(hi:lo:0x000,64) - assert(isInt64(32, addend)); + // Range is 21 bits + the 12 page relative bits + // known to be 0. -2^32 <= X < 2^32 + assert(isInt64(21+12, addend)); assert((addend & 0xfff) == 0); /* page relative */ *(inst_t *)P = (*(inst_t *)P & 0x9f00001f) - | (inst_t) (((uint64_t) addend << 17) & 0x60000000) - | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0); + | (inst_t) (((uint64_t) addend << 17) & 0x60000000) + | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0); break; } /* - control flow relocations */ @@ -108,8 +110,8 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) { break; } case COMPAT_R_AARCH64_ADR_GOT_PAGE: { - - assert(isInt64(32, addend)); /* X in range */ + /* range is -2^32 <= X < 2^32 */ + assert(isInt64(21+12, addend)); /* X in range */ assert((addend & 0xfff) == 0); /* page relative */ *(inst_t *)P = (*(inst_t *)P & 0x9f00001f) ===================================== rts/sm/CNF.c ===================================== @@ -1016,8 +1016,9 @@ cmp_fixup_table_item (const void *e1, const void *e2) { const StgWord *w1 = e1; const StgWord *w2 = e2; - - return *w1 - *w2; + if (*w1 > *w2) return +1; + else if (*w1 < *w2) return -1; + else return 0; } static StgWord * ===================================== testsuite/tests/typecheck/should_compile/T18185.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +module T18185 where + +import GHC.TypeLits +import Type.Reflection + +class iss :|+ is ~ oss => AddT (iss :: [Symbol]) (is :: Symbol) (oss :: [Symbol]) where + type iss :|+ is :: [Symbol] + +class (CmpSymbol is ish ~ ord, AddT'I ord is ish ist ~ oss) => AddT' ord is ish ist oss where + type AddT'I ord is ish ist :: [Symbol] + +class (CmpSymbol "a" "a" ~ o) => C1 o +class (CmpNat 1 1 ~ o) => C2 o +class ((CmpSymbol "a" "a" :: Ordering) ~ o) => C3 o +class ((CmpNat 1 1 :: Ordering) ~ o) => C4 o + +f1 :: TypeRep (CmpSymbol "a" "a") +f1 = typeRep + +f2 :: TypeRep (CmpNat 1 1) +f2 = typeRep + +f3 :: TypeRep (CmpSymbol "a" "a" :: Ordering) +f3 = typeRep + +f4 :: TypeRep (CmpNat 1 1 :: Ordering) +f4 = typeRep ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -670,3 +670,4 @@ test('T16204a', normal, compile, ['']) test('T16204b', normal, compile, ['']) test('T16225', normal, compile, ['']) test('T16312', normal, compile, ['-O']) +test('T18185', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2900ab4fd9118d542a3ccac830fdce046288d71f...30a5613260a580d26a8bd3ff9391f7c85fe01881 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2900ab4fd9118d542a3ccac830fdce046288d71f...30a5613260a580d26a8bd3ff9391f7c85fe01881 You're receiving 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 Jul 8 16:04:25 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 08 Jul 2020 12:04:25 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] 6 commits: Build a threaded stage 1 if the bootstrapping GHC supports it. Message-ID: <5f05ee89345f8_80b3f8486b77e482346330@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 4cdac979 by Travis Whitaker at 2020-07-08T12:04:12-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. (cherry picked from commit 67738db10010fd28a8e997b5c8f83ea591b88a0e) - - - - - 716fb3d0 by Moritz Angermann at 2020-07-08T12:04:15-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. (cherry picked from commit b455074875d3c8fd3a5787e01dc6f922f3a97bc2) - - - - - f8c9b6dd by Artem Pelenitsyn at 2020-07-08T12:04:15-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. (cherry picked from commit af5e3a885ddd09dd5f550552c535af3661ff3dbf) - - - - - 317c0f7f by Ryan Scott at 2020-07-08T12:04:15-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. (cherry picked from commit 66bd24d197251b9907cbffba3d5d8a3f5e3c2e80) - - - - - b79343aa by Ben Gamari at 2020-07-08T12:04:15-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 (cherry picked from commit c00c81a507d31b6d51e89f00d1e4c83f71c7d382) - - - - - 0111c371 by GHC GitLab CI at 2020-07-08T12:04:15-04:00 Bump to 8.8.4, RELEASE=YES - - - - - 18 changed files: - compiler/ghc.mk - compiler/prelude/PrelNames.hs - compiler/prelude/TysWiredIn.hs - configure.ac - ghc/ghc.mk - hadrian/cfg/system.config.in - hadrian/src/Expression.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Packages.hs - libraries/base/GHC/Float.hs - + libraries/ghc-compact/tests/T16992.hs - + libraries/ghc-compact/tests/T16992.stdout - libraries/ghc-compact/tests/all.T - libraries/ghc-prim/ghc-prim.cabal - mk/config.mk.in - rts/sm/CNF.c - + testsuite/tests/typecheck/should_compile/T18185.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/ghc.mk ===================================== @@ -326,6 +326,12 @@ ifeq "$(GhcThreaded)" "YES" compiler_stage2_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS endif +# If the bootstrapping GHC supplies the threaded RTS, then we can have a +# threaded stage 1 too. +ifeq "$(GhcThreadedRts)" "YES" +compiler_stage1_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS +endif + ifeq "$(GhcWithNativeCodeGen)" "YES" compiler_stage1_CONFIGURE_OPTS += --flags=ncg compiler_stage2_CONFIGURE_OPTS += --flags=ncg ===================================== compiler/prelude/PrelNames.hs ===================================== @@ -420,10 +420,6 @@ basicKnownKeyNames -- Annotation type checking toAnnotationWrapperName - -- The Ordering type - , orderingTyConName - , ordLTDataConName, ordEQDataConName, ordGTDataConName - -- The SPEC type for SpecConstr , specTyConName ===================================== compiler/prelude/TysWiredIn.hs ===================================== @@ -197,8 +197,11 @@ names in PrelNames, so they use wTcQual, wDataQual, etc -- that occurs in this list that name will be assigned the wired-in key we -- define here. -- --- Because of their infinite nature, this list excludes tuples, Any and implicit --- parameter TyCons (see Note [Built-in syntax and the OrigNameCache]). +-- Because of their infinite nature, this list excludes +-- * tuples, including boxed, unboxed and constraint tuples +--- (mkTupleTyCon, unitTyCon, pairTyCon) +-- * unboxed sums (sumTyCon) +-- See Note [Infinite families of known-key names] in GHC.Builtin.Names -- -- See also Note [Known-key names] wiredInTyCons :: [TyCon] @@ -219,6 +222,7 @@ wiredInTyCons = [ -- Units are not treated like other tuples, because then , wordTyCon , word8TyCon , listTyCon + , orderingTyCon , maybeTyCon , heqTyCon , eqTyCon ===================================== configure.ac ===================================== @@ -13,10 +13,10 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.3], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.4], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # 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 @@ -127,6 +127,9 @@ dnl CC_STAGE0 is like the "previous" variable CC (inherited by CC_STAGE[123]) dnl but instead used by stage0 for bootstrapping stage1 AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)]) +dnl RTS ways supplied by the bootstrapping compiler. +AC_ARG_VAR(RTS_WAYS_STAGE0, [RTS ways]) + if test "$WithGhc" != ""; then FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl @@ -150,6 +153,17 @@ if test "$WithGhc" != ""; then BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command]) BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) + BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) + + dnl Check whether or not the bootstrapping GHC has a threaded RTS. This + dnl determines whether or not we can have a threaded stage 1. + dnl See Note [Linking ghc-bin against threaded stage0 RTS] in + dnl hadrian/src/Settings/Packages.hs for details. + if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null; then + AC_SUBST(GhcThreadedRts, YES) + else + AC_SUBST(GhcThreadedRts, NO) + fi fi dnl ** Must have GHC to build GHC @@ -1372,6 +1386,7 @@ Configure completed successfully. echo "\ Bootstrapping using : $WithGhc which is version : $GhcVersion + with threaded RTS? : $GhcThreadedRts " if test "x$CC_LLVM_BACKEND" = "x1"; then ===================================== ghc/ghc.mk ===================================== @@ -63,6 +63,13 @@ ghc_stage2_MORE_HC_OPTS += -threaded ghc_stage3_MORE_HC_OPTS += -threaded endif +# If stage 0 supplies a threaded RTS, we can use it for stage 1. +# See Note [Linking ghc-bin against threaded stage0 RTS] in +# hadrian/src/Settings/Packages.hs for details. +ifeq "$(GhcThreadedRts)" "YES" +ghc_stage1_MORE_HC_OPTS += -threaded +endif + ifeq "$(GhcProfiled)" "YES" ghc_stage2_PROGRAM_WAY = p endif ===================================== hadrian/cfg/system.config.in ===================================== @@ -77,6 +77,8 @@ ghc-major-version = @GhcMajVersion@ ghc-minor-version = @GhcMinVersion@ ghc-patch-level = @GhcPatchLevel@ +bootstrap-threaded-rts = @GhcThreadedRts@ + supports-this-unit-id = @SUPPORTS_THIS_UNIT_ID@ project-name = @ProjectName@ ===================================== hadrian/src/Expression.hs ===================================== @@ -26,6 +26,7 @@ import Base import Builder import Context hiding (stage, package, way) import Expression.Type +import Oracles.Flag import Hadrian.Expression hiding (Expr, Predicate, Args) import Hadrian.Haskell.Cabal.Type import Hadrian.Oracles.Cabal @@ -99,6 +100,13 @@ stage2 = stage Stage2 notStage0 :: Predicate notStage0 = notM stage0 +-- | Whether or not the bootstrapping compiler provides a threaded RTS. We need +-- to know this when building stage 1, since stage 1 links against the +-- compiler's RTS ways. See Note [Linking ghc-bin against threaded stage0 RTS] +-- in Settings.Packages for details. +threadedBootstrapper :: Predicate +threadedBootstrapper = expr (flag BootstrapThreadedRts) + -- | Is a certain package /not/ built right now? notPackage :: Package -> Predicate notPackage = notM . package ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -21,6 +21,7 @@ data Flag = ArSupportsAtFile | WithLibdw | HaveLibMingwEx | UseSystemFfi + | BootstrapThreadedRts -- Note, if a flag is set to empty string we treat it as set to NO. This seems -- fragile, but some flags do behave like this, e.g. GccIsClang. @@ -39,6 +40,7 @@ flag f = do WithLibdw -> "with-libdw" HaveLibMingwEx -> "have-lib-mingw-ex" UseSystemFfi -> "use-system-ffi" + BootstrapThreadedRts -> "bootstrap-threaded-rts" value <- lookupValueOrError configFile key when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag " ++ quote (key ++ " = " ++ value) ++ " cannot be parsed." ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -53,10 +53,15 @@ packageArgs = do , arg "--disable-library-for-ghci" , anyTargetOs ["openbsd"] ? arg "--ld-options=-E" , flag GhcUnregisterised ? arg "--ghc-option=-DNO_REGS" - , notM ghcWithSMP ? arg "--ghc-option=-DNOSMP" - , notM ghcWithSMP ? arg "--ghc-option=-optc-DNOSMP" + , notM targetSupportsSMP ? arg "--ghc-option=-DNOSMP" + , notM targetSupportsSMP ? arg "--ghc-option=-optc-DNOSMP" + -- When building stage 1 or later, use thread-safe RTS functions if + -- the configuration calls for a threaded GHC. , (any (wayUnit Threaded) rtsWays) ? notStage0 ? arg "--ghc-option=-optc-DTHREADED_RTS" + -- When building stage 1, use thread-safe RTS functions if the + -- bootstrapping (stage 0) compiler provides a threaded RTS way. + , stage0 ? threadedBootstrapper ? arg "--ghc-option=-optc-DTHREADED_RTS" , ghcWithInterpreter ? ghcEnableTablesNextToCode ? notM (flag GhcUnregisterised) ? @@ -85,10 +90,27 @@ packageArgs = do , builder (Cabal Flags) ? mconcat [ ghcWithInterpreter ? notStage0 ? arg "ghci" , flag CrossCompiling ? arg "-terminfo" - -- the 'threaded' flag is True by default, but - -- let's record explicitly that we link all ghc - -- executables with the threaded runtime. - , arg "threaded" ] ] + -- Note [Linking ghc-bin against threaded stage0 RTS] + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- We must maintain the invariant that GHCs linked with '-threaded' + -- are built with '-optc=-DTHREADED_RTS', otherwise we'll end up + -- with a GHC that can use the threaded runtime, but contains some + -- non-thread-safe functions. See + -- https://gitlab.haskell.org/ghc/ghc/issues/18024 for an example of + -- the sort of issues this can cause. + , ifM stage0 + -- We build a threaded stage 1 if the bootstrapping compiler + -- supports it. + (ifM threadedBootstrapper + (arg "threaded") + (arg "-threaded")) + -- We build a threaded stage N, N>1 if the configuration calls + -- for it. + (ifM (ghcThreaded <$> expr flavour) + (arg "threaded") + (arg "-threaded")) + ] + ] -------------------------------- ghcPkg -------------------------------- , package ghcPkg ? ===================================== libraries/base/GHC/Float.hs ===================================== @@ -141,6 +141,14 @@ class (Fractional a) => Floating a where log1pexp x = log1p (exp x) log1mexp x = log1p (negate (exp x)) +-- | Default implementation for @'log1mexp'@ requiring @'Ord'@ to test +-- against a threshold to decide which implementation variant to use. +log1mexpOrd :: (Ord a, Floating a) => a -> a +{-# INLINE log1mexpOrd #-} +log1mexpOrd a + | a > -(log 2) = log (negate (expm1 a)) + | otherwise = log1p (negate (exp a)) + -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat a where @@ -398,9 +406,7 @@ instance Floating Float where log1p = log1pFloat expm1 = expm1Float - log1mexp a - | a <= log 2 = log (negate (expm1Float a)) - | otherwise = log1pFloat (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pFloat (exp a) @@ -539,9 +545,7 @@ instance Floating Double where log1p = log1pDouble expm1 = expm1Double - log1mexp a - | a <= log 2 = log (negate (expm1Double a)) - | otherwise = log1pDouble (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pDouble (exp a) ===================================== libraries/ghc-compact/tests/T16992.hs ===================================== @@ -0,0 +1,22 @@ +import Data.Bifunctor +import Foreign.Ptr +import qualified Data.ByteString as BS +import qualified Data.ByteString.Unsafe as BS +import qualified GHC.Compact as Compact +import qualified GHC.Compact.Serialized as CompactSerialize + +-- | Minimal test case for reproducing compactFixupPointers# bug for large compact regions. +-- See Issue #16992. +main :: IO () +main = do + let + large = 1024 * 1024 * 128 + largeString = replicate large 'A' + + region <- Compact.compact largeString + + Just deserialized <- CompactSerialize.withSerializedCompact region $ \s -> do + blks <- mapM (BS.unsafePackCStringLen . bimap castPtr fromIntegral) (CompactSerialize.serializedCompactBlockList s) + CompactSerialize.importCompactByteStrings s blks + + print (Compact.getCompact deserialized == largeString) ===================================== libraries/ghc-compact/tests/T16992.stdout ===================================== @@ -0,0 +1 @@ +True ===================================== libraries/ghc-compact/tests/all.T ===================================== @@ -22,3 +22,8 @@ test('compact_share', omit_ways(['ghci', 'profasm', 'profthreaded']), test('compact_bench', [ ignore_stdout, extra_run_opts('100') ], compile_and_run, ['']) test('T17044', normal, compile_and_run, ['']) +# N.B. Sanity check times out due to large list. +test('T16992', [when(wordsize(32), skip), # Resource limit exceeded on 32-bit + high_memory_usage, + run_timeout_multiplier(5), + omit_ways(['sanity'])], compile_and_run, ['']) ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -66,6 +66,11 @@ Library -- on Windows. Required because of mingw32. extra-libraries: user32, mingw32, mingwex + if os(linux) + -- we need libm, but for musl and other's we might need libc, as libm + -- is just an empty shell. + extra-libraries: c, m + c-sources: cbits/atomic.c cbits/bswap.c ===================================== mk/config.mk.in ===================================== @@ -199,6 +199,9 @@ endif # `GhcUnregisterised` mode doesn't allow that. GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO)) +# Whether or not the bootstrapping GHC supplies a threaded RTS. +GhcThreadedRts = @GhcThreadedRts@ + # Whether to include GHCi in the compiler. Depends on whether the RTS linker # has support for this OS/ARCH combination. ===================================== rts/sm/CNF.c ===================================== @@ -1016,8 +1016,9 @@ cmp_fixup_table_item (const void *e1, const void *e2) { const StgWord *w1 = e1; const StgWord *w2 = e2; - - return *w1 - *w2; + if (*w1 > *w2) return +1; + else if (*w1 < *w2) return -1; + else return 0; } static StgWord * ===================================== testsuite/tests/typecheck/should_compile/T18185.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +module T18185 where + +import GHC.TypeLits +import Type.Reflection + +class iss :|+ is ~ oss => AddT (iss :: [Symbol]) (is :: Symbol) (oss :: [Symbol]) where + type iss :|+ is :: [Symbol] + +class (CmpSymbol is ish ~ ord, AddT'I ord is ish ist ~ oss) => AddT' ord is ish ist oss where + type AddT'I ord is ish ist :: [Symbol] + +class (CmpSymbol "a" "a" ~ o) => C1 o +class (CmpNat 1 1 ~ o) => C2 o +class ((CmpSymbol "a" "a" :: Ordering) ~ o) => C3 o +class ((CmpNat 1 1 :: Ordering) ~ o) => C4 o + +f1 :: TypeRep (CmpSymbol "a" "a") +f1 = typeRep + +f2 :: TypeRep (CmpNat 1 1) +f2 = typeRep + +f3 :: TypeRep (CmpSymbol "a" "a" :: Ordering) +f3 = typeRep + +f4 :: TypeRep (CmpNat 1 1 :: Ordering) +f4 = typeRep ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -670,3 +670,4 @@ test('T16204a', normal, compile, ['']) test('T16204b', normal, compile, ['']) test('T16225', normal, compile, ['']) test('T16312', normal, compile, ['-O']) +test('T18185', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/30a5613260a580d26a8bd3ff9391f7c85fe01881...0111c371bb5d8017deee89660f8844f4d078ecf2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/30a5613260a580d26a8bd3ff9391f7c85fe01881...0111c371bb5d8017deee89660f8844f4d078ecf2 You're receiving 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 Jul 8 16:09:13 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 08 Jul 2020 12:09:13 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] 2 commits: More release notes Message-ID: <5f05efa931b4e_80b3f848e5b86582348319@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 22d7f115 by Ben Gamari at 2020-07-08T12:09:07-04:00 More release notes - - - - - b18d909b by GHC GitLab CI at 2020-07-08T12:09:07-04:00 Bump to 8.8.4, RELEASE=YES - - - - - 2 changed files: - configure.ac - docs/users_guide/8.8.4-notes.rst Changes: ===================================== configure.ac ===================================== @@ -13,10 +13,10 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.3], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.4], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # 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 ===================================== docs/users_guide/8.8.4-notes.rst ===================================== @@ -13,6 +13,14 @@ Highlights - Workaround a Linux kernel bug in the implementation of ``timerfd``\s (:ghc-ticket:`18033`). +- Fix a few linking issues affecting ARM + +- Fix "missing interface file" error triggered by some uses of ``Ordering`` (:ghc-ticket:`18185`) + +- Fix an integer overflow in the compact-normal-form import implementation (:ghc-ticket:`16992`) + +- ``configure`` now accepts ``--enable-numa`` flag to enable/disable ``numactl`` support on Linux. + Known issues ------------ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0111c371bb5d8017deee89660f8844f4d078ecf2...b18d909b178ebc795f6018b89ee16ea310234cfb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0111c371bb5d8017deee89660f8844f4d078ecf2...b18d909b178ebc795f6018b89ee16ea310234cfb You're receiving 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 Jul 8 16:17:23 2020 From: gitlab at gitlab.haskell.org (Josh Meredith) Date: Wed, 08 Jul 2020 12:17:23 -0400 Subject: [Git][ghc/ghc][wip/pluginExtFields] Add exports Message-ID: <5f05f193b79bc_80b3f849c221f4023513a8@gitlab.haskell.org.mail> Josh Meredith pushed to branch wip/pluginExtFields at Glasgow Haskell Compiler / GHC Commits: 842771d5 by Josh Meredith at 2020-07-09T02:17:07+10:00 Add exports - - - - - 1 changed file: - compiler/GHC/IfaceToCore.hs Changes: ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -20,7 +20,9 @@ module GHC.IfaceToCore ( tcIfaceAnnotations, tcIfaceCompleteSigs, tcIfaceExpr, -- Desired by HERMIT (#7683) tcIfaceGlobal, - tcIfaceOneShot + tcIfaceOneShot, + tcIfaceType, + tcJoinInfo, ) where #include "HsVersions.h" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/842771d5ff7f60672f86800846e3cf8a82f4aafe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/842771d5ff7f60672f86800846e3cf8a82f4aafe You're receiving 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 Jul 8 17:18:11 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 08 Jul 2020 13:18:11 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] 8 commits: ghc-prim needs to depend on libc and libm Message-ID: <5f05ffd3a839c_80b3f849c221f40236093@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 407b98f7 by Moritz Angermann at 2020-07-08T12:54:35-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. (cherry picked from commit b455074875d3c8fd3a5787e01dc6f922f3a97bc2) - - - - - 14401143 by Artem Pelenitsyn at 2020-07-08T12:54:35-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. (cherry picked from commit af5e3a885ddd09dd5f550552c535af3661ff3dbf) - - - - - 49a68ebf by Ryan Scott at 2020-07-08T12:54:35-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. (cherry picked from commit 66bd24d197251b9907cbffba3d5d8a3f5e3c2e80) - - - - - 6abc5456 by Ben Gamari at 2020-07-08T12:54:35-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 (cherry picked from commit c00c81a507d31b6d51e89f00d1e4c83f71c7d382) - - - - - 322e5e53 by Ben Gamari at 2020-07-08T12:57:17-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. (cherry picked from commit 2b89ca5b850b4097447cc4908cbb0631011ce979) - - - - - 58485483 by Travis Whitaker at 2020-07-08T13:05:52-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. (cherry picked from commit 67738db10010fd28a8e997b5c8f83ea591b88a0e) - - - - - 581956c8 by Ben Gamari at 2020-07-08T13:05:52-04:00 More release notes - - - - - 927e8c91 by GHC GitLab CI at 2020-07-08T13:05:52-04:00 Bump to 8.8.4, RELEASE=YES - - - - - 21 changed files: - compiler/deSugar/DsExpr.hs - compiler/ghc.mk - compiler/prelude/PrelNames.hs - compiler/prelude/TysWiredIn.hs - configure.ac - docs/users_guide/8.8.4-notes.rst - ghc/ghc.mk - hadrian/cfg/system.config.in - hadrian/src/Expression.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Packages.hs - libraries/base/GHC/Float.hs - + libraries/ghc-compact/tests/T16992.hs - + libraries/ghc-compact/tests/T16992.stdout - libraries/ghc-compact/tests/all.T - libraries/ghc-prim/ghc-prim.cabal - mk/config.mk.in - rts/sm/CNF.c - testsuite/tests/deSugar/should_run/all.T - + testsuite/tests/typecheck/should_compile/T18185.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/deSugar/DsExpr.hs ===================================== @@ -331,26 +331,47 @@ Then we get That 'g' in the 'in' part is an evidence variable, and when converting to core it must become a CO. -Operator sections. At first it looks as if we can convert -\begin{verbatim} - (expr op) -\end{verbatim} -to -\begin{verbatim} - \x -> op expr x -\end{verbatim} + +Note [Desugaring operator sections] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +At first it looks as if we can convert + + (expr `op`) + +naively to + + \x -> op expr x But no! expr might be a redex, and we can lose laziness badly this way. Consider -\begin{verbatim} - map (expr op) xs -\end{verbatim} -for example. So we convert instead to -\begin{verbatim} - let y = expr in \x -> op y x -\end{verbatim} -If \tr{expr} is actually just a variable, say, then the simplifier -will sort it out. + + map (expr `op`) xs + +for example. If expr were a redex then eta-expanding naively would +result in multiple evaluations where the user might only have expected one. + +So we convert instead to + + let y = expr in \x -> op y x + +Also, note that we must do this for both right and (perhaps surprisingly) left +sections. Why are left sections necessary? Consider the program (found in #18151), + + seq (True `undefined`) () + +according to the Haskell Report this should reduce to () (as it specifies +desugaring via eta expansion). However, if we fail to eta expand we will rather +bottom. Consequently, we must eta expand even in the case of a left section. + +If `expr` is actually just a variable, say, then the simplifier +will inline `y`, eliminating the redundant `let`. + +Note that this works even in the case that `expr` is unlifted. In this case +bindNonRec will automatically do the right thing, giving us: + + case expr of y -> (\x -> op y x) + +See #18151. -} ds_expr _ e@(OpApp _ e1 op e2) @@ -359,17 +380,35 @@ ds_expr _ e@(OpApp _ e1 op e2) ; dsWhenNoErrs (mapM dsLExprNoLP [e1, e2]) (\exprs' -> mkCoreAppsDs (text "opapp" <+> ppr e) op' exprs') } -ds_expr _ (SectionL _ expr op) -- Desugar (e !) to ((!) e) - = do { op' <- dsLExpr op - ; dsWhenNoErrs (dsLExprNoLP expr) - (\expr' -> mkCoreAppDs (text "sectionl" <+> ppr expr) op' expr') } - --- dsLExpr (SectionR op expr) -- \ x -> op x expr +-- dsExpr (SectionL op expr) === (expr `op`) ~> \y -> op expr y +-- +-- See Note [Desugaring operator sections]. +-- N.B. this also must handle postfix operator sections due to -XPostfixOperators. +ds_expr _ e@(SectionL _ expr op) = do + core_op <- dsLExpr op + x_core <- dsLExpr expr + case splitFunTys (exprType core_op) of + -- Binary operator section + (x_ty:y_ty:_, _) -> do + dsWhenNoErrs + (mapM newSysLocalDsNoLP [x_ty, y_ty]) + (\[x_id, y_id] -> + bindNonRec x_id x_core + $ Lam y_id (mkCoreAppsDs (text "sectionl" <+> ppr e) + core_op [Var x_id, Var y_id])) + + -- Postfix operator section + (_:_, _) -> do + return $ mkCoreAppDs (text "sectionl" <+> ppr e) core_op x_core + + _ -> pprPanic "dsExpr(SectionL)" (ppr e) + +-- dsExpr (SectionR op expr) === (`op` expr) ~> \x -> op x expr +-- +-- See Note [Desugaring operator sections]. ds_expr _ e@(SectionR _ op expr) = do core_op <- dsLExpr op - -- for the type of x, we need the type of op's 2nd argument let (x_ty:y_ty:_, _) = splitFunTys (exprType core_op) - -- See comment with SectionL y_core <- dsLExpr expr dsWhenNoErrs (mapM newSysLocalDsNoLP [x_ty, y_ty]) (\[x_id, y_id] -> bindNonRec y_id y_core $ ===================================== compiler/ghc.mk ===================================== @@ -326,6 +326,12 @@ ifeq "$(GhcThreaded)" "YES" compiler_stage2_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS endif +# If the bootstrapping GHC supplies the threaded RTS, then we can have a +# threaded stage 1 too. +ifeq "$(GhcThreadedRts)" "YES" +compiler_stage1_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS +endif + ifeq "$(GhcWithNativeCodeGen)" "YES" compiler_stage1_CONFIGURE_OPTS += --flags=ncg compiler_stage2_CONFIGURE_OPTS += --flags=ncg ===================================== compiler/prelude/PrelNames.hs ===================================== @@ -420,10 +420,6 @@ basicKnownKeyNames -- Annotation type checking toAnnotationWrapperName - -- The Ordering type - , orderingTyConName - , ordLTDataConName, ordEQDataConName, ordGTDataConName - -- The SPEC type for SpecConstr , specTyConName ===================================== compiler/prelude/TysWiredIn.hs ===================================== @@ -197,8 +197,11 @@ names in PrelNames, so they use wTcQual, wDataQual, etc -- that occurs in this list that name will be assigned the wired-in key we -- define here. -- --- Because of their infinite nature, this list excludes tuples, Any and implicit --- parameter TyCons (see Note [Built-in syntax and the OrigNameCache]). +-- Because of their infinite nature, this list excludes +-- * tuples, including boxed, unboxed and constraint tuples +--- (mkTupleTyCon, unitTyCon, pairTyCon) +-- * unboxed sums (sumTyCon) +-- See Note [Infinite families of known-key names] in GHC.Builtin.Names -- -- See also Note [Known-key names] wiredInTyCons :: [TyCon] @@ -219,6 +222,7 @@ wiredInTyCons = [ -- Units are not treated like other tuples, because then , wordTyCon , word8TyCon , listTyCon + , orderingTyCon , maybeTyCon , heqTyCon , eqTyCon ===================================== configure.ac ===================================== @@ -13,10 +13,10 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.3], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.4], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # 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 @@ -127,6 +127,9 @@ dnl CC_STAGE0 is like the "previous" variable CC (inherited by CC_STAGE[123]) dnl but instead used by stage0 for bootstrapping stage1 AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)]) +dnl RTS ways supplied by the bootstrapping compiler. +AC_ARG_VAR(RTS_WAYS_STAGE0, [RTS ways]) + if test "$WithGhc" != ""; then FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl @@ -150,6 +153,17 @@ if test "$WithGhc" != ""; then BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command]) BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) + BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) + + dnl Check whether or not the bootstrapping GHC has a threaded RTS. This + dnl determines whether or not we can have a threaded stage 1. + dnl See Note [Linking ghc-bin against threaded stage0 RTS] in + dnl hadrian/src/Settings/Packages.hs for details. + if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null; then + AC_SUBST(GhcThreadedRts, YES) + else + AC_SUBST(GhcThreadedRts, NO) + fi fi dnl ** Must have GHC to build GHC @@ -1372,6 +1386,7 @@ Configure completed successfully. echo "\ Bootstrapping using : $WithGhc which is version : $GhcVersion + with threaded RTS? : $GhcThreadedRts " if test "x$CC_LLVM_BACKEND" = "x1"; then ===================================== docs/users_guide/8.8.4-notes.rst ===================================== @@ -6,13 +6,27 @@ Release notes for version 8.8.4 GHC 8.8.4 is a minor release intended to fix regressions and minor bugs in the 8.8.1, 8.8.2 and 8.8.3 releases. +Like previous releases in the 8.8 series, the :ghc-flag:`LLVM backend <-fllvm>` +of this release is to be used with LLVM 7. + Highlights ---------- -- Fix a bug in process creation on Windows (:ghc-ticket:`17926`). +- Fixes a bug in process creation on Windows (:ghc-ticket:`17926`). + +- Works around a Linux kernel bug in the implementation of ``timerfd``\s (:ghc-ticket:`18033`). + +- Fixes a few linking issues affecting ARM + +- Fixes "missing interface file" error triggered by some uses of ``Ordering`` (:ghc-ticket:`18185`) + +- Fixes an integer overflow in the compact-normal-form import implementation (:ghc-ticket:`16992`) + +- ``configure`` now accepts ``--enable-numa`` flag to enable/disable ``numactl`` support on Linux. -- Workaround a Linux kernel bug in the implementation of ``timerfd``\s (:ghc-ticket:`18033`). +- Fixes potentially lost sharing due to the desugaring of left operator sections (:ghc-ticket:`18151`). +- Fixes a build-system bug resulting in potential miscompilation by unregisteised compilers (:ghc-ticket:`18024`) Known issues ------------ ===================================== ghc/ghc.mk ===================================== @@ -63,6 +63,15 @@ ghc_stage2_MORE_HC_OPTS += -threaded ghc_stage3_MORE_HC_OPTS += -threaded endif +# If stage 0 supplies a threaded RTS, we can use it for stage 1. +# See Note [Linking ghc-bin against threaded stage0 RTS] in +# hadrian/src/Settings/Packages.hs for details. +ifeq "$(GhcThreadedRts)" "YES" +ghc_stage1_MORE_HC_OPTS += -threaded +else +ghc_stage1_CONFIGURE_OPTS += -f-threaded +endif + ifeq "$(GhcProfiled)" "YES" ghc_stage2_PROGRAM_WAY = p endif ===================================== hadrian/cfg/system.config.in ===================================== @@ -77,6 +77,8 @@ ghc-major-version = @GhcMajVersion@ ghc-minor-version = @GhcMinVersion@ ghc-patch-level = @GhcPatchLevel@ +bootstrap-threaded-rts = @GhcThreadedRts@ + supports-this-unit-id = @SUPPORTS_THIS_UNIT_ID@ project-name = @ProjectName@ ===================================== hadrian/src/Expression.hs ===================================== @@ -6,8 +6,8 @@ module Expression ( expr, exprIO, arg, remove, -- ** Predicates - (?), stage, stage0, stage1, stage2, notStage0, package, notPackage, - libraryPackage, builder, way, input, inputs, output, outputs, + (?), stage, stage0, stage1, stage2, notStage0, threadedBootstrapper, + package, notPackage, libraryPackage, builder, way, input, inputs, output, outputs, -- ** Evaluation interpret, interpretInContext, @@ -26,6 +26,7 @@ import Base import Builder import Context hiding (stage, package, way) import Expression.Type +import Oracles.Flag import Hadrian.Expression hiding (Expr, Predicate, Args) import Hadrian.Haskell.Cabal.Type import Hadrian.Oracles.Cabal @@ -83,6 +84,19 @@ instance BuilderPredicate a => BuilderPredicate (FilePath -> a) where way :: Way -> Predicate way w = (w ==) <$> getWay +{- +Note [Stage Names] +~~~~~~~~~~~~~~~~~~ + +Code referring to specific stages can be a bit tricky. In Hadrian, the stages +have the same names they carried in the autoconf build system, but they are +often referred to by the stage used to construct them. For example, the stage 1 +artifacts will be placed in _build/stage0, because they are constructed by the +stage 0 compiler. The stage predicates in this module behave the same way, +'stage0' will return 'True' while stage 0 is being used to build the stage 1 +compiler. +-} + -- | Is the build currently in stage 0? stage0 :: Predicate stage0 = stage Stage0 @@ -99,6 +113,13 @@ stage2 = stage Stage2 notStage0 :: Predicate notStage0 = notM stage0 +-- | Whether or not the bootstrapping compiler provides a threaded RTS. We need +-- to know this when building stage 1, since stage 1 links against the +-- compiler's RTS ways. See Note [Linking ghc-bin against threaded stage0 RTS] +-- in Settings.Packages for details. +threadedBootstrapper :: Predicate +threadedBootstrapper = expr (flag BootstrapThreadedRts) + -- | Is a certain package /not/ built right now? notPackage :: Package -> Predicate notPackage = notM . package ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -21,6 +21,7 @@ data Flag = ArSupportsAtFile | WithLibdw | HaveLibMingwEx | UseSystemFfi + | BootstrapThreadedRts -- Note, if a flag is set to empty string we treat it as set to NO. This seems -- fragile, but some flags do behave like this, e.g. GccIsClang. @@ -39,6 +40,7 @@ flag f = do WithLibdw -> "with-libdw" HaveLibMingwEx -> "have-lib-mingw-ex" UseSystemFfi -> "use-system-ffi" + BootstrapThreadedRts -> "bootstrap-threaded-rts" value <- lookupValueOrError configFile key when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag " ++ quote (key ++ " = " ++ value) ++ " cannot be parsed." ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -85,10 +85,24 @@ packageArgs = do , builder (Cabal Flags) ? mconcat [ ghcWithInterpreter ? notStage0 ? arg "ghci" , flag CrossCompiling ? arg "-terminfo" - -- the 'threaded' flag is True by default, but - -- let's record explicitly that we link all ghc - -- executables with the threaded runtime. - , arg "threaded" ] ] + -- Note [Linking ghc-bin against threaded stage0 RTS] + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- We must maintain the invariant that GHCs linked with '-threaded' + -- are built with '-optc=-DTHREADED_RTS', otherwise we'll end up + -- with a GHC that can use the threaded runtime, but contains some + -- non-thread-safe functions. See + -- https://gitlab.haskell.org/ghc/ghc/issues/18024 for an example of + -- the sort of issues this can cause. + , ifM stage0 + -- We build a threaded stage 1 if the bootstrapping compiler + -- supports it. + (ifM threadedBootstrapper + (arg "threaded") + (arg "-threaded")) + -- We build a threaded stage N. + (arg "threaded") + ] + ] -------------------------------- ghcPkg -------------------------------- , package ghcPkg ? ===================================== libraries/base/GHC/Float.hs ===================================== @@ -141,6 +141,14 @@ class (Fractional a) => Floating a where log1pexp x = log1p (exp x) log1mexp x = log1p (negate (exp x)) +-- | Default implementation for @'log1mexp'@ requiring @'Ord'@ to test +-- against a threshold to decide which implementation variant to use. +log1mexpOrd :: (Ord a, Floating a) => a -> a +{-# INLINE log1mexpOrd #-} +log1mexpOrd a + | a > -(log 2) = log (negate (expm1 a)) + | otherwise = log1p (negate (exp a)) + -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat a where @@ -398,9 +406,7 @@ instance Floating Float where log1p = log1pFloat expm1 = expm1Float - log1mexp a - | a <= log 2 = log (negate (expm1Float a)) - | otherwise = log1pFloat (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pFloat (exp a) @@ -539,9 +545,7 @@ instance Floating Double where log1p = log1pDouble expm1 = expm1Double - log1mexp a - | a <= log 2 = log (negate (expm1Double a)) - | otherwise = log1pDouble (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pDouble (exp a) ===================================== libraries/ghc-compact/tests/T16992.hs ===================================== @@ -0,0 +1,22 @@ +import Data.Bifunctor +import Foreign.Ptr +import qualified Data.ByteString as BS +import qualified Data.ByteString.Unsafe as BS +import qualified GHC.Compact as Compact +import qualified GHC.Compact.Serialized as CompactSerialize + +-- | Minimal test case for reproducing compactFixupPointers# bug for large compact regions. +-- See Issue #16992. +main :: IO () +main = do + let + large = 1024 * 1024 * 128 + largeString = replicate large 'A' + + region <- Compact.compact largeString + + Just deserialized <- CompactSerialize.withSerializedCompact region $ \s -> do + blks <- mapM (BS.unsafePackCStringLen . bimap castPtr fromIntegral) (CompactSerialize.serializedCompactBlockList s) + CompactSerialize.importCompactByteStrings s blks + + print (Compact.getCompact deserialized == largeString) ===================================== libraries/ghc-compact/tests/T16992.stdout ===================================== @@ -0,0 +1 @@ +True ===================================== libraries/ghc-compact/tests/all.T ===================================== @@ -22,3 +22,8 @@ test('compact_share', omit_ways(['ghci', 'profasm', 'profthreaded']), test('compact_bench', [ ignore_stdout, extra_run_opts('100') ], compile_and_run, ['']) test('T17044', normal, compile_and_run, ['']) +# N.B. Sanity check times out due to large list. +test('T16992', [when(wordsize(32), skip), # Resource limit exceeded on 32-bit + high_memory_usage, + run_timeout_multiplier(5), + omit_ways(['sanity'])], compile_and_run, ['']) ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -66,6 +66,11 @@ Library -- on Windows. Required because of mingw32. extra-libraries: user32, mingw32, mingwex + if os(linux) + -- we need libm, but for musl and other's we might need libc, as libm + -- is just an empty shell. + extra-libraries: c, m + c-sources: cbits/atomic.c cbits/bswap.c ===================================== mk/config.mk.in ===================================== @@ -199,6 +199,9 @@ endif # `GhcUnregisterised` mode doesn't allow that. GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO)) +# Whether or not the bootstrapping GHC supplies a threaded RTS. +GhcThreadedRts = @GhcThreadedRts@ + # Whether to include GHCi in the compiler. Depends on whether the RTS linker # has support for this OS/ARCH combination. ===================================== rts/sm/CNF.c ===================================== @@ -1016,8 +1016,9 @@ cmp_fixup_table_item (const void *e1, const void *e2) { const StgWord *w1 = e1; const StgWord *w2 = e2; - - return *w1 - *w2; + if (*w1 > *w2) return +1; + else if (*w1 < *w2) return -1; + else return 0; } static StgWord * ===================================== testsuite/tests/deSugar/should_run/all.T ===================================== @@ -63,3 +63,4 @@ test('T11601', exit_code(1), compile_and_run, ['']) test('T11747', normal, compile_and_run, ['-dcore-lint']) test('T12595', normal, compile_and_run, ['']) test('T13285', normal, compile_and_run, ['']) +test('T18151', normal, compile_and_run, ['']) ===================================== testsuite/tests/typecheck/should_compile/T18185.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +module T18185 where + +import GHC.TypeLits +import Type.Reflection + +class iss :|+ is ~ oss => AddT (iss :: [Symbol]) (is :: Symbol) (oss :: [Symbol]) where + type iss :|+ is :: [Symbol] + +class (CmpSymbol is ish ~ ord, AddT'I ord is ish ist ~ oss) => AddT' ord is ish ist oss where + type AddT'I ord is ish ist :: [Symbol] + +class (CmpSymbol "a" "a" ~ o) => C1 o +class (CmpNat 1 1 ~ o) => C2 o +class ((CmpSymbol "a" "a" :: Ordering) ~ o) => C3 o +class ((CmpNat 1 1 :: Ordering) ~ o) => C4 o + +f1 :: TypeRep (CmpSymbol "a" "a") +f1 = typeRep + +f2 :: TypeRep (CmpNat 1 1) +f2 = typeRep + +f3 :: TypeRep (CmpSymbol "a" "a" :: Ordering) +f3 = typeRep + +f4 :: TypeRep (CmpNat 1 1 :: Ordering) +f4 = typeRep ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -670,3 +670,4 @@ test('T16204a', normal, compile, ['']) test('T16204b', normal, compile, ['']) test('T16225', normal, compile, ['']) test('T16312', normal, compile, ['-O']) +test('T18185', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b18d909b178ebc795f6018b89ee16ea310234cfb...927e8c91d53d9d0c36debfd57fd1f30fa04e6b9a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b18d909b178ebc795f6018b89ee16ea310234cfb...927e8c91d53d9d0c36debfd57fd1f30fa04e6b9a You're receiving 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 Jul 8 18:46:10 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 08 Jul 2020 14:46:10 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] hadrian: add flag to skip rebuilding dependency information #17636 Message-ID: <5f061472668f8_80b3f849ba1b9402371236@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 348f19c0 by Adam Sandberg Ericsson at 2020-07-08T14:46:07-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - 4 changed files: - hadrian/README.md - hadrian/doc/make.md - hadrian/src/CommandLine.hs - hadrian/src/Main.hs Changes: ===================================== hadrian/README.md ===================================== @@ -104,6 +104,8 @@ simply drop the `--freeze1` flag and Hadrian will rebuild all out-of-date files. * `--freeze2`: just like `--freeze1` but tell Hadrian to additionally freeze Stage2 GHC. +* `--skip-depends`: skips rebuilding Haskell module dependency files. + * `--integer-simple`: build GHC using the `integer-simple` integer library (instead of `integer-gmp`). ===================================== hadrian/doc/make.md ===================================== @@ -208,3 +208,17 @@ time you fire up a build. This is not possible with the Make build system. # Hadrian build nofib # builds the compiler and everything we need if necessary, too ``` + +- `make FAST=YES` + + Partially supported in hadrian with the `--skip-depends` argument. Since + hadrian is not directory aware some of the features of `FAST=YES` are not + replicated. + + ```sh + # Make + make FAST=YES + + # Hadrian + build --skip-depends + ``` ===================================== hadrian/src/CommandLine.hs ===================================== @@ -1,5 +1,5 @@ module CommandLine ( - optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2, + optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2, lookupSkipDepends, cmdBignum, cmdBignumCheck, cmdProgressInfo, cmdConfigure, cmdCompleteSetting, cmdDocsArgs, lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs, cmdPrefix @@ -26,6 +26,7 @@ data CommandLineArgs = CommandLineArgs , flavour :: Maybe String , freeze1 :: Bool , freeze2 :: Bool + , skipDepends :: Bool , bignum :: Maybe String , bignumCheck :: Bool , progressInfo :: ProgressInfo @@ -43,6 +44,7 @@ defaultCommandLineArgs = CommandLineArgs , flavour = Nothing , freeze1 = False , freeze2 = False + , skipDepends = False , bignum = Nothing , bignumCheck = False , progressInfo = Brief @@ -114,9 +116,10 @@ readBuildRoot ms = set :: BuildRoot -> CommandLineArgs -> CommandLineArgs set flag flags = flags { buildRoot = flag } -readFreeze1, readFreeze2 :: Either String (CommandLineArgs -> CommandLineArgs) +readFreeze1, readFreeze2, readSkipDepends :: Either String (CommandLineArgs -> CommandLineArgs) readFreeze1 = Right $ \flags -> flags { freeze1 = True } readFreeze2 = Right $ \flags -> flags { freeze1 = True, freeze2 = True } +readSkipDepends = Right $ \flags -> flags { skipDepends = True } readProgressInfo :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) readProgressInfo ms = @@ -256,6 +259,8 @@ optDescrs = "Freeze Stage1 GHC." , Option [] ["freeze2"] (NoArg readFreeze2) "Freeze Stage2 GHC." + , Option [] ["skip-depends"] (NoArg readSkipDepends) + "Skip rebuilding dependency information." , Option [] ["bignum"] (OptArg readBignum "BIGNUM") "Select GHC BigNum backend: native, gmp, ffi." , Option [] ["progress-info"] (OptArg readProgressInfo "STYLE") @@ -361,6 +366,9 @@ lookupFreeze1 = freeze1 . lookupExtra defaultCommandLineArgs lookupFreeze2 :: Map.HashMap TypeRep Dynamic -> Bool lookupFreeze2 = freeze2 . lookupExtra defaultCommandLineArgs +lookupSkipDepends :: Map.HashMap TypeRep Dynamic -> Bool +lookupSkipDepends = skipDepends . lookupExtra defaultCommandLineArgs + cmdBignum :: Action (Maybe String) cmdBignum = bignum <$> cmdLineArgs ===================================== hadrian/src/Main.hs ===================================== @@ -35,7 +35,10 @@ main = do ] ++ [ (RebuildLater, buildRoot -/- "stage1/**") | CommandLine.lookupFreeze2 argsMap - ] + ] ++ + (if CommandLine.lookupSkipDepends argsMap + then [(RebuildLater, buildRoot -/- "**/.dependencies.mk"), (RebuildLater, buildRoot -/- "**/.dependencies")] + else []) cwd <- getCurrentDirectory shakeColor <- shouldUseColor View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/348f19c00d0f14112e3845b4654b8ab9cb694db9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/348f19c00d0f14112e3845b4654b8ab9cb694db9 You're receiving 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 Jul 8 18:59:47 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 08 Jul 2020 14:59:47 -0400 Subject: [Git][ghc/ghc][wip/winio] 141 commits: Improve handling of data type return kinds Message-ID: <5f0617a3cb114_80b3f84960bea1423772a7@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/winio at Glasgow Haskell Compiler / GHC Commits: 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - cf3c9b03 by Tamar Christina at 2020-07-08T13:32:07-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - cdf6eb79 by Tamar Christina at 2020-07-08T13:32:07-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - d6b9fc40 by Tamar Christina at 2020-07-08T14:58:02-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - cb5b7499 by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Small linker comment and ifdef cleanups - - - - - 8cc8a0f7 by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Flush event logs eagerly. - - - - - 5b149e1a by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 4c5bd53e by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Implement new Console API - - - - - 4a953be9 by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Add IOPort synchronization primitive - - - - - d7072e59 by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Add new io-manager cmdline options - - - - - b320722b by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 1c822755 by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - 10043d17 by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 9651ab6d by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Switch Testsuite to test winio by default - - - - - d74e88c8 by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Multiple refactorings and support changes. - - - - - 94ccdcc2 by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: core threaded I/O manager - - - - - 555efe8e by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: core non-threaded I/O manager - - - - - bca098f4 by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 1f19cd5a by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Relaxing some constraints in io-manager. - - - - - 1bf0fcbc by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - e5c4878e by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Remove some barf statements that are a bit strict. - - - - - b52a9a94 by Andreas Klebinger at 2020-07-08T14:58:07-04:00 winio: Expand comments describing non-threaded loop - - - - - d0cc6653 by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: fix FileSize unstat-able handles - - - - - dea10a19 by Tamar Christina at 2020-07-08T14:58:07-04:00 winio: Implement new tempfile routines for winio - - - - - 6f94d596 by Andreas Klebinger at 2020-07-08T14:58:07-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - 05f65c02 by Andreas Klebinger at 2020-07-08T14:58:07-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - 3f302ad7 by Andreas Klebinger at 2020-07-08T14:58:08-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - c3bcbee0 by Andreas Klebinger at 2020-07-08T14:58:08-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 48c651b1 by Andreas Klebinger at 2020-07-08T14:58:42-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - 72fec492 by Andreas Klebinger at 2020-07-08T14:58:44-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 162343ba by Andreas Klebinger at 2020-07-08T14:58:44-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - b97e9829 by Andreas Klebinger at 2020-07-08T14:58:44-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 6263c22d by Andreas Klebinger at 2020-07-08T14:58:44-04:00 winio: Remove debug event log trace - - - - - e87655cf by Andreas Klebinger at 2020-07-08T14:58:44-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 448ad259 by Andreas Klebinger at 2020-07-08T14:58:44-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - 57754fc9 by Andreas Klebinger at 2020-07-08T14:58:44-04:00 winio: Update output of T9681 since we now actually run it. - - - - - e2764c5c by Andreas Klebinger at 2020-07-08T14:58:44-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 2c30cafb by Andreas Klebinger at 2020-07-08T14:58:44-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - ae27ef79 by Andreas Klebinger at 2020-07-08T14:58:44-04:00 winio: Assign thread labels to IOManager threads. - - - - - 462307a1 by Andreas Klebinger at 2020-07-08T14:58:44-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - c84c1ba2 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - cb70d147 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - dc231a32 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Add comments/cleanup an import in base - - - - - 30754f32 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - 66a2af39 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Make last_event a local variable - - - - - 9257ce5d by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 85d56030 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - 8e9b937f by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - e4504115 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - 7964eaaf by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 576e57c4 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - 68d22b2a by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - d4717f23 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Update placeholder comment with actual function name. - - - - - 2a541a40 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Always lock win32 event queue - - - - - 07ea3c19 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 250951fc by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 750b50d6 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3a5b1d61 by Tamar Christina at 2020-07-08T14:58:45-04:00 winio: Various fixes related to rebase and testdriver - - - - - dd22c99c by Tamar Christina at 2020-07-08T14:58:45-04:00 winio: Fix rebase artifacts - - - - - 660b7581 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - 3cee740d by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - a4c579de by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 34762dcb by Tamar Christina at 2020-07-08T14:58:45-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 19495735 by Ben Gamari at 2020-07-08T14:58:45-04:00 winio: Minor comments/renamings - - - - - 933a0262 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 856deec0 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Small refactor in withOverlappedEx - - - - - 2c1b2456 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: A few comments and commented out dbxIO - - - - - cb4d1deb by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - a22e2af1 by Tamar Christina at 2020-07-08T14:58:45-04:00 winio: revert BHandle changes. - - - - - 9493716f by Ben Gamari at 2020-07-08T14:58:45-04:00 winio: Fix imports - - - - - dd4b4577 by Tamar Christina at 2020-07-08T14:58:45-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - 11032741 by Ben Gamari at 2020-07-08T14:58:45-04:00 winio: Only compile sources on Windows - - - - - 3889b2a6 by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 52114c0e by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - cecaa0cc by Andreas Klebinger at 2020-07-08T14:58:45-04:00 winio: Deduplicate openFile logic - - - - - 49b99d0f by Tamar Christina at 2020-07-08T14:58:46-04:00 winio: fix -werror issue in encoding file - - - - - acce0592 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - c7ad1fd7 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: add a note about file locking in the RTS. - - - - - d6a9c25a by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Add version to @since annotation - - - - - 530818d6 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - f4193f0d by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - a1a2642c by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 22e6b2d5 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 54434bdd by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Make it explicit that we only create one IO manager - - - - - 455a1325 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Note why we don't use blocking waits. - - - - - cc6e355c by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Remove commented out pragma - - - - - e122e685 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - cd37bb57 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Rename SmartHandles to StdHandles - - - - - 42f1f101 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 2a6e604f by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Update IOPort haddocks. - - - - - fcb9b00a by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Add a note cross reference - - - - - 9de44cbd by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - 985dea4f by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - 2fd02493 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Remove historical todos - - - - - 39a84aeb by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Update note, remove debugging pragma. - - - - - 4b0d504b by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - 543c3b0c by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Remove obsolete comment about cond. variables - - - - - 40ef4e9e by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: fix initial linux validate build - - - - - 6400dfdf by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Fix ThreadDelay001 CPP - - - - - c8a95929 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Fix openFile009 merge conflict leftover - - - - - b381917f by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - 20b8ef2a by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - 816f5307 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 6b833fea by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - d5688ad6 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - daf49012 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: Also accept T7037 stderr - - - - - 46c8a571 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: fix cabal04 by filtering rts args - - - - - 1e226ce5 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: fix cabal01 by accepting expected stderr - - - - - d52f9cc3 by Andreas Klebinger at 2020-07-08T14:58:46-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - ffddb278 by Andreas Klebinger at 2020-07-08T14:58:47-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - f3739f43 by Andreas Klebinger at 2020-07-08T14:58:47-04:00 winio: fix tempfiles test on linux - - - - - 6c40e234 by Andreas Klebinger at 2020-07-08T14:58:47-04:00 winio: Accept accepted stderr for T3807 - - - - - fd992cfc by Andreas Klebinger at 2020-07-08T14:58:47-04:00 winio: Accept accepted stderr for linker_unload - - - - - 00806f1a by Andreas Klebinger at 2020-07-08T14:58:47-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 08fe2489 by Tamar Christina at 2020-07-08T14:58:47-04:00 winio: clarify wording on conditional variables. - - - - - f7ab4657 by Tamar Christina at 2020-07-08T14:58:47-04:00 winio: clarify comment on cooked mode. - - - - - 21b71f6b by Tamar Christina at 2020-07-08T14:58:47-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 28 changed files: - Makefile - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Driver.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Info.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f20bdee3cb580c4ec3adac3ed6155370bdbf6b5f...21b71f6bb5ab51d89fdb2c1cb07d624c61605619 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f20bdee3cb580c4ec3adac3ed6155370bdbf6b5f...21b71f6bb5ab51d89fdb2c1cb07d624c61605619 You're receiving 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 Jul 8 19:02:55 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 08 Jul 2020 15:02:55 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] 5 commits: testsuite: Add test for #18151 Message-ID: <5f06185f675f8_80b3f84960bea142377477@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: eda32b7a by Ben Gamari at 2020-07-08T15:02:32-04:00 testsuite: Add test for #18151 - - - - - 2e17d60c by Ben Gamari at 2020-07-08T15:02:46-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. (cherry picked from commit 2b89ca5b850b4097447cc4908cbb0631011ce979) - - - - - 433341fb by Travis Whitaker at 2020-07-08T15:02:48-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. (cherry picked from commit 67738db10010fd28a8e997b5c8f83ea591b88a0e) - - - - - 98a053a9 by Ben Gamari at 2020-07-08T15:02:48-04:00 More release notes - - - - - 1fdd6165 by GHC GitLab CI at 2020-07-08T15:02:48-04:00 Bump to 8.8.4, RELEASE=YES - - - - - 13 changed files: - compiler/deSugar/DsExpr.hs - compiler/ghc.mk - configure.ac - docs/users_guide/8.8.4-notes.rst - ghc/ghc.mk - hadrian/cfg/system.config.in - hadrian/src/Expression.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Packages.hs - mk/config.mk.in - + testsuite/tests/deSugar/should_run/T18151.hs - + testsuite/tests/deSugar/should_run/T18151.stdout - testsuite/tests/deSugar/should_run/all.T Changes: ===================================== compiler/deSugar/DsExpr.hs ===================================== @@ -331,26 +331,47 @@ Then we get That 'g' in the 'in' part is an evidence variable, and when converting to core it must become a CO. -Operator sections. At first it looks as if we can convert -\begin{verbatim} - (expr op) -\end{verbatim} -to -\begin{verbatim} - \x -> op expr x -\end{verbatim} + +Note [Desugaring operator sections] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +At first it looks as if we can convert + + (expr `op`) + +naively to + + \x -> op expr x But no! expr might be a redex, and we can lose laziness badly this way. Consider -\begin{verbatim} - map (expr op) xs -\end{verbatim} -for example. So we convert instead to -\begin{verbatim} - let y = expr in \x -> op y x -\end{verbatim} -If \tr{expr} is actually just a variable, say, then the simplifier -will sort it out. + + map (expr `op`) xs + +for example. If expr were a redex then eta-expanding naively would +result in multiple evaluations where the user might only have expected one. + +So we convert instead to + + let y = expr in \x -> op y x + +Also, note that we must do this for both right and (perhaps surprisingly) left +sections. Why are left sections necessary? Consider the program (found in #18151), + + seq (True `undefined`) () + +according to the Haskell Report this should reduce to () (as it specifies +desugaring via eta expansion). However, if we fail to eta expand we will rather +bottom. Consequently, we must eta expand even in the case of a left section. + +If `expr` is actually just a variable, say, then the simplifier +will inline `y`, eliminating the redundant `let`. + +Note that this works even in the case that `expr` is unlifted. In this case +bindNonRec will automatically do the right thing, giving us: + + case expr of y -> (\x -> op y x) + +See #18151. -} ds_expr _ e@(OpApp _ e1 op e2) @@ -359,17 +380,35 @@ ds_expr _ e@(OpApp _ e1 op e2) ; dsWhenNoErrs (mapM dsLExprNoLP [e1, e2]) (\exprs' -> mkCoreAppsDs (text "opapp" <+> ppr e) op' exprs') } -ds_expr _ (SectionL _ expr op) -- Desugar (e !) to ((!) e) - = do { op' <- dsLExpr op - ; dsWhenNoErrs (dsLExprNoLP expr) - (\expr' -> mkCoreAppDs (text "sectionl" <+> ppr expr) op' expr') } - --- dsLExpr (SectionR op expr) -- \ x -> op x expr +-- dsExpr (SectionL op expr) === (expr `op`) ~> \y -> op expr y +-- +-- See Note [Desugaring operator sections]. +-- N.B. this also must handle postfix operator sections due to -XPostfixOperators. +ds_expr _ e@(SectionL _ expr op) = do + core_op <- dsLExpr op + x_core <- dsLExpr expr + case splitFunTys (exprType core_op) of + -- Binary operator section + (x_ty:y_ty:_, _) -> do + dsWhenNoErrs + (mapM newSysLocalDsNoLP [x_ty, y_ty]) + (\[x_id, y_id] -> + bindNonRec x_id x_core + $ Lam y_id (mkCoreAppsDs (text "sectionl" <+> ppr e) + core_op [Var x_id, Var y_id])) + + -- Postfix operator section + (_:_, _) -> do + return $ mkCoreAppDs (text "sectionl" <+> ppr e) core_op x_core + + _ -> pprPanic "dsExpr(SectionL)" (ppr e) + +-- dsExpr (SectionR op expr) === (`op` expr) ~> \x -> op x expr +-- +-- See Note [Desugaring operator sections]. ds_expr _ e@(SectionR _ op expr) = do core_op <- dsLExpr op - -- for the type of x, we need the type of op's 2nd argument let (x_ty:y_ty:_, _) = splitFunTys (exprType core_op) - -- See comment with SectionL y_core <- dsLExpr expr dsWhenNoErrs (mapM newSysLocalDsNoLP [x_ty, y_ty]) (\[x_id, y_id] -> bindNonRec y_id y_core $ ===================================== compiler/ghc.mk ===================================== @@ -326,6 +326,12 @@ ifeq "$(GhcThreaded)" "YES" compiler_stage2_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS endif +# If the bootstrapping GHC supplies the threaded RTS, then we can have a +# threaded stage 1 too. +ifeq "$(GhcThreadedRts)" "YES" +compiler_stage1_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS +endif + ifeq "$(GhcWithNativeCodeGen)" "YES" compiler_stage1_CONFIGURE_OPTS += --flags=ncg compiler_stage2_CONFIGURE_OPTS += --flags=ncg ===================================== configure.ac ===================================== @@ -13,10 +13,10 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.3], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.8.4], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # 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 @@ -127,6 +127,9 @@ dnl CC_STAGE0 is like the "previous" variable CC (inherited by CC_STAGE[123]) dnl but instead used by stage0 for bootstrapping stage1 AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)]) +dnl RTS ways supplied by the bootstrapping compiler. +AC_ARG_VAR(RTS_WAYS_STAGE0, [RTS ways]) + if test "$WithGhc" != ""; then FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl @@ -150,6 +153,17 @@ if test "$WithGhc" != ""; then BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command]) BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) + BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) + + dnl Check whether or not the bootstrapping GHC has a threaded RTS. This + dnl determines whether or not we can have a threaded stage 1. + dnl See Note [Linking ghc-bin against threaded stage0 RTS] in + dnl hadrian/src/Settings/Packages.hs for details. + if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null; then + AC_SUBST(GhcThreadedRts, YES) + else + AC_SUBST(GhcThreadedRts, NO) + fi fi dnl ** Must have GHC to build GHC @@ -1372,6 +1386,7 @@ Configure completed successfully. echo "\ Bootstrapping using : $WithGhc which is version : $GhcVersion + with threaded RTS? : $GhcThreadedRts " if test "x$CC_LLVM_BACKEND" = "x1"; then ===================================== docs/users_guide/8.8.4-notes.rst ===================================== @@ -6,13 +6,27 @@ Release notes for version 8.8.4 GHC 8.8.4 is a minor release intended to fix regressions and minor bugs in the 8.8.1, 8.8.2 and 8.8.3 releases. +Like previous releases in the 8.8 series, the :ghc-flag:`LLVM backend <-fllvm>` +of this release is to be used with LLVM 7. + Highlights ---------- -- Fix a bug in process creation on Windows (:ghc-ticket:`17926`). +- Fixes a bug in process creation on Windows (:ghc-ticket:`17926`). + +- Works around a Linux kernel bug in the implementation of ``timerfd``\s (:ghc-ticket:`18033`). + +- Fixes a few linking issues affecting ARM + +- Fixes "missing interface file" error triggered by some uses of ``Ordering`` (:ghc-ticket:`18185`) + +- Fixes an integer overflow in the compact-normal-form import implementation (:ghc-ticket:`16992`) + +- ``configure`` now accepts ``--enable-numa`` flag to enable/disable ``numactl`` support on Linux. -- Workaround a Linux kernel bug in the implementation of ``timerfd``\s (:ghc-ticket:`18033`). +- Fixes potentially lost sharing due to the desugaring of left operator sections (:ghc-ticket:`18151`). +- Fixes a build-system bug resulting in potential miscompilation by unregisteised compilers (:ghc-ticket:`18024`) Known issues ------------ ===================================== ghc/ghc.mk ===================================== @@ -63,6 +63,15 @@ ghc_stage2_MORE_HC_OPTS += -threaded ghc_stage3_MORE_HC_OPTS += -threaded endif +# If stage 0 supplies a threaded RTS, we can use it for stage 1. +# See Note [Linking ghc-bin against threaded stage0 RTS] in +# hadrian/src/Settings/Packages.hs for details. +ifeq "$(GhcThreadedRts)" "YES" +ghc_stage1_MORE_HC_OPTS += -threaded +else +ghc_stage1_CONFIGURE_OPTS += -f-threaded +endif + ifeq "$(GhcProfiled)" "YES" ghc_stage2_PROGRAM_WAY = p endif ===================================== hadrian/cfg/system.config.in ===================================== @@ -77,6 +77,8 @@ ghc-major-version = @GhcMajVersion@ ghc-minor-version = @GhcMinVersion@ ghc-patch-level = @GhcPatchLevel@ +bootstrap-threaded-rts = @GhcThreadedRts@ + supports-this-unit-id = @SUPPORTS_THIS_UNIT_ID@ project-name = @ProjectName@ ===================================== hadrian/src/Expression.hs ===================================== @@ -6,8 +6,8 @@ module Expression ( expr, exprIO, arg, remove, -- ** Predicates - (?), stage, stage0, stage1, stage2, notStage0, package, notPackage, - libraryPackage, builder, way, input, inputs, output, outputs, + (?), stage, stage0, stage1, stage2, notStage0, threadedBootstrapper, + package, notPackage, libraryPackage, builder, way, input, inputs, output, outputs, -- ** Evaluation interpret, interpretInContext, @@ -26,6 +26,7 @@ import Base import Builder import Context hiding (stage, package, way) import Expression.Type +import Oracles.Flag import Hadrian.Expression hiding (Expr, Predicate, Args) import Hadrian.Haskell.Cabal.Type import Hadrian.Oracles.Cabal @@ -83,6 +84,19 @@ instance BuilderPredicate a => BuilderPredicate (FilePath -> a) where way :: Way -> Predicate way w = (w ==) <$> getWay +{- +Note [Stage Names] +~~~~~~~~~~~~~~~~~~ + +Code referring to specific stages can be a bit tricky. In Hadrian, the stages +have the same names they carried in the autoconf build system, but they are +often referred to by the stage used to construct them. For example, the stage 1 +artifacts will be placed in _build/stage0, because they are constructed by the +stage 0 compiler. The stage predicates in this module behave the same way, +'stage0' will return 'True' while stage 0 is being used to build the stage 1 +compiler. +-} + -- | Is the build currently in stage 0? stage0 :: Predicate stage0 = stage Stage0 @@ -99,6 +113,13 @@ stage2 = stage Stage2 notStage0 :: Predicate notStage0 = notM stage0 +-- | Whether or not the bootstrapping compiler provides a threaded RTS. We need +-- to know this when building stage 1, since stage 1 links against the +-- compiler's RTS ways. See Note [Linking ghc-bin against threaded stage0 RTS] +-- in Settings.Packages for details. +threadedBootstrapper :: Predicate +threadedBootstrapper = expr (flag BootstrapThreadedRts) + -- | Is a certain package /not/ built right now? notPackage :: Package -> Predicate notPackage = notM . package ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -21,6 +21,7 @@ data Flag = ArSupportsAtFile | WithLibdw | HaveLibMingwEx | UseSystemFfi + | BootstrapThreadedRts -- Note, if a flag is set to empty string we treat it as set to NO. This seems -- fragile, but some flags do behave like this, e.g. GccIsClang. @@ -39,6 +40,7 @@ flag f = do WithLibdw -> "with-libdw" HaveLibMingwEx -> "have-lib-mingw-ex" UseSystemFfi -> "use-system-ffi" + BootstrapThreadedRts -> "bootstrap-threaded-rts" value <- lookupValueOrError configFile key when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag " ++ quote (key ++ " = " ++ value) ++ " cannot be parsed." ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -85,10 +85,24 @@ packageArgs = do , builder (Cabal Flags) ? mconcat [ ghcWithInterpreter ? notStage0 ? arg "ghci" , flag CrossCompiling ? arg "-terminfo" - -- the 'threaded' flag is True by default, but - -- let's record explicitly that we link all ghc - -- executables with the threaded runtime. - , arg "threaded" ] ] + -- Note [Linking ghc-bin against threaded stage0 RTS] + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- We must maintain the invariant that GHCs linked with '-threaded' + -- are built with '-optc=-DTHREADED_RTS', otherwise we'll end up + -- with a GHC that can use the threaded runtime, but contains some + -- non-thread-safe functions. See + -- https://gitlab.haskell.org/ghc/ghc/issues/18024 for an example of + -- the sort of issues this can cause. + , ifM stage0 + -- We build a threaded stage 1 if the bootstrapping compiler + -- supports it. + (ifM threadedBootstrapper + (arg "threaded") + (arg "-threaded")) + -- We build a threaded stage N. + (arg "threaded") + ] + ] -------------------------------- ghcPkg -------------------------------- , package ghcPkg ? ===================================== mk/config.mk.in ===================================== @@ -199,6 +199,9 @@ endif # `GhcUnregisterised` mode doesn't allow that. GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO)) +# Whether or not the bootstrapping GHC supplies a threaded RTS. +GhcThreadedRts = @GhcThreadedRts@ + # Whether to include GHCi in the compiler. Depends on whether the RTS linker # has support for this OS/ARCH combination. ===================================== testsuite/tests/deSugar/should_run/T18151.hs ===================================== @@ -0,0 +1,10 @@ +-- According to the Report this should reduce to (). However, in #18151 it was +-- reported that GHC bottoms. +x :: () +x = seq (True `undefined`) () +{-# NOINLINE x #-} + +main :: IO () +main = do + print x + ===================================== testsuite/tests/deSugar/should_run/T18151.stdout ===================================== @@ -0,0 +1 @@ +() \ No newline at end of file ===================================== testsuite/tests/deSugar/should_run/all.T ===================================== @@ -63,3 +63,4 @@ test('T11601', exit_code(1), compile_and_run, ['']) test('T11747', normal, compile_and_run, ['-dcore-lint']) test('T12595', normal, compile_and_run, ['']) test('T13285', normal, compile_and_run, ['']) +test('T18151', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/927e8c91d53d9d0c36debfd57fd1f30fa04e6b9a...1fdd616527070b0b09661f78363c176f35049d9c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/927e8c91d53d9d0c36debfd57fd1f30fa04e6b9a...1fdd616527070b0b09661f78363c176f35049d9c You're receiving 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 Jul 8 19:06:41 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 08 Jul 2020 15:06:41 -0400 Subject: [Git][ghc/ghc][wip/winio] winio: Bump submodules Message-ID: <5f061941aef96_80bda8bdb4237935f@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/winio at Glasgow Haskell Compiler / GHC Commits: 5542c1b2 by Ben Gamari at 2020-07-08T15:06:26-04:00 winio: Bump submodules - - - - - 1 changed file: - libraries/Cabal Changes: ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit 8dc7f0db292ff1a5b1316127e3652d06ab51f3ad +Subproject commit 32dad5c1cf70d65ecb93b0ec214445cf9c9f6615 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5542c1b232f7427f93056e731980fd8e8837ca31 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5542c1b232f7427f93056e731980fd8e8837ca31 You're receiving 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 Jul 9 00:36:55 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 08 Jul 2020 20:36:55 -0400 Subject: [Git][ghc/ghc][master] hadrian: add flag to skip rebuilding dependency information #17636 Message-ID: <5f0666a796e14_80b114013dc239712f@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - 4 changed files: - hadrian/README.md - hadrian/doc/make.md - hadrian/src/CommandLine.hs - hadrian/src/Main.hs Changes: ===================================== hadrian/README.md ===================================== @@ -104,6 +104,8 @@ simply drop the `--freeze1` flag and Hadrian will rebuild all out-of-date files. * `--freeze2`: just like `--freeze1` but tell Hadrian to additionally freeze Stage2 GHC. +* `--skip-depends`: skips rebuilding Haskell module dependency files. + * `--integer-simple`: build GHC using the `integer-simple` integer library (instead of `integer-gmp`). ===================================== hadrian/doc/make.md ===================================== @@ -208,3 +208,17 @@ time you fire up a build. This is not possible with the Make build system. # Hadrian build nofib # builds the compiler and everything we need if necessary, too ``` + +- `make FAST=YES` + + Partially supported in hadrian with the `--skip-depends` argument. Since + hadrian is not directory aware some of the features of `FAST=YES` are not + replicated. + + ```sh + # Make + make FAST=YES + + # Hadrian + build --skip-depends + ``` ===================================== hadrian/src/CommandLine.hs ===================================== @@ -1,5 +1,5 @@ module CommandLine ( - optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2, + optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2, lookupSkipDepends, cmdBignum, cmdBignumCheck, cmdProgressInfo, cmdConfigure, cmdCompleteSetting, cmdDocsArgs, lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs, cmdPrefix @@ -26,6 +26,7 @@ data CommandLineArgs = CommandLineArgs , flavour :: Maybe String , freeze1 :: Bool , freeze2 :: Bool + , skipDepends :: Bool , bignum :: Maybe String , bignumCheck :: Bool , progressInfo :: ProgressInfo @@ -43,6 +44,7 @@ defaultCommandLineArgs = CommandLineArgs , flavour = Nothing , freeze1 = False , freeze2 = False + , skipDepends = False , bignum = Nothing , bignumCheck = False , progressInfo = Brief @@ -114,9 +116,10 @@ readBuildRoot ms = set :: BuildRoot -> CommandLineArgs -> CommandLineArgs set flag flags = flags { buildRoot = flag } -readFreeze1, readFreeze2 :: Either String (CommandLineArgs -> CommandLineArgs) +readFreeze1, readFreeze2, readSkipDepends :: Either String (CommandLineArgs -> CommandLineArgs) readFreeze1 = Right $ \flags -> flags { freeze1 = True } readFreeze2 = Right $ \flags -> flags { freeze1 = True, freeze2 = True } +readSkipDepends = Right $ \flags -> flags { skipDepends = True } readProgressInfo :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) readProgressInfo ms = @@ -256,6 +259,8 @@ optDescrs = "Freeze Stage1 GHC." , Option [] ["freeze2"] (NoArg readFreeze2) "Freeze Stage2 GHC." + , Option [] ["skip-depends"] (NoArg readSkipDepends) + "Skip rebuilding dependency information." , Option [] ["bignum"] (OptArg readBignum "BIGNUM") "Select GHC BigNum backend: native, gmp, ffi." , Option [] ["progress-info"] (OptArg readProgressInfo "STYLE") @@ -361,6 +366,9 @@ lookupFreeze1 = freeze1 . lookupExtra defaultCommandLineArgs lookupFreeze2 :: Map.HashMap TypeRep Dynamic -> Bool lookupFreeze2 = freeze2 . lookupExtra defaultCommandLineArgs +lookupSkipDepends :: Map.HashMap TypeRep Dynamic -> Bool +lookupSkipDepends = skipDepends . lookupExtra defaultCommandLineArgs + cmdBignum :: Action (Maybe String) cmdBignum = bignum <$> cmdLineArgs ===================================== hadrian/src/Main.hs ===================================== @@ -35,7 +35,10 @@ main = do ] ++ [ (RebuildLater, buildRoot -/- "stage1/**") | CommandLine.lookupFreeze2 argsMap - ] + ] ++ + (if CommandLine.lookupSkipDepends argsMap + then [(RebuildLater, buildRoot -/- "**/.dependencies.mk"), (RebuildLater, buildRoot -/- "**/.dependencies")] + else []) cwd <- getCurrentDirectory shakeColor <- shouldUseColor View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3033e0e4940e6ecc43f478f1dcfbd0c3cb1e3ef8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3033e0e4940e6ecc43f478f1dcfbd0c3cb1e3ef8 You're receiving 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 Jul 9 01:32:47 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 08 Jul 2020 21:32:47 -0400 Subject: [Git][ghc/ghc][wip/angerman/fix-int-gmp] 2 commits: hadrian: add flag to skip rebuilding dependency information #17636 Message-ID: <5f0673bf35f68_80b3f849ba1b9402398465@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/fix-int-gmp at Glasgow Haskell Compiler / GHC Commits: 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - e5428393 by Moritz Angermann at 2020-07-08T21:32:44-04:00 fix gmp selection - - - - - 5 changed files: - hadrian/README.md - hadrian/doc/make.md - hadrian/src/CommandLine.hs - hadrian/src/Main.hs - libraries/ghc-bignum/gmp/ghc.mk Changes: ===================================== hadrian/README.md ===================================== @@ -104,6 +104,8 @@ simply drop the `--freeze1` flag and Hadrian will rebuild all out-of-date files. * `--freeze2`: just like `--freeze1` but tell Hadrian to additionally freeze Stage2 GHC. +* `--skip-depends`: skips rebuilding Haskell module dependency files. + * `--integer-simple`: build GHC using the `integer-simple` integer library (instead of `integer-gmp`). ===================================== hadrian/doc/make.md ===================================== @@ -208,3 +208,17 @@ time you fire up a build. This is not possible with the Make build system. # Hadrian build nofib # builds the compiler and everything we need if necessary, too ``` + +- `make FAST=YES` + + Partially supported in hadrian with the `--skip-depends` argument. Since + hadrian is not directory aware some of the features of `FAST=YES` are not + replicated. + + ```sh + # Make + make FAST=YES + + # Hadrian + build --skip-depends + ``` ===================================== hadrian/src/CommandLine.hs ===================================== @@ -1,5 +1,5 @@ module CommandLine ( - optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2, + optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2, lookupSkipDepends, cmdBignum, cmdBignumCheck, cmdProgressInfo, cmdConfigure, cmdCompleteSetting, cmdDocsArgs, lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs, cmdPrefix @@ -26,6 +26,7 @@ data CommandLineArgs = CommandLineArgs , flavour :: Maybe String , freeze1 :: Bool , freeze2 :: Bool + , skipDepends :: Bool , bignum :: Maybe String , bignumCheck :: Bool , progressInfo :: ProgressInfo @@ -43,6 +44,7 @@ defaultCommandLineArgs = CommandLineArgs , flavour = Nothing , freeze1 = False , freeze2 = False + , skipDepends = False , bignum = Nothing , bignumCheck = False , progressInfo = Brief @@ -114,9 +116,10 @@ readBuildRoot ms = set :: BuildRoot -> CommandLineArgs -> CommandLineArgs set flag flags = flags { buildRoot = flag } -readFreeze1, readFreeze2 :: Either String (CommandLineArgs -> CommandLineArgs) +readFreeze1, readFreeze2, readSkipDepends :: Either String (CommandLineArgs -> CommandLineArgs) readFreeze1 = Right $ \flags -> flags { freeze1 = True } readFreeze2 = Right $ \flags -> flags { freeze1 = True, freeze2 = True } +readSkipDepends = Right $ \flags -> flags { skipDepends = True } readProgressInfo :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) readProgressInfo ms = @@ -256,6 +259,8 @@ optDescrs = "Freeze Stage1 GHC." , Option [] ["freeze2"] (NoArg readFreeze2) "Freeze Stage2 GHC." + , Option [] ["skip-depends"] (NoArg readSkipDepends) + "Skip rebuilding dependency information." , Option [] ["bignum"] (OptArg readBignum "BIGNUM") "Select GHC BigNum backend: native, gmp, ffi." , Option [] ["progress-info"] (OptArg readProgressInfo "STYLE") @@ -361,6 +366,9 @@ lookupFreeze1 = freeze1 . lookupExtra defaultCommandLineArgs lookupFreeze2 :: Map.HashMap TypeRep Dynamic -> Bool lookupFreeze2 = freeze2 . lookupExtra defaultCommandLineArgs +lookupSkipDepends :: Map.HashMap TypeRep Dynamic -> Bool +lookupSkipDepends = skipDepends . lookupExtra defaultCommandLineArgs + cmdBignum :: Action (Maybe String) cmdBignum = bignum <$> cmdLineArgs ===================================== hadrian/src/Main.hs ===================================== @@ -35,7 +35,10 @@ main = do ] ++ [ (RebuildLater, buildRoot -/- "stage1/**") | CommandLine.lookupFreeze2 argsMap - ] + ] ++ + (if CommandLine.lookupSkipDepends argsMap + then [(RebuildLater, buildRoot -/- "**/.dependencies.mk"), (RebuildLater, buildRoot -/- "**/.dependencies")] + else []) cwd <- getCurrentDirectory shakeColor <- shouldUseColor ===================================== libraries/ghc-bignum/gmp/ghc.mk ===================================== @@ -77,11 +77,13 @@ endif endif UseIntreeGmp = NO +ifeq "$(GMP_ENABLED)" "YES" ifneq "$(HaveLibGmp)" "YES" ifneq "$(HaveFrameworkGMP)" "YES" UseIntreeGmp = YES endif endif +endif # gmp_wrappers.c includes "ghc-gmp.h" libraries/ghc-bignum/cbits/gmp_wrappers.c: libraries/ghc-bignum/include/ghc-gmp.h View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d4bc3c0eaf345a3ff020fa71ee97c6e8546a33a8...e54283931d4586e5001c8bb99ea90cdbc82e5746 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d4bc3c0eaf345a3ff020fa71ee97c6e8546a33a8...e54283931d4586e5001c8bb99ea90cdbc82e5746 You're receiving 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 Jul 9 02:01:18 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 08 Jul 2020 22:01:18 -0400 Subject: [Git][ghc/ghc][wip/angerman/out-of-range-reloc] 7 commits: hadrian: add flag to skip rebuilding dependency information #17636 Message-ID: <5f067a6e1c1d9_80b3f849ba1b94024001d2@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/out-of-range-reloc at Glasgow Haskell Compiler / GHC Commits: 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - 006ca3d2 by Moritz Angermann at 2020-07-08T22:01:15-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - eff4884e by Moritz Angermann at 2020-07-08T22:01:15-04:00 Cleanup - - - - - c75d67fb by Moritz Angermann at 2020-07-08T22:01:15-04:00 Cleanup (2) - - - - - c95b6d28 by Moritz Angermann at 2020-07-08T22:01:15-04:00 kill duplicate prot. It's an argument now. - - - - - 6245c02a by Moritz Angermann at 2020-07-08T22:01:15-04:00 Fixup MachO mmapForLinker call. - - - - - b7b17202 by Moritz Angermann at 2020-07-08T22:01:15-04:00 Drop aarch64_target check from rts/Linker.c - - - - - 12 changed files: - hadrian/README.md - hadrian/doc/make.md - hadrian/src/CommandLine.hs - hadrian/src/Main.hs - rts/Linker.c - rts/LinkerInternals.h - rts/linker/Elf.c - rts/linker/LoadArchive.c - rts/linker/M32Alloc.c - rts/linker/MachO.c - rts/linker/SymbolExtras.c - rts/linker/elf_got.c Changes: ===================================== hadrian/README.md ===================================== @@ -104,6 +104,8 @@ simply drop the `--freeze1` flag and Hadrian will rebuild all out-of-date files. * `--freeze2`: just like `--freeze1` but tell Hadrian to additionally freeze Stage2 GHC. +* `--skip-depends`: skips rebuilding Haskell module dependency files. + * `--integer-simple`: build GHC using the `integer-simple` integer library (instead of `integer-gmp`). ===================================== hadrian/doc/make.md ===================================== @@ -208,3 +208,17 @@ time you fire up a build. This is not possible with the Make build system. # Hadrian build nofib # builds the compiler and everything we need if necessary, too ``` + +- `make FAST=YES` + + Partially supported in hadrian with the `--skip-depends` argument. Since + hadrian is not directory aware some of the features of `FAST=YES` are not + replicated. + + ```sh + # Make + make FAST=YES + + # Hadrian + build --skip-depends + ``` ===================================== hadrian/src/CommandLine.hs ===================================== @@ -1,5 +1,5 @@ module CommandLine ( - optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2, + optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2, lookupSkipDepends, cmdBignum, cmdBignumCheck, cmdProgressInfo, cmdConfigure, cmdCompleteSetting, cmdDocsArgs, lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs, cmdPrefix @@ -26,6 +26,7 @@ data CommandLineArgs = CommandLineArgs , flavour :: Maybe String , freeze1 :: Bool , freeze2 :: Bool + , skipDepends :: Bool , bignum :: Maybe String , bignumCheck :: Bool , progressInfo :: ProgressInfo @@ -43,6 +44,7 @@ defaultCommandLineArgs = CommandLineArgs , flavour = Nothing , freeze1 = False , freeze2 = False + , skipDepends = False , bignum = Nothing , bignumCheck = False , progressInfo = Brief @@ -114,9 +116,10 @@ readBuildRoot ms = set :: BuildRoot -> CommandLineArgs -> CommandLineArgs set flag flags = flags { buildRoot = flag } -readFreeze1, readFreeze2 :: Either String (CommandLineArgs -> CommandLineArgs) +readFreeze1, readFreeze2, readSkipDepends :: Either String (CommandLineArgs -> CommandLineArgs) readFreeze1 = Right $ \flags -> flags { freeze1 = True } readFreeze2 = Right $ \flags -> flags { freeze1 = True, freeze2 = True } +readSkipDepends = Right $ \flags -> flags { skipDepends = True } readProgressInfo :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) readProgressInfo ms = @@ -256,6 +259,8 @@ optDescrs = "Freeze Stage1 GHC." , Option [] ["freeze2"] (NoArg readFreeze2) "Freeze Stage2 GHC." + , Option [] ["skip-depends"] (NoArg readSkipDepends) + "Skip rebuilding dependency information." , Option [] ["bignum"] (OptArg readBignum "BIGNUM") "Select GHC BigNum backend: native, gmp, ffi." , Option [] ["progress-info"] (OptArg readProgressInfo "STYLE") @@ -361,6 +366,9 @@ lookupFreeze1 = freeze1 . lookupExtra defaultCommandLineArgs lookupFreeze2 :: Map.HashMap TypeRep Dynamic -> Bool lookupFreeze2 = freeze2 . lookupExtra defaultCommandLineArgs +lookupSkipDepends :: Map.HashMap TypeRep Dynamic -> Bool +lookupSkipDepends = skipDepends . lookupExtra defaultCommandLineArgs + cmdBignum :: Action (Maybe String) cmdBignum = bignum <$> cmdLineArgs ===================================== hadrian/src/Main.hs ===================================== @@ -35,7 +35,10 @@ main = do ] ++ [ (RebuildLater, buildRoot -/- "stage1/**") | CommandLine.lookupFreeze2 argsMap - ] + ] ++ + (if CommandLine.lookupSkipDepends argsMap + then [(RebuildLater, buildRoot -/- "**/.dependencies.mk"), (RebuildLater, buildRoot -/- "**/.dependencies")] + else []) cwd <- getCurrentDirectory shakeColor <- shouldUseColor ===================================== rts/Linker.c ===================================== @@ -188,7 +188,7 @@ int ocTryLoad( ObjectCode* oc ); * * MAP_32BIT not available on OpenBSD/amd64 */ -#if defined(MAP_32BIT) && defined(x86_64_HOST_ARCH) +#if defined(MAP_32BIT) && (defined(x86_64_HOST_ARCH) || defined(aarch64_HOST_ARCH)) #define MAP_LOW_MEM #define TRY_MAP_32BIT MAP_32BIT #else @@ -214,10 +214,22 @@ int ocTryLoad( ObjectCode* oc ); * systems, we have to pick a base address in the low 2Gb of the address space * and try to allocate memory from there. * + * The same holds for aarch64, where the default, even with PIC, model + * is 4GB. The linker is free to emit AARCH64_ADR_PREL_PG_HI21 + * relocations. + * * We pick a default address based on the OS, but also make this * configurable via an RTS flag (+RTS -xm) */ -#if defined(MAP_32BIT) || DEFAULT_LINKER_ALWAYS_PIC + +#if (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH)) +// Try to use stg_upd_frame_info as the base. We need to be within +-4GB of that +// address, otherwise we violate the aarch64 memory model. Any object we load +// can potentially reference any of the ones we bake into the binary (and list) +// in RtsSymbols. Thus we'll need to be within +-4GB of those, +// stg_upd_frame_info is a good candidate as it's referenced often. +#define MMAP_32BIT_BASE_DEFAULT (void*)&stg_upd_frame_info; +#elif defined(MAP_32BIT) || DEFAULT_LINKER_ALWAYS_PIC // Try to use MAP_32BIT #define MMAP_32BIT_BASE_DEFAULT 0 #else @@ -1040,11 +1052,47 @@ resolveSymbolAddr (pathchar* buffer, int size, } #if RTS_LINKER_USE_MMAP + +/* ----------------------------------------------------------------------------- + Occationally we depend on mmap'd region being close to already mmap'd regions. + + Our static in-memory linker may be restricted by the architectures relocation + range. E.g. aarch64 has a +-4GB range for PIC code, thus we'd preferrably + get memory for the linker close to existing mappings. mmap on it's own is + free to return any memory location, independent of what the preferred + location argument indicates. + + For example mmap (via qemu) might give you addresses all over the available + memory range if the requested location is already occupied. + + mmap_next will do a linear search from the start page upwards to find a + suitable location that is as close as possible to the locations (proivded + via the first argument). + -------------------------------------------------------------------------- */ + +void* +mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { + if(addr == NULL) return mmap(addr, length, prot, flags, fd, offset); + // we are going to look for up to pageSize * 1024 * 1024 (4GB) from the + // address. + size_t pageSize = getPageSize(); + for(int i = (uintptr_t)addr & (pageSize-1) ? 1 : 0; i < 1024*1024; i++) { + void *target = (void*)(((uintptr_t)addr & ~(pageSize-1))+(i*pageSize)); + void *mem = mmap(target, length, prot, flags, fd, offset); + if(mem == NULL) return mem; + if(mem == target) return mem; + munmap(mem, length); + IF_DEBUG(linker && (i % 1024 == 0), + debugBelch("mmap_next failed to find suitable space in %p - %p\n", addr, target)); + } + return NULL; +} + // // Returns NULL on failure. // void * -mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset) +mmapForLinker (size_t bytes, uint32_t prot, uint32_t flags, int fd, int offset) { void *map_addr = NULL; void *result; @@ -1065,15 +1113,14 @@ mmap_again: map_addr = mmap_32bit_base; } - const int prot = PROT_READ | PROT_WRITE; IF_DEBUG(linker, debugBelch("mmapForLinker: \tprotection %#0x\n", prot)); IF_DEBUG(linker, debugBelch("mmapForLinker: \tflags %#0x\n", MAP_PRIVATE | tryMap32Bit | fixed | flags)); - result = mmap(map_addr, size, prot, - MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); + result = mmap_next(map_addr, size, prot, + MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); if (result == MAP_FAILED) { sysErrorBelch("mmap %" FMT_Word " bytes at %p",(W_)size,map_addr); @@ -1126,6 +1173,28 @@ mmap_again: goto mmap_again; } } +#elif (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH)) + // for aarch64 we need to make sure we stay within 4GB of the + // mmap_32bit_base, and we also do not want to update it. +// if (mmap_32bit_base != (void*)&stg_upd_frame_info) { + if (result == map_addr) { + mmap_32bit_base = (void*)((uintptr_t)map_addr + size); + } else { + // upper limit 4GB - size of the object file - 1mb wiggle room. + if(llabs((uintptr_t)result - (uintptr_t)&stg_upd_frame_info) > (2<<32) - size - (2<<20)) { + // not within range :( + debugTrace(DEBUG_linker, + "MAP_32BIT didn't work; gave us %lu bytes at 0x%p", + bytes, result); + munmap(result, size); + // TODO: some abort/mmap_32bit_base recomputation based on + // if mmap_32bit_base is changed, or still at stg_upd_frame_info + goto mmap_again; + } else { + mmap_32bit_base = (void*)((uintptr_t)result + size); + } + } +// } #endif IF_DEBUG(linker, @@ -1454,9 +1523,9 @@ preloadObjectFile (pathchar *path) * See also the misalignment logic for darwin below. */ #if defined(ios_HOST_OS) - image = mmap(NULL, fileSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); + image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); #else - image = mmap(NULL, fileSize, PROT_READ|PROT_WRITE|PROT_EXEC, + image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, fd, 0); #endif ===================================== rts/LinkerInternals.h ===================================== @@ -14,6 +14,7 @@ #if RTS_LINKER_USE_MMAP #include +void* mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset); #endif void printLoadedObjects(void); @@ -293,7 +294,7 @@ void exitLinker( void ); void freeObjectCode (ObjectCode *oc); SymbolAddr* loadSymbol(SymbolName *lbl, RtsSymbolInfo *pinfo); -void *mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset); +void *mmapForLinker (size_t bytes, uint32_t prot, uint32_t flags, int fd, int offset); void mmapForLinkerMarkExecutable (void *start, size_t len); void addProddableBlock ( ObjectCode* oc, void* start, int size ); ===================================== rts/linker/Elf.c ===================================== @@ -637,7 +637,7 @@ mapObjectFileSection (int fd, Elf_Word offset, Elf_Word size, pageOffset = roundDownToPage(offset); pageSize = roundUpToPage(offset-pageOffset+size); - p = mmapForLinker(pageSize, 0, fd, pageOffset); + p = mmapForLinker(pageSize, PROT_READ | PROT_WRITE, 0, fd, pageOffset); if (p == NULL) return NULL; *mapped_size = pageSize; *mapped_offset = pageOffset; @@ -709,7 +709,7 @@ ocGetNames_ELF ( ObjectCode* oc ) * address might be out of range for sections that are mmaped. */ alloc = SECTION_MMAP; - start = mmapForLinker(size, MAP_ANONYMOUS, -1, 0); + start = mmapForLinker(size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); mapped_start = start; mapped_offset = 0; mapped_size = roundUpToPage(size); @@ -751,8 +751,9 @@ ocGetNames_ELF ( ObjectCode* oc ) unsigned nstubs = numberOfStubsForSection(oc, i); unsigned stub_space = STUB_SIZE * nstubs; - void * mem = mmapForLinker(size+stub_space, MAP_ANON, -1, 0); - if( mem == NULL ) { + void * mem = mmapForLinker(size+stub_space, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + + if( mem == MAP_FAILED ) { barf("failed to mmap allocated memory to load section %d. " "errno = %d", i, errno); } @@ -841,6 +842,26 @@ ocGetNames_ELF ( ObjectCode* oc ) unsigned curSymbol = 0; + unsigned long common_size = 0; + unsigned long common_used = 0; + for(ElfSymbolTable *symTab = oc->info->symbolTables; + symTab != NULL; symTab = symTab->next) { + for (size_t j = 0; j < symTab->n_symbols; j++) { + ElfSymbol *symbol = &symTab->symbols[j]; + if (SHN_COMMON == symTab->symbols[j].elf_sym->st_shndx) { + common_size += symbol->elf_sym->st_size; + } + } + } + void * common_mem = NULL; + if(common_size > 0) { + common_mem = mmapForLinker(common_size, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, + -1, 0); + ASSERT(common_mem != NULL); + } + //TODO: we ignore local symbols anyway right? So we can use the // shdr[i].sh_info to get the index of the first non-local symbol // ie we should use j = shdr[i].sh_info @@ -876,12 +897,15 @@ ocGetNames_ELF ( ObjectCode* oc ) if (shndx == SHN_COMMON) { isLocal = false; - symbol->addr = stgCallocBytes(1, symbol->elf_sym->st_size, - "ocGetNames_ELF(COMMON)"); - /* - debugBelch("COMMON symbol, size %d name %s\n", - stab[j].st_size, nm); - */ + ASSERT(common_used < common_size); + ASSERT(common_mem); + symbol->addr = (void*)((uintptr_t)common_mem + common_used); + common_used += symbol->elf_sym->st_size; + ASSERT(common_used <= common_size); + + debugBelch("COMMON symbol, size %ld name %s allocated at %p\n", + symbol->elf_sym->st_size, nm, symbol->addr); + /* Pointless to do addProddableBlock() for this area, since the linker should never poke around in it. */ } else if ((ELF_ST_BIND(symbol->elf_sym->st_info) == STB_GLOBAL ===================================== rts/linker/LoadArchive.c ===================================== @@ -489,7 +489,7 @@ static HsInt loadArchive_ (pathchar *path) #if defined(darwin_HOST_OS) || defined(ios_HOST_OS) if (RTS_LINKER_USE_MMAP) - image = mmapForLinker(memberSize, MAP_ANONYMOUS, -1, 0); + image = mmapForLinker(memberSize, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); else { /* See loadObj() */ misalignment = machoGetMisalignment(f); @@ -548,7 +548,7 @@ while reading filename from `%" PATH_FMT "'", path); } DEBUG_LOG("Found GNU-variant file index\n"); #if RTS_LINKER_USE_MMAP - gnuFileIndex = mmapForLinker(memberSize + 1, MAP_ANONYMOUS, -1, 0); + gnuFileIndex = mmapForLinker(memberSize + 1, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); #else gnuFileIndex = stgMallocBytes(memberSize + 1, "loadArchive(image)"); #endif ===================================== rts/linker/M32Alloc.c ===================================== @@ -256,7 +256,7 @@ m32_alloc_page(void) m32_free_page_pool_size --; return page; } else { - struct m32_page_t *page = mmapForLinker(getPageSize(),MAP_ANONYMOUS,-1,0); + struct m32_page_t *page = mmapForLinker(getPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); if (page > (struct m32_page_t *) 0xffffffff) { barf("m32_alloc_page: failed to get allocation in lower 32-bits"); } @@ -280,7 +280,7 @@ m32_allocator_new(bool executable) // Preallocate the initial M32_MAX_PAGES to ensure that they don't // fragment the memory. size_t pgsz = getPageSize(); - char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES,MAP_ANONYMOUS,-1,0); + char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,-1,0); if (bigchunk == NULL) barf("m32_allocator_init: Failed to map"); @@ -396,7 +396,7 @@ m32_alloc(struct m32_allocator_t *alloc, size_t size, size_t alignment) if (m32_is_large_object(size,alignment)) { // large object size_t alsize = ROUND_UP(sizeof(struct m32_page_t), alignment); - struct m32_page_t *page = mmapForLinker(alsize+size,MAP_ANONYMOUS,-1,0); + struct m32_page_t *page = mmapForLinker(alsize+size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,-1,0); page->filled_page.size = alsize + size; m32_allocator_push_filled_list(&alloc->unprotected_list, (struct m32_page_t *) page); return (char*) page + alsize; ===================================== rts/linker/MachO.c ===================================== @@ -508,7 +508,7 @@ makeGot(ObjectCode * oc) { if(got_slots > 0) { oc->info->got_size = got_slots * sizeof(void*); - oc->info->got_start = mmap(NULL, oc->info->got_size, + oc->info->got_start = mmapForLinker(oc->info->got_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); @@ -1114,7 +1114,7 @@ ocBuildSegments_MachO(ObjectCode *oc) return 1; } - mem = mmapForLinker(size_compound, MAP_ANON, -1, 0); + mem = mmapForLinker(size_compound, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); if (NULL == mem) return 0; IF_DEBUG(linker, debugBelch("ocBuildSegments: allocating %d segments\n", n_activeSegments)); ===================================== rts/linker/SymbolExtras.c ===================================== @@ -79,7 +79,7 @@ int ocAllocateExtras(ObjectCode* oc, int count, int first, int bssSize) size_t n = roundUpToPage(oc->fileSize); bssSize = roundUpToAlign(bssSize, 8); size_t allocated_size = n + bssSize + extras_size; - void *new = mmapForLinker(allocated_size, MAP_ANONYMOUS, -1, 0); + void *new = mmapForLinker(allocated_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); if (new) { memcpy(new, oc->image, oc->fileSize); if (oc->imageMapped) { ===================================== rts/linker/elf_got.c ===================================== @@ -48,7 +48,7 @@ makeGot(ObjectCode * oc) { } if(got_slots > 0) { oc->info->got_size = got_slots * sizeof(void *); - void * mem = mmap(NULL, oc->info->got_size, + void * mem = mmapForLinker(oc->info->got_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b7e6c894a23ce937151c68a83b48740b6f385808...b7b1720236236068e2bed4cfe85918a1e712fc4a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b7e6c894a23ce937151c68a83b48740b6f385808...b7b1720236236068e2bed4cfe85918a1e712fc4a You're receiving 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 Jul 9 08:09:18 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 09 Jul 2020 04:09:18 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: hadrian: add flag to skip rebuilding dependency information #17636 Message-ID: <5f06d0ae60652_80b3f848e5b8658240558a@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - fa533a79 by Stefan Schulze Frielinghaus at 2020-07-09T04:09:11-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 709797c6 by Sylvain Henry at 2020-07-09T04:09:15-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - 7 changed files: - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Runtime/Heap/Inspect.hs - hadrian/README.md - hadrian/doc/make.md - hadrian/src/CommandLine.hs - hadrian/src/Main.hs - testsuite/tests/ghci.debugger/scripts/all.T Changes: ===================================== compiler/GHC/CmmToLlvm/CodeGen.hs ===================================== @@ -353,7 +353,7 @@ genCall (PrimTarget (MO_U_Mul2 w)) [dstH, dstL] [lhs, rhs] = runStmtsDecls $ do statement $ Store retL dstRegL statement $ Store retH dstRegH -genCall (PrimTarget (MO_S_Mul2 w)) [dstH, dstL] [lhs, rhs] = runStmtsDecls $ do +genCall (PrimTarget (MO_S_Mul2 w)) [dstC, dstH, dstL] [lhs, rhs] = runStmtsDecls $ do let width = widthToLlvmInt w bitWidth = widthInBits w width2x = LMInt (bitWidth * 2) @@ -373,10 +373,18 @@ genCall (PrimTarget (MO_S_Mul2 w)) [dstH, dstL] [lhs, rhs] = runStmtsDecls $ do retShifted <- doExprW width2x $ LlvmOp LM_MO_AShr retV widthLlvmLit -- And extract them into retH. retH <- doExprW width $ Cast LM_Trunc retShifted width + -- Check if the carry is useful by doing a full arithmetic right shift on + -- retL and comparing the result with retH + let widthLlvmLitm1 = LMLitVar $ LMIntLit (fromIntegral bitWidth - 1) width + retH' <- doExprW width $ LlvmOp LM_MO_AShr retL widthLlvmLitm1 + retC1 <- doExprW i1 $ Compare LM_CMP_Ne retH retH' -- Compare op returns a 1-bit value (i1) + retC <- doExprW width $ Cast LM_Zext retC1 width -- so we zero-extend it dstRegL <- getCmmRegW (CmmLocal dstL) dstRegH <- getCmmRegW (CmmLocal dstH) + dstRegC <- getCmmRegW (CmmLocal dstC) statement $ Store retL dstRegL statement $ Store retH dstRegH + statement $ Store retC dstRegC -- MO_U_QuotRem2 is another case we handle by widening the registers to double -- the width and use normal LLVM instructions (similarly to the MO_U_Mul2). The ===================================== compiler/GHC/Runtime/Heap/Inspect.hs ===================================== @@ -870,20 +870,21 @@ extractSubTerms recurse clos = liftM thdOf3 . go 0 0 (error "unboxedTupleTerm: no HValue for unboxed tuple") terms -- Extract a sub-word sized field from a word - index item_size_b index_b word_size endian = - (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes - where - mask :: Word - mask = case item_size_b of - 1 -> 0xFF - 2 -> 0xFFFF - 4 -> 0xFFFFFFFF - _ -> panic ("Weird byte-index: " ++ show index_b) - (q,r) = index_b `quotRem` word_size - word = array!!q - moveBytes = case endian of - BigEndian -> word_size - (r + item_size_b) * 8 - LittleEndian -> r * 8 + -- A sub word is aligned to the left-most part of a word on big-endian + -- platforms, and to the right-most part of a word on little-endian + -- platforms. This allows to write and read it back from memory + -- independent of endianness. Bits not belonging to a sub word are zeroed + -- out, although, this is strictly speaking not necessary since a sub word + -- is read back from memory by appropriately casted pointers (see e.g. + -- ppr_float of cPprTermBase). + index size_b aligned_idx word_size endian = case endian of + BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits + LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits + where + (q, r) = aligned_idx `quotRem` word_size + word = array!!q + moveBits = r * 8 + zeroOutBits = (word_size - size_b) * 8 -- | Fast, breadth-first Type reconstruction ===================================== hadrian/README.md ===================================== @@ -104,6 +104,8 @@ simply drop the `--freeze1` flag and Hadrian will rebuild all out-of-date files. * `--freeze2`: just like `--freeze1` but tell Hadrian to additionally freeze Stage2 GHC. +* `--skip-depends`: skips rebuilding Haskell module dependency files. + * `--integer-simple`: build GHC using the `integer-simple` integer library (instead of `integer-gmp`). ===================================== hadrian/doc/make.md ===================================== @@ -208,3 +208,17 @@ time you fire up a build. This is not possible with the Make build system. # Hadrian build nofib # builds the compiler and everything we need if necessary, too ``` + +- `make FAST=YES` + + Partially supported in hadrian with the `--skip-depends` argument. Since + hadrian is not directory aware some of the features of `FAST=YES` are not + replicated. + + ```sh + # Make + make FAST=YES + + # Hadrian + build --skip-depends + ``` ===================================== hadrian/src/CommandLine.hs ===================================== @@ -1,5 +1,5 @@ module CommandLine ( - optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2, + optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2, lookupSkipDepends, cmdBignum, cmdBignumCheck, cmdProgressInfo, cmdConfigure, cmdCompleteSetting, cmdDocsArgs, lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs, cmdPrefix @@ -26,6 +26,7 @@ data CommandLineArgs = CommandLineArgs , flavour :: Maybe String , freeze1 :: Bool , freeze2 :: Bool + , skipDepends :: Bool , bignum :: Maybe String , bignumCheck :: Bool , progressInfo :: ProgressInfo @@ -43,6 +44,7 @@ defaultCommandLineArgs = CommandLineArgs , flavour = Nothing , freeze1 = False , freeze2 = False + , skipDepends = False , bignum = Nothing , bignumCheck = False , progressInfo = Brief @@ -114,9 +116,10 @@ readBuildRoot ms = set :: BuildRoot -> CommandLineArgs -> CommandLineArgs set flag flags = flags { buildRoot = flag } -readFreeze1, readFreeze2 :: Either String (CommandLineArgs -> CommandLineArgs) +readFreeze1, readFreeze2, readSkipDepends :: Either String (CommandLineArgs -> CommandLineArgs) readFreeze1 = Right $ \flags -> flags { freeze1 = True } readFreeze2 = Right $ \flags -> flags { freeze1 = True, freeze2 = True } +readSkipDepends = Right $ \flags -> flags { skipDepends = True } readProgressInfo :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) readProgressInfo ms = @@ -256,6 +259,8 @@ optDescrs = "Freeze Stage1 GHC." , Option [] ["freeze2"] (NoArg readFreeze2) "Freeze Stage2 GHC." + , Option [] ["skip-depends"] (NoArg readSkipDepends) + "Skip rebuilding dependency information." , Option [] ["bignum"] (OptArg readBignum "BIGNUM") "Select GHC BigNum backend: native, gmp, ffi." , Option [] ["progress-info"] (OptArg readProgressInfo "STYLE") @@ -361,6 +366,9 @@ lookupFreeze1 = freeze1 . lookupExtra defaultCommandLineArgs lookupFreeze2 :: Map.HashMap TypeRep Dynamic -> Bool lookupFreeze2 = freeze2 . lookupExtra defaultCommandLineArgs +lookupSkipDepends :: Map.HashMap TypeRep Dynamic -> Bool +lookupSkipDepends = skipDepends . lookupExtra defaultCommandLineArgs + cmdBignum :: Action (Maybe String) cmdBignum = bignum <$> cmdLineArgs ===================================== hadrian/src/Main.hs ===================================== @@ -35,7 +35,10 @@ main = do ] ++ [ (RebuildLater, buildRoot -/- "stage1/**") | CommandLine.lookupFreeze2 argsMap - ] + ] ++ + (if CommandLine.lookupSkipDepends argsMap + then [(RebuildLater, buildRoot -/- "**/.dependencies.mk"), (RebuildLater, buildRoot -/- "**/.dependencies")] + else []) cwd <- getCurrentDirectory shakeColor <- shouldUseColor ===================================== testsuite/tests/ghci.debugger/scripts/all.T ===================================== @@ -28,9 +28,7 @@ test('print020', [extra_files(['../HappyTest.hs']), omit_ways(['ghci-ext'])], ghci_script, ['print020.script']) test('print021', normal, ghci_script, ['print021.script']) -test('print022', - [when(arch('powerpc64'), expect_broken(14455))], - ghci_script, ['print022.script']) +test('print022', normal, ghci_script, ['print022.script']) test('print023', extra_files(['../Test.hs']), ghci_script, ['print023.script']) test('print024', extra_files(['../Test.hs']), ghci_script, ['print024.script']) test('print025', normal, ghci_script, ['print025.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/348f19c00d0f14112e3845b4654b8ab9cb694db9...709797c6d0754a21a39395f5ee89ec2b978ff63e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/348f19c00d0f14112e3845b4654b8ab9cb694db9...709797c6d0754a21a39395f5ee89ec2b978ff63e You're receiving 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 Jul 9 12:01:14 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Thu, 09 Jul 2020 08:01:14 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 3 commits: no show Message-ID: <5f07070a1a33_80b3f849ba1b94024202ef@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 5f4b40ef by Moritz Angermann at 2020-07-09T11:58:38+00:00 no show - - - - - 699462fa by Moritz Angermann at 2020-07-09T12:00:04+00:00 Some notes on PIC - - - - - d8f0783d by Moritz Angermann at 2020-07-09T12:00:34+00:00 Properly load W32 with bit 31 set. - - - - - 3 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/PIC.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -327,6 +327,7 @@ getRegisterReg :: Platform -> CmmReg -> Reg getRegisterReg _ (CmmLocal (LocalReg u pk)) = RegVirtual $ mkVirtualReg u (cmmTypeFormat pk) +-- XXX: this crashes for PicBaseReg getRegisterReg platform (CmmGlobal mid) = case globalRegMaybe platform mid of Just reg -> RegReal reg @@ -403,11 +404,32 @@ getRegister e = do config <- getConfig getRegister' config (ncgPlatform config) e +-- Handling PIC on AArch64. AArch64 does not have a special PIC register, the +-- general approach is to simply go through the GOT, and there is assembly +-- support for this: +-- +-- // Load the address of 'sym' from the GOT using ADRP and LDR (used for +-- // position-independent code on AArch64): +-- adrp x0, #:got:sym +-- ldr x0, [x0, #:got_lo12:sym] +-- +-- See also: https://developer.arm.com/documentation/dui0774/i/armclang-integrated-assembler-directives/assembly-expressions +-- +-- CmmGlobal @PicBaseReg@'s are generated in @GHC.CmmToAsm.PIC@ in the +-- @cmmMakePicReference at . This is in turn called from @cmmMakeDynamicReference@ +-- also in @Cmm.CmmToAsm.PIC@ from where it is also exported. There are two +-- callsites for this. One is in this module to produce the @target@ in @genCCall@ +-- the other is in @GHC.CmmToAsm@ in @cmmExprNative at . +-- +-- Conceptually we do not want any special PicBaseReg to be used on AArch64. If +-- we want to distinguish between symbol loading, we need to address this through +-- the way we load it, not through a register. +-- getRegister' :: NCGConfig -> Platform -> CmmExpr -> NatM Register getRegister' config plat expr = case expr of - -- CmmReg (CmmGlobal PicBaseReg) - -- -> return (Fixed II64 toc nilOL) + CmmReg (CmmGlobal PicBaseReg) + -> pprPanic "getRegisterReg-memory" (ppr $ PicBaseReg) CmmLit lit -> case lit of @@ -430,6 +452,15 @@ getRegister' config plat expr , MOV (OpReg W32 dst) (OpImm (ImmInt half0)) , MOVK (OpReg W32 dst) (OpImmShift (ImmInt half1) SLSL 16) ])) + -- fallback for W32 + CmmInt i W32 -> do + let half0 = fromIntegral (fromIntegral i :: Word16) + half1 = fromIntegral (fromIntegral (i `shiftR` 16) :: Word16) + return (Any (intFormat W32) (\dst -> toOL [ COMMENT (ppr expr) + , MOV (OpReg W32 dst) (OpImm (ImmInt half0)) + , MOVK (OpReg W32 dst) (OpImmShift (ImmInt half1) SLSL 16) + ])) + -- anything else CmmInt i W64 -> do let half0 = fromIntegral (fromIntegral i :: Word16) half1 = fromIntegral (fromIntegral (i `shiftR` 16) :: Word16) @@ -739,11 +770,11 @@ assignMem_IntCode rep addrE srcE (src_reg, _format, code) <- getSomeReg srcE Amode addr addr_code <- getAmode addrE let AddrReg r1 = addr - return $ unitOL (COMMENT (ppr srcE)) + return $ unitOL (COMMENT $ text "RHS:" <+> ppr srcE) `appOL` code - `appOL` unitOL (COMMENT (ppr addrE)) + `appOL` unitOL (COMMENT $ text "LHS:" <+> ppr addrE) `appOL` addr_code - `snocOL` COMMENT (ppr src_reg <> text " -> " <> ppr r1) + `snocOL` COMMENT (text "Store:" <+> ppr r1 <+> text "<-" <+> ppr src_reg) `snocOL` STR rep (OpReg (formatToWidth rep) src_reg) (OpAddr addr) assignReg_IntCode _ reg src @@ -868,6 +899,58 @@ genCondBranch _ true false expr = do -- -- We need to make sure we preserve x9-x15, don't want to touch x16, x17. +-- Note [PLT vs GOT relocations] +-- When linking objects together, we may need to lookup foreign references. That +-- is symbolic references to functions or values in other objects. When +-- compiling the object, we can not know where those elements will end up in +-- memory (relative to the current location). Thus the use of symbols. There +-- are two types of items we are interested, code segments we want to jump to +-- and continue execution there (functions, ...), and data items we want to look +-- up (strings, numbers, ...). For functions we can use the fact that we can use +-- an intermediate jump without visibility to the programs execution. If we +-- want to jump to a function that is simply too far away to reach for the B/BL +-- instruction, we can create a small piece of code that loads the full target +-- address and jumps to that on demand. Say f wants to call g, however g is out +-- of range for a direct jump, we can create a function h in range for f, that +-- will load the address of g, and jump there. The area where we construct h +-- is called the Procedure Linking Table (PLT), we have essentially replaced +-- f -> g with f -> h -> g. This is fine for function calls. However if we +-- want to lookup values, this trick doesn't work, so we need something else. +-- We will instead reserve a slot in memory, and have a symbol pointing to that +-- slot. Now what we essentially do is, we reference that slot, and expect that +-- slot to hold the final resting address of the data we are interested in. +-- Thus what that symbol really points to is the location of the final data. +-- The block of memory where we hold all those slots is the Global Offset Table +-- (GOT). Instead of x <- $foo, we now do y <- $fooPtr, and x <- [$y]. +-- +-- For JUMP/CALLs we have 26bits (+/- 128MB), for conditional branches we only +-- have 19bits (+/- 1MB). Symbol lookups are also within +/- 1MB, thus for most +-- of the LOAD/STOREs we'd want to use adrp, and add to compute a value within +-- 4GB of the PC, and load that. For anything outside of that range, we'd have +-- to go through the GOT. +-- +-- adrp x0, +-- add x0, :lo: +-- +-- will compute the address of int x0 if is within 4GB of the +-- PC. +-- +-- If we want to get the slot in the global offset table (GOT), we can do this: +-- +-- adrp x0, #:got: +-- ldr x0, [x0, #:got_lo12:] +-- +-- this will compute the address anywhere in the addressable 64bit space into +-- x0, by loading the address from the GOT slot. +-- +-- To actually get the value of , we'd need to ldr x0, x0 still, which +-- for the first case can be optimized to use ldr x0, [x0, #:lo12:] +-- instaed of the add instruction. +-- +-- As the memory model for AArch64 for PIC is considered to be +/- 4GB, we do +-- not need to go through the GOT, unless we want to address the full address +-- range within 64bit. + genCCall :: ForeignTarget -- function to call -> [CmmFormal] -- where to put the result @@ -887,7 +970,14 @@ genCCall target dest_regs arg_regs bid = do -- be a foreign procedure with an address expr -- and a calling convention. ForeignTarget expr _cconv -> do - (reg, _format, reg_code) <- getSomeReg expr + (call_target, call_target_code) <- case expr of + -- if this is a label, let's just directly to it. This will produce the + -- correct CALL relocation for BL... + (CmmLit (CmmLabel lbl)) -> pure (TLabel lbl, nilOL) + -- ... if it's not a label--well--let's compute the expression into a + -- register and jump to that. See Note [PLT vs GOT relocations] + _ -> do (reg, _format, reg_code) <- getSomeReg expr + pure (TReg reg, reg_code) -- compute the code and register logic for all arg_regs. -- this will give us the format information to match on. arg_regs' <- mapM getSomeReg arg_regs @@ -907,46 +997,12 @@ genCCall target dest_regs arg_regs bid = do moveStackUp i = toOL [ ADD (OpReg W64 (regSingle 31)) (OpReg W64 (regSingle 31)) (OpImm (ImmInt (8 * i))) , POP_STACK_FRAME , DELTA 0 ] - -- XXX: Maybe PUSH_STACK_FRAME + POP_STACK_FRAME would work if we injected DELTAs? - -- - -- otherwise we end up with something like this: - -- stp x29, x30, [sp, #-16]! // sp <- sp - 16 ------------. <--+- push stack frame - -- mov x29, sp // x29 <- sp | <--' - -- adrp x16, cx_str // x16 <- &cx_str | - -- add x16, x16, :lo12:cx_str // ... | - -- mov x0, x16 // x0 <- &cx_str | - -- mov x1, x22 // x1 <- x22 | - -- str x18, [ sp, 64 ] // *(sp+64) <- x18 | <-- !!! - -- blr x17 // printf(&cx_str, x22) | - -- ldp x29, x30, [sp], #16 // sp <- sp + 16 ------------' <-- pop stack frame - -- adrp x18, printf // x18 <- &printf - -- add x18, x18, :lo12:printf // ... - -- stp x29, x30, [sp, #-16]! // sp <- sp - 16 ------------. - -- mov x29, sp // x29 <- sp | - -- adrp x17, cC_str // x17 <- &cC_str | - -- add x17, x17, :lo12:cC_str // ... | - -- mov x0, x17 // x0 <- x17 | - -- blr x18 // printf(&cStr) | - -- ldp x29, x30, [sp], #16 // sp <- sp + 16 ------------' - -- adrp x18, printf // x18 <- &printf - -- add x18, x18, :lo12:printf // ... - -- stp x29, x30, [sp, #-16]! // sp <- sp - 16 ------------. - -- mov x29, sp // x29 <- sp | - -- adrp x17, cF_str // x17 <- &cF_str | - -- add x17, x17, :lo12:cF_str // ... | - -- mov x0, x17 // x0 <- x17 | - -- blr x18 // printf(&cF_str) | - -- ldp x29, x30, [sp], #16 // sp <- sp + 16 ------------' - -- mov w18, #8 // x18 <- 8 - -- ldr x17, [ sp, 64 ] // x17 <- *(sp + 64) <-- !!! - -- - -- where the spill slot and the reload slot do not match, as the SP changed - -- inbetween. - let code = reg_code -- compute the label into a register + + let code = call_target_code -- compute the label (possibly into a register) `appOL` moveStackDown stackArgs - `appOL` passArgumentsCode -- put the arguments into x0, ... - `appOL` (unitOL $ BL (TReg reg))-- branch and link. - `appOL` readResultsCode -- parse the results into registers + `appOL` passArgumentsCode -- put the arguments into x0, ... + `appOL` (unitOL $ BL call_target) -- branch and link. + `appOL` readResultsCode -- parse the results into registers `appOL` moveStackUp stackArgs return (code, Nothing) ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -256,7 +256,7 @@ asmMultilineComment c = whenPprDebug $ text "/*" $+$ c $+$ text "*/" pprIm :: Imm -> SDoc pprIm im = case im of ImmInt i -> char '#' <> int i - ImmInteger i -> char '#' <> text (show i) + ImmInteger i -> char '#' <> integer i -- XXX: This will only work for -- The floating point value must be expressable as ±n ÷ 16 × 2^r, ===================================== compiler/GHC/CmmToAsm/PIC.hs ===================================== @@ -161,6 +161,11 @@ cmmMakePicReference config lbl | OSMinGW32 <- platformOS platform = CmmLit $ CmmLabel lbl + -- no pic base reg on AArch64, however indicate this symbol should go through + -- the global offset table (GOT). + | ArchAArch64 <- platformArch platform + = CmmLit $ CmmLabel lbl + | OSAIX <- platformOS platform = CmmMachOp (MO_Add W32) [ CmmReg (CmmGlobal PicBaseReg) @@ -252,6 +257,16 @@ howToAccessLabel config _ OSMinGW32 this_mod _ lbl | otherwise = AccessDirectly +-- On AArch64, relocations for JUMP and CALL will be emitted with 26bits, this +-- is enough for ~64MB of range. Anything else will need to go through a veneer, +-- which is the job of the linker to build. We might only want to lookup +-- Data References through the GOT. +howToAccessLabel _config ArchAArch64 _os _this_mod kind _lbl + = case kind of + DataReference -> AccessDirectly -- AccessViaSymbolPtr + CallReference -> AccessDirectly + JumpReference -> AccessDirectly + -- Mach-O (Darwin, Mac OS X) -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a5b00b4cd8db15ca91ebac52554b3399d4f14d82...d8f0783dca2be440b92eb59e3bee116e5d0777ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a5b00b4cd8db15ca91ebac52554b3399d4f14d82...d8f0783dca2be440b92eb59e3bee116e5d0777ad You're receiving 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 Jul 9 13:26:16 2020 From: gitlab at gitlab.haskell.org (Sylvain Henry) Date: Thu, 09 Jul 2020 09:26:16 -0400 Subject: [Git][ghc/ghc][wip/proposal-195] 199 commits: gitlab-ci: Allow ARMv7 job to fail Message-ID: <5f071af8821e8_80b3f846a0d2e3c24264b1@gitlab.haskell.org.mail> Sylvain Henry pushed to branch wip/proposal-195 at Glasgow Haskell Compiler / GHC Commits: cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00 gitlab-ci: Allow ARMv7 job to fail Due to #18298. - - - - - 32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00 Clean up boot vs non-boot disambiguating types We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule. - - - - - c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00 docs: Add more details on InterruptibleFFI. Details from https://gitlab.haskell.org/ghc/ghc/issues/8684 and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430 - - - - - 1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00 Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr. MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd. This regression did not make it into a release of GHC. Here, the original behavior is restored, and FinalPtr is given the same treatment as PlainPtr. - - - - - 2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00 Fix documentation on type families not being extracted It looks like the location of the Names used for CoAxioms on type families are now located at their type constructors. Previously, Docs.hs thought the Names were located in the RHS, so the RealSrcSpan in the instanceMap and getInstLoc didn't match up. Fixes #18241 - - - - - 6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00 GHC.Hs.Instances: Compile with -O0 This module contains exclusively Data instances, which are going to be slow no matter what we do. Furthermore, they are incredibly slow to compile with optimisation (see #9557). Consequently we compile this with -O0. See #18254. - - - - - c330331a by nineonine at 2020-06-04T04:37:59-04:00 Add test for #17669 - - - - - cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00 rts: Add Windows-specific implementation of rtsSleep Previously we would use the POSIX path, which uses `nanosleep`. However, it turns out that `nanosleep` is provided by `libpthread` on Windows. In general we don't want to incur such a dependency. Avoid this by simply using `Sleep` on Windows. Fixes #18272. - - - - - ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00 compiler: Disable use of process jobs with process < 1.6.9 Due to #17926. - - - - - 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - 652b3e85 by Matthew Pickering at 2020-07-09T15:23:25+02:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/test-metrics.sh - .gitmodules - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/48c844a2d7a8066ecb4e45ad4dca2ae042e02b66...652b3e85ee41fd9d42c5162f258ec8eedc29c651 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/48c844a2d7a8066ecb4e45ad4dca2ae042e02b66...652b3e85ee41fd9d42c5162f258ec8eedc29c651 You're receiving 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 Jul 9 13:44:08 2020 From: gitlab at gitlab.haskell.org (Sylvain Henry) Date: Thu, 09 Jul 2020 09:44:08 -0400 Subject: [Git][ghc/ghc][wip/proposal-195] Use a newtype `Code` for the return type of typed quotations (Proposal #195) Message-ID: <5f071f287495b_80b3f846a0d2e3c2432035@gitlab.haskell.org.mail> Sylvain Henry pushed to branch wip/proposal-195 at Glasgow Haskell Compiler / GHC Commits: e36b0d43 by Matthew Pickering at 2020-07-09T15:43:54+02:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Splice.hs - docs/users_guide/exts/deriving_extra.rst - docs/users_guide/exts/template_haskell.rst - libraries/template-haskell/Language/Haskell/TH.hs - + libraries/template-haskell/Language/Haskell/TH/CodeDo.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - libraries/template-haskell/template-haskell.cabal.in - libraries/text - testsuite/tests/deriving/should_compile/drv-empty-data.stderr - testsuite/tests/parser/should_compile/Proposal229f_instances.hs - testsuite/tests/partial-sigs/should_compile/TypedSplice.hs - testsuite/tests/partial-sigs/should_compile/TypedSplice.stderr - testsuite/tests/quotes/T17857.hs - testsuite/tests/th/T10945.stderr - testsuite/tests/th/T15471A.hs - testsuite/tests/th/T15843.hs - testsuite/tests/th/T16195A.hs - testsuite/tests/th/T18121.hs - testsuite/tests/th/T8577.stderr - testsuite/tests/th/T8577a.hs - testsuite/tests/th/TH_StringLift.hs - testsuite/tests/th/TH_reifyLocalDefs.hs - testsuite/tests/th/overloaded/T17839.hs - testsuite/tests/th/overloaded/TH_overloaded_constraints.hs - testsuite/tests/th/overloaded/TH_overloaded_csp.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e36b0d435a9270c871e5180cf30909ddfad26940 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e36b0d435a9270c871e5180cf30909ddfad26940 You're receiving 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 Jul 9 13:49:29 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 09 Jul 2020 09:49:29 -0400 Subject: [Git][ghc/ghc][master] Fix GHCi :print on big-endian platforms Message-ID: <5f072069bc80b_80b3f849ba1b940244205d@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 2 changed files: - compiler/GHC/Runtime/Heap/Inspect.hs - testsuite/tests/ghci.debugger/scripts/all.T Changes: ===================================== compiler/GHC/Runtime/Heap/Inspect.hs ===================================== @@ -870,20 +870,21 @@ extractSubTerms recurse clos = liftM thdOf3 . go 0 0 (error "unboxedTupleTerm: no HValue for unboxed tuple") terms -- Extract a sub-word sized field from a word - index item_size_b index_b word_size endian = - (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes - where - mask :: Word - mask = case item_size_b of - 1 -> 0xFF - 2 -> 0xFFFF - 4 -> 0xFFFFFFFF - _ -> panic ("Weird byte-index: " ++ show index_b) - (q,r) = index_b `quotRem` word_size - word = array!!q - moveBytes = case endian of - BigEndian -> word_size - (r + item_size_b) * 8 - LittleEndian -> r * 8 + -- A sub word is aligned to the left-most part of a word on big-endian + -- platforms, and to the right-most part of a word on little-endian + -- platforms. This allows to write and read it back from memory + -- independent of endianness. Bits not belonging to a sub word are zeroed + -- out, although, this is strictly speaking not necessary since a sub word + -- is read back from memory by appropriately casted pointers (see e.g. + -- ppr_float of cPprTermBase). + index size_b aligned_idx word_size endian = case endian of + BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits + LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits + where + (q, r) = aligned_idx `quotRem` word_size + word = array!!q + moveBits = r * 8 + zeroOutBits = (word_size - size_b) * 8 -- | Fast, breadth-first Type reconstruction ===================================== testsuite/tests/ghci.debugger/scripts/all.T ===================================== @@ -28,9 +28,7 @@ test('print020', [extra_files(['../HappyTest.hs']), omit_ways(['ghci-ext'])], ghci_script, ['print020.script']) test('print021', normal, ghci_script, ['print021.script']) -test('print022', - [when(arch('powerpc64'), expect_broken(14455))], - ghci_script, ['print022.script']) +test('print022', normal, ghci_script, ['print022.script']) test('print023', extra_files(['../Test.hs']), ghci_script, ['print023.script']) test('print024', extra_files(['../Test.hs']), ghci_script, ['print024.script']) test('print025', normal, ghci_script, ['print025.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b7de4b960a1024adcd0bded6bd320a90979d7ab8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b7de4b960a1024adcd0bded6bd320a90979d7ab8 You're receiving 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 Jul 9 13:50:08 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 09 Jul 2020 09:50:08 -0400 Subject: [Git][ghc/ghc][master] LLVM: fix MO_S_Mul2 support (#18434) Message-ID: <5f072090ce4d_80b3f8490174d382444590@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - 1 changed file: - compiler/GHC/CmmToLlvm/CodeGen.hs Changes: ===================================== compiler/GHC/CmmToLlvm/CodeGen.hs ===================================== @@ -353,7 +353,7 @@ genCall (PrimTarget (MO_U_Mul2 w)) [dstH, dstL] [lhs, rhs] = runStmtsDecls $ do statement $ Store retL dstRegL statement $ Store retH dstRegH -genCall (PrimTarget (MO_S_Mul2 w)) [dstH, dstL] [lhs, rhs] = runStmtsDecls $ do +genCall (PrimTarget (MO_S_Mul2 w)) [dstC, dstH, dstL] [lhs, rhs] = runStmtsDecls $ do let width = widthToLlvmInt w bitWidth = widthInBits w width2x = LMInt (bitWidth * 2) @@ -373,10 +373,18 @@ genCall (PrimTarget (MO_S_Mul2 w)) [dstH, dstL] [lhs, rhs] = runStmtsDecls $ do retShifted <- doExprW width2x $ LlvmOp LM_MO_AShr retV widthLlvmLit -- And extract them into retH. retH <- doExprW width $ Cast LM_Trunc retShifted width + -- Check if the carry is useful by doing a full arithmetic right shift on + -- retL and comparing the result with retH + let widthLlvmLitm1 = LMLitVar $ LMIntLit (fromIntegral bitWidth - 1) width + retH' <- doExprW width $ LlvmOp LM_MO_AShr retL widthLlvmLitm1 + retC1 <- doExprW i1 $ Compare LM_CMP_Ne retH retH' -- Compare op returns a 1-bit value (i1) + retC <- doExprW width $ Cast LM_Zext retC1 width -- so we zero-extend it dstRegL <- getCmmRegW (CmmLocal dstL) dstRegH <- getCmmRegW (CmmLocal dstH) + dstRegC <- getCmmRegW (CmmLocal dstC) statement $ Store retL dstRegL statement $ Store retH dstRegH + statement $ Store retC dstRegC -- MO_U_QuotRem2 is another case we handle by widening the registers to double -- the width and use normal LLVM instructions (similarly to the MO_U_Mul2). The View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3656dff8259199d0dab2d1a1f1b887c252a9c1a3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3656dff8259199d0dab2d1a1f1b887c252a9c1a3 You're receiving 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 Jul 9 16:24:46 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Thu, 09 Jul 2020 12:24:46 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/exprSizeBangs Message-ID: <5f0744ce5cbad_80b3f84960bea1424708dc@gitlab.haskell.org.mail> Andreas Klebinger pushed new branch wip/andreask/exprSizeBangs at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/exprSizeBangs You're receiving 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 Jul 9 20:21:20 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 09 Jul 2020 16:21:20 -0400 Subject: [Git][ghc/ghc][ghc-8.8] 12 commits: Revert "Bump to 8.8.4, RELEASE=YES" Message-ID: <5f077c4034f6c_80b3f846a0d2e3c250080@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC Commits: 31e2bfbf by Ben Gamari at 2020-07-08T11:53:43-04:00 Revert "Bump to 8.8.4, RELEASE=YES" This reverts commit b12faad0ad27b56cfc35ac1faef448b6f2245734. - - - - - 8eb55fc9 by Moritz Angermann at 2020-07-08T11:53:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf (cherry picked from commit 4a158ffc4e0ac250897aefaf6caf03eb5f688182) - - - - - 146ef07e by Moritz Angermann at 2020-07-08T11:53:43-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. (cherry picked from commit 3fd12af1eaafe304e5916bc1fcfdf31709d360b8) - - - - - 407b98f7 by Moritz Angermann at 2020-07-08T12:54:35-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. (cherry picked from commit b455074875d3c8fd3a5787e01dc6f922f3a97bc2) - - - - - 14401143 by Artem Pelenitsyn at 2020-07-08T12:54:35-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. (cherry picked from commit af5e3a885ddd09dd5f550552c535af3661ff3dbf) - - - - - 49a68ebf by Ryan Scott at 2020-07-08T12:54:35-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. (cherry picked from commit 66bd24d197251b9907cbffba3d5d8a3f5e3c2e80) - - - - - 6abc5456 by Ben Gamari at 2020-07-08T12:54:35-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 (cherry picked from commit c00c81a507d31b6d51e89f00d1e4c83f71c7d382) - - - - - eda32b7a by Ben Gamari at 2020-07-08T15:02:32-04:00 testsuite: Add test for #18151 - - - - - 2e17d60c by Ben Gamari at 2020-07-08T15:02:46-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. (cherry picked from commit 2b89ca5b850b4097447cc4908cbb0631011ce979) - - - - - 433341fb by Travis Whitaker at 2020-07-08T15:02:48-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. (cherry picked from commit 67738db10010fd28a8e997b5c8f83ea591b88a0e) - - - - - 98a053a9 by Ben Gamari at 2020-07-08T15:02:48-04:00 More release notes - - - - - 1fdd6165 by GHC GitLab CI at 2020-07-08T15:02:48-04:00 Bump to 8.8.4, RELEASE=YES - - - - - 25 changed files: - compiler/deSugar/DsExpr.hs - compiler/ghc.mk - compiler/prelude/PrelNames.hs - compiler/prelude/TysWiredIn.hs - configure.ac - docs/users_guide/8.8.4-notes.rst - ghc/ghc.mk - hadrian/cfg/system.config.in - hadrian/src/Expression.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Packages.hs - libraries/base/GHC/Float.hs - + libraries/ghc-compact/tests/T16992.hs - + libraries/ghc-compact/tests/T16992.stdout - libraries/ghc-compact/tests/all.T - libraries/ghc-prim/ghc-prim.cabal - mk/config.mk.in - rts/linker/LoadArchive.c - rts/linker/elf_reloc_aarch64.c - rts/sm/CNF.c - + testsuite/tests/deSugar/should_run/T18151.hs - + testsuite/tests/deSugar/should_run/T18151.stdout - testsuite/tests/deSugar/should_run/all.T - + testsuite/tests/typecheck/should_compile/T18185.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/deSugar/DsExpr.hs ===================================== @@ -331,26 +331,47 @@ Then we get That 'g' in the 'in' part is an evidence variable, and when converting to core it must become a CO. -Operator sections. At first it looks as if we can convert -\begin{verbatim} - (expr op) -\end{verbatim} -to -\begin{verbatim} - \x -> op expr x -\end{verbatim} + +Note [Desugaring operator sections] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +At first it looks as if we can convert + + (expr `op`) + +naively to + + \x -> op expr x But no! expr might be a redex, and we can lose laziness badly this way. Consider -\begin{verbatim} - map (expr op) xs -\end{verbatim} -for example. So we convert instead to -\begin{verbatim} - let y = expr in \x -> op y x -\end{verbatim} -If \tr{expr} is actually just a variable, say, then the simplifier -will sort it out. + + map (expr `op`) xs + +for example. If expr were a redex then eta-expanding naively would +result in multiple evaluations where the user might only have expected one. + +So we convert instead to + + let y = expr in \x -> op y x + +Also, note that we must do this for both right and (perhaps surprisingly) left +sections. Why are left sections necessary? Consider the program (found in #18151), + + seq (True `undefined`) () + +according to the Haskell Report this should reduce to () (as it specifies +desugaring via eta expansion). However, if we fail to eta expand we will rather +bottom. Consequently, we must eta expand even in the case of a left section. + +If `expr` is actually just a variable, say, then the simplifier +will inline `y`, eliminating the redundant `let`. + +Note that this works even in the case that `expr` is unlifted. In this case +bindNonRec will automatically do the right thing, giving us: + + case expr of y -> (\x -> op y x) + +See #18151. -} ds_expr _ e@(OpApp _ e1 op e2) @@ -359,17 +380,35 @@ ds_expr _ e@(OpApp _ e1 op e2) ; dsWhenNoErrs (mapM dsLExprNoLP [e1, e2]) (\exprs' -> mkCoreAppsDs (text "opapp" <+> ppr e) op' exprs') } -ds_expr _ (SectionL _ expr op) -- Desugar (e !) to ((!) e) - = do { op' <- dsLExpr op - ; dsWhenNoErrs (dsLExprNoLP expr) - (\expr' -> mkCoreAppDs (text "sectionl" <+> ppr expr) op' expr') } - --- dsLExpr (SectionR op expr) -- \ x -> op x expr +-- dsExpr (SectionL op expr) === (expr `op`) ~> \y -> op expr y +-- +-- See Note [Desugaring operator sections]. +-- N.B. this also must handle postfix operator sections due to -XPostfixOperators. +ds_expr _ e@(SectionL _ expr op) = do + core_op <- dsLExpr op + x_core <- dsLExpr expr + case splitFunTys (exprType core_op) of + -- Binary operator section + (x_ty:y_ty:_, _) -> do + dsWhenNoErrs + (mapM newSysLocalDsNoLP [x_ty, y_ty]) + (\[x_id, y_id] -> + bindNonRec x_id x_core + $ Lam y_id (mkCoreAppsDs (text "sectionl" <+> ppr e) + core_op [Var x_id, Var y_id])) + + -- Postfix operator section + (_:_, _) -> do + return $ mkCoreAppDs (text "sectionl" <+> ppr e) core_op x_core + + _ -> pprPanic "dsExpr(SectionL)" (ppr e) + +-- dsExpr (SectionR op expr) === (`op` expr) ~> \x -> op x expr +-- +-- See Note [Desugaring operator sections]. ds_expr _ e@(SectionR _ op expr) = do core_op <- dsLExpr op - -- for the type of x, we need the type of op's 2nd argument let (x_ty:y_ty:_, _) = splitFunTys (exprType core_op) - -- See comment with SectionL y_core <- dsLExpr expr dsWhenNoErrs (mapM newSysLocalDsNoLP [x_ty, y_ty]) (\[x_id, y_id] -> bindNonRec y_id y_core $ ===================================== compiler/ghc.mk ===================================== @@ -326,6 +326,12 @@ ifeq "$(GhcThreaded)" "YES" compiler_stage2_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS endif +# If the bootstrapping GHC supplies the threaded RTS, then we can have a +# threaded stage 1 too. +ifeq "$(GhcThreadedRts)" "YES" +compiler_stage1_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS +endif + ifeq "$(GhcWithNativeCodeGen)" "YES" compiler_stage1_CONFIGURE_OPTS += --flags=ncg compiler_stage2_CONFIGURE_OPTS += --flags=ncg ===================================== compiler/prelude/PrelNames.hs ===================================== @@ -420,10 +420,6 @@ basicKnownKeyNames -- Annotation type checking toAnnotationWrapperName - -- The Ordering type - , orderingTyConName - , ordLTDataConName, ordEQDataConName, ordGTDataConName - -- The SPEC type for SpecConstr , specTyConName ===================================== compiler/prelude/TysWiredIn.hs ===================================== @@ -197,8 +197,11 @@ names in PrelNames, so they use wTcQual, wDataQual, etc -- that occurs in this list that name will be assigned the wired-in key we -- define here. -- --- Because of their infinite nature, this list excludes tuples, Any and implicit --- parameter TyCons (see Note [Built-in syntax and the OrigNameCache]). +-- Because of their infinite nature, this list excludes +-- * tuples, including boxed, unboxed and constraint tuples +--- (mkTupleTyCon, unitTyCon, pairTyCon) +-- * unboxed sums (sumTyCon) +-- See Note [Infinite families of known-key names] in GHC.Builtin.Names -- -- See also Note [Known-key names] wiredInTyCons :: [TyCon] @@ -219,6 +222,7 @@ wiredInTyCons = [ -- Units are not treated like other tuples, because then , wordTyCon , word8TyCon , listTyCon + , orderingTyCon , maybeTyCon , heqTyCon , eqTyCon ===================================== configure.ac ===================================== @@ -127,6 +127,9 @@ dnl CC_STAGE0 is like the "previous" variable CC (inherited by CC_STAGE[123]) dnl but instead used by stage0 for bootstrapping stage1 AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)]) +dnl RTS ways supplied by the bootstrapping compiler. +AC_ARG_VAR(RTS_WAYS_STAGE0, [RTS ways]) + if test "$WithGhc" != ""; then FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl @@ -150,6 +153,17 @@ if test "$WithGhc" != ""; then BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command]) BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) + BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) + + dnl Check whether or not the bootstrapping GHC has a threaded RTS. This + dnl determines whether or not we can have a threaded stage 1. + dnl See Note [Linking ghc-bin against threaded stage0 RTS] in + dnl hadrian/src/Settings/Packages.hs for details. + if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null; then + AC_SUBST(GhcThreadedRts, YES) + else + AC_SUBST(GhcThreadedRts, NO) + fi fi dnl ** Must have GHC to build GHC @@ -1372,6 +1386,7 @@ Configure completed successfully. echo "\ Bootstrapping using : $WithGhc which is version : $GhcVersion + with threaded RTS? : $GhcThreadedRts " if test "x$CC_LLVM_BACKEND" = "x1"; then ===================================== docs/users_guide/8.8.4-notes.rst ===================================== @@ -6,13 +6,27 @@ Release notes for version 8.8.4 GHC 8.8.4 is a minor release intended to fix regressions and minor bugs in the 8.8.1, 8.8.2 and 8.8.3 releases. +Like previous releases in the 8.8 series, the :ghc-flag:`LLVM backend <-fllvm>` +of this release is to be used with LLVM 7. + Highlights ---------- -- Fix a bug in process creation on Windows (:ghc-ticket:`17926`). +- Fixes a bug in process creation on Windows (:ghc-ticket:`17926`). + +- Works around a Linux kernel bug in the implementation of ``timerfd``\s (:ghc-ticket:`18033`). + +- Fixes a few linking issues affecting ARM + +- Fixes "missing interface file" error triggered by some uses of ``Ordering`` (:ghc-ticket:`18185`) + +- Fixes an integer overflow in the compact-normal-form import implementation (:ghc-ticket:`16992`) + +- ``configure`` now accepts ``--enable-numa`` flag to enable/disable ``numactl`` support on Linux. -- Workaround a Linux kernel bug in the implementation of ``timerfd``\s (:ghc-ticket:`18033`). +- Fixes potentially lost sharing due to the desugaring of left operator sections (:ghc-ticket:`18151`). +- Fixes a build-system bug resulting in potential miscompilation by unregisteised compilers (:ghc-ticket:`18024`) Known issues ------------ ===================================== ghc/ghc.mk ===================================== @@ -63,6 +63,15 @@ ghc_stage2_MORE_HC_OPTS += -threaded ghc_stage3_MORE_HC_OPTS += -threaded endif +# If stage 0 supplies a threaded RTS, we can use it for stage 1. +# See Note [Linking ghc-bin against threaded stage0 RTS] in +# hadrian/src/Settings/Packages.hs for details. +ifeq "$(GhcThreadedRts)" "YES" +ghc_stage1_MORE_HC_OPTS += -threaded +else +ghc_stage1_CONFIGURE_OPTS += -f-threaded +endif + ifeq "$(GhcProfiled)" "YES" ghc_stage2_PROGRAM_WAY = p endif ===================================== hadrian/cfg/system.config.in ===================================== @@ -77,6 +77,8 @@ ghc-major-version = @GhcMajVersion@ ghc-minor-version = @GhcMinVersion@ ghc-patch-level = @GhcPatchLevel@ +bootstrap-threaded-rts = @GhcThreadedRts@ + supports-this-unit-id = @SUPPORTS_THIS_UNIT_ID@ project-name = @ProjectName@ ===================================== hadrian/src/Expression.hs ===================================== @@ -6,8 +6,8 @@ module Expression ( expr, exprIO, arg, remove, -- ** Predicates - (?), stage, stage0, stage1, stage2, notStage0, package, notPackage, - libraryPackage, builder, way, input, inputs, output, outputs, + (?), stage, stage0, stage1, stage2, notStage0, threadedBootstrapper, + package, notPackage, libraryPackage, builder, way, input, inputs, output, outputs, -- ** Evaluation interpret, interpretInContext, @@ -26,6 +26,7 @@ import Base import Builder import Context hiding (stage, package, way) import Expression.Type +import Oracles.Flag import Hadrian.Expression hiding (Expr, Predicate, Args) import Hadrian.Haskell.Cabal.Type import Hadrian.Oracles.Cabal @@ -83,6 +84,19 @@ instance BuilderPredicate a => BuilderPredicate (FilePath -> a) where way :: Way -> Predicate way w = (w ==) <$> getWay +{- +Note [Stage Names] +~~~~~~~~~~~~~~~~~~ + +Code referring to specific stages can be a bit tricky. In Hadrian, the stages +have the same names they carried in the autoconf build system, but they are +often referred to by the stage used to construct them. For example, the stage 1 +artifacts will be placed in _build/stage0, because they are constructed by the +stage 0 compiler. The stage predicates in this module behave the same way, +'stage0' will return 'True' while stage 0 is being used to build the stage 1 +compiler. +-} + -- | Is the build currently in stage 0? stage0 :: Predicate stage0 = stage Stage0 @@ -99,6 +113,13 @@ stage2 = stage Stage2 notStage0 :: Predicate notStage0 = notM stage0 +-- | Whether or not the bootstrapping compiler provides a threaded RTS. We need +-- to know this when building stage 1, since stage 1 links against the +-- compiler's RTS ways. See Note [Linking ghc-bin against threaded stage0 RTS] +-- in Settings.Packages for details. +threadedBootstrapper :: Predicate +threadedBootstrapper = expr (flag BootstrapThreadedRts) + -- | Is a certain package /not/ built right now? notPackage :: Package -> Predicate notPackage = notM . package ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -21,6 +21,7 @@ data Flag = ArSupportsAtFile | WithLibdw | HaveLibMingwEx | UseSystemFfi + | BootstrapThreadedRts -- Note, if a flag is set to empty string we treat it as set to NO. This seems -- fragile, but some flags do behave like this, e.g. GccIsClang. @@ -39,6 +40,7 @@ flag f = do WithLibdw -> "with-libdw" HaveLibMingwEx -> "have-lib-mingw-ex" UseSystemFfi -> "use-system-ffi" + BootstrapThreadedRts -> "bootstrap-threaded-rts" value <- lookupValueOrError configFile key when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag " ++ quote (key ++ " = " ++ value) ++ " cannot be parsed." ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -85,10 +85,24 @@ packageArgs = do , builder (Cabal Flags) ? mconcat [ ghcWithInterpreter ? notStage0 ? arg "ghci" , flag CrossCompiling ? arg "-terminfo" - -- the 'threaded' flag is True by default, but - -- let's record explicitly that we link all ghc - -- executables with the threaded runtime. - , arg "threaded" ] ] + -- Note [Linking ghc-bin against threaded stage0 RTS] + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- We must maintain the invariant that GHCs linked with '-threaded' + -- are built with '-optc=-DTHREADED_RTS', otherwise we'll end up + -- with a GHC that can use the threaded runtime, but contains some + -- non-thread-safe functions. See + -- https://gitlab.haskell.org/ghc/ghc/issues/18024 for an example of + -- the sort of issues this can cause. + , ifM stage0 + -- We build a threaded stage 1 if the bootstrapping compiler + -- supports it. + (ifM threadedBootstrapper + (arg "threaded") + (arg "-threaded")) + -- We build a threaded stage N. + (arg "threaded") + ] + ] -------------------------------- ghcPkg -------------------------------- , package ghcPkg ? ===================================== libraries/base/GHC/Float.hs ===================================== @@ -141,6 +141,14 @@ class (Fractional a) => Floating a where log1pexp x = log1p (exp x) log1mexp x = log1p (negate (exp x)) +-- | Default implementation for @'log1mexp'@ requiring @'Ord'@ to test +-- against a threshold to decide which implementation variant to use. +log1mexpOrd :: (Ord a, Floating a) => a -> a +{-# INLINE log1mexpOrd #-} +log1mexpOrd a + | a > -(log 2) = log (negate (expm1 a)) + | otherwise = log1p (negate (exp a)) + -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat a where @@ -398,9 +406,7 @@ instance Floating Float where log1p = log1pFloat expm1 = expm1Float - log1mexp a - | a <= log 2 = log (negate (expm1Float a)) - | otherwise = log1pFloat (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pFloat (exp a) @@ -539,9 +545,7 @@ instance Floating Double where log1p = log1pDouble expm1 = expm1Double - log1mexp a - | a <= log 2 = log (negate (expm1Double a)) - | otherwise = log1pDouble (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pDouble (exp a) ===================================== libraries/ghc-compact/tests/T16992.hs ===================================== @@ -0,0 +1,22 @@ +import Data.Bifunctor +import Foreign.Ptr +import qualified Data.ByteString as BS +import qualified Data.ByteString.Unsafe as BS +import qualified GHC.Compact as Compact +import qualified GHC.Compact.Serialized as CompactSerialize + +-- | Minimal test case for reproducing compactFixupPointers# bug for large compact regions. +-- See Issue #16992. +main :: IO () +main = do + let + large = 1024 * 1024 * 128 + largeString = replicate large 'A' + + region <- Compact.compact largeString + + Just deserialized <- CompactSerialize.withSerializedCompact region $ \s -> do + blks <- mapM (BS.unsafePackCStringLen . bimap castPtr fromIntegral) (CompactSerialize.serializedCompactBlockList s) + CompactSerialize.importCompactByteStrings s blks + + print (Compact.getCompact deserialized == largeString) ===================================== libraries/ghc-compact/tests/T16992.stdout ===================================== @@ -0,0 +1 @@ +True ===================================== libraries/ghc-compact/tests/all.T ===================================== @@ -22,3 +22,8 @@ test('compact_share', omit_ways(['ghci', 'profasm', 'profthreaded']), test('compact_bench', [ ignore_stdout, extra_run_opts('100') ], compile_and_run, ['']) test('T17044', normal, compile_and_run, ['']) +# N.B. Sanity check times out due to large list. +test('T16992', [when(wordsize(32), skip), # Resource limit exceeded on 32-bit + high_memory_usage, + run_timeout_multiplier(5), + omit_ways(['sanity'])], compile_and_run, ['']) ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -66,6 +66,11 @@ Library -- on Windows. Required because of mingw32. extra-libraries: user32, mingw32, mingwex + if os(linux) + -- we need libm, but for musl and other's we might need libc, as libm + -- is just an empty shell. + extra-libraries: c, m + c-sources: cbits/atomic.c cbits/bswap.c ===================================== mk/config.mk.in ===================================== @@ -199,6 +199,9 @@ endif # `GhcUnregisterised` mode doesn't allow that. GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO)) +# Whether or not the bootstrapping GHC supplies a threaded RTS. +GhcThreadedRts = @GhcThreadedRts@ + # Whether to include GHCi in the compiler. Depends on whether the RTS linker # has support for this OS/ARCH combination. ===================================== rts/linker/LoadArchive.c ===================================== @@ -461,6 +461,7 @@ static HsInt loadArchive_ (pathchar *path) /* TODO: Stop relying on file extensions to determine input formats. Instead try to match file headers. See Trac #13103. */ isObject = (thisFileNameSize >= 2 && strncmp(fileName + thisFileNameSize - 2, ".o" , 2) == 0) + || (thisFileNameSize >= 3 && strncmp(fileName + thisFileNameSize - 3, ".lo" , 3) == 0) || (thisFileNameSize >= 4 && strncmp(fileName + thisFileNameSize - 4, ".p_o", 4) == 0) || (thisFileNameSize >= 4 && strncmp(fileName + thisFileNameSize - 4, ".obj", 4) == 0); ===================================== rts/linker/elf_reloc_aarch64.c ===================================== @@ -90,12 +90,14 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) { // ... hi ] [ Rd ] // // imm64 = SignExtend(hi:lo:0x000,64) - assert(isInt64(32, addend)); + // Range is 21 bits + the 12 page relative bits + // known to be 0. -2^32 <= X < 2^32 + assert(isInt64(21+12, addend)); assert((addend & 0xfff) == 0); /* page relative */ *(inst_t *)P = (*(inst_t *)P & 0x9f00001f) - | (inst_t) (((uint64_t) addend << 17) & 0x60000000) - | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0); + | (inst_t) (((uint64_t) addend << 17) & 0x60000000) + | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0); break; } /* - control flow relocations */ @@ -108,8 +110,8 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) { break; } case COMPAT_R_AARCH64_ADR_GOT_PAGE: { - - assert(isInt64(32, addend)); /* X in range */ + /* range is -2^32 <= X < 2^32 */ + assert(isInt64(21+12, addend)); /* X in range */ assert((addend & 0xfff) == 0); /* page relative */ *(inst_t *)P = (*(inst_t *)P & 0x9f00001f) ===================================== rts/sm/CNF.c ===================================== @@ -1016,8 +1016,9 @@ cmp_fixup_table_item (const void *e1, const void *e2) { const StgWord *w1 = e1; const StgWord *w2 = e2; - - return *w1 - *w2; + if (*w1 > *w2) return +1; + else if (*w1 < *w2) return -1; + else return 0; } static StgWord * ===================================== testsuite/tests/deSugar/should_run/T18151.hs ===================================== @@ -0,0 +1,10 @@ +-- According to the Report this should reduce to (). However, in #18151 it was +-- reported that GHC bottoms. +x :: () +x = seq (True `undefined`) () +{-# NOINLINE x #-} + +main :: IO () +main = do + print x + ===================================== testsuite/tests/deSugar/should_run/T18151.stdout ===================================== @@ -0,0 +1 @@ +() \ No newline at end of file ===================================== testsuite/tests/deSugar/should_run/all.T ===================================== @@ -63,3 +63,4 @@ test('T11601', exit_code(1), compile_and_run, ['']) test('T11747', normal, compile_and_run, ['-dcore-lint']) test('T12595', normal, compile_and_run, ['']) test('T13285', normal, compile_and_run, ['']) +test('T18151', normal, compile_and_run, ['']) ===================================== testsuite/tests/typecheck/should_compile/T18185.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +module T18185 where + +import GHC.TypeLits +import Type.Reflection + +class iss :|+ is ~ oss => AddT (iss :: [Symbol]) (is :: Symbol) (oss :: [Symbol]) where + type iss :|+ is :: [Symbol] + +class (CmpSymbol is ish ~ ord, AddT'I ord is ish ist ~ oss) => AddT' ord is ish ist oss where + type AddT'I ord is ish ist :: [Symbol] + +class (CmpSymbol "a" "a" ~ o) => C1 o +class (CmpNat 1 1 ~ o) => C2 o +class ((CmpSymbol "a" "a" :: Ordering) ~ o) => C3 o +class ((CmpNat 1 1 :: Ordering) ~ o) => C4 o + +f1 :: TypeRep (CmpSymbol "a" "a") +f1 = typeRep + +f2 :: TypeRep (CmpNat 1 1) +f2 = typeRep + +f3 :: TypeRep (CmpSymbol "a" "a" :: Ordering) +f3 = typeRep + +f4 :: TypeRep (CmpNat 1 1 :: Ordering) +f4 = typeRep ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -670,3 +670,4 @@ test('T16204a', normal, compile, ['']) test('T16204b', normal, compile, ['']) test('T16225', normal, compile, ['']) test('T16312', normal, compile, ['-O']) +test('T18185', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac697a44ffb216cb351468b1b0e9ddb84de1495a...1fdd616527070b0b09661f78363c176f35049d9c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac697a44ffb216cb351468b1b0e9ddb84de1495a...1fdd616527070b0b09661f78363c176f35049d9c You're receiving 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 Jul 9 21:27:07 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Thu, 09 Jul 2020 17:27:07 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18412 Message-ID: <5f078bab69955_80b3f84960bea142506349@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T18412 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18412 You're receiving 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 Jul 9 21:40:57 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Thu, 09 Jul 2020 17:40:57 -0400 Subject: [Git][ghc/ghc][wip/az/exactprint] 62 commits: Switch from HscSource to IsBootInterface for module lookup in GhcMake Message-ID: <5f078ee9779eb_80b3f846a0d2e3c251042a@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/exactprint at Glasgow Haskell Compiler / GHC Commits: 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - 03fa8574 by Alan Zimmerman at 2020-07-09T22:38:20+01:00 Proof of Concept implementation of in-tree API Annotations This MR introduces a possible machinery to introduce API Annotations into the TTG extension points. It is intended to be a concrete example for discussion. It still needs to process comments. ---- Work in progress, adding more TTG extensions for annotations. And fixing ppr round-trip tests by being able to blank out in-tree annotations, as done with SrcSpans. This is needed for the case of class Foo a where for which current ppr does not print the "where". Rename AA to AddApiAnn and AA to AddAnn Add XConPatIn and XConPatOut Rebase ---- First pass at bringing in LocatedA for API anns in locations Treatment of ECP in parsing is provisional at this stage, leads to some horribly stuff in Parser.y and RdrHsSyn. It is an extensive but not invasive change. I think (AZ). Locally it reports some parsing tests using less memory. Add ApiAnns to the HsExpr data structure. rebase. Change HsMatchContext and HsStmtContext to use an id, not a GhcPass parameter. Add ApiAnns to Hs/Types Rebase Rebased 2020-03-25 WIP on in-tree annotations Includes updating HsModule Imports LocateA ImportDecl so we can hang AnnSemi off it A whole bunch of stuff more InjectivityAnn and FamEqn now have annotations in them Add annotations to context srcspan ---- In-tree annotations: LHsDecl and LHsBind LocatedA ---- WIP on in-tree annotations ---- in-tree annotations: LHsType is now LocatedA ---- FunDeps is now also a HS data type ---- WIP. Added LocatedA to Pat, Expr, Decl And worked some more through Parser.y ---- LStmt now Located ---- Finished working through Parser.y, tests seem ok failures relate to annotations. Adding test infrastructure for check-exact Like check-ppr, but checking for an exact reproduction of the parsed source file. Starting to work on actual exact printer Bring in ApiAnnName As an alternative for LocatedA, to be used for names only. Carrying extra name adornments, such as locations of backticks, parens, etc. Working on changing ApiAnnName to accurately reflect actual usage Get rid of AnnApiName in favour of LocatedN Working on check-exact. Making progress Working on the ghc-exact bit Progress, can reproduce the first Test.hs file. Move API Annotations out of the extensions to annotations - - - - - 30 changed files: - .gitlab/test-metrics.sh - .gitmodules - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/SPARC/CodeGen/Base.hs - compiler/GHC/CmmToAsm/SPARC/Regs.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/195c9d4ffa8b39b4acdf66770d17051ae5ed4337...03fa85748b5f025c78d5d0e261d4be18aff2e2ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/195c9d4ffa8b39b4acdf66770d17051ae5ed4337...03fa85748b5f025c78d5d0e261d4be18aff2e2ce You're receiving 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 Jul 9 21:45:43 2020 From: gitlab at gitlab.haskell.org (Vilem-Benjamin Liepelt) Date: Thu, 09 Jul 2020 17:45:43 -0400 Subject: [Git][ghc/ghc][wip/buggymcbugfix/arrayOf-primop] Add smallarray cases in evac and scav Message-ID: <5f0790073fd5e_80bda8bdb425110cb@gitlab.haskell.org.mail> Vilem-Benjamin Liepelt pushed to branch wip/buggymcbugfix/arrayOf-primop at Glasgow Haskell Compiler / GHC Commits: 9e33d989 by buggymcbugfix at 2020-07-09T23:16:43+02:00 Add smallarray cases in evac and scav - - - - - 2 changed files: - rts/sm/Evac.c - rts/sm/Scav.c Changes: ===================================== rts/sm/Evac.c ===================================== @@ -631,6 +631,13 @@ loop: */ return; + case SMALL_MUT_ARR_PTRS_CLEAN: + case SMALL_MUT_ARR_PTRS_DIRTY: + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: + evacuate_static_object(STATIC_LINK(info, (StgSmallMutArrPtrs*)q), q); + return; + default: barf("evacuate(static): strange closure type %d", (int)(info->type)); } ===================================== rts/sm/Scav.c ===================================== @@ -1791,6 +1791,20 @@ scavenge_static(void) } break; } + case SMALL_MUT_ARR_PTRS_CLEAN: + case SMALL_MUT_ARR_PTRS_DIRTY: + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: + { + StgPtr q, next; + StgSmallMutArrPtrs* arr = (StgSmallMutArrPtrs*)p; + next = (P_)arr->payload + arr->ptrs; + // evacuate the pointers + for (q = (P_)arr->payload; q < next; q++) { + evacuate((StgClosure **)q); + } + break; + } default: barf("scavenge_static: strange closure %d", (int)(info->type)); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e33d989ff4557bfc495eb3e2d97eccedf8d6b8c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e33d989ff4557bfc495eb3e2d97eccedf8d6b8c You're receiving 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 Jul 10 03:30:28 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Thu, 09 Jul 2020 23:30:28 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] 31 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f07e0d412e10_80b114013dc25261e4@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - 4c5ec3c1 by Moritz Angermann at 2020-07-10T03:29:58+00:00 Cross Test Suite - - - - - e743d517 by Moritz Angermann at 2020-07-10T03:29:58+00:00 platform backwards compat, until libraries are patched. - - - - - f1d5e39d by Moritz Angermann at 2020-07-10T03:29:58+00:00 unbreak test.mk - - - - - c749d0cd by Moritz Angermann at 2020-07-10T03:29:58+00:00 default TEST_WRAPPER - - - - - b0587218 by Moritz Angermann at 2020-07-10T03:29:58+00:00 m( - - - - - 72ff2121 by Moritz Angermann at 2020-07-10T03:29:58+00:00 Fixup the test-suite - - - - - 30 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Unit/Types.hs - configure.ac - docs/users_guide/8.12.1-notes.rst - docs/users_guide/phases.rst - docs/users_guide/shared_libs.rst - hadrian/.gitignore - hadrian/README.md - hadrian/doc/make.md - hadrian/ghci-cabal → hadrian/ghci-cabal.in - hadrian/ghci-stack → hadrian/ghci-stack.in - hadrian/src/CommandLine.hs - hadrian/src/Main.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Default.hs - hadrian/src/Target.hs - libraries/base/GHC/Natural.hs - libraries/base/tests/IO/Makefile - libraries/base/tests/IO/T12010/Makefile The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d142e4f43c89685e97771b79a93fc9800abeaa54...72ff21211b7d86fb10bb9634d2e746f605f38cf0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d142e4f43c89685e97771b79a93fc9800abeaa54...72ff21211b7d86fb10bb9634d2e746f605f38cf0 You're receiving 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 Jul 10 10:39:38 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 10 Jul 2020 06:39:38 -0400 Subject: [Git][ghc/ghc][wip/angerman/out-of-range-reloc] 3 commits: Fix GHCi :print on big-endian platforms Message-ID: <5f08456ad476_80bda8bdb4253786f@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/out-of-range-reloc at Glasgow Haskell Compiler / GHC Commits: b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - aedfeb0b by Moritz Angermann at 2020-07-10T18:38:57+08:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - 11 changed files: - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Runtime/Heap/Inspect.hs - rts/Linker.c - rts/LinkerInternals.h - rts/linker/Elf.c - rts/linker/LoadArchive.c - rts/linker/M32Alloc.c - rts/linker/MachO.c - rts/linker/SymbolExtras.c - rts/linker/elf_got.c - testsuite/tests/ghci.debugger/scripts/all.T Changes: ===================================== compiler/GHC/CmmToLlvm/CodeGen.hs ===================================== @@ -353,7 +353,7 @@ genCall (PrimTarget (MO_U_Mul2 w)) [dstH, dstL] [lhs, rhs] = runStmtsDecls $ do statement $ Store retL dstRegL statement $ Store retH dstRegH -genCall (PrimTarget (MO_S_Mul2 w)) [dstH, dstL] [lhs, rhs] = runStmtsDecls $ do +genCall (PrimTarget (MO_S_Mul2 w)) [dstC, dstH, dstL] [lhs, rhs] = runStmtsDecls $ do let width = widthToLlvmInt w bitWidth = widthInBits w width2x = LMInt (bitWidth * 2) @@ -373,10 +373,18 @@ genCall (PrimTarget (MO_S_Mul2 w)) [dstH, dstL] [lhs, rhs] = runStmtsDecls $ do retShifted <- doExprW width2x $ LlvmOp LM_MO_AShr retV widthLlvmLit -- And extract them into retH. retH <- doExprW width $ Cast LM_Trunc retShifted width + -- Check if the carry is useful by doing a full arithmetic right shift on + -- retL and comparing the result with retH + let widthLlvmLitm1 = LMLitVar $ LMIntLit (fromIntegral bitWidth - 1) width + retH' <- doExprW width $ LlvmOp LM_MO_AShr retL widthLlvmLitm1 + retC1 <- doExprW i1 $ Compare LM_CMP_Ne retH retH' -- Compare op returns a 1-bit value (i1) + retC <- doExprW width $ Cast LM_Zext retC1 width -- so we zero-extend it dstRegL <- getCmmRegW (CmmLocal dstL) dstRegH <- getCmmRegW (CmmLocal dstH) + dstRegC <- getCmmRegW (CmmLocal dstC) statement $ Store retL dstRegL statement $ Store retH dstRegH + statement $ Store retC dstRegC -- MO_U_QuotRem2 is another case we handle by widening the registers to double -- the width and use normal LLVM instructions (similarly to the MO_U_Mul2). The ===================================== compiler/GHC/Runtime/Heap/Inspect.hs ===================================== @@ -870,20 +870,21 @@ extractSubTerms recurse clos = liftM thdOf3 . go 0 0 (error "unboxedTupleTerm: no HValue for unboxed tuple") terms -- Extract a sub-word sized field from a word - index item_size_b index_b word_size endian = - (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes - where - mask :: Word - mask = case item_size_b of - 1 -> 0xFF - 2 -> 0xFFFF - 4 -> 0xFFFFFFFF - _ -> panic ("Weird byte-index: " ++ show index_b) - (q,r) = index_b `quotRem` word_size - word = array!!q - moveBytes = case endian of - BigEndian -> word_size - (r + item_size_b) * 8 - LittleEndian -> r * 8 + -- A sub word is aligned to the left-most part of a word on big-endian + -- platforms, and to the right-most part of a word on little-endian + -- platforms. This allows to write and read it back from memory + -- independent of endianness. Bits not belonging to a sub word are zeroed + -- out, although, this is strictly speaking not necessary since a sub word + -- is read back from memory by appropriately casted pointers (see e.g. + -- ppr_float of cPprTermBase). + index size_b aligned_idx word_size endian = case endian of + BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits + LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits + where + (q, r) = aligned_idx `quotRem` word_size + word = array!!q + moveBits = r * 8 + zeroOutBits = (word_size - size_b) * 8 -- | Fast, breadth-first Type reconstruction ===================================== rts/Linker.c ===================================== @@ -188,7 +188,7 @@ int ocTryLoad( ObjectCode* oc ); * * MAP_32BIT not available on OpenBSD/amd64 */ -#if defined(MAP_32BIT) && defined(x86_64_HOST_ARCH) +#if defined(MAP_32BIT) && (defined(x86_64_HOST_ARCH) || (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH))) #define MAP_LOW_MEM #define TRY_MAP_32BIT MAP_32BIT #else @@ -214,10 +214,22 @@ int ocTryLoad( ObjectCode* oc ); * systems, we have to pick a base address in the low 2Gb of the address space * and try to allocate memory from there. * + * The same holds for aarch64, where the default, even with PIC, model + * is 4GB. The linker is free to emit AARCH64_ADR_PREL_PG_HI21 + * relocations. + * * We pick a default address based on the OS, but also make this * configurable via an RTS flag (+RTS -xm) */ -#if defined(MAP_32BIT) || DEFAULT_LINKER_ALWAYS_PIC + +#if (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH)) +// Try to use stg_upd_frame_info as the base. We need to be within +-4GB of that +// address, otherwise we violate the aarch64 memory model. Any object we load +// can potentially reference any of the ones we bake into the binary (and list) +// in RtsSymbols. Thus we'll need to be within +-4GB of those, +// stg_upd_frame_info is a good candidate as it's referenced often. +#define MMAP_32BIT_BASE_DEFAULT (void*)&stg_upd_frame_info; +#elif defined(MAP_32BIT) || DEFAULT_LINKER_ALWAYS_PIC // Try to use MAP_32BIT #define MMAP_32BIT_BASE_DEFAULT 0 #else @@ -1040,11 +1052,47 @@ resolveSymbolAddr (pathchar* buffer, int size, } #if RTS_LINKER_USE_MMAP + +/* ----------------------------------------------------------------------------- + Occationally we depend on mmap'd region being close to already mmap'd regions. + + Our static in-memory linker may be restricted by the architectures relocation + range. E.g. aarch64 has a +-4GB range for PIC code, thus we'd preferrably + get memory for the linker close to existing mappings. mmap on it's own is + free to return any memory location, independent of what the preferred + location argument indicates. + + For example mmap (via qemu) might give you addresses all over the available + memory range if the requested location is already occupied. + + mmap_next will do a linear search from the start page upwards to find a + suitable location that is as close as possible to the locations (proivded + via the first argument). + -------------------------------------------------------------------------- */ + +void* +mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { + if(addr == NULL) return mmap(addr, length, prot, flags, fd, offset); + // we are going to look for up to pageSize * 1024 * 1024 (4GB) from the + // address. + size_t pageSize = getPageSize(); + for(int i = (uintptr_t)addr & (pageSize-1) ? 1 : 0; i < 1024*1024; i++) { + void *target = (void*)(((uintptr_t)addr & ~(pageSize-1))+(i*pageSize)); + void *mem = mmap(target, length, prot, flags, fd, offset); + if(mem == NULL) return mem; + if(mem == target) return mem; + munmap(mem, length); + IF_DEBUG(linker && (i % 1024 == 0), + debugBelch("mmap_next failed to find suitable space in %p - %p\n", addr, target)); + } + return NULL; +} + // // Returns NULL on failure. // void * -mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset) +mmapForLinker (size_t bytes, uint32_t prot, uint32_t flags, int fd, int offset) { void *map_addr = NULL; void *result; @@ -1065,15 +1113,14 @@ mmap_again: map_addr = mmap_32bit_base; } - const int prot = PROT_READ | PROT_WRITE; IF_DEBUG(linker, debugBelch("mmapForLinker: \tprotection %#0x\n", prot)); IF_DEBUG(linker, debugBelch("mmapForLinker: \tflags %#0x\n", MAP_PRIVATE | tryMap32Bit | fixed | flags)); - result = mmap(map_addr, size, prot, - MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); + result = mmap_next(map_addr, size, prot, + MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); if (result == MAP_FAILED) { sysErrorBelch("mmap %" FMT_Word " bytes at %p",(W_)size,map_addr); @@ -1126,6 +1173,28 @@ mmap_again: goto mmap_again; } } +#elif (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH)) + // for aarch64 we need to make sure we stay within 4GB of the + // mmap_32bit_base, and we also do not want to update it. +// if (mmap_32bit_base != (void*)&stg_upd_frame_info) { + if (result == map_addr) { + mmap_32bit_base = (void*)((uintptr_t)map_addr + size); + } else { + // upper limit 4GB - size of the object file - 1mb wiggle room. + if(llabs((uintptr_t)result - (uintptr_t)&stg_upd_frame_info) > (2<<32) - size - (2<<20)) { + // not within range :( + debugTrace(DEBUG_linker, + "MAP_32BIT didn't work; gave us %lu bytes at 0x%p", + bytes, result); + munmap(result, size); + // TODO: some abort/mmap_32bit_base recomputation based on + // if mmap_32bit_base is changed, or still at stg_upd_frame_info + goto mmap_again; + } else { + mmap_32bit_base = (void*)((uintptr_t)result + size); + } + } +// } #endif IF_DEBUG(linker, @@ -1454,9 +1523,9 @@ preloadObjectFile (pathchar *path) * See also the misalignment logic for darwin below. */ #if defined(ios_HOST_OS) - image = mmap(NULL, fileSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); + image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); #else - image = mmap(NULL, fileSize, PROT_READ|PROT_WRITE|PROT_EXEC, + image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, fd, 0); #endif ===================================== rts/LinkerInternals.h ===================================== @@ -14,6 +14,7 @@ #if RTS_LINKER_USE_MMAP #include +void* mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset); #endif void printLoadedObjects(void); @@ -293,7 +294,7 @@ void exitLinker( void ); void freeObjectCode (ObjectCode *oc); SymbolAddr* loadSymbol(SymbolName *lbl, RtsSymbolInfo *pinfo); -void *mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset); +void *mmapForLinker (size_t bytes, uint32_t prot, uint32_t flags, int fd, int offset); void mmapForLinkerMarkExecutable (void *start, size_t len); void addProddableBlock ( ObjectCode* oc, void* start, int size ); ===================================== rts/linker/Elf.c ===================================== @@ -637,7 +637,7 @@ mapObjectFileSection (int fd, Elf_Word offset, Elf_Word size, pageOffset = roundDownToPage(offset); pageSize = roundUpToPage(offset-pageOffset+size); - p = mmapForLinker(pageSize, 0, fd, pageOffset); + p = mmapForLinker(pageSize, PROT_READ | PROT_WRITE, 0, fd, pageOffset); if (p == NULL) return NULL; *mapped_size = pageSize; *mapped_offset = pageOffset; @@ -709,7 +709,7 @@ ocGetNames_ELF ( ObjectCode* oc ) * address might be out of range for sections that are mmaped. */ alloc = SECTION_MMAP; - start = mmapForLinker(size, MAP_ANONYMOUS, -1, 0); + start = mmapForLinker(size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); mapped_start = start; mapped_offset = 0; mapped_size = roundUpToPage(size); @@ -751,8 +751,9 @@ ocGetNames_ELF ( ObjectCode* oc ) unsigned nstubs = numberOfStubsForSection(oc, i); unsigned stub_space = STUB_SIZE * nstubs; - void * mem = mmapForLinker(size+stub_space, MAP_ANON, -1, 0); - if( mem == NULL ) { + void * mem = mmapForLinker(size+stub_space, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + + if( mem == MAP_FAILED ) { barf("failed to mmap allocated memory to load section %d. " "errno = %d", i, errno); } @@ -841,6 +842,26 @@ ocGetNames_ELF ( ObjectCode* oc ) unsigned curSymbol = 0; + unsigned long common_size = 0; + unsigned long common_used = 0; + for(ElfSymbolTable *symTab = oc->info->symbolTables; + symTab != NULL; symTab = symTab->next) { + for (size_t j = 0; j < symTab->n_symbols; j++) { + ElfSymbol *symbol = &symTab->symbols[j]; + if (SHN_COMMON == symTab->symbols[j].elf_sym->st_shndx) { + common_size += symbol->elf_sym->st_size; + } + } + } + void * common_mem = NULL; + if(common_size > 0) { + common_mem = mmapForLinker(common_size, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, + -1, 0); + ASSERT(common_mem != NULL); + } + //TODO: we ignore local symbols anyway right? So we can use the // shdr[i].sh_info to get the index of the first non-local symbol // ie we should use j = shdr[i].sh_info @@ -876,12 +897,15 @@ ocGetNames_ELF ( ObjectCode* oc ) if (shndx == SHN_COMMON) { isLocal = false; - symbol->addr = stgCallocBytes(1, symbol->elf_sym->st_size, - "ocGetNames_ELF(COMMON)"); - /* - debugBelch("COMMON symbol, size %d name %s\n", - stab[j].st_size, nm); - */ + ASSERT(common_used < common_size); + ASSERT(common_mem); + symbol->addr = (void*)((uintptr_t)common_mem + common_used); + common_used += symbol->elf_sym->st_size; + ASSERT(common_used <= common_size); + + debugBelch("COMMON symbol, size %ld name %s allocated at %p\n", + symbol->elf_sym->st_size, nm, symbol->addr); + /* Pointless to do addProddableBlock() for this area, since the linker should never poke around in it. */ } else if ((ELF_ST_BIND(symbol->elf_sym->st_info) == STB_GLOBAL ===================================== rts/linker/LoadArchive.c ===================================== @@ -489,7 +489,7 @@ static HsInt loadArchive_ (pathchar *path) #if defined(darwin_HOST_OS) || defined(ios_HOST_OS) if (RTS_LINKER_USE_MMAP) - image = mmapForLinker(memberSize, MAP_ANONYMOUS, -1, 0); + image = mmapForLinker(memberSize, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); else { /* See loadObj() */ misalignment = machoGetMisalignment(f); @@ -548,7 +548,7 @@ while reading filename from `%" PATH_FMT "'", path); } DEBUG_LOG("Found GNU-variant file index\n"); #if RTS_LINKER_USE_MMAP - gnuFileIndex = mmapForLinker(memberSize + 1, MAP_ANONYMOUS, -1, 0); + gnuFileIndex = mmapForLinker(memberSize + 1, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); #else gnuFileIndex = stgMallocBytes(memberSize + 1, "loadArchive(image)"); #endif ===================================== rts/linker/M32Alloc.c ===================================== @@ -256,7 +256,7 @@ m32_alloc_page(void) m32_free_page_pool_size --; return page; } else { - struct m32_page_t *page = mmapForLinker(getPageSize(),MAP_ANONYMOUS,-1,0); + struct m32_page_t *page = mmapForLinker(getPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); if (page > (struct m32_page_t *) 0xffffffff) { barf("m32_alloc_page: failed to get allocation in lower 32-bits"); } @@ -280,7 +280,7 @@ m32_allocator_new(bool executable) // Preallocate the initial M32_MAX_PAGES to ensure that they don't // fragment the memory. size_t pgsz = getPageSize(); - char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES,MAP_ANONYMOUS,-1,0); + char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,-1,0); if (bigchunk == NULL) barf("m32_allocator_init: Failed to map"); @@ -396,7 +396,7 @@ m32_alloc(struct m32_allocator_t *alloc, size_t size, size_t alignment) if (m32_is_large_object(size,alignment)) { // large object size_t alsize = ROUND_UP(sizeof(struct m32_page_t), alignment); - struct m32_page_t *page = mmapForLinker(alsize+size,MAP_ANONYMOUS,-1,0); + struct m32_page_t *page = mmapForLinker(alsize+size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,-1,0); page->filled_page.size = alsize + size; m32_allocator_push_filled_list(&alloc->unprotected_list, (struct m32_page_t *) page); return (char*) page + alsize; ===================================== rts/linker/MachO.c ===================================== @@ -508,7 +508,7 @@ makeGot(ObjectCode * oc) { if(got_slots > 0) { oc->info->got_size = got_slots * sizeof(void*); - oc->info->got_start = mmap(NULL, oc->info->got_size, + oc->info->got_start = mmapForLinker(oc->info->got_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); @@ -1114,7 +1114,7 @@ ocBuildSegments_MachO(ObjectCode *oc) return 1; } - mem = mmapForLinker(size_compound, MAP_ANON, -1, 0); + mem = mmapForLinker(size_compound, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); if (NULL == mem) return 0; IF_DEBUG(linker, debugBelch("ocBuildSegments: allocating %d segments\n", n_activeSegments)); ===================================== rts/linker/SymbolExtras.c ===================================== @@ -79,7 +79,7 @@ int ocAllocateExtras(ObjectCode* oc, int count, int first, int bssSize) size_t n = roundUpToPage(oc->fileSize); bssSize = roundUpToAlign(bssSize, 8); size_t allocated_size = n + bssSize + extras_size; - void *new = mmapForLinker(allocated_size, MAP_ANONYMOUS, -1, 0); + void *new = mmapForLinker(allocated_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); if (new) { memcpy(new, oc->image, oc->fileSize); if (oc->imageMapped) { ===================================== rts/linker/elf_got.c ===================================== @@ -48,7 +48,7 @@ makeGot(ObjectCode * oc) { } if(got_slots > 0) { oc->info->got_size = got_slots * sizeof(void *); - void * mem = mmap(NULL, oc->info->got_size, + void * mem = mmapForLinker(oc->info->got_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); ===================================== testsuite/tests/ghci.debugger/scripts/all.T ===================================== @@ -28,9 +28,7 @@ test('print020', [extra_files(['../HappyTest.hs']), omit_ways(['ghci-ext'])], ghci_script, ['print020.script']) test('print021', normal, ghci_script, ['print021.script']) -test('print022', - [when(arch('powerpc64'), expect_broken(14455))], - ghci_script, ['print022.script']) +test('print022', normal, ghci_script, ['print022.script']) test('print023', extra_files(['../Test.hs']), ghci_script, ['print023.script']) test('print024', extra_files(['../Test.hs']), ghci_script, ['print024.script']) test('print025', normal, ghci_script, ['print025.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b7b1720236236068e2bed4cfe85918a1e712fc4a...aedfeb0b2b22172a0dfca0fe0c020ac80539d6ae -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b7b1720236236068e2bed4cfe85918a1e712fc4a...aedfeb0b2b22172a0dfca0fe0c020ac80539d6ae You're receiving 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 Jul 10 11:12:17 2020 From: gitlab at gitlab.haskell.org (Peter Trommler) Date: Fri, 10 Jul 2020 07:12:17 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18431 Message-ID: <5f084d11701bc_80b3f849c221f4025382e5@gitlab.haskell.org.mail> Peter Trommler pushed new branch wip/T18431 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18431 You're receiving 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 Jul 10 13:52:29 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Fri, 10 Jul 2020 09:52:29 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/jsonProfEscaping Message-ID: <5f08729d3380c_80b3f848662eb1c2549483@gitlab.haskell.org.mail> Andreas Klebinger pushed new branch wip/andreask/jsonProfEscaping at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/jsonProfEscaping You're receiving 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 Jul 10 13:53:09 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Fri, 10 Jul 2020 09:53:09 -0400 Subject: [Git][ghc/ghc][wip/andreask/jsonProfEscaping] Escape backslashes in json profiling reports properly. Message-ID: <5f0872c53b3a_80b114013dc25496e5@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/jsonProfEscaping at Glasgow Haskell Compiler / GHC Commits: 8ef59825 by Andreas Klebinger at 2020-07-10T15:52:59+02:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 1 changed file: - rts/ProfilerReportJson.c Changes: ===================================== rts/ProfilerReportJson.c ===================================== @@ -6,6 +6,7 @@ * * ---------------------------------------------------------------------------*/ +#define PROFILING #if defined(PROFILING) #include "PosixSource.h" @@ -15,23 +16,33 @@ #include "ProfilerReportJson.h" #include "Profiling.h" -// This only handles characters that you might see in a Haskell cost-centre -// name. -static void escapeString(char const* str, char *out, int len) +// I don't think this code is all that perf critical. +// So we just allocate a new buffer each time around. +static void escapeString(char const* str, char **buf) { - len--; // reserve character in output for terminating NUL - for (; *str != '\0' && len > 0; str++) { + char *out; + size_t req_size; //Max required size for decoding. + size_t in_size; //Input size, including zero. + + in_size = strlen(str) + 1; + // The strings are generally small and short + // lived so should be ok to just double the size. + req_size = in_size * 2; + out = stgMallocBytes(req_size, "writeCCSReportJson"); + *buf = out; + // We provide an outputbuffer twice the size of the input, + // and at worse double the output size. So we can skip + // length checks. + for (; *str != '\0'; str++) { char c = *str; if (c == '\\') { - if (len < 2) break; - *out = '\\'; out++; len--; - *out = '\\'; out++; len--; + *out = '\\'; out++; + *out = '\\'; out++; } else if (c == '\n') { - if (len < 2) break; - *out = '\\'; out++; len--; - *out = 'n'; out++; len--; + *out = '\\'; out++; + *out = 'n'; out++; } else { - *out = c; out++; len--; + *out = c; out++; } } *out = '\0'; @@ -40,11 +51,13 @@ static void escapeString(char const* str, char *out, int len) static void logCostCentres(FILE *prof_file) { - char tmp[256]; + char* lbl; + char* src_loc; bool needs_comma = false; fprintf(prof_file, "[\n"); for (CostCentre *cc = CC_LIST; cc != NULL; cc = cc->link) { - escapeString(cc->label, tmp, sizeof(tmp)); + escapeString(cc->label, &lbl); + escapeString(cc->srcloc, &src_loc); fprintf(prof_file, "%s" "{\"id\": %" FMT_Int ", " @@ -53,11 +66,13 @@ logCostCentres(FILE *prof_file) "\"src_loc\": \"%s\", " "\"is_caf\": %s}", needs_comma ? ", " : "", - cc->ccID, tmp, cc->module, cc->srcloc, + cc->ccID, lbl, cc->module, src_loc, cc->is_caf ? "true" : "false"); needs_comma = true; } fprintf(prof_file, "]\n"); + stgFree(lbl); + stgFree(src_loc); } static void @@ -92,15 +107,24 @@ writeCCSReportJson(FILE *prof_file, CostCentreStack const *stack, ProfilerTotals totals) { + fprintf(prof_file, "{\n\"program\": \"%s\",\n", prog_name); fprintf(prof_file, "\"arguments\": ["); - for (int count = 0; prog_argv[count]; count++) + for (int count = 0; prog_argv[count]; count++) { + char* arg; + escapeString(prog_argv[count], &arg); fprintf(prof_file, "%s\"%s\"", - count == 0 ? "" : ", ", prog_argv[count]); + count == 0 ? "" : ", ", arg); + stgFree(arg); + } fprintf(prof_file, "],\n\"rts_arguments\": ["); - for (int count = 0; rts_argv[count]; count++) + for (int count = 0; rts_argv[count]; count++) { + char* arg; + escapeString(rts_argv[count], &arg); fprintf(prof_file, "%s\"%s\"", - count == 0 ? "" : ", ", rts_argv[count]); + count == 0 ? "" : ", ", arg); + stgFree(arg); + } fprintf(prof_file, "],\n"); fprintf(prof_file, "\"end_time\": \"%s\",\n", time_str()); @@ -121,6 +145,7 @@ writeCCSReportJson(FILE *prof_file, fprintf(prof_file, ",\n\"profile\": "); logCostCentreStack(prof_file, stack); fprintf(prof_file, "}\n"); + } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8ef5982548113c789c238270809e541e706e30a6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8ef5982548113c789c238270809e541e706e30a6 You're receiving 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 Jul 10 14:34:24 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 10 Jul 2020 10:34:24 -0400 Subject: [Git][ghc/ghc][wip/T18328] 35 commits: rts/ProfHeap: Only allocate the Censuses that we need Message-ID: <5f087c70d0a3d_80b3f848e5b86582560493@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18328 at Glasgow Haskell Compiler / GHC Commits: 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - da1a239d by Simon Peyton Jones at 2020-07-10T10:34:09-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric decrease: T3064 T3294 T12707 T13056 - - - - - 27 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Driver.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Module.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3fcefa7a0a39228f86b3770d9d6c7bc005f273b8...da1a239d0007060b65f513cce7ec06f74ee2aee1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3fcefa7a0a39228f86b3770d9d6c7bc005f273b8...da1a239d0007060b65f513cce7ec06f74ee2aee1 You're receiving 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 Jul 10 14:56:09 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Fri, 10 Jul 2020 10:56:09 -0400 Subject: [Git][ghc/ghc][wip/andreask/jsonProfEscaping] Escape backslashes in json profiling reports properly. Message-ID: <5f0881896674e_80b3f848662eb1c256119f@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/jsonProfEscaping at Glasgow Haskell Compiler / GHC Commits: 2331686b by Andreas Klebinger at 2020-07-10T16:56:00+02:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 1 changed file: - rts/ProfilerReportJson.c Changes: ===================================== rts/ProfilerReportJson.c ===================================== @@ -15,23 +15,33 @@ #include "ProfilerReportJson.h" #include "Profiling.h" -// This only handles characters that you might see in a Haskell cost-centre -// name. -static void escapeString(char const* str, char *out, int len) +// I don't think this code is all that perf critical. +// So we just allocate a new buffer each time around. +static void escapeString(char const* str, char **buf) { - len--; // reserve character in output for terminating NUL - for (; *str != '\0' && len > 0; str++) { + char *out; + size_t req_size; //Max required size for decoding. + size_t in_size; //Input size, including zero. + + in_size = strlen(str) + 1; + // The strings are generally small and short + // lived so should be ok to just double the size. + req_size = in_size * 2; + out = stgMallocBytes(req_size, "writeCCSReportJson"); + *buf = out; + // We provide an outputbuffer twice the size of the input, + // and at worse double the output size. So we can skip + // length checks. + for (; *str != '\0'; str++) { char c = *str; if (c == '\\') { - if (len < 2) break; - *out = '\\'; out++; len--; - *out = '\\'; out++; len--; + *out = '\\'; out++; + *out = '\\'; out++; } else if (c == '\n') { - if (len < 2) break; - *out = '\\'; out++; len--; - *out = 'n'; out++; len--; + *out = '\\'; out++; + *out = 'n'; out++; } else { - *out = c; out++; len--; + *out = c; out++; } } *out = '\0'; @@ -40,11 +50,13 @@ static void escapeString(char const* str, char *out, int len) static void logCostCentres(FILE *prof_file) { - char tmp[256]; + char* lbl; + char* src_loc; bool needs_comma = false; fprintf(prof_file, "[\n"); for (CostCentre *cc = CC_LIST; cc != NULL; cc = cc->link) { - escapeString(cc->label, tmp, sizeof(tmp)); + escapeString(cc->label, &lbl); + escapeString(cc->srcloc, &src_loc); fprintf(prof_file, "%s" "{\"id\": %" FMT_Int ", " @@ -53,11 +65,13 @@ logCostCentres(FILE *prof_file) "\"src_loc\": \"%s\", " "\"is_caf\": %s}", needs_comma ? ", " : "", - cc->ccID, tmp, cc->module, cc->srcloc, + cc->ccID, lbl, cc->module, src_loc, cc->is_caf ? "true" : "false"); needs_comma = true; } fprintf(prof_file, "]\n"); + stgFree(lbl); + stgFree(src_loc); } static void @@ -92,15 +106,24 @@ writeCCSReportJson(FILE *prof_file, CostCentreStack const *stack, ProfilerTotals totals) { + fprintf(prof_file, "{\n\"program\": \"%s\",\n", prog_name); fprintf(prof_file, "\"arguments\": ["); - for (int count = 0; prog_argv[count]; count++) + for (int count = 0; prog_argv[count]; count++) { + char* arg; + escapeString(prog_argv[count], &arg); fprintf(prof_file, "%s\"%s\"", - count == 0 ? "" : ", ", prog_argv[count]); + count == 0 ? "" : ", ", arg); + stgFree(arg); + } fprintf(prof_file, "],\n\"rts_arguments\": ["); - for (int count = 0; rts_argv[count]; count++) + for (int count = 0; rts_argv[count]; count++) { + char* arg; + escapeString(rts_argv[count], &arg); fprintf(prof_file, "%s\"%s\"", - count == 0 ? "" : ", ", rts_argv[count]); + count == 0 ? "" : ", ", arg); + stgFree(arg); + } fprintf(prof_file, "],\n"); fprintf(prof_file, "\"end_time\": \"%s\",\n", time_str()); @@ -121,6 +144,7 @@ writeCCSReportJson(FILE *prof_file, fprintf(prof_file, ",\n\"profile\": "); logCostCentreStack(prof_file, stack); fprintf(prof_file, "}\n"); + } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2331686b2b7bba160a863469b18c566f427a9db7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2331686b2b7bba160a863469b18c566f427a9db7 You're receiving 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 Jul 10 20:44:58 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Fri, 10 Jul 2020 16:44:58 -0400 Subject: [Git][ghc/ghc][wip/andreask/jsonProfEscaping] Escape backslashes in json profiling reports properly. Message-ID: <5f08d34adbb15_80b3f8490174d3825975ec@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/jsonProfEscaping at Glasgow Haskell Compiler / GHC Commits: fecafac8 by Andreas Klebinger at 2020-07-10T22:44:45+02:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 1 changed file: - rts/ProfilerReportJson.c Changes: ===================================== rts/ProfilerReportJson.c ===================================== @@ -15,23 +15,35 @@ #include "ProfilerReportJson.h" #include "Profiling.h" -// This only handles characters that you might see in a Haskell cost-centre -// name. -static void escapeString(char const* str, char *out, int len) +#include + +// I don't think this code is all that perf critical. +// So we just allocate a new buffer each time around. +static void escapeString(char const* str, char **buf) { - len--; // reserve character in output for terminating NUL - for (; *str != '\0' && len > 0; str++) { + char *out; + size_t req_size; //Max required size for decoding. + size_t in_size; //Input size, including zero. + + in_size = strlen(str) + 1; + // The strings are generally small and short + // lived so should be ok to just double the size. + req_size = in_size * 2; + out = stgMallocBytes(req_size, "writeCCSReportJson"); + *buf = out; + // We provide an outputbuffer twice the size of the input, + // and at worse double the output size. So we can skip + // length checks. + for (; *str != '\0'; str++) { char c = *str; if (c == '\\') { - if (len < 2) break; - *out = '\\'; out++; len--; - *out = '\\'; out++; len--; + *out = '\\'; out++; + *out = '\\'; out++; } else if (c == '\n') { - if (len < 2) break; - *out = '\\'; out++; len--; - *out = 'n'; out++; len--; + *out = '\\'; out++; + *out = 'n'; out++; } else { - *out = c; out++; len--; + *out = c; out++; } } *out = '\0'; @@ -40,11 +52,13 @@ static void escapeString(char const* str, char *out, int len) static void logCostCentres(FILE *prof_file) { - char tmp[256]; + char* lbl; + char* src_loc; bool needs_comma = false; fprintf(prof_file, "[\n"); for (CostCentre *cc = CC_LIST; cc != NULL; cc = cc->link) { - escapeString(cc->label, tmp, sizeof(tmp)); + escapeString(cc->label, &lbl); + escapeString(cc->srcloc, &src_loc); fprintf(prof_file, "%s" "{\"id\": %" FMT_Int ", " @@ -53,11 +67,13 @@ logCostCentres(FILE *prof_file) "\"src_loc\": \"%s\", " "\"is_caf\": %s}", needs_comma ? ", " : "", - cc->ccID, tmp, cc->module, cc->srcloc, + cc->ccID, lbl, cc->module, src_loc, cc->is_caf ? "true" : "false"); needs_comma = true; } fprintf(prof_file, "]\n"); + stgFree(lbl); + stgFree(src_loc); } static void @@ -92,15 +108,24 @@ writeCCSReportJson(FILE *prof_file, CostCentreStack const *stack, ProfilerTotals totals) { + fprintf(prof_file, "{\n\"program\": \"%s\",\n", prog_name); fprintf(prof_file, "\"arguments\": ["); - for (int count = 0; prog_argv[count]; count++) + for (int count = 0; prog_argv[count]; count++) { + char* arg; + escapeString(prog_argv[count], &arg); fprintf(prof_file, "%s\"%s\"", - count == 0 ? "" : ", ", prog_argv[count]); + count == 0 ? "" : ", ", arg); + stgFree(arg); + } fprintf(prof_file, "],\n\"rts_arguments\": ["); - for (int count = 0; rts_argv[count]; count++) + for (int count = 0; rts_argv[count]; count++) { + char* arg; + escapeString(rts_argv[count], &arg); fprintf(prof_file, "%s\"%s\"", - count == 0 ? "" : ", ", rts_argv[count]); + count == 0 ? "" : ", ", arg); + stgFree(arg); + } fprintf(prof_file, "],\n"); fprintf(prof_file, "\"end_time\": \"%s\",\n", time_str()); @@ -121,6 +146,7 @@ writeCCSReportJson(FILE *prof_file, fprintf(prof_file, ",\n\"profile\": "); logCostCentreStack(prof_file, stack); fprintf(prof_file, "}\n"); + } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fecafac8065d951c14a23de2395e078328f856cd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fecafac8065d951c14a23de2395e078328f856cd You're receiving 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 Jul 10 21:51:48 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 10 Jul 2020 17:51:48 -0400 Subject: [Git][ghc/ghc][wip/T18412] Allow multiple case branches to have a higher rank type Message-ID: <5f08e2f4dd61a_80bda8bdb426091f3@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18412 at Glasgow Haskell Compiler / GHC Commits: 3ecd7b82 by Simon Peyton Jones at 2020-07-10T22:50:23+01:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult]. - - - - - 14 changed files: - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/Unify.hs - testsuite/tests/simplCore/should_compile/T17901.stdout - + testsuite/tests/typecheck/should_compile/T18412.hs - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T10619.stderr - testsuite/tests/typecheck/should_fail/tcfail002.stderr - testsuite/tests/typecheck/should_fail/tcfail104.stderr Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -19,7 +19,8 @@ Note [The Type-related module hierarchy] -- We expose the relevant stuff from this module via the Type module {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE CPP, DeriveDataTypeable, MultiWayIf, PatternSynonyms, BangPatterns #-} +{-# LANGUAGE CPP, MultiWayIf, PatternSynonyms, BangPatterns #-} +{-# LANGUAGE DeriveDataTypeable #-} module GHC.Core.TyCo.Rep ( TyThing(..), tyThingCategory, pprTyThingCategory, pprShortTyThing, @@ -2025,6 +2026,12 @@ GHC.Core.Multiplicity above this module. -- | A shorthand for data with an attached 'Mult' element (the multiplicity). data Scaled a = Scaled Mult a deriving (Data.Data) + -- You might think that this would be a natural candiate for + -- Functor, Traversable but Krzysztof says (!3674) "it was too easy + -- to accidentally lift functions (substitutions, zonking etc.) from + -- Type -> Type to Scaled Type -> Scaled Type, ignoring + -- multiplicities and causing bugs". So we don't. + instance (Outputable a) => Outputable (Scaled a) where ppr (Scaled _cnt t) = ppr t ===================================== compiler/GHC/Core/UsageEnv.hs ===================================== @@ -1,7 +1,7 @@ {-# LANGUAGE ViewPatterns #-} module GHC.Core.UsageEnv (UsageEnv, addUsage, scaleUsage, zeroUE, lookupUE, scaleUE, deleteUE, addUE, Usage(..), unitUE, - supUE, supUEs) where + bottomUE, supUE, supUEs) where import Data.Foldable import GHC.Prelude ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -591,10 +591,6 @@ tcExpr (HsCase x scrut matches) res_ty tcExpr (HsIf x NoSyntaxExprRn pred b1 b2) res_ty -- Ordinary 'if' = do { pred' <- tcLExpr pred (mkCheckExpType boolTy) - ; res_ty <- tauifyExpType res_ty - -- Just like Note [Case branches must never infer a non-tau type] - -- in GHC.Tc.Gen.Match (See #10619) - ; (u1,b1') <- tcCollectingUsage $ tcLExpr b1 res_ty ; (u2,b2') <- tcCollectingUsage $ tcLExpr b2 res_ty ; tcEmitBindingUsage (supUE u1 u2) @@ -611,13 +607,7 @@ tcExpr (HsIf x fun@(SyntaxExprRn {}) pred b1 b2) res_ty ; return (HsIf x fun' pred' b1' b2') } tcExpr (HsMultiIf _ alts) res_ty - = do { res_ty <- if isSingleton alts - then return res_ty - else tauifyExpType res_ty - -- Just like GHC.Tc.Gen.Match - -- Note [Case branches must never infer a non-tau type] - - ; alts' <- mapM (wrapLocM $ tcGRHS match_ctxt res_ty) alts + = do { alts' <- mapM (wrapLocM $ tcGRHS match_ctxt res_ty) alts ; res_ty <- readExpType res_ty ; return (HsMultiIf res_ty alts') } where match_ctxt = MC { mc_what = IfAlt, mc_body = tcBody } ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -164,80 +164,47 @@ tcGRHSsPat grhss res_ty = tcGRHSs match_ctxt grhss (mkCheckExpType res_ty) match_ctxt = MC { mc_what = PatBindRhs, mc_body = tcBody } -{- -************************************************************************ +{- ********************************************************************* * * -\subsection{tcMatch} + tcMatch * * -************************************************************************ - -Note [Case branches must never infer a non-tau type] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider - - case ... of - ... -> \(x :: forall a. a -> a) -> x - ... -> \y -> y - -Should that type-check? The problem is that, if we check the second branch -first, then we'll get a type (b -> b) for the branches, which won't unify -with the polytype in the first branch. If we check the first branch first, -then everything is OK. This order-dependency is terrible. So we want only -proper tau-types in branches (unless a sigma-type is pushed down). -This is what expTypeToType ensures: it replaces an Infer with a fresh -tau-type. - -An even trickier case looks like - - f x True = x undefined - f x False = x () - -Here, we see that the arguments must also be non-Infer. Thus, we must -use expTypeToType on the output of matchExpectedFunTys, not the input. - -But we make a special case for a one-branch case. This is so that - - f = \(x :: forall a. a -> a) -> x - -still gets assigned a polytype. --} +********************************************************************* -} --- | When the MatchGroup has multiple RHSs, convert an Infer ExpType in the --- expected type into TauTvs. --- See Note [Case branches must never infer a non-tau type] -tauifyMultipleMatches :: [LMatch id body] - -> [Scaled ExpType] -> TcM [Scaled ExpType] -tauifyMultipleMatches group exp_tys - | isSingletonMatchGroup group = return exp_tys - | otherwise = mapM (\(Scaled m t) -> - fmap (Scaled m) (tauifyExpType t)) exp_tys - -- NB: In the empty-match case, this ensures we fill in the ExpType +data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module + = MC { mc_what :: HsMatchContext GhcRn, -- What kind of thing this is + mc_body :: Located (body GhcRn) -- Type checker for a body of + -- an alternative + -> ExpRhoType + -> TcM (Located (body GhcTc)) } -- | Type-check a MatchGroup. tcMatches :: (Outputable (body GhcRn)) => TcMatchCtxt body -> [Scaled ExpSigmaType] -- Expected pattern types - -> ExpRhoType -- Expected result-type of the Match. + -> ExpRhoType -- Expected result-type of the Match. -> MatchGroup GhcRn (Located (body GhcRn)) -> TcM (MatchGroup GhcTc (Located (body GhcTc))) -data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module - = MC { mc_what :: HsMatchContext GhcRn, -- What kind of thing this is - mc_body :: Located (body GhcRn) -- Type checker for a body of - -- an alternative - -> ExpRhoType - -> TcM (Located (body GhcTc)) } tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches , mg_origin = origin }) - = do { (Scaled _ rhs_ty):pat_tys <- tauifyMultipleMatches matches ((Scaled One rhs_ty):pat_tys) -- return type has implicitly multiplicity 1, it doesn't matter all that much in this case since it isn't used and is eliminated immediately. - -- See Note [Case branches must never infer a non-tau type] + | null matches -- Deal with case e of {} + -- Since there are no branches, no one else will fill in rhs_ty + -- when in inference mode, so we must do it ourselves, + -- here, using expTypeToType + = do { tcEmitBindingUsage bottomUE + ; pat_tys <- mapM scaledExpTypeToType pat_tys + ; rhs_ty <- expTypeToType rhs_ty + ; return (MG { mg_alts = L l [] + , mg_ext = MatchGroupTc pat_tys rhs_ty + , mg_origin = origin }) } - ; umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches + | otherwise + = do { umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches ; let (usages,matches') = unzip umatches ; tcEmitBindingUsage $ supUEs usages - ; pat_tys <- mapM (\(Scaled m t) -> fmap (Scaled m) (readExpType t)) pat_tys + ; pat_tys <- mapM readScaledExpType pat_tys ; rhs_ty <- readExpType rhs_ty - ; return (MG { mg_alts = L l matches' - , mg_ext = MatchGroupTc pat_tys rhs_ty + ; return (MG { mg_alts = L l matches' + , mg_ext = MatchGroupTc pat_tys rhs_ty , mg_origin = origin }) } ------------- ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -629,10 +629,9 @@ There are two bits of rebindable syntax: lit1_ty and lit2_ty could conceivably be different. var_ty is the type inferred for x, the variable in the pattern. -If the pushed-down pattern type isn't a tau-type, the two pat_ty's above -could conceivably be different specializations. But this is very much -like the situation in Note [Case branches must be taus] in GHC.Tc.Gen.Match. -So we tauify the pat_ty before proceeding. +If the pushed-down pattern type isn't a tau-type, the two pat_ty's +above could conceivably be different specializations. So we use +expTypeToType on pat_ty before proceeding. Note that we need to type-check the literal twice, because it is used twice, and may be used at different types. The second HsOverLit stored in the ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -474,8 +474,6 @@ newOverloadedLit :: HsOverLit GhcRn newOverloadedLit lit@(OverLit { ol_val = val, ol_ext = rebindable }) res_ty | not rebindable - -- all built-in overloaded lits are tau-types, so we can just - -- tauify the ExpType = do { res_ty <- expTypeToType res_ty ; dflags <- getDynFlags ; let platform = targetPlatform dflags ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -36,9 +36,10 @@ module GHC.Tc.Utils.TcMType ( ExpType(..), ExpSigmaType, ExpRhoType, mkCheckExpType, newInferExpType, - readExpType, readExpType_maybe, - expTypeToType, checkingExpType_maybe, checkingExpType, - tauifyExpType, inferResultToType, + readExpType, readExpType_maybe, readScaledExpType, + expTypeToType, scaledExpTypeToType, + checkingExpType_maybe, checkingExpType, + inferResultToType, -------------------------------- -- Creating new evidence variables @@ -396,7 +397,6 @@ checkCoercionHole cv co Note [ExpType] ~~~~~~~~~~~~~~ - An ExpType is used as the "expected type" when type-checking an expression. An ExpType can hold a "hole" that can be filled in by the type-checker. This allows us to have one tcExpr that works in both checking mode and @@ -426,14 +426,13 @@ Consider This is a classic untouchable-variable / ambiguous GADT return type scenario. But, with ExpTypes, we'll be inferring the type of the RHS. -And, because there is only one branch of the case, we won't trigger -Note [Case branches must never infer a non-tau type] of GHC.Tc.Gen.Match. We thus must track a TcLevel in an Inferring ExpType. If we try to -fill the ExpType and find that the TcLevels don't work out, we -fill the ExpType with a tau-tv at the low TcLevel, hopefully to -be worked out later by some means. This is triggered in -test gadt/gadt-escape1. +fill the ExpType and find that the TcLevels don't work out, we fill +the ExpType with a tau-tv at the low TcLevel, hopefully to be worked +out later by some means -- see GHC.Tc.Utils.Unify.fillInferResult, +and Note [fillInferResult] in that module. +This behaviour triggered in test gadt/gadt-escape1. -} -- actual data definition is in GHC.Tc.Utils.TcType @@ -453,6 +452,12 @@ readExpType_maybe :: ExpType -> TcM (Maybe TcType) readExpType_maybe (Check ty) = return (Just ty) readExpType_maybe (Infer (IR { ir_ref = ref})) = readMutVar ref +-- | Same as readExpType, but for Scaled ExpTypes +readScaledExpType :: Scaled ExpType -> TcM (Scaled Type) +readScaledExpType (Scaled m exp_ty) + = do { ty <- readExpType exp_ty + ; return (Scaled m ty) } + -- | Extract a type out of an ExpType. Otherwise, panics. readExpType :: ExpType -> TcM TcType readExpType exp_ty @@ -472,12 +477,10 @@ checkingExpType :: String -> ExpType -> TcType checkingExpType _ (Check ty) = ty checkingExpType err et = pprPanic "checkingExpType" (text err $$ ppr et) -tauifyExpType :: ExpType -> TcM ExpType --- ^ Turn a (Infer hole) type into a (Check alpha), --- where alpha is a fresh unification variable -tauifyExpType (Check ty) = return (Check ty) -- No-op for (Check ty) -tauifyExpType (Infer inf_res) = do { ty <- inferResultToType inf_res - ; return (Check ty) } +scaledExpTypeToType :: Scaled ExpType -> TcM (Scaled TcType) +scaledExpTypeToType (Scaled m exp_ty) + = do { ty <- expTypeToType exp_ty + ; return (Scaled m ty) } -- | Extracts the expected type if there is one, or generates a new -- TauTv if there isn't. @@ -488,13 +491,17 @@ expTypeToType (Infer inf_res) = inferResultToType inf_res inferResultToType :: InferResult -> TcM Type inferResultToType (IR { ir_uniq = u, ir_lvl = tc_lvl , ir_ref = ref }) - = do { rr <- newMetaTyVarTyAtLevel tc_lvl runtimeRepTy + = do { mb_inferred_ty <- readTcRef ref + ; case mb_inferred_ty of { + Just ty -> return ty ; + Nothing -> + do { rr <- newMetaTyVarTyAtLevel tc_lvl runtimeRepTy ; tau <- newMetaTyVarTyAtLevel tc_lvl (tYPE rr) -- See Note [TcLevel of ExpType] ; writeMutVar ref (Just tau) ; traceTc "Forcing ExpType to be monomorphic:" (ppr u <+> text ":=" <+> ppr tau) - ; return tau } + ; return tau } } } {- ********************************************************************* ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -793,33 +793,25 @@ instantiateAndFillInferResult orig ty inf_res ; return (mkWpCastN co <.> wrap) } fillInferResult :: TcType -> InferResult -> TcM TcCoercionN --- If wrap = fillInferResult t1 t2 --- => wrap :: t1 ~> t2 -fillInferResult orig_ty (IR { ir_uniq = u, ir_lvl = res_lvl - , ir_ref = ref }) - = do { (ty_co, ty_to_fill_with) <- promoteTcType res_lvl orig_ty - - ; traceTc "Filling ExpType" $ - ppr u <+> text ":=" <+> ppr ty_to_fill_with - - ; when debugIsOn (check_hole ty_to_fill_with) - - ; writeTcRef ref (Just ty_to_fill_with) - - ; return ty_co } - where - check_hole ty -- Debug check only - = do { let ty_lvl = tcTypeLevel ty - ; MASSERT2( not (ty_lvl `strictlyDeeperThan` res_lvl), - ppr u $$ ppr res_lvl $$ ppr ty_lvl $$ - ppr ty <+> dcolon <+> ppr (tcTypeKind ty) $$ ppr orig_ty ) - ; cts <- readTcRef ref - ; case cts of - Just already_there -> pprPanic "writeExpType" - (vcat [ ppr u - , ppr ty - , ppr already_there ]) - Nothing -> return () } +-- If co = fillInferResult t1 t2 +-- => co :: t1 ~ t2 +-- See Note [fillInferResult] +fillInferResult act_res_ty (IR { ir_uniq = u, ir_lvl = res_lvl + , ir_ref = ref }) + = do { mb_exp_res_ty <- readTcRef ref + ; case mb_exp_res_ty of + Just exp_res_ty + -> do { traceTc "Joining inferred ExpType" $ + ppr u <> colon <+> ppr act_res_ty <+> char '~' <+> ppr exp_res_ty + ; ensureMonoType res_lvl act_res_ty + ; unifyType Nothing act_res_ty exp_res_ty } + Nothing + -> do { traceTc "Filling inferred ExpType" $ + ppr u <+> text ":=" <+> ppr act_res_ty + ; (prom_co, act_res_ty) <- promoteTcType res_lvl act_res_ty + ; writeTcRef ref (Just act_res_ty) + ; return prom_co } + } {- Note [Instantiation of InferResult] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -857,6 +849,81 @@ There is one place where we don't want to instantiate eagerly, namely in GHC.Tc.Module.tcRnExpr, which implements GHCi's :type command. See Note [Implementing :type] in GHC.Tc.Module. +Note [fillInferResult] +~~~~~~~~~~~~~~~~~~~~~~ +When inferring, we use fillInferResult to "fill in" the hole in InferResult + data InferResult = IR { ir_uniq :: Unique + , ir_lvl :: TcLevel + , ir_ref :: IORef (Maybe TcType) } + +There are two things to worry about: + +1. What if it is under a GADT or existential pattern match? + - GADTs: a unification variable (and Infer's hole is similar) is untouchable + - Existentials: be careful about skolem-escape + +2. What if it is filled in more than once? E.g. multiple branches of a case + case e of + T1 -> e1 + T2 -> e2 + +Our typing rules are: + +* The RHS of a existential or GADT alternative must always be a + monotype, regardless of the number of alternatives. + +* Multiple non-existential/GADT branches can have (the same) + higher rank type (#18412). E.g. this is OK: + case e of + True -> hr + False -> hr + where hr:: (forall a. a->a) -> Int + c.f. Section 7.1 of "Practical type inference for arbitrary-rank types" + We use choice (2) in that Section. + (GHC 8.10 and earlier used choice (1).) + + But note that + case e of + True -> hr + False -> \x -> hr x + will fail, because we still /infer/ both branches, so the \x will get + a (monotype) unification variable, which will fail to unify with + (forall a. a->a) + +For (1) we can detect the GADT/existential situation by seeing that +the current TcLevel is greater than that stored in ir_lvl of the Infer +ExpType. We bump the level whenever we go past a GADT/existential match. + +Then, before filling the hole use promoteTcType to promote the type +to the outer ir_lvl. promoteTcType does this + - create a fresh unification variable alpha at level ir_lvl + - emits an equality alpha[ir_lvl] ~ ty + - fills the hole with alpha +That forces the type to be a monotype (since unification variables can +only unify with monotypes); and catches skolem-escapes because the +alpha is untouchable until the equality floats out. + +For (2), we simply look to see if the hole is filled already. + - if not, we promote (as above) and fill the hole + - if it is filled, we simply unify with the type that is + already there + +There is one wrinkle. Suppose we have + case e of + T1 -> e1 :: (forall a. a->a) -> Int + G2 -> e2 +where T1 is not GADT or existential, but G2 is a GADT. Then supppose the +T1 alternative fills the hole with (forall a. a->a) -> Int, which is fine. +But now the G2 alternative must not *just* unify with that else we'd risk +allowing through (e2 :: (forall a. a->a) -> Int). If we'd checked G2 first +we'd have filled the hole with a unification variable, which enforces a +monotype. + +So if we check G2 second, we still want to emit a constraint that restricts +the RHS to be a monotype. This is done by ensureMonoType, and it works +by simply generating a constraint (alpha ~ ty), where alpha is a fresh +unification variable. We discard the evidence. + -} {- ********************************************************************* @@ -865,8 +932,22 @@ command. See Note [Implementing :type] in GHC.Tc.Module. * * ********************************************************************* -} +ensureMonoType :: TcLevel -> TcType -> TcM () +ensureMonoType dest_lvl res_ty + = do { cur_lvl <- getTcLevel + ; unless (cur_lvl `sameDepthAs` dest_lvl) $ + do { mono_ty <- newOpenFlexiTyVarTy + ; let eq_orig = TypeEqOrigin { uo_actual = res_ty + , uo_expected = mono_ty + , uo_thing = Nothing + , uo_visible = False } + + ; _co <- emitWantedEq eq_orig TypeLevel Nominal res_ty mono_ty + ; return () } } + promoteTcType :: TcLevel -> TcType -> TcM (TcCoercion, TcType) -- See Note [Promoting a type] +-- See also Note [fillInferResult] -- promoteTcType level ty = (co, ty') -- * Returns ty' whose max level is just 'level' -- and whose kind is ~# to the kind of 'ty' ===================================== testsuite/tests/simplCore/should_compile/T17901.stdout ===================================== @@ -1,14 +1,14 @@ - (wombat1 [Occ=Once*!] :: T -> p) + (wombat1 [Occ=Once*!] :: T -> t) A -> wombat1 T17901.A; B -> wombat1 T17901.B; C -> wombat1 T17901.C - = \ (@p) (wombat1 :: T -> p) (x :: T) -> + = \ (@t) (wombat1 :: T -> t) (x :: T) -> case x of wild { __DEFAULT -> wombat1 wild } - Tmpl= \ (@p) (wombat2 [Occ=Once!] :: S -> p) (x [Occ=Once] :: S) -> + Tmpl= \ (@t) (wombat2 [Occ=Once!] :: S -> t) (x [Occ=Once] :: S) -> case x of wild [Occ=Once] { __DEFAULT -> wombat2 wild }}] - = \ (@p) (wombat2 :: S -> p) (x :: S) -> + = \ (@t) (wombat2 :: S -> t) (x :: S) -> case x of wild { __DEFAULT -> wombat2 wild } - Tmpl= \ (@p) (wombat3 [Occ=Once!] :: W -> p) (x [Occ=Once] :: W) -> + Tmpl= \ (@t) (wombat3 [Occ=Once!] :: W -> t) (x [Occ=Once] :: W) -> case x of wild [Occ=Once] { __DEFAULT -> wombat3 wild }}] - = \ (@p) (wombat3 :: W -> p) (x :: W) -> + = \ (@t) (wombat3 :: W -> t) (x :: W) -> case x of wild { __DEFAULT -> wombat3 wild } ===================================== testsuite/tests/typecheck/should_compile/T18412.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RankNTypes #-} + +module T18412 where + +hr :: (forall a. a -> a) -> () +hr _ = () + +foo x = case x of () -> hr + +-- This did not use to be allowed, because the +-- multiple branches have (the same) polytypes +-- Enhancement July 2020 +bar x = case x of True -> hr + False -> hr ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -716,3 +716,4 @@ test('T17775-viewpats-a', normal, compile, ['']) test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) test('T17775-viewpats-d', normal, compile_fail, ['']) +test('T18412', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T10619.stderr ===================================== @@ -1,13 +1,11 @@ -T10619.hs:9:15: error: - • Couldn't match type ‘p’ with ‘forall b. b -> b’ - Expected: p -> p - Actual: (forall a. a -> a) -> forall b. b -> b - ‘p’ is a rigid type variable bound by - the inferred type of foo :: p1 -> p -> p - at T10619.hs:(8,1)-(10,20) - • In the expression: - (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b +T10619.hs:10:14: error: + • Couldn't match type ‘p1’ with ‘forall a. a -> a’ + Expected: (forall a. a -> a) -> forall b. b -> b + Actual: p1 -> p1 + Cannot instantiate unification variable ‘p1’ + with a type involving polytypes: forall a. a -> a + • In the expression: \ y -> y In the expression: if True then ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) @@ -19,15 +17,13 @@ T10619.hs:9:15: error: ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) else \ y -> y - • Relevant bindings include - foo :: p1 -> p -> p (bound at T10619.hs:8:1) T10619.hs:14:15: error: • Couldn't match type ‘p’ with ‘forall a. a -> a’ Expected: p -> p Actual: (forall a. a -> a) -> forall b. b -> b ‘p’ is a rigid type variable bound by - the inferred type of bar :: p1 -> p -> p + the inferred type of bar :: p2 -> p -> p at T10619.hs:(12,1)-(14,66) • In the expression: (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b @@ -43,21 +39,16 @@ T10619.hs:14:15: error: else ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) • Relevant bindings include - bar :: p1 -> p -> p (bound at T10619.hs:12:1) + bar :: p2 -> p -> p (bound at T10619.hs:12:1) -T10619.hs:16:13: error: - • Couldn't match type ‘p’ with ‘forall b. b -> b’ - Expected: p -> p - Actual: (forall a. a -> a) -> forall b. b -> b - ‘p’ is a rigid type variable bound by - the inferred type of baz :: Bool -> p -> p - at T10619.hs:(16,1)-(17,19) - • In the expression: - (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b - In an equation for ‘baz’: - baz True = (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b - • Relevant bindings include - baz :: Bool -> p -> p (bound at T10619.hs:16:1) +T10619.hs:17:13: error: + • Couldn't match type ‘p0’ with ‘forall a. a -> a’ + Expected: (forall a. a -> a) -> forall b. b -> b + Actual: p0 -> p0 + Cannot instantiate unification variable ‘p0’ + with a type involving polytypes: forall a. a -> a + • In the expression: \ y -> y + In an equation for ‘baz’: baz False = \ y -> y T10619.hs:20:14: error: • Couldn't match type ‘p’ with ‘forall a. a -> a’ ===================================== testsuite/tests/typecheck/should_fail/tcfail002.stderr ===================================== @@ -1,8 +1,8 @@ tcfail002.hs:4:7: error: - • Couldn't match expected type ‘p’ with actual type ‘[p]’ + • Couldn't match expected type ‘a’ with actual type ‘[a]’ • In the expression: z In an equation for ‘c’: c z = z • Relevant bindings include - z :: [p] (bound at tcfail002.hs:4:3) - c :: [p] -> p (bound at tcfail002.hs:3:1) + z :: [a] (bound at tcfail002.hs:4:3) + c :: [a] -> a (bound at tcfail002.hs:3:1) ===================================== testsuite/tests/typecheck/should_fail/tcfail104.stderr ===================================== @@ -1,19 +1,22 @@ -tcfail104.hs:14:12: error: +tcfail104.hs:16:12: error: + • Couldn't match type: Char -> Char + with: forall a. a -> a + Expected: (forall a. a -> a) -> Char -> Char + Actual: (Char -> Char) -> Char -> Char + • In the expression: \ x -> x + In the expression: + if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x) + In the expression: + (if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x)) id 'c' + +tcfail104.hs:22:12: error: • Couldn't match type: forall a. a -> a with: Char -> Char Expected: (Char -> Char) -> Char -> Char Actual: (forall a. a -> a) -> Char -> Char • In the expression: \ (x :: forall a. a -> a) -> x In the expression: - if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x) + if v then (\ x -> x) else (\ (x :: forall a. a -> a) -> x) In the expression: - (if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x)) id 'c' - -tcfail104.hs:22:15: error: - • Couldn't match expected type: Char -> Char - with actual type: forall a. a -> a - • When checking that the pattern signature: forall a. a -> a - fits the type of its context: Char -> Char - In the pattern: x :: forall a. a -> a - In the expression: \ (x :: forall a. a -> a) -> x + (if v then (\ x -> x) else (\ (x :: forall a. a -> a) -> x)) id 'c' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3ecd7b82c4ac35723d09b5e0eaf6b62808805b6e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3ecd7b82c4ac35723d09b5e0eaf6b62808805b6e You're receiving 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 Jul 10 23:25:09 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 10 Jul 2020 19:25:09 -0400 Subject: [Git][ghc/ghc][wip/T18126] Lots more small changes Message-ID: <5f08f8d5c5787_80b3f84960bea142614258@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: 05df195d by Simon Peyton Jones at 2020-07-11T00:12:53+01:00 Lots more small changes In particular, a substantial refactoring of constraint generation during kind inference, in TyCl and HsType. Needs a proper Note. This is WIP, needs better documentation etc. But we are down to a handful of error-message regressions. - - - - - 30 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Default.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Var.hs - testsuite/tests/dependent/should_fail/RAE_T32a.stderr - testsuite/tests/dependent/should_fail/T11407.stderr - testsuite/tests/dependent/should_fail/T13780a.stderr - testsuite/tests/dependent/should_fail/T15859.hs - testsuite/tests/dependent/should_fail/T15859.stderr - + testsuite/tests/dependent/should_fail/T15859a.hs - + testsuite/tests/dependent/should_fail/T15859a.stderr - testsuite/tests/dependent/should_fail/T16344a.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/05df195d9c818ddda655de7d60f15ff23a82f755 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/05df195d9c818ddda655de7d60f15ff23a82f755 You're receiving 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 Jul 11 00:08:56 2020 From: gitlab at gitlab.haskell.org (John Ericson) Date: Fri, 10 Jul 2020 20:08:56 -0400 Subject: [Git][ghc/ghc][wip/keep-going-hs-boot] 86 commits: Cmm: introduce SAVE_REGS/RESTORE_REGS Message-ID: <5f090318372ce_80bda8bdb426148ba@gitlab.haskell.org.mail> John Ericson pushed to branch wip/keep-going-hs-boot at Glasgow Haskell Compiler / GHC Commits: 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - ce7215aa by John Ericson at 2020-07-10T18:36:23-04:00 For -fkeep-failed do not duplicate dependency edge code We now compute the deps for -fkeep-failed the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are done consistently now. - - - - - 30 changed files: - .gitlab/test-metrics.sh - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/SPARC/CodeGen/Base.hs - compiler/GHC/CmmToAsm/SPARC/Regs.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Regs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/97684237b6423a0140abb2112b3d11ed4e7b7e73...ce7215aac1da956ae4acffab439b9eebad51b136 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/97684237b6423a0140abb2112b3d11ed4e7b7e73...ce7215aac1da956ae4acffab439b9eebad51b136 You're receiving 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 Jul 11 00:13:56 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Fri, 10 Jul 2020 20:13:56 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/inlineable_eq_list Message-ID: <5f09044448ead_80b114013dc2615888@gitlab.haskell.org.mail> Andreas Klebinger pushed new branch wip/andreask/inlineable_eq_list at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/inlineable_eq_list You're receiving 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 Jul 11 00:17:44 2020 From: gitlab at gitlab.haskell.org (John Ericson) Date: Fri, 10 Jul 2020 20:17:44 -0400 Subject: [Git][ghc/ghc][wip/keep-going-hs-boot] For -fkeep-failed do not duplicate dependency edge code Message-ID: <5f090528a988_80b3f848e5b86582617423@gitlab.haskell.org.mail> John Ericson pushed to branch wip/keep-going-hs-boot at Glasgow Haskell Compiler / GHC Commits: 1a671789 by John Ericson at 2020-07-10T20:15:04-04:00 For -fkeep-failed do not duplicate dependency edge code We now compute the deps for -fkeep-failed the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are done consistently now. - - - - - 1 changed file: - compiler/GHC/Driver/Make.hs Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -952,6 +952,12 @@ mkBuildModule ms = GWIB , gwib_isBoot = isBootSummary ms } +mkHomeBuildModule :: ModSummary -> ModuleNameWithIsBoot +mkHomeBuildModule ms = GWIB + { gwib_mod = moduleName $ ms_mod ms + , gwib_isBoot = isBootSummary ms + } + -- | The entry point to the parallel upsweep. -- -- See also the simpler, sequential 'upsweep'. @@ -1390,20 +1396,20 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do keep_going this_mods old_hpt done mods mod_index nmods uids_to_check done_holes = do let sum_deps ms (AcyclicSCC mod) = - if any (flip elem . map (unLoc . snd) $ ms_imps mod) ms - then ms_mod_name mod:ms + if any (flip elem $ unfilteredEdges False mod) ms + then mkHomeBuildModule mod:ms else ms sum_deps ms _ = ms dep_closure = foldl' sum_deps this_mods mods dropped_ms = drop (length this_mods) (reverse dep_closure) - prunable (AcyclicSCC mod) = elem (ms_mod_name mod) dep_closure + prunable (AcyclicSCC mod) = elem (mkHomeBuildModule mod) dep_closure prunable _ = False mods' = filter (not . prunable) mods nmods' = nmods - length dropped_ms when (not $ null dropped_ms) $ do dflags <- getSessionDynFlags - liftIO $ fatalErrorMsg dflags (keepGoingPruneErr dropped_ms) + liftIO $ fatalErrorMsg dflags (keepGoingPruneErr $ gwib_mod <$> dropped_ms) (_, done') <- upsweep' old_hpt done mods' (mod_index+1) nmods' uids_to_check done_holes return (Failed, done') @@ -1428,7 +1434,7 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do = do dflags <- getSessionDynFlags liftIO $ fatalErrorMsg dflags (cyclicModuleErr ms) if gopt Opt_KeepGoing dflags - then keep_going (map ms_mod_name ms) old_hpt done mods mod_index nmods + then keep_going (mkHomeBuildModule <$> ms) old_hpt done mods mod_index nmods uids_to_check done_holes else return (Failed, done) @@ -1482,7 +1488,7 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do Nothing -> do dflags <- getSessionDynFlags if gopt Opt_KeepGoing dflags - then keep_going [ms_mod_name mod] old_hpt done mods mod_index nmods + then keep_going [mkHomeBuildModule mod] old_hpt done mods mod_index nmods uids_to_check done_holes else return (Failed, done) Just mod_info -> do @@ -1917,7 +1923,7 @@ reachableBackwards mod summaries = [ node_payload node | node <- reachableG (transposeG graph) root ] where -- the rest just sets up the graph: (graph, lookup_node) = moduleGraphNodes False summaries - root = expectJust "reachableBackwards" (lookup_node IsBoot mod) + root = expectJust "reachableBackwards" (lookup_node $ GWIB mod IsBoot) -- --------------------------------------------------------------------------- -- @@ -1960,7 +1966,7 @@ topSortModuleGraph drop_hs_boot_nodes module_graph mb_root_mod -- the specified module. We do this by building a graph with -- the full set of nodes, and determining the reachable set from -- the specified node. - let root | Just node <- lookup_node NotBoot root_mod + let root | Just node <- lookup_node $ GWIB root_mod NotBoot , graph `hasVertexG` node = node | otherwise @@ -1975,60 +1981,56 @@ summaryNodeKey = node_key summaryNodeSummary :: SummaryNode -> ModSummary summaryNodeSummary = node_payload +unfilteredEdges :: Bool -> ModSummary -> [ModuleNameWithIsBoot] +unfilteredEdges drop_hs_boot_nodes ms = + (flip GWIB hs_boot_key . unLoc <$> ms_home_srcimps ms) ++ + (flip GWIB NotBoot . unLoc <$> ms_home_imps ms) ++ + [ GWIB (ms_mod_name ms) IsBoot + | not $ drop_hs_boot_nodes || ms_hsc_src ms == HsBootFile + -- see [boot-edges] below + ] + where + -- [boot-edges] if this is a .hs and there is an equivalent + -- .hs-boot, add a link from the former to the latter. This + -- has the effect of detecting bogus cases where the .hs-boot + -- depends on the .hs, by introducing a cycle. Additionally, + -- it ensures that we will always process the .hs-boot before + -- the .hs, and so the HomePackageTable will always have the + -- most up to date information. + + -- Drop hs-boot nodes by using HsSrcFile as the key + hs_boot_key | drop_hs_boot_nodes = NotBoot -- is regular mod or signature + | otherwise = IsBoot + moduleGraphNodes :: Bool -> [ModSummary] - -> (Graph SummaryNode, IsBootInterface -> ModuleName -> Maybe SummaryNode) + -> (Graph SummaryNode, ModuleNameWithIsBoot -> Maybe SummaryNode) moduleGraphNodes drop_hs_boot_nodes summaries = (graphFromEdgedVerticesUniq nodes, lookup_node) where numbered_summaries = zip summaries [1..] - lookup_node :: IsBootInterface -> ModuleName -> Maybe SummaryNode - lookup_node hs_src mod = Map.lookup - (GWIB { gwib_mod = mod, gwib_isBoot = hs_src }) - node_map + lookup_node :: ModuleNameWithIsBoot -> Maybe SummaryNode + lookup_node mnwib = Map.lookup mnwib node_map - lookup_key :: IsBootInterface -> ModuleName -> Maybe Int - lookup_key hs_src mod = fmap summaryNodeKey (lookup_node hs_src mod) + lookup_key :: ModuleNameWithIsBoot -> Maybe Int + lookup_key = fmap summaryNodeKey . lookup_node node_map :: NodeMap SummaryNode - node_map = Map.fromList [ ( GWIB - { gwib_mod = moduleName $ ms_mod s - , gwib_isBoot = hscSourceToIsBoot $ ms_hsc_src s - } - , node - ) + node_map = Map.fromList [ (mkHomeBuildModule s, node) | node <- nodes - , let s = summaryNodeSummary node ] + , let s = summaryNodeSummary node + ] -- We use integers as the keys for the SCC algorithm nodes :: [SummaryNode] - nodes = [ DigraphNode s key out_keys + nodes = [ DigraphNode s key $ out_edge_keys $ unfilteredEdges drop_hs_boot_nodes s | (s, key) <- numbered_summaries -- Drop the hi-boot ones if told to do so , not (isBootSummary s == IsBoot && drop_hs_boot_nodes) - , let out_keys = out_edge_keys hs_boot_key (map unLoc (ms_home_srcimps s)) ++ - out_edge_keys NotBoot (map unLoc (ms_home_imps s)) ++ - (-- see [boot-edges] below - if drop_hs_boot_nodes || ms_hsc_src s == HsBootFile - then [] - else case lookup_key IsBoot (ms_mod_name s) of - Nothing -> [] - Just k -> [k]) ] - - -- [boot-edges] if this is a .hs and there is an equivalent - -- .hs-boot, add a link from the former to the latter. This - -- has the effect of detecting bogus cases where the .hs-boot - -- depends on the .hs, by introducing a cycle. Additionally, - -- it ensures that we will always process the .hs-boot before - -- the .hs, and so the HomePackageTable will always have the - -- most up to date information. - - -- Drop hs-boot nodes by using HsSrcFile as the key - hs_boot_key | drop_hs_boot_nodes = NotBoot -- is regular mod or signature - | otherwise = IsBoot + ] - out_edge_keys :: IsBootInterface -> [ModuleName] -> [Int] - out_edge_keys hi_boot ms = mapMaybe (lookup_key hi_boot) ms + out_edge_keys :: [ModuleNameWithIsBoot] -> [Int] + out_edge_keys = mapMaybe lookup_key -- If we want keep_hi_boot_nodes, then we do lookup_key with -- IsBoot; else False View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1a6717895314a5a1f588cd0bd8bae34cb43873ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1a6717895314a5a1f588cd0bd8bae34cb43873ad You're receiving 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 Jul 11 00:20:10 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Fri, 10 Jul 2020 20:20:10 -0400 Subject: [Git][ghc/ghc][wip/andreask/inlineable_eq_list] Try making compare inlineable for [] Message-ID: <5f0905ba499f2_80b3f848662eb1c26184ab@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/inlineable_eq_list at Glasgow Haskell Compiler / GHC Commits: 6960060e by Andreas Klebinger at 2020-07-10T20:20:08-04:00 Try making compare inlineable for [] - - - - - 1 changed file: - libraries/ghc-prim/GHC/Classes.hs Changes: ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -400,6 +400,7 @@ instance (Ord a) => Ord [a] where {-# SPECIALISE instance Ord [[Char]] #-} {-# SPECIALISE instance Ord [Char] #-} {-# SPECIALISE instance Ord [Int] #-} + {-# INLINEABLE compare #-} compare [] [] = EQ compare [] (_:_) = LT compare (_:_) [] = GT View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6960060ed0900a50dccfe7c47e6da8308923be77 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6960060ed0900a50dccfe7c47e6da8308923be77 You're receiving 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 Jul 11 01:40:49 2020 From: gitlab at gitlab.haskell.org (John Ericson) Date: Fri, 10 Jul 2020 21:40:49 -0400 Subject: [Git][ghc/ghc][wip/keep-going-hs-boot] For `-fkeep-going` do not duplicate dependency edge code Message-ID: <5f0918a11e508_80b3f849ba1b94026213a5@gitlab.haskell.org.mail> John Ericson pushed to branch wip/keep-going-hs-boot at Glasgow Haskell Compiler / GHC Commits: f5f76b7b by John Ericson at 2020-07-10T21:40:03-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 1 changed file: - compiler/GHC/Driver/Make.hs Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -952,6 +952,12 @@ mkBuildModule ms = GWIB , gwib_isBoot = isBootSummary ms } +mkHomeBuildModule :: ModSummary -> ModuleNameWithIsBoot +mkHomeBuildModule ms = GWIB + { gwib_mod = moduleName $ ms_mod ms + , gwib_isBoot = isBootSummary ms + } + -- | The entry point to the parallel upsweep. -- -- See also the simpler, sequential 'upsweep'. @@ -1390,20 +1396,20 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do keep_going this_mods old_hpt done mods mod_index nmods uids_to_check done_holes = do let sum_deps ms (AcyclicSCC mod) = - if any (flip elem . map (unLoc . snd) $ ms_imps mod) ms - then ms_mod_name mod:ms + if any (flip elem $ unfilteredEdges False mod) ms + then mkHomeBuildModule mod:ms else ms sum_deps ms _ = ms dep_closure = foldl' sum_deps this_mods mods dropped_ms = drop (length this_mods) (reverse dep_closure) - prunable (AcyclicSCC mod) = elem (ms_mod_name mod) dep_closure + prunable (AcyclicSCC mod) = elem (mkHomeBuildModule mod) dep_closure prunable _ = False mods' = filter (not . prunable) mods nmods' = nmods - length dropped_ms when (not $ null dropped_ms) $ do dflags <- getSessionDynFlags - liftIO $ fatalErrorMsg dflags (keepGoingPruneErr dropped_ms) + liftIO $ fatalErrorMsg dflags (keepGoingPruneErr $ gwib_mod <$> dropped_ms) (_, done') <- upsweep' old_hpt done mods' (mod_index+1) nmods' uids_to_check done_holes return (Failed, done') @@ -1428,7 +1434,7 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do = do dflags <- getSessionDynFlags liftIO $ fatalErrorMsg dflags (cyclicModuleErr ms) if gopt Opt_KeepGoing dflags - then keep_going (map ms_mod_name ms) old_hpt done mods mod_index nmods + then keep_going (mkHomeBuildModule <$> ms) old_hpt done mods mod_index nmods uids_to_check done_holes else return (Failed, done) @@ -1482,7 +1488,7 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do Nothing -> do dflags <- getSessionDynFlags if gopt Opt_KeepGoing dflags - then keep_going [ms_mod_name mod] old_hpt done mods mod_index nmods + then keep_going [mkHomeBuildModule mod] old_hpt done mods mod_index nmods uids_to_check done_holes else return (Failed, done) Just mod_info -> do @@ -1917,7 +1923,7 @@ reachableBackwards mod summaries = [ node_payload node | node <- reachableG (transposeG graph) root ] where -- the rest just sets up the graph: (graph, lookup_node) = moduleGraphNodes False summaries - root = expectJust "reachableBackwards" (lookup_node IsBoot mod) + root = expectJust "reachableBackwards" (lookup_node $ GWIB mod IsBoot) -- --------------------------------------------------------------------------- -- @@ -1960,7 +1966,7 @@ topSortModuleGraph drop_hs_boot_nodes module_graph mb_root_mod -- the specified module. We do this by building a graph with -- the full set of nodes, and determining the reachable set from -- the specified node. - let root | Just node <- lookup_node NotBoot root_mod + let root | Just node <- lookup_node $ GWIB root_mod NotBoot , graph `hasVertexG` node = node | otherwise @@ -1975,60 +1981,56 @@ summaryNodeKey = node_key summaryNodeSummary :: SummaryNode -> ModSummary summaryNodeSummary = node_payload +unfilteredEdges :: Bool -> ModSummary -> [ModuleNameWithIsBoot] +unfilteredEdges drop_hs_boot_nodes ms = + (flip GWIB hs_boot_key . unLoc <$> ms_home_srcimps ms) ++ + (flip GWIB NotBoot . unLoc <$> ms_home_imps ms) ++ + [ GWIB (ms_mod_name ms) IsBoot + | not $ drop_hs_boot_nodes || ms_hsc_src ms == HsBootFile + -- see [boot-edges] below + ] + where + -- [boot-edges] if this is a .hs and there is an equivalent + -- .hs-boot, add a link from the former to the latter. This + -- has the effect of detecting bogus cases where the .hs-boot + -- depends on the .hs, by introducing a cycle. Additionally, + -- it ensures that we will always process the .hs-boot before + -- the .hs, and so the HomePackageTable will always have the + -- most up to date information. + + -- Drop hs-boot nodes by using HsSrcFile as the key + hs_boot_key | drop_hs_boot_nodes = NotBoot -- is regular mod or signature + | otherwise = IsBoot + moduleGraphNodes :: Bool -> [ModSummary] - -> (Graph SummaryNode, IsBootInterface -> ModuleName -> Maybe SummaryNode) + -> (Graph SummaryNode, ModuleNameWithIsBoot -> Maybe SummaryNode) moduleGraphNodes drop_hs_boot_nodes summaries = (graphFromEdgedVerticesUniq nodes, lookup_node) where numbered_summaries = zip summaries [1..] - lookup_node :: IsBootInterface -> ModuleName -> Maybe SummaryNode - lookup_node hs_src mod = Map.lookup - (GWIB { gwib_mod = mod, gwib_isBoot = hs_src }) - node_map + lookup_node :: ModuleNameWithIsBoot -> Maybe SummaryNode + lookup_node mnwib = Map.lookup mnwib node_map - lookup_key :: IsBootInterface -> ModuleName -> Maybe Int - lookup_key hs_src mod = fmap summaryNodeKey (lookup_node hs_src mod) + lookup_key :: ModuleNameWithIsBoot -> Maybe Int + lookup_key = fmap summaryNodeKey . lookup_node node_map :: NodeMap SummaryNode - node_map = Map.fromList [ ( GWIB - { gwib_mod = moduleName $ ms_mod s - , gwib_isBoot = hscSourceToIsBoot $ ms_hsc_src s - } - , node - ) + node_map = Map.fromList [ (mkHomeBuildModule s, node) | node <- nodes - , let s = summaryNodeSummary node ] + , let s = summaryNodeSummary node + ] -- We use integers as the keys for the SCC algorithm nodes :: [SummaryNode] - nodes = [ DigraphNode s key out_keys + nodes = [ DigraphNode s key $ out_edge_keys $ unfilteredEdges drop_hs_boot_nodes s | (s, key) <- numbered_summaries -- Drop the hi-boot ones if told to do so , not (isBootSummary s == IsBoot && drop_hs_boot_nodes) - , let out_keys = out_edge_keys hs_boot_key (map unLoc (ms_home_srcimps s)) ++ - out_edge_keys NotBoot (map unLoc (ms_home_imps s)) ++ - (-- see [boot-edges] below - if drop_hs_boot_nodes || ms_hsc_src s == HsBootFile - then [] - else case lookup_key IsBoot (ms_mod_name s) of - Nothing -> [] - Just k -> [k]) ] - - -- [boot-edges] if this is a .hs and there is an equivalent - -- .hs-boot, add a link from the former to the latter. This - -- has the effect of detecting bogus cases where the .hs-boot - -- depends on the .hs, by introducing a cycle. Additionally, - -- it ensures that we will always process the .hs-boot before - -- the .hs, and so the HomePackageTable will always have the - -- most up to date information. - - -- Drop hs-boot nodes by using HsSrcFile as the key - hs_boot_key | drop_hs_boot_nodes = NotBoot -- is regular mod or signature - | otherwise = IsBoot + ] - out_edge_keys :: IsBootInterface -> [ModuleName] -> [Int] - out_edge_keys hi_boot ms = mapMaybe (lookup_key hi_boot) ms + out_edge_keys :: [ModuleNameWithIsBoot] -> [Int] + out_edge_keys = mapMaybe lookup_key -- If we want keep_hi_boot_nodes, then we do lookup_key with -- IsBoot; else False View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5f76b7b3174dcea394961262609c18e3fd26545 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5f76b7b3174dcea394961262609c18e3fd26545 You're receiving 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 Jul 11 02:49:35 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 10 Jul 2020 22:49:35 -0400 Subject: [Git][ghc/ghc][wip/angerman/fix-hadrian-cross-macos] 29 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f0928bfed347_80b3f8490174d3826286e4@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/fix-hadrian-cross-macos at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - 56bd9bf3 by Moritz Angermann at 2020-07-10T22:49:34-04:00 Fix ar-stage0 having no at-file support in hadrian - - - - - 209f0ffc by Moritz Angermann at 2020-07-10T22:49:34-04:00 No Undefined Oriented Programming - - - - - 29c38162 by Moritz Angermann at 2020-07-10T22:49:34-04:00 fallback - - - - - 9e479b9a by Moritz Angermann at 2020-07-10T22:49:34-04:00 add docs - - - - - 30 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Unit/Types.hs - configure.ac - docs/users_guide/8.12.1-notes.rst - docs/users_guide/phases.rst - docs/users_guide/shared_libs.rst - hadrian/.gitignore - hadrian/README.md - hadrian/cfg/system.config.in - hadrian/doc/make.md - hadrian/ghci-cabal → hadrian/ghci-cabal.in - hadrian/ghci-stack → hadrian/ghci-stack.in - hadrian/src/Builder.hs - hadrian/src/CommandLine.hs - hadrian/src/Expression.hs - hadrian/src/Main.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Packages.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Gmp.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/366acd5cc26e504c9db63547e4cc5257e3f6740d...9e479b9ae96f52bcb0140474e9ea4ad2eed74223 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/366acd5cc26e504c9db63547e4cc5257e3f6740d...9e479b9ae96f52bcb0140474e9ea4ad2eed74223 You're receiving 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 Jul 11 10:37:14 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Sat, 11 Jul 2020 06:37:14 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/allocationArea Message-ID: <5f09965a22394_80b114013dc262982@gitlab.haskell.org.mail> Andreas Klebinger pushed new branch wip/andreask/allocationArea at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/allocationArea You're receiving 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 Jul 11 13:23:52 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sat, 11 Jul 2020 09:23:52 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 47 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f09bd6853b50_80b3f846a0d2e3c26384e5@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - 7019067f by Moritz Angermann at 2020-07-10T03:24:03+00:00 Initial NCG - - - - - 51980a73 by Moritz Angermann at 2020-07-10T03:24:03+00:00 Address Takenobu's comments - - - - - d086d1a4 by Moritz Angermann at 2020-07-10T03:24:03+00:00 Fix floating points handling of NaNs - - - - - abaab35b by Moritz Angermann at 2020-07-10T03:24:03+00:00 Add basic Graph Coloring support - - - - - 9a4cc2c3 by Moritz Angermann at 2020-07-10T03:24:03+00:00 Drop debug - - - - - c9acb42b by Moritz Angermann at 2020-07-10T03:24:03+00:00 Add primops_match.cmm testsuite - - - - - 3c64f8c6 by Moritz Angermann at 2020-07-10T03:24:03+00:00 Fix -NaN for real this time. - - - - - ab9b9333 by Moritz Angermann at 2020-07-10T03:24:03+00:00 Adds nan test. - - - - - 06ae96be by Moritz Angermann at 2020-07-10T03:24:03+00:00 no show - - - - - 17ec4f00 by Moritz Angermann at 2020-07-10T03:24:03+00:00 Some notes on PIC - - - - - 9dcc2a6d by Moritz Angermann at 2020-07-10T03:24:03+00:00 Properly load W32 with bit 31 set. - - - - - e28ad0f2 by Moritz Angermann at 2020-07-10T03:24:03+00:00 better relocation logging - - - - - 451bb5c2 by Moritz Angermann at 2020-07-10T11:49:13+00:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - d126be12 by Moritz Angermann at 2020-07-10T11:49:28+00:00 Revert "BigNum: rename BigNat types" This reverts commit d3bd68978476487591fc60f7feb7cfb36b8fc3a3. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - f3686c09 by Moritz Angermann at 2020-07-11T04:23:49+00:00 Add AsmOpt Flags - - - - - 7daed1e7 by Moritz Angermann at 2020-07-11T08:26:45+00:00 Adds ANN instruction. I wish I had a `pad n` function for SDoc, that would interact with the layout, and just pad what ever was printed so far to `n` chars. - - - - - 7cbc8506 by Moritz Angermann at 2020-07-11T08:27:12+00:00 Drop dead 32bit logic. - - - - - c5d7fe89 by Moritz Angermann at 2020-07-11T08:45:54+00:00 Add Show CmmExpr instances. Why would we want this, when we have Outputtable CmmExpr? Quite often when working on Code Generators, we want to structurally match on a Cmm Expression. Having to recover the Cmm Expression from its Outputtable text is not always trivial, and requires substantial effort. By having a Show instance, we can almost copy the definition to match on. - - - - - b730ba5a by Moritz Angermann at 2020-07-11T08:46:07+00:00 Drop duplicate show instance for CLabel now. - - - - - b2d42f98 by Moritz Angermann at 2020-07-11T12:31:23+00:00 Add link, lest I keep forgetting it. - - - - - 0ddcd9be by Moritz Angermann at 2020-07-11T12:31:50+00:00 inline comments with // - - - - - 7e0e2ea9 by Moritz Angermann at 2020-07-11T12:32:42+00:00 Some optimizations; not yet sure if safe or not. - - - - - 11 changed files: - aclocal.m4 - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Expr.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Type.hs - compiler/GHC/CmmToAsm.hs - + compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - + compiler/GHC/CmmToAsm/AArch64/Cond.hs - + compiler/GHC/CmmToAsm/AArch64/Instr.hs - + compiler/GHC/CmmToAsm/AArch64/LLVM Test Results.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8f0783dca2be440b92eb59e3bee116e5d0777ad...7e0e2ea99a84981fd1ea6350780c0f14af5e8877 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8f0783dca2be440b92eb59e3bee116e5d0777ad...7e0e2ea99a84981fd1ea6350780c0f14af5e8877 You're receiving 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 Jul 11 13:38:02 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sat, 11 Jul 2020 09:38:02 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] Add latest opt changes. Message-ID: <5f09c0ba4ca9c_80b3f849c221f4026398cf@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 27ea955b by Moritz Angermann at 2020-07-11T13:36:56+00:00 Add latest opt changes. - - - - - 1 changed file: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -601,16 +601,20 @@ getRegister' config plat expr -- XXX: for now we'll only implement the 64bit versions. And rely on the -- fallthrough to alert us if things go wrong! -- OPTIMIZATION WARNING: Dyadic CmmMachOp destructuring + -- 0. XXX 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 _) [(CmmReg (CmmGlobal r)), CmmLit (CmmInt 0 _)] -> pprPanic "getRegister:CmmMachOp:Add:Imm is 0" (ppr expr) CmmMachOp (MO_Add w) [(CmmReg reg@(CmmGlobal _)), CmmLit (CmmInt n _)] | n > 0 && n < 4096 -> return $ Any (intFormat w) (\d -> unitOL $ ANN (text $ show expr) (ADD (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) + -- XXX: 12bits lsl #12; e.g. lower 12 bits of n are 0; shift n >> 12, and set lsl to #12. -- OPTIMIZATION WARNING: This only works because reg is CmmGlobal where w' = formatToWidth (cmmTypeFormat (cmmRegType plat reg)) r' = getRegisterReg plat reg CmmMachOp (MO_Sub w) [(CmmReg reg@(CmmGlobal _)), CmmLit (CmmInt n _)] | n > 0 && n < 4096 -> return $ Any (intFormat w) (\d -> unitOL $ ANN (text $ show expr) (SUB (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) + -- XXX: 12bits lsl #12; e.g. lower 12 bits of n are 0; shift n >> 12, and set lsl to #12. -- OPTIMIZATION WARNING: This only works because reg is CmmGlobal where w' = formatToWidth (cmmTypeFormat (cmmRegType plat reg)) r' = getRegisterReg plat reg View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/27ea955ba4ed6d547ac86428bbe95272652a48dc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/27ea955ba4ed6d547ac86428bbe95272652a48dc You're receiving 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 Jul 11 13:46:52 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sat, 11 Jul 2020 09:46:52 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/angerman/aarch64-dev-shell Message-ID: <5f09c2ccb45d_80b3f84960bea14264078c@gitlab.haskell.org.mail> Moritz Angermann pushed new branch wip/angerman/aarch64-dev-shell at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/angerman/aarch64-dev-shell You're receiving 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 Jul 11 14:03:16 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 10:03:16 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] gitlab-ci: Bootstrap with 8.8.4-rc1 on Windows Message-ID: <5f09c6a4c1e30_80b3f849c221f402642596@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 0e57e4ab by Ben Gamari at 2020-07-11T10:02:43-04:00 gitlab-ci: Bootstrap with 8.8.4-rc1 on Windows This avoids bugs in the `process` library during bootstrapping. - - - - - 2 changed files: - .gitlab-ci.yml - .gitlab/win32-init.sh Changes: ===================================== .gitlab-ci.yml ===================================== @@ -636,6 +636,8 @@ validate-x86_64-windows: extends: .build-windows-make variables: MSYSTEM: MINGW64 + GHC_VERSION: 8.8.4-rc1 + GHC_TARBALL_URL: "https://downloads.haskell.org/~ghc/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "quick" CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" cache: @@ -647,6 +649,8 @@ release-x86_64-windows: extends: validate-x86_64-windows variables: MSYSTEM: MINGW64 + GHC_VERSION: 8.8.4-rc1 + GHC_TARBALL_URL: "https://downloads.haskell.org/~ghc/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" ===================================== .gitlab/win32-init.sh ===================================== @@ -22,7 +22,10 @@ if [ ! -e $toolchain/bin/ghc ]; then exit 1 ;; esac - curl https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz | tar -xJ + if [ -z "$GHC_TARBALL_URL" ]; then + GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" + fi + curl "$GHC_TARBALL_URL" | tar -xJ mv ghc-$GHC_VERSION toolchain fi View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0e57e4ab0e651d51c9378df79dfb32c95723521e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0e57e4ab0e651d51c9378df79dfb32c95723521e You're receiving 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 Jul 11 14:09:51 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 10:09:51 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] gitlab-ci: Bootstrap with 8.8.4-rc1 on Windows Message-ID: <5f09c82fce26d_80b3f849ba1b9402642748@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: aa4e5d6b by Ben Gamari at 2020-07-11T10:09:40-04:00 gitlab-ci: Bootstrap with 8.8.4-rc1 on Windows This avoids bugs in the `process` library during bootstrapping. - - - - - 2 changed files: - .gitlab-ci.yml - .gitlab/win32-init.sh Changes: ===================================== .gitlab-ci.yml ===================================== @@ -636,6 +636,8 @@ validate-x86_64-windows: extends: .build-windows-make variables: MSYSTEM: MINGW64 + GHC_VERSION: 8.8.4-rc1 + GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "quick" CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" cache: @@ -647,6 +649,8 @@ release-x86_64-windows: extends: validate-x86_64-windows variables: MSYSTEM: MINGW64 + GHC_VERSION: 8.8.4-rc1 + GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" ===================================== .gitlab/win32-init.sh ===================================== @@ -22,7 +22,10 @@ if [ ! -e $toolchain/bin/ghc ]; then exit 1 ;; esac - curl https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz | tar -xJ + if [ -z "$GHC_TARBALL_URL" ]; then + GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" + fi + curl "$GHC_TARBALL_URL" | tar -xJ mv ghc-$GHC_VERSION toolchain fi View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aa4e5d6bc065676fed930c2a49a4bb73985f3a35 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aa4e5d6bc065676fed930c2a49a4bb73985f3a35 You're receiving 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 Jul 11 14:54:57 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 10:54:57 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/use-CmmRegOff-smart-ctor Message-ID: <5f09d2c1f1081_80b3f848e5b86582648310@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/use-CmmRegOff-smart-ctor at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/use-CmmRegOff-smart-ctor You're receiving 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 Jul 11 16:17:27 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 12:17:27 -0400 Subject: [Git][ghc/ghc][master] 3 commits: Define multiShotIO and use it in mkSplitUniqueSupply Message-ID: <5f09e617c2c39_80b3f849c221f402653736@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - 13 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Types/Unique/Supply.hs - testsuite/tests/profiling/should_run/T5654-O1.prof.sample - testsuite/tests/profiling/should_run/T5654b-O1.prof.sample - testsuite/tests/profiling/should_run/ioprof.stderr - + testsuite/tests/simplCore/should_compile/T18328.hs - + testsuite/tests/simplCore/should_compile/T18328.stderr - + testsuite/tests/simplCore/should_compile/T18355.hs - + testsuite/tests/simplCore/should_compile/T18355.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -13,9 +13,12 @@ -- | Arity and eta expansion module GHC.Core.Opt.Arity ( manifestArity, joinRhsArity, exprArity, typeArity - , exprEtaExpandArity, findRhsArity, etaExpand + , exprEtaExpandArity, findRhsArity + , etaExpand, etaExpandAT , etaExpandToJoinPoint, etaExpandToJoinPointRule , exprBotStrictness_maybe + , ArityType(..), expandableArityType, arityTypeArity + , maxWithArity, isBotArityType, idArityType ) where @@ -36,12 +39,13 @@ import GHC.Core.TyCon ( initRecTc, checkRecTc ) import GHC.Core.Predicate ( isDictTy ) import GHC.Core.Coercion as Coercion import GHC.Core.Multiplicity +import GHC.Types.Var.Set import GHC.Types.Basic import GHC.Types.Unique import GHC.Driver.Session ( DynFlags, GeneralFlag(..), gopt ) import GHC.Utils.Outputable import GHC.Data.FastString -import GHC.Utils.Misc ( debugIsOn ) +import GHC.Utils.Misc ( lengthAtLeast ) {- ************************************************************************ @@ -156,7 +160,9 @@ exprBotStrictness_maybe e Nothing -> Nothing Just ar -> Just (ar, sig ar) where - env = AE { ae_ped_bot = True, ae_cheap_fn = \ _ _ -> False } + env = AE { ae_ped_bot = True + , ae_cheap_fn = \ _ _ -> False + , ae_joins = emptyVarSet } sig ar = mkClosedStrictSig (replicate ar topDmd) botDiv {- @@ -483,8 +489,11 @@ Then f :: AT [False,False] ATop -------------------- Main arity code ---------------------------- -} --- See Note [ArityType] -data ArityType = ATop [OneShotInfo] | ABot Arity + +data ArityType -- See Note [ArityType] + = ATop [OneShotInfo] + | ABot Arity + deriving( Eq ) -- There is always an explicit lambda -- to justify the [OneShot], or the Arity @@ -492,21 +501,49 @@ instance Outputable ArityType where ppr (ATop os) = text "ATop" <> parens (ppr (length os)) ppr (ABot n) = text "ABot" <> parens (ppr n) +arityTypeArity :: ArityType -> Arity +-- The number of value args for the arity type +arityTypeArity (ATop oss) = length oss +arityTypeArity (ABot ar) = ar + +expandableArityType :: ArityType -> Bool +-- True <=> eta-expansion will add at least one lambda +expandableArityType (ATop oss) = not (null oss) +expandableArityType (ABot ar) = ar /= 0 + +isBotArityType :: ArityType -> Bool +isBotArityType (ABot {}) = True +isBotArityType (ATop {}) = False + +arityTypeOneShots :: ArityType -> [OneShotInfo] +arityTypeOneShots (ATop oss) = oss +arityTypeOneShots (ABot ar) = replicate ar OneShotLam + -- If we are diveging or throwing an exception anyway + -- it's fine to push redexes inside the lambdas + +botArityType :: ArityType +botArityType = ABot 0 -- Unit for andArityType + +maxWithArity :: ArityType -> Arity -> ArityType +maxWithArity at@(ABot {}) _ = at +maxWithArity at@(ATop oss) ar + | oss `lengthAtLeast` ar = at + | otherwise = ATop (take ar (oss ++ repeat NoOneShotInfo)) + vanillaArityType :: ArityType vanillaArityType = ATop [] -- Totally uninformative -- ^ The Arity returned is the number of value args the -- expression can be applied to without doing much work -exprEtaExpandArity :: DynFlags -> CoreExpr -> Arity +exprEtaExpandArity :: DynFlags -> CoreExpr -> ArityType -- exprEtaExpandArity is used when eta expanding -- e ==> \xy -> e x y exprEtaExpandArity dflags e - = case (arityType env e) of - ATop oss -> length oss - ABot n -> n + = arityType env e where env = AE { ae_cheap_fn = mk_cheap_fn dflags isCheapApp - , ae_ped_bot = gopt Opt_PedanticBottoms dflags } + , ae_ped_bot = gopt Opt_PedanticBottoms dflags + , ae_joins = emptyVarSet } getBotArity :: ArityType -> Maybe Arity -- Arity of a divergent function @@ -525,7 +562,7 @@ mk_cheap_fn dflags cheap_app ---------------------- -findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> (Arity, Bool) +findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> ArityType -- This implements the fixpoint loop for arity analysis -- See Note [Arity analysis] -- If findRhsArity e = (n, is_bot) then @@ -539,46 +576,37 @@ findRhsArity dflags bndr rhs old_arity -- we stop right away (since arities should not decrease) -- Result: the common case is that there is just one iteration where - is_lam = has_lam rhs - - has_lam (Tick _ e) = has_lam e - has_lam (Lam b e) = isId b || has_lam e - has_lam _ = False - init_cheap_app :: CheapAppFun init_cheap_app fn n_val_args | fn == bndr = True -- On the first pass, this binder gets infinite arity | otherwise = isCheapApp fn n_val_args - go :: (Arity, Bool) -> (Arity, Bool) - go cur_info@(cur_arity, _) - | cur_arity <= old_arity = cur_info - | new_arity == cur_arity = cur_info - | otherwise = ASSERT( new_arity < cur_arity ) + go :: ArityType -> ArityType + go cur_atype + | cur_arity <= old_arity = cur_atype + | new_atype == cur_atype = cur_atype + | otherwise = #if defined(DEBUG) pprTrace "Exciting arity" - (vcat [ ppr bndr <+> ppr cur_arity <+> ppr new_arity + (vcat [ ppr bndr <+> ppr cur_atype <+> ppr new_atype , ppr rhs]) #endif - go new_info + go new_atype where - new_info@(new_arity, _) = get_arity cheap_app + new_atype = get_arity cheap_app + cur_arity = arityTypeArity cur_atype cheap_app :: CheapAppFun cheap_app fn n_val_args | fn == bndr = n_val_args < cur_arity | otherwise = isCheapApp fn n_val_args - get_arity :: CheapAppFun -> (Arity, Bool) - get_arity cheap_app - = case (arityType env rhs) of - ABot n -> (n, True) - ATop (os:oss) | isOneShotInfo os || is_lam - -> (1 + length oss, False) -- Don't expand PAPs/thunks - ATop _ -> (0, False) -- Note [Eta expanding thunks] - where + get_arity :: CheapAppFun -> ArityType + get_arity cheap_app = arityType env rhs + where env = AE { ae_cheap_fn = mk_cheap_fn dflags cheap_app - , ae_ped_bot = gopt Opt_PedanticBottoms dflags } + , ae_ped_bot = gopt Opt_PedanticBottoms dflags + , ae_joins = emptyVarSet } {- Note [Arity analysis] @@ -608,7 +636,6 @@ write the analysis loop. The analysis is cheap-and-cheerful because it doesn't deal with mutual recursion. But the self-recursive case is the important one. - Note [Eta expanding through dictionaries] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If the experimental -fdicts-cheap flag is on, we eta-expand through @@ -627,24 +654,6 @@ The (foo DInt) is floated out, and makes ineffective a RULE One could go further and make exprIsCheap reply True to any dictionary-typed expression, but that's more work. - -Note [Eta expanding thunks] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We don't eta-expand - * Trivial RHSs x = y - * PAPs x = map g - * Thunks f = case y of p -> \x -> blah - -When we see - f = case y of p -> \x -> blah -should we eta-expand it? Well, if 'x' is a one-shot state token -then 'yes' because 'f' will only be applied once. But otherwise -we (conservatively) say no. My main reason is to avoid expanding -PAPSs - f = g d ==> f = \x. g d x -because that might in turn make g inline (if it has an inline pragma), -which we might not want. After all, INLINE pragmas say "inline only -when saturated" so we don't want to be too gung-ho about saturating! -} arityLam :: Id -> ArityType -> ArityType @@ -668,6 +677,7 @@ arityApp (ATop []) _ = ATop [] arityApp (ATop (_:as)) cheap = floatIn cheap (ATop as) andArityType :: ArityType -> ArityType -> ArityType -- Used for branches of a 'case' +-- This is least upper bound in the ArityType lattice andArityType (ABot n1) (ABot n2) = ABot (n1 `max` n2) -- Note [ABot branches: use max] andArityType (ATop as) (ABot _) = ATop as andArityType (ABot _) (ATop bs) = ATop bs @@ -736,14 +746,20 @@ type CheapFun = CoreExpr -> Maybe Type -> Bool data ArityEnv = AE { ae_cheap_fn :: CheapFun , ae_ped_bot :: Bool -- True <=> be pedantic about bottoms + , ae_joins :: IdSet -- In-scope join points + -- See Note [Eta-expansion and join points] } +extendJoinEnv :: ArityEnv -> [JoinId] -> ArityEnv +extendJoinEnv env@(AE { ae_joins = joins }) join_ids + = env { ae_joins = joins `extendVarSetList` join_ids } + +---------------- arityType :: ArityEnv -> CoreExpr -> ArityType arityType env (Cast e co) = case arityType env e of - ATop os -> ATop (take co_arity os) - -- See Note [Arity trimming] + ATop os -> ATop (take co_arity os) -- See Note [Arity trimming] ABot n | co_arity < n -> ATop (replicate co_arity noOneShotInfo) | otherwise -> ABot n where @@ -755,18 +771,11 @@ arityType env (Cast e co) -- However, do make sure that ATop -> ATop and ABot -> ABot! -- Casts don't affect that part. Getting this wrong provoked #5475 -arityType _ (Var v) - | strict_sig <- idStrictness v - , not $ isTopSig strict_sig - , (ds, res) <- splitStrictSig strict_sig - , let arity = length ds - = if isDeadEndDiv res then ABot arity - else ATop (take arity one_shots) +arityType env (Var v) + | v `elemVarSet` ae_joins env + = botArityType -- See Note [Eta-expansion and join points] | otherwise - = ATop (take (idArity v) one_shots) - where - one_shots :: [OneShotInfo] -- One-shot-ness derived from the type - one_shots = typeArity (idType v) + = idArityType v -- Lambdas; increase arity arityType env (Lam x e) @@ -789,13 +798,13 @@ arityType env (App fun arg ) -- arityType env (Case scrut _ _ alts) | exprIsDeadEnd scrut || null alts - = ABot 0 -- Do not eta expand - -- See Note [Dealing with bottom (1)] + = botArityType -- Do not eta expand + -- See Note [Dealing with bottom (1)] | otherwise = case alts_type of - ABot n | n>0 -> ATop [] -- Don't eta expand - | otherwise -> ABot 0 -- if RHS is bottomming - -- See Note [Dealing with bottom (2)] + ABot n | n>0 -> ATop [] -- Don't eta expand + | otherwise -> botArityType -- if RHS is bottomming + -- See Note [Dealing with bottom (2)] ATop as | not (ae_ped_bot env) -- See Note [Dealing with bottom (3)] , ae_cheap_fn env scrut Nothing -> ATop as @@ -804,6 +813,28 @@ arityType env (Case scrut _ _ alts) where alts_type = foldr1 andArityType [arityType env rhs | (_,_,rhs) <- alts] +arityType env (Let (NonRec j rhs) body) + | Just join_arity <- isJoinId_maybe j + , (_, rhs_body) <- collectNBinders join_arity rhs + = -- See Note [Eta-expansion and join points] + andArityType (arityType env rhs_body) + (arityType env' body) + where + env' = extendJoinEnv env [j] + +arityType env (Let (Rec pairs) body) + | ((j,_):_) <- pairs + , isJoinId j + = -- See Note [Eta-expansion and join points] + foldr (andArityType . do_one) (arityType env' body) pairs + where + env' = extendJoinEnv env (map fst pairs) + do_one (j,rhs) + | Just arity <- isJoinId_maybe j + = arityType env' $ snd $ collectNBinders arity rhs + | otherwise + = pprPanic "arityType:joinrec" (ppr pairs) + arityType env (Let b e) = floatIn (cheap_bind b) (arityType env e) where @@ -816,6 +847,73 @@ arityType env (Tick t e) arityType _ _ = vanillaArityType +{- Note [Eta-expansion and join points] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider this (#18328) + + f x = join j y = case y of + True -> \a. blah + False -> \b. blah + in case x of + A -> j True + B -> \c. blah + C -> j False + +and suppose the join point is too big to inline. Now, what is the +arity of f? If we inlined the join point, we'd definitely say "arity +2" because we are prepared to push case-scrutinisation inside a +lambda. But currently the join point totally messes all that up, +because (thought of as a vanilla let-binding) the arity pinned on 'j' +is just 1. + +Why don't we eta-expand j? Because of +Note [Do not eta-expand join points] in GHC.Core.Opt.Simplify.Utils + +Even if we don't eta-expand j, why is its arity only 1? +See invariant 2b in Note [Invariants on join points] in GHC.Core. + +So we do this: + +* Treat the RHS of a join-point binding, /after/ stripping off + join-arity lambda-binders, as very like the body of the let. + More precisely, do andArityType with the arityType from the + body of the let. + +* Dually, when we come to a /call/ of a join point, just no-op + by returning botArityType, the bottom element of ArityType, + which so that: bot `andArityType` x = x + +* This works if the join point is bound in the expression we are + taking the arityType of. But if it's bound further out, it makes + no sense to say that (say) the arityType of (j False) is ABot 0. + Bad things happen. So we keep track of the in-scope join-point Ids + in ae_join. + +This will make f, above, have arity 2. Then, we'll eta-expand it thus: + + f x eta = (join j y = ... in case x of ...) eta + +and the Simplify will automatically push that application of eta into +the join points. + +An alternative (roughly equivalent) idea would be to carry an +environment mapping let-bound Ids to their ArityType. +-} + +idArityType :: Id -> ArityType +idArityType v + | strict_sig <- idStrictness v + , not $ isTopSig strict_sig + , (ds, res) <- splitStrictSig strict_sig + , let arity = length ds + = if isDeadEndDiv res then ABot arity + else ATop (take arity one_shots) + | otherwise + = ATop (take (idArity v) one_shots) + where + one_shots :: [OneShotInfo] -- One-shot-ness derived from the type + one_shots = typeArity (idType v) + {- %************************************************************************ %* * @@ -912,6 +1010,25 @@ which we want to lead to code like This means that we need to look through type applications and be ready to re-add floats on the top. +Note [Eta expansion with ArityType] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The etaExpandAT function takes an ArityType (not just an Arity) to +guide eta-expansion. Why? Because we want to preserve one-shot info. +Consider + foo = \x. case x of + True -> (\s{os}. blah) |> co + False -> wubble +We'll get an ArityType for foo of (ATop [NoOneShot,OneShot]). + +Then we want to eta-expand to + foo = \x. (\eta{os}. (case x of ...as before...) eta) |> some_co + +That 'eta' binder is fresh, and we really want it to have the +one-shot flag from the inner \s{osf}. By expanding with the +ArityType gotten from analysing the RHS, we achieve this neatly. + +This makes a big difference to the one-shot monad trick; +see Note [The one-shot state monad trick] in GHC.Core.Unify. -} -- | @etaExpand n e@ returns an expression with @@ -924,11 +1041,16 @@ to re-add floats on the top. -- We should have that: -- -- > ty = exprType e = exprType e' -etaExpand :: Arity -- ^ Result should have this number of value args - -> CoreExpr -- ^ Expression to expand - -> CoreExpr +etaExpand :: Arity -> CoreExpr -> CoreExpr +etaExpandAT :: ArityType -> CoreExpr -> CoreExpr + +etaExpand n orig_expr = eta_expand (replicate n NoOneShotInfo) orig_expr +etaExpandAT at orig_expr = eta_expand (arityTypeOneShots at) orig_expr + -- See Note [Eta expansion with ArityType] + -- etaExpand arity e = res -- Then 'res' has at least 'arity' lambdas at the top +-- See Note [Eta expansion with ArityType] -- -- etaExpand deals with for-alls. For example: -- etaExpand 1 E @@ -939,21 +1061,23 @@ etaExpand :: Arity -- ^ Result should have this number of value arg -- It deals with coerces too, though they are now rare -- so perhaps the extra code isn't worth it -etaExpand n orig_expr - = go n orig_expr +eta_expand :: [OneShotInfo] -> CoreExpr -> CoreExpr +eta_expand one_shots orig_expr + = go one_shots orig_expr where -- Strip off existing lambdas and casts before handing off to mkEtaWW -- Note [Eta expansion and SCCs] - go 0 expr = expr - go n (Lam v body) | isTyVar v = Lam v (go n body) - | otherwise = Lam v (go (n-1) body) - go n (Cast expr co) = Cast (go n expr) co - go n expr + go [] expr = expr + go oss@(_:oss1) (Lam v body) | isTyVar v = Lam v (go oss body) + | otherwise = Lam v (go oss1 body) + go oss (Cast expr co) = Cast (go oss expr) co + + go oss expr = -- pprTrace "ee" (vcat [ppr orig_expr, ppr expr, ppr etas]) $ retick $ etaInfoAbs etas (etaInfoApp subst' sexpr etas) where in_scope = mkInScopeSet (exprFreeVars expr) - (in_scope', etas) = mkEtaWW n (ppr orig_expr) in_scope (exprType expr) + (in_scope', etas) = mkEtaWW oss (ppr orig_expr) in_scope (exprType expr) subst' = mkEmptySubst in_scope' -- Find ticks behind type apps. @@ -1052,7 +1176,7 @@ etaInfoAppTy _ (EtaCo co : eis) = etaInfoAppTy (coercionRKind co) eis -- semantically-irrelevant source annotations, so call sites must take care to -- preserve that info. See Note [Eta expansion and SCCs]. mkEtaWW - :: Arity + :: [OneShotInfo] -- ^ How many value arguments to eta-expand -> SDoc -- ^ The pretty-printed original expression, for warnings. @@ -1064,36 +1188,29 @@ mkEtaWW -- The outgoing 'InScopeSet' extends the incoming 'InScopeSet' with the -- fresh variables in 'EtaInfo'. -mkEtaWW orig_n ppr_orig_expr in_scope orig_ty - = go orig_n empty_subst orig_ty [] +mkEtaWW orig_oss ppr_orig_expr in_scope orig_ty + = go 0 orig_oss empty_subst orig_ty [] where empty_subst = mkEmptyTCvSubst in_scope - go :: Arity -- Number of value args to expand to + go :: Int -- For fresh names + -> [OneShotInfo] -- Number of value args to expand to -> TCvSubst -> Type -- We are really looking at subst(ty) -> [EtaInfo] -- Accumulating parameter -> (InScopeSet, [EtaInfo]) - go n subst ty eis -- See Note [exprArity invariant] - + go _ [] subst _ eis -- See Note [exprArity invariant] ----------- Done! No more expansion needed - | n == 0 = (getTCvInScope subst, reverse eis) + go n oss@(one_shot:oss1) subst ty eis -- See Note [exprArity invariant] ----------- Forall types (forall a. ty) | Just (tcv,ty') <- splitForAllTy_maybe ty - , let (subst', tcv') = Type.substVarBndr subst tcv - = let ((n_subst, n_tcv), n_n) - -- We want to have at least 'n' lambdas at the top. - -- If tcv is a tyvar, it corresponds to one Lambda (/\). - -- And we won't reduce n. - -- If tcv is a covar, we could eta-expand the expr with one - -- lambda \co:ty. e co. In this case we generate a new variable - -- of the coercion type, update the scope, and reduce n by 1. - | isTyVar tcv = ((subst', tcv'), n) - -- covar case: - | otherwise = (freshEtaId n subst' (unrestricted (varType tcv')), n-1) - -- Avoid free vars of the original expression - in go n_n n_subst ty' (EtaVar n_tcv : eis) + , (subst', tcv') <- Type.substVarBndr subst tcv + , let oss' | isTyVar tcv = oss + | otherwise = oss1 + -- A forall can bind a CoVar, in which case + -- we consume one of the [OneShotInfo] + = go n oss' subst' ty' (EtaVar tcv' : eis) ----------- Function types (t1 -> t2) | Just (mult, arg_ty, res_ty) <- splitFunTy_maybe ty @@ -1101,9 +1218,11 @@ mkEtaWW orig_n ppr_orig_expr in_scope orig_ty -- See Note [Levity polymorphism invariants] in GHC.Core -- See also test case typecheck/should_run/EtaExpandLevPoly - , let (subst', eta_id') = freshEtaId n subst (Scaled mult arg_ty) - -- Avoid free vars of the original expression - = go (n-1) subst' res_ty (EtaVar eta_id' : eis) + , (subst', eta_id) <- freshEtaId n subst (Scaled mult arg_ty) + -- Avoid free vars of the original expression + + , let eta_id' = eta_id `setIdOneShotInfo` one_shot + = go (n+1) oss1 subst' res_ty (EtaVar eta_id' : eis) ----------- Newtypes -- Given this: @@ -1117,12 +1236,12 @@ mkEtaWW orig_n ppr_orig_expr in_scope orig_ty -- Remember to apply the substitution to co (#16979) -- (or we could have applied to ty, but then -- we'd have had to zap it for the recursive call) - = go n subst ty' (pushCoercion co' eis) + = go n oss subst ty' (pushCoercion co' eis) | otherwise -- We have an expression of arity > 0, -- but its type isn't a function, or a binder -- is levity-polymorphic - = WARN( True, (ppr orig_n <+> ppr orig_ty) $$ ppr_orig_expr ) + = WARN( True, (ppr orig_oss <+> ppr orig_ty) $$ ppr_orig_expr ) (getTCvInScope subst, reverse eis) -- This *can* legitimately happen: -- e.g. coerce Int (\x. x) Essentially the programmer is ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -1519,18 +1519,40 @@ match_cstring_length env id_unf _ [lit1] match_cstring_length _ _ _ _ = Nothing --------------------------------------------------- --- The rule is this: --- inline f_ty (f a b c) = a b c --- (if f has an unfolding, EVEN if it's a loop breaker) --- --- It's important to allow the argument to 'inline' to have args itself --- (a) because its more forgiving to allow the programmer to write --- inline f a b c --- or inline (f a b c) --- (b) because a polymorphic f wll get a type argument that the --- programmer can't avoid --- --- Also, don't forget about 'inline's type argument! +{- Note [inlineId magic] +~~~~~~~~~~~~~~~~~~~~~~~~ +The call 'inline f' arranges that 'f' is inlined, regardless of +its size. More precisely, the call 'inline f' rewrites to the +right-hand side of 'f's definition. This allows the programmer to +control inlining from a particular call site rather than the +definition site of the function. + +The moving parts are simple: + +* A very simple definition in the library base:GHC.Magic + {-# NOINLINE[0] inline #-} + inline :: a -> a + inline x = x + So in phase 0, 'inline' will be inlined, so its use imposes + no overhead. + +* A rewrite rule, in GHC.Core.Opt.ConstantFold, which makes + (inline f) inline, implemented by match_inline. + The rule for the 'inline' function is this: + inline f_ty (f a b c) = a b c + (if f has an unfolding, EVEN if it's a loop breaker) + + It's important to allow the argument to 'inline' to have args itself + (a) because its more forgiving to allow the programmer to write + either inline f a b c + or inline (f a b c) + (b) because a polymorphic f wll get a type argument that the + programmer can't avoid, so the call may look like + inline (map @Int @Bool) g xs + + Also, don't forget about 'inline's type argument! +-} + match_inline :: [Expr CoreBndr] -> Maybe (Expr CoreBndr) match_inline (Type _ : e : _) | (Var f, args1) <- collectArgs e, @@ -1540,7 +1562,7 @@ match_inline (Type _ : e : _) match_inline _ = Nothing - +--------------------------------------------------- -- See Note [magicDictId magic] in "GHC.Types.Id.Make" -- for a description of what is going on here. match_magicDict :: [Expr CoreBndr] -> Maybe (Expr CoreBndr) ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -46,7 +46,8 @@ import GHC.Core.Ppr ( pprCoreExpr ) import GHC.Types.Unique ( hasKey ) import GHC.Core.Unfold import GHC.Core.Utils -import GHC.Core.Opt.Arity ( etaExpand ) +import GHC.Core.Opt.Arity ( ArityType(..), arityTypeArity, isBotArityType + , idArityType, etaExpandAT ) import GHC.Core.SimpleOpt ( pushCoTyArg, pushCoValArg , joinPointBinding_maybe, joinPointBindings_maybe ) import GHC.Core.FVs ( mkRuleInfo ) @@ -706,10 +707,10 @@ makeTrivialBinding mode top_lvl occ_fs info expr expr_ty -- Now something very like completeBind, -- but without the postInlineUnconditionally part - ; (arity, is_bot, expr2) <- tryEtaExpandRhs mode var expr1 + ; (arity_type, expr2) <- tryEtaExpandRhs mode var expr1 ; unf <- mkLetUnfolding (sm_dflags mode) top_lvl InlineRhs var expr2 - ; let final_id = addLetBndrInfo var arity is_bot unf + ; let final_id = addLetBndrInfo var arity_type unf bind = NonRec final_id expr2 ; return ( floats `addLetFlts` unitLetFloat bind, final_id ) } @@ -799,14 +800,13 @@ completeBind env top_lvl mb_cont old_bndr new_bndr new_rhs -- Do eta-expansion on the RHS of the binding -- See Note [Eta-expanding at let bindings] in GHC.Core.Opt.Simplify.Utils - ; (new_arity, is_bot, final_rhs) <- tryEtaExpandRhs (getMode env) - new_bndr new_rhs + ; (new_arity, final_rhs) <- tryEtaExpandRhs (getMode env) new_bndr new_rhs -- Simplify the unfolding ; new_unfolding <- simplLetUnfolding env top_lvl mb_cont old_bndr final_rhs (idType new_bndr) new_arity old_unf - ; let final_bndr = addLetBndrInfo new_bndr new_arity is_bot new_unfolding + ; let final_bndr = addLetBndrInfo new_bndr new_arity new_unfolding -- See Note [In-scope set as a substitution] ; if postInlineUnconditionally env top_lvl final_bndr occ_info final_rhs @@ -823,10 +823,13 @@ completeBind env top_lvl mb_cont old_bndr new_bndr new_rhs -- pprTrace "Binding" (ppr final_bndr <+> ppr new_unfolding) $ return (mkFloatBind env (NonRec final_bndr final_rhs)) } -addLetBndrInfo :: OutId -> Arity -> Bool -> Unfolding -> OutId -addLetBndrInfo new_bndr new_arity is_bot new_unf +addLetBndrInfo :: OutId -> ArityType -> Unfolding -> OutId +addLetBndrInfo new_bndr new_arity_type new_unf = new_bndr `setIdInfo` info5 where + new_arity = arityTypeArity new_arity_type + is_bot = isBotArityType new_arity_type + info1 = idInfo new_bndr `setArityInfo` new_arity -- Unfolding info: Note [Setting the new unfolding] @@ -844,12 +847,13 @@ addLetBndrInfo new_bndr new_arity is_bot new_unf = info2 -- Bottoming bindings: see Note [Bottoming bindings] - info4 | is_bot = info3 - `setStrictnessInfo` - mkClosedStrictSig (replicate new_arity topDmd) botDiv - `setCprInfo` mkCprSig new_arity botCpr + info4 | is_bot = info3 `setStrictnessInfo` bot_sig + `setCprInfo` bot_cpr | otherwise = info3 + bot_sig = mkClosedStrictSig (replicate new_arity topDmd) botDiv + bot_cpr = mkCprSig new_arity botCpr + -- Zap call arity info. We have used it by now (via -- `tryEtaExpandRhs`), and the simplifier can invalidate this -- information, leading to broken code later (e.g. #13479) @@ -860,9 +864,9 @@ addLetBndrInfo new_bndr new_arity is_bot new_unf ~~~~~~~~~~~~~~~~~~~~~~~~ Generally speaking the arity of a binding should not decrease. But it *can* legitimately happen because of RULES. Eg - f = g Int + f = g @Int where g has arity 2, will have arity 2. But if there's a rewrite rule - g Int --> h + g @Int --> h where h has arity 1, then f's arity will decrease. Here's a real-life example, which is in the output of Specialise: @@ -892,7 +896,7 @@ Then we'd like to drop the dead immediately. So it's good to propagate the info that x's RHS is bottom to x's IdInfo as rapidly as possible. -We use tryEtaExpandRhs on every binding, and it turns ou that the +We use tryEtaExpandRhs on every binding, and it turns out that the arity computation it performs (via GHC.Core.Opt.Arity.findRhsArity) already does a simple bottoming-expression analysis. So all we need to do is propagate that info to the binder's IdInfo. @@ -1551,7 +1555,7 @@ simplLamBndr env bndr | isId bndr && hasCoreUnfolding old_unf -- Special case = do { (env1, bndr1) <- simplBinder env bndr ; unf' <- simplStableUnfolding env1 NotTopLevel Nothing bndr - (idType bndr1) (idArity bndr1) old_unf + (idType bndr1) (idArityType bndr1) old_unf ; let bndr2 = bndr1 `setIdUnfolding` unf' ; return (modifyInScope env1 bndr2, bndr2) } @@ -3736,7 +3740,7 @@ because we don't know its usage in each RHS separately simplLetUnfolding :: SimplEnv-> TopLevelFlag -> MaybeJoinCont -> InId - -> OutExpr -> OutType -> Arity + -> OutExpr -> OutType -> ArityType -> Unfolding -> SimplM Unfolding simplLetUnfolding env top_lvl cont_mb id new_rhs rhs_ty arity unf | isStableUnfolding unf @@ -3766,7 +3770,9 @@ mkLetUnfolding dflags top_lvl src id new_rhs simplStableUnfolding :: SimplEnv -> TopLevelFlag -> MaybeJoinCont -- Just k => a join point with continuation k -> InId - -> OutType -> Arity -> Unfolding + -> OutType + -> ArityType -- Used to eta expand, but only for non-join-points + -> Unfolding ->SimplM Unfolding -- Note [Setting the new unfolding] simplStableUnfolding env top_lvl mb_cont id rhs_ty id_arity unf @@ -3829,7 +3835,7 @@ simplStableUnfolding env top_lvl mb_cont id rhs_ty id_arity unf eta_expand expr | not eta_on = expr | exprIsTrivial expr = expr - | otherwise = etaExpand id_arity expr + | otherwise = etaExpandAT id_arity expr eta_on = sm_eta_expand (getMode env) {- Note [Eta-expand stable unfoldings] ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1479,9 +1479,9 @@ mkLam env bndrs body cont , sm_eta_expand (getMode env) , any isRuntimeVar bndrs , let body_arity = exprEtaExpandArity dflags body - , body_arity > 0 + , expandableArityType body_arity = do { tick (EtaExpansion (head bndrs)) - ; let res = mkLams bndrs (etaExpand body_arity body) + ; let res = mkLams bndrs (etaExpandAT body_arity body) ; traceSmpl "eta expand" (vcat [text "before" <+> ppr (mkLams bndrs body) , text "after" <+> ppr res]) ; return res } @@ -1551,7 +1551,7 @@ because the latter is not well-kinded. -} tryEtaExpandRhs :: SimplMode -> OutId -> OutExpr - -> SimplM (Arity, Bool, OutExpr) + -> SimplM (ArityType, OutExpr) -- See Note [Eta-expanding at let bindings] -- If tryEtaExpandRhs rhs = (n, is_bot, rhs') then -- (a) rhs' has manifest arity n @@ -1559,40 +1559,46 @@ tryEtaExpandRhs :: SimplMode -> OutId -> OutExpr tryEtaExpandRhs mode bndr rhs | Just join_arity <- isJoinId_maybe bndr = do { let (join_bndrs, join_body) = collectNBinders join_arity rhs - ; return (count isId join_bndrs, exprIsDeadEnd join_body, rhs) } + oss = [idOneShotInfo id | id <- join_bndrs, isId id] + arity_type | exprIsDeadEnd join_body = ABot (length oss) + | otherwise = ATop oss + ; return (arity_type, rhs) } -- Note [Do not eta-expand join points] -- But do return the correct arity and bottom-ness, because -- these are used to set the bndr's IdInfo (#15517) -- Note [Invariants on join points] invariant 2b, in GHC.Core + | sm_eta_expand mode -- Provided eta-expansion is on + , new_arity > old_arity -- And the current manifest arity isn't enough + , want_eta rhs + = do { tick (EtaExpansion bndr) + ; return (arity_type, etaExpandAT arity_type rhs) } + | otherwise - = do { (new_arity, is_bot, new_rhs) <- try_expand + = return (arity_type, rhs) - ; WARN( new_arity < old_id_arity, - (text "Arity decrease:" <+> (ppr bndr <+> ppr old_id_arity - <+> ppr old_arity <+> ppr new_arity) $$ ppr new_rhs) ) - -- Note [Arity decrease] in GHC.Core.Opt.Simplify - return (new_arity, is_bot, new_rhs) } where - try_expand - | exprIsTrivial rhs -- See Note [Do not eta-expand trivial expressions] - = return (exprArity rhs, False, rhs) - - | sm_eta_expand mode -- Provided eta-expansion is on - , new_arity > old_arity -- And the current manifest arity isn't enough - = do { tick (EtaExpansion bndr) - ; return (new_arity, is_bot, etaExpand new_arity rhs) } - - | otherwise - = return (old_arity, is_bot && new_arity == old_arity, rhs) - - dflags = sm_dflags mode - old_arity = exprArity rhs -- See Note [Do not expand eta-expand PAPs] - old_id_arity = idArity bndr - - (new_arity1, is_bot) = findRhsArity dflags bndr rhs old_arity - new_arity2 = idCallArity bndr - new_arity = max new_arity1 new_arity2 + dflags = sm_dflags mode + old_arity = exprArity rhs + + arity_type = findRhsArity dflags bndr rhs old_arity + `maxWithArity` idCallArity bndr + new_arity = arityTypeArity arity_type + + -- See Note [Which RHSs do we eta-expand?] + want_eta (Cast e _) = want_eta e + want_eta (Tick _ e) = want_eta e + want_eta (Lam b e) | isTyVar b = want_eta e + want_eta (App e a) | exprIsTrivial a = want_eta e + want_eta (Var {}) = False + want_eta (Lit {}) = False + want_eta _ = True +{- + want_eta _ = case arity_type of + ATop (os:_) -> isOneShotInfo os + ATop [] -> False + ABot {} -> True +-} {- Note [Eta-expanding at let bindings] @@ -1619,14 +1625,53 @@ because then 'genMap' will inline, and it really shouldn't: at least as far as the programmer is concerned, it's not applied to two arguments! -Note [Do not eta-expand trivial expressions] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Do not eta-expand a trivial RHS like - f = g -If we eta expand do - f = \x. g x -we'll just eta-reduce again, and so on; so the -simplifier never terminates. +Note [Which RHSs do we eta-expand?] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We don't eta-expand: + +* Trivial RHSs, e.g. f = g + If we eta expand do + f = \x. g x + we'll just eta-reduce again, and so on; so the + simplifier never terminates. + +* PAPs: see Note [Do not eta-expand PAPs] + +What about things like this? + f = case y of p -> \x -> blah + +Here we do eta-expand. This is a change (Jun 20), but if we have +really decided that f has arity 1, then putting that lambda at the top +seems like a Good idea. + +Note [Do not eta-expand PAPs] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We used to have old_arity = manifestArity rhs, which meant that we +would eta-expand even PAPs. But this gives no particular advantage, +and can lead to a massive blow-up in code size, exhibited by #9020. +Suppose we have a PAP + foo :: IO () + foo = returnIO () +Then we can eta-expand do + foo = (\eta. (returnIO () |> sym g) eta) |> g +where + g :: IO () ~ State# RealWorld -> (# State# RealWorld, () #) + +But there is really no point in doing this, and it generates masses of +coercions and whatnot that eventually disappear again. For T9020, GHC +allocated 6.6G before, and 0.8G afterwards; and residency dropped from +1.8G to 45M. + +Moreover, if we eta expand + f = g d ==> f = \x. g d x +that might in turn make g inline (if it has an inline pragma), which +we might not want. After all, INLINE pragmas say "inline only when +saturated" so we don't want to be too gung-ho about saturating! + +But note that this won't eta-expand, say + f = \g -> map g +Does it matter not eta-expanding such functions? I'm not sure. Perhaps +strictness analysis will have less to bite on? Note [Do not eta-expand join points] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1667,29 +1712,6 @@ CorePrep comes around, the code is very likely to look more like this: $j2 = if n > 0 then $j1 else (...) eta -Note [Do not eta-expand PAPs] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We used to have old_arity = manifestArity rhs, which meant that we -would eta-expand even PAPs. But this gives no particular advantage, -and can lead to a massive blow-up in code size, exhibited by #9020. -Suppose we have a PAP - foo :: IO () - foo = returnIO () -Then we can eta-expand do - foo = (\eta. (returnIO () |> sym g) eta) |> g -where - g :: IO () ~ State# RealWorld -> (# State# RealWorld, () #) - -But there is really no point in doing this, and it generates masses of -coercions and whatnot that eventually disappear again. For T9020, GHC -allocated 6.6G before, and 0.8G afterwards; and residency dropped from -1.8G to 45M. - -But note that this won't eta-expand, say - f = \g -> map g -Does it matter not eta-expanding such functions? I'm not sure. Perhaps -strictness analysis will have less to bite on? - ************************************************************************ * * ===================================== compiler/GHC/Types/Unique/Supply.hs ===================================== @@ -48,6 +48,7 @@ import GHC.Utils.Monad import Control.Monad import Data.Bits import Data.Char +import GHC.Exts( inline ) #include "Unique.h" @@ -111,8 +112,15 @@ Why doesn't full laziness float out the (\s2...)? Because of the state hack (#18238). So for this module we switch the state hack off -- it's an example -of when it makes things worse rather than better. Now full laziness -can float that lambda out, and we get +of when it makes things worse rather than better. And we use +multiShotIO (see Note [multiShotIO]) thus: + + mk_supply = multiShotIO $ + unsafeInterleaveIO $ + genSym >>= \ u -> + ... + +Now full laziness can float that lambda out, and we get $wmkSplitUniqSupply c# s = letrec @@ -146,6 +154,38 @@ bit slower. (Test perf/should_run/UniqLoop had a 20% perf change.) Sigh. The test perf/should_run/UniqLoop keeps track of this loop. Watch it carefully. + +Note [multiShotIO] +~~~~~~~~~~~~~~~~~~ +The function multiShotIO :: IO a -> IO a +says that the argument IO action may be invoked repeatedly (is +multi-shot), and so there should be a multi-shot lambda around it. +It's quite easy to define, in any module with `-fno-state-hack`: + multiShotIO :: IO a -> IO a + {-# INLINE multiShotIO #-} + multiShotIO (IO m) = IO (\s -> inline m s) + +Because of -fno-state-hack, that '\s' will be multi-shot. Now, +ignoring the casts from IO: + multiShotIO (\ss{one-shot}. blah) + ==> let m = \ss{one-shot}. blah + in \s. inline m s + ==> \s. (\ss{one-shot}.blah) s + ==> \s. blah[s/ss] + +The magic `inline` function does two things +* It prevents eta reduction. If we wrote just + multiShotIO (IO m) = IO (\s -> m s) + the lamda would eta-reduce to 'm' and all would be lost. + +* It helps ensure that 'm' really does inline. + +Note that 'inline' evaporates in phase 0. See Note [inlineIdMagic] +in GHC.Core.Opt.ConstantFold.match_inline. + +The INLINE pragma on multiShotIO is very important, else the +'inline' call will evaporate when compiling the module that +defines 'multiShotIO', before it is ever exported. -} @@ -176,12 +216,18 @@ mkSplitUniqSupply c -- This is one of the most hammered bits in the whole compiler -- See Note [Optimising the unique supply] -- NB: Use unsafeInterleaveIO for thread-safety. - mk_supply = unsafeInterleaveIO $ + mk_supply = multiShotIO $ + unsafeInterleaveIO $ genSym >>= \ u -> mk_supply >>= \ s1 -> mk_supply >>= \ s2 -> return (MkSplitUniqSupply (mask .|. u) s1 s2) +multiShotIO :: IO a -> IO a +{-# INLINE multiShotIO #-} +-- See Note [multiShotIO] +multiShotIO (IO m) = IO (\s -> inline m s) + foreign import ccall unsafe "genSym" genSym :: IO Int foreign import ccall unsafe "initGenSym" initUniqSupply :: Int -> Int -> IO () ===================================== testsuite/tests/profiling/should_run/T5654-O1.prof.sample ===================================== @@ -1,27 +1,28 @@ - Thu Dec 8 11:34 2016 Time and Allocation Profiling Report (Final) + Thu Jul 9 17:12 2020 Time and Allocation Profiling Report (Final) - T5654-O1 +RTS -p -RTS + T5654-O1 +RTS -hc -p -RTS total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) - total alloc = 39,064 bytes (excludes profiling overheads) + total alloc = 38,664 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc -MAIN MAIN 0.0 1.9 -CAF GHC.IO.Handle.FD 0.0 88.6 -CAF GHC.IO.Encoding 0.0 7.1 -CAF GHC.Conc.Signal 0.0 1.6 +MAIN MAIN 0.0 1.7 +CAF GHC.IO.Handle.FD 0.0 89.7 +CAF GHC.IO.Encoding 0.0 6.3 +CAF GHC.Conc.Signal 0.0 1.7 - individual inherited -COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc -MAIN MAIN 104 0 0.0 1.9 0.0 100.0 - CAF Main 207 0 0.0 0.0 0.0 0.2 - main Main T5654-O1.hs:13:1-21 208 1 0.0 0.1 0.0 0.2 - f Main T5654-O1.hs:7:1-5 209 1 0.0 0.0 0.0 0.0 - g Main T5654-O1.hs:11:1-11 210 1 0.0 0.0 0.0 0.0 - CAF GHC.Conc.Signal 201 0 0.0 1.6 0.0 1.6 - CAF GHC.IO.Encoding 191 0 0.0 7.1 0.0 7.1 - CAF GHC.IO.Encoding.Iconv 189 0 0.0 0.6 0.0 0.6 - CAF GHC.IO.Handle.FD 181 0 0.0 88.6 0.0 88.6 +MAIN MAIN 121 0 0.0 1.7 0.0 100.0 + CAF Main 241 0 0.0 0.0 0.0 0.1 + f Main T5654-O1.hs:7:1-5 243 1 0.0 0.0 0.0 0.0 + main Main T5654-O1.hs:13:1-21 242 1 0.0 0.1 0.0 0.1 + f Main T5654-O1.hs:7:1-5 244 0 0.0 0.0 0.0 0.0 + g Main T5654-O1.hs:11:1-11 245 1 0.0 0.0 0.0 0.0 + CAF GHC.Conc.Signal 236 0 0.0 1.7 0.0 1.7 + CAF GHC.IO.Encoding 227 0 0.0 6.3 0.0 6.3 + CAF GHC.IO.Encoding.Iconv 225 0 0.0 0.5 0.0 0.5 + CAF GHC.IO.Handle.FD 217 0 0.0 89.7 0.0 89.7 ===================================== testsuite/tests/profiling/should_run/T5654b-O1.prof.sample ===================================== @@ -1,28 +1,30 @@ - Fri Jun 3 11:00 2016 Time and Allocation Profiling Report (Final) + Thu Jul 9 17:12 2020 Time and Allocation Profiling Report (Final) T5654b-O1 +RTS -hc -p -RTS total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) - total alloc = 38,880 bytes (excludes profiling overheads) + total alloc = 38,728 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc MAIN MAIN 0.0 1.7 -CAF GHC.IO.Handle.FD 0.0 88.8 -CAF GHC.IO.Encoding 0.0 7.1 +CAF GHC.IO.Handle.FD 0.0 89.5 +CAF GHC.IO.Encoding 0.0 6.3 CAF GHC.Conc.Signal 0.0 1.7 - individual inherited -COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc + individual inherited +COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc -MAIN MAIN 43 0 0.0 1.7 0.0 100.0 - CAF Main 85 0 0.0 0.0 0.0 0.1 - main Main T5654b-O1.hs:22:1-21 86 1 0.0 0.1 0.0 0.1 - f Main T5654b-O1.hs:12:1-7 87 1 0.0 0.0 0.0 0.0 - g Main T5654b-O1.hs:16:1-7 88 1 0.0 0.0 0.0 0.0 - h Main T5654b-O1.hs:20:1-19 89 1 0.0 0.0 0.0 0.0 - CAF GHC.Conc.Signal 79 0 0.0 1.7 0.0 1.7 - CAF GHC.IO.Encoding 74 0 0.0 7.1 0.0 7.1 - CAF GHC.IO.Handle.FD 72 0 0.0 88.8 0.0 88.8 - CAF GHC.IO.Encoding.Iconv 53 0 0.0 0.6 0.0 0.6 +MAIN MAIN 121 0 0.0 1.7 0.0 100.0 + CAF Main 241 0 0.0 0.0 0.0 0.3 + f Main T5654b-O1.hs:12:1-7 243 1 0.0 0.1 0.0 0.1 + g Main T5654b-O1.hs:16:1-7 244 1 0.0 0.0 0.0 0.0 + main Main T5654b-O1.hs:22:1-21 242 1 0.0 0.1 0.0 0.1 + f Main T5654b-O1.hs:12:1-7 245 0 0.0 0.0 0.0 0.0 + g Main T5654b-O1.hs:16:1-7 246 0 0.0 0.0 0.0 0.0 + h Main T5654b-O1.hs:20:1-19 247 1 0.0 0.0 0.0 0.0 + CAF GHC.Conc.Signal 236 0 0.0 1.7 0.0 1.7 + CAF GHC.IO.Encoding 227 0 0.0 6.3 0.0 6.3 + CAF GHC.IO.Encoding.Iconv 225 0 0.0 0.5 0.0 0.5 + CAF GHC.IO.Handle.FD 217 0 0.0 89.5 0.0 89.5 ===================================== testsuite/tests/profiling/should_run/ioprof.stderr ===================================== @@ -1,5 +1,5 @@ ioprof: a -CallStack (from ImplicitParams): +CallStack (from HasCallStack): error, called at ioprof.hs:23:22 in main:Main CallStack (from -prof): Main.errorM.\ (ioprof.hs:23:22-28) @@ -11,4 +11,3 @@ CallStack (from -prof): Main.bar (ioprof.hs:31:1-20) Main.runM (ioprof.hs:26:1-37) Main.main (ioprof.hs:28:1-43) - Main.CAF () ===================================== testsuite/tests/simplCore/should_compile/T18328.hs ===================================== @@ -0,0 +1,14 @@ +module T18328 where + +f :: Int -> [a] -> [a] -> [a] +f x ys = let {-# NOINLINE j #-} + j y = case x of + 3 -> ((++) ys) . ((++) ys) . ((++) ys) . ((++) ys) + _ -> ((++) ys) . ((++) ys) . ((++) ys) + + in + case x of + 1 -> j 2 + 2 -> j 3 + 3 -> j 4 + _ -> ((++) ys) ===================================== testsuite/tests/simplCore/should_compile/T18328.stderr ===================================== @@ -0,0 +1,87 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 69, types: 61, coercions: 0, joins: 1/1} + +-- RHS size: {terms: 42, types: 28, coercions: 0, joins: 1/1} +T18328.$wf [InlPrag=NOUSERINLINE[2]] + :: forall {a}. GHC.Prim.Int# -> [a] -> [a] -> [a] +[GblId, + Arity=3, + Str=, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [182 0 0] 312 0}] +T18328.$wf + = \ (@a) (ww :: GHC.Prim.Int#) (w :: [a]) (w1 :: [a]) -> + join { + $wj [InlPrag=NOINLINE, Dmd=] + :: forall {p}. GHC.Prim.Void# -> [a] + [LclId[JoinId(2)], Arity=1, Str=, Unf=OtherCon []] + $wj (@p) _ [Occ=Dead, OS=OneShot] + = case ww of { + __DEFAULT -> ++ @a w (++ @a w (++ @a w w1)); + 3# -> ++ @a w (++ @a w (++ @a w (++ @a w w1))) + } } in + case ww of { + __DEFAULT -> ++ @a w w1; + 1# -> jump $wj @Integer GHC.Prim.void#; + 2# -> jump $wj @Integer GHC.Prim.void#; + 3# -> jump $wj @Integer GHC.Prim.void# + } + +-- RHS size: {terms: 11, types: 10, coercions: 0, joins: 0/0} +f [InlPrag=NOUSERINLINE[2]] :: forall a. Int -> [a] -> [a] -> [a] +[GblId, + Arity=3, + Str=, + Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) + Tmpl= \ (@a) + (w [Occ=Once!] :: Int) + (w1 [Occ=Once] :: [a]) + (w2 [Occ=Once] :: [a]) -> + case w of { GHC.Types.I# ww1 [Occ=Once] -> + T18328.$wf @a ww1 w1 w2 + }}] +f = \ (@a) (w :: Int) (w1 :: [a]) (w2 :: [a]) -> + case w of { GHC.Types.I# ww1 -> T18328.$wf @a ww1 w1 w2 } + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T18328.$trModule4 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +T18328.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T18328.$trModule3 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +T18328.$trModule3 = GHC.Types.TrNameS T18328.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T18328.$trModule2 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] +T18328.$trModule2 = "T18328"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T18328.$trModule1 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +T18328.$trModule1 = GHC.Types.TrNameS T18328.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +T18328.$trModule :: GHC.Types.Module +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] +T18328.$trModule + = GHC.Types.Module T18328.$trModule3 T18328.$trModule1 + + + ===================================== testsuite/tests/simplCore/should_compile/T18355.hs ===================================== @@ -0,0 +1,9 @@ +module T18355 where + +import GHC.Exts + +-- I expect the simplified Core to have an eta-expaned +-- defn of f, with a OneShot on the final lambda-binder +f x b = case b of + True -> oneShot (\y -> x+y) + False -> \y -> x-y ===================================== testsuite/tests/simplCore/should_compile/T18355.stderr ===================================== @@ -0,0 +1,70 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 32, types: 23, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 17, types: 10, coercions: 0, joins: 0/0} +f :: forall {a}. Num a => a -> Bool -> a -> a +[GblId, + Arity=4, + Str=, + Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=4,unsat_ok=True,boring_ok=False) + Tmpl= \ (@a) + ($dNum [Occ=Once*] :: Num a) + (x [Occ=Once*] :: a) + (b [Occ=Once!] :: Bool) + (eta [Occ=Once*, OS=OneShot] :: a) -> + case b of { + False -> - @a $dNum x eta; + True -> + @a $dNum x eta + }}] +f = \ (@a) + ($dNum :: Num a) + (x :: a) + (b :: Bool) + (eta [OS=OneShot] :: a) -> + case b of { + False -> - @a $dNum x eta; + True -> + @a $dNum x eta + } + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T18355.$trModule4 :: Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +T18355.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T18355.$trModule3 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +T18355.$trModule3 = GHC.Types.TrNameS T18355.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T18355.$trModule2 :: Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] +T18355.$trModule2 = "T18355"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T18355.$trModule1 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +T18355.$trModule1 = GHC.Types.TrNameS T18355.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +T18355.$trModule :: GHC.Types.Module +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] +T18355.$trModule + = GHC.Types.Module T18355.$trModule3 T18355.$trModule1 + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -328,5 +328,7 @@ test('T18231', [ only_ways(['optasm']), grep_errmsg(r'^[\w\.]+ ::.*->.*') ], com # Cast WW test('T17673', [ only_ways(['optasm']), grep_errmsg(r'^\w+\.\$wf') ], compile, ['-ddump-simpl -dsuppress-uniques -dppr-cols=9999']) test('T18078', [ only_ways(['optasm']), grep_errmsg(r'^\w+\.\$wf') ], compile, ['-ddump-simpl -dsuppress-uniques -dppr-cols=9999']) +test('T18328', [ only_ways(['optasm']), grep_errmsg(r'Arity=') ], compile, ['-ddump-simpl -dsuppress-uniques']) test('T18347', normal, compile, ['-dcore-lint -O']) +test('T18355', [ grep_errmsg(r'OneShot') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T18399', normal, compile, ['-dcore-lint -O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3656dff8259199d0dab2d1a1f1b887c252a9c1a3...2b7c71cb79095a10b9a5964a5a0676a2a196e92d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3656dff8259199d0dab2d1a1f1b887c252a9c1a3...2b7c71cb79095a10b9a5964a5a0676a2a196e92d You're receiving 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 Jul 11 16:18:26 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 12:18:26 -0400 Subject: [Git][ghc/ghc][wip/simon-perf] 32 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f09e6523fd88_80b3f849c221f4026554d2@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/simon-perf at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - 0c41e851 by Simon Peyton Jones at 2020-07-11T12:18:08-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - f44b5b9e by Simon Peyton Jones at 2020-07-11T12:18:08-04:00 Comments only - - - - - b9f0d583 by Simon Peyton Jones at 2020-07-11T12:18:08-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - f2506067 by Simon Peyton Jones at 2020-07-11T12:18:08-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes two significant changes: 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Then in postInlineUnconditionally use that info to avoid inling something many many times. Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally See Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils 2. Change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg] Current nofib run Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- VS -0.3% +115.9% +12.1% +11.2% 0.0% boyer2 -0.3% +10.0% +3.5% +4.0% 0.0% cryptarithm2 -0.3% +39.0% +16.6% +16.1% 0.0% gamteb -0.3% +4.1% -0.0% +0.4% 0.0% last-piece -0.3% +1.4% -1.1% -0.4% 0.0% mate -0.4% -11.1% -8.5% -9.0% 0.0% multiplier -0.3% -2.2% -1.5% -1.5% 0.0% transform -0.3% +3.4% +0.5% +0.8% 0.0% -------------------------------------------------------------------------------- Min -0.8% -11.1% -8.5% -9.0% 0.0% Max -0.3% +115.9% +30.1% +26.4% 0.0% Geometric Mean -0.3% +1.0% +1.0% +1.0% -0.0% Should investigate these numbers. But the tickets are indeed cured, I think. - - - - - 30 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Types/Unique/Supply.hs - compiler/GHC/Unit/Types.hs - configure.ac - docs/users_guide/8.12.1-notes.rst - docs/users_guide/phases.rst - docs/users_guide/shared_libs.rst - hadrian/.gitignore - hadrian/README.md - hadrian/doc/make.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d0a71dc443b9e4b017e043ee4c138720ddb4d9a6...f250606761b8120799a276eafc858bfb94743df9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d0a71dc443b9e4b017e043ee4c138720ddb4d9a6...f250606761b8120799a276eafc858bfb94743df9 You're receiving 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 Jul 11 16:39:14 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 12:39:14 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] Backport CI infrastructure rework Message-ID: <5f09eb32f40e2_80b3f8490174d382657253@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 2ca1a2dd by Ben Gamari at 2020-07-11T12:38:59-04:00 Backport CI infrastructure rework - - - - - 5 changed files: - .gitlab-ci.yml - + .gitlab/ci.sh - − .gitlab/darwin-init.sh - + .gitlab/linters/check-version-number.sh - − .gitlab/win32-init.sh Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,59 +2,45 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a + DOCKER_REV: 6223fe0b5942f4fa35bdec92c74566cf195bfb42 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/win32-init.sh. + # .gitlab/ci.sh. WINDOWS_TOOLCHAIN_VERSION: 1 -before_script: - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + # Disable shallow clones; they break our linting rules + GIT_DEPTH: 0 + + # Overridden by individual jobs + CONFIGURE_ARGS: "" + + GIT_SUBMODULE_STRATEGY: "recursive" stages: - - lint # Source linting - - build # A quick smoke-test to weed out broken commits - - full-build # Build all the things - - cleanup # See Note [Cleanup on Windows] - - packaging # Source distribution, etc. - - hackage # head.hackage testing - - deploy # push documentation - -.only-default: &only-default - rules: - - if: $CI_MERGE_REQUEST_ID - - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "master"' - - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - - if: '$CI_PIPELINE_SOURCE == "web"' + - lint # Source linting + - quick-build # A very quick smoke-test to weed out broken commits + - build # A quick smoke-test to weed out broken commits + - full-build # Build all the things + - cleanup # See Note [Cleanup after the shell executor] + - packaging # Source distribution, etc. + - testing # head.hackage correctness and compiler performance testing + - deploy # push documentation workflow: - # N.B. Don't run on wip/ branches, instead on run on merge requests. + # N.B.Don't run on wip/ branches, instead on run on merge requests. rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' -############################################################ -# Runner Tags -############################################################ -# -# * x86_64-linux: Any Docker-capable x86_64 Linux machine -# * aarch64-linux: Any Docker-capable AArch64 Linux machine -# * x86_64-windows: A x86_64 Windows machine -# * lint: Any Docker-capable x86_64 Linux machine; distinct from -# x86_64-linux to ensure low-latency availability. -# - .nightly: &nightly rules: - if: $NIGHTLY + artifacts: + when: always + expire_in: 8 weeks .release: &release variables: @@ -66,53 +52,105 @@ workflow: rules: - if: '$RELEASE == "yes"' +############################################################ +# Runner Tags +############################################################ +# +# * x86_64-linux: Any Docker-capable x86_64 Linux machine +# * aarch64-linux: Any Docker-capable AArch64 Linux machine +# * x86_64-windows: A x86_64 Windows machine +# * lint: Any Docker-capable x86_64 Linux machine; distinct from +# x86_64-linux to ensure low-latency availability. +# + ############################################################ # Linting ############################################################ ghc-linters: - allow_failure: true stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" - - "echo Merge base $base" + - "echo Linting changes between $base..$CI_COMMIT_SHA" # - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA) - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA) - - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA - - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA + - .gitlab/linters/check-makefiles.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-cpp.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-version-number.sh + - python3 utils/checkUniques/check-uniques.py . dependencies: [] tags: - lint rules: - if: $CI_MERGE_REQUEST_ID +# Run mypy Python typechecker on linter scripts. +lint-linters: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy .gitlab/linters/*.py + dependencies: [] + tags: + - lint + +# Check that .T files all parse by listing broken tests. +lint-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + script: + - make -Ctestsuite list_broken TEST_HC=ghc + dependencies: [] + tags: + - lint + +# Run mypy Python typechecker on testsuite driver +typecheck-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy testsuite/driver/runtests.py + dependencies: [] + tags: + - lint + # We allow the submodule checker to fail when run on merge requests (to -# accomodate, e.g., haddock changes not yet upstream) but not on `master` or +# accommodate, e.g., haddock changes not yet upstream) but not on `master` or # Marge jobs. .lint-submods: stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA) + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" + - "echo Linting submodule changes between $base..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $base..$CI_COMMIT_SHA) dependencies: [] tags: - lint lint-submods: extends: .lint-submods + # Allow failure on merge requests since any necessary submodule patches may + # not be upstreamed yet. rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/' allow_failure: false - allow_failure: true -lint-submods-mr: +lint-submods-branch: extends: .lint-submods - allow_failure: true + script: + - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA) rules: - - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' .lint-changelogs: stage: lint @@ -125,6 +163,7 @@ lint-submods-mr: lint-changelogs: extends: .lint-changelogs + # Allow failure since this isn't a final release. allow_failure: true rules: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' @@ -140,71 +179,183 @@ lint-release-changelogs: ############################################################ .validate-hadrian: - <<: *only-default - allow_failure: true + variables: + FLAVOUR: "validate" script: - - cabal update - - git clean -xdf && git submodule foreach git clean -xdf - - bash .circleci/prepare-system.sh - - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi - - ./boot - - ./configure $CONFIGURE_ARGS - - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian cache: key: hadrian paths: - cabal-cache artifacts: - when: always + reports: + junit: junit.xml + expire_in: 2 week paths: - ghc.tar.xz + - junit.xml -validate-x86_64-linux-deb8-hadrian: +.validate-linux-hadrian: extends: .validate-hadrian - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + variables: + TEST_ENV: "x86_64-linux-deb9-hadrian" before_script: # workaround for docker permissions - sudo chown ghc:ghc -R . - - python3 .gitlab/fix-submodules.py - git submodule sync --recursive - git submodule update --init --recursive - git checkout .gitmodules - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + after_script: + - .gitlab/ci.sh clean tags: - x86_64-linux +validate-x86_64-linux-deb9-hadrian: + extends: .validate-linux-hadrian + stage: build + +validate-x86_64-linux-deb9-unreg-hadrian: + extends: .validate-linux-hadrian + stage: full-build + variables: + CONFIGURE_ARGS: --enable-unregisterised + TEST_ENV: "x86_64-linux-deb9-unreg-hadrian" + +hadrian-ghc-in-ghci: + stage: quick-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + variables: + GHC_FLAGS: -Werror + tags: + - x86_64-linux + script: + - cabal update + - cd hadrian; cabal new-build --project-file=ci.project; cd .. + - git clean -xdf && git submodule foreach git clean -xdf + - .gitlab/ci.sh setup + - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi + - ./boot + - ./configure $CONFIGURE_ARGS + # 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," + cache: + key: hadrian-ghci + paths: + - cabal-cache ############################################################ # Validation via Pipelines (make) ############################################################ .validate: - <<: *only-default variables: TEST_TYPE: test - before_script: - - git clean -xdf && git submodule foreach git clean -xdf + MAKE_ARGS: "-Werror" script: - - ./boot - - ./configure $CONFIGURE_ARGS - - | - THREADS=`mk/detect-cpu-count.sh` - make V=0 -j$THREADS WERROR=-Werror - - | - make binary-dist TAR_COMP_OPTS="-1" - - | - THREADS=`mk/detect-cpu-count.sh` - make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_make + - .gitlab/ci.sh test_make dependencies: [] artifacts: reports: junit: junit.xml expire_in: 2 week paths: - - ghc-*.tar.xz + - $BIN_DIST_PREP_TAR_COMP - junit.xml + - performance-metrics.tsv + +################################# +# x86_64-freebsd +################################# + +.build-x86_64-freebsd: + extends: .validate + tags: + - x86_64-freebsd + allow_failure: true + variables: + # N.B. we use iconv from ports as I see linker errors when we attempt + # to use the "native" iconv embedded in libc as suggested by the + # porting guide [1]. + # [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + GHC_VERSION: 8.10.1 + CABAL_INSTALL_VERSION: 3.2.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd" + BUILD_FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Conditional due to lack of builder capacity +validate-x86_64-freebsd: + extends: .build-x86_64-freebsd + stage: full-build + rules: + - if: '$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/' + +nightly-x86_64-freebsd: + <<: *nightly + extends: .build-x86_64-freebsd + stage: full-build + +release-x86_64-freebsd: + <<: *release + extends: .build-x86_64-freebsd + stage: full-build + +.build-x86_64-freebsd-hadrian: + extends: .validate-hadrian + stage: full-build + tags: + - x86_64-freebsd + allow_failure: true + variables: + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + HADRIAN_ARGS: "--docs=no-sphinx" + GHC_VERSION: 8.6.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd-hadrian" + FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Disabled due to lack of builder capacity +.validate-x86_64-freebsd-hadrian: + extends: .build-x86_64-freebsd-hadrian + stage: full-build ################################# # x86_64-darwin @@ -216,54 +367,71 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: "8.8.3" - CABAL_INSTALL_VERSION: 2.4.1.0 - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz" + GHC_VERSION: 8.8.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-apple-darwin.tar.xz" MACOSX_DEPLOYMENT_TARGET: "10.7" # Only Sierra and onwards supports clock_gettime. See #12858 ac_cv_func_clock_gettime: "no" LANG: "en_US.UTF-8" - CONFIGURE_ARGS: --with-intree-gmp + CONFIGURE_ARGS: "--with-intree-gmp" TEST_ENV: "x86_64-darwin" - before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - - bash .gitlab/darwin-init.sh - - PATH="`pwd`/toolchain/bin:$PATH" + BUILD_FLAVOUR: "perf" after_script: - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean artifacts: when: always expire_in: 2 week cache: - key: darwin + key: "darwin-$GHC_VERSION" paths: - cabal-cache - toolchain +# Disabled because of OS X CI capacity +.validate-x86_64-darwin-hadrian: + stage: full-build + tags: + - x86_64-darwin + variables: + GHC_VERSION: 8.8.3 + MACOSX_DEPLOYMENT_TARGET: "10.7" + ac_cv_func_clock_gettime: "no" + LANG: "en_US.UTF-8" + CONFIGURE_ARGS: --with-intree-gmp + TEST_ENV: "x86_64-darwin-hadrian" + FLAVOUR: "validate" + script: + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + reports: + junit: junit.xml + paths: + - ghc.tar.xz + - junit.xml + .validate-linux: extends: .validate tags: - x86_64-linux + variables: + BUILD_FLAVOUR: "perf" before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" # Build hyperlinked sources for documentation when building releases - | if [[ -n "$CI_COMMIT_TAG" ]]; then - echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk + HADDOCK_HYPERLINKED_SOURCES=1 fi - - bash .circleci/prepare-system.sh # workaround for docker permissions - sudo chown ghc:ghc -R . after_script: @@ -285,9 +453,7 @@ validate-x86_64-darwin: allow_failure: true variables: TEST_ENV: "aarch64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz" - # Inexplicably makeindex fails - BUILD_SPHINX_PDF: "NO" + BIN_DIST_PREP_TAR_COMP: "ghc-aarch64-linux-deb9.tar.xz" cache: key: linux-aarch64-deb9 tags: @@ -302,8 +468,41 @@ validate-aarch64-linux-deb9: nightly-aarch64-linux-deb9: <<: *nightly extends: .build-aarch64-linux-deb9 + variables: + TEST_TYPE: slowtest + +################################# +# armv7-linux-deb9 +################################# + +.build-armv7-linux-deb9: + extends: .validate-linux + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb9:$DOCKER_REV" + # Due to linker issues + allow_failure: true + variables: + TEST_ENV: "armv7-linux-deb9" + BIN_DIST_PREP_TAR_COMP: "ghc-armv7-linux-deb9.tar.xz" + CONFIGURE_ARGS: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" + # N.B. We disable ld.lld explicitly here because it appears to fail + # non-deterministically on ARMv7. See #18280. + LD: "ld.gold" + GccUseLdOpt: "-fuse-ld=gold" + cache: + key: linux-armv7-deb9 + tags: + - armv7-linux + +validate-armv7-linux-deb9: + extends: .build-armv7-linux-deb9 artifacts: - expire_in: 2 year + when: always + expire_in: 2 week + +nightly-armv7-linux-deb9: + <<: *nightly + extends: .build-armv7-linux-deb9 variables: TEST_TYPE: slowtest @@ -317,7 +516,7 @@ nightly-aarch64-linux-deb9: image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "i386-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-i386-deb9-linux.tar.xz" cache: key: linux-i386-deb9 @@ -332,23 +531,6 @@ nightly-i386-linux-deb9: extends: .build-i386-linux-deb9 variables: TEST_TYPE: slowtest - artifacts: - when: always - expire_in: 2 week - -################################# -# x86_64-linux-deb10 -################################# - -.build-x86_64-linux-deb10: - extends: .validate-linux - stage: full-build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - variables: - TEST_ENV: "x86_64-linux-deb10" - BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" - cache: - key: linux-x86_64-deb10 ################################# # x86_64-linux-deb9 @@ -356,40 +538,62 @@ nightly-i386-linux-deb9: .build-x86_64-linux-deb9: extends: .validate-linux - stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb9-linux.tar.xz" cache: key: linux-x86_64-deb9 -validate-x86_64-linux-deb9: +# Disabled to reduce CI load +.validate-x86_64-linux-deb9: extends: .build-x86_64-linux-deb9 + stage: full-build artifacts: when: always expire_in: 2 week +release-x86_64-linux-deb9: + <<: *release + extends: .build-x86_64-linux-deb9 + stage: full-build + nightly-x86_64-linux-deb9: <<: *nightly extends: .build-x86_64-linux-deb9 - artifacts: - expire_in: 2 year + stage: full-build variables: TEST_TYPE: slowtest # N.B. Has DEBUG assertions enabled in stage2 validate-x86_64-linux-deb9-debug: extends: .build-x86_64-linux-deb9 - stage: build + stage: full-build variables: BUILD_FLAVOUR: validate + # Ensure that stage2 also has DEBUG enabled + ValidateSpeed: SLOW + # Override validate flavour default; see #16890. + BUILD_SPHINX_PDF: "YES" + TEST_TYPE: slowtest TEST_ENV: "x86_64-linux-deb9-debug" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-debug.tar.xz" + artifacts: + when: always + expire_in: 2 week -validate-x86_64-linux-deb9-llvm: +# Disabled to alleviate CI load +.validate-x86_64-linux-deb9-llvm: + extends: .build-x86_64-linux-deb9 + stage: full-build + variables: + BUILD_FLAVOUR: perf-llvm + TEST_ENV: "x86_64-linux-deb9-llvm" + +nightly-x86_64-linux-deb9-llvm: + <<: *nightly extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: BUILD_FLAVOUR: perf-llvm TEST_ENV: "x86_64-linux-deb9-llvm" @@ -397,11 +601,11 @@ validate-x86_64-linux-deb9-llvm: validate-x86_64-linux-deb9-integer-simple: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: + BUILD_FLAVOUR: validate INTEGER_LIBRARY: integer-simple - TEST_ENV: "x86_64-linux-deb9-integer-simple" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz" + TEST_ENV: "x86_64-linux-deb9-integer-simple-validate" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-integer-simple.tar.xz" nightly-x86_64-linux-deb9-integer-simple: <<: *nightly @@ -411,185 +615,205 @@ nightly-x86_64-linux-deb9-integer-simple: INTEGER_LIBRARY: integer-simple TEST_ENV: "x86_64-linux-deb9-integer-simple" TEST_TYPE: slowtest - artifacts: - expire_in: 2 year -validate-x86_64-linux-deb9-unreg: +validate-x86_64-linux-deb9-dwarf: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: - CONFIGURE_ARGS: --enable-unregisterised - TEST_ENV: "x86_64-linux-deb9-unreg" + CONFIGURE_ARGS: "--enable-dwarf-unwind" + BUILD_FLAVOUR: dwarf + TEST_ENV: "x86_64-linux-deb9-dwarf" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-dwarf.tar.xz" + +################################# +# x86_64-linux-deb10 +################################# -release-x86_64-linux-deb9-dwarf: +.build-x86_64-linux-deb10: extends: .validate-linux - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" - allow_failure: true + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb9" - artifacts: - when: always - expire_in: 2 week + TEST_ENV: "x86_64-linux-deb10" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" cache: - key: linux-x86_64-deb9 + key: linux-x86_64-deb10 +# Disabled to alleviate CI load +.validate-x86_64-linux-deb10: + extends: .build-x86_64-linux-deb10 + stage: full-build -release-x86_64-linux-deb10-dwarf: - <<: *release +nightly-x86_64-linux-deb10: + <<: *nightly extends: .build-x86_64-linux-deb10 variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb10-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb10-linux-dwarf.tar.xz" + TEST_TYPE: slowtest + +release-x86_64-linux-deb10: + <<: *release + extends: .build-x86_64-linux-deb10 ################################# # x86_64-linux-deb8 ################################# -release-x86_64-linux-deb8: - <<: *release +.build-x86_64-linux-deb8: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + # Due to #18298. + allow_failure: true variables: TEST_ENV: "x86_64-linux-deb8" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz" - # Disable sphinx PDF output as our Debian image doesn't have the requisite packages + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb8-linux.tar.xz" + # Debian 8's Sphinx is too old to support the table directive's :widths: + # option: https://sourceforge.net/p/docutils/patches/120/ + BUILD_SPHINX_HTML: "NO" + BUILD_SPHINX_INFO: "NO" BUILD_SPHINX_PDF: "NO" + BUILD_SPHINX_MAN: "NO" cache: key: linux-x86_64-deb8 + +release-x86_64-linux-deb8: + <<: *release + extends: .build-x86_64-linux-deb8 + +################################# +# x86_64-linux-alpine +################################# + +.build-x86_64-linux-alpine-hadrian: + extends: .validate-linux-hadrian + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine:$DOCKER_REV" + # There are currently a few failing tests + allow_failure: true + variables: + TEST_ENV: "x86_64-linux-alpine" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-alpine-linux.tar.xz" + # Can't use ld.gold due to #13958. + CONFIGURE_ARGS: "--disable-ld-override" + HADRIAN_ARGS: "--docs=no-sphinx" + # encoding004 due to lack of locale support + # T10458 due to fact that dynamic linker tries to reload libAS + BROKEN_TESTS: "encoding004 T10458" + cache: + key: linux-x86_64-alpine artifacts: when: always expire_in: 2 week +release-x86_64-linux-alpine: + <<: *release + extends: .build-x86_64-linux-alpine-hadrian + +nightly-x86_64-linux-alpine: + <<: *nightly + extends: .build-x86_64-linux-alpine-hadrian + ################################# # x86_64-linux-centos7 ################################# -release-x86_64-linux-centos7: - <<: *release +.build-x86_64-linux-centos7: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" variables: - # For the testsuite - LANG: "en_US.UTF-8" # The sphinx release shipped with Centos 7 fails to build out documentation BUILD_SPHINX_HTML: "NO" BUILD_SPHINX_PDF: "NO" TEST_ENV: "x86_64-linux-centos7" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz" - allow_failure: true + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-centos7-linux.tar.xz" + # CentOS seems to default to ascii + LANG: "en_US.UTF-8" cache: key: linux-x86_64-centos7 - artifacts: - when: always - expire_in: 2 week + +release-x86_64-linux-centos7: + <<: *release + extends: .build-x86_64-linux-centos7 ################################# # x86_64-linux-fedora27 ################################# -.build-x86_64-linux-fedora27: +validate-x86_64-linux-fedora27: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-fedora27" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: key: linux-x86_64-fedora27 - -validate-x86_64-linux-fedora27: - extends: .build-x86_64-linux-fedora27 artifacts: when: always # These are used for head.hackage jobs therefore we keep them around for # longer. expire_in: 8 week -release-x86_64-linux-fedora27: - <<: *release - extends: .build-x86_64-linux-fedora27 - -release-x86_64-linux-fedora27-dwarf: - <<: *release - extends: .build-x86_64-linux-fedora27 - variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-fedora27-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux-dwarf.tar.xz" - ############################################################ # Validation via Pipelines (Windows) ############################################################ .build-windows: - <<: *only-default + # For the reasons given in #17777 this build isn't reliable. + allow_failure: true before_script: - git clean -xdf - - git submodule foreach git clean -xdf - # Use a local temporary directory to ensure that concurrent builds don't - # interfere with one another - - | - mkdir tmp - set TMP=%cd%\tmp - set TEMP=%cd%\tmp - - - set PATH=C:\msys64\usr\bin;%PATH% - - python .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - bash .gitlab/win32-init.sh + # Setup toolchain + - bash .gitlab/ci.sh setup after_script: - - rd /s /q tmp - - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache - - bash -c 'make clean || true' + - | + Copy-Item -Recurse -Path $Env:APPDATA\cabal -Destination cabal-cache + - bash .gitlab/ci.sh clean dependencies: [] variables: - FORCE_SYMLINKS: 1 + #FORCE_SYMLINKS: 1 LANG: "en_US.UTF-8" SPHINXBUILD: "/mingw64/bin/sphinx-build.exe" + CABAL_INSTALL_VERSION: 3.0.0.0 + GHC_VERSION: "8.8.3" cache: paths: - cabal-cache - - ghc-8.6.2 + - toolchain - ghc-tarballs .build-windows-hadrian: extends: .build-windows stage: full-build - allow_failure: true variables: - GHC_VERSION: "8.8.3" + FLAVOUR: "validate" + # skipping perf tests for now since we build a quick-flavoured GHC, + # which might result in some broken perf tests? + HADRIAN_ARGS: "--docs=no-sphinx --skip-perf" + script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex' - - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist" - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz - # FIXME: Testsuite disabled due to #16156. - # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_hadrian + - bash .gitlab/ci.sh test_hadrian tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: + reports: + junit: junit.xml + expire_in: 2 week when: always paths: - ghc.tar.xz + - junit.xml validate-x86_64-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW64 + TEST_ENV: "x86_64-windows-hadrian" cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" @@ -598,86 +822,94 @@ nightly-i386-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW32 + TEST_ENV: "i386-windows-hadrian" cache: key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" .build-windows-make: extends: .build-windows stage: full-build - # due to #16084 - allow_failure: true variables: - BUILD_FLAVOUR: "UNSET" - GHC_VERSION: "8.8.3" - BUILD_PROF_LIBS: "YES" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz" + BUILD_FLAVOUR: "quick" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-mingw32.tar.xz" script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS' - - bash -c "echo \"include mk/flavours/${BUILD_FLAVOUR}.mk\" > mk/build.mk" - - bash -c "echo \"GhcLibHcOpts+=-haddock\" >> mk/build.mk" - - bash -c "echo \"BUILD_PROF_LIBS = $BUILD_PROF_LIBS\" >> mk/build.mk" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1" - - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_make + - bash .gitlab/ci.sh test_make tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: when: always expire_in: 2 week reports: junit: junit.xml paths: - - ghc-*.tar.xz + # N.B. variable interpolation apparently doesn't work on Windows so + # this can't be $BIN_DIST_PREP_TAR_COMP + - "ghc-x86_64-mingw32.tar.xz" - junit.xml -validate-x86_64-windows: +.build-x86_64-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" - BUILD_FLAVOUR: "quick" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" + TEST_ENV: "x86_64-windows" cache: key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-x86_64-windows: + extends: .build-x86_64-windows-make + +nightly-x86_64-windows: + <<: *nightly + extends: .build-x86_64-windows-make + stage: full-build + variables: + BUILD_FLAVOUR: "validate" + # Normal Windows validate builds are profiled; that won't do for releases. release-x86_64-windows: <<: *release extends: validate-x86_64-windows variables: - MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" - -release-i386-windows: + # +release-x86_64-windows-integer-simple: <<: *release - extends: .build-windows-make + extends: validate-x86_64-windows variables: - MSYSTEM: MINGW32 + INTEGER_LIBRARY: integer-simple BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - # Due to #15934 - BUILD_PROF_LIBS: "NO" - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows: - <<: *nightly + +.build-i386-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW32 - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - BUILD_FLAVOUR: "quick" # Due to #15934 BUILD_PROF_LIBS: "NO" + TEST_ENV: "i386-windows" + # Due to #17736 + allow_failure: true cache: key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-i386-windows: + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +release-i386-windows: + <<: *release + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +nightly-i386-windows: + <<: *nightly + extends: .build-i386-windows-make + ############################################################ # Cleanup ############################################################ @@ -687,40 +919,24 @@ nightly-i386-windows: # # As noted in [1], gitlab-runner's shell executor doesn't clean up its working # directory after builds. Unfortunately, we are forced to use the shell executor -# on Windows. To avoid running out of disk space we add a stage at the end of -# the build to remove the \GitLabRunner\builds directory. Since we only run a -# single build at a time on Windows this should be safe. +# on Darwin. To avoid running out of disk space we add a stage at the end of +# the build to remove the /.../GitLabRunner/builds directory. Since we only run a +# single build at a time on Darwin this should be safe. +# +# We used to have a similar cleanup job on Windows as well however it ended up +# being quite fragile as we have multiple Windows builders yet there is no +# guarantee that the cleanup job is run on the same machine as the build itself +# was run. Consequently we were forced to instead handle cleanup with a separate +# cleanup cron job on Windows. # # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856 -# See Note [Cleanup after shell executor] -cleanup-windows: - <<: *only-default - stage: cleanup - tags: - - x86_64-windows - dependencies: [] - before_script: - - echo "Time to clean up" - script: - - echo "Let's go" - after_script: - - set "BUILD_DIR=%CI_PROJECT_DIR%" - - set "BUILD_DIR=%BUILD_DIR:/=\%" - - echo "Cleaning %BUILD_DIR%" - - cd \GitLabRunner - # This is way more complicated than it should be: - # See https://stackoverflow.com/questions/1965787 - - del %BUILD_DIR%\* /F /Q - - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p" - - exit /b 0 - # See Note [Cleanup after shell executor] cleanup-darwin: - <<: *only-default stage: cleanup tags: - x86_64-darwin + when: always dependencies: [] before_script: - echo "Time to clean up" @@ -737,19 +953,56 @@ cleanup-darwin: # Packaging ############################################################ +doc-tarball: + stage: packaging + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + dependencies: + - validate-x86_64-linux-deb9-debug + - validate-x86_64-windows + variables: + LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz" + WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz" + # Due to Windows allow_failure + allow_failure: true + artifacts: + paths: + - haddock.html.tar.xz + - libraries.html.tar.xz + - users_guide.html.tar.xz + - index.html + - "*.pdf" + script: + - | + if [ ! -f "$LINUX_BINDIST" ]; then + echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" + exit 1 + fi + if [ ! -f "$WINDOWS_BINDIST" ]; then + echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?" + exit 1 + fi + - rm -Rf docs + - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST + - ls -lh + - mv docs/*.tar.xz docs/index.html . + source-tarball: - <<: *release stage: packaging tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" dependencies: [] + rules: + - if: $CI_COMMIT_TAG + when: always artifacts: paths: - ghc-*.tar.xz - version script: - - mk/get-win32-tarballs.sh download all + - python3 mk/get-win32-tarballs.py download all - ./boot - ./configure - make sdist @@ -770,9 +1023,8 @@ source-tarball: # pipeline. .hackage: - <<: *only-default - stage: hackage - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + stage: testing + image: ghcci/x86_64-linux-deb9:0.2 tags: - x86_64-linux dependencies: [] @@ -781,6 +1033,10 @@ source-tarball: script: - bash .gitlab/start-head.hackage.sh +hackage: + extends: .hackage + when: manual + hackage-label: extends: .hackage rules: @@ -790,3 +1046,69 @@ nightly-hackage: <<: *nightly extends: .hackage +############################################################ +# Nofib testing +############################################################ + +perf-nofib: + stage: testing + dependencies: + - validate-x86_64-linux-deb9-dwarf + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + rules: + - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + tags: + - x86_64-linux + script: + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ghc-x86_64-deb9-linux-dwarf.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - cabal update; cabal install -w $BOOT_HC regex-compat + - export PATH=$root/bin:$PATH + - make -C nofib boot mode=fast -j$CPUS + - "make -C nofib EXTRA_RUNTEST_OPTS='-cachegrind +RTS -V0 -RTS' NoFibRuns=1 mode=fast -j$CPUS 2>&1 | tee nofib.log" + artifacts: + expire_in: 12 week + when: always + paths: + - nofib.log + +############################################################ +# Documentation deployment via GitLab Pages +############################################################ + +pages: + stage: deploy + dependencies: + - doc-tarball + image: ghcci/x86_64-linux-deb9:0.2 + # Due to Windows allow_failure + allow_failure: true + tags: + - x86_64-linux + script: + - mkdir -p public/doc + - tar -xf haddock.html.tar.xz -C public/doc + - tar -xf libraries.html.tar.xz -C public/doc + - tar -xf users_guide.html.tar.xz -C public/doc + - | + cat >public/index.html < + + + EOF + - cp -f index.html public/doc + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + artifacts: + paths: + - public ===================================== .gitlab/ci.sh ===================================== @@ -0,0 +1,464 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2230 + +# This is the primary driver of the GitLab CI infrastructure. + +set -e -o pipefail + +# Configuration: +hackage_index_state="@1579718451" + +# Colors +BLACK="0;30" +GRAY="1;30" +RED="0;31" +LT_RED="1;31" +BROWN="0;33" +LT_BROWN="1;33" +GREEN="0;32" +LT_GREEN="1;32" +BLUE="0;34" +LT_BLUE="1;34" +PURPLE="0;35" +LT_PURPLE="1;35" +CYAN="0;36" +LT_CYAN="1;36" +WHITE="1;37" +LT_GRAY="0;37" + +export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 + +# GitLab Pipelines log section delimiters +# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664 +start_section() { + name="$1" + echo -e "section_start:$(date +%s):$name\015\033[0K" +} + +end_section() { + name="$1" + echo -e "section_end:$(date +%s):$name\015\033[0K" +} + +echo_color() { + local color="$1" + local msg="$2" + echo -e "\033[${color}m${msg}\033[0m" +} + +error() { echo_color "${RED}" "$1"; } +warn() { echo_color "${LT_BROWN}" "$1"; } +info() { echo_color "${LT_BLUE}" "$1"; } + +fail() { error "error: $1"; exit 1; } + +function run() { + info "Running $*..." + "$@" || ( error "$* failed"; return 1; ) +} + +TOP="$(pwd)" + +function mingw_init() { + case "$MSYSTEM" in + MINGW32) + triple="i386-unknown-mingw32" + boot_triple="i386-unknown-mingw32" # triple of bootstrap GHC + ;; + MINGW64) + triple="x86_64-unknown-mingw32" + boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC + ;; + *) + fail "win32-init: Unknown MSYSTEM $MSYSTEM" + ;; + esac + + # Bring mingw toolchain into PATH. + # This is extracted from /etc/profile since this script inexplicably fails to + # run under gitlab-runner. + # shellcheck disable=SC1091 + source /etc/msystem + MINGW_MOUNT_POINT="${MINGW_PREFIX}" + PATH="$MINGW_MOUNT_POINT/bin:$PATH" + + # We always use mingw64 Python to avoid path length issues like #17483. + export PYTHON="/mingw64/bin/python3" +} + +# This will contain GHC's local native toolchain +toolchain="$TOP/toolchain" +mkdir -p "$toolchain/bin" +PATH="$toolchain/bin:$PATH" + +export METRICS_FILE="$CI_PROJECT_DIR/performance-metrics.tsv" + +cores="$(mk/detect-cpu-count.sh)" + +# Use a local temporary directory to ensure that concurrent builds don't +# interfere with one another +mkdir -p "$TOP/tmp" +export TMP="$TOP/tmp" +export TEMP="$TOP/tmp" + +function darwin_setup() { + # It looks like we already have python2 here and just installing python3 + # does not work. + brew upgrade python + brew install ghc cabal-install ncurses gmp + + pip3 install sphinx + # PDF documentation disabled as MacTeX apparently doesn't include xelatex. + #brew cask install mactex +} + +function show_tool() { + local tool="$1" + info "$tool = ${!tool}" + ${!tool} --version +} + +function set_toolchain_paths() { + needs_toolchain=1 + case "$(uname)" in + Linux) needs_toolchain="" ;; + *) ;; + esac + + if [[ -n "$needs_toolchain" ]]; then + # These are populated by setup_toolchain + GHC="$toolchain/bin/ghc$exe" + CABAL="$toolchain/bin/cabal$exe" + HAPPY="$toolchain/bin/happy$exe" + ALEX="$toolchain/bin/alex$exe" + else + GHC="$(which ghc)" + CABAL="/usr/local/bin/cabal" + HAPPY="$HOME/.cabal/bin/happy" + ALEX="$HOME/.cabal/bin/alex" + fi + export GHC + export CABAL + export HAPPY + export ALEX +} + +# Extract GHC toolchain +function setup() { + if [ -d "$TOP/cabal-cache" ]; then + info "Extracting cabal cache..." + mkdir -p "$cabal_dir" + cp -Rf cabal-cache/* "$cabal_dir" + fi + + if [[ -n "$needs_toolchain" ]]; then + setup_toolchain + fi + case "$(uname)" in + Darwin) darwin_setup ;; + *) ;; + esac + + # Make sure that git works + git config user.email "ghc-ci at gitlab-haskell.org" + git config user.name "GHC GitLab CI" + + info "=====================================================" + info "Toolchain versions" + info "=====================================================" + show_tool GHC + show_tool CABAL + show_tool HAPPY + show_tool ALEX +} + +function fetch_ghc() { + local v="$GHC_VERSION" + if [[ -z "$v" ]]; then + fail "GHC_VERSION is not set" + fi + + if [ ! -e "$GHC" ]; then + start_section "fetch GHC" + url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple}.tar.xz" + info "Fetching GHC binary distribution from $url..." + curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution" + tar -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution" + case "$(uname)" in + MSYS_*|MINGW*) + cp -r "ghc-${GHC_VERSION}"/* "$toolchain" + ;; + *) + pushd "ghc-${GHC_VERSION}" + ./configure --prefix="$toolchain" + "$MAKE" install + popd + ;; + esac + rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz + end_section "fetch GHC" + fi + +} + +function fetch_cabal() { + local v="$CABAL_INSTALL_VERSION" + if [[ -z "$v" ]]; then + fail "CABAL_INSTALL_VERSION is not set" + fi + + if [ ! -e "$CABAL" ]; then + start_section "fetch GHC" + case "$(uname)" in + # N.B. Windows uses zip whereas all others use .tar.xz + MSYS_*|MINGW*) + case "$MSYSTEM" in + MINGW32) cabal_arch="i386" ;; + MINGW64) cabal_arch="x86_64" ;; + *) fail "unknown MSYSTEM $MSYSTEM" ;; + esac + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-unknown-mingw32.zip" + info "Fetching cabal binary distribution from $url..." + curl "$url" > "$TMP/cabal.zip" + unzip "$TMP/cabal.zip" + mv cabal.exe "$CABAL" + ;; + *) + local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/" + case "$(uname)" in + Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;; + FreeBSD) + #cabal_url="$base_url/cabal-install-$v-x86_64-portbld-freebsd.tar.xz" ;; + cabal_url="http://home.smart-cactus.org/~ben/ghc/cabal-install-3.0.0.0-x86_64-portbld-freebsd.tar.xz" ;; + *) fail "don't know where to fetch cabal-install for $(uname)" + esac + echo "Fetching cabal-install from $cabal_url" + curl "$cabal_url" > cabal.tar.xz + tar -xJf cabal.tar.xz + mv cabal "$toolchain/bin" + ;; + esac + end_section "fetch GHC" + fi +} + +# For non-Docker platforms we prepare the bootstrap toolchain +# here. For Docker platforms this is done in the Docker image +# build. +function setup_toolchain() { + fetch_ghc + fetch_cabal + cabal_install="$CABAL v2-install --index-state=$hackage_index_state --installdir=$toolchain/bin" + # Avoid symlinks on Windows + case "$(uname)" in + MSYS_*|MINGW*) cabal_install="$cabal_install --install-method=copy" ;; + *) ;; + esac + + if [ ! -e "$HAPPY" ]; then + info "Building happy..." + cabal update + $cabal_install happy + fi + + if [ ! -e "$ALEX" ]; then + info "Building alex..." + cabal update + $cabal_install alex + fi +} + +function cleanup_submodules() { + start_section "clean submodules" + info "Cleaning submodules..." + # On Windows submodules can inexplicably get into funky states where git + # believes that the submodule is initialized yet its associated repository + # is not valid. Avoid failing in this case with the following insanity. + git submodule sync --recursive || git submodule deinit --force --all + git submodule update --init --recursive + git submodule foreach git clean -xdf + end_section "clean submodules" +} + +function prepare_build_mk() { + if [[ -z "$BUILD_FLAVOUR" ]]; then fail "BUILD_FLAVOUR is not set"; fi + if [[ -z ${BUILD_SPHINX_HTML:-} ]]; then BUILD_SPHINX_HTML=YES; fi + if [[ -z ${BUILD_SPHINX_PDF:-} ]]; then BUILD_SPHINX_PDF=YES; fi + if [[ -z ${INTEGER_LIBRARY:-} ]]; then INTEGER_LIBRARY=integer-gmp; fi + + cat > mk/build.mk <> mk/build.mk + fi + + case "$(uname)" in + Darwin) echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk ;; + *) ;; + esac + + info "build.mk is:" + cat mk/build.mk +} + +function configure() { + start_section "booting" + run python3 boot + end_section "booting" + + local target_args="" + if [[ -n "$triple" ]]; then + target_args="--target=$triple" + fi + + start_section "configuring" + run ./configure \ + --enable-tarballs-autodownload \ + $target_args \ + $CONFIGURE_ARGS \ + GHC="$GHC" \ + HAPPY="$HAPPY" \ + ALEX="$ALEX" \ + || ( cat config.log; fail "configure failed" ) + end_section "configuring" +} + +function build_make() { + prepare_build_mk + if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then + fail "BIN_DIST_PREP_TAR_COMP is not set" + fi + + echo "include mk/flavours/${BUILD_FLAVOUR}.mk" > mk/build.mk + echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk + run "$MAKE" -j"$cores" $MAKE_ARGS + run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 + ls -lh "$BIN_DIST_PREP_TAR_COMP" +} + +function fetch_perf_notes() { + info "Fetching perf notes..." + "$TOP/.gitlab/test-metrics.sh" pull +} + +function push_perf_notes() { + info "Pushing perf notes..." + "$TOP/.gitlab/test-metrics.sh" push +} + +function test_make() { + run "$MAKE" test_bindist TEST_PREP=YES + run "$MAKE" V=0 test \ + THREADS="$cores" \ + JUNIT_FILE=../../junit.xml +} + +function build_hadrian() { + if [ -z "$FLAVOUR" ]; then + fail "FLAVOUR not set" + fi + + run_hadrian binary-dist + + mv _build/bindist/ghc*.tar.xz ghc.tar.xz +} + +function test_hadrian() { + cd _build/bindist/ghc-*/ + run ./configure --prefix="$TOP"/_build/install + run "$MAKE" install + cd ../../../ + + run_hadrian \ + test \ + --summary-junit=./junit.xml \ + --test-compiler="$TOP"/_build/install/bin/ghc +} + +function clean() { + rm -R tmp + run "$MAKE" --quiet clean || true + run rm -Rf _build +} + +function run_hadrian() { + run hadrian/build-cabal \ + --flavour="$FLAVOUR" \ + -j"$cores" \ + --broken-test="$BROKEN_TESTS" \ + $HADRIAN_ARGS \ + $@ +} + +# A convenience function to allow debugging in the CI environment. +function shell() { + local cmd=$@ + if [ -z "$cmd" ]; then + cmd="bash -i" + fi + run $cmd +} + +# Determine Cabal data directory +case "$(uname)" in + MSYS_*|MINGW*) exe=".exe"; cabal_dir="$APPDATA/cabal" ;; + *) cabal_dir="$HOME/.cabal"; exe="" ;; +esac + +# Platform-specific environment initialization +MAKE="make" +case "$(uname)" in + MSYS_*|MINGW*) mingw_init ;; + Darwin) boot_triple="x86_64-apple-darwin" ;; + FreeBSD) + boot_triple="x86_64-portbld-freebsd" + MAKE="gmake" + ;; + Linux) ;; + *) fail "uname $(uname) is not supported" ;; +esac + +set_toolchain_paths + +case $1 in + setup) setup && cleanup_submodules ;; + configure) configure ;; + build_make) build_make ;; + test_make) + fetch_perf_notes + res=0 + test_make || res=$? + push_perf_notes + exit $res ;; + build_hadrian) build_hadrian ;; + # N.B. Always push notes, even if the build fails. This is okay to do as the + # testsuite driver doesn't record notes for tests that fail due to + # correctness. + test_hadrian) + fetch_perf_notes + res=0 + test_hadrian || res=$? + push_perf_notes + exit $res ;; + run_hadrian) run_hadrian $@ ;; + clean) clean ;; + shell) shell $@ ;; + *) fail "unknown mode $1" ;; +esac ===================================== .gitlab/darwin-init.sh deleted ===================================== @@ -1,41 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $HOME/.cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - mkdir -p tmp - cd tmp - ghc_tarball="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-x86_64-apple-darwin.tar.xz" - echo "Fetching GHC from $ghc_tarball" - curl $ghc_tarball | tar -xJ - cd ghc-$GHC_VERSION - ./configure --prefix=$toolchain - make install - cd ../.. - rm -Rf tmp -fi - -if [ ! -e $toolchain/bin/cabal ]; then - cabal_tarball="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL_VERSION/cabal-install-$CABAL_INSTALL_VERSION-x86_64-apple-darwin-sierra.tar.xz" - echo "Fetching cabal-install from $cabal_tarball" - curl $cabal_tarball | tar -xz - mv cabal $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal new-install happy --symlink-bindir=$toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal new-install alex --symlink-bindir=$toolchain/bin -fi - ===================================== .gitlab/linters/check-version-number.sh ===================================== @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +grep -E -q '\[[0-9]+\.[0-9]+\.[0-9]+\]' configure.ac || + ( echo "error: configure.ac: GHC version number must have three components."; exit 1 ) ===================================== .gitlab/win32-init.sh deleted ===================================== @@ -1,50 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:/mingw64/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $APPDATA/cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - case $MSYSTEM in - MINGW32) - triple="i386-unknown-mingw32" - ;; - MINGW64) - triple="x86_64-unknown-mingw32" - ;; - *) - echo "win32-init: Unknown MSYSTEM $MSYSTEM" - exit 1 - ;; - esac - if [ -z "$GHC_TARBALL_URL" ]; then - GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" - fi - curl "$GHC_TARBALL_URL" | tar -xJ - mv ghc-$GHC_VERSION toolchain -fi - -if [ ! -e $toolchain/bin/cabal ]; then - url="https://downloads.haskell.org/~cabal/cabal-install-2.4.1.0/cabal-install-2.4.1.0-x86_64-unknown-mingw32.zip" - curl $url > /tmp/cabal.zip - unzip /tmp/cabal.zip - mv cabal.exe $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal install happy - cp $APPDATA/cabal/bin/happy $toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal install alex - cp $APPDATA/cabal/bin/alex $toolchain/bin -fi - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ca1a2dd1213a94a9219753e95ae0f816b2ca9b5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ca1a2dd1213a94a9219753e95ae0f816b2ca9b5 You're receiving 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 Jul 11 16:52:49 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 12:52:49 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] Backport CI infrastructure rework Message-ID: <5f09ee61c8ccb_80b3f849ba1b9402659342@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: bca1b960 by Ben Gamari at 2020-07-11T12:52:37-04:00 Backport CI infrastructure rework - - - - - 7 changed files: - .gitlab-ci.yml - + .gitlab/ci.sh - − .gitlab/darwin-init.sh - .gitlab/linters/check-makefiles.py - + .gitlab/linters/check-version-number.sh - .gitlab/linters/linter.py - − .gitlab/win32-init.sh Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,59 +2,45 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a + DOCKER_REV: 6223fe0b5942f4fa35bdec92c74566cf195bfb42 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/win32-init.sh. + # .gitlab/ci.sh. WINDOWS_TOOLCHAIN_VERSION: 1 -before_script: - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + # Disable shallow clones; they break our linting rules + GIT_DEPTH: 0 + + # Overridden by individual jobs + CONFIGURE_ARGS: "" + + GIT_SUBMODULE_STRATEGY: "recursive" stages: - - lint # Source linting - - build # A quick smoke-test to weed out broken commits - - full-build # Build all the things - - cleanup # See Note [Cleanup on Windows] - - packaging # Source distribution, etc. - - hackage # head.hackage testing - - deploy # push documentation - -.only-default: &only-default - rules: - - if: $CI_MERGE_REQUEST_ID - - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "master"' - - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - - if: '$CI_PIPELINE_SOURCE == "web"' + - lint # Source linting + - quick-build # A very quick smoke-test to weed out broken commits + - build # A quick smoke-test to weed out broken commits + - full-build # Build all the things + - cleanup # See Note [Cleanup after the shell executor] + - packaging # Source distribution, etc. + - testing # head.hackage correctness and compiler performance testing + - deploy # push documentation workflow: - # N.B. Don't run on wip/ branches, instead on run on merge requests. + # N.B.Don't run on wip/ branches, instead on run on merge requests. rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' -############################################################ -# Runner Tags -############################################################ -# -# * x86_64-linux: Any Docker-capable x86_64 Linux machine -# * aarch64-linux: Any Docker-capable AArch64 Linux machine -# * x86_64-windows: A x86_64 Windows machine -# * lint: Any Docker-capable x86_64 Linux machine; distinct from -# x86_64-linux to ensure low-latency availability. -# - .nightly: &nightly rules: - if: $NIGHTLY + artifacts: + when: always + expire_in: 8 weeks .release: &release variables: @@ -66,53 +52,105 @@ workflow: rules: - if: '$RELEASE == "yes"' +############################################################ +# Runner Tags +############################################################ +# +# * x86_64-linux: Any Docker-capable x86_64 Linux machine +# * aarch64-linux: Any Docker-capable AArch64 Linux machine +# * x86_64-windows: A x86_64 Windows machine +# * lint: Any Docker-capable x86_64 Linux machine; distinct from +# x86_64-linux to ensure low-latency availability. +# + ############################################################ # Linting ############################################################ ghc-linters: - allow_failure: true stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" - - "echo Merge base $base" + - "echo Linting changes between $base..$CI_COMMIT_SHA" # - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA) - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA) - - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA - - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA + - .gitlab/linters/check-makefiles.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-cpp.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-version-number.sh + - python3 utils/checkUniques/check-uniques.py . dependencies: [] tags: - lint rules: - if: $CI_MERGE_REQUEST_ID +# Run mypy Python typechecker on linter scripts. +lint-linters: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy .gitlab/linters/*.py + dependencies: [] + tags: + - lint + +# Check that .T files all parse by listing broken tests. +lint-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + script: + - make -Ctestsuite list_broken TEST_HC=ghc + dependencies: [] + tags: + - lint + +# Run mypy Python typechecker on testsuite driver +typecheck-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy testsuite/driver/runtests.py + dependencies: [] + tags: + - lint + # We allow the submodule checker to fail when run on merge requests (to -# accomodate, e.g., haddock changes not yet upstream) but not on `master` or +# accommodate, e.g., haddock changes not yet upstream) but not on `master` or # Marge jobs. .lint-submods: stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA) + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" + - "echo Linting submodule changes between $base..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $base..$CI_COMMIT_SHA) dependencies: [] tags: - lint lint-submods: extends: .lint-submods + # Allow failure on merge requests since any necessary submodule patches may + # not be upstreamed yet. rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/' allow_failure: false - allow_failure: true -lint-submods-mr: +lint-submods-branch: extends: .lint-submods - allow_failure: true + script: + - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA) rules: - - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' .lint-changelogs: stage: lint @@ -125,6 +163,7 @@ lint-submods-mr: lint-changelogs: extends: .lint-changelogs + # Allow failure since this isn't a final release. allow_failure: true rules: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' @@ -140,71 +179,183 @@ lint-release-changelogs: ############################################################ .validate-hadrian: - <<: *only-default - allow_failure: true + variables: + FLAVOUR: "validate" script: - - cabal update - - git clean -xdf && git submodule foreach git clean -xdf - - bash .circleci/prepare-system.sh - - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi - - ./boot - - ./configure $CONFIGURE_ARGS - - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian cache: key: hadrian paths: - cabal-cache artifacts: - when: always + reports: + junit: junit.xml + expire_in: 2 week paths: - ghc.tar.xz + - junit.xml -validate-x86_64-linux-deb8-hadrian: +.validate-linux-hadrian: extends: .validate-hadrian - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + variables: + TEST_ENV: "x86_64-linux-deb9-hadrian" before_script: # workaround for docker permissions - sudo chown ghc:ghc -R . - - python3 .gitlab/fix-submodules.py - git submodule sync --recursive - git submodule update --init --recursive - git checkout .gitmodules - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + after_script: + - .gitlab/ci.sh clean tags: - x86_64-linux +validate-x86_64-linux-deb9-hadrian: + extends: .validate-linux-hadrian + stage: build + +validate-x86_64-linux-deb9-unreg-hadrian: + extends: .validate-linux-hadrian + stage: full-build + variables: + CONFIGURE_ARGS: --enable-unregisterised + TEST_ENV: "x86_64-linux-deb9-unreg-hadrian" + +hadrian-ghc-in-ghci: + stage: quick-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + variables: + GHC_FLAGS: -Werror + tags: + - x86_64-linux + script: + - cabal update + - cd hadrian; cabal new-build --project-file=ci.project; cd .. + - git clean -xdf && git submodule foreach git clean -xdf + - .gitlab/ci.sh setup + - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi + - ./boot + - ./configure $CONFIGURE_ARGS + # 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," + cache: + key: hadrian-ghci + paths: + - cabal-cache ############################################################ # Validation via Pipelines (make) ############################################################ .validate: - <<: *only-default variables: TEST_TYPE: test - before_script: - - git clean -xdf && git submodule foreach git clean -xdf + MAKE_ARGS: "-Werror" script: - - ./boot - - ./configure $CONFIGURE_ARGS - - | - THREADS=`mk/detect-cpu-count.sh` - make V=0 -j$THREADS WERROR=-Werror - - | - make binary-dist TAR_COMP_OPTS="-1" - - | - THREADS=`mk/detect-cpu-count.sh` - make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_make + - .gitlab/ci.sh test_make dependencies: [] artifacts: reports: junit: junit.xml expire_in: 2 week paths: - - ghc-*.tar.xz + - $BIN_DIST_PREP_TAR_COMP - junit.xml + - performance-metrics.tsv + +################################# +# x86_64-freebsd +################################# + +.build-x86_64-freebsd: + extends: .validate + tags: + - x86_64-freebsd + allow_failure: true + variables: + # N.B. we use iconv from ports as I see linker errors when we attempt + # to use the "native" iconv embedded in libc as suggested by the + # porting guide [1]. + # [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + GHC_VERSION: 8.10.1 + CABAL_INSTALL_VERSION: 3.2.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd" + BUILD_FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Conditional due to lack of builder capacity +validate-x86_64-freebsd: + extends: .build-x86_64-freebsd + stage: full-build + rules: + - if: '$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/' + +nightly-x86_64-freebsd: + <<: *nightly + extends: .build-x86_64-freebsd + stage: full-build + +release-x86_64-freebsd: + <<: *release + extends: .build-x86_64-freebsd + stage: full-build + +.build-x86_64-freebsd-hadrian: + extends: .validate-hadrian + stage: full-build + tags: + - x86_64-freebsd + allow_failure: true + variables: + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + HADRIAN_ARGS: "--docs=no-sphinx" + GHC_VERSION: 8.6.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd-hadrian" + FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Disabled due to lack of builder capacity +.validate-x86_64-freebsd-hadrian: + extends: .build-x86_64-freebsd-hadrian + stage: full-build ################################# # x86_64-darwin @@ -216,54 +367,71 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: "8.8.3" - CABAL_INSTALL_VERSION: 2.4.1.0 - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz" + GHC_VERSION: 8.8.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-apple-darwin.tar.xz" MACOSX_DEPLOYMENT_TARGET: "10.7" # Only Sierra and onwards supports clock_gettime. See #12858 ac_cv_func_clock_gettime: "no" LANG: "en_US.UTF-8" - CONFIGURE_ARGS: --with-intree-gmp + CONFIGURE_ARGS: "--with-intree-gmp" TEST_ENV: "x86_64-darwin" - before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - - bash .gitlab/darwin-init.sh - - PATH="`pwd`/toolchain/bin:$PATH" + BUILD_FLAVOUR: "perf" after_script: - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean artifacts: when: always expire_in: 2 week cache: - key: darwin + key: "darwin-$GHC_VERSION" paths: - cabal-cache - toolchain +# Disabled because of OS X CI capacity +.validate-x86_64-darwin-hadrian: + stage: full-build + tags: + - x86_64-darwin + variables: + GHC_VERSION: 8.8.3 + MACOSX_DEPLOYMENT_TARGET: "10.7" + ac_cv_func_clock_gettime: "no" + LANG: "en_US.UTF-8" + CONFIGURE_ARGS: --with-intree-gmp + TEST_ENV: "x86_64-darwin-hadrian" + FLAVOUR: "validate" + script: + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + reports: + junit: junit.xml + paths: + - ghc.tar.xz + - junit.xml + .validate-linux: extends: .validate tags: - x86_64-linux + variables: + BUILD_FLAVOUR: "perf" before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" # Build hyperlinked sources for documentation when building releases - | if [[ -n "$CI_COMMIT_TAG" ]]; then - echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk + HADDOCK_HYPERLINKED_SOURCES=1 fi - - bash .circleci/prepare-system.sh # workaround for docker permissions - sudo chown ghc:ghc -R . after_script: @@ -285,9 +453,7 @@ validate-x86_64-darwin: allow_failure: true variables: TEST_ENV: "aarch64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz" - # Inexplicably makeindex fails - BUILD_SPHINX_PDF: "NO" + BIN_DIST_PREP_TAR_COMP: "ghc-aarch64-linux-deb9.tar.xz" cache: key: linux-aarch64-deb9 tags: @@ -302,8 +468,41 @@ validate-aarch64-linux-deb9: nightly-aarch64-linux-deb9: <<: *nightly extends: .build-aarch64-linux-deb9 + variables: + TEST_TYPE: slowtest + +################################# +# armv7-linux-deb9 +################################# + +.build-armv7-linux-deb9: + extends: .validate-linux + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb9:$DOCKER_REV" + # Due to linker issues + allow_failure: true + variables: + TEST_ENV: "armv7-linux-deb9" + BIN_DIST_PREP_TAR_COMP: "ghc-armv7-linux-deb9.tar.xz" + CONFIGURE_ARGS: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" + # N.B. We disable ld.lld explicitly here because it appears to fail + # non-deterministically on ARMv7. See #18280. + LD: "ld.gold" + GccUseLdOpt: "-fuse-ld=gold" + cache: + key: linux-armv7-deb9 + tags: + - armv7-linux + +validate-armv7-linux-deb9: + extends: .build-armv7-linux-deb9 artifacts: - expire_in: 2 year + when: always + expire_in: 2 week + +nightly-armv7-linux-deb9: + <<: *nightly + extends: .build-armv7-linux-deb9 variables: TEST_TYPE: slowtest @@ -317,7 +516,7 @@ nightly-aarch64-linux-deb9: image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "i386-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-i386-deb9-linux.tar.xz" cache: key: linux-i386-deb9 @@ -332,23 +531,6 @@ nightly-i386-linux-deb9: extends: .build-i386-linux-deb9 variables: TEST_TYPE: slowtest - artifacts: - when: always - expire_in: 2 week - -################################# -# x86_64-linux-deb10 -################################# - -.build-x86_64-linux-deb10: - extends: .validate-linux - stage: full-build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - variables: - TEST_ENV: "x86_64-linux-deb10" - BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" - cache: - key: linux-x86_64-deb10 ################################# # x86_64-linux-deb9 @@ -356,40 +538,62 @@ nightly-i386-linux-deb9: .build-x86_64-linux-deb9: extends: .validate-linux - stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb9-linux.tar.xz" cache: key: linux-x86_64-deb9 -validate-x86_64-linux-deb9: +# Disabled to reduce CI load +.validate-x86_64-linux-deb9: extends: .build-x86_64-linux-deb9 + stage: full-build artifacts: when: always expire_in: 2 week +release-x86_64-linux-deb9: + <<: *release + extends: .build-x86_64-linux-deb9 + stage: full-build + nightly-x86_64-linux-deb9: <<: *nightly extends: .build-x86_64-linux-deb9 - artifacts: - expire_in: 2 year + stage: full-build variables: TEST_TYPE: slowtest # N.B. Has DEBUG assertions enabled in stage2 validate-x86_64-linux-deb9-debug: extends: .build-x86_64-linux-deb9 - stage: build + stage: full-build variables: BUILD_FLAVOUR: validate + # Ensure that stage2 also has DEBUG enabled + ValidateSpeed: SLOW + # Override validate flavour default; see #16890. + BUILD_SPHINX_PDF: "YES" + TEST_TYPE: slowtest TEST_ENV: "x86_64-linux-deb9-debug" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-debug.tar.xz" + artifacts: + when: always + expire_in: 2 week -validate-x86_64-linux-deb9-llvm: +# Disabled to alleviate CI load +.validate-x86_64-linux-deb9-llvm: + extends: .build-x86_64-linux-deb9 + stage: full-build + variables: + BUILD_FLAVOUR: perf-llvm + TEST_ENV: "x86_64-linux-deb9-llvm" + +nightly-x86_64-linux-deb9-llvm: + <<: *nightly extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: BUILD_FLAVOUR: perf-llvm TEST_ENV: "x86_64-linux-deb9-llvm" @@ -397,11 +601,11 @@ validate-x86_64-linux-deb9-llvm: validate-x86_64-linux-deb9-integer-simple: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: + BUILD_FLAVOUR: validate INTEGER_LIBRARY: integer-simple - TEST_ENV: "x86_64-linux-deb9-integer-simple" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz" + TEST_ENV: "x86_64-linux-deb9-integer-simple-validate" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-integer-simple.tar.xz" nightly-x86_64-linux-deb9-integer-simple: <<: *nightly @@ -411,185 +615,205 @@ nightly-x86_64-linux-deb9-integer-simple: INTEGER_LIBRARY: integer-simple TEST_ENV: "x86_64-linux-deb9-integer-simple" TEST_TYPE: slowtest - artifacts: - expire_in: 2 year -validate-x86_64-linux-deb9-unreg: +validate-x86_64-linux-deb9-dwarf: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: - CONFIGURE_ARGS: --enable-unregisterised - TEST_ENV: "x86_64-linux-deb9-unreg" + CONFIGURE_ARGS: "--enable-dwarf-unwind" + BUILD_FLAVOUR: dwarf + TEST_ENV: "x86_64-linux-deb9-dwarf" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-dwarf.tar.xz" + +################################# +# x86_64-linux-deb10 +################################# -release-x86_64-linux-deb9-dwarf: +.build-x86_64-linux-deb10: extends: .validate-linux - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" - allow_failure: true + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb9" - artifacts: - when: always - expire_in: 2 week + TEST_ENV: "x86_64-linux-deb10" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" cache: - key: linux-x86_64-deb9 + key: linux-x86_64-deb10 +# Disabled to alleviate CI load +.validate-x86_64-linux-deb10: + extends: .build-x86_64-linux-deb10 + stage: full-build -release-x86_64-linux-deb10-dwarf: - <<: *release +nightly-x86_64-linux-deb10: + <<: *nightly extends: .build-x86_64-linux-deb10 variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb10-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb10-linux-dwarf.tar.xz" + TEST_TYPE: slowtest + +release-x86_64-linux-deb10: + <<: *release + extends: .build-x86_64-linux-deb10 ################################# # x86_64-linux-deb8 ################################# -release-x86_64-linux-deb8: - <<: *release +.build-x86_64-linux-deb8: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + # Due to #18298. + allow_failure: true variables: TEST_ENV: "x86_64-linux-deb8" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz" - # Disable sphinx PDF output as our Debian image doesn't have the requisite packages + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb8-linux.tar.xz" + # Debian 8's Sphinx is too old to support the table directive's :widths: + # option: https://sourceforge.net/p/docutils/patches/120/ + BUILD_SPHINX_HTML: "NO" + BUILD_SPHINX_INFO: "NO" BUILD_SPHINX_PDF: "NO" + BUILD_SPHINX_MAN: "NO" cache: key: linux-x86_64-deb8 + +release-x86_64-linux-deb8: + <<: *release + extends: .build-x86_64-linux-deb8 + +################################# +# x86_64-linux-alpine +################################# + +.build-x86_64-linux-alpine-hadrian: + extends: .validate-linux-hadrian + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine:$DOCKER_REV" + # There are currently a few failing tests + allow_failure: true + variables: + TEST_ENV: "x86_64-linux-alpine" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-alpine-linux.tar.xz" + # Can't use ld.gold due to #13958. + CONFIGURE_ARGS: "--disable-ld-override" + HADRIAN_ARGS: "--docs=no-sphinx" + # encoding004 due to lack of locale support + # T10458 due to fact that dynamic linker tries to reload libAS + BROKEN_TESTS: "encoding004 T10458" + cache: + key: linux-x86_64-alpine artifacts: when: always expire_in: 2 week +release-x86_64-linux-alpine: + <<: *release + extends: .build-x86_64-linux-alpine-hadrian + +nightly-x86_64-linux-alpine: + <<: *nightly + extends: .build-x86_64-linux-alpine-hadrian + ################################# # x86_64-linux-centos7 ################################# -release-x86_64-linux-centos7: - <<: *release +.build-x86_64-linux-centos7: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" variables: - # For the testsuite - LANG: "en_US.UTF-8" # The sphinx release shipped with Centos 7 fails to build out documentation BUILD_SPHINX_HTML: "NO" BUILD_SPHINX_PDF: "NO" TEST_ENV: "x86_64-linux-centos7" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz" - allow_failure: true + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-centos7-linux.tar.xz" + # CentOS seems to default to ascii + LANG: "en_US.UTF-8" cache: key: linux-x86_64-centos7 - artifacts: - when: always - expire_in: 2 week + +release-x86_64-linux-centos7: + <<: *release + extends: .build-x86_64-linux-centos7 ################################# # x86_64-linux-fedora27 ################################# -.build-x86_64-linux-fedora27: +validate-x86_64-linux-fedora27: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-fedora27" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: key: linux-x86_64-fedora27 - -validate-x86_64-linux-fedora27: - extends: .build-x86_64-linux-fedora27 artifacts: when: always # These are used for head.hackage jobs therefore we keep them around for # longer. expire_in: 8 week -release-x86_64-linux-fedora27: - <<: *release - extends: .build-x86_64-linux-fedora27 - -release-x86_64-linux-fedora27-dwarf: - <<: *release - extends: .build-x86_64-linux-fedora27 - variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-fedora27-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux-dwarf.tar.xz" - ############################################################ # Validation via Pipelines (Windows) ############################################################ .build-windows: - <<: *only-default + # For the reasons given in #17777 this build isn't reliable. + allow_failure: true before_script: - git clean -xdf - - git submodule foreach git clean -xdf - # Use a local temporary directory to ensure that concurrent builds don't - # interfere with one another - - | - mkdir tmp - set TMP=%cd%\tmp - set TEMP=%cd%\tmp - - - set PATH=C:\msys64\usr\bin;%PATH% - - python .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - bash .gitlab/win32-init.sh + # Setup toolchain + - bash .gitlab/ci.sh setup after_script: - - rd /s /q tmp - - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache - - bash -c 'make clean || true' + - | + Copy-Item -Recurse -Path $Env:APPDATA\cabal -Destination cabal-cache + - bash .gitlab/ci.sh clean dependencies: [] variables: - FORCE_SYMLINKS: 1 + #FORCE_SYMLINKS: 1 LANG: "en_US.UTF-8" SPHINXBUILD: "/mingw64/bin/sphinx-build.exe" + CABAL_INSTALL_VERSION: 3.0.0.0 + GHC_VERSION: "8.8.3" cache: paths: - cabal-cache - - ghc-8.6.2 + - toolchain - ghc-tarballs .build-windows-hadrian: extends: .build-windows stage: full-build - allow_failure: true variables: - GHC_VERSION: "8.8.3" + FLAVOUR: "validate" + # skipping perf tests for now since we build a quick-flavoured GHC, + # which might result in some broken perf tests? + HADRIAN_ARGS: "--docs=no-sphinx --skip-perf" + script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex' - - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist" - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz - # FIXME: Testsuite disabled due to #16156. - # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_hadrian + - bash .gitlab/ci.sh test_hadrian tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: + reports: + junit: junit.xml + expire_in: 2 week when: always paths: - ghc.tar.xz + - junit.xml validate-x86_64-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW64 + TEST_ENV: "x86_64-windows-hadrian" cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" @@ -598,86 +822,94 @@ nightly-i386-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW32 + TEST_ENV: "i386-windows-hadrian" cache: key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" .build-windows-make: extends: .build-windows stage: full-build - # due to #16084 - allow_failure: true variables: - BUILD_FLAVOUR: "UNSET" - GHC_VERSION: "8.8.3" - BUILD_PROF_LIBS: "YES" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz" + BUILD_FLAVOUR: "quick" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-mingw32.tar.xz" script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS' - - bash -c "echo \"include mk/flavours/${BUILD_FLAVOUR}.mk\" > mk/build.mk" - - bash -c "echo \"GhcLibHcOpts+=-haddock\" >> mk/build.mk" - - bash -c "echo \"BUILD_PROF_LIBS = $BUILD_PROF_LIBS\" >> mk/build.mk" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1" - - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_make + - bash .gitlab/ci.sh test_make tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: when: always expire_in: 2 week reports: junit: junit.xml paths: - - ghc-*.tar.xz + # N.B. variable interpolation apparently doesn't work on Windows so + # this can't be $BIN_DIST_PREP_TAR_COMP + - "ghc-x86_64-mingw32.tar.xz" - junit.xml -validate-x86_64-windows: +.build-x86_64-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" - BUILD_FLAVOUR: "quick" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" + TEST_ENV: "x86_64-windows" cache: key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-x86_64-windows: + extends: .build-x86_64-windows-make + +nightly-x86_64-windows: + <<: *nightly + extends: .build-x86_64-windows-make + stage: full-build + variables: + BUILD_FLAVOUR: "validate" + # Normal Windows validate builds are profiled; that won't do for releases. release-x86_64-windows: <<: *release extends: validate-x86_64-windows variables: - MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" - -release-i386-windows: + # +release-x86_64-windows-integer-simple: <<: *release - extends: .build-windows-make + extends: validate-x86_64-windows variables: - MSYSTEM: MINGW32 + INTEGER_LIBRARY: integer-simple BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - # Due to #15934 - BUILD_PROF_LIBS: "NO" - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows: - <<: *nightly + +.build-i386-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW32 - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - BUILD_FLAVOUR: "quick" # Due to #15934 BUILD_PROF_LIBS: "NO" + TEST_ENV: "i386-windows" + # Due to #17736 + allow_failure: true cache: key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-i386-windows: + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +release-i386-windows: + <<: *release + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +nightly-i386-windows: + <<: *nightly + extends: .build-i386-windows-make + ############################################################ # Cleanup ############################################################ @@ -687,40 +919,24 @@ nightly-i386-windows: # # As noted in [1], gitlab-runner's shell executor doesn't clean up its working # directory after builds. Unfortunately, we are forced to use the shell executor -# on Windows. To avoid running out of disk space we add a stage at the end of -# the build to remove the \GitLabRunner\builds directory. Since we only run a -# single build at a time on Windows this should be safe. +# on Darwin. To avoid running out of disk space we add a stage at the end of +# the build to remove the /.../GitLabRunner/builds directory. Since we only run a +# single build at a time on Darwin this should be safe. +# +# We used to have a similar cleanup job on Windows as well however it ended up +# being quite fragile as we have multiple Windows builders yet there is no +# guarantee that the cleanup job is run on the same machine as the build itself +# was run. Consequently we were forced to instead handle cleanup with a separate +# cleanup cron job on Windows. # # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856 -# See Note [Cleanup after shell executor] -cleanup-windows: - <<: *only-default - stage: cleanup - tags: - - x86_64-windows - dependencies: [] - before_script: - - echo "Time to clean up" - script: - - echo "Let's go" - after_script: - - set "BUILD_DIR=%CI_PROJECT_DIR%" - - set "BUILD_DIR=%BUILD_DIR:/=\%" - - echo "Cleaning %BUILD_DIR%" - - cd \GitLabRunner - # This is way more complicated than it should be: - # See https://stackoverflow.com/questions/1965787 - - del %BUILD_DIR%\* /F /Q - - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p" - - exit /b 0 - # See Note [Cleanup after shell executor] cleanup-darwin: - <<: *only-default stage: cleanup tags: - x86_64-darwin + when: always dependencies: [] before_script: - echo "Time to clean up" @@ -737,19 +953,56 @@ cleanup-darwin: # Packaging ############################################################ +doc-tarball: + stage: packaging + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + dependencies: + - validate-x86_64-linux-deb9-debug + - validate-x86_64-windows + variables: + LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz" + WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz" + # Due to Windows allow_failure + allow_failure: true + artifacts: + paths: + - haddock.html.tar.xz + - libraries.html.tar.xz + - users_guide.html.tar.xz + - index.html + - "*.pdf" + script: + - | + if [ ! -f "$LINUX_BINDIST" ]; then + echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" + exit 1 + fi + if [ ! -f "$WINDOWS_BINDIST" ]; then + echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?" + exit 1 + fi + - rm -Rf docs + - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST + - ls -lh + - mv docs/*.tar.xz docs/index.html . + source-tarball: - <<: *release stage: packaging tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" dependencies: [] + rules: + - if: $CI_COMMIT_TAG + when: always artifacts: paths: - ghc-*.tar.xz - version script: - - mk/get-win32-tarballs.sh download all + - python3 mk/get-win32-tarballs.py download all - ./boot - ./configure - make sdist @@ -770,9 +1023,8 @@ source-tarball: # pipeline. .hackage: - <<: *only-default - stage: hackage - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + stage: testing + image: ghcci/x86_64-linux-deb9:0.2 tags: - x86_64-linux dependencies: [] @@ -781,6 +1033,10 @@ source-tarball: script: - bash .gitlab/start-head.hackage.sh +hackage: + extends: .hackage + when: manual + hackage-label: extends: .hackage rules: @@ -790,3 +1046,69 @@ nightly-hackage: <<: *nightly extends: .hackage +############################################################ +# Nofib testing +############################################################ + +perf-nofib: + stage: testing + dependencies: + - validate-x86_64-linux-deb9-dwarf + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + rules: + - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + tags: + - x86_64-linux + script: + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ghc-x86_64-deb9-linux-dwarf.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - cabal update; cabal install -w $BOOT_HC regex-compat + - export PATH=$root/bin:$PATH + - make -C nofib boot mode=fast -j$CPUS + - "make -C nofib EXTRA_RUNTEST_OPTS='-cachegrind +RTS -V0 -RTS' NoFibRuns=1 mode=fast -j$CPUS 2>&1 | tee nofib.log" + artifacts: + expire_in: 12 week + when: always + paths: + - nofib.log + +############################################################ +# Documentation deployment via GitLab Pages +############################################################ + +pages: + stage: deploy + dependencies: + - doc-tarball + image: ghcci/x86_64-linux-deb9:0.2 + # Due to Windows allow_failure + allow_failure: true + tags: + - x86_64-linux + script: + - mkdir -p public/doc + - tar -xf haddock.html.tar.xz -C public/doc + - tar -xf libraries.html.tar.xz -C public/doc + - tar -xf users_guide.html.tar.xz -C public/doc + - | + cat >public/index.html < + + + EOF + - cp -f index.html public/doc + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + artifacts: + paths: + - public ===================================== .gitlab/ci.sh ===================================== @@ -0,0 +1,464 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2230 + +# This is the primary driver of the GitLab CI infrastructure. + +set -e -o pipefail + +# Configuration: +hackage_index_state="@1579718451" + +# Colors +BLACK="0;30" +GRAY="1;30" +RED="0;31" +LT_RED="1;31" +BROWN="0;33" +LT_BROWN="1;33" +GREEN="0;32" +LT_GREEN="1;32" +BLUE="0;34" +LT_BLUE="1;34" +PURPLE="0;35" +LT_PURPLE="1;35" +CYAN="0;36" +LT_CYAN="1;36" +WHITE="1;37" +LT_GRAY="0;37" + +export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 + +# GitLab Pipelines log section delimiters +# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664 +start_section() { + name="$1" + echo -e "section_start:$(date +%s):$name\015\033[0K" +} + +end_section() { + name="$1" + echo -e "section_end:$(date +%s):$name\015\033[0K" +} + +echo_color() { + local color="$1" + local msg="$2" + echo -e "\033[${color}m${msg}\033[0m" +} + +error() { echo_color "${RED}" "$1"; } +warn() { echo_color "${LT_BROWN}" "$1"; } +info() { echo_color "${LT_BLUE}" "$1"; } + +fail() { error "error: $1"; exit 1; } + +function run() { + info "Running $*..." + "$@" || ( error "$* failed"; return 1; ) +} + +TOP="$(pwd)" + +function mingw_init() { + case "$MSYSTEM" in + MINGW32) + triple="i386-unknown-mingw32" + boot_triple="i386-unknown-mingw32" # triple of bootstrap GHC + ;; + MINGW64) + triple="x86_64-unknown-mingw32" + boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC + ;; + *) + fail "win32-init: Unknown MSYSTEM $MSYSTEM" + ;; + esac + + # Bring mingw toolchain into PATH. + # This is extracted from /etc/profile since this script inexplicably fails to + # run under gitlab-runner. + # shellcheck disable=SC1091 + source /etc/msystem + MINGW_MOUNT_POINT="${MINGW_PREFIX}" + PATH="$MINGW_MOUNT_POINT/bin:$PATH" + + # We always use mingw64 Python to avoid path length issues like #17483. + export PYTHON="/mingw64/bin/python3" +} + +# This will contain GHC's local native toolchain +toolchain="$TOP/toolchain" +mkdir -p "$toolchain/bin" +PATH="$toolchain/bin:$PATH" + +export METRICS_FILE="$CI_PROJECT_DIR/performance-metrics.tsv" + +cores="$(mk/detect-cpu-count.sh)" + +# Use a local temporary directory to ensure that concurrent builds don't +# interfere with one another +mkdir -p "$TOP/tmp" +export TMP="$TOP/tmp" +export TEMP="$TOP/tmp" + +function darwin_setup() { + # It looks like we already have python2 here and just installing python3 + # does not work. + brew upgrade python + brew install ghc cabal-install ncurses gmp + + pip3 install sphinx + # PDF documentation disabled as MacTeX apparently doesn't include xelatex. + #brew cask install mactex +} + +function show_tool() { + local tool="$1" + info "$tool = ${!tool}" + ${!tool} --version +} + +function set_toolchain_paths() { + needs_toolchain=1 + case "$(uname)" in + Linux) needs_toolchain="" ;; + *) ;; + esac + + if [[ -n "$needs_toolchain" ]]; then + # These are populated by setup_toolchain + GHC="$toolchain/bin/ghc$exe" + CABAL="$toolchain/bin/cabal$exe" + HAPPY="$toolchain/bin/happy$exe" + ALEX="$toolchain/bin/alex$exe" + else + GHC="$(which ghc)" + CABAL="/usr/local/bin/cabal" + HAPPY="$HOME/.cabal/bin/happy" + ALEX="$HOME/.cabal/bin/alex" + fi + export GHC + export CABAL + export HAPPY + export ALEX +} + +# Extract GHC toolchain +function setup() { + if [ -d "$TOP/cabal-cache" ]; then + info "Extracting cabal cache..." + mkdir -p "$cabal_dir" + cp -Rf cabal-cache/* "$cabal_dir" + fi + + if [[ -n "$needs_toolchain" ]]; then + setup_toolchain + fi + case "$(uname)" in + Darwin) darwin_setup ;; + *) ;; + esac + + # Make sure that git works + git config user.email "ghc-ci at gitlab-haskell.org" + git config user.name "GHC GitLab CI" + + info "=====================================================" + info "Toolchain versions" + info "=====================================================" + show_tool GHC + show_tool CABAL + show_tool HAPPY + show_tool ALEX +} + +function fetch_ghc() { + local v="$GHC_VERSION" + if [[ -z "$v" ]]; then + fail "GHC_VERSION is not set" + fi + + if [ ! -e "$GHC" ]; then + start_section "fetch GHC" + url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple}.tar.xz" + info "Fetching GHC binary distribution from $url..." + curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution" + tar -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution" + case "$(uname)" in + MSYS_*|MINGW*) + cp -r "ghc-${GHC_VERSION}"/* "$toolchain" + ;; + *) + pushd "ghc-${GHC_VERSION}" + ./configure --prefix="$toolchain" + "$MAKE" install + popd + ;; + esac + rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz + end_section "fetch GHC" + fi + +} + +function fetch_cabal() { + local v="$CABAL_INSTALL_VERSION" + if [[ -z "$v" ]]; then + fail "CABAL_INSTALL_VERSION is not set" + fi + + if [ ! -e "$CABAL" ]; then + start_section "fetch GHC" + case "$(uname)" in + # N.B. Windows uses zip whereas all others use .tar.xz + MSYS_*|MINGW*) + case "$MSYSTEM" in + MINGW32) cabal_arch="i386" ;; + MINGW64) cabal_arch="x86_64" ;; + *) fail "unknown MSYSTEM $MSYSTEM" ;; + esac + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-unknown-mingw32.zip" + info "Fetching cabal binary distribution from $url..." + curl "$url" > "$TMP/cabal.zip" + unzip "$TMP/cabal.zip" + mv cabal.exe "$CABAL" + ;; + *) + local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/" + case "$(uname)" in + Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;; + FreeBSD) + #cabal_url="$base_url/cabal-install-$v-x86_64-portbld-freebsd.tar.xz" ;; + cabal_url="http://home.smart-cactus.org/~ben/ghc/cabal-install-3.0.0.0-x86_64-portbld-freebsd.tar.xz" ;; + *) fail "don't know where to fetch cabal-install for $(uname)" + esac + echo "Fetching cabal-install from $cabal_url" + curl "$cabal_url" > cabal.tar.xz + tar -xJf cabal.tar.xz + mv cabal "$toolchain/bin" + ;; + esac + end_section "fetch GHC" + fi +} + +# For non-Docker platforms we prepare the bootstrap toolchain +# here. For Docker platforms this is done in the Docker image +# build. +function setup_toolchain() { + fetch_ghc + fetch_cabal + cabal_install="$CABAL v2-install --index-state=$hackage_index_state --installdir=$toolchain/bin" + # Avoid symlinks on Windows + case "$(uname)" in + MSYS_*|MINGW*) cabal_install="$cabal_install --install-method=copy" ;; + *) ;; + esac + + if [ ! -e "$HAPPY" ]; then + info "Building happy..." + cabal update + $cabal_install happy + fi + + if [ ! -e "$ALEX" ]; then + info "Building alex..." + cabal update + $cabal_install alex + fi +} + +function cleanup_submodules() { + start_section "clean submodules" + info "Cleaning submodules..." + # On Windows submodules can inexplicably get into funky states where git + # believes that the submodule is initialized yet its associated repository + # is not valid. Avoid failing in this case with the following insanity. + git submodule sync --recursive || git submodule deinit --force --all + git submodule update --init --recursive + git submodule foreach git clean -xdf + end_section "clean submodules" +} + +function prepare_build_mk() { + if [[ -z "$BUILD_FLAVOUR" ]]; then fail "BUILD_FLAVOUR is not set"; fi + if [[ -z ${BUILD_SPHINX_HTML:-} ]]; then BUILD_SPHINX_HTML=YES; fi + if [[ -z ${BUILD_SPHINX_PDF:-} ]]; then BUILD_SPHINX_PDF=YES; fi + if [[ -z ${INTEGER_LIBRARY:-} ]]; then INTEGER_LIBRARY=integer-gmp; fi + + cat > mk/build.mk <> mk/build.mk + fi + + case "$(uname)" in + Darwin) echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk ;; + *) ;; + esac + + info "build.mk is:" + cat mk/build.mk +} + +function configure() { + start_section "booting" + run python3 boot + end_section "booting" + + local target_args="" + if [[ -n "$triple" ]]; then + target_args="--target=$triple" + fi + + start_section "configuring" + run ./configure \ + --enable-tarballs-autodownload \ + $target_args \ + $CONFIGURE_ARGS \ + GHC="$GHC" \ + HAPPY="$HAPPY" \ + ALEX="$ALEX" \ + || ( cat config.log; fail "configure failed" ) + end_section "configuring" +} + +function build_make() { + prepare_build_mk + if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then + fail "BIN_DIST_PREP_TAR_COMP is not set" + fi + + echo "include mk/flavours/${BUILD_FLAVOUR}.mk" > mk/build.mk + echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk + run "$MAKE" -j"$cores" $MAKE_ARGS + run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 + ls -lh "$BIN_DIST_PREP_TAR_COMP" +} + +function fetch_perf_notes() { + info "Fetching perf notes..." + "$TOP/.gitlab/test-metrics.sh" pull +} + +function push_perf_notes() { + info "Pushing perf notes..." + "$TOP/.gitlab/test-metrics.sh" push +} + +function test_make() { + run "$MAKE" test_bindist TEST_PREP=YES + run "$MAKE" V=0 test \ + THREADS="$cores" \ + JUNIT_FILE=../../junit.xml +} + +function build_hadrian() { + if [ -z "$FLAVOUR" ]; then + fail "FLAVOUR not set" + fi + + run_hadrian binary-dist + + mv _build/bindist/ghc*.tar.xz ghc.tar.xz +} + +function test_hadrian() { + cd _build/bindist/ghc-*/ + run ./configure --prefix="$TOP"/_build/install + run "$MAKE" install + cd ../../../ + + run_hadrian \ + test \ + --summary-junit=./junit.xml \ + --test-compiler="$TOP"/_build/install/bin/ghc +} + +function clean() { + rm -R tmp + run "$MAKE" --quiet clean || true + run rm -Rf _build +} + +function run_hadrian() { + run hadrian/build-cabal \ + --flavour="$FLAVOUR" \ + -j"$cores" \ + --broken-test="$BROKEN_TESTS" \ + $HADRIAN_ARGS \ + $@ +} + +# A convenience function to allow debugging in the CI environment. +function shell() { + local cmd=$@ + if [ -z "$cmd" ]; then + cmd="bash -i" + fi + run $cmd +} + +# Determine Cabal data directory +case "$(uname)" in + MSYS_*|MINGW*) exe=".exe"; cabal_dir="$APPDATA/cabal" ;; + *) cabal_dir="$HOME/.cabal"; exe="" ;; +esac + +# Platform-specific environment initialization +MAKE="make" +case "$(uname)" in + MSYS_*|MINGW*) mingw_init ;; + Darwin) boot_triple="x86_64-apple-darwin" ;; + FreeBSD) + boot_triple="x86_64-portbld-freebsd" + MAKE="gmake" + ;; + Linux) ;; + *) fail "uname $(uname) is not supported" ;; +esac + +set_toolchain_paths + +case $1 in + setup) setup && cleanup_submodules ;; + configure) configure ;; + build_make) build_make ;; + test_make) + fetch_perf_notes + res=0 + test_make || res=$? + push_perf_notes + exit $res ;; + build_hadrian) build_hadrian ;; + # N.B. Always push notes, even if the build fails. This is okay to do as the + # testsuite driver doesn't record notes for tests that fail due to + # correctness. + test_hadrian) + fetch_perf_notes + res=0 + test_hadrian || res=$? + push_perf_notes + exit $res ;; + run_hadrian) run_hadrian $@ ;; + clean) clean ;; + shell) shell $@ ;; + *) fail "unknown mode $1" ;; +esac ===================================== .gitlab/darwin-init.sh deleted ===================================== @@ -1,41 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $HOME/.cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - mkdir -p tmp - cd tmp - ghc_tarball="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-x86_64-apple-darwin.tar.xz" - echo "Fetching GHC from $ghc_tarball" - curl $ghc_tarball | tar -xJ - cd ghc-$GHC_VERSION - ./configure --prefix=$toolchain - make install - cd ../.. - rm -Rf tmp -fi - -if [ ! -e $toolchain/bin/cabal ]; then - cabal_tarball="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL_VERSION/cabal-install-$CABAL_INSTALL_VERSION-x86_64-apple-darwin-sierra.tar.xz" - echo "Fetching cabal-install from $cabal_tarball" - curl $cabal_tarball | tar -xz - mv cabal $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal new-install happy --symlink-bindir=$toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal new-install alex --symlink-bindir=$toolchain/bin -fi - ===================================== .gitlab/linters/check-makefiles.py ===================================== @@ -1,5 +1,11 @@ #!/usr/bin/env python3 +""" +Linters for testsuite makefiles +""" + +from linter import run_linters, RegexpLinter + """ Warn for use of `--interactive` inside Makefiles (#11468). @@ -7,13 +13,21 @@ Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to forget one of those flags when adding a new test. """ +interactive_linter = \ + RegexpLinter(r'--interactive', + message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`." + ).add_path_filter(lambda path: path.name == 'Makefile') -from linter import run_linters, RegexpLinter +test_hc_quotes_linter = \ + RegexpLinter('\t\\$\\(TEST_HC\\)', + message = "Warning: $(TEST_HC) should be quoted in Makefiles.", + ).add_path_filter(lambda path: path.name == 'Makefile') linters = [ - RegexpLinter(r'--interactive', - message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`.") + interactive_linter, + test_hc_quotes_linter, ] if __name__ == '__main__': - run_linters(linters) #$, subdir='testsuite') + run_linters(linters, + subdir='testsuite') ===================================== .gitlab/linters/check-version-number.sh ===================================== @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +grep -E -q '\[[0-9]+\.[0-9]+\.[0-9]+\]' configure.ac || + ( echo "error: configure.ac: GHC version number must have three components."; exit 1 ) ===================================== .gitlab/linters/linter.py ===================================== @@ -7,10 +7,11 @@ import sys import re import textwrap import subprocess -from typing import List, Optional +from pathlib import Path +from typing import List, Optional, Callable, Sequence from collections import namedtuple -def lint_failure(file, line_no, line_content, message): +def lint_failure(file, line_no: int, line_content: str, message: str): """ Print a lint failure message. """ wrapper = textwrap.TextWrapper(initial_indent=' ', subsequent_indent=' ') @@ -29,7 +30,7 @@ def lint_failure(file, line_no, line_content, message): print(textwrap.dedent(msg)) -def get_changed_files(base_commit, head_commit, +def get_changed_files(base_commit: str, head_commit: str, subdir: str = '.'): """ Get the files changed by the given range of commits. """ cmd = ['git', 'diff', '--name-only', @@ -46,12 +47,21 @@ class Linter(object): """ def __init__(self): self.warnings = [] # type: List[Warning] + self.path_filters = [] # type: List[Callable[[Path], bool]] def add_warning(self, w: Warning): self.warnings.append(w) - def lint(self, path): - pass + def add_path_filter(self, f: Callable[[Path], bool]) -> "Linter": + self.path_filters.append(f) + return self + + def do_lint(self, path: Path): + if all(f(path) for f in self.path_filters): + self.lint(path) + + def lint(self, path: Path): + raise NotImplementedError class LineLinter(Linter): """ @@ -59,44 +69,55 @@ class LineLinter(Linter): the given line from a file and calls :func:`add_warning` for any lint issues found. """ - def lint(self, path): - if os.path.isfile(path): - with open(path, 'r') as f: + def lint(self, path: Path): + if path.is_file(): + with path.open('r') as f: for line_no, line in enumerate(f): self.lint_line(path, line_no+1, line) - def lint_line(self, path, line_no, line): - pass + def lint_line(self, path: Path, line_no: int, line: str): + raise NotImplementedError class RegexpLinter(LineLinter): """ A :class:`RegexpLinter` produces the given warning message for all lines matching the given regular expression. """ - def __init__(self, regex, message): + def __init__(self, regex: str, message: str): LineLinter.__init__(self) self.re = re.compile(regex) self.message = message - def lint_line(self, path, line_no, line): + def lint_line(self, path: Path, line_no: int, line: str): if self.re.search(line): w = Warning(path=path, line_no=line_no, line_content=line[:-1], message=self.message) self.add_warning(w) -def run_linters(linters: List[Linter], +def run_linters(linters: Sequence[Linter], subdir: str = '.') -> None: import argparse parser = argparse.ArgumentParser() - parser.add_argument('base', help='Base commit') - parser.add_argument('head', help='Head commit') + subparsers = parser.add_subparsers() + + subparser = subparsers.add_parser('commits', help='Lint a range of commits') + subparser.add_argument('base', help='Base commit') + subparser.add_argument('head', help='Head commit') + subparser.set_defaults(get_linted_files=lambda args: + get_changed_files(args.base, args.head, subdir)) + + subparser = subparsers.add_parser('files', help='Lint a range of commits') + subparser.add_argument('file', nargs='+', help='File to lint') + subparser.set_defaults(get_linted_files=lambda args: args.file) + args = parser.parse_args() - for path in get_changed_files(args.base, args.head, subdir): + linted_files = args.get_linted_files(args) + for path in linted_files: if path.startswith('.gitlab/linters'): continue for linter in linters: - linter.lint(path) + linter.do_lint(Path(path)) warnings = [warning for linter in linters ===================================== .gitlab/win32-init.sh deleted ===================================== @@ -1,50 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:/mingw64/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $APPDATA/cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - case $MSYSTEM in - MINGW32) - triple="i386-unknown-mingw32" - ;; - MINGW64) - triple="x86_64-unknown-mingw32" - ;; - *) - echo "win32-init: Unknown MSYSTEM $MSYSTEM" - exit 1 - ;; - esac - if [ -z "$GHC_TARBALL_URL" ]; then - GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" - fi - curl "$GHC_TARBALL_URL" | tar -xJ - mv ghc-$GHC_VERSION toolchain -fi - -if [ ! -e $toolchain/bin/cabal ]; then - url="https://downloads.haskell.org/~cabal/cabal-install-2.4.1.0/cabal-install-2.4.1.0-x86_64-unknown-mingw32.zip" - curl $url > /tmp/cabal.zip - unzip /tmp/cabal.zip - mv cabal.exe $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal install happy - cp $APPDATA/cabal/bin/happy $toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal install alex - cp $APPDATA/cabal/bin/alex $toolchain/bin -fi - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bca1b960248b834589b16031faaaff56abeb5491 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bca1b960248b834589b16031faaaff56abeb5491 You're receiving 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 Jul 11 16:54:31 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 12:54:31 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] Backport CI infrastructure rework Message-ID: <5f09eec790b79_80b3f846a0d2e3c265975f@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 9f52e0ca by Ben Gamari at 2020-07-11T12:54:18-04:00 Backport CI infrastructure rework - - - - - 7 changed files: - .gitlab-ci.yml - + .gitlab/ci.sh - − .gitlab/darwin-init.sh - .gitlab/linters/check-makefiles.py - + .gitlab/linters/check-version-number.sh - .gitlab/linters/linter.py - − .gitlab/win32-init.sh Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,59 +2,45 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a + DOCKER_REV: 6223fe0b5942f4fa35bdec92c74566cf195bfb42 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/win32-init.sh. + # .gitlab/ci.sh. WINDOWS_TOOLCHAIN_VERSION: 1 -before_script: - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + # Disable shallow clones; they break our linting rules + GIT_DEPTH: 0 + + # Overridden by individual jobs + CONFIGURE_ARGS: "" + + GIT_SUBMODULE_STRATEGY: "recursive" stages: - - lint # Source linting - - build # A quick smoke-test to weed out broken commits - - full-build # Build all the things - - cleanup # See Note [Cleanup on Windows] - - packaging # Source distribution, etc. - - hackage # head.hackage testing - - deploy # push documentation - -.only-default: &only-default - rules: - - if: $CI_MERGE_REQUEST_ID - - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "master"' - - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - - if: '$CI_PIPELINE_SOURCE == "web"' + - lint # Source linting + - quick-build # A very quick smoke-test to weed out broken commits + - build # A quick smoke-test to weed out broken commits + - full-build # Build all the things + - cleanup # See Note [Cleanup after the shell executor] + - packaging # Source distribution, etc. + - testing # head.hackage correctness and compiler performance testing + - deploy # push documentation workflow: - # N.B. Don't run on wip/ branches, instead on run on merge requests. + # N.B.Don't run on wip/ branches, instead on run on merge requests. rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' -############################################################ -# Runner Tags -############################################################ -# -# * x86_64-linux: Any Docker-capable x86_64 Linux machine -# * aarch64-linux: Any Docker-capable AArch64 Linux machine -# * x86_64-windows: A x86_64 Windows machine -# * lint: Any Docker-capable x86_64 Linux machine; distinct from -# x86_64-linux to ensure low-latency availability. -# - .nightly: &nightly rules: - if: $NIGHTLY + artifacts: + when: always + expire_in: 8 weeks .release: &release variables: @@ -66,53 +52,105 @@ workflow: rules: - if: '$RELEASE == "yes"' +############################################################ +# Runner Tags +############################################################ +# +# * x86_64-linux: Any Docker-capable x86_64 Linux machine +# * aarch64-linux: Any Docker-capable AArch64 Linux machine +# * x86_64-windows: A x86_64 Windows machine +# * lint: Any Docker-capable x86_64 Linux machine; distinct from +# x86_64-linux to ensure low-latency availability. +# + ############################################################ # Linting ############################################################ ghc-linters: - allow_failure: true stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" - - "echo Merge base $base" + - "echo Linting changes between $base..$CI_COMMIT_SHA" # - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA) - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA) - - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA - - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA + - .gitlab/linters/check-makefiles.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-cpp.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-version-number.sh + - python3 utils/checkUniques/check-uniques.py . dependencies: [] tags: - lint rules: - if: $CI_MERGE_REQUEST_ID +# Run mypy Python typechecker on linter scripts. +lint-linters: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy .gitlab/linters/*.py + dependencies: [] + tags: + - lint + +# Check that .T files all parse by listing broken tests. +lint-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + script: + - make -Ctestsuite list_broken TEST_HC=ghc + dependencies: [] + tags: + - lint + +# Run mypy Python typechecker on testsuite driver +.typecheck-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy testsuite/driver/runtests.py + dependencies: [] + tags: + - lint + # We allow the submodule checker to fail when run on merge requests (to -# accomodate, e.g., haddock changes not yet upstream) but not on `master` or +# accommodate, e.g., haddock changes not yet upstream) but not on `master` or # Marge jobs. .lint-submods: stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA) + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" + - "echo Linting submodule changes between $base..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $base..$CI_COMMIT_SHA) dependencies: [] tags: - lint lint-submods: extends: .lint-submods + # Allow failure on merge requests since any necessary submodule patches may + # not be upstreamed yet. rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/' allow_failure: false - allow_failure: true -lint-submods-mr: +lint-submods-branch: extends: .lint-submods - allow_failure: true + script: + - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA) rules: - - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' .lint-changelogs: stage: lint @@ -125,6 +163,7 @@ lint-submods-mr: lint-changelogs: extends: .lint-changelogs + # Allow failure since this isn't a final release. allow_failure: true rules: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' @@ -140,71 +179,183 @@ lint-release-changelogs: ############################################################ .validate-hadrian: - <<: *only-default - allow_failure: true + variables: + FLAVOUR: "validate" script: - - cabal update - - git clean -xdf && git submodule foreach git clean -xdf - - bash .circleci/prepare-system.sh - - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi - - ./boot - - ./configure $CONFIGURE_ARGS - - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian cache: key: hadrian paths: - cabal-cache artifacts: - when: always + reports: + junit: junit.xml + expire_in: 2 week paths: - ghc.tar.xz + - junit.xml -validate-x86_64-linux-deb8-hadrian: +.validate-linux-hadrian: extends: .validate-hadrian - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + variables: + TEST_ENV: "x86_64-linux-deb9-hadrian" before_script: # workaround for docker permissions - sudo chown ghc:ghc -R . - - python3 .gitlab/fix-submodules.py - git submodule sync --recursive - git submodule update --init --recursive - git checkout .gitmodules - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + after_script: + - .gitlab/ci.sh clean tags: - x86_64-linux +validate-x86_64-linux-deb9-hadrian: + extends: .validate-linux-hadrian + stage: build + +validate-x86_64-linux-deb9-unreg-hadrian: + extends: .validate-linux-hadrian + stage: full-build + variables: + CONFIGURE_ARGS: --enable-unregisterised + TEST_ENV: "x86_64-linux-deb9-unreg-hadrian" + +hadrian-ghc-in-ghci: + stage: quick-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + variables: + GHC_FLAGS: -Werror + tags: + - x86_64-linux + script: + - cabal update + - cd hadrian; cabal new-build --project-file=ci.project; cd .. + - git clean -xdf && git submodule foreach git clean -xdf + - .gitlab/ci.sh setup + - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi + - ./boot + - ./configure $CONFIGURE_ARGS + # 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," + cache: + key: hadrian-ghci + paths: + - cabal-cache ############################################################ # Validation via Pipelines (make) ############################################################ .validate: - <<: *only-default variables: TEST_TYPE: test - before_script: - - git clean -xdf && git submodule foreach git clean -xdf + MAKE_ARGS: "-Werror" script: - - ./boot - - ./configure $CONFIGURE_ARGS - - | - THREADS=`mk/detect-cpu-count.sh` - make V=0 -j$THREADS WERROR=-Werror - - | - make binary-dist TAR_COMP_OPTS="-1" - - | - THREADS=`mk/detect-cpu-count.sh` - make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_make + - .gitlab/ci.sh test_make dependencies: [] artifacts: reports: junit: junit.xml expire_in: 2 week paths: - - ghc-*.tar.xz + - $BIN_DIST_PREP_TAR_COMP - junit.xml + - performance-metrics.tsv + +################################# +# x86_64-freebsd +################################# + +.build-x86_64-freebsd: + extends: .validate + tags: + - x86_64-freebsd + allow_failure: true + variables: + # N.B. we use iconv from ports as I see linker errors when we attempt + # to use the "native" iconv embedded in libc as suggested by the + # porting guide [1]. + # [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + GHC_VERSION: 8.10.1 + CABAL_INSTALL_VERSION: 3.2.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd" + BUILD_FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Conditional due to lack of builder capacity +validate-x86_64-freebsd: + extends: .build-x86_64-freebsd + stage: full-build + rules: + - if: '$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/' + +nightly-x86_64-freebsd: + <<: *nightly + extends: .build-x86_64-freebsd + stage: full-build + +release-x86_64-freebsd: + <<: *release + extends: .build-x86_64-freebsd + stage: full-build + +.build-x86_64-freebsd-hadrian: + extends: .validate-hadrian + stage: full-build + tags: + - x86_64-freebsd + allow_failure: true + variables: + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + HADRIAN_ARGS: "--docs=no-sphinx" + GHC_VERSION: 8.6.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd-hadrian" + FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Disabled due to lack of builder capacity +.validate-x86_64-freebsd-hadrian: + extends: .build-x86_64-freebsd-hadrian + stage: full-build ################################# # x86_64-darwin @@ -216,54 +367,71 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: "8.8.3" - CABAL_INSTALL_VERSION: 2.4.1.0 - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz" + GHC_VERSION: 8.8.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-apple-darwin.tar.xz" MACOSX_DEPLOYMENT_TARGET: "10.7" # Only Sierra and onwards supports clock_gettime. See #12858 ac_cv_func_clock_gettime: "no" LANG: "en_US.UTF-8" - CONFIGURE_ARGS: --with-intree-gmp + CONFIGURE_ARGS: "--with-intree-gmp" TEST_ENV: "x86_64-darwin" - before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - - bash .gitlab/darwin-init.sh - - PATH="`pwd`/toolchain/bin:$PATH" + BUILD_FLAVOUR: "perf" after_script: - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean artifacts: when: always expire_in: 2 week cache: - key: darwin + key: "darwin-$GHC_VERSION" paths: - cabal-cache - toolchain +# Disabled because of OS X CI capacity +.validate-x86_64-darwin-hadrian: + stage: full-build + tags: + - x86_64-darwin + variables: + GHC_VERSION: 8.8.3 + MACOSX_DEPLOYMENT_TARGET: "10.7" + ac_cv_func_clock_gettime: "no" + LANG: "en_US.UTF-8" + CONFIGURE_ARGS: --with-intree-gmp + TEST_ENV: "x86_64-darwin-hadrian" + FLAVOUR: "validate" + script: + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + reports: + junit: junit.xml + paths: + - ghc.tar.xz + - junit.xml + .validate-linux: extends: .validate tags: - x86_64-linux + variables: + BUILD_FLAVOUR: "perf" before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" # Build hyperlinked sources for documentation when building releases - | if [[ -n "$CI_COMMIT_TAG" ]]; then - echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk + HADDOCK_HYPERLINKED_SOURCES=1 fi - - bash .circleci/prepare-system.sh # workaround for docker permissions - sudo chown ghc:ghc -R . after_script: @@ -285,9 +453,7 @@ validate-x86_64-darwin: allow_failure: true variables: TEST_ENV: "aarch64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz" - # Inexplicably makeindex fails - BUILD_SPHINX_PDF: "NO" + BIN_DIST_PREP_TAR_COMP: "ghc-aarch64-linux-deb9.tar.xz" cache: key: linux-aarch64-deb9 tags: @@ -302,8 +468,41 @@ validate-aarch64-linux-deb9: nightly-aarch64-linux-deb9: <<: *nightly extends: .build-aarch64-linux-deb9 + variables: + TEST_TYPE: slowtest + +################################# +# armv7-linux-deb9 +################################# + +.build-armv7-linux-deb9: + extends: .validate-linux + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb9:$DOCKER_REV" + # Due to linker issues + allow_failure: true + variables: + TEST_ENV: "armv7-linux-deb9" + BIN_DIST_PREP_TAR_COMP: "ghc-armv7-linux-deb9.tar.xz" + CONFIGURE_ARGS: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" + # N.B. We disable ld.lld explicitly here because it appears to fail + # non-deterministically on ARMv7. See #18280. + LD: "ld.gold" + GccUseLdOpt: "-fuse-ld=gold" + cache: + key: linux-armv7-deb9 + tags: + - armv7-linux + +validate-armv7-linux-deb9: + extends: .build-armv7-linux-deb9 artifacts: - expire_in: 2 year + when: always + expire_in: 2 week + +nightly-armv7-linux-deb9: + <<: *nightly + extends: .build-armv7-linux-deb9 variables: TEST_TYPE: slowtest @@ -317,7 +516,7 @@ nightly-aarch64-linux-deb9: image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "i386-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-i386-deb9-linux.tar.xz" cache: key: linux-i386-deb9 @@ -332,23 +531,6 @@ nightly-i386-linux-deb9: extends: .build-i386-linux-deb9 variables: TEST_TYPE: slowtest - artifacts: - when: always - expire_in: 2 week - -################################# -# x86_64-linux-deb10 -################################# - -.build-x86_64-linux-deb10: - extends: .validate-linux - stage: full-build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - variables: - TEST_ENV: "x86_64-linux-deb10" - BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" - cache: - key: linux-x86_64-deb10 ################################# # x86_64-linux-deb9 @@ -356,40 +538,62 @@ nightly-i386-linux-deb9: .build-x86_64-linux-deb9: extends: .validate-linux - stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb9-linux.tar.xz" cache: key: linux-x86_64-deb9 -validate-x86_64-linux-deb9: +# Disabled to reduce CI load +.validate-x86_64-linux-deb9: extends: .build-x86_64-linux-deb9 + stage: full-build artifacts: when: always expire_in: 2 week +release-x86_64-linux-deb9: + <<: *release + extends: .build-x86_64-linux-deb9 + stage: full-build + nightly-x86_64-linux-deb9: <<: *nightly extends: .build-x86_64-linux-deb9 - artifacts: - expire_in: 2 year + stage: full-build variables: TEST_TYPE: slowtest # N.B. Has DEBUG assertions enabled in stage2 validate-x86_64-linux-deb9-debug: extends: .build-x86_64-linux-deb9 - stage: build + stage: full-build variables: BUILD_FLAVOUR: validate + # Ensure that stage2 also has DEBUG enabled + ValidateSpeed: SLOW + # Override validate flavour default; see #16890. + BUILD_SPHINX_PDF: "YES" + TEST_TYPE: slowtest TEST_ENV: "x86_64-linux-deb9-debug" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-debug.tar.xz" + artifacts: + when: always + expire_in: 2 week -validate-x86_64-linux-deb9-llvm: +# Disabled to alleviate CI load +.validate-x86_64-linux-deb9-llvm: + extends: .build-x86_64-linux-deb9 + stage: full-build + variables: + BUILD_FLAVOUR: perf-llvm + TEST_ENV: "x86_64-linux-deb9-llvm" + +nightly-x86_64-linux-deb9-llvm: + <<: *nightly extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: BUILD_FLAVOUR: perf-llvm TEST_ENV: "x86_64-linux-deb9-llvm" @@ -397,11 +601,11 @@ validate-x86_64-linux-deb9-llvm: validate-x86_64-linux-deb9-integer-simple: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: + BUILD_FLAVOUR: validate INTEGER_LIBRARY: integer-simple - TEST_ENV: "x86_64-linux-deb9-integer-simple" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz" + TEST_ENV: "x86_64-linux-deb9-integer-simple-validate" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-integer-simple.tar.xz" nightly-x86_64-linux-deb9-integer-simple: <<: *nightly @@ -411,185 +615,205 @@ nightly-x86_64-linux-deb9-integer-simple: INTEGER_LIBRARY: integer-simple TEST_ENV: "x86_64-linux-deb9-integer-simple" TEST_TYPE: slowtest - artifacts: - expire_in: 2 year -validate-x86_64-linux-deb9-unreg: +validate-x86_64-linux-deb9-dwarf: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: - CONFIGURE_ARGS: --enable-unregisterised - TEST_ENV: "x86_64-linux-deb9-unreg" + CONFIGURE_ARGS: "--enable-dwarf-unwind" + BUILD_FLAVOUR: dwarf + TEST_ENV: "x86_64-linux-deb9-dwarf" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-dwarf.tar.xz" + +################################# +# x86_64-linux-deb10 +################################# -release-x86_64-linux-deb9-dwarf: +.build-x86_64-linux-deb10: extends: .validate-linux - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" - allow_failure: true + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb9" - artifacts: - when: always - expire_in: 2 week + TEST_ENV: "x86_64-linux-deb10" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" cache: - key: linux-x86_64-deb9 + key: linux-x86_64-deb10 +# Disabled to alleviate CI load +.validate-x86_64-linux-deb10: + extends: .build-x86_64-linux-deb10 + stage: full-build -release-x86_64-linux-deb10-dwarf: - <<: *release +nightly-x86_64-linux-deb10: + <<: *nightly extends: .build-x86_64-linux-deb10 variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb10-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb10-linux-dwarf.tar.xz" + TEST_TYPE: slowtest + +release-x86_64-linux-deb10: + <<: *release + extends: .build-x86_64-linux-deb10 ################################# # x86_64-linux-deb8 ################################# -release-x86_64-linux-deb8: - <<: *release +.build-x86_64-linux-deb8: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + # Due to #18298. + allow_failure: true variables: TEST_ENV: "x86_64-linux-deb8" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz" - # Disable sphinx PDF output as our Debian image doesn't have the requisite packages + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb8-linux.tar.xz" + # Debian 8's Sphinx is too old to support the table directive's :widths: + # option: https://sourceforge.net/p/docutils/patches/120/ + BUILD_SPHINX_HTML: "NO" + BUILD_SPHINX_INFO: "NO" BUILD_SPHINX_PDF: "NO" + BUILD_SPHINX_MAN: "NO" cache: key: linux-x86_64-deb8 + +release-x86_64-linux-deb8: + <<: *release + extends: .build-x86_64-linux-deb8 + +################################# +# x86_64-linux-alpine +################################# + +.build-x86_64-linux-alpine-hadrian: + extends: .validate-linux-hadrian + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine:$DOCKER_REV" + # There are currently a few failing tests + allow_failure: true + variables: + TEST_ENV: "x86_64-linux-alpine" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-alpine-linux.tar.xz" + # Can't use ld.gold due to #13958. + CONFIGURE_ARGS: "--disable-ld-override" + HADRIAN_ARGS: "--docs=no-sphinx" + # encoding004 due to lack of locale support + # T10458 due to fact that dynamic linker tries to reload libAS + BROKEN_TESTS: "encoding004 T10458" + cache: + key: linux-x86_64-alpine artifacts: when: always expire_in: 2 week +release-x86_64-linux-alpine: + <<: *release + extends: .build-x86_64-linux-alpine-hadrian + +nightly-x86_64-linux-alpine: + <<: *nightly + extends: .build-x86_64-linux-alpine-hadrian + ################################# # x86_64-linux-centos7 ################################# -release-x86_64-linux-centos7: - <<: *release +.build-x86_64-linux-centos7: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" variables: - # For the testsuite - LANG: "en_US.UTF-8" # The sphinx release shipped with Centos 7 fails to build out documentation BUILD_SPHINX_HTML: "NO" BUILD_SPHINX_PDF: "NO" TEST_ENV: "x86_64-linux-centos7" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz" - allow_failure: true + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-centos7-linux.tar.xz" + # CentOS seems to default to ascii + LANG: "en_US.UTF-8" cache: key: linux-x86_64-centos7 - artifacts: - when: always - expire_in: 2 week + +release-x86_64-linux-centos7: + <<: *release + extends: .build-x86_64-linux-centos7 ################################# # x86_64-linux-fedora27 ################################# -.build-x86_64-linux-fedora27: +validate-x86_64-linux-fedora27: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-fedora27" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: key: linux-x86_64-fedora27 - -validate-x86_64-linux-fedora27: - extends: .build-x86_64-linux-fedora27 artifacts: when: always # These are used for head.hackage jobs therefore we keep them around for # longer. expire_in: 8 week -release-x86_64-linux-fedora27: - <<: *release - extends: .build-x86_64-linux-fedora27 - -release-x86_64-linux-fedora27-dwarf: - <<: *release - extends: .build-x86_64-linux-fedora27 - variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-fedora27-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux-dwarf.tar.xz" - ############################################################ # Validation via Pipelines (Windows) ############################################################ .build-windows: - <<: *only-default + # For the reasons given in #17777 this build isn't reliable. + allow_failure: true before_script: - git clean -xdf - - git submodule foreach git clean -xdf - # Use a local temporary directory to ensure that concurrent builds don't - # interfere with one another - - | - mkdir tmp - set TMP=%cd%\tmp - set TEMP=%cd%\tmp - - - set PATH=C:\msys64\usr\bin;%PATH% - - python .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - bash .gitlab/win32-init.sh + # Setup toolchain + - bash .gitlab/ci.sh setup after_script: - - rd /s /q tmp - - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache - - bash -c 'make clean || true' + - | + Copy-Item -Recurse -Path $Env:APPDATA\cabal -Destination cabal-cache + - bash .gitlab/ci.sh clean dependencies: [] variables: - FORCE_SYMLINKS: 1 + #FORCE_SYMLINKS: 1 LANG: "en_US.UTF-8" SPHINXBUILD: "/mingw64/bin/sphinx-build.exe" + CABAL_INSTALL_VERSION: 3.0.0.0 + GHC_VERSION: "8.8.3" cache: paths: - cabal-cache - - ghc-8.6.2 + - toolchain - ghc-tarballs .build-windows-hadrian: extends: .build-windows stage: full-build - allow_failure: true variables: - GHC_VERSION: "8.8.3" + FLAVOUR: "validate" + # skipping perf tests for now since we build a quick-flavoured GHC, + # which might result in some broken perf tests? + HADRIAN_ARGS: "--docs=no-sphinx --skip-perf" + script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex' - - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist" - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz - # FIXME: Testsuite disabled due to #16156. - # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_hadrian + - bash .gitlab/ci.sh test_hadrian tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: + reports: + junit: junit.xml + expire_in: 2 week when: always paths: - ghc.tar.xz + - junit.xml validate-x86_64-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW64 + TEST_ENV: "x86_64-windows-hadrian" cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" @@ -598,86 +822,94 @@ nightly-i386-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW32 + TEST_ENV: "i386-windows-hadrian" cache: key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" .build-windows-make: extends: .build-windows stage: full-build - # due to #16084 - allow_failure: true variables: - BUILD_FLAVOUR: "UNSET" - GHC_VERSION: "8.8.3" - BUILD_PROF_LIBS: "YES" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz" + BUILD_FLAVOUR: "quick" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-mingw32.tar.xz" script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS' - - bash -c "echo \"include mk/flavours/${BUILD_FLAVOUR}.mk\" > mk/build.mk" - - bash -c "echo \"GhcLibHcOpts+=-haddock\" >> mk/build.mk" - - bash -c "echo \"BUILD_PROF_LIBS = $BUILD_PROF_LIBS\" >> mk/build.mk" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1" - - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_make + - bash .gitlab/ci.sh test_make tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: when: always expire_in: 2 week reports: junit: junit.xml paths: - - ghc-*.tar.xz + # N.B. variable interpolation apparently doesn't work on Windows so + # this can't be $BIN_DIST_PREP_TAR_COMP + - "ghc-x86_64-mingw32.tar.xz" - junit.xml -validate-x86_64-windows: +.build-x86_64-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" - BUILD_FLAVOUR: "quick" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" + TEST_ENV: "x86_64-windows" cache: key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-x86_64-windows: + extends: .build-x86_64-windows-make + +nightly-x86_64-windows: + <<: *nightly + extends: .build-x86_64-windows-make + stage: full-build + variables: + BUILD_FLAVOUR: "validate" + # Normal Windows validate builds are profiled; that won't do for releases. release-x86_64-windows: <<: *release extends: validate-x86_64-windows variables: - MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" - -release-i386-windows: + # +release-x86_64-windows-integer-simple: <<: *release - extends: .build-windows-make + extends: validate-x86_64-windows variables: - MSYSTEM: MINGW32 + INTEGER_LIBRARY: integer-simple BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - # Due to #15934 - BUILD_PROF_LIBS: "NO" - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows: - <<: *nightly + +.build-i386-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW32 - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - BUILD_FLAVOUR: "quick" # Due to #15934 BUILD_PROF_LIBS: "NO" + TEST_ENV: "i386-windows" + # Due to #17736 + allow_failure: true cache: key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-i386-windows: + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +release-i386-windows: + <<: *release + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +nightly-i386-windows: + <<: *nightly + extends: .build-i386-windows-make + ############################################################ # Cleanup ############################################################ @@ -687,40 +919,24 @@ nightly-i386-windows: # # As noted in [1], gitlab-runner's shell executor doesn't clean up its working # directory after builds. Unfortunately, we are forced to use the shell executor -# on Windows. To avoid running out of disk space we add a stage at the end of -# the build to remove the \GitLabRunner\builds directory. Since we only run a -# single build at a time on Windows this should be safe. +# on Darwin. To avoid running out of disk space we add a stage at the end of +# the build to remove the /.../GitLabRunner/builds directory. Since we only run a +# single build at a time on Darwin this should be safe. +# +# We used to have a similar cleanup job on Windows as well however it ended up +# being quite fragile as we have multiple Windows builders yet there is no +# guarantee that the cleanup job is run on the same machine as the build itself +# was run. Consequently we were forced to instead handle cleanup with a separate +# cleanup cron job on Windows. # # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856 -# See Note [Cleanup after shell executor] -cleanup-windows: - <<: *only-default - stage: cleanup - tags: - - x86_64-windows - dependencies: [] - before_script: - - echo "Time to clean up" - script: - - echo "Let's go" - after_script: - - set "BUILD_DIR=%CI_PROJECT_DIR%" - - set "BUILD_DIR=%BUILD_DIR:/=\%" - - echo "Cleaning %BUILD_DIR%" - - cd \GitLabRunner - # This is way more complicated than it should be: - # See https://stackoverflow.com/questions/1965787 - - del %BUILD_DIR%\* /F /Q - - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p" - - exit /b 0 - # See Note [Cleanup after shell executor] cleanup-darwin: - <<: *only-default stage: cleanup tags: - x86_64-darwin + when: always dependencies: [] before_script: - echo "Time to clean up" @@ -737,19 +953,56 @@ cleanup-darwin: # Packaging ############################################################ +doc-tarball: + stage: packaging + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + dependencies: + - validate-x86_64-linux-deb9-debug + - validate-x86_64-windows + variables: + LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz" + WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz" + # Due to Windows allow_failure + allow_failure: true + artifacts: + paths: + - haddock.html.tar.xz + - libraries.html.tar.xz + - users_guide.html.tar.xz + - index.html + - "*.pdf" + script: + - | + if [ ! -f "$LINUX_BINDIST" ]; then + echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" + exit 1 + fi + if [ ! -f "$WINDOWS_BINDIST" ]; then + echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?" + exit 1 + fi + - rm -Rf docs + - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST + - ls -lh + - mv docs/*.tar.xz docs/index.html . + source-tarball: - <<: *release stage: packaging tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" dependencies: [] + rules: + - if: $CI_COMMIT_TAG + when: always artifacts: paths: - ghc-*.tar.xz - version script: - - mk/get-win32-tarballs.sh download all + - python3 mk/get-win32-tarballs.py download all - ./boot - ./configure - make sdist @@ -770,9 +1023,8 @@ source-tarball: # pipeline. .hackage: - <<: *only-default - stage: hackage - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + stage: testing + image: ghcci/x86_64-linux-deb9:0.2 tags: - x86_64-linux dependencies: [] @@ -781,6 +1033,10 @@ source-tarball: script: - bash .gitlab/start-head.hackage.sh +hackage: + extends: .hackage + when: manual + hackage-label: extends: .hackage rules: @@ -790,3 +1046,69 @@ nightly-hackage: <<: *nightly extends: .hackage +############################################################ +# Nofib testing +############################################################ + +perf-nofib: + stage: testing + dependencies: + - validate-x86_64-linux-deb9-dwarf + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + rules: + - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + tags: + - x86_64-linux + script: + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ghc-x86_64-deb9-linux-dwarf.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - cabal update; cabal install -w $BOOT_HC regex-compat + - export PATH=$root/bin:$PATH + - make -C nofib boot mode=fast -j$CPUS + - "make -C nofib EXTRA_RUNTEST_OPTS='-cachegrind +RTS -V0 -RTS' NoFibRuns=1 mode=fast -j$CPUS 2>&1 | tee nofib.log" + artifacts: + expire_in: 12 week + when: always + paths: + - nofib.log + +############################################################ +# Documentation deployment via GitLab Pages +############################################################ + +pages: + stage: deploy + dependencies: + - doc-tarball + image: ghcci/x86_64-linux-deb9:0.2 + # Due to Windows allow_failure + allow_failure: true + tags: + - x86_64-linux + script: + - mkdir -p public/doc + - tar -xf haddock.html.tar.xz -C public/doc + - tar -xf libraries.html.tar.xz -C public/doc + - tar -xf users_guide.html.tar.xz -C public/doc + - | + cat >public/index.html < + + + EOF + - cp -f index.html public/doc + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + artifacts: + paths: + - public ===================================== .gitlab/ci.sh ===================================== @@ -0,0 +1,464 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2230 + +# This is the primary driver of the GitLab CI infrastructure. + +set -e -o pipefail + +# Configuration: +hackage_index_state="@1579718451" + +# Colors +BLACK="0;30" +GRAY="1;30" +RED="0;31" +LT_RED="1;31" +BROWN="0;33" +LT_BROWN="1;33" +GREEN="0;32" +LT_GREEN="1;32" +BLUE="0;34" +LT_BLUE="1;34" +PURPLE="0;35" +LT_PURPLE="1;35" +CYAN="0;36" +LT_CYAN="1;36" +WHITE="1;37" +LT_GRAY="0;37" + +export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 + +# GitLab Pipelines log section delimiters +# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664 +start_section() { + name="$1" + echo -e "section_start:$(date +%s):$name\015\033[0K" +} + +end_section() { + name="$1" + echo -e "section_end:$(date +%s):$name\015\033[0K" +} + +echo_color() { + local color="$1" + local msg="$2" + echo -e "\033[${color}m${msg}\033[0m" +} + +error() { echo_color "${RED}" "$1"; } +warn() { echo_color "${LT_BROWN}" "$1"; } +info() { echo_color "${LT_BLUE}" "$1"; } + +fail() { error "error: $1"; exit 1; } + +function run() { + info "Running $*..." + "$@" || ( error "$* failed"; return 1; ) +} + +TOP="$(pwd)" + +function mingw_init() { + case "$MSYSTEM" in + MINGW32) + triple="i386-unknown-mingw32" + boot_triple="i386-unknown-mingw32" # triple of bootstrap GHC + ;; + MINGW64) + triple="x86_64-unknown-mingw32" + boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC + ;; + *) + fail "win32-init: Unknown MSYSTEM $MSYSTEM" + ;; + esac + + # Bring mingw toolchain into PATH. + # This is extracted from /etc/profile since this script inexplicably fails to + # run under gitlab-runner. + # shellcheck disable=SC1091 + source /etc/msystem + MINGW_MOUNT_POINT="${MINGW_PREFIX}" + PATH="$MINGW_MOUNT_POINT/bin:$PATH" + + # We always use mingw64 Python to avoid path length issues like #17483. + export PYTHON="/mingw64/bin/python3" +} + +# This will contain GHC's local native toolchain +toolchain="$TOP/toolchain" +mkdir -p "$toolchain/bin" +PATH="$toolchain/bin:$PATH" + +export METRICS_FILE="$CI_PROJECT_DIR/performance-metrics.tsv" + +cores="$(mk/detect-cpu-count.sh)" + +# Use a local temporary directory to ensure that concurrent builds don't +# interfere with one another +mkdir -p "$TOP/tmp" +export TMP="$TOP/tmp" +export TEMP="$TOP/tmp" + +function darwin_setup() { + # It looks like we already have python2 here and just installing python3 + # does not work. + brew upgrade python + brew install ghc cabal-install ncurses gmp + + pip3 install sphinx + # PDF documentation disabled as MacTeX apparently doesn't include xelatex. + #brew cask install mactex +} + +function show_tool() { + local tool="$1" + info "$tool = ${!tool}" + ${!tool} --version +} + +function set_toolchain_paths() { + needs_toolchain=1 + case "$(uname)" in + Linux) needs_toolchain="" ;; + *) ;; + esac + + if [[ -n "$needs_toolchain" ]]; then + # These are populated by setup_toolchain + GHC="$toolchain/bin/ghc$exe" + CABAL="$toolchain/bin/cabal$exe" + HAPPY="$toolchain/bin/happy$exe" + ALEX="$toolchain/bin/alex$exe" + else + GHC="$(which ghc)" + CABAL="/usr/local/bin/cabal" + HAPPY="$HOME/.cabal/bin/happy" + ALEX="$HOME/.cabal/bin/alex" + fi + export GHC + export CABAL + export HAPPY + export ALEX +} + +# Extract GHC toolchain +function setup() { + if [ -d "$TOP/cabal-cache" ]; then + info "Extracting cabal cache..." + mkdir -p "$cabal_dir" + cp -Rf cabal-cache/* "$cabal_dir" + fi + + if [[ -n "$needs_toolchain" ]]; then + setup_toolchain + fi + case "$(uname)" in + Darwin) darwin_setup ;; + *) ;; + esac + + # Make sure that git works + git config user.email "ghc-ci at gitlab-haskell.org" + git config user.name "GHC GitLab CI" + + info "=====================================================" + info "Toolchain versions" + info "=====================================================" + show_tool GHC + show_tool CABAL + show_tool HAPPY + show_tool ALEX +} + +function fetch_ghc() { + local v="$GHC_VERSION" + if [[ -z "$v" ]]; then + fail "GHC_VERSION is not set" + fi + + if [ ! -e "$GHC" ]; then + start_section "fetch GHC" + url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple}.tar.xz" + info "Fetching GHC binary distribution from $url..." + curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution" + tar -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution" + case "$(uname)" in + MSYS_*|MINGW*) + cp -r "ghc-${GHC_VERSION}"/* "$toolchain" + ;; + *) + pushd "ghc-${GHC_VERSION}" + ./configure --prefix="$toolchain" + "$MAKE" install + popd + ;; + esac + rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz + end_section "fetch GHC" + fi + +} + +function fetch_cabal() { + local v="$CABAL_INSTALL_VERSION" + if [[ -z "$v" ]]; then + fail "CABAL_INSTALL_VERSION is not set" + fi + + if [ ! -e "$CABAL" ]; then + start_section "fetch GHC" + case "$(uname)" in + # N.B. Windows uses zip whereas all others use .tar.xz + MSYS_*|MINGW*) + case "$MSYSTEM" in + MINGW32) cabal_arch="i386" ;; + MINGW64) cabal_arch="x86_64" ;; + *) fail "unknown MSYSTEM $MSYSTEM" ;; + esac + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-unknown-mingw32.zip" + info "Fetching cabal binary distribution from $url..." + curl "$url" > "$TMP/cabal.zip" + unzip "$TMP/cabal.zip" + mv cabal.exe "$CABAL" + ;; + *) + local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/" + case "$(uname)" in + Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;; + FreeBSD) + #cabal_url="$base_url/cabal-install-$v-x86_64-portbld-freebsd.tar.xz" ;; + cabal_url="http://home.smart-cactus.org/~ben/ghc/cabal-install-3.0.0.0-x86_64-portbld-freebsd.tar.xz" ;; + *) fail "don't know where to fetch cabal-install for $(uname)" + esac + echo "Fetching cabal-install from $cabal_url" + curl "$cabal_url" > cabal.tar.xz + tar -xJf cabal.tar.xz + mv cabal "$toolchain/bin" + ;; + esac + end_section "fetch GHC" + fi +} + +# For non-Docker platforms we prepare the bootstrap toolchain +# here. For Docker platforms this is done in the Docker image +# build. +function setup_toolchain() { + fetch_ghc + fetch_cabal + cabal_install="$CABAL v2-install --index-state=$hackage_index_state --installdir=$toolchain/bin" + # Avoid symlinks on Windows + case "$(uname)" in + MSYS_*|MINGW*) cabal_install="$cabal_install --install-method=copy" ;; + *) ;; + esac + + if [ ! -e "$HAPPY" ]; then + info "Building happy..." + cabal update + $cabal_install happy + fi + + if [ ! -e "$ALEX" ]; then + info "Building alex..." + cabal update + $cabal_install alex + fi +} + +function cleanup_submodules() { + start_section "clean submodules" + info "Cleaning submodules..." + # On Windows submodules can inexplicably get into funky states where git + # believes that the submodule is initialized yet its associated repository + # is not valid. Avoid failing in this case with the following insanity. + git submodule sync --recursive || git submodule deinit --force --all + git submodule update --init --recursive + git submodule foreach git clean -xdf + end_section "clean submodules" +} + +function prepare_build_mk() { + if [[ -z "$BUILD_FLAVOUR" ]]; then fail "BUILD_FLAVOUR is not set"; fi + if [[ -z ${BUILD_SPHINX_HTML:-} ]]; then BUILD_SPHINX_HTML=YES; fi + if [[ -z ${BUILD_SPHINX_PDF:-} ]]; then BUILD_SPHINX_PDF=YES; fi + if [[ -z ${INTEGER_LIBRARY:-} ]]; then INTEGER_LIBRARY=integer-gmp; fi + + cat > mk/build.mk <> mk/build.mk + fi + + case "$(uname)" in + Darwin) echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk ;; + *) ;; + esac + + info "build.mk is:" + cat mk/build.mk +} + +function configure() { + start_section "booting" + run python3 boot + end_section "booting" + + local target_args="" + if [[ -n "$triple" ]]; then + target_args="--target=$triple" + fi + + start_section "configuring" + run ./configure \ + --enable-tarballs-autodownload \ + $target_args \ + $CONFIGURE_ARGS \ + GHC="$GHC" \ + HAPPY="$HAPPY" \ + ALEX="$ALEX" \ + || ( cat config.log; fail "configure failed" ) + end_section "configuring" +} + +function build_make() { + prepare_build_mk + if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then + fail "BIN_DIST_PREP_TAR_COMP is not set" + fi + + echo "include mk/flavours/${BUILD_FLAVOUR}.mk" > mk/build.mk + echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk + run "$MAKE" -j"$cores" $MAKE_ARGS + run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 + ls -lh "$BIN_DIST_PREP_TAR_COMP" +} + +function fetch_perf_notes() { + info "Fetching perf notes..." + "$TOP/.gitlab/test-metrics.sh" pull +} + +function push_perf_notes() { + info "Pushing perf notes..." + "$TOP/.gitlab/test-metrics.sh" push +} + +function test_make() { + run "$MAKE" test_bindist TEST_PREP=YES + run "$MAKE" V=0 test \ + THREADS="$cores" \ + JUNIT_FILE=../../junit.xml +} + +function build_hadrian() { + if [ -z "$FLAVOUR" ]; then + fail "FLAVOUR not set" + fi + + run_hadrian binary-dist + + mv _build/bindist/ghc*.tar.xz ghc.tar.xz +} + +function test_hadrian() { + cd _build/bindist/ghc-*/ + run ./configure --prefix="$TOP"/_build/install + run "$MAKE" install + cd ../../../ + + run_hadrian \ + test \ + --summary-junit=./junit.xml \ + --test-compiler="$TOP"/_build/install/bin/ghc +} + +function clean() { + rm -R tmp + run "$MAKE" --quiet clean || true + run rm -Rf _build +} + +function run_hadrian() { + run hadrian/build-cabal \ + --flavour="$FLAVOUR" \ + -j"$cores" \ + --broken-test="$BROKEN_TESTS" \ + $HADRIAN_ARGS \ + $@ +} + +# A convenience function to allow debugging in the CI environment. +function shell() { + local cmd=$@ + if [ -z "$cmd" ]; then + cmd="bash -i" + fi + run $cmd +} + +# Determine Cabal data directory +case "$(uname)" in + MSYS_*|MINGW*) exe=".exe"; cabal_dir="$APPDATA/cabal" ;; + *) cabal_dir="$HOME/.cabal"; exe="" ;; +esac + +# Platform-specific environment initialization +MAKE="make" +case "$(uname)" in + MSYS_*|MINGW*) mingw_init ;; + Darwin) boot_triple="x86_64-apple-darwin" ;; + FreeBSD) + boot_triple="x86_64-portbld-freebsd" + MAKE="gmake" + ;; + Linux) ;; + *) fail "uname $(uname) is not supported" ;; +esac + +set_toolchain_paths + +case $1 in + setup) setup && cleanup_submodules ;; + configure) configure ;; + build_make) build_make ;; + test_make) + fetch_perf_notes + res=0 + test_make || res=$? + push_perf_notes + exit $res ;; + build_hadrian) build_hadrian ;; + # N.B. Always push notes, even if the build fails. This is okay to do as the + # testsuite driver doesn't record notes for tests that fail due to + # correctness. + test_hadrian) + fetch_perf_notes + res=0 + test_hadrian || res=$? + push_perf_notes + exit $res ;; + run_hadrian) run_hadrian $@ ;; + clean) clean ;; + shell) shell $@ ;; + *) fail "unknown mode $1" ;; +esac ===================================== .gitlab/darwin-init.sh deleted ===================================== @@ -1,41 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $HOME/.cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - mkdir -p tmp - cd tmp - ghc_tarball="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-x86_64-apple-darwin.tar.xz" - echo "Fetching GHC from $ghc_tarball" - curl $ghc_tarball | tar -xJ - cd ghc-$GHC_VERSION - ./configure --prefix=$toolchain - make install - cd ../.. - rm -Rf tmp -fi - -if [ ! -e $toolchain/bin/cabal ]; then - cabal_tarball="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL_VERSION/cabal-install-$CABAL_INSTALL_VERSION-x86_64-apple-darwin-sierra.tar.xz" - echo "Fetching cabal-install from $cabal_tarball" - curl $cabal_tarball | tar -xz - mv cabal $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal new-install happy --symlink-bindir=$toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal new-install alex --symlink-bindir=$toolchain/bin -fi - ===================================== .gitlab/linters/check-makefiles.py ===================================== @@ -1,5 +1,11 @@ #!/usr/bin/env python3 +""" +Linters for testsuite makefiles +""" + +from linter import run_linters, RegexpLinter + """ Warn for use of `--interactive` inside Makefiles (#11468). @@ -7,13 +13,21 @@ Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to forget one of those flags when adding a new test. """ +interactive_linter = \ + RegexpLinter(r'--interactive', + message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`." + ).add_path_filter(lambda path: path.name == 'Makefile') -from linter import run_linters, RegexpLinter +test_hc_quotes_linter = \ + RegexpLinter('\t\\$\\(TEST_HC\\)', + message = "Warning: $(TEST_HC) should be quoted in Makefiles.", + ).add_path_filter(lambda path: path.name == 'Makefile') linters = [ - RegexpLinter(r'--interactive', - message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`.") + interactive_linter, + test_hc_quotes_linter, ] if __name__ == '__main__': - run_linters(linters) #$, subdir='testsuite') + run_linters(linters, + subdir='testsuite') ===================================== .gitlab/linters/check-version-number.sh ===================================== @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +grep -E -q '\[[0-9]+\.[0-9]+\.[0-9]+\]' configure.ac || + ( echo "error: configure.ac: GHC version number must have three components."; exit 1 ) ===================================== .gitlab/linters/linter.py ===================================== @@ -7,10 +7,11 @@ import sys import re import textwrap import subprocess -from typing import List, Optional +from pathlib import Path +from typing import List, Optional, Callable, Sequence from collections import namedtuple -def lint_failure(file, line_no, line_content, message): +def lint_failure(file, line_no: int, line_content: str, message: str): """ Print a lint failure message. """ wrapper = textwrap.TextWrapper(initial_indent=' ', subsequent_indent=' ') @@ -29,7 +30,7 @@ def lint_failure(file, line_no, line_content, message): print(textwrap.dedent(msg)) -def get_changed_files(base_commit, head_commit, +def get_changed_files(base_commit: str, head_commit: str, subdir: str = '.'): """ Get the files changed by the given range of commits. """ cmd = ['git', 'diff', '--name-only', @@ -46,12 +47,21 @@ class Linter(object): """ def __init__(self): self.warnings = [] # type: List[Warning] + self.path_filters = [] # type: List[Callable[[Path], bool]] def add_warning(self, w: Warning): self.warnings.append(w) - def lint(self, path): - pass + def add_path_filter(self, f: Callable[[Path], bool]) -> "Linter": + self.path_filters.append(f) + return self + + def do_lint(self, path: Path): + if all(f(path) for f in self.path_filters): + self.lint(path) + + def lint(self, path: Path): + raise NotImplementedError class LineLinter(Linter): """ @@ -59,44 +69,55 @@ class LineLinter(Linter): the given line from a file and calls :func:`add_warning` for any lint issues found. """ - def lint(self, path): - if os.path.isfile(path): - with open(path, 'r') as f: + def lint(self, path: Path): + if path.is_file(): + with path.open('r') as f: for line_no, line in enumerate(f): self.lint_line(path, line_no+1, line) - def lint_line(self, path, line_no, line): - pass + def lint_line(self, path: Path, line_no: int, line: str): + raise NotImplementedError class RegexpLinter(LineLinter): """ A :class:`RegexpLinter` produces the given warning message for all lines matching the given regular expression. """ - def __init__(self, regex, message): + def __init__(self, regex: str, message: str): LineLinter.__init__(self) self.re = re.compile(regex) self.message = message - def lint_line(self, path, line_no, line): + def lint_line(self, path: Path, line_no: int, line: str): if self.re.search(line): w = Warning(path=path, line_no=line_no, line_content=line[:-1], message=self.message) self.add_warning(w) -def run_linters(linters: List[Linter], +def run_linters(linters: Sequence[Linter], subdir: str = '.') -> None: import argparse parser = argparse.ArgumentParser() - parser.add_argument('base', help='Base commit') - parser.add_argument('head', help='Head commit') + subparsers = parser.add_subparsers() + + subparser = subparsers.add_parser('commits', help='Lint a range of commits') + subparser.add_argument('base', help='Base commit') + subparser.add_argument('head', help='Head commit') + subparser.set_defaults(get_linted_files=lambda args: + get_changed_files(args.base, args.head, subdir)) + + subparser = subparsers.add_parser('files', help='Lint a range of commits') + subparser.add_argument('file', nargs='+', help='File to lint') + subparser.set_defaults(get_linted_files=lambda args: args.file) + args = parser.parse_args() - for path in get_changed_files(args.base, args.head, subdir): + linted_files = args.get_linted_files(args) + for path in linted_files: if path.startswith('.gitlab/linters'): continue for linter in linters: - linter.lint(path) + linter.do_lint(Path(path)) warnings = [warning for linter in linters ===================================== .gitlab/win32-init.sh deleted ===================================== @@ -1,50 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:/mingw64/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $APPDATA/cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - case $MSYSTEM in - MINGW32) - triple="i386-unknown-mingw32" - ;; - MINGW64) - triple="x86_64-unknown-mingw32" - ;; - *) - echo "win32-init: Unknown MSYSTEM $MSYSTEM" - exit 1 - ;; - esac - if [ -z "$GHC_TARBALL_URL" ]; then - GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" - fi - curl "$GHC_TARBALL_URL" | tar -xJ - mv ghc-$GHC_VERSION toolchain -fi - -if [ ! -e $toolchain/bin/cabal ]; then - url="https://downloads.haskell.org/~cabal/cabal-install-2.4.1.0/cabal-install-2.4.1.0-x86_64-unknown-mingw32.zip" - curl $url > /tmp/cabal.zip - unzip /tmp/cabal.zip - mv cabal.exe $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal install happy - cp $APPDATA/cabal/bin/happy $toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal install alex - cp $APPDATA/cabal/bin/alex $toolchain/bin -fi - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f52e0ca0cc0430da4d30de4228844f92c89226b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f52e0ca0cc0430da4d30de4228844f92c89226b You're receiving 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 Jul 11 16:59:19 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 12:59:19 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] Backport CI infrastructure rework Message-ID: <5f09efe7e048_80b3f849ba1b94026601c3@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 90549bb1 by Ben Gamari at 2020-07-11T12:59:05-04:00 Backport CI infrastructure rework - - - - - 8 changed files: - .gitlab-ci.yml - + .gitlab/ci.sh - − .gitlab/darwin-init.sh - .gitlab/linters/check-makefiles.py - + .gitlab/linters/check-version-number.sh - .gitlab/linters/linter.py - − .gitlab/win32-init.sh - + hadrian/ci.project Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,59 +2,45 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a + DOCKER_REV: 6223fe0b5942f4fa35bdec92c74566cf195bfb42 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/win32-init.sh. + # .gitlab/ci.sh. WINDOWS_TOOLCHAIN_VERSION: 1 -before_script: - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + # Disable shallow clones; they break our linting rules + GIT_DEPTH: 0 + + # Overridden by individual jobs + CONFIGURE_ARGS: "" + + GIT_SUBMODULE_STRATEGY: "recursive" stages: - - lint # Source linting - - build # A quick smoke-test to weed out broken commits - - full-build # Build all the things - - cleanup # See Note [Cleanup on Windows] - - packaging # Source distribution, etc. - - hackage # head.hackage testing - - deploy # push documentation - -.only-default: &only-default - rules: - - if: $CI_MERGE_REQUEST_ID - - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "master"' - - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - - if: '$CI_PIPELINE_SOURCE == "web"' + - lint # Source linting + - quick-build # A very quick smoke-test to weed out broken commits + - build # A quick smoke-test to weed out broken commits + - full-build # Build all the things + - cleanup # See Note [Cleanup after the shell executor] + - packaging # Source distribution, etc. + - testing # head.hackage correctness and compiler performance testing + - deploy # push documentation workflow: - # N.B. Don't run on wip/ branches, instead on run on merge requests. + # N.B.Don't run on wip/ branches, instead on run on merge requests. rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' -############################################################ -# Runner Tags -############################################################ -# -# * x86_64-linux: Any Docker-capable x86_64 Linux machine -# * aarch64-linux: Any Docker-capable AArch64 Linux machine -# * x86_64-windows: A x86_64 Windows machine -# * lint: Any Docker-capable x86_64 Linux machine; distinct from -# x86_64-linux to ensure low-latency availability. -# - .nightly: &nightly rules: - if: $NIGHTLY + artifacts: + when: always + expire_in: 8 weeks .release: &release variables: @@ -66,53 +52,105 @@ workflow: rules: - if: '$RELEASE == "yes"' +############################################################ +# Runner Tags +############################################################ +# +# * x86_64-linux: Any Docker-capable x86_64 Linux machine +# * aarch64-linux: Any Docker-capable AArch64 Linux machine +# * x86_64-windows: A x86_64 Windows machine +# * lint: Any Docker-capable x86_64 Linux machine; distinct from +# x86_64-linux to ensure low-latency availability. +# + ############################################################ # Linting ############################################################ ghc-linters: - allow_failure: true stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" - - "echo Merge base $base" + - "echo Linting changes between $base..$CI_COMMIT_SHA" # - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA) - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA) - - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA - - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA + - .gitlab/linters/check-makefiles.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-cpp.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-version-number.sh + - python3 utils/checkUniques/check-uniques.py . dependencies: [] tags: - lint rules: - if: $CI_MERGE_REQUEST_ID +# Run mypy Python typechecker on linter scripts. +lint-linters: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy .gitlab/linters/*.py + dependencies: [] + tags: + - lint + +# Check that .T files all parse by listing broken tests. +lint-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + script: + - make -Ctestsuite list_broken TEST_HC=ghc + dependencies: [] + tags: + - lint + +# Run mypy Python typechecker on testsuite driver +.typecheck-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy testsuite/driver/runtests.py + dependencies: [] + tags: + - lint + # We allow the submodule checker to fail when run on merge requests (to -# accomodate, e.g., haddock changes not yet upstream) but not on `master` or +# accommodate, e.g., haddock changes not yet upstream) but not on `master` or # Marge jobs. .lint-submods: stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA) + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" + - "echo Linting submodule changes between $base..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $base..$CI_COMMIT_SHA) dependencies: [] tags: - lint lint-submods: extends: .lint-submods + # Allow failure on merge requests since any necessary submodule patches may + # not be upstreamed yet. rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/' allow_failure: false - allow_failure: true -lint-submods-mr: +lint-submods-branch: extends: .lint-submods - allow_failure: true + script: + - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA) rules: - - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' .lint-changelogs: stage: lint @@ -125,6 +163,7 @@ lint-submods-mr: lint-changelogs: extends: .lint-changelogs + # Allow failure since this isn't a final release. allow_failure: true rules: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' @@ -140,71 +179,183 @@ lint-release-changelogs: ############################################################ .validate-hadrian: - <<: *only-default - allow_failure: true + variables: + FLAVOUR: "validate" script: - - cabal update - - git clean -xdf && git submodule foreach git clean -xdf - - bash .circleci/prepare-system.sh - - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi - - ./boot - - ./configure $CONFIGURE_ARGS - - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian cache: key: hadrian paths: - cabal-cache artifacts: - when: always + reports: + junit: junit.xml + expire_in: 2 week paths: - ghc.tar.xz + - junit.xml -validate-x86_64-linux-deb8-hadrian: +.validate-linux-hadrian: extends: .validate-hadrian - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + variables: + TEST_ENV: "x86_64-linux-deb9-hadrian" before_script: # workaround for docker permissions - sudo chown ghc:ghc -R . - - python3 .gitlab/fix-submodules.py - git submodule sync --recursive - git submodule update --init --recursive - git checkout .gitmodules - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + after_script: + - .gitlab/ci.sh clean tags: - x86_64-linux +validate-x86_64-linux-deb9-hadrian: + extends: .validate-linux-hadrian + stage: build + +validate-x86_64-linux-deb9-unreg-hadrian: + extends: .validate-linux-hadrian + stage: full-build + variables: + CONFIGURE_ARGS: --enable-unregisterised + TEST_ENV: "x86_64-linux-deb9-unreg-hadrian" + +hadrian-ghc-in-ghci: + stage: quick-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + variables: + GHC_FLAGS: -Werror + tags: + - x86_64-linux + script: + - cabal update + - cd hadrian; cabal new-build --project-file=ci.project; cd .. + - git clean -xdf && git submodule foreach git clean -xdf + - .gitlab/ci.sh setup + - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi + - ./boot + - ./configure $CONFIGURE_ARGS + # 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," + cache: + key: hadrian-ghci + paths: + - cabal-cache ############################################################ # Validation via Pipelines (make) ############################################################ .validate: - <<: *only-default variables: TEST_TYPE: test - before_script: - - git clean -xdf && git submodule foreach git clean -xdf + MAKE_ARGS: "-Werror" script: - - ./boot - - ./configure $CONFIGURE_ARGS - - | - THREADS=`mk/detect-cpu-count.sh` - make V=0 -j$THREADS WERROR=-Werror - - | - make binary-dist TAR_COMP_OPTS="-1" - - | - THREADS=`mk/detect-cpu-count.sh` - make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_make + - .gitlab/ci.sh test_make dependencies: [] artifacts: reports: junit: junit.xml expire_in: 2 week paths: - - ghc-*.tar.xz + - $BIN_DIST_PREP_TAR_COMP - junit.xml + - performance-metrics.tsv + +################################# +# x86_64-freebsd +################################# + +.build-x86_64-freebsd: + extends: .validate + tags: + - x86_64-freebsd + allow_failure: true + variables: + # N.B. we use iconv from ports as I see linker errors when we attempt + # to use the "native" iconv embedded in libc as suggested by the + # porting guide [1]. + # [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + GHC_VERSION: 8.10.1 + CABAL_INSTALL_VERSION: 3.2.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd" + BUILD_FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Conditional due to lack of builder capacity +validate-x86_64-freebsd: + extends: .build-x86_64-freebsd + stage: full-build + rules: + - if: '$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/' + +nightly-x86_64-freebsd: + <<: *nightly + extends: .build-x86_64-freebsd + stage: full-build + +release-x86_64-freebsd: + <<: *release + extends: .build-x86_64-freebsd + stage: full-build + +.build-x86_64-freebsd-hadrian: + extends: .validate-hadrian + stage: full-build + tags: + - x86_64-freebsd + allow_failure: true + variables: + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + HADRIAN_ARGS: "--docs=no-sphinx" + GHC_VERSION: 8.6.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd-hadrian" + FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Disabled due to lack of builder capacity +.validate-x86_64-freebsd-hadrian: + extends: .build-x86_64-freebsd-hadrian + stage: full-build ################################# # x86_64-darwin @@ -216,54 +367,71 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: "8.8.3" - CABAL_INSTALL_VERSION: 2.4.1.0 - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz" + GHC_VERSION: 8.8.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-apple-darwin.tar.xz" MACOSX_DEPLOYMENT_TARGET: "10.7" # Only Sierra and onwards supports clock_gettime. See #12858 ac_cv_func_clock_gettime: "no" LANG: "en_US.UTF-8" - CONFIGURE_ARGS: --with-intree-gmp + CONFIGURE_ARGS: "--with-intree-gmp" TEST_ENV: "x86_64-darwin" - before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - - bash .gitlab/darwin-init.sh - - PATH="`pwd`/toolchain/bin:$PATH" + BUILD_FLAVOUR: "perf" after_script: - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean artifacts: when: always expire_in: 2 week cache: - key: darwin + key: "darwin-$GHC_VERSION" paths: - cabal-cache - toolchain +# Disabled because of OS X CI capacity +.validate-x86_64-darwin-hadrian: + stage: full-build + tags: + - x86_64-darwin + variables: + GHC_VERSION: 8.8.3 + MACOSX_DEPLOYMENT_TARGET: "10.7" + ac_cv_func_clock_gettime: "no" + LANG: "en_US.UTF-8" + CONFIGURE_ARGS: --with-intree-gmp + TEST_ENV: "x86_64-darwin-hadrian" + FLAVOUR: "validate" + script: + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + reports: + junit: junit.xml + paths: + - ghc.tar.xz + - junit.xml + .validate-linux: extends: .validate tags: - x86_64-linux + variables: + BUILD_FLAVOUR: "perf" before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" # Build hyperlinked sources for documentation when building releases - | if [[ -n "$CI_COMMIT_TAG" ]]; then - echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk + HADDOCK_HYPERLINKED_SOURCES=1 fi - - bash .circleci/prepare-system.sh # workaround for docker permissions - sudo chown ghc:ghc -R . after_script: @@ -285,9 +453,7 @@ validate-x86_64-darwin: allow_failure: true variables: TEST_ENV: "aarch64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz" - # Inexplicably makeindex fails - BUILD_SPHINX_PDF: "NO" + BIN_DIST_PREP_TAR_COMP: "ghc-aarch64-linux-deb9.tar.xz" cache: key: linux-aarch64-deb9 tags: @@ -302,8 +468,41 @@ validate-aarch64-linux-deb9: nightly-aarch64-linux-deb9: <<: *nightly extends: .build-aarch64-linux-deb9 + variables: + TEST_TYPE: slowtest + +################################# +# armv7-linux-deb9 +################################# + +.build-armv7-linux-deb9: + extends: .validate-linux + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb9:$DOCKER_REV" + # Due to linker issues + allow_failure: true + variables: + TEST_ENV: "armv7-linux-deb9" + BIN_DIST_PREP_TAR_COMP: "ghc-armv7-linux-deb9.tar.xz" + CONFIGURE_ARGS: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" + # N.B. We disable ld.lld explicitly here because it appears to fail + # non-deterministically on ARMv7. See #18280. + LD: "ld.gold" + GccUseLdOpt: "-fuse-ld=gold" + cache: + key: linux-armv7-deb9 + tags: + - armv7-linux + +validate-armv7-linux-deb9: + extends: .build-armv7-linux-deb9 artifacts: - expire_in: 2 year + when: always + expire_in: 2 week + +nightly-armv7-linux-deb9: + <<: *nightly + extends: .build-armv7-linux-deb9 variables: TEST_TYPE: slowtest @@ -317,7 +516,7 @@ nightly-aarch64-linux-deb9: image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "i386-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-i386-deb9-linux.tar.xz" cache: key: linux-i386-deb9 @@ -332,23 +531,6 @@ nightly-i386-linux-deb9: extends: .build-i386-linux-deb9 variables: TEST_TYPE: slowtest - artifacts: - when: always - expire_in: 2 week - -################################# -# x86_64-linux-deb10 -################################# - -.build-x86_64-linux-deb10: - extends: .validate-linux - stage: full-build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - variables: - TEST_ENV: "x86_64-linux-deb10" - BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" - cache: - key: linux-x86_64-deb10 ################################# # x86_64-linux-deb9 @@ -356,40 +538,62 @@ nightly-i386-linux-deb9: .build-x86_64-linux-deb9: extends: .validate-linux - stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb9-linux.tar.xz" cache: key: linux-x86_64-deb9 -validate-x86_64-linux-deb9: +# Disabled to reduce CI load +.validate-x86_64-linux-deb9: extends: .build-x86_64-linux-deb9 + stage: full-build artifacts: when: always expire_in: 2 week +release-x86_64-linux-deb9: + <<: *release + extends: .build-x86_64-linux-deb9 + stage: full-build + nightly-x86_64-linux-deb9: <<: *nightly extends: .build-x86_64-linux-deb9 - artifacts: - expire_in: 2 year + stage: full-build variables: TEST_TYPE: slowtest # N.B. Has DEBUG assertions enabled in stage2 validate-x86_64-linux-deb9-debug: extends: .build-x86_64-linux-deb9 - stage: build + stage: full-build variables: BUILD_FLAVOUR: validate + # Ensure that stage2 also has DEBUG enabled + ValidateSpeed: SLOW + # Override validate flavour default; see #16890. + BUILD_SPHINX_PDF: "YES" + TEST_TYPE: slowtest TEST_ENV: "x86_64-linux-deb9-debug" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-debug.tar.xz" + artifacts: + when: always + expire_in: 2 week -validate-x86_64-linux-deb9-llvm: +# Disabled to alleviate CI load +.validate-x86_64-linux-deb9-llvm: + extends: .build-x86_64-linux-deb9 + stage: full-build + variables: + BUILD_FLAVOUR: perf-llvm + TEST_ENV: "x86_64-linux-deb9-llvm" + +nightly-x86_64-linux-deb9-llvm: + <<: *nightly extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: BUILD_FLAVOUR: perf-llvm TEST_ENV: "x86_64-linux-deb9-llvm" @@ -397,11 +601,11 @@ validate-x86_64-linux-deb9-llvm: validate-x86_64-linux-deb9-integer-simple: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: + BUILD_FLAVOUR: validate INTEGER_LIBRARY: integer-simple - TEST_ENV: "x86_64-linux-deb9-integer-simple" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz" + TEST_ENV: "x86_64-linux-deb9-integer-simple-validate" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-integer-simple.tar.xz" nightly-x86_64-linux-deb9-integer-simple: <<: *nightly @@ -411,185 +615,205 @@ nightly-x86_64-linux-deb9-integer-simple: INTEGER_LIBRARY: integer-simple TEST_ENV: "x86_64-linux-deb9-integer-simple" TEST_TYPE: slowtest - artifacts: - expire_in: 2 year -validate-x86_64-linux-deb9-unreg: +validate-x86_64-linux-deb9-dwarf: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: - CONFIGURE_ARGS: --enable-unregisterised - TEST_ENV: "x86_64-linux-deb9-unreg" + CONFIGURE_ARGS: "--enable-dwarf-unwind" + BUILD_FLAVOUR: dwarf + TEST_ENV: "x86_64-linux-deb9-dwarf" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-dwarf.tar.xz" + +################################# +# x86_64-linux-deb10 +################################# -release-x86_64-linux-deb9-dwarf: +.build-x86_64-linux-deb10: extends: .validate-linux - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" - allow_failure: true + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb9" - artifacts: - when: always - expire_in: 2 week + TEST_ENV: "x86_64-linux-deb10" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" cache: - key: linux-x86_64-deb9 + key: linux-x86_64-deb10 +# Disabled to alleviate CI load +.validate-x86_64-linux-deb10: + extends: .build-x86_64-linux-deb10 + stage: full-build -release-x86_64-linux-deb10-dwarf: - <<: *release +nightly-x86_64-linux-deb10: + <<: *nightly extends: .build-x86_64-linux-deb10 variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb10-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb10-linux-dwarf.tar.xz" + TEST_TYPE: slowtest + +release-x86_64-linux-deb10: + <<: *release + extends: .build-x86_64-linux-deb10 ################################# # x86_64-linux-deb8 ################################# -release-x86_64-linux-deb8: - <<: *release +.build-x86_64-linux-deb8: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + # Due to #18298. + allow_failure: true variables: TEST_ENV: "x86_64-linux-deb8" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz" - # Disable sphinx PDF output as our Debian image doesn't have the requisite packages + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb8-linux.tar.xz" + # Debian 8's Sphinx is too old to support the table directive's :widths: + # option: https://sourceforge.net/p/docutils/patches/120/ + BUILD_SPHINX_HTML: "NO" + BUILD_SPHINX_INFO: "NO" BUILD_SPHINX_PDF: "NO" + BUILD_SPHINX_MAN: "NO" cache: key: linux-x86_64-deb8 + +release-x86_64-linux-deb8: + <<: *release + extends: .build-x86_64-linux-deb8 + +################################# +# x86_64-linux-alpine +################################# + +.build-x86_64-linux-alpine-hadrian: + extends: .validate-linux-hadrian + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine:$DOCKER_REV" + # There are currently a few failing tests + allow_failure: true + variables: + TEST_ENV: "x86_64-linux-alpine" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-alpine-linux.tar.xz" + # Can't use ld.gold due to #13958. + CONFIGURE_ARGS: "--disable-ld-override" + HADRIAN_ARGS: "--docs=no-sphinx" + # encoding004 due to lack of locale support + # T10458 due to fact that dynamic linker tries to reload libAS + BROKEN_TESTS: "encoding004 T10458" + cache: + key: linux-x86_64-alpine artifacts: when: always expire_in: 2 week +release-x86_64-linux-alpine: + <<: *release + extends: .build-x86_64-linux-alpine-hadrian + +nightly-x86_64-linux-alpine: + <<: *nightly + extends: .build-x86_64-linux-alpine-hadrian + ################################# # x86_64-linux-centos7 ################################# -release-x86_64-linux-centos7: - <<: *release +.build-x86_64-linux-centos7: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" variables: - # For the testsuite - LANG: "en_US.UTF-8" # The sphinx release shipped with Centos 7 fails to build out documentation BUILD_SPHINX_HTML: "NO" BUILD_SPHINX_PDF: "NO" TEST_ENV: "x86_64-linux-centos7" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz" - allow_failure: true + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-centos7-linux.tar.xz" + # CentOS seems to default to ascii + LANG: "en_US.UTF-8" cache: key: linux-x86_64-centos7 - artifacts: - when: always - expire_in: 2 week + +release-x86_64-linux-centos7: + <<: *release + extends: .build-x86_64-linux-centos7 ################################# # x86_64-linux-fedora27 ################################# -.build-x86_64-linux-fedora27: +validate-x86_64-linux-fedora27: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-fedora27" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: key: linux-x86_64-fedora27 - -validate-x86_64-linux-fedora27: - extends: .build-x86_64-linux-fedora27 artifacts: when: always # These are used for head.hackage jobs therefore we keep them around for # longer. expire_in: 8 week -release-x86_64-linux-fedora27: - <<: *release - extends: .build-x86_64-linux-fedora27 - -release-x86_64-linux-fedora27-dwarf: - <<: *release - extends: .build-x86_64-linux-fedora27 - variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-fedora27-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux-dwarf.tar.xz" - ############################################################ # Validation via Pipelines (Windows) ############################################################ .build-windows: - <<: *only-default + # For the reasons given in #17777 this build isn't reliable. + allow_failure: true before_script: - git clean -xdf - - git submodule foreach git clean -xdf - # Use a local temporary directory to ensure that concurrent builds don't - # interfere with one another - - | - mkdir tmp - set TMP=%cd%\tmp - set TEMP=%cd%\tmp - - - set PATH=C:\msys64\usr\bin;%PATH% - - python .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - bash .gitlab/win32-init.sh + # Setup toolchain + - bash .gitlab/ci.sh setup after_script: - - rd /s /q tmp - - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache - - bash -c 'make clean || true' + - | + Copy-Item -Recurse -Path $Env:APPDATA\cabal -Destination cabal-cache + - bash .gitlab/ci.sh clean dependencies: [] variables: - FORCE_SYMLINKS: 1 + #FORCE_SYMLINKS: 1 LANG: "en_US.UTF-8" SPHINXBUILD: "/mingw64/bin/sphinx-build.exe" + CABAL_INSTALL_VERSION: 3.0.0.0 + GHC_VERSION: "8.8.3" cache: paths: - cabal-cache - - ghc-8.6.2 + - toolchain - ghc-tarballs .build-windows-hadrian: extends: .build-windows stage: full-build - allow_failure: true variables: - GHC_VERSION: "8.8.3" + FLAVOUR: "validate" + # skipping perf tests for now since we build a quick-flavoured GHC, + # which might result in some broken perf tests? + HADRIAN_ARGS: "--docs=no-sphinx --skip-perf" + script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex' - - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist" - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz - # FIXME: Testsuite disabled due to #16156. - # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_hadrian + - bash .gitlab/ci.sh test_hadrian tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: + reports: + junit: junit.xml + expire_in: 2 week when: always paths: - ghc.tar.xz + - junit.xml validate-x86_64-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW64 + TEST_ENV: "x86_64-windows-hadrian" cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" @@ -598,86 +822,94 @@ nightly-i386-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW32 + TEST_ENV: "i386-windows-hadrian" cache: key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" .build-windows-make: extends: .build-windows stage: full-build - # due to #16084 - allow_failure: true variables: - BUILD_FLAVOUR: "UNSET" - GHC_VERSION: "8.8.3" - BUILD_PROF_LIBS: "YES" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz" + BUILD_FLAVOUR: "quick" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-mingw32.tar.xz" script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS' - - bash -c "echo \"include mk/flavours/${BUILD_FLAVOUR}.mk\" > mk/build.mk" - - bash -c "echo \"GhcLibHcOpts+=-haddock\" >> mk/build.mk" - - bash -c "echo \"BUILD_PROF_LIBS = $BUILD_PROF_LIBS\" >> mk/build.mk" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1" - - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_make + - bash .gitlab/ci.sh test_make tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: when: always expire_in: 2 week reports: junit: junit.xml paths: - - ghc-*.tar.xz + # N.B. variable interpolation apparently doesn't work on Windows so + # this can't be $BIN_DIST_PREP_TAR_COMP + - "ghc-x86_64-mingw32.tar.xz" - junit.xml -validate-x86_64-windows: +.build-x86_64-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" - BUILD_FLAVOUR: "quick" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" + TEST_ENV: "x86_64-windows" cache: key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-x86_64-windows: + extends: .build-x86_64-windows-make + +nightly-x86_64-windows: + <<: *nightly + extends: .build-x86_64-windows-make + stage: full-build + variables: + BUILD_FLAVOUR: "validate" + # Normal Windows validate builds are profiled; that won't do for releases. release-x86_64-windows: <<: *release extends: validate-x86_64-windows variables: - MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" - -release-i386-windows: + # +release-x86_64-windows-integer-simple: <<: *release - extends: .build-windows-make + extends: validate-x86_64-windows variables: - MSYSTEM: MINGW32 + INTEGER_LIBRARY: integer-simple BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - # Due to #15934 - BUILD_PROF_LIBS: "NO" - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows: - <<: *nightly + +.build-i386-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW32 - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - BUILD_FLAVOUR: "quick" # Due to #15934 BUILD_PROF_LIBS: "NO" + TEST_ENV: "i386-windows" + # Due to #17736 + allow_failure: true cache: key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-i386-windows: + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +release-i386-windows: + <<: *release + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +nightly-i386-windows: + <<: *nightly + extends: .build-i386-windows-make + ############################################################ # Cleanup ############################################################ @@ -687,40 +919,24 @@ nightly-i386-windows: # # As noted in [1], gitlab-runner's shell executor doesn't clean up its working # directory after builds. Unfortunately, we are forced to use the shell executor -# on Windows. To avoid running out of disk space we add a stage at the end of -# the build to remove the \GitLabRunner\builds directory. Since we only run a -# single build at a time on Windows this should be safe. +# on Darwin. To avoid running out of disk space we add a stage at the end of +# the build to remove the /.../GitLabRunner/builds directory. Since we only run a +# single build at a time on Darwin this should be safe. +# +# We used to have a similar cleanup job on Windows as well however it ended up +# being quite fragile as we have multiple Windows builders yet there is no +# guarantee that the cleanup job is run on the same machine as the build itself +# was run. Consequently we were forced to instead handle cleanup with a separate +# cleanup cron job on Windows. # # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856 -# See Note [Cleanup after shell executor] -cleanup-windows: - <<: *only-default - stage: cleanup - tags: - - x86_64-windows - dependencies: [] - before_script: - - echo "Time to clean up" - script: - - echo "Let's go" - after_script: - - set "BUILD_DIR=%CI_PROJECT_DIR%" - - set "BUILD_DIR=%BUILD_DIR:/=\%" - - echo "Cleaning %BUILD_DIR%" - - cd \GitLabRunner - # This is way more complicated than it should be: - # See https://stackoverflow.com/questions/1965787 - - del %BUILD_DIR%\* /F /Q - - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p" - - exit /b 0 - # See Note [Cleanup after shell executor] cleanup-darwin: - <<: *only-default stage: cleanup tags: - x86_64-darwin + when: always dependencies: [] before_script: - echo "Time to clean up" @@ -737,19 +953,56 @@ cleanup-darwin: # Packaging ############################################################ +doc-tarball: + stage: packaging + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + dependencies: + - validate-x86_64-linux-deb9-debug + - validate-x86_64-windows + variables: + LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz" + WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz" + # Due to Windows allow_failure + allow_failure: true + artifacts: + paths: + - haddock.html.tar.xz + - libraries.html.tar.xz + - users_guide.html.tar.xz + - index.html + - "*.pdf" + script: + - | + if [ ! -f "$LINUX_BINDIST" ]; then + echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" + exit 1 + fi + if [ ! -f "$WINDOWS_BINDIST" ]; then + echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?" + exit 1 + fi + - rm -Rf docs + - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST + - ls -lh + - mv docs/*.tar.xz docs/index.html . + source-tarball: - <<: *release stage: packaging tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" dependencies: [] + rules: + - if: $CI_COMMIT_TAG + when: always artifacts: paths: - ghc-*.tar.xz - version script: - - mk/get-win32-tarballs.sh download all + - python3 mk/get-win32-tarballs.py download all - ./boot - ./configure - make sdist @@ -770,9 +1023,8 @@ source-tarball: # pipeline. .hackage: - <<: *only-default - stage: hackage - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + stage: testing + image: ghcci/x86_64-linux-deb9:0.2 tags: - x86_64-linux dependencies: [] @@ -781,6 +1033,10 @@ source-tarball: script: - bash .gitlab/start-head.hackage.sh +hackage: + extends: .hackage + when: manual + hackage-label: extends: .hackage rules: @@ -790,3 +1046,69 @@ nightly-hackage: <<: *nightly extends: .hackage +############################################################ +# Nofib testing +############################################################ + +perf-nofib: + stage: testing + dependencies: + - validate-x86_64-linux-deb9-dwarf + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + rules: + - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + tags: + - x86_64-linux + script: + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ghc-x86_64-deb9-linux-dwarf.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - cabal update; cabal install -w $BOOT_HC regex-compat + - export PATH=$root/bin:$PATH + - make -C nofib boot mode=fast -j$CPUS + - "make -C nofib EXTRA_RUNTEST_OPTS='-cachegrind +RTS -V0 -RTS' NoFibRuns=1 mode=fast -j$CPUS 2>&1 | tee nofib.log" + artifacts: + expire_in: 12 week + when: always + paths: + - nofib.log + +############################################################ +# Documentation deployment via GitLab Pages +############################################################ + +pages: + stage: deploy + dependencies: + - doc-tarball + image: ghcci/x86_64-linux-deb9:0.2 + # Due to Windows allow_failure + allow_failure: true + tags: + - x86_64-linux + script: + - mkdir -p public/doc + - tar -xf haddock.html.tar.xz -C public/doc + - tar -xf libraries.html.tar.xz -C public/doc + - tar -xf users_guide.html.tar.xz -C public/doc + - | + cat >public/index.html < + + + EOF + - cp -f index.html public/doc + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + artifacts: + paths: + - public ===================================== .gitlab/ci.sh ===================================== @@ -0,0 +1,464 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2230 + +# This is the primary driver of the GitLab CI infrastructure. + +set -e -o pipefail + +# Configuration: +hackage_index_state="@1579718451" + +# Colors +BLACK="0;30" +GRAY="1;30" +RED="0;31" +LT_RED="1;31" +BROWN="0;33" +LT_BROWN="1;33" +GREEN="0;32" +LT_GREEN="1;32" +BLUE="0;34" +LT_BLUE="1;34" +PURPLE="0;35" +LT_PURPLE="1;35" +CYAN="0;36" +LT_CYAN="1;36" +WHITE="1;37" +LT_GRAY="0;37" + +export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 + +# GitLab Pipelines log section delimiters +# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664 +start_section() { + name="$1" + echo -e "section_start:$(date +%s):$name\015\033[0K" +} + +end_section() { + name="$1" + echo -e "section_end:$(date +%s):$name\015\033[0K" +} + +echo_color() { + local color="$1" + local msg="$2" + echo -e "\033[${color}m${msg}\033[0m" +} + +error() { echo_color "${RED}" "$1"; } +warn() { echo_color "${LT_BROWN}" "$1"; } +info() { echo_color "${LT_BLUE}" "$1"; } + +fail() { error "error: $1"; exit 1; } + +function run() { + info "Running $*..." + "$@" || ( error "$* failed"; return 1; ) +} + +TOP="$(pwd)" + +function mingw_init() { + case "$MSYSTEM" in + MINGW32) + triple="i386-unknown-mingw32" + boot_triple="i386-unknown-mingw32" # triple of bootstrap GHC + ;; + MINGW64) + triple="x86_64-unknown-mingw32" + boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC + ;; + *) + fail "win32-init: Unknown MSYSTEM $MSYSTEM" + ;; + esac + + # Bring mingw toolchain into PATH. + # This is extracted from /etc/profile since this script inexplicably fails to + # run under gitlab-runner. + # shellcheck disable=SC1091 + source /etc/msystem + MINGW_MOUNT_POINT="${MINGW_PREFIX}" + PATH="$MINGW_MOUNT_POINT/bin:$PATH" + + # We always use mingw64 Python to avoid path length issues like #17483. + export PYTHON="/mingw64/bin/python3" +} + +# This will contain GHC's local native toolchain +toolchain="$TOP/toolchain" +mkdir -p "$toolchain/bin" +PATH="$toolchain/bin:$PATH" + +export METRICS_FILE="$CI_PROJECT_DIR/performance-metrics.tsv" + +cores="$(mk/detect-cpu-count.sh)" + +# Use a local temporary directory to ensure that concurrent builds don't +# interfere with one another +mkdir -p "$TOP/tmp" +export TMP="$TOP/tmp" +export TEMP="$TOP/tmp" + +function darwin_setup() { + # It looks like we already have python2 here and just installing python3 + # does not work. + brew upgrade python + brew install ghc cabal-install ncurses gmp + + pip3 install sphinx + # PDF documentation disabled as MacTeX apparently doesn't include xelatex. + #brew cask install mactex +} + +function show_tool() { + local tool="$1" + info "$tool = ${!tool}" + ${!tool} --version +} + +function set_toolchain_paths() { + needs_toolchain=1 + case "$(uname)" in + Linux) needs_toolchain="" ;; + *) ;; + esac + + if [[ -n "$needs_toolchain" ]]; then + # These are populated by setup_toolchain + GHC="$toolchain/bin/ghc$exe" + CABAL="$toolchain/bin/cabal$exe" + HAPPY="$toolchain/bin/happy$exe" + ALEX="$toolchain/bin/alex$exe" + else + GHC="$(which ghc)" + CABAL="/usr/local/bin/cabal" + HAPPY="$HOME/.cabal/bin/happy" + ALEX="$HOME/.cabal/bin/alex" + fi + export GHC + export CABAL + export HAPPY + export ALEX +} + +# Extract GHC toolchain +function setup() { + if [ -d "$TOP/cabal-cache" ]; then + info "Extracting cabal cache..." + mkdir -p "$cabal_dir" + cp -Rf cabal-cache/* "$cabal_dir" + fi + + if [[ -n "$needs_toolchain" ]]; then + setup_toolchain + fi + case "$(uname)" in + Darwin) darwin_setup ;; + *) ;; + esac + + # Make sure that git works + git config user.email "ghc-ci at gitlab-haskell.org" + git config user.name "GHC GitLab CI" + + info "=====================================================" + info "Toolchain versions" + info "=====================================================" + show_tool GHC + show_tool CABAL + show_tool HAPPY + show_tool ALEX +} + +function fetch_ghc() { + local v="$GHC_VERSION" + if [[ -z "$v" ]]; then + fail "GHC_VERSION is not set" + fi + + if [ ! -e "$GHC" ]; then + start_section "fetch GHC" + url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple}.tar.xz" + info "Fetching GHC binary distribution from $url..." + curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution" + tar -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution" + case "$(uname)" in + MSYS_*|MINGW*) + cp -r "ghc-${GHC_VERSION}"/* "$toolchain" + ;; + *) + pushd "ghc-${GHC_VERSION}" + ./configure --prefix="$toolchain" + "$MAKE" install + popd + ;; + esac + rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz + end_section "fetch GHC" + fi + +} + +function fetch_cabal() { + local v="$CABAL_INSTALL_VERSION" + if [[ -z "$v" ]]; then + fail "CABAL_INSTALL_VERSION is not set" + fi + + if [ ! -e "$CABAL" ]; then + start_section "fetch GHC" + case "$(uname)" in + # N.B. Windows uses zip whereas all others use .tar.xz + MSYS_*|MINGW*) + case "$MSYSTEM" in + MINGW32) cabal_arch="i386" ;; + MINGW64) cabal_arch="x86_64" ;; + *) fail "unknown MSYSTEM $MSYSTEM" ;; + esac + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-unknown-mingw32.zip" + info "Fetching cabal binary distribution from $url..." + curl "$url" > "$TMP/cabal.zip" + unzip "$TMP/cabal.zip" + mv cabal.exe "$CABAL" + ;; + *) + local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/" + case "$(uname)" in + Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;; + FreeBSD) + #cabal_url="$base_url/cabal-install-$v-x86_64-portbld-freebsd.tar.xz" ;; + cabal_url="http://home.smart-cactus.org/~ben/ghc/cabal-install-3.0.0.0-x86_64-portbld-freebsd.tar.xz" ;; + *) fail "don't know where to fetch cabal-install for $(uname)" + esac + echo "Fetching cabal-install from $cabal_url" + curl "$cabal_url" > cabal.tar.xz + tar -xJf cabal.tar.xz + mv cabal "$toolchain/bin" + ;; + esac + end_section "fetch GHC" + fi +} + +# For non-Docker platforms we prepare the bootstrap toolchain +# here. For Docker platforms this is done in the Docker image +# build. +function setup_toolchain() { + fetch_ghc + fetch_cabal + cabal_install="$CABAL v2-install --index-state=$hackage_index_state --installdir=$toolchain/bin" + # Avoid symlinks on Windows + case "$(uname)" in + MSYS_*|MINGW*) cabal_install="$cabal_install --install-method=copy" ;; + *) ;; + esac + + if [ ! -e "$HAPPY" ]; then + info "Building happy..." + cabal update + $cabal_install happy + fi + + if [ ! -e "$ALEX" ]; then + info "Building alex..." + cabal update + $cabal_install alex + fi +} + +function cleanup_submodules() { + start_section "clean submodules" + info "Cleaning submodules..." + # On Windows submodules can inexplicably get into funky states where git + # believes that the submodule is initialized yet its associated repository + # is not valid. Avoid failing in this case with the following insanity. + git submodule sync --recursive || git submodule deinit --force --all + git submodule update --init --recursive + git submodule foreach git clean -xdf + end_section "clean submodules" +} + +function prepare_build_mk() { + if [[ -z "$BUILD_FLAVOUR" ]]; then fail "BUILD_FLAVOUR is not set"; fi + if [[ -z ${BUILD_SPHINX_HTML:-} ]]; then BUILD_SPHINX_HTML=YES; fi + if [[ -z ${BUILD_SPHINX_PDF:-} ]]; then BUILD_SPHINX_PDF=YES; fi + if [[ -z ${INTEGER_LIBRARY:-} ]]; then INTEGER_LIBRARY=integer-gmp; fi + + cat > mk/build.mk <> mk/build.mk + fi + + case "$(uname)" in + Darwin) echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk ;; + *) ;; + esac + + info "build.mk is:" + cat mk/build.mk +} + +function configure() { + start_section "booting" + run python3 boot + end_section "booting" + + local target_args="" + if [[ -n "$triple" ]]; then + target_args="--target=$triple" + fi + + start_section "configuring" + run ./configure \ + --enable-tarballs-autodownload \ + $target_args \ + $CONFIGURE_ARGS \ + GHC="$GHC" \ + HAPPY="$HAPPY" \ + ALEX="$ALEX" \ + || ( cat config.log; fail "configure failed" ) + end_section "configuring" +} + +function build_make() { + prepare_build_mk + if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then + fail "BIN_DIST_PREP_TAR_COMP is not set" + fi + + echo "include mk/flavours/${BUILD_FLAVOUR}.mk" > mk/build.mk + echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk + run "$MAKE" -j"$cores" $MAKE_ARGS + run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 + ls -lh "$BIN_DIST_PREP_TAR_COMP" +} + +function fetch_perf_notes() { + info "Fetching perf notes..." + "$TOP/.gitlab/test-metrics.sh" pull +} + +function push_perf_notes() { + info "Pushing perf notes..." + "$TOP/.gitlab/test-metrics.sh" push +} + +function test_make() { + run "$MAKE" test_bindist TEST_PREP=YES + run "$MAKE" V=0 test \ + THREADS="$cores" \ + JUNIT_FILE=../../junit.xml +} + +function build_hadrian() { + if [ -z "$FLAVOUR" ]; then + fail "FLAVOUR not set" + fi + + run_hadrian binary-dist + + mv _build/bindist/ghc*.tar.xz ghc.tar.xz +} + +function test_hadrian() { + cd _build/bindist/ghc-*/ + run ./configure --prefix="$TOP"/_build/install + run "$MAKE" install + cd ../../../ + + run_hadrian \ + test \ + --summary-junit=./junit.xml \ + --test-compiler="$TOP"/_build/install/bin/ghc +} + +function clean() { + rm -R tmp + run "$MAKE" --quiet clean || true + run rm -Rf _build +} + +function run_hadrian() { + run hadrian/build-cabal \ + --flavour="$FLAVOUR" \ + -j"$cores" \ + --broken-test="$BROKEN_TESTS" \ + $HADRIAN_ARGS \ + $@ +} + +# A convenience function to allow debugging in the CI environment. +function shell() { + local cmd=$@ + if [ -z "$cmd" ]; then + cmd="bash -i" + fi + run $cmd +} + +# Determine Cabal data directory +case "$(uname)" in + MSYS_*|MINGW*) exe=".exe"; cabal_dir="$APPDATA/cabal" ;; + *) cabal_dir="$HOME/.cabal"; exe="" ;; +esac + +# Platform-specific environment initialization +MAKE="make" +case "$(uname)" in + MSYS_*|MINGW*) mingw_init ;; + Darwin) boot_triple="x86_64-apple-darwin" ;; + FreeBSD) + boot_triple="x86_64-portbld-freebsd" + MAKE="gmake" + ;; + Linux) ;; + *) fail "uname $(uname) is not supported" ;; +esac + +set_toolchain_paths + +case $1 in + setup) setup && cleanup_submodules ;; + configure) configure ;; + build_make) build_make ;; + test_make) + fetch_perf_notes + res=0 + test_make || res=$? + push_perf_notes + exit $res ;; + build_hadrian) build_hadrian ;; + # N.B. Always push notes, even if the build fails. This is okay to do as the + # testsuite driver doesn't record notes for tests that fail due to + # correctness. + test_hadrian) + fetch_perf_notes + res=0 + test_hadrian || res=$? + push_perf_notes + exit $res ;; + run_hadrian) run_hadrian $@ ;; + clean) clean ;; + shell) shell $@ ;; + *) fail "unknown mode $1" ;; +esac ===================================== .gitlab/darwin-init.sh deleted ===================================== @@ -1,41 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $HOME/.cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - mkdir -p tmp - cd tmp - ghc_tarball="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-x86_64-apple-darwin.tar.xz" - echo "Fetching GHC from $ghc_tarball" - curl $ghc_tarball | tar -xJ - cd ghc-$GHC_VERSION - ./configure --prefix=$toolchain - make install - cd ../.. - rm -Rf tmp -fi - -if [ ! -e $toolchain/bin/cabal ]; then - cabal_tarball="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL_VERSION/cabal-install-$CABAL_INSTALL_VERSION-x86_64-apple-darwin-sierra.tar.xz" - echo "Fetching cabal-install from $cabal_tarball" - curl $cabal_tarball | tar -xz - mv cabal $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal new-install happy --symlink-bindir=$toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal new-install alex --symlink-bindir=$toolchain/bin -fi - ===================================== .gitlab/linters/check-makefiles.py ===================================== @@ -1,5 +1,11 @@ #!/usr/bin/env python3 +""" +Linters for testsuite makefiles +""" + +from linter import run_linters, RegexpLinter + """ Warn for use of `--interactive` inside Makefiles (#11468). @@ -7,13 +13,21 @@ Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to forget one of those flags when adding a new test. """ +interactive_linter = \ + RegexpLinter(r'--interactive', + message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`." + ).add_path_filter(lambda path: path.name == 'Makefile') -from linter import run_linters, RegexpLinter +test_hc_quotes_linter = \ + RegexpLinter('\t\\$\\(TEST_HC\\)', + message = "Warning: $(TEST_HC) should be quoted in Makefiles.", + ).add_path_filter(lambda path: path.name == 'Makefile') linters = [ - RegexpLinter(r'--interactive', - message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`.") + interactive_linter, + test_hc_quotes_linter, ] if __name__ == '__main__': - run_linters(linters) #$, subdir='testsuite') + run_linters(linters, + subdir='testsuite') ===================================== .gitlab/linters/check-version-number.sh ===================================== @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +grep -E -q '\[[0-9]+\.[0-9]+\.[0-9]+\]' configure.ac || + ( echo "error: configure.ac: GHC version number must have three components."; exit 1 ) ===================================== .gitlab/linters/linter.py ===================================== @@ -7,10 +7,11 @@ import sys import re import textwrap import subprocess -from typing import List, Optional +from pathlib import Path +from typing import List, Optional, Callable, Sequence from collections import namedtuple -def lint_failure(file, line_no, line_content, message): +def lint_failure(file, line_no: int, line_content: str, message: str): """ Print a lint failure message. """ wrapper = textwrap.TextWrapper(initial_indent=' ', subsequent_indent=' ') @@ -29,7 +30,7 @@ def lint_failure(file, line_no, line_content, message): print(textwrap.dedent(msg)) -def get_changed_files(base_commit, head_commit, +def get_changed_files(base_commit: str, head_commit: str, subdir: str = '.'): """ Get the files changed by the given range of commits. """ cmd = ['git', 'diff', '--name-only', @@ -46,12 +47,21 @@ class Linter(object): """ def __init__(self): self.warnings = [] # type: List[Warning] + self.path_filters = [] # type: List[Callable[[Path], bool]] def add_warning(self, w: Warning): self.warnings.append(w) - def lint(self, path): - pass + def add_path_filter(self, f: Callable[[Path], bool]) -> "Linter": + self.path_filters.append(f) + return self + + def do_lint(self, path: Path): + if all(f(path) for f in self.path_filters): + self.lint(path) + + def lint(self, path: Path): + raise NotImplementedError class LineLinter(Linter): """ @@ -59,44 +69,55 @@ class LineLinter(Linter): the given line from a file and calls :func:`add_warning` for any lint issues found. """ - def lint(self, path): - if os.path.isfile(path): - with open(path, 'r') as f: + def lint(self, path: Path): + if path.is_file(): + with path.open('r') as f: for line_no, line in enumerate(f): self.lint_line(path, line_no+1, line) - def lint_line(self, path, line_no, line): - pass + def lint_line(self, path: Path, line_no: int, line: str): + raise NotImplementedError class RegexpLinter(LineLinter): """ A :class:`RegexpLinter` produces the given warning message for all lines matching the given regular expression. """ - def __init__(self, regex, message): + def __init__(self, regex: str, message: str): LineLinter.__init__(self) self.re = re.compile(regex) self.message = message - def lint_line(self, path, line_no, line): + def lint_line(self, path: Path, line_no: int, line: str): if self.re.search(line): w = Warning(path=path, line_no=line_no, line_content=line[:-1], message=self.message) self.add_warning(w) -def run_linters(linters: List[Linter], +def run_linters(linters: Sequence[Linter], subdir: str = '.') -> None: import argparse parser = argparse.ArgumentParser() - parser.add_argument('base', help='Base commit') - parser.add_argument('head', help='Head commit') + subparsers = parser.add_subparsers() + + subparser = subparsers.add_parser('commits', help='Lint a range of commits') + subparser.add_argument('base', help='Base commit') + subparser.add_argument('head', help='Head commit') + subparser.set_defaults(get_linted_files=lambda args: + get_changed_files(args.base, args.head, subdir)) + + subparser = subparsers.add_parser('files', help='Lint a range of commits') + subparser.add_argument('file', nargs='+', help='File to lint') + subparser.set_defaults(get_linted_files=lambda args: args.file) + args = parser.parse_args() - for path in get_changed_files(args.base, args.head, subdir): + linted_files = args.get_linted_files(args) + for path in linted_files: if path.startswith('.gitlab/linters'): continue for linter in linters: - linter.lint(path) + linter.do_lint(Path(path)) warnings = [warning for linter in linters ===================================== .gitlab/win32-init.sh deleted ===================================== @@ -1,50 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:/mingw64/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $APPDATA/cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - case $MSYSTEM in - MINGW32) - triple="i386-unknown-mingw32" - ;; - MINGW64) - triple="x86_64-unknown-mingw32" - ;; - *) - echo "win32-init: Unknown MSYSTEM $MSYSTEM" - exit 1 - ;; - esac - if [ -z "$GHC_TARBALL_URL" ]; then - GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" - fi - curl "$GHC_TARBALL_URL" | tar -xJ - mv ghc-$GHC_VERSION toolchain -fi - -if [ ! -e $toolchain/bin/cabal ]; then - url="https://downloads.haskell.org/~cabal/cabal-install-2.4.1.0/cabal-install-2.4.1.0-x86_64-unknown-mingw32.zip" - curl $url > /tmp/cabal.zip - unzip /tmp/cabal.zip - mv cabal.exe $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal install happy - cp $APPDATA/cabal/bin/happy $toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal install alex - cp $APPDATA/cabal/bin/alex $toolchain/bin -fi - ===================================== hadrian/ci.project ===================================== @@ -0,0 +1,4 @@ +packages: ./ + +package hadrian + ghc-options: -Werror View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/90549bb12aaf750124e4cf8de61a60dd44ca36db -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/90549bb12aaf750124e4cf8de61a60dd44ca36db You're receiving 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 Jul 11 17:05:35 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 13:05:35 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] hadrian: Drop redundant import Message-ID: <5f09f15fa40a9_80b3f848662eb1c26605b7@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 5527b84e by Ben Gamari at 2020-07-11T13:05:21-04:00 hadrian: Drop redundant import - - - - - 1 changed file: - hadrian/src/Hadrian/Utilities.hs Changes: ===================================== hadrian/src/Hadrian/Utilities.hs ===================================== @@ -37,7 +37,6 @@ import Control.Monad.Extra import Data.Char import Data.Dynamic (Dynamic, fromDynamic, toDyn) import Data.HashMap.Strict (HashMap) -import Data.List (isPrefixOf) import Data.List.Extra import Data.Maybe import Data.Typeable (TypeRep, typeOf) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5527b84ecc28e4fe732e15815fb450f09f61ab40 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5527b84ecc28e4fe732e15815fb450f09f61ab40 You're receiving 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 Jul 11 17:17:36 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 13:17:36 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] hadrian: Don't build with -Werror Message-ID: <5f09f430b80a8_80b3f84960bea14266095d@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: c5ba2f00 by Ben Gamari at 2020-07-11T13:17:27-04:00 hadrian: Don't build with -Werror - - - - - 1 changed file: - hadrian/ci.project Changes: ===================================== hadrian/ci.project ===================================== @@ -1,4 +1,4 @@ packages: ./ package hadrian - ghc-options: -Werror + -- ghc-options: -Werror View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c5ba2f005b0b4064ed058136a2698a163bd09560 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c5ba2f005b0b4064ed058136a2698a163bd09560 You're receiving 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 Jul 11 17:26:53 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 13:26:53 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] Backport CI infrastructure rework Message-ID: <5f09f65decc83_80b3f848e5b8658266135b@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 79177f96 by Ben Gamari at 2020-07-11T13:26:44-04:00 Backport CI infrastructure rework - - - - - 9 changed files: - .gitlab-ci.yml - + .gitlab/ci.sh - − .gitlab/darwin-init.sh - .gitlab/linters/check-makefiles.py - + .gitlab/linters/check-version-number.sh - .gitlab/linters/linter.py - − .gitlab/win32-init.sh - + hadrian/ci.project - hadrian/src/Hadrian/Utilities.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,59 +2,45 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a + DOCKER_REV: 6223fe0b5942f4fa35bdec92c74566cf195bfb42 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/win32-init.sh. + # .gitlab/ci.sh. WINDOWS_TOOLCHAIN_VERSION: 1 -before_script: - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + # Disable shallow clones; they break our linting rules + GIT_DEPTH: 0 + + # Overridden by individual jobs + CONFIGURE_ARGS: "" + + GIT_SUBMODULE_STRATEGY: "recursive" stages: - - lint # Source linting - - build # A quick smoke-test to weed out broken commits - - full-build # Build all the things - - cleanup # See Note [Cleanup on Windows] - - packaging # Source distribution, etc. - - hackage # head.hackage testing - - deploy # push documentation - -.only-default: &only-default - rules: - - if: $CI_MERGE_REQUEST_ID - - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "master"' - - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - - if: '$CI_PIPELINE_SOURCE == "web"' + - lint # Source linting + - quick-build # A very quick smoke-test to weed out broken commits + - build # A quick smoke-test to weed out broken commits + - full-build # Build all the things + - cleanup # See Note [Cleanup after the shell executor] + - packaging # Source distribution, etc. + - testing # head.hackage correctness and compiler performance testing + - deploy # push documentation workflow: - # N.B. Don't run on wip/ branches, instead on run on merge requests. + # N.B.Don't run on wip/ branches, instead on run on merge requests. rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' -############################################################ -# Runner Tags -############################################################ -# -# * x86_64-linux: Any Docker-capable x86_64 Linux machine -# * aarch64-linux: Any Docker-capable AArch64 Linux machine -# * x86_64-windows: A x86_64 Windows machine -# * lint: Any Docker-capable x86_64 Linux machine; distinct from -# x86_64-linux to ensure low-latency availability. -# - .nightly: &nightly rules: - if: $NIGHTLY + artifacts: + when: always + expire_in: 8 weeks .release: &release variables: @@ -66,53 +52,105 @@ workflow: rules: - if: '$RELEASE == "yes"' +############################################################ +# Runner Tags +############################################################ +# +# * x86_64-linux: Any Docker-capable x86_64 Linux machine +# * aarch64-linux: Any Docker-capable AArch64 Linux machine +# * x86_64-windows: A x86_64 Windows machine +# * lint: Any Docker-capable x86_64 Linux machine; distinct from +# x86_64-linux to ensure low-latency availability. +# + ############################################################ # Linting ############################################################ ghc-linters: - allow_failure: true stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" - - "echo Merge base $base" + - "echo Linting changes between $base..$CI_COMMIT_SHA" # - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA) - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA) - - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA - - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA + - .gitlab/linters/check-makefiles.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-cpp.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-version-number.sh + - python3 utils/checkUniques/check-uniques.py . dependencies: [] tags: - lint rules: - if: $CI_MERGE_REQUEST_ID +# Run mypy Python typechecker on linter scripts. +lint-linters: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy .gitlab/linters/*.py + dependencies: [] + tags: + - lint + +# Check that .T files all parse by listing broken tests. +lint-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + script: + - make -Ctestsuite list_broken TEST_HC=ghc + dependencies: [] + tags: + - lint + +# Run mypy Python typechecker on testsuite driver +.typecheck-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy testsuite/driver/runtests.py + dependencies: [] + tags: + - lint + # We allow the submodule checker to fail when run on merge requests (to -# accomodate, e.g., haddock changes not yet upstream) but not on `master` or +# accommodate, e.g., haddock changes not yet upstream) but not on `master` or # Marge jobs. .lint-submods: stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA) + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" + - "echo Linting submodule changes between $base..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $base..$CI_COMMIT_SHA) dependencies: [] tags: - lint lint-submods: extends: .lint-submods + # Allow failure on merge requests since any necessary submodule patches may + # not be upstreamed yet. rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/' allow_failure: false - allow_failure: true -lint-submods-mr: +lint-submods-branch: extends: .lint-submods - allow_failure: true + script: + - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA) rules: - - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' .lint-changelogs: stage: lint @@ -125,6 +163,7 @@ lint-submods-mr: lint-changelogs: extends: .lint-changelogs + # Allow failure since this isn't a final release. allow_failure: true rules: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' @@ -140,71 +179,183 @@ lint-release-changelogs: ############################################################ .validate-hadrian: - <<: *only-default - allow_failure: true + variables: + FLAVOUR: "validate" script: - - cabal update - - git clean -xdf && git submodule foreach git clean -xdf - - bash .circleci/prepare-system.sh - - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi - - ./boot - - ./configure $CONFIGURE_ARGS - - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian cache: key: hadrian paths: - cabal-cache artifacts: - when: always + reports: + junit: junit.xml + expire_in: 2 week paths: - ghc.tar.xz + - junit.xml -validate-x86_64-linux-deb8-hadrian: +.validate-linux-hadrian: extends: .validate-hadrian - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + variables: + TEST_ENV: "x86_64-linux-deb9-hadrian" before_script: # workaround for docker permissions - sudo chown ghc:ghc -R . - - python3 .gitlab/fix-submodules.py - git submodule sync --recursive - git submodule update --init --recursive - git checkout .gitmodules - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + after_script: + - .gitlab/ci.sh clean tags: - x86_64-linux +validate-x86_64-linux-deb9-hadrian: + extends: .validate-linux-hadrian + stage: build + +validate-x86_64-linux-deb9-unreg-hadrian: + extends: .validate-linux-hadrian + stage: full-build + variables: + CONFIGURE_ARGS: --enable-unregisterised + TEST_ENV: "x86_64-linux-deb9-unreg-hadrian" + +.hadrian-ghc-in-ghci: + stage: quick-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + variables: + GHC_FLAGS: -Werror + tags: + - x86_64-linux + script: + - cabal update + - cd hadrian; cabal new-build --project-file=ci.project; cd .. + - git clean -xdf && git submodule foreach git clean -xdf + - .gitlab/ci.sh setup + - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi + - ./boot + - ./configure $CONFIGURE_ARGS + # 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," + cache: + key: hadrian-ghci + paths: + - cabal-cache ############################################################ # Validation via Pipelines (make) ############################################################ .validate: - <<: *only-default variables: TEST_TYPE: test - before_script: - - git clean -xdf && git submodule foreach git clean -xdf + MAKE_ARGS: "-Werror" script: - - ./boot - - ./configure $CONFIGURE_ARGS - - | - THREADS=`mk/detect-cpu-count.sh` - make V=0 -j$THREADS WERROR=-Werror - - | - make binary-dist TAR_COMP_OPTS="-1" - - | - THREADS=`mk/detect-cpu-count.sh` - make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_make + - .gitlab/ci.sh test_make dependencies: [] artifacts: reports: junit: junit.xml expire_in: 2 week paths: - - ghc-*.tar.xz + - $BIN_DIST_PREP_TAR_COMP - junit.xml + - performance-metrics.tsv + +################################# +# x86_64-freebsd +################################# + +.build-x86_64-freebsd: + extends: .validate + tags: + - x86_64-freebsd + allow_failure: true + variables: + # N.B. we use iconv from ports as I see linker errors when we attempt + # to use the "native" iconv embedded in libc as suggested by the + # porting guide [1]. + # [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + GHC_VERSION: 8.10.1 + CABAL_INSTALL_VERSION: 3.2.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd" + BUILD_FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Conditional due to lack of builder capacity +validate-x86_64-freebsd: + extends: .build-x86_64-freebsd + stage: full-build + rules: + - if: '$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/' + +nightly-x86_64-freebsd: + <<: *nightly + extends: .build-x86_64-freebsd + stage: full-build + +release-x86_64-freebsd: + <<: *release + extends: .build-x86_64-freebsd + stage: full-build + +.build-x86_64-freebsd-hadrian: + extends: .validate-hadrian + stage: full-build + tags: + - x86_64-freebsd + allow_failure: true + variables: + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + HADRIAN_ARGS: "--docs=no-sphinx" + GHC_VERSION: 8.6.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd-hadrian" + FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Disabled due to lack of builder capacity +.validate-x86_64-freebsd-hadrian: + extends: .build-x86_64-freebsd-hadrian + stage: full-build ################################# # x86_64-darwin @@ -216,54 +367,71 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: "8.8.3" - CABAL_INSTALL_VERSION: 2.4.1.0 - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz" + GHC_VERSION: 8.8.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-apple-darwin.tar.xz" MACOSX_DEPLOYMENT_TARGET: "10.7" # Only Sierra and onwards supports clock_gettime. See #12858 ac_cv_func_clock_gettime: "no" LANG: "en_US.UTF-8" - CONFIGURE_ARGS: --with-intree-gmp + CONFIGURE_ARGS: "--with-intree-gmp" TEST_ENV: "x86_64-darwin" - before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - - bash .gitlab/darwin-init.sh - - PATH="`pwd`/toolchain/bin:$PATH" + BUILD_FLAVOUR: "perf" after_script: - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean artifacts: when: always expire_in: 2 week cache: - key: darwin + key: "darwin-$GHC_VERSION" paths: - cabal-cache - toolchain +# Disabled because of OS X CI capacity +.validate-x86_64-darwin-hadrian: + stage: full-build + tags: + - x86_64-darwin + variables: + GHC_VERSION: 8.8.3 + MACOSX_DEPLOYMENT_TARGET: "10.7" + ac_cv_func_clock_gettime: "no" + LANG: "en_US.UTF-8" + CONFIGURE_ARGS: --with-intree-gmp + TEST_ENV: "x86_64-darwin-hadrian" + FLAVOUR: "validate" + script: + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + reports: + junit: junit.xml + paths: + - ghc.tar.xz + - junit.xml + .validate-linux: extends: .validate tags: - x86_64-linux + variables: + BUILD_FLAVOUR: "perf" before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" # Build hyperlinked sources for documentation when building releases - | if [[ -n "$CI_COMMIT_TAG" ]]; then - echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk + HADDOCK_HYPERLINKED_SOURCES=1 fi - - bash .circleci/prepare-system.sh # workaround for docker permissions - sudo chown ghc:ghc -R . after_script: @@ -285,9 +453,7 @@ validate-x86_64-darwin: allow_failure: true variables: TEST_ENV: "aarch64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz" - # Inexplicably makeindex fails - BUILD_SPHINX_PDF: "NO" + BIN_DIST_PREP_TAR_COMP: "ghc-aarch64-linux-deb9.tar.xz" cache: key: linux-aarch64-deb9 tags: @@ -302,8 +468,41 @@ validate-aarch64-linux-deb9: nightly-aarch64-linux-deb9: <<: *nightly extends: .build-aarch64-linux-deb9 + variables: + TEST_TYPE: slowtest + +################################# +# armv7-linux-deb9 +################################# + +.build-armv7-linux-deb9: + extends: .validate-linux + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb9:$DOCKER_REV" + # Due to linker issues + allow_failure: true + variables: + TEST_ENV: "armv7-linux-deb9" + BIN_DIST_PREP_TAR_COMP: "ghc-armv7-linux-deb9.tar.xz" + CONFIGURE_ARGS: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" + # N.B. We disable ld.lld explicitly here because it appears to fail + # non-deterministically on ARMv7. See #18280. + LD: "ld.gold" + GccUseLdOpt: "-fuse-ld=gold" + cache: + key: linux-armv7-deb9 + tags: + - armv7-linux + +validate-armv7-linux-deb9: + extends: .build-armv7-linux-deb9 artifacts: - expire_in: 2 year + when: always + expire_in: 2 week + +nightly-armv7-linux-deb9: + <<: *nightly + extends: .build-armv7-linux-deb9 variables: TEST_TYPE: slowtest @@ -317,7 +516,7 @@ nightly-aarch64-linux-deb9: image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "i386-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-i386-deb9-linux.tar.xz" cache: key: linux-i386-deb9 @@ -332,23 +531,6 @@ nightly-i386-linux-deb9: extends: .build-i386-linux-deb9 variables: TEST_TYPE: slowtest - artifacts: - when: always - expire_in: 2 week - -################################# -# x86_64-linux-deb10 -################################# - -.build-x86_64-linux-deb10: - extends: .validate-linux - stage: full-build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - variables: - TEST_ENV: "x86_64-linux-deb10" - BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" - cache: - key: linux-x86_64-deb10 ################################# # x86_64-linux-deb9 @@ -356,40 +538,62 @@ nightly-i386-linux-deb9: .build-x86_64-linux-deb9: extends: .validate-linux - stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb9-linux.tar.xz" cache: key: linux-x86_64-deb9 -validate-x86_64-linux-deb9: +# Disabled to reduce CI load +.validate-x86_64-linux-deb9: extends: .build-x86_64-linux-deb9 + stage: full-build artifacts: when: always expire_in: 2 week +release-x86_64-linux-deb9: + <<: *release + extends: .build-x86_64-linux-deb9 + stage: full-build + nightly-x86_64-linux-deb9: <<: *nightly extends: .build-x86_64-linux-deb9 - artifacts: - expire_in: 2 year + stage: full-build variables: TEST_TYPE: slowtest # N.B. Has DEBUG assertions enabled in stage2 validate-x86_64-linux-deb9-debug: extends: .build-x86_64-linux-deb9 - stage: build + stage: full-build variables: BUILD_FLAVOUR: validate + # Ensure that stage2 also has DEBUG enabled + ValidateSpeed: SLOW + # Override validate flavour default; see #16890. + BUILD_SPHINX_PDF: "YES" + TEST_TYPE: slowtest TEST_ENV: "x86_64-linux-deb9-debug" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-debug.tar.xz" + artifacts: + when: always + expire_in: 2 week -validate-x86_64-linux-deb9-llvm: +# Disabled to alleviate CI load +.validate-x86_64-linux-deb9-llvm: + extends: .build-x86_64-linux-deb9 + stage: full-build + variables: + BUILD_FLAVOUR: perf-llvm + TEST_ENV: "x86_64-linux-deb9-llvm" + +nightly-x86_64-linux-deb9-llvm: + <<: *nightly extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: BUILD_FLAVOUR: perf-llvm TEST_ENV: "x86_64-linux-deb9-llvm" @@ -397,11 +601,11 @@ validate-x86_64-linux-deb9-llvm: validate-x86_64-linux-deb9-integer-simple: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: + BUILD_FLAVOUR: validate INTEGER_LIBRARY: integer-simple - TEST_ENV: "x86_64-linux-deb9-integer-simple" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz" + TEST_ENV: "x86_64-linux-deb9-integer-simple-validate" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-integer-simple.tar.xz" nightly-x86_64-linux-deb9-integer-simple: <<: *nightly @@ -411,185 +615,205 @@ nightly-x86_64-linux-deb9-integer-simple: INTEGER_LIBRARY: integer-simple TEST_ENV: "x86_64-linux-deb9-integer-simple" TEST_TYPE: slowtest - artifacts: - expire_in: 2 year -validate-x86_64-linux-deb9-unreg: +validate-x86_64-linux-deb9-dwarf: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: - CONFIGURE_ARGS: --enable-unregisterised - TEST_ENV: "x86_64-linux-deb9-unreg" + CONFIGURE_ARGS: "--enable-dwarf-unwind" + BUILD_FLAVOUR: dwarf + TEST_ENV: "x86_64-linux-deb9-dwarf" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-dwarf.tar.xz" + +################################# +# x86_64-linux-deb10 +################################# -release-x86_64-linux-deb9-dwarf: +.build-x86_64-linux-deb10: extends: .validate-linux - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" - allow_failure: true + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb9" - artifacts: - when: always - expire_in: 2 week + TEST_ENV: "x86_64-linux-deb10" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" cache: - key: linux-x86_64-deb9 + key: linux-x86_64-deb10 +# Disabled to alleviate CI load +.validate-x86_64-linux-deb10: + extends: .build-x86_64-linux-deb10 + stage: full-build -release-x86_64-linux-deb10-dwarf: - <<: *release +nightly-x86_64-linux-deb10: + <<: *nightly extends: .build-x86_64-linux-deb10 variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb10-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb10-linux-dwarf.tar.xz" + TEST_TYPE: slowtest + +release-x86_64-linux-deb10: + <<: *release + extends: .build-x86_64-linux-deb10 ################################# # x86_64-linux-deb8 ################################# -release-x86_64-linux-deb8: - <<: *release +.build-x86_64-linux-deb8: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + # Due to #18298. + allow_failure: true variables: TEST_ENV: "x86_64-linux-deb8" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz" - # Disable sphinx PDF output as our Debian image doesn't have the requisite packages + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb8-linux.tar.xz" + # Debian 8's Sphinx is too old to support the table directive's :widths: + # option: https://sourceforge.net/p/docutils/patches/120/ + BUILD_SPHINX_HTML: "NO" + BUILD_SPHINX_INFO: "NO" BUILD_SPHINX_PDF: "NO" + BUILD_SPHINX_MAN: "NO" cache: key: linux-x86_64-deb8 + +release-x86_64-linux-deb8: + <<: *release + extends: .build-x86_64-linux-deb8 + +################################# +# x86_64-linux-alpine +################################# + +.build-x86_64-linux-alpine-hadrian: + extends: .validate-linux-hadrian + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine:$DOCKER_REV" + # There are currently a few failing tests + allow_failure: true + variables: + TEST_ENV: "x86_64-linux-alpine" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-alpine-linux.tar.xz" + # Can't use ld.gold due to #13958. + CONFIGURE_ARGS: "--disable-ld-override" + HADRIAN_ARGS: "--docs=no-sphinx" + # encoding004 due to lack of locale support + # T10458 due to fact that dynamic linker tries to reload libAS + BROKEN_TESTS: "encoding004 T10458" + cache: + key: linux-x86_64-alpine artifacts: when: always expire_in: 2 week +release-x86_64-linux-alpine: + <<: *release + extends: .build-x86_64-linux-alpine-hadrian + +nightly-x86_64-linux-alpine: + <<: *nightly + extends: .build-x86_64-linux-alpine-hadrian + ################################# # x86_64-linux-centos7 ################################# -release-x86_64-linux-centos7: - <<: *release +.build-x86_64-linux-centos7: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" variables: - # For the testsuite - LANG: "en_US.UTF-8" # The sphinx release shipped with Centos 7 fails to build out documentation BUILD_SPHINX_HTML: "NO" BUILD_SPHINX_PDF: "NO" TEST_ENV: "x86_64-linux-centos7" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz" - allow_failure: true + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-centos7-linux.tar.xz" + # CentOS seems to default to ascii + LANG: "en_US.UTF-8" cache: key: linux-x86_64-centos7 - artifacts: - when: always - expire_in: 2 week + +release-x86_64-linux-centos7: + <<: *release + extends: .build-x86_64-linux-centos7 ################################# # x86_64-linux-fedora27 ################################# -.build-x86_64-linux-fedora27: +validate-x86_64-linux-fedora27: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-fedora27" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: key: linux-x86_64-fedora27 - -validate-x86_64-linux-fedora27: - extends: .build-x86_64-linux-fedora27 artifacts: when: always # These are used for head.hackage jobs therefore we keep them around for # longer. expire_in: 8 week -release-x86_64-linux-fedora27: - <<: *release - extends: .build-x86_64-linux-fedora27 - -release-x86_64-linux-fedora27-dwarf: - <<: *release - extends: .build-x86_64-linux-fedora27 - variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-fedora27-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux-dwarf.tar.xz" - ############################################################ # Validation via Pipelines (Windows) ############################################################ .build-windows: - <<: *only-default + # For the reasons given in #17777 this build isn't reliable. + allow_failure: true before_script: - git clean -xdf - - git submodule foreach git clean -xdf - # Use a local temporary directory to ensure that concurrent builds don't - # interfere with one another - - | - mkdir tmp - set TMP=%cd%\tmp - set TEMP=%cd%\tmp - - - set PATH=C:\msys64\usr\bin;%PATH% - - python .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - bash .gitlab/win32-init.sh + # Setup toolchain + - bash .gitlab/ci.sh setup after_script: - - rd /s /q tmp - - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache - - bash -c 'make clean || true' + - | + Copy-Item -Recurse -Path $Env:APPDATA\cabal -Destination cabal-cache + - bash .gitlab/ci.sh clean dependencies: [] variables: - FORCE_SYMLINKS: 1 + #FORCE_SYMLINKS: 1 LANG: "en_US.UTF-8" SPHINXBUILD: "/mingw64/bin/sphinx-build.exe" + CABAL_INSTALL_VERSION: 3.0.0.0 + GHC_VERSION: "8.8.3" cache: paths: - cabal-cache - - ghc-8.6.2 + - toolchain - ghc-tarballs .build-windows-hadrian: extends: .build-windows stage: full-build - allow_failure: true variables: - GHC_VERSION: "8.8.3" + FLAVOUR: "validate" + # skipping perf tests for now since we build a quick-flavoured GHC, + # which might result in some broken perf tests? + HADRIAN_ARGS: "--docs=no-sphinx --skip-perf" + script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex' - - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist" - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz - # FIXME: Testsuite disabled due to #16156. - # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_hadrian + - bash .gitlab/ci.sh test_hadrian tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: + reports: + junit: junit.xml + expire_in: 2 week when: always paths: - ghc.tar.xz + - junit.xml validate-x86_64-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW64 + TEST_ENV: "x86_64-windows-hadrian" cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" @@ -598,86 +822,94 @@ nightly-i386-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW32 + TEST_ENV: "i386-windows-hadrian" cache: key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" .build-windows-make: extends: .build-windows stage: full-build - # due to #16084 - allow_failure: true variables: - BUILD_FLAVOUR: "UNSET" - GHC_VERSION: "8.8.3" - BUILD_PROF_LIBS: "YES" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz" + BUILD_FLAVOUR: "quick" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-mingw32.tar.xz" script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS' - - bash -c "echo \"include mk/flavours/${BUILD_FLAVOUR}.mk\" > mk/build.mk" - - bash -c "echo \"GhcLibHcOpts+=-haddock\" >> mk/build.mk" - - bash -c "echo \"BUILD_PROF_LIBS = $BUILD_PROF_LIBS\" >> mk/build.mk" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1" - - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_make + - bash .gitlab/ci.sh test_make tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: when: always expire_in: 2 week reports: junit: junit.xml paths: - - ghc-*.tar.xz + # N.B. variable interpolation apparently doesn't work on Windows so + # this can't be $BIN_DIST_PREP_TAR_COMP + - "ghc-x86_64-mingw32.tar.xz" - junit.xml -validate-x86_64-windows: +.build-x86_64-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" - BUILD_FLAVOUR: "quick" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" + TEST_ENV: "x86_64-windows" cache: key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-x86_64-windows: + extends: .build-x86_64-windows-make + +nightly-x86_64-windows: + <<: *nightly + extends: .build-x86_64-windows-make + stage: full-build + variables: + BUILD_FLAVOUR: "validate" + # Normal Windows validate builds are profiled; that won't do for releases. release-x86_64-windows: <<: *release extends: validate-x86_64-windows variables: - MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" - -release-i386-windows: + # +release-x86_64-windows-integer-simple: <<: *release - extends: .build-windows-make + extends: validate-x86_64-windows variables: - MSYSTEM: MINGW32 + INTEGER_LIBRARY: integer-simple BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - # Due to #15934 - BUILD_PROF_LIBS: "NO" - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows: - <<: *nightly + +.build-i386-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW32 - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - BUILD_FLAVOUR: "quick" # Due to #15934 BUILD_PROF_LIBS: "NO" + TEST_ENV: "i386-windows" + # Due to #17736 + allow_failure: true cache: key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-i386-windows: + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +release-i386-windows: + <<: *release + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +nightly-i386-windows: + <<: *nightly + extends: .build-i386-windows-make + ############################################################ # Cleanup ############################################################ @@ -687,40 +919,24 @@ nightly-i386-windows: # # As noted in [1], gitlab-runner's shell executor doesn't clean up its working # directory after builds. Unfortunately, we are forced to use the shell executor -# on Windows. To avoid running out of disk space we add a stage at the end of -# the build to remove the \GitLabRunner\builds directory. Since we only run a -# single build at a time on Windows this should be safe. +# on Darwin. To avoid running out of disk space we add a stage at the end of +# the build to remove the /.../GitLabRunner/builds directory. Since we only run a +# single build at a time on Darwin this should be safe. +# +# We used to have a similar cleanup job on Windows as well however it ended up +# being quite fragile as we have multiple Windows builders yet there is no +# guarantee that the cleanup job is run on the same machine as the build itself +# was run. Consequently we were forced to instead handle cleanup with a separate +# cleanup cron job on Windows. # # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856 -# See Note [Cleanup after shell executor] -cleanup-windows: - <<: *only-default - stage: cleanup - tags: - - x86_64-windows - dependencies: [] - before_script: - - echo "Time to clean up" - script: - - echo "Let's go" - after_script: - - set "BUILD_DIR=%CI_PROJECT_DIR%" - - set "BUILD_DIR=%BUILD_DIR:/=\%" - - echo "Cleaning %BUILD_DIR%" - - cd \GitLabRunner - # This is way more complicated than it should be: - # See https://stackoverflow.com/questions/1965787 - - del %BUILD_DIR%\* /F /Q - - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p" - - exit /b 0 - # See Note [Cleanup after shell executor] cleanup-darwin: - <<: *only-default stage: cleanup tags: - x86_64-darwin + when: always dependencies: [] before_script: - echo "Time to clean up" @@ -737,19 +953,56 @@ cleanup-darwin: # Packaging ############################################################ +doc-tarball: + stage: packaging + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + dependencies: + - validate-x86_64-linux-deb9-debug + - validate-x86_64-windows + variables: + LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz" + WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz" + # Due to Windows allow_failure + allow_failure: true + artifacts: + paths: + - haddock.html.tar.xz + - libraries.html.tar.xz + - users_guide.html.tar.xz + - index.html + - "*.pdf" + script: + - | + if [ ! -f "$LINUX_BINDIST" ]; then + echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" + exit 1 + fi + if [ ! -f "$WINDOWS_BINDIST" ]; then + echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?" + exit 1 + fi + - rm -Rf docs + - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST + - ls -lh + - mv docs/*.tar.xz docs/index.html . + source-tarball: - <<: *release stage: packaging tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" dependencies: [] + rules: + - if: $CI_COMMIT_TAG + when: always artifacts: paths: - ghc-*.tar.xz - version script: - - mk/get-win32-tarballs.sh download all + - python3 mk/get-win32-tarballs.py download all - ./boot - ./configure - make sdist @@ -770,9 +1023,8 @@ source-tarball: # pipeline. .hackage: - <<: *only-default - stage: hackage - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + stage: testing + image: ghcci/x86_64-linux-deb9:0.2 tags: - x86_64-linux dependencies: [] @@ -781,6 +1033,10 @@ source-tarball: script: - bash .gitlab/start-head.hackage.sh +hackage: + extends: .hackage + when: manual + hackage-label: extends: .hackage rules: @@ -790,3 +1046,69 @@ nightly-hackage: <<: *nightly extends: .hackage +############################################################ +# Nofib testing +############################################################ + +perf-nofib: + stage: testing + dependencies: + - validate-x86_64-linux-deb9-dwarf + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + rules: + - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + tags: + - x86_64-linux + script: + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ghc-x86_64-deb9-linux-dwarf.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - cabal update; cabal install -w $BOOT_HC regex-compat + - export PATH=$root/bin:$PATH + - make -C nofib boot mode=fast -j$CPUS + - "make -C nofib EXTRA_RUNTEST_OPTS='-cachegrind +RTS -V0 -RTS' NoFibRuns=1 mode=fast -j$CPUS 2>&1 | tee nofib.log" + artifacts: + expire_in: 12 week + when: always + paths: + - nofib.log + +############################################################ +# Documentation deployment via GitLab Pages +############################################################ + +pages: + stage: deploy + dependencies: + - doc-tarball + image: ghcci/x86_64-linux-deb9:0.2 + # Due to Windows allow_failure + allow_failure: true + tags: + - x86_64-linux + script: + - mkdir -p public/doc + - tar -xf haddock.html.tar.xz -C public/doc + - tar -xf libraries.html.tar.xz -C public/doc + - tar -xf users_guide.html.tar.xz -C public/doc + - | + cat >public/index.html < + + + EOF + - cp -f index.html public/doc + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + artifacts: + paths: + - public ===================================== .gitlab/ci.sh ===================================== @@ -0,0 +1,464 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2230 + +# This is the primary driver of the GitLab CI infrastructure. + +set -e -o pipefail + +# Configuration: +hackage_index_state="@1579718451" + +# Colors +BLACK="0;30" +GRAY="1;30" +RED="0;31" +LT_RED="1;31" +BROWN="0;33" +LT_BROWN="1;33" +GREEN="0;32" +LT_GREEN="1;32" +BLUE="0;34" +LT_BLUE="1;34" +PURPLE="0;35" +LT_PURPLE="1;35" +CYAN="0;36" +LT_CYAN="1;36" +WHITE="1;37" +LT_GRAY="0;37" + +export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 + +# GitLab Pipelines log section delimiters +# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664 +start_section() { + name="$1" + echo -e "section_start:$(date +%s):$name\015\033[0K" +} + +end_section() { + name="$1" + echo -e "section_end:$(date +%s):$name\015\033[0K" +} + +echo_color() { + local color="$1" + local msg="$2" + echo -e "\033[${color}m${msg}\033[0m" +} + +error() { echo_color "${RED}" "$1"; } +warn() { echo_color "${LT_BROWN}" "$1"; } +info() { echo_color "${LT_BLUE}" "$1"; } + +fail() { error "error: $1"; exit 1; } + +function run() { + info "Running $*..." + "$@" || ( error "$* failed"; return 1; ) +} + +TOP="$(pwd)" + +function mingw_init() { + case "$MSYSTEM" in + MINGW32) + triple="i386-unknown-mingw32" + boot_triple="i386-unknown-mingw32" # triple of bootstrap GHC + ;; + MINGW64) + triple="x86_64-unknown-mingw32" + boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC + ;; + *) + fail "win32-init: Unknown MSYSTEM $MSYSTEM" + ;; + esac + + # Bring mingw toolchain into PATH. + # This is extracted from /etc/profile since this script inexplicably fails to + # run under gitlab-runner. + # shellcheck disable=SC1091 + source /etc/msystem + MINGW_MOUNT_POINT="${MINGW_PREFIX}" + PATH="$MINGW_MOUNT_POINT/bin:$PATH" + + # We always use mingw64 Python to avoid path length issues like #17483. + export PYTHON="/mingw64/bin/python3" +} + +# This will contain GHC's local native toolchain +toolchain="$TOP/toolchain" +mkdir -p "$toolchain/bin" +PATH="$toolchain/bin:$PATH" + +export METRICS_FILE="$CI_PROJECT_DIR/performance-metrics.tsv" + +cores="$(mk/detect-cpu-count.sh)" + +# Use a local temporary directory to ensure that concurrent builds don't +# interfere with one another +mkdir -p "$TOP/tmp" +export TMP="$TOP/tmp" +export TEMP="$TOP/tmp" + +function darwin_setup() { + # It looks like we already have python2 here and just installing python3 + # does not work. + brew upgrade python + brew install ghc cabal-install ncurses gmp + + pip3 install sphinx + # PDF documentation disabled as MacTeX apparently doesn't include xelatex. + #brew cask install mactex +} + +function show_tool() { + local tool="$1" + info "$tool = ${!tool}" + ${!tool} --version +} + +function set_toolchain_paths() { + needs_toolchain=1 + case "$(uname)" in + Linux) needs_toolchain="" ;; + *) ;; + esac + + if [[ -n "$needs_toolchain" ]]; then + # These are populated by setup_toolchain + GHC="$toolchain/bin/ghc$exe" + CABAL="$toolchain/bin/cabal$exe" + HAPPY="$toolchain/bin/happy$exe" + ALEX="$toolchain/bin/alex$exe" + else + GHC="$(which ghc)" + CABAL="/usr/local/bin/cabal" + HAPPY="$HOME/.cabal/bin/happy" + ALEX="$HOME/.cabal/bin/alex" + fi + export GHC + export CABAL + export HAPPY + export ALEX +} + +# Extract GHC toolchain +function setup() { + if [ -d "$TOP/cabal-cache" ]; then + info "Extracting cabal cache..." + mkdir -p "$cabal_dir" + cp -Rf cabal-cache/* "$cabal_dir" + fi + + if [[ -n "$needs_toolchain" ]]; then + setup_toolchain + fi + case "$(uname)" in + Darwin) darwin_setup ;; + *) ;; + esac + + # Make sure that git works + git config user.email "ghc-ci at gitlab-haskell.org" + git config user.name "GHC GitLab CI" + + info "=====================================================" + info "Toolchain versions" + info "=====================================================" + show_tool GHC + show_tool CABAL + show_tool HAPPY + show_tool ALEX +} + +function fetch_ghc() { + local v="$GHC_VERSION" + if [[ -z "$v" ]]; then + fail "GHC_VERSION is not set" + fi + + if [ ! -e "$GHC" ]; then + start_section "fetch GHC" + url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple}.tar.xz" + info "Fetching GHC binary distribution from $url..." + curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution" + tar -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution" + case "$(uname)" in + MSYS_*|MINGW*) + cp -r "ghc-${GHC_VERSION}"/* "$toolchain" + ;; + *) + pushd "ghc-${GHC_VERSION}" + ./configure --prefix="$toolchain" + "$MAKE" install + popd + ;; + esac + rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz + end_section "fetch GHC" + fi + +} + +function fetch_cabal() { + local v="$CABAL_INSTALL_VERSION" + if [[ -z "$v" ]]; then + fail "CABAL_INSTALL_VERSION is not set" + fi + + if [ ! -e "$CABAL" ]; then + start_section "fetch GHC" + case "$(uname)" in + # N.B. Windows uses zip whereas all others use .tar.xz + MSYS_*|MINGW*) + case "$MSYSTEM" in + MINGW32) cabal_arch="i386" ;; + MINGW64) cabal_arch="x86_64" ;; + *) fail "unknown MSYSTEM $MSYSTEM" ;; + esac + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-unknown-mingw32.zip" + info "Fetching cabal binary distribution from $url..." + curl "$url" > "$TMP/cabal.zip" + unzip "$TMP/cabal.zip" + mv cabal.exe "$CABAL" + ;; + *) + local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/" + case "$(uname)" in + Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;; + FreeBSD) + #cabal_url="$base_url/cabal-install-$v-x86_64-portbld-freebsd.tar.xz" ;; + cabal_url="http://home.smart-cactus.org/~ben/ghc/cabal-install-3.0.0.0-x86_64-portbld-freebsd.tar.xz" ;; + *) fail "don't know where to fetch cabal-install for $(uname)" + esac + echo "Fetching cabal-install from $cabal_url" + curl "$cabal_url" > cabal.tar.xz + tar -xJf cabal.tar.xz + mv cabal "$toolchain/bin" + ;; + esac + end_section "fetch GHC" + fi +} + +# For non-Docker platforms we prepare the bootstrap toolchain +# here. For Docker platforms this is done in the Docker image +# build. +function setup_toolchain() { + fetch_ghc + fetch_cabal + cabal_install="$CABAL v2-install --index-state=$hackage_index_state --installdir=$toolchain/bin" + # Avoid symlinks on Windows + case "$(uname)" in + MSYS_*|MINGW*) cabal_install="$cabal_install --install-method=copy" ;; + *) ;; + esac + + if [ ! -e "$HAPPY" ]; then + info "Building happy..." + cabal update + $cabal_install happy + fi + + if [ ! -e "$ALEX" ]; then + info "Building alex..." + cabal update + $cabal_install alex + fi +} + +function cleanup_submodules() { + start_section "clean submodules" + info "Cleaning submodules..." + # On Windows submodules can inexplicably get into funky states where git + # believes that the submodule is initialized yet its associated repository + # is not valid. Avoid failing in this case with the following insanity. + git submodule sync --recursive || git submodule deinit --force --all + git submodule update --init --recursive + git submodule foreach git clean -xdf + end_section "clean submodules" +} + +function prepare_build_mk() { + if [[ -z "$BUILD_FLAVOUR" ]]; then fail "BUILD_FLAVOUR is not set"; fi + if [[ -z ${BUILD_SPHINX_HTML:-} ]]; then BUILD_SPHINX_HTML=YES; fi + if [[ -z ${BUILD_SPHINX_PDF:-} ]]; then BUILD_SPHINX_PDF=YES; fi + if [[ -z ${INTEGER_LIBRARY:-} ]]; then INTEGER_LIBRARY=integer-gmp; fi + + cat > mk/build.mk <> mk/build.mk + fi + + case "$(uname)" in + Darwin) echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk ;; + *) ;; + esac + + info "build.mk is:" + cat mk/build.mk +} + +function configure() { + start_section "booting" + run python3 boot + end_section "booting" + + local target_args="" + if [[ -n "$triple" ]]; then + target_args="--target=$triple" + fi + + start_section "configuring" + run ./configure \ + --enable-tarballs-autodownload \ + $target_args \ + $CONFIGURE_ARGS \ + GHC="$GHC" \ + HAPPY="$HAPPY" \ + ALEX="$ALEX" \ + || ( cat config.log; fail "configure failed" ) + end_section "configuring" +} + +function build_make() { + prepare_build_mk + if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then + fail "BIN_DIST_PREP_TAR_COMP is not set" + fi + + echo "include mk/flavours/${BUILD_FLAVOUR}.mk" > mk/build.mk + echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk + run "$MAKE" -j"$cores" $MAKE_ARGS + run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 + ls -lh "$BIN_DIST_PREP_TAR_COMP" +} + +function fetch_perf_notes() { + info "Fetching perf notes..." + "$TOP/.gitlab/test-metrics.sh" pull +} + +function push_perf_notes() { + info "Pushing perf notes..." + "$TOP/.gitlab/test-metrics.sh" push +} + +function test_make() { + run "$MAKE" test_bindist TEST_PREP=YES + run "$MAKE" V=0 test \ + THREADS="$cores" \ + JUNIT_FILE=../../junit.xml +} + +function build_hadrian() { + if [ -z "$FLAVOUR" ]; then + fail "FLAVOUR not set" + fi + + run_hadrian binary-dist + + mv _build/bindist/ghc*.tar.xz ghc.tar.xz +} + +function test_hadrian() { + cd _build/bindist/ghc-*/ + run ./configure --prefix="$TOP"/_build/install + run "$MAKE" install + cd ../../../ + + run_hadrian \ + test \ + --summary-junit=./junit.xml \ + --test-compiler="$TOP"/_build/install/bin/ghc +} + +function clean() { + rm -R tmp + run "$MAKE" --quiet clean || true + run rm -Rf _build +} + +function run_hadrian() { + run hadrian/build-cabal \ + --flavour="$FLAVOUR" \ + -j"$cores" \ + --broken-test="$BROKEN_TESTS" \ + $HADRIAN_ARGS \ + $@ +} + +# A convenience function to allow debugging in the CI environment. +function shell() { + local cmd=$@ + if [ -z "$cmd" ]; then + cmd="bash -i" + fi + run $cmd +} + +# Determine Cabal data directory +case "$(uname)" in + MSYS_*|MINGW*) exe=".exe"; cabal_dir="$APPDATA/cabal" ;; + *) cabal_dir="$HOME/.cabal"; exe="" ;; +esac + +# Platform-specific environment initialization +MAKE="make" +case "$(uname)" in + MSYS_*|MINGW*) mingw_init ;; + Darwin) boot_triple="x86_64-apple-darwin" ;; + FreeBSD) + boot_triple="x86_64-portbld-freebsd" + MAKE="gmake" + ;; + Linux) ;; + *) fail "uname $(uname) is not supported" ;; +esac + +set_toolchain_paths + +case $1 in + setup) setup && cleanup_submodules ;; + configure) configure ;; + build_make) build_make ;; + test_make) + fetch_perf_notes + res=0 + test_make || res=$? + push_perf_notes + exit $res ;; + build_hadrian) build_hadrian ;; + # N.B. Always push notes, even if the build fails. This is okay to do as the + # testsuite driver doesn't record notes for tests that fail due to + # correctness. + test_hadrian) + fetch_perf_notes + res=0 + test_hadrian || res=$? + push_perf_notes + exit $res ;; + run_hadrian) run_hadrian $@ ;; + clean) clean ;; + shell) shell $@ ;; + *) fail "unknown mode $1" ;; +esac ===================================== .gitlab/darwin-init.sh deleted ===================================== @@ -1,41 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $HOME/.cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - mkdir -p tmp - cd tmp - ghc_tarball="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-x86_64-apple-darwin.tar.xz" - echo "Fetching GHC from $ghc_tarball" - curl $ghc_tarball | tar -xJ - cd ghc-$GHC_VERSION - ./configure --prefix=$toolchain - make install - cd ../.. - rm -Rf tmp -fi - -if [ ! -e $toolchain/bin/cabal ]; then - cabal_tarball="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL_VERSION/cabal-install-$CABAL_INSTALL_VERSION-x86_64-apple-darwin-sierra.tar.xz" - echo "Fetching cabal-install from $cabal_tarball" - curl $cabal_tarball | tar -xz - mv cabal $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal new-install happy --symlink-bindir=$toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal new-install alex --symlink-bindir=$toolchain/bin -fi - ===================================== .gitlab/linters/check-makefiles.py ===================================== @@ -1,5 +1,11 @@ #!/usr/bin/env python3 +""" +Linters for testsuite makefiles +""" + +from linter import run_linters, RegexpLinter + """ Warn for use of `--interactive` inside Makefiles (#11468). @@ -7,13 +13,21 @@ Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to forget one of those flags when adding a new test. """ +interactive_linter = \ + RegexpLinter(r'--interactive', + message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`." + ).add_path_filter(lambda path: path.name == 'Makefile') -from linter import run_linters, RegexpLinter +test_hc_quotes_linter = \ + RegexpLinter('\t\\$\\(TEST_HC\\)', + message = "Warning: $(TEST_HC) should be quoted in Makefiles.", + ).add_path_filter(lambda path: path.name == 'Makefile') linters = [ - RegexpLinter(r'--interactive', - message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`.") + interactive_linter, + test_hc_quotes_linter, ] if __name__ == '__main__': - run_linters(linters) #$, subdir='testsuite') + run_linters(linters, + subdir='testsuite') ===================================== .gitlab/linters/check-version-number.sh ===================================== @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +grep -E -q '\[[0-9]+\.[0-9]+\.[0-9]+\]' configure.ac || + ( echo "error: configure.ac: GHC version number must have three components."; exit 1 ) ===================================== .gitlab/linters/linter.py ===================================== @@ -7,10 +7,11 @@ import sys import re import textwrap import subprocess -from typing import List, Optional +from pathlib import Path +from typing import List, Optional, Callable, Sequence from collections import namedtuple -def lint_failure(file, line_no, line_content, message): +def lint_failure(file, line_no: int, line_content: str, message: str): """ Print a lint failure message. """ wrapper = textwrap.TextWrapper(initial_indent=' ', subsequent_indent=' ') @@ -29,7 +30,7 @@ def lint_failure(file, line_no, line_content, message): print(textwrap.dedent(msg)) -def get_changed_files(base_commit, head_commit, +def get_changed_files(base_commit: str, head_commit: str, subdir: str = '.'): """ Get the files changed by the given range of commits. """ cmd = ['git', 'diff', '--name-only', @@ -46,12 +47,21 @@ class Linter(object): """ def __init__(self): self.warnings = [] # type: List[Warning] + self.path_filters = [] # type: List[Callable[[Path], bool]] def add_warning(self, w: Warning): self.warnings.append(w) - def lint(self, path): - pass + def add_path_filter(self, f: Callable[[Path], bool]) -> "Linter": + self.path_filters.append(f) + return self + + def do_lint(self, path: Path): + if all(f(path) for f in self.path_filters): + self.lint(path) + + def lint(self, path: Path): + raise NotImplementedError class LineLinter(Linter): """ @@ -59,44 +69,55 @@ class LineLinter(Linter): the given line from a file and calls :func:`add_warning` for any lint issues found. """ - def lint(self, path): - if os.path.isfile(path): - with open(path, 'r') as f: + def lint(self, path: Path): + if path.is_file(): + with path.open('r') as f: for line_no, line in enumerate(f): self.lint_line(path, line_no+1, line) - def lint_line(self, path, line_no, line): - pass + def lint_line(self, path: Path, line_no: int, line: str): + raise NotImplementedError class RegexpLinter(LineLinter): """ A :class:`RegexpLinter` produces the given warning message for all lines matching the given regular expression. """ - def __init__(self, regex, message): + def __init__(self, regex: str, message: str): LineLinter.__init__(self) self.re = re.compile(regex) self.message = message - def lint_line(self, path, line_no, line): + def lint_line(self, path: Path, line_no: int, line: str): if self.re.search(line): w = Warning(path=path, line_no=line_no, line_content=line[:-1], message=self.message) self.add_warning(w) -def run_linters(linters: List[Linter], +def run_linters(linters: Sequence[Linter], subdir: str = '.') -> None: import argparse parser = argparse.ArgumentParser() - parser.add_argument('base', help='Base commit') - parser.add_argument('head', help='Head commit') + subparsers = parser.add_subparsers() + + subparser = subparsers.add_parser('commits', help='Lint a range of commits') + subparser.add_argument('base', help='Base commit') + subparser.add_argument('head', help='Head commit') + subparser.set_defaults(get_linted_files=lambda args: + get_changed_files(args.base, args.head, subdir)) + + subparser = subparsers.add_parser('files', help='Lint a range of commits') + subparser.add_argument('file', nargs='+', help='File to lint') + subparser.set_defaults(get_linted_files=lambda args: args.file) + args = parser.parse_args() - for path in get_changed_files(args.base, args.head, subdir): + linted_files = args.get_linted_files(args) + for path in linted_files: if path.startswith('.gitlab/linters'): continue for linter in linters: - linter.lint(path) + linter.do_lint(Path(path)) warnings = [warning for linter in linters ===================================== .gitlab/win32-init.sh deleted ===================================== @@ -1,50 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:/mingw64/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $APPDATA/cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - case $MSYSTEM in - MINGW32) - triple="i386-unknown-mingw32" - ;; - MINGW64) - triple="x86_64-unknown-mingw32" - ;; - *) - echo "win32-init: Unknown MSYSTEM $MSYSTEM" - exit 1 - ;; - esac - if [ -z "$GHC_TARBALL_URL" ]; then - GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" - fi - curl "$GHC_TARBALL_URL" | tar -xJ - mv ghc-$GHC_VERSION toolchain -fi - -if [ ! -e $toolchain/bin/cabal ]; then - url="https://downloads.haskell.org/~cabal/cabal-install-2.4.1.0/cabal-install-2.4.1.0-x86_64-unknown-mingw32.zip" - curl $url > /tmp/cabal.zip - unzip /tmp/cabal.zip - mv cabal.exe $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal install happy - cp $APPDATA/cabal/bin/happy $toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal install alex - cp $APPDATA/cabal/bin/alex $toolchain/bin -fi - ===================================== hadrian/ci.project ===================================== @@ -0,0 +1,4 @@ +packages: ./ + +package hadrian + -- ghc-options: -Werror ===================================== hadrian/src/Hadrian/Utilities.hs ===================================== @@ -37,7 +37,6 @@ import Control.Monad.Extra import Data.Char import Data.Dynamic (Dynamic, fromDynamic, toDyn) import Data.HashMap.Strict (HashMap) -import Data.List (isPrefixOf) import Data.List.Extra import Data.Maybe import Data.Typeable (TypeRep, typeOf) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/79177f96a53a282cff1b548ebe322601cf58bc6b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/79177f96a53a282cff1b548ebe322601cf58bc6b You're receiving 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 Jul 11 17:31:34 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 13:31:34 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] Backport CI infrastructure rework Message-ID: <5f09f7761605f_80b3f8486b77e4826617a6@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 39c1f10c by Ben Gamari at 2020-07-11T13:31:22-04:00 Backport CI infrastructure rework - - - - - 9 changed files: - .gitlab-ci.yml - + .gitlab/ci.sh - − .gitlab/darwin-init.sh - .gitlab/linters/check-makefiles.py - + .gitlab/linters/check-version-number.sh - .gitlab/linters/linter.py - − .gitlab/win32-init.sh - + hadrian/ci.project - hadrian/src/Hadrian/Utilities.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,59 +2,45 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a + DOCKER_REV: 6223fe0b5942f4fa35bdec92c74566cf195bfb42 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/win32-init.sh. + # .gitlab/ci.sh. WINDOWS_TOOLCHAIN_VERSION: 1 -before_script: - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + # Disable shallow clones; they break our linting rules + GIT_DEPTH: 0 + + # Overridden by individual jobs + CONFIGURE_ARGS: "" + + GIT_SUBMODULE_STRATEGY: "recursive" stages: - - lint # Source linting - - build # A quick smoke-test to weed out broken commits - - full-build # Build all the things - - cleanup # See Note [Cleanup on Windows] - - packaging # Source distribution, etc. - - hackage # head.hackage testing - - deploy # push documentation - -.only-default: &only-default - rules: - - if: $CI_MERGE_REQUEST_ID - - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "master"' - - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - - if: '$CI_PIPELINE_SOURCE == "web"' + - lint # Source linting + - quick-build # A very quick smoke-test to weed out broken commits + - build # A quick smoke-test to weed out broken commits + - full-build # Build all the things + - cleanup # See Note [Cleanup after the shell executor] + - packaging # Source distribution, etc. + - testing # head.hackage correctness and compiler performance testing + - deploy # push documentation workflow: - # N.B. Don't run on wip/ branches, instead on run on merge requests. + # N.B.Don't run on wip/ branches, instead on run on merge requests. rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' -############################################################ -# Runner Tags -############################################################ -# -# * x86_64-linux: Any Docker-capable x86_64 Linux machine -# * aarch64-linux: Any Docker-capable AArch64 Linux machine -# * x86_64-windows: A x86_64 Windows machine -# * lint: Any Docker-capable x86_64 Linux machine; distinct from -# x86_64-linux to ensure low-latency availability. -# - .nightly: &nightly rules: - if: $NIGHTLY + artifacts: + when: always + expire_in: 8 weeks .release: &release variables: @@ -66,53 +52,105 @@ workflow: rules: - if: '$RELEASE == "yes"' +############################################################ +# Runner Tags +############################################################ +# +# * x86_64-linux: Any Docker-capable x86_64 Linux machine +# * aarch64-linux: Any Docker-capable AArch64 Linux machine +# * x86_64-windows: A x86_64 Windows machine +# * lint: Any Docker-capable x86_64 Linux machine; distinct from +# x86_64-linux to ensure low-latency availability. +# + ############################################################ # Linting ############################################################ ghc-linters: - allow_failure: true stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" - - "echo Merge base $base" + - "echo Linting changes between $base..$CI_COMMIT_SHA" # - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA) - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA) - - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA - - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA + - .gitlab/linters/check-makefiles.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-cpp.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-version-number.sh + - python3 utils/checkUniques/check-uniques.py . dependencies: [] tags: - lint rules: - if: $CI_MERGE_REQUEST_ID +# Run mypy Python typechecker on linter scripts. +lint-linters: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy .gitlab/linters/*.py + dependencies: [] + tags: + - lint + +# Check that .T files all parse by listing broken tests. +lint-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + script: + - make -Ctestsuite list_broken TEST_HC=ghc + dependencies: [] + tags: + - lint + +# Run mypy Python typechecker on testsuite driver +.typecheck-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy testsuite/driver/runtests.py + dependencies: [] + tags: + - lint + # We allow the submodule checker to fail when run on merge requests (to -# accomodate, e.g., haddock changes not yet upstream) but not on `master` or +# accommodate, e.g., haddock changes not yet upstream) but not on `master` or # Marge jobs. .lint-submods: stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA) + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" + - "echo Linting submodule changes between $base..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $base..$CI_COMMIT_SHA) dependencies: [] tags: - lint lint-submods: extends: .lint-submods + # Allow failure on merge requests since any necessary submodule patches may + # not be upstreamed yet. rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/' allow_failure: false - allow_failure: true -lint-submods-mr: +lint-submods-branch: extends: .lint-submods - allow_failure: true + script: + - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA) rules: - - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' .lint-changelogs: stage: lint @@ -125,6 +163,7 @@ lint-submods-mr: lint-changelogs: extends: .lint-changelogs + # Allow failure since this isn't a final release. allow_failure: true rules: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' @@ -140,71 +179,183 @@ lint-release-changelogs: ############################################################ .validate-hadrian: - <<: *only-default - allow_failure: true + variables: + FLAVOUR: "validate" script: - - cabal update - - git clean -xdf && git submodule foreach git clean -xdf - - bash .circleci/prepare-system.sh - - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi - - ./boot - - ./configure $CONFIGURE_ARGS - - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian cache: key: hadrian paths: - cabal-cache artifacts: - when: always + reports: + junit: junit.xml + expire_in: 2 week paths: - ghc.tar.xz + - junit.xml -validate-x86_64-linux-deb8-hadrian: +.validate-linux-hadrian: extends: .validate-hadrian - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + variables: + TEST_ENV: "x86_64-linux-deb9-hadrian" before_script: # workaround for docker permissions - sudo chown ghc:ghc -R . - - python3 .gitlab/fix-submodules.py - git submodule sync --recursive - git submodule update --init --recursive - git checkout .gitmodules - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + after_script: + - .gitlab/ci.sh clean tags: - x86_64-linux +validate-x86_64-linux-deb9-hadrian: + extends: .validate-linux-hadrian + stage: build + +validate-x86_64-linux-deb9-unreg-hadrian: + extends: .validate-linux-hadrian + stage: full-build + variables: + CONFIGURE_ARGS: --enable-unregisterised + TEST_ENV: "x86_64-linux-deb9-unreg-hadrian" + +.hadrian-ghc-in-ghci: + stage: quick-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + variables: + GHC_FLAGS: -Werror + tags: + - x86_64-linux + script: + - cabal update + - cd hadrian; cabal new-build --project-file=ci.project; cd .. + - git clean -xdf && git submodule foreach git clean -xdf + - .gitlab/ci.sh setup + - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi + - ./boot + - ./configure $CONFIGURE_ARGS + # 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," + cache: + key: hadrian-ghci + paths: + - cabal-cache ############################################################ # Validation via Pipelines (make) ############################################################ .validate: - <<: *only-default variables: TEST_TYPE: test - before_script: - - git clean -xdf && git submodule foreach git clean -xdf + MAKE_ARGS: "-Werror" script: - - ./boot - - ./configure $CONFIGURE_ARGS - - | - THREADS=`mk/detect-cpu-count.sh` - make V=0 -j$THREADS WERROR=-Werror - - | - make binary-dist TAR_COMP_OPTS="-1" - - | - THREADS=`mk/detect-cpu-count.sh` - make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_make + - .gitlab/ci.sh test_make dependencies: [] artifacts: reports: junit: junit.xml expire_in: 2 week paths: - - ghc-*.tar.xz + - $BIN_DIST_PREP_TAR_COMP - junit.xml + - performance-metrics.tsv + +################################# +# x86_64-freebsd +################################# + +.build-x86_64-freebsd: + extends: .validate + tags: + - x86_64-freebsd + allow_failure: true + variables: + # N.B. we use iconv from ports as I see linker errors when we attempt + # to use the "native" iconv embedded in libc as suggested by the + # porting guide [1]. + # [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + GHC_VERSION: 8.10.1 + CABAL_INSTALL_VERSION: 3.2.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd" + BUILD_FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Conditional due to lack of builder capacity +validate-x86_64-freebsd: + extends: .build-x86_64-freebsd + stage: full-build + rules: + - if: '$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/' + +nightly-x86_64-freebsd: + <<: *nightly + extends: .build-x86_64-freebsd + stage: full-build + +release-x86_64-freebsd: + <<: *release + extends: .build-x86_64-freebsd + stage: full-build + +.build-x86_64-freebsd-hadrian: + extends: .validate-hadrian + stage: full-build + tags: + - x86_64-freebsd + allow_failure: true + variables: + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + HADRIAN_ARGS: "--docs=no-sphinx" + GHC_VERSION: 8.6.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd-hadrian" + FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Disabled due to lack of builder capacity +.validate-x86_64-freebsd-hadrian: + extends: .build-x86_64-freebsd-hadrian + stage: full-build ################################# # x86_64-darwin @@ -216,54 +367,71 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: "8.8.3" - CABAL_INSTALL_VERSION: 2.4.1.0 - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz" + GHC_VERSION: 8.8.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-apple-darwin.tar.xz" MACOSX_DEPLOYMENT_TARGET: "10.7" # Only Sierra and onwards supports clock_gettime. See #12858 ac_cv_func_clock_gettime: "no" LANG: "en_US.UTF-8" - CONFIGURE_ARGS: --with-intree-gmp + CONFIGURE_ARGS: "--with-intree-gmp" TEST_ENV: "x86_64-darwin" - before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - - bash .gitlab/darwin-init.sh - - PATH="`pwd`/toolchain/bin:$PATH" + BUILD_FLAVOUR: "perf" after_script: - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean artifacts: when: always expire_in: 2 week cache: - key: darwin + key: "darwin-$GHC_VERSION" paths: - cabal-cache - toolchain +# Disabled because of OS X CI capacity +.validate-x86_64-darwin-hadrian: + stage: full-build + tags: + - x86_64-darwin + variables: + GHC_VERSION: 8.8.3 + MACOSX_DEPLOYMENT_TARGET: "10.7" + ac_cv_func_clock_gettime: "no" + LANG: "en_US.UTF-8" + CONFIGURE_ARGS: --with-intree-gmp + TEST_ENV: "x86_64-darwin-hadrian" + FLAVOUR: "validate" + script: + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + reports: + junit: junit.xml + paths: + - ghc.tar.xz + - junit.xml + .validate-linux: extends: .validate tags: - x86_64-linux + variables: + BUILD_FLAVOUR: "perf" before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" # Build hyperlinked sources for documentation when building releases - | if [[ -n "$CI_COMMIT_TAG" ]]; then - echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk + HADDOCK_HYPERLINKED_SOURCES=1 fi - - bash .circleci/prepare-system.sh # workaround for docker permissions - sudo chown ghc:ghc -R . after_script: @@ -285,9 +453,7 @@ validate-x86_64-darwin: allow_failure: true variables: TEST_ENV: "aarch64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz" - # Inexplicably makeindex fails - BUILD_SPHINX_PDF: "NO" + BIN_DIST_PREP_TAR_COMP: "ghc-aarch64-linux-deb9.tar.xz" cache: key: linux-aarch64-deb9 tags: @@ -302,8 +468,41 @@ validate-aarch64-linux-deb9: nightly-aarch64-linux-deb9: <<: *nightly extends: .build-aarch64-linux-deb9 + variables: + TEST_TYPE: slowtest + +################################# +# armv7-linux-deb9 +################################# + +.build-armv7-linux-deb9: + extends: .validate-linux + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb9:$DOCKER_REV" + # Due to linker issues + allow_failure: true + variables: + TEST_ENV: "armv7-linux-deb9" + BIN_DIST_PREP_TAR_COMP: "ghc-armv7-linux-deb9.tar.xz" + CONFIGURE_ARGS: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" + # N.B. We disable ld.lld explicitly here because it appears to fail + # non-deterministically on ARMv7. See #18280. + LD: "ld.gold" + GccUseLdOpt: "-fuse-ld=gold" + cache: + key: linux-armv7-deb9 + tags: + - armv7-linux + +validate-armv7-linux-deb9: + extends: .build-armv7-linux-deb9 artifacts: - expire_in: 2 year + when: always + expire_in: 2 week + +nightly-armv7-linux-deb9: + <<: *nightly + extends: .build-armv7-linux-deb9 variables: TEST_TYPE: slowtest @@ -317,7 +516,7 @@ nightly-aarch64-linux-deb9: image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "i386-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-i386-deb9-linux.tar.xz" cache: key: linux-i386-deb9 @@ -332,23 +531,6 @@ nightly-i386-linux-deb9: extends: .build-i386-linux-deb9 variables: TEST_TYPE: slowtest - artifacts: - when: always - expire_in: 2 week - -################################# -# x86_64-linux-deb10 -################################# - -.build-x86_64-linux-deb10: - extends: .validate-linux - stage: full-build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - variables: - TEST_ENV: "x86_64-linux-deb10" - BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" - cache: - key: linux-x86_64-deb10 ################################# # x86_64-linux-deb9 @@ -356,40 +538,62 @@ nightly-i386-linux-deb9: .build-x86_64-linux-deb9: extends: .validate-linux - stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb9-linux.tar.xz" cache: key: linux-x86_64-deb9 -validate-x86_64-linux-deb9: +# Disabled to reduce CI load +.validate-x86_64-linux-deb9: extends: .build-x86_64-linux-deb9 + stage: full-build artifacts: when: always expire_in: 2 week +release-x86_64-linux-deb9: + <<: *release + extends: .build-x86_64-linux-deb9 + stage: full-build + nightly-x86_64-linux-deb9: <<: *nightly extends: .build-x86_64-linux-deb9 - artifacts: - expire_in: 2 year + stage: full-build variables: TEST_TYPE: slowtest # N.B. Has DEBUG assertions enabled in stage2 validate-x86_64-linux-deb9-debug: extends: .build-x86_64-linux-deb9 - stage: build + stage: full-build variables: BUILD_FLAVOUR: validate + # Ensure that stage2 also has DEBUG enabled + ValidateSpeed: SLOW + # Override validate flavour default; see #16890. + BUILD_SPHINX_PDF: "YES" + TEST_TYPE: slowtest TEST_ENV: "x86_64-linux-deb9-debug" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-debug.tar.xz" + artifacts: + when: always + expire_in: 2 week -validate-x86_64-linux-deb9-llvm: +# Disabled to alleviate CI load +.validate-x86_64-linux-deb9-llvm: + extends: .build-x86_64-linux-deb9 + stage: full-build + variables: + BUILD_FLAVOUR: perf-llvm + TEST_ENV: "x86_64-linux-deb9-llvm" + +nightly-x86_64-linux-deb9-llvm: + <<: *nightly extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: BUILD_FLAVOUR: perf-llvm TEST_ENV: "x86_64-linux-deb9-llvm" @@ -397,11 +601,11 @@ validate-x86_64-linux-deb9-llvm: validate-x86_64-linux-deb9-integer-simple: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: + BUILD_FLAVOUR: validate INTEGER_LIBRARY: integer-simple - TEST_ENV: "x86_64-linux-deb9-integer-simple" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz" + TEST_ENV: "x86_64-linux-deb9-integer-simple-validate" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-integer-simple.tar.xz" nightly-x86_64-linux-deb9-integer-simple: <<: *nightly @@ -411,185 +615,205 @@ nightly-x86_64-linux-deb9-integer-simple: INTEGER_LIBRARY: integer-simple TEST_ENV: "x86_64-linux-deb9-integer-simple" TEST_TYPE: slowtest - artifacts: - expire_in: 2 year -validate-x86_64-linux-deb9-unreg: +validate-x86_64-linux-deb9-dwarf: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: - CONFIGURE_ARGS: --enable-unregisterised - TEST_ENV: "x86_64-linux-deb9-unreg" + CONFIGURE_ARGS: "--enable-dwarf-unwind" + BUILD_FLAVOUR: dwarf + TEST_ENV: "x86_64-linux-deb9-dwarf" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-dwarf.tar.xz" + +################################# +# x86_64-linux-deb10 +################################# -release-x86_64-linux-deb9-dwarf: +.build-x86_64-linux-deb10: extends: .validate-linux - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" - allow_failure: true + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb9" - artifacts: - when: always - expire_in: 2 week + TEST_ENV: "x86_64-linux-deb10" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" cache: - key: linux-x86_64-deb9 + key: linux-x86_64-deb10 +# Disabled to alleviate CI load +.validate-x86_64-linux-deb10: + extends: .build-x86_64-linux-deb10 + stage: full-build -release-x86_64-linux-deb10-dwarf: - <<: *release +nightly-x86_64-linux-deb10: + <<: *nightly extends: .build-x86_64-linux-deb10 variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb10-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb10-linux-dwarf.tar.xz" + TEST_TYPE: slowtest + +release-x86_64-linux-deb10: + <<: *release + extends: .build-x86_64-linux-deb10 ################################# # x86_64-linux-deb8 ################################# -release-x86_64-linux-deb8: - <<: *release +.build-x86_64-linux-deb8: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + # Due to #18298. + allow_failure: true variables: TEST_ENV: "x86_64-linux-deb8" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz" - # Disable sphinx PDF output as our Debian image doesn't have the requisite packages + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb8-linux.tar.xz" + # Debian 8's Sphinx is too old to support the table directive's :widths: + # option: https://sourceforge.net/p/docutils/patches/120/ + BUILD_SPHINX_HTML: "NO" + BUILD_SPHINX_INFO: "NO" BUILD_SPHINX_PDF: "NO" + BUILD_SPHINX_MAN: "NO" cache: key: linux-x86_64-deb8 + +release-x86_64-linux-deb8: + <<: *release + extends: .build-x86_64-linux-deb8 + +################################# +# x86_64-linux-alpine +################################# + +.build-x86_64-linux-alpine-hadrian: + extends: .validate-linux-hadrian + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine:$DOCKER_REV" + # There are currently a few failing tests + allow_failure: true + variables: + TEST_ENV: "x86_64-linux-alpine" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-alpine-linux.tar.xz" + # Can't use ld.gold due to #13958. + CONFIGURE_ARGS: "--disable-ld-override" + HADRIAN_ARGS: "--docs=no-sphinx" + # encoding004 due to lack of locale support + # T10458 due to fact that dynamic linker tries to reload libAS + BROKEN_TESTS: "encoding004 T10458" + cache: + key: linux-x86_64-alpine artifacts: when: always expire_in: 2 week +release-x86_64-linux-alpine: + <<: *release + extends: .build-x86_64-linux-alpine-hadrian + +nightly-x86_64-linux-alpine: + <<: *nightly + extends: .build-x86_64-linux-alpine-hadrian + ################################# # x86_64-linux-centos7 ################################# -release-x86_64-linux-centos7: - <<: *release +.build-x86_64-linux-centos7: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" variables: - # For the testsuite - LANG: "en_US.UTF-8" # The sphinx release shipped with Centos 7 fails to build out documentation BUILD_SPHINX_HTML: "NO" BUILD_SPHINX_PDF: "NO" TEST_ENV: "x86_64-linux-centos7" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz" - allow_failure: true + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-centos7-linux.tar.xz" + # CentOS seems to default to ascii + LANG: "en_US.UTF-8" cache: key: linux-x86_64-centos7 - artifacts: - when: always - expire_in: 2 week + +release-x86_64-linux-centos7: + <<: *release + extends: .build-x86_64-linux-centos7 ################################# # x86_64-linux-fedora27 ################################# -.build-x86_64-linux-fedora27: +validate-x86_64-linux-fedora27: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-fedora27" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: key: linux-x86_64-fedora27 - -validate-x86_64-linux-fedora27: - extends: .build-x86_64-linux-fedora27 artifacts: when: always # These are used for head.hackage jobs therefore we keep them around for # longer. expire_in: 8 week -release-x86_64-linux-fedora27: - <<: *release - extends: .build-x86_64-linux-fedora27 - -release-x86_64-linux-fedora27-dwarf: - <<: *release - extends: .build-x86_64-linux-fedora27 - variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-fedora27-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux-dwarf.tar.xz" - ############################################################ # Validation via Pipelines (Windows) ############################################################ .build-windows: - <<: *only-default + # For the reasons given in #17777 this build isn't reliable. + allow_failure: true before_script: - git clean -xdf - - git submodule foreach git clean -xdf - # Use a local temporary directory to ensure that concurrent builds don't - # interfere with one another - - | - mkdir tmp - set TMP=%cd%\tmp - set TEMP=%cd%\tmp - - - set PATH=C:\msys64\usr\bin;%PATH% - - python .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - bash .gitlab/win32-init.sh + # Setup toolchain + - bash .gitlab/ci.sh setup after_script: - - rd /s /q tmp - - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache - - bash -c 'make clean || true' + - | + Copy-Item -Recurse -Path $Env:APPDATA\cabal -Destination cabal-cache + - bash .gitlab/ci.sh clean dependencies: [] variables: - FORCE_SYMLINKS: 1 + #FORCE_SYMLINKS: 1 LANG: "en_US.UTF-8" SPHINXBUILD: "/mingw64/bin/sphinx-build.exe" + CABAL_INSTALL_VERSION: 3.0.0.0 + GHC_VERSION: "8.8.3" cache: paths: - cabal-cache - - ghc-8.6.2 + - toolchain - ghc-tarballs .build-windows-hadrian: extends: .build-windows stage: full-build - allow_failure: true variables: - GHC_VERSION: "8.8.3" + FLAVOUR: "validate" + # skipping perf tests for now since we build a quick-flavoured GHC, + # which might result in some broken perf tests? + HADRIAN_ARGS: "--docs=no-sphinx --skip-perf" + script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex' - - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist" - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz - # FIXME: Testsuite disabled due to #16156. - # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_hadrian + - bash .gitlab/ci.sh test_hadrian tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: + reports: + junit: junit.xml + expire_in: 2 week when: always paths: - ghc.tar.xz + - junit.xml validate-x86_64-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW64 + TEST_ENV: "x86_64-windows-hadrian" cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" @@ -598,86 +822,94 @@ nightly-i386-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW32 + TEST_ENV: "i386-windows-hadrian" cache: key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" .build-windows-make: extends: .build-windows stage: full-build - # due to #16084 - allow_failure: true variables: - BUILD_FLAVOUR: "UNSET" - GHC_VERSION: "8.8.3" - BUILD_PROF_LIBS: "YES" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz" + BUILD_FLAVOUR: "quick" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-mingw32.tar.xz" script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS' - - bash -c "echo \"include mk/flavours/${BUILD_FLAVOUR}.mk\" > mk/build.mk" - - bash -c "echo \"GhcLibHcOpts+=-haddock\" >> mk/build.mk" - - bash -c "echo \"BUILD_PROF_LIBS = $BUILD_PROF_LIBS\" >> mk/build.mk" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1" - - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_make + - bash .gitlab/ci.sh test_make tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: when: always expire_in: 2 week reports: junit: junit.xml paths: - - ghc-*.tar.xz + # N.B. variable interpolation apparently doesn't work on Windows so + # this can't be $BIN_DIST_PREP_TAR_COMP + - "ghc-x86_64-mingw32.tar.xz" - junit.xml -validate-x86_64-windows: +.build-x86_64-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" - BUILD_FLAVOUR: "quick" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" + TEST_ENV: "x86_64-windows" cache: key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-x86_64-windows: + extends: .build-x86_64-windows-make + +nightly-x86_64-windows: + <<: *nightly + extends: .build-x86_64-windows-make + stage: full-build + variables: + BUILD_FLAVOUR: "validate" + # Normal Windows validate builds are profiled; that won't do for releases. release-x86_64-windows: <<: *release extends: validate-x86_64-windows variables: - MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" - -release-i386-windows: + # +release-x86_64-windows-integer-simple: <<: *release - extends: .build-windows-make + extends: validate-x86_64-windows variables: - MSYSTEM: MINGW32 + INTEGER_LIBRARY: integer-simple BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - # Due to #15934 - BUILD_PROF_LIBS: "NO" - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows: - <<: *nightly + +.build-i386-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW32 - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - BUILD_FLAVOUR: "quick" # Due to #15934 BUILD_PROF_LIBS: "NO" + TEST_ENV: "i386-windows" + # Due to #17736 + allow_failure: true cache: key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-i386-windows: + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +release-i386-windows: + <<: *release + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +nightly-i386-windows: + <<: *nightly + extends: .build-i386-windows-make + ############################################################ # Cleanup ############################################################ @@ -687,40 +919,24 @@ nightly-i386-windows: # # As noted in [1], gitlab-runner's shell executor doesn't clean up its working # directory after builds. Unfortunately, we are forced to use the shell executor -# on Windows. To avoid running out of disk space we add a stage at the end of -# the build to remove the \GitLabRunner\builds directory. Since we only run a -# single build at a time on Windows this should be safe. +# on Darwin. To avoid running out of disk space we add a stage at the end of +# the build to remove the /.../GitLabRunner/builds directory. Since we only run a +# single build at a time on Darwin this should be safe. +# +# We used to have a similar cleanup job on Windows as well however it ended up +# being quite fragile as we have multiple Windows builders yet there is no +# guarantee that the cleanup job is run on the same machine as the build itself +# was run. Consequently we were forced to instead handle cleanup with a separate +# cleanup cron job on Windows. # # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856 -# See Note [Cleanup after shell executor] -cleanup-windows: - <<: *only-default - stage: cleanup - tags: - - x86_64-windows - dependencies: [] - before_script: - - echo "Time to clean up" - script: - - echo "Let's go" - after_script: - - set "BUILD_DIR=%CI_PROJECT_DIR%" - - set "BUILD_DIR=%BUILD_DIR:/=\%" - - echo "Cleaning %BUILD_DIR%" - - cd \GitLabRunner - # This is way more complicated than it should be: - # See https://stackoverflow.com/questions/1965787 - - del %BUILD_DIR%\* /F /Q - - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p" - - exit /b 0 - # See Note [Cleanup after shell executor] cleanup-darwin: - <<: *only-default stage: cleanup tags: - x86_64-darwin + when: always dependencies: [] before_script: - echo "Time to clean up" @@ -737,19 +953,56 @@ cleanup-darwin: # Packaging ############################################################ +doc-tarball: + stage: packaging + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + dependencies: + - validate-x86_64-linux-deb9-debug + - validate-x86_64-windows + variables: + LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz" + WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz" + # Due to Windows allow_failure + allow_failure: true + artifacts: + paths: + - haddock.html.tar.xz + - libraries.html.tar.xz + - users_guide.html.tar.xz + - index.html + - "*.pdf" + script: + - | + if [ ! -f "$LINUX_BINDIST" ]; then + echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" + exit 1 + fi + if [ ! -f "$WINDOWS_BINDIST" ]; then + echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?" + exit 1 + fi + - rm -Rf docs + - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST + - ls -lh + - mv docs/*.tar.xz docs/index.html . + source-tarball: - <<: *release stage: packaging tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" dependencies: [] + rules: + - if: $CI_COMMIT_TAG + when: always artifacts: paths: - ghc-*.tar.xz - version script: - - mk/get-win32-tarballs.sh download all + - python3 mk/get-win32-tarballs.py download all - ./boot - ./configure - make sdist @@ -770,9 +1023,8 @@ source-tarball: # pipeline. .hackage: - <<: *only-default - stage: hackage - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + stage: testing + image: ghcci/x86_64-linux-deb9:0.2 tags: - x86_64-linux dependencies: [] @@ -781,6 +1033,10 @@ source-tarball: script: - bash .gitlab/start-head.hackage.sh +hackage: + extends: .hackage + when: manual + hackage-label: extends: .hackage rules: @@ -790,3 +1046,69 @@ nightly-hackage: <<: *nightly extends: .hackage +############################################################ +# Nofib testing +############################################################ + +perf-nofib: + stage: testing + dependencies: + - validate-x86_64-linux-deb9-dwarf + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + rules: + - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + tags: + - x86_64-linux + script: + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ghc-x86_64-deb9-linux-dwarf.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - cabal update; cabal install -w $BOOT_HC regex-compat + - export PATH=$root/bin:$PATH + - make -C nofib boot mode=fast -j$CPUS + - "make -C nofib EXTRA_RUNTEST_OPTS='-cachegrind +RTS -V0 -RTS' NoFibRuns=1 mode=fast -j$CPUS 2>&1 | tee nofib.log" + artifacts: + expire_in: 12 week + when: always + paths: + - nofib.log + +############################################################ +# Documentation deployment via GitLab Pages +############################################################ + +pages: + stage: deploy + dependencies: + - doc-tarball + image: ghcci/x86_64-linux-deb9:0.2 + # Due to Windows allow_failure + allow_failure: true + tags: + - x86_64-linux + script: + - mkdir -p public/doc + - tar -xf haddock.html.tar.xz -C public/doc + - tar -xf libraries.html.tar.xz -C public/doc + - tar -xf users_guide.html.tar.xz -C public/doc + - | + cat >public/index.html < + + + EOF + - cp -f index.html public/doc + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + artifacts: + paths: + - public ===================================== .gitlab/ci.sh ===================================== @@ -0,0 +1,464 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2230 + +# This is the primary driver of the GitLab CI infrastructure. + +set -e -o pipefail + +# Configuration: +hackage_index_state="@1579718451" + +# Colors +BLACK="0;30" +GRAY="1;30" +RED="0;31" +LT_RED="1;31" +BROWN="0;33" +LT_BROWN="1;33" +GREEN="0;32" +LT_GREEN="1;32" +BLUE="0;34" +LT_BLUE="1;34" +PURPLE="0;35" +LT_PURPLE="1;35" +CYAN="0;36" +LT_CYAN="1;36" +WHITE="1;37" +LT_GRAY="0;37" + +export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 + +# GitLab Pipelines log section delimiters +# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664 +start_section() { + name="$1" + echo -e "section_start:$(date +%s):$name\015\033[0K" +} + +end_section() { + name="$1" + echo -e "section_end:$(date +%s):$name\015\033[0K" +} + +echo_color() { + local color="$1" + local msg="$2" + echo -e "\033[${color}m${msg}\033[0m" +} + +error() { echo_color "${RED}" "$1"; } +warn() { echo_color "${LT_BROWN}" "$1"; } +info() { echo_color "${LT_BLUE}" "$1"; } + +fail() { error "error: $1"; exit 1; } + +function run() { + info "Running $*..." + "$@" || ( error "$* failed"; return 1; ) +} + +TOP="$(pwd)" + +function mingw_init() { + case "$MSYSTEM" in + MINGW32) + triple="i386-unknown-mingw32" + boot_triple="i386-unknown-mingw32" # triple of bootstrap GHC + ;; + MINGW64) + triple="x86_64-unknown-mingw32" + boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC + ;; + *) + fail "win32-init: Unknown MSYSTEM $MSYSTEM" + ;; + esac + + # Bring mingw toolchain into PATH. + # This is extracted from /etc/profile since this script inexplicably fails to + # run under gitlab-runner. + # shellcheck disable=SC1091 + source /etc/msystem + MINGW_MOUNT_POINT="${MINGW_PREFIX}" + PATH="$MINGW_MOUNT_POINT/bin:$PATH" + + # We always use mingw64 Python to avoid path length issues like #17483. + export PYTHON="/mingw64/bin/python3" +} + +# This will contain GHC's local native toolchain +toolchain="$TOP/toolchain" +mkdir -p "$toolchain/bin" +PATH="$toolchain/bin:$PATH" + +export METRICS_FILE="$CI_PROJECT_DIR/performance-metrics.tsv" + +cores="$(mk/detect-cpu-count.sh)" + +# Use a local temporary directory to ensure that concurrent builds don't +# interfere with one another +mkdir -p "$TOP/tmp" +export TMP="$TOP/tmp" +export TEMP="$TOP/tmp" + +function darwin_setup() { + # It looks like we already have python2 here and just installing python3 + # does not work. + brew upgrade python + brew install ghc cabal-install ncurses gmp + + pip3 install sphinx + # PDF documentation disabled as MacTeX apparently doesn't include xelatex. + #brew cask install mactex +} + +function show_tool() { + local tool="$1" + info "$tool = ${!tool}" + ${!tool} --version +} + +function set_toolchain_paths() { + needs_toolchain=1 + case "$(uname)" in + Linux) needs_toolchain="" ;; + *) ;; + esac + + if [[ -n "$needs_toolchain" ]]; then + # These are populated by setup_toolchain + GHC="$toolchain/bin/ghc$exe" + CABAL="$toolchain/bin/cabal$exe" + HAPPY="$toolchain/bin/happy$exe" + ALEX="$toolchain/bin/alex$exe" + else + GHC="$(which ghc)" + CABAL="/usr/local/bin/cabal" + HAPPY="$HOME/.cabal/bin/happy" + ALEX="$HOME/.cabal/bin/alex" + fi + export GHC + export CABAL + export HAPPY + export ALEX +} + +# Extract GHC toolchain +function setup() { + if [ -d "$TOP/cabal-cache" ]; then + info "Extracting cabal cache..." + mkdir -p "$cabal_dir" + cp -Rf cabal-cache/* "$cabal_dir" + fi + + if [[ -n "$needs_toolchain" ]]; then + setup_toolchain + fi + case "$(uname)" in + Darwin) darwin_setup ;; + *) ;; + esac + + # Make sure that git works + git config user.email "ghc-ci at gitlab-haskell.org" + git config user.name "GHC GitLab CI" + + info "=====================================================" + info "Toolchain versions" + info "=====================================================" + show_tool GHC + show_tool CABAL + show_tool HAPPY + show_tool ALEX +} + +function fetch_ghc() { + local v="$GHC_VERSION" + if [[ -z "$v" ]]; then + fail "GHC_VERSION is not set" + fi + + if [ ! -e "$GHC" ]; then + start_section "fetch GHC" + url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple}.tar.xz" + info "Fetching GHC binary distribution from $url..." + curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution" + tar -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution" + case "$(uname)" in + MSYS_*|MINGW*) + cp -r "ghc-${GHC_VERSION}"/* "$toolchain" + ;; + *) + pushd "ghc-${GHC_VERSION}" + ./configure --prefix="$toolchain" + "$MAKE" install + popd + ;; + esac + rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz + end_section "fetch GHC" + fi + +} + +function fetch_cabal() { + local v="$CABAL_INSTALL_VERSION" + if [[ -z "$v" ]]; then + fail "CABAL_INSTALL_VERSION is not set" + fi + + if [ ! -e "$CABAL" ]; then + start_section "fetch GHC" + case "$(uname)" in + # N.B. Windows uses zip whereas all others use .tar.xz + MSYS_*|MINGW*) + case "$MSYSTEM" in + MINGW32) cabal_arch="i386" ;; + MINGW64) cabal_arch="x86_64" ;; + *) fail "unknown MSYSTEM $MSYSTEM" ;; + esac + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-unknown-mingw32.zip" + info "Fetching cabal binary distribution from $url..." + curl "$url" > "$TMP/cabal.zip" + unzip "$TMP/cabal.zip" + mv cabal.exe "$CABAL" + ;; + *) + local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/" + case "$(uname)" in + Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;; + FreeBSD) + #cabal_url="$base_url/cabal-install-$v-x86_64-portbld-freebsd.tar.xz" ;; + cabal_url="http://home.smart-cactus.org/~ben/ghc/cabal-install-3.0.0.0-x86_64-portbld-freebsd.tar.xz" ;; + *) fail "don't know where to fetch cabal-install for $(uname)" + esac + echo "Fetching cabal-install from $cabal_url" + curl "$cabal_url" > cabal.tar.xz + tar -xJf cabal.tar.xz + mv cabal "$toolchain/bin" + ;; + esac + end_section "fetch GHC" + fi +} + +# For non-Docker platforms we prepare the bootstrap toolchain +# here. For Docker platforms this is done in the Docker image +# build. +function setup_toolchain() { + fetch_ghc + fetch_cabal + cabal_install="$CABAL v2-install --index-state=$hackage_index_state --installdir=$toolchain/bin" + # Avoid symlinks on Windows + case "$(uname)" in + MSYS_*|MINGW*) cabal_install="$cabal_install --install-method=copy" ;; + *) ;; + esac + + if [ ! -e "$HAPPY" ]; then + info "Building happy..." + cabal update + $cabal_install happy + fi + + if [ ! -e "$ALEX" ]; then + info "Building alex..." + cabal update + $cabal_install alex + fi +} + +function cleanup_submodules() { + start_section "clean submodules" + info "Cleaning submodules..." + # On Windows submodules can inexplicably get into funky states where git + # believes that the submodule is initialized yet its associated repository + # is not valid. Avoid failing in this case with the following insanity. + git submodule sync --recursive || git submodule deinit --force --all + git submodule update --init --recursive + git submodule foreach git clean -xdf + end_section "clean submodules" +} + +function prepare_build_mk() { + if [[ -z "$BUILD_FLAVOUR" ]]; then fail "BUILD_FLAVOUR is not set"; fi + if [[ -z ${BUILD_SPHINX_HTML:-} ]]; then BUILD_SPHINX_HTML=YES; fi + if [[ -z ${BUILD_SPHINX_PDF:-} ]]; then BUILD_SPHINX_PDF=YES; fi + if [[ -z ${INTEGER_LIBRARY:-} ]]; then INTEGER_LIBRARY=integer-gmp; fi + + cat > mk/build.mk <> mk/build.mk + fi + + case "$(uname)" in + Darwin) echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk ;; + *) ;; + esac + + info "build.mk is:" + cat mk/build.mk +} + +function configure() { + start_section "booting" + run python3 boot + end_section "booting" + + local target_args="" + if [[ -n "$triple" ]]; then + target_args="--target=$triple" + fi + + start_section "configuring" + run ./configure \ + --enable-tarballs-autodownload \ + $target_args \ + $CONFIGURE_ARGS \ + GHC="$GHC" \ + HAPPY="$HAPPY" \ + ALEX="$ALEX" \ + || ( cat config.log; fail "configure failed" ) + end_section "configuring" +} + +function build_make() { + prepare_build_mk + if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then + fail "BIN_DIST_PREP_TAR_COMP is not set" + fi + + echo "include mk/flavours/${BUILD_FLAVOUR}.mk" > mk/build.mk + echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk + run "$MAKE" -j"$cores" $MAKE_ARGS + run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 + ls -lh "$BIN_DIST_PREP_TAR_COMP" +} + +function fetch_perf_notes() { + info "Fetching perf notes..." + "$TOP/.gitlab/test-metrics.sh" pull +} + +function push_perf_notes() { + info "Pushing perf notes..." + "$TOP/.gitlab/test-metrics.sh" push +} + +function test_make() { + run "$MAKE" test_bindist TEST_PREP=YES + run "$MAKE" V=0 test \ + THREADS="$cores" \ + JUNIT_FILE=../../junit.xml +} + +function build_hadrian() { + if [ -z "$FLAVOUR" ]; then + fail "FLAVOUR not set" + fi + + run_hadrian binary-dist + + mv _build/bindist/ghc*.tar.xz ghc.tar.xz +} + +function test_hadrian() { + cd _build/bindist/ghc-*/ + run ./configure --prefix="$TOP"/_build/install + run "$MAKE" install + cd ../../../ + + run_hadrian \ + test \ + --summary-junit=./junit.xml \ + --test-compiler="$TOP"/_build/install/bin/ghc +} + +function clean() { + rm -R tmp + run "$MAKE" --quiet clean || true + run rm -Rf _build +} + +function run_hadrian() { + run hadrian/build.cabal.sh \ + --flavour="$FLAVOUR" \ + -j"$cores" \ + --broken-test="$BROKEN_TESTS" \ + $HADRIAN_ARGS \ + $@ +} + +# A convenience function to allow debugging in the CI environment. +function shell() { + local cmd=$@ + if [ -z "$cmd" ]; then + cmd="bash -i" + fi + run $cmd +} + +# Determine Cabal data directory +case "$(uname)" in + MSYS_*|MINGW*) exe=".exe"; cabal_dir="$APPDATA/cabal" ;; + *) cabal_dir="$HOME/.cabal"; exe="" ;; +esac + +# Platform-specific environment initialization +MAKE="make" +case "$(uname)" in + MSYS_*|MINGW*) mingw_init ;; + Darwin) boot_triple="x86_64-apple-darwin" ;; + FreeBSD) + boot_triple="x86_64-portbld-freebsd" + MAKE="gmake" + ;; + Linux) ;; + *) fail "uname $(uname) is not supported" ;; +esac + +set_toolchain_paths + +case $1 in + setup) setup && cleanup_submodules ;; + configure) configure ;; + build_make) build_make ;; + test_make) + fetch_perf_notes + res=0 + test_make || res=$? + push_perf_notes + exit $res ;; + build_hadrian) build_hadrian ;; + # N.B. Always push notes, even if the build fails. This is okay to do as the + # testsuite driver doesn't record notes for tests that fail due to + # correctness. + test_hadrian) + fetch_perf_notes + res=0 + test_hadrian || res=$? + push_perf_notes + exit $res ;; + run_hadrian) run_hadrian $@ ;; + clean) clean ;; + shell) shell $@ ;; + *) fail "unknown mode $1" ;; +esac ===================================== .gitlab/darwin-init.sh deleted ===================================== @@ -1,41 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $HOME/.cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - mkdir -p tmp - cd tmp - ghc_tarball="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-x86_64-apple-darwin.tar.xz" - echo "Fetching GHC from $ghc_tarball" - curl $ghc_tarball | tar -xJ - cd ghc-$GHC_VERSION - ./configure --prefix=$toolchain - make install - cd ../.. - rm -Rf tmp -fi - -if [ ! -e $toolchain/bin/cabal ]; then - cabal_tarball="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL_VERSION/cabal-install-$CABAL_INSTALL_VERSION-x86_64-apple-darwin-sierra.tar.xz" - echo "Fetching cabal-install from $cabal_tarball" - curl $cabal_tarball | tar -xz - mv cabal $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal new-install happy --symlink-bindir=$toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal new-install alex --symlink-bindir=$toolchain/bin -fi - ===================================== .gitlab/linters/check-makefiles.py ===================================== @@ -1,5 +1,11 @@ #!/usr/bin/env python3 +""" +Linters for testsuite makefiles +""" + +from linter import run_linters, RegexpLinter + """ Warn for use of `--interactive` inside Makefiles (#11468). @@ -7,13 +13,21 @@ Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to forget one of those flags when adding a new test. """ +interactive_linter = \ + RegexpLinter(r'--interactive', + message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`." + ).add_path_filter(lambda path: path.name == 'Makefile') -from linter import run_linters, RegexpLinter +test_hc_quotes_linter = \ + RegexpLinter('\t\\$\\(TEST_HC\\)', + message = "Warning: $(TEST_HC) should be quoted in Makefiles.", + ).add_path_filter(lambda path: path.name == 'Makefile') linters = [ - RegexpLinter(r'--interactive', - message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`.") + interactive_linter, + test_hc_quotes_linter, ] if __name__ == '__main__': - run_linters(linters) #$, subdir='testsuite') + run_linters(linters, + subdir='testsuite') ===================================== .gitlab/linters/check-version-number.sh ===================================== @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +grep -E -q '\[[0-9]+\.[0-9]+\.[0-9]+\]' configure.ac || + ( echo "error: configure.ac: GHC version number must have three components."; exit 1 ) ===================================== .gitlab/linters/linter.py ===================================== @@ -7,10 +7,11 @@ import sys import re import textwrap import subprocess -from typing import List, Optional +from pathlib import Path +from typing import List, Optional, Callable, Sequence from collections import namedtuple -def lint_failure(file, line_no, line_content, message): +def lint_failure(file, line_no: int, line_content: str, message: str): """ Print a lint failure message. """ wrapper = textwrap.TextWrapper(initial_indent=' ', subsequent_indent=' ') @@ -29,7 +30,7 @@ def lint_failure(file, line_no, line_content, message): print(textwrap.dedent(msg)) -def get_changed_files(base_commit, head_commit, +def get_changed_files(base_commit: str, head_commit: str, subdir: str = '.'): """ Get the files changed by the given range of commits. """ cmd = ['git', 'diff', '--name-only', @@ -46,12 +47,21 @@ class Linter(object): """ def __init__(self): self.warnings = [] # type: List[Warning] + self.path_filters = [] # type: List[Callable[[Path], bool]] def add_warning(self, w: Warning): self.warnings.append(w) - def lint(self, path): - pass + def add_path_filter(self, f: Callable[[Path], bool]) -> "Linter": + self.path_filters.append(f) + return self + + def do_lint(self, path: Path): + if all(f(path) for f in self.path_filters): + self.lint(path) + + def lint(self, path: Path): + raise NotImplementedError class LineLinter(Linter): """ @@ -59,44 +69,55 @@ class LineLinter(Linter): the given line from a file and calls :func:`add_warning` for any lint issues found. """ - def lint(self, path): - if os.path.isfile(path): - with open(path, 'r') as f: + def lint(self, path: Path): + if path.is_file(): + with path.open('r') as f: for line_no, line in enumerate(f): self.lint_line(path, line_no+1, line) - def lint_line(self, path, line_no, line): - pass + def lint_line(self, path: Path, line_no: int, line: str): + raise NotImplementedError class RegexpLinter(LineLinter): """ A :class:`RegexpLinter` produces the given warning message for all lines matching the given regular expression. """ - def __init__(self, regex, message): + def __init__(self, regex: str, message: str): LineLinter.__init__(self) self.re = re.compile(regex) self.message = message - def lint_line(self, path, line_no, line): + def lint_line(self, path: Path, line_no: int, line: str): if self.re.search(line): w = Warning(path=path, line_no=line_no, line_content=line[:-1], message=self.message) self.add_warning(w) -def run_linters(linters: List[Linter], +def run_linters(linters: Sequence[Linter], subdir: str = '.') -> None: import argparse parser = argparse.ArgumentParser() - parser.add_argument('base', help='Base commit') - parser.add_argument('head', help='Head commit') + subparsers = parser.add_subparsers() + + subparser = subparsers.add_parser('commits', help='Lint a range of commits') + subparser.add_argument('base', help='Base commit') + subparser.add_argument('head', help='Head commit') + subparser.set_defaults(get_linted_files=lambda args: + get_changed_files(args.base, args.head, subdir)) + + subparser = subparsers.add_parser('files', help='Lint a range of commits') + subparser.add_argument('file', nargs='+', help='File to lint') + subparser.set_defaults(get_linted_files=lambda args: args.file) + args = parser.parse_args() - for path in get_changed_files(args.base, args.head, subdir): + linted_files = args.get_linted_files(args) + for path in linted_files: if path.startswith('.gitlab/linters'): continue for linter in linters: - linter.lint(path) + linter.do_lint(Path(path)) warnings = [warning for linter in linters ===================================== .gitlab/win32-init.sh deleted ===================================== @@ -1,50 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:/mingw64/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $APPDATA/cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - case $MSYSTEM in - MINGW32) - triple="i386-unknown-mingw32" - ;; - MINGW64) - triple="x86_64-unknown-mingw32" - ;; - *) - echo "win32-init: Unknown MSYSTEM $MSYSTEM" - exit 1 - ;; - esac - if [ -z "$GHC_TARBALL_URL" ]; then - GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" - fi - curl "$GHC_TARBALL_URL" | tar -xJ - mv ghc-$GHC_VERSION toolchain -fi - -if [ ! -e $toolchain/bin/cabal ]; then - url="https://downloads.haskell.org/~cabal/cabal-install-2.4.1.0/cabal-install-2.4.1.0-x86_64-unknown-mingw32.zip" - curl $url > /tmp/cabal.zip - unzip /tmp/cabal.zip - mv cabal.exe $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal install happy - cp $APPDATA/cabal/bin/happy $toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal install alex - cp $APPDATA/cabal/bin/alex $toolchain/bin -fi - ===================================== hadrian/ci.project ===================================== @@ -0,0 +1,4 @@ +packages: ./ + +package hadrian + -- ghc-options: -Werror ===================================== hadrian/src/Hadrian/Utilities.hs ===================================== @@ -37,7 +37,6 @@ import Control.Monad.Extra import Data.Char import Data.Dynamic (Dynamic, fromDynamic, toDyn) import Data.HashMap.Strict (HashMap) -import Data.List (isPrefixOf) import Data.List.Extra import Data.Maybe import Data.Typeable (TypeRep, typeOf) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39c1f10c71d1e6348b5099b670a69b9343dfbc2e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39c1f10c71d1e6348b5099b670a69b9343dfbc2e You're receiving 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 Jul 11 17:44:33 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 13:44:33 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] Backport CI infrastructure rework Message-ID: <5f09fa81993ea_80b3f849c221f402662155@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 96e2e2a8 by Ben Gamari at 2020-07-11T13:44:21-04:00 Backport CI infrastructure rework - - - - - 9 changed files: - .gitlab-ci.yml - + .gitlab/ci.sh - − .gitlab/darwin-init.sh - .gitlab/linters/check-makefiles.py - + .gitlab/linters/check-version-number.sh - .gitlab/linters/linter.py - − .gitlab/win32-init.sh - + hadrian/ci.project - hadrian/src/Hadrian/Utilities.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,59 +2,45 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a + DOCKER_REV: 6223fe0b5942f4fa35bdec92c74566cf195bfb42 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/win32-init.sh. + # .gitlab/ci.sh. WINDOWS_TOOLCHAIN_VERSION: 1 -before_script: - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + # Disable shallow clones; they break our linting rules + GIT_DEPTH: 0 + + # Overridden by individual jobs + CONFIGURE_ARGS: "" + + GIT_SUBMODULE_STRATEGY: "recursive" stages: - - lint # Source linting - - build # A quick smoke-test to weed out broken commits - - full-build # Build all the things - - cleanup # See Note [Cleanup on Windows] - - packaging # Source distribution, etc. - - hackage # head.hackage testing - - deploy # push documentation - -.only-default: &only-default - rules: - - if: $CI_MERGE_REQUEST_ID - - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "master"' - - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - - if: '$CI_PIPELINE_SOURCE == "web"' + - lint # Source linting + - quick-build # A very quick smoke-test to weed out broken commits + - build # A quick smoke-test to weed out broken commits + - full-build # Build all the things + - cleanup # See Note [Cleanup after the shell executor] + - packaging # Source distribution, etc. + - testing # head.hackage correctness and compiler performance testing + - deploy # push documentation workflow: - # N.B. Don't run on wip/ branches, instead on run on merge requests. + # N.B.Don't run on wip/ branches, instead on run on merge requests. rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' -############################################################ -# Runner Tags -############################################################ -# -# * x86_64-linux: Any Docker-capable x86_64 Linux machine -# * aarch64-linux: Any Docker-capable AArch64 Linux machine -# * x86_64-windows: A x86_64 Windows machine -# * lint: Any Docker-capable x86_64 Linux machine; distinct from -# x86_64-linux to ensure low-latency availability. -# - .nightly: &nightly rules: - if: $NIGHTLY + artifacts: + when: always + expire_in: 8 weeks .release: &release variables: @@ -66,53 +52,105 @@ workflow: rules: - if: '$RELEASE == "yes"' +############################################################ +# Runner Tags +############################################################ +# +# * x86_64-linux: Any Docker-capable x86_64 Linux machine +# * aarch64-linux: Any Docker-capable AArch64 Linux machine +# * x86_64-windows: A x86_64 Windows machine +# * lint: Any Docker-capable x86_64 Linux machine; distinct from +# x86_64-linux to ensure low-latency availability. +# + ############################################################ # Linting ############################################################ ghc-linters: - allow_failure: true stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" - - "echo Merge base $base" + - "echo Linting changes between $base..$CI_COMMIT_SHA" # - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA) - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA) - - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA - - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA + - .gitlab/linters/check-makefiles.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-cpp.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-version-number.sh + - python3 utils/checkUniques/check-uniques.py . dependencies: [] tags: - lint rules: - if: $CI_MERGE_REQUEST_ID +# Run mypy Python typechecker on linter scripts. +lint-linters: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy .gitlab/linters/*.py + dependencies: [] + tags: + - lint + +# Check that .T files all parse by listing broken tests. +lint-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + script: + - make -Ctestsuite list_broken TEST_HC=ghc + dependencies: [] + tags: + - lint + +# Run mypy Python typechecker on testsuite driver +.typecheck-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy testsuite/driver/runtests.py + dependencies: [] + tags: + - lint + # We allow the submodule checker to fail when run on merge requests (to -# accomodate, e.g., haddock changes not yet upstream) but not on `master` or +# accommodate, e.g., haddock changes not yet upstream) but not on `master` or # Marge jobs. .lint-submods: stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA) + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" + - "echo Linting submodule changes between $base..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $base..$CI_COMMIT_SHA) dependencies: [] tags: - lint lint-submods: extends: .lint-submods + # Allow failure on merge requests since any necessary submodule patches may + # not be upstreamed yet. rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/' allow_failure: false - allow_failure: true -lint-submods-mr: +lint-submods-branch: extends: .lint-submods - allow_failure: true + script: + - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA) rules: - - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' .lint-changelogs: stage: lint @@ -125,6 +163,7 @@ lint-submods-mr: lint-changelogs: extends: .lint-changelogs + # Allow failure since this isn't a final release. allow_failure: true rules: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' @@ -140,71 +179,183 @@ lint-release-changelogs: ############################################################ .validate-hadrian: - <<: *only-default - allow_failure: true + variables: + FLAVOUR: "validate" script: - - cabal update - - git clean -xdf && git submodule foreach git clean -xdf - - bash .circleci/prepare-system.sh - - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi - - ./boot - - ./configure $CONFIGURE_ARGS - - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian cache: key: hadrian paths: - cabal-cache artifacts: - when: always + reports: + junit: junit.xml + expire_in: 2 week paths: - ghc.tar.xz + - junit.xml -validate-x86_64-linux-deb8-hadrian: +.validate-linux-hadrian: extends: .validate-hadrian - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + variables: + TEST_ENV: "x86_64-linux-deb9-hadrian" before_script: # workaround for docker permissions - sudo chown ghc:ghc -R . - - python3 .gitlab/fix-submodules.py - git submodule sync --recursive - git submodule update --init --recursive - git checkout .gitmodules - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + after_script: + - .gitlab/ci.sh clean tags: - x86_64-linux +validate-x86_64-linux-deb9-hadrian: + extends: .validate-linux-hadrian + stage: build + +validate-x86_64-linux-deb9-unreg-hadrian: + extends: .validate-linux-hadrian + stage: full-build + variables: + CONFIGURE_ARGS: --enable-unregisterised + TEST_ENV: "x86_64-linux-deb9-unreg-hadrian" + +.hadrian-ghc-in-ghci: + stage: quick-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + variables: + GHC_FLAGS: -Werror + tags: + - x86_64-linux + script: + - cabal update + - cd hadrian; cabal new-build --project-file=ci.project; cd .. + - git clean -xdf && git submodule foreach git clean -xdf + - .gitlab/ci.sh setup + - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi + - ./boot + - ./configure $CONFIGURE_ARGS + # 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," + cache: + key: hadrian-ghci + paths: + - cabal-cache ############################################################ # Validation via Pipelines (make) ############################################################ .validate: - <<: *only-default variables: TEST_TYPE: test - before_script: - - git clean -xdf && git submodule foreach git clean -xdf + MAKE_ARGS: "-Werror" script: - - ./boot - - ./configure $CONFIGURE_ARGS - - | - THREADS=`mk/detect-cpu-count.sh` - make V=0 -j$THREADS WERROR=-Werror - - | - make binary-dist TAR_COMP_OPTS="-1" - - | - THREADS=`mk/detect-cpu-count.sh` - make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_make + - .gitlab/ci.sh test_make dependencies: [] artifacts: reports: junit: junit.xml expire_in: 2 week paths: - - ghc-*.tar.xz + - $BIN_DIST_PREP_TAR_COMP - junit.xml + - performance-metrics.tsv + +################################# +# x86_64-freebsd +################################# + +.build-x86_64-freebsd: + extends: .validate + tags: + - x86_64-freebsd + allow_failure: true + variables: + # N.B. we use iconv from ports as I see linker errors when we attempt + # to use the "native" iconv embedded in libc as suggested by the + # porting guide [1]. + # [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + GHC_VERSION: 8.10.1 + CABAL_INSTALL_VERSION: 3.2.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd" + BUILD_FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Conditional due to lack of builder capacity +validate-x86_64-freebsd: + extends: .build-x86_64-freebsd + stage: full-build + rules: + - if: '$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/' + +nightly-x86_64-freebsd: + <<: *nightly + extends: .build-x86_64-freebsd + stage: full-build + +release-x86_64-freebsd: + <<: *release + extends: .build-x86_64-freebsd + stage: full-build + +.build-x86_64-freebsd-hadrian: + extends: .validate-hadrian + stage: full-build + tags: + - x86_64-freebsd + allow_failure: true + variables: + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + HADRIAN_ARGS: "--docs=no-sphinx" + GHC_VERSION: 8.6.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd-hadrian" + FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Disabled due to lack of builder capacity +.validate-x86_64-freebsd-hadrian: + extends: .build-x86_64-freebsd-hadrian + stage: full-build ################################# # x86_64-darwin @@ -216,54 +367,71 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: "8.8.3" - CABAL_INSTALL_VERSION: 2.4.1.0 - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz" + GHC_VERSION: 8.8.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-apple-darwin.tar.xz" MACOSX_DEPLOYMENT_TARGET: "10.7" # Only Sierra and onwards supports clock_gettime. See #12858 ac_cv_func_clock_gettime: "no" LANG: "en_US.UTF-8" - CONFIGURE_ARGS: --with-intree-gmp + CONFIGURE_ARGS: "--with-intree-gmp" TEST_ENV: "x86_64-darwin" - before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - - bash .gitlab/darwin-init.sh - - PATH="`pwd`/toolchain/bin:$PATH" + BUILD_FLAVOUR: "perf" after_script: - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean artifacts: when: always expire_in: 2 week cache: - key: darwin + key: "darwin-$GHC_VERSION" paths: - cabal-cache - toolchain +# Disabled because of OS X CI capacity +.validate-x86_64-darwin-hadrian: + stage: full-build + tags: + - x86_64-darwin + variables: + GHC_VERSION: 8.8.3 + MACOSX_DEPLOYMENT_TARGET: "10.7" + ac_cv_func_clock_gettime: "no" + LANG: "en_US.UTF-8" + CONFIGURE_ARGS: --with-intree-gmp + TEST_ENV: "x86_64-darwin-hadrian" + FLAVOUR: "validate" + script: + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + reports: + junit: junit.xml + paths: + - ghc.tar.xz + - junit.xml + .validate-linux: extends: .validate tags: - x86_64-linux + variables: + BUILD_FLAVOUR: "perf" before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" # Build hyperlinked sources for documentation when building releases - | if [[ -n "$CI_COMMIT_TAG" ]]; then - echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk + HADDOCK_HYPERLINKED_SOURCES=1 fi - - bash .circleci/prepare-system.sh # workaround for docker permissions - sudo chown ghc:ghc -R . after_script: @@ -285,9 +453,7 @@ validate-x86_64-darwin: allow_failure: true variables: TEST_ENV: "aarch64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz" - # Inexplicably makeindex fails - BUILD_SPHINX_PDF: "NO" + BIN_DIST_PREP_TAR_COMP: "ghc-aarch64-linux-deb9.tar.xz" cache: key: linux-aarch64-deb9 tags: @@ -302,8 +468,41 @@ validate-aarch64-linux-deb9: nightly-aarch64-linux-deb9: <<: *nightly extends: .build-aarch64-linux-deb9 + variables: + TEST_TYPE: slowtest + +################################# +# armv7-linux-deb9 +################################# + +.build-armv7-linux-deb9: + extends: .validate-linux + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb9:$DOCKER_REV" + # Due to linker issues + allow_failure: true + variables: + TEST_ENV: "armv7-linux-deb9" + BIN_DIST_PREP_TAR_COMP: "ghc-armv7-linux-deb9.tar.xz" + CONFIGURE_ARGS: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" + # N.B. We disable ld.lld explicitly here because it appears to fail + # non-deterministically on ARMv7. See #18280. + LD: "ld.gold" + GccUseLdOpt: "-fuse-ld=gold" + cache: + key: linux-armv7-deb9 + tags: + - armv7-linux + +validate-armv7-linux-deb9: + extends: .build-armv7-linux-deb9 artifacts: - expire_in: 2 year + when: always + expire_in: 2 week + +nightly-armv7-linux-deb9: + <<: *nightly + extends: .build-armv7-linux-deb9 variables: TEST_TYPE: slowtest @@ -317,7 +516,7 @@ nightly-aarch64-linux-deb9: image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "i386-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-i386-deb9-linux.tar.xz" cache: key: linux-i386-deb9 @@ -332,23 +531,6 @@ nightly-i386-linux-deb9: extends: .build-i386-linux-deb9 variables: TEST_TYPE: slowtest - artifacts: - when: always - expire_in: 2 week - -################################# -# x86_64-linux-deb10 -################################# - -.build-x86_64-linux-deb10: - extends: .validate-linux - stage: full-build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - variables: - TEST_ENV: "x86_64-linux-deb10" - BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" - cache: - key: linux-x86_64-deb10 ################################# # x86_64-linux-deb9 @@ -356,40 +538,62 @@ nightly-i386-linux-deb9: .build-x86_64-linux-deb9: extends: .validate-linux - stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb9-linux.tar.xz" cache: key: linux-x86_64-deb9 -validate-x86_64-linux-deb9: +# Disabled to reduce CI load +.validate-x86_64-linux-deb9: extends: .build-x86_64-linux-deb9 + stage: full-build artifacts: when: always expire_in: 2 week +release-x86_64-linux-deb9: + <<: *release + extends: .build-x86_64-linux-deb9 + stage: full-build + nightly-x86_64-linux-deb9: <<: *nightly extends: .build-x86_64-linux-deb9 - artifacts: - expire_in: 2 year + stage: full-build variables: TEST_TYPE: slowtest # N.B. Has DEBUG assertions enabled in stage2 validate-x86_64-linux-deb9-debug: extends: .build-x86_64-linux-deb9 - stage: build + stage: full-build variables: BUILD_FLAVOUR: validate + # Ensure that stage2 also has DEBUG enabled + ValidateSpeed: SLOW + # Override validate flavour default; see #16890. + BUILD_SPHINX_PDF: "YES" + TEST_TYPE: slowtest TEST_ENV: "x86_64-linux-deb9-debug" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-debug.tar.xz" + artifacts: + when: always + expire_in: 2 week -validate-x86_64-linux-deb9-llvm: +# Disabled to alleviate CI load +.validate-x86_64-linux-deb9-llvm: + extends: .build-x86_64-linux-deb9 + stage: full-build + variables: + BUILD_FLAVOUR: perf-llvm + TEST_ENV: "x86_64-linux-deb9-llvm" + +nightly-x86_64-linux-deb9-llvm: + <<: *nightly extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: BUILD_FLAVOUR: perf-llvm TEST_ENV: "x86_64-linux-deb9-llvm" @@ -397,11 +601,11 @@ validate-x86_64-linux-deb9-llvm: validate-x86_64-linux-deb9-integer-simple: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: + BUILD_FLAVOUR: validate INTEGER_LIBRARY: integer-simple - TEST_ENV: "x86_64-linux-deb9-integer-simple" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz" + TEST_ENV: "x86_64-linux-deb9-integer-simple-validate" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-integer-simple.tar.xz" nightly-x86_64-linux-deb9-integer-simple: <<: *nightly @@ -411,185 +615,205 @@ nightly-x86_64-linux-deb9-integer-simple: INTEGER_LIBRARY: integer-simple TEST_ENV: "x86_64-linux-deb9-integer-simple" TEST_TYPE: slowtest - artifacts: - expire_in: 2 year -validate-x86_64-linux-deb9-unreg: +validate-x86_64-linux-deb9-dwarf: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: - CONFIGURE_ARGS: --enable-unregisterised - TEST_ENV: "x86_64-linux-deb9-unreg" + CONFIGURE_ARGS: "--enable-dwarf-unwind" + BUILD_FLAVOUR: dwarf + TEST_ENV: "x86_64-linux-deb9-dwarf" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-dwarf.tar.xz" + +################################# +# x86_64-linux-deb10 +################################# -release-x86_64-linux-deb9-dwarf: +.build-x86_64-linux-deb10: extends: .validate-linux - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" - allow_failure: true + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb9" - artifacts: - when: always - expire_in: 2 week + TEST_ENV: "x86_64-linux-deb10" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" cache: - key: linux-x86_64-deb9 + key: linux-x86_64-deb10 +# Disabled to alleviate CI load +.validate-x86_64-linux-deb10: + extends: .build-x86_64-linux-deb10 + stage: full-build -release-x86_64-linux-deb10-dwarf: - <<: *release +nightly-x86_64-linux-deb10: + <<: *nightly extends: .build-x86_64-linux-deb10 variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb10-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb10-linux-dwarf.tar.xz" + TEST_TYPE: slowtest + +release-x86_64-linux-deb10: + <<: *release + extends: .build-x86_64-linux-deb10 ################################# # x86_64-linux-deb8 ################################# -release-x86_64-linux-deb8: - <<: *release +.build-x86_64-linux-deb8: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + # Due to #18298. + allow_failure: true variables: TEST_ENV: "x86_64-linux-deb8" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz" - # Disable sphinx PDF output as our Debian image doesn't have the requisite packages + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb8-linux.tar.xz" + # Debian 8's Sphinx is too old to support the table directive's :widths: + # option: https://sourceforge.net/p/docutils/patches/120/ + BUILD_SPHINX_HTML: "NO" + BUILD_SPHINX_INFO: "NO" BUILD_SPHINX_PDF: "NO" + BUILD_SPHINX_MAN: "NO" cache: key: linux-x86_64-deb8 + +release-x86_64-linux-deb8: + <<: *release + extends: .build-x86_64-linux-deb8 + +################################# +# x86_64-linux-alpine +################################# + +.build-x86_64-linux-alpine-hadrian: + extends: .validate-linux-hadrian + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine:$DOCKER_REV" + # There are currently a few failing tests + allow_failure: true + variables: + TEST_ENV: "x86_64-linux-alpine" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-alpine-linux.tar.xz" + # Can't use ld.gold due to #13958. + CONFIGURE_ARGS: "--disable-ld-override" + HADRIAN_ARGS: "--docs=no-sphinx" + # encoding004 due to lack of locale support + # T10458 due to fact that dynamic linker tries to reload libAS + BROKEN_TESTS: "encoding004 T10458" + cache: + key: linux-x86_64-alpine artifacts: when: always expire_in: 2 week +release-x86_64-linux-alpine: + <<: *release + extends: .build-x86_64-linux-alpine-hadrian + +nightly-x86_64-linux-alpine: + <<: *nightly + extends: .build-x86_64-linux-alpine-hadrian + ################################# # x86_64-linux-centos7 ################################# -release-x86_64-linux-centos7: - <<: *release +.build-x86_64-linux-centos7: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" variables: - # For the testsuite - LANG: "en_US.UTF-8" # The sphinx release shipped with Centos 7 fails to build out documentation BUILD_SPHINX_HTML: "NO" BUILD_SPHINX_PDF: "NO" TEST_ENV: "x86_64-linux-centos7" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz" - allow_failure: true + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-centos7-linux.tar.xz" + # CentOS seems to default to ascii + LANG: "en_US.UTF-8" cache: key: linux-x86_64-centos7 - artifacts: - when: always - expire_in: 2 week + +release-x86_64-linux-centos7: + <<: *release + extends: .build-x86_64-linux-centos7 ################################# # x86_64-linux-fedora27 ################################# -.build-x86_64-linux-fedora27: +validate-x86_64-linux-fedora27: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-fedora27" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: key: linux-x86_64-fedora27 - -validate-x86_64-linux-fedora27: - extends: .build-x86_64-linux-fedora27 artifacts: when: always # These are used for head.hackage jobs therefore we keep them around for # longer. expire_in: 8 week -release-x86_64-linux-fedora27: - <<: *release - extends: .build-x86_64-linux-fedora27 - -release-x86_64-linux-fedora27-dwarf: - <<: *release - extends: .build-x86_64-linux-fedora27 - variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-fedora27-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux-dwarf.tar.xz" - ############################################################ # Validation via Pipelines (Windows) ############################################################ .build-windows: - <<: *only-default + # For the reasons given in #17777 this build isn't reliable. + allow_failure: true before_script: - git clean -xdf - - git submodule foreach git clean -xdf - # Use a local temporary directory to ensure that concurrent builds don't - # interfere with one another - - | - mkdir tmp - set TMP=%cd%\tmp - set TEMP=%cd%\tmp - - - set PATH=C:\msys64\usr\bin;%PATH% - - python .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - bash .gitlab/win32-init.sh + # Setup toolchain + - bash .gitlab/ci.sh setup after_script: - - rd /s /q tmp - - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache - - bash -c 'make clean || true' + - | + Copy-Item -Recurse -Path $Env:APPDATA\cabal -Destination cabal-cache + - bash .gitlab/ci.sh clean dependencies: [] variables: - FORCE_SYMLINKS: 1 + #FORCE_SYMLINKS: 1 LANG: "en_US.UTF-8" SPHINXBUILD: "/mingw64/bin/sphinx-build.exe" + CABAL_INSTALL_VERSION: 3.0.0.0 + GHC_VERSION: "8.8.3" cache: paths: - cabal-cache - - ghc-8.6.2 + - toolchain - ghc-tarballs .build-windows-hadrian: extends: .build-windows stage: full-build - allow_failure: true variables: - GHC_VERSION: "8.8.3" + FLAVOUR: "validate" + # skipping perf tests for now since we build a quick-flavoured GHC, + # which might result in some broken perf tests? + HADRIAN_ARGS: "--docs=no-sphinx --skip-perf" + script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex' - - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist" - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz - # FIXME: Testsuite disabled due to #16156. - # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_hadrian + - bash .gitlab/ci.sh test_hadrian tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: + reports: + junit: junit.xml + expire_in: 2 week when: always paths: - ghc.tar.xz + - junit.xml validate-x86_64-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW64 + TEST_ENV: "x86_64-windows-hadrian" cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" @@ -598,86 +822,94 @@ nightly-i386-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW32 + TEST_ENV: "i386-windows-hadrian" cache: key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" .build-windows-make: extends: .build-windows stage: full-build - # due to #16084 - allow_failure: true variables: - BUILD_FLAVOUR: "UNSET" - GHC_VERSION: "8.8.3" - BUILD_PROF_LIBS: "YES" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz" + BUILD_FLAVOUR: "quick" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-mingw32.tar.xz" script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS' - - bash -c "echo \"include mk/flavours/${BUILD_FLAVOUR}.mk\" > mk/build.mk" - - bash -c "echo \"GhcLibHcOpts+=-haddock\" >> mk/build.mk" - - bash -c "echo \"BUILD_PROF_LIBS = $BUILD_PROF_LIBS\" >> mk/build.mk" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1" - - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_make + - bash .gitlab/ci.sh test_make tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: when: always expire_in: 2 week reports: junit: junit.xml paths: - - ghc-*.tar.xz + # N.B. variable interpolation apparently doesn't work on Windows so + # this can't be $BIN_DIST_PREP_TAR_COMP + - "ghc-x86_64-mingw32.tar.xz" - junit.xml -validate-x86_64-windows: +.build-x86_64-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" - BUILD_FLAVOUR: "quick" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" + TEST_ENV: "x86_64-windows" cache: key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-x86_64-windows: + extends: .build-x86_64-windows-make + +nightly-x86_64-windows: + <<: *nightly + extends: .build-x86_64-windows-make + stage: full-build + variables: + BUILD_FLAVOUR: "validate" + # Normal Windows validate builds are profiled; that won't do for releases. release-x86_64-windows: <<: *release extends: validate-x86_64-windows variables: - MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" - -release-i386-windows: + # +release-x86_64-windows-integer-simple: <<: *release - extends: .build-windows-make + extends: validate-x86_64-windows variables: - MSYSTEM: MINGW32 + INTEGER_LIBRARY: integer-simple BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - # Due to #15934 - BUILD_PROF_LIBS: "NO" - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows: - <<: *nightly + +.build-i386-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW32 - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - BUILD_FLAVOUR: "quick" # Due to #15934 BUILD_PROF_LIBS: "NO" + TEST_ENV: "i386-windows" + # Due to #17736 + allow_failure: true cache: key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-i386-windows: + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +release-i386-windows: + <<: *release + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +nightly-i386-windows: + <<: *nightly + extends: .build-i386-windows-make + ############################################################ # Cleanup ############################################################ @@ -687,40 +919,24 @@ nightly-i386-windows: # # As noted in [1], gitlab-runner's shell executor doesn't clean up its working # directory after builds. Unfortunately, we are forced to use the shell executor -# on Windows. To avoid running out of disk space we add a stage at the end of -# the build to remove the \GitLabRunner\builds directory. Since we only run a -# single build at a time on Windows this should be safe. +# on Darwin. To avoid running out of disk space we add a stage at the end of +# the build to remove the /.../GitLabRunner/builds directory. Since we only run a +# single build at a time on Darwin this should be safe. +# +# We used to have a similar cleanup job on Windows as well however it ended up +# being quite fragile as we have multiple Windows builders yet there is no +# guarantee that the cleanup job is run on the same machine as the build itself +# was run. Consequently we were forced to instead handle cleanup with a separate +# cleanup cron job on Windows. # # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856 -# See Note [Cleanup after shell executor] -cleanup-windows: - <<: *only-default - stage: cleanup - tags: - - x86_64-windows - dependencies: [] - before_script: - - echo "Time to clean up" - script: - - echo "Let's go" - after_script: - - set "BUILD_DIR=%CI_PROJECT_DIR%" - - set "BUILD_DIR=%BUILD_DIR:/=\%" - - echo "Cleaning %BUILD_DIR%" - - cd \GitLabRunner - # This is way more complicated than it should be: - # See https://stackoverflow.com/questions/1965787 - - del %BUILD_DIR%\* /F /Q - - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p" - - exit /b 0 - # See Note [Cleanup after shell executor] cleanup-darwin: - <<: *only-default stage: cleanup tags: - x86_64-darwin + when: always dependencies: [] before_script: - echo "Time to clean up" @@ -737,19 +953,56 @@ cleanup-darwin: # Packaging ############################################################ +doc-tarball: + stage: packaging + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + dependencies: + - validate-x86_64-linux-deb9-debug + - validate-x86_64-windows + variables: + LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz" + WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz" + # Due to Windows allow_failure + allow_failure: true + artifacts: + paths: + - haddock.html.tar.xz + - libraries.html.tar.xz + - users_guide.html.tar.xz + - index.html + - "*.pdf" + script: + - | + if [ ! -f "$LINUX_BINDIST" ]; then + echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" + exit 1 + fi + if [ ! -f "$WINDOWS_BINDIST" ]; then + echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?" + exit 1 + fi + - rm -Rf docs + - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST + - ls -lh + - mv docs/*.tar.xz docs/index.html . + source-tarball: - <<: *release stage: packaging tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" dependencies: [] + rules: + - if: $CI_COMMIT_TAG + when: always artifacts: paths: - ghc-*.tar.xz - version script: - - mk/get-win32-tarballs.sh download all + - python3 mk/get-win32-tarballs.py download all - ./boot - ./configure - make sdist @@ -770,9 +1023,8 @@ source-tarball: # pipeline. .hackage: - <<: *only-default - stage: hackage - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + stage: testing + image: ghcci/x86_64-linux-deb9:0.2 tags: - x86_64-linux dependencies: [] @@ -781,6 +1033,10 @@ source-tarball: script: - bash .gitlab/start-head.hackage.sh +hackage: + extends: .hackage + when: manual + hackage-label: extends: .hackage rules: @@ -790,3 +1046,69 @@ nightly-hackage: <<: *nightly extends: .hackage +############################################################ +# Nofib testing +############################################################ + +perf-nofib: + stage: testing + dependencies: + - validate-x86_64-linux-deb9-dwarf + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + rules: + - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + tags: + - x86_64-linux + script: + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ghc-x86_64-deb9-linux-dwarf.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - cabal update; cabal install -w $BOOT_HC regex-compat + - export PATH=$root/bin:$PATH + - make -C nofib boot mode=fast -j$CPUS + - "make -C nofib EXTRA_RUNTEST_OPTS='-cachegrind +RTS -V0 -RTS' NoFibRuns=1 mode=fast -j$CPUS 2>&1 | tee nofib.log" + artifacts: + expire_in: 12 week + when: always + paths: + - nofib.log + +############################################################ +# Documentation deployment via GitLab Pages +############################################################ + +pages: + stage: deploy + dependencies: + - doc-tarball + image: ghcci/x86_64-linux-deb9:0.2 + # Due to Windows allow_failure + allow_failure: true + tags: + - x86_64-linux + script: + - mkdir -p public/doc + - tar -xf haddock.html.tar.xz -C public/doc + - tar -xf libraries.html.tar.xz -C public/doc + - tar -xf users_guide.html.tar.xz -C public/doc + - | + cat >public/index.html < + + + EOF + - cp -f index.html public/doc + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + artifacts: + paths: + - public ===================================== .gitlab/ci.sh ===================================== @@ -0,0 +1,463 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2230 + +# This is the primary driver of the GitLab CI infrastructure. + +set -e -o pipefail + +# Configuration: +hackage_index_state="@1579718451" + +# Colors +BLACK="0;30" +GRAY="1;30" +RED="0;31" +LT_RED="1;31" +BROWN="0;33" +LT_BROWN="1;33" +GREEN="0;32" +LT_GREEN="1;32" +BLUE="0;34" +LT_BLUE="1;34" +PURPLE="0;35" +LT_PURPLE="1;35" +CYAN="0;36" +LT_CYAN="1;36" +WHITE="1;37" +LT_GRAY="0;37" + +export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 + +# GitLab Pipelines log section delimiters +# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664 +start_section() { + name="$1" + echo -e "section_start:$(date +%s):$name\015\033[0K" +} + +end_section() { + name="$1" + echo -e "section_end:$(date +%s):$name\015\033[0K" +} + +echo_color() { + local color="$1" + local msg="$2" + echo -e "\033[${color}m${msg}\033[0m" +} + +error() { echo_color "${RED}" "$1"; } +warn() { echo_color "${LT_BROWN}" "$1"; } +info() { echo_color "${LT_BLUE}" "$1"; } + +fail() { error "error: $1"; exit 1; } + +function run() { + info "Running $*..." + "$@" || ( error "$* failed"; return 1; ) +} + +TOP="$(pwd)" + +function mingw_init() { + case "$MSYSTEM" in + MINGW32) + triple="i386-unknown-mingw32" + boot_triple="i386-unknown-mingw32" # triple of bootstrap GHC + ;; + MINGW64) + triple="x86_64-unknown-mingw32" + boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC + ;; + *) + fail "win32-init: Unknown MSYSTEM $MSYSTEM" + ;; + esac + + # Bring mingw toolchain into PATH. + # This is extracted from /etc/profile since this script inexplicably fails to + # run under gitlab-runner. + # shellcheck disable=SC1091 + source /etc/msystem + MINGW_MOUNT_POINT="${MINGW_PREFIX}" + PATH="$MINGW_MOUNT_POINT/bin:$PATH" + + # We always use mingw64 Python to avoid path length issues like #17483. + export PYTHON="/mingw64/bin/python3" +} + +# This will contain GHC's local native toolchain +toolchain="$TOP/toolchain" +mkdir -p "$toolchain/bin" +PATH="$toolchain/bin:$PATH" + +export METRICS_FILE="$CI_PROJECT_DIR/performance-metrics.tsv" + +cores="$(mk/detect-cpu-count.sh)" + +# Use a local temporary directory to ensure that concurrent builds don't +# interfere with one another +mkdir -p "$TOP/tmp" +export TMP="$TOP/tmp" +export TEMP="$TOP/tmp" + +function darwin_setup() { + # It looks like we already have python2 here and just installing python3 + # does not work. + brew upgrade python + brew install ghc cabal-install ncurses gmp + + pip3 install sphinx + # PDF documentation disabled as MacTeX apparently doesn't include xelatex. + #brew cask install mactex +} + +function show_tool() { + local tool="$1" + info "$tool = ${!tool}" + ${!tool} --version +} + +function set_toolchain_paths() { + needs_toolchain=1 + case "$(uname)" in + Linux) needs_toolchain="" ;; + *) ;; + esac + + if [[ -n "$needs_toolchain" ]]; then + # These are populated by setup_toolchain + GHC="$toolchain/bin/ghc$exe" + CABAL="$toolchain/bin/cabal$exe" + HAPPY="$toolchain/bin/happy$exe" + ALEX="$toolchain/bin/alex$exe" + else + GHC="$(which ghc)" + CABAL="/usr/local/bin/cabal" + HAPPY="$HOME/.cabal/bin/happy" + ALEX="$HOME/.cabal/bin/alex" + fi + export GHC + export CABAL + export HAPPY + export ALEX +} + +# Extract GHC toolchain +function setup() { + if [ -d "$TOP/cabal-cache" ]; then + info "Extracting cabal cache..." + mkdir -p "$cabal_dir" + cp -Rf cabal-cache/* "$cabal_dir" + fi + + if [[ -n "$needs_toolchain" ]]; then + setup_toolchain + fi + case "$(uname)" in + Darwin) darwin_setup ;; + *) ;; + esac + + # Make sure that git works + git config user.email "ghc-ci at gitlab-haskell.org" + git config user.name "GHC GitLab CI" + + info "=====================================================" + info "Toolchain versions" + info "=====================================================" + show_tool GHC + show_tool CABAL + show_tool HAPPY + show_tool ALEX +} + +function fetch_ghc() { + local v="$GHC_VERSION" + if [[ -z "$v" ]]; then + fail "GHC_VERSION is not set" + fi + + if [ ! -e "$GHC" ]; then + start_section "fetch GHC" + url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple}.tar.xz" + info "Fetching GHC binary distribution from $url..." + curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution" + tar -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution" + case "$(uname)" in + MSYS_*|MINGW*) + cp -r "ghc-${GHC_VERSION}"/* "$toolchain" + ;; + *) + pushd "ghc-${GHC_VERSION}" + ./configure --prefix="$toolchain" + "$MAKE" install + popd + ;; + esac + rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz + end_section "fetch GHC" + fi + +} + +function fetch_cabal() { + local v="$CABAL_INSTALL_VERSION" + if [[ -z "$v" ]]; then + fail "CABAL_INSTALL_VERSION is not set" + fi + + if [ ! -e "$CABAL" ]; then + start_section "fetch GHC" + case "$(uname)" in + # N.B. Windows uses zip whereas all others use .tar.xz + MSYS_*|MINGW*) + case "$MSYSTEM" in + MINGW32) cabal_arch="i386" ;; + MINGW64) cabal_arch="x86_64" ;; + *) fail "unknown MSYSTEM $MSYSTEM" ;; + esac + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-unknown-mingw32.zip" + info "Fetching cabal binary distribution from $url..." + curl "$url" > "$TMP/cabal.zip" + unzip "$TMP/cabal.zip" + mv cabal.exe "$CABAL" + ;; + *) + local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/" + case "$(uname)" in + Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;; + FreeBSD) + #cabal_url="$base_url/cabal-install-$v-x86_64-portbld-freebsd.tar.xz" ;; + cabal_url="http://home.smart-cactus.org/~ben/ghc/cabal-install-3.0.0.0-x86_64-portbld-freebsd.tar.xz" ;; + *) fail "don't know where to fetch cabal-install for $(uname)" + esac + echo "Fetching cabal-install from $cabal_url" + curl "$cabal_url" > cabal.tar.xz + tar -xJf cabal.tar.xz + mv cabal "$toolchain/bin" + ;; + esac + end_section "fetch GHC" + fi +} + +# For non-Docker platforms we prepare the bootstrap toolchain +# here. For Docker platforms this is done in the Docker image +# build. +function setup_toolchain() { + fetch_ghc + fetch_cabal + cabal_install="$CABAL v2-install --index-state=$hackage_index_state --installdir=$toolchain/bin" + # Avoid symlinks on Windows + case "$(uname)" in + MSYS_*|MINGW*) cabal_install="$cabal_install --install-method=copy" ;; + *) ;; + esac + + if [ ! -e "$HAPPY" ]; then + info "Building happy..." + cabal update + $cabal_install happy + fi + + if [ ! -e "$ALEX" ]; then + info "Building alex..." + cabal update + $cabal_install alex + fi +} + +function cleanup_submodules() { + start_section "clean submodules" + info "Cleaning submodules..." + # On Windows submodules can inexplicably get into funky states where git + # believes that the submodule is initialized yet its associated repository + # is not valid. Avoid failing in this case with the following insanity. + git submodule sync --recursive || git submodule deinit --force --all + git submodule update --init --recursive + git submodule foreach git clean -xdf + end_section "clean submodules" +} + +function prepare_build_mk() { + if [[ -z "$BUILD_FLAVOUR" ]]; then fail "BUILD_FLAVOUR is not set"; fi + if [[ -z ${BUILD_SPHINX_HTML:-} ]]; then BUILD_SPHINX_HTML=YES; fi + if [[ -z ${BUILD_SPHINX_PDF:-} ]]; then BUILD_SPHINX_PDF=YES; fi + if [[ -z ${INTEGER_LIBRARY:-} ]]; then INTEGER_LIBRARY=integer-gmp; fi + + cat > mk/build.mk <> mk/build.mk + fi + + case "$(uname)" in + Darwin) echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk ;; + *) ;; + esac + + info "build.mk is:" + cat mk/build.mk +} + +function configure() { + start_section "booting" + run python3 boot + end_section "booting" + + local target_args="" + if [[ -n "$triple" ]]; then + target_args="--target=$triple" + fi + + start_section "configuring" + run ./configure \ + --enable-tarballs-autodownload \ + $target_args \ + $CONFIGURE_ARGS \ + GHC="$GHC" \ + HAPPY="$HAPPY" \ + ALEX="$ALEX" \ + || ( cat config.log; fail "configure failed" ) + end_section "configuring" +} + +function build_make() { + prepare_build_mk + if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then + fail "BIN_DIST_PREP_TAR_COMP is not set" + fi + + echo "include mk/flavours/${BUILD_FLAVOUR}.mk" > mk/build.mk + echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk + run "$MAKE" -j"$cores" $MAKE_ARGS + run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 + ls -lh "$BIN_DIST_PREP_TAR_COMP" +} + +function fetch_perf_notes() { + info "Fetching perf notes..." + "$TOP/.gitlab/test-metrics.sh" pull +} + +function push_perf_notes() { + info "Pushing perf notes..." + "$TOP/.gitlab/test-metrics.sh" push +} + +function test_make() { + run "$MAKE" test_bindist TEST_PREP=YES + run "$MAKE" V=0 test \ + THREADS="$cores" \ + JUNIT_FILE=../../junit.xml +} + +function build_hadrian() { + if [ -z "$FLAVOUR" ]; then + fail "FLAVOUR not set" + fi + + run_hadrian binary-dist + + mv _build/bindist/ghc*.tar.xz ghc.tar.xz +} + +function test_hadrian() { + cd _build/bindist/ghc-*/ + run ./configure --prefix="$TOP"/_build/install + run "$MAKE" install + cd ../../../ + + run_hadrian \ + test \ + --summary-junit=./junit.xml \ + --test-compiler="$TOP"/_build/install/bin/ghc +} + +function clean() { + rm -R tmp + run "$MAKE" --quiet clean || true + run rm -Rf _build +} + +function run_hadrian() { + run hadrian/build.cabal.sh \ + --flavour="$FLAVOUR" \ + -j"$cores" \ + $HADRIAN_ARGS \ + $@ +} + +# A convenience function to allow debugging in the CI environment. +function shell() { + local cmd=$@ + if [ -z "$cmd" ]; then + cmd="bash -i" + fi + run $cmd +} + +# Determine Cabal data directory +case "$(uname)" in + MSYS_*|MINGW*) exe=".exe"; cabal_dir="$APPDATA/cabal" ;; + *) cabal_dir="$HOME/.cabal"; exe="" ;; +esac + +# Platform-specific environment initialization +MAKE="make" +case "$(uname)" in + MSYS_*|MINGW*) mingw_init ;; + Darwin) boot_triple="x86_64-apple-darwin" ;; + FreeBSD) + boot_triple="x86_64-portbld-freebsd" + MAKE="gmake" + ;; + Linux) ;; + *) fail "uname $(uname) is not supported" ;; +esac + +set_toolchain_paths + +case $1 in + setup) setup && cleanup_submodules ;; + configure) configure ;; + build_make) build_make ;; + test_make) + fetch_perf_notes + res=0 + test_make || res=$? + push_perf_notes + exit $res ;; + build_hadrian) build_hadrian ;; + # N.B. Always push notes, even if the build fails. This is okay to do as the + # testsuite driver doesn't record notes for tests that fail due to + # correctness. + test_hadrian) + fetch_perf_notes + res=0 + test_hadrian || res=$? + push_perf_notes + exit $res ;; + run_hadrian) run_hadrian $@ ;; + clean) clean ;; + shell) shell $@ ;; + *) fail "unknown mode $1" ;; +esac ===================================== .gitlab/darwin-init.sh deleted ===================================== @@ -1,41 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $HOME/.cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - mkdir -p tmp - cd tmp - ghc_tarball="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-x86_64-apple-darwin.tar.xz" - echo "Fetching GHC from $ghc_tarball" - curl $ghc_tarball | tar -xJ - cd ghc-$GHC_VERSION - ./configure --prefix=$toolchain - make install - cd ../.. - rm -Rf tmp -fi - -if [ ! -e $toolchain/bin/cabal ]; then - cabal_tarball="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL_VERSION/cabal-install-$CABAL_INSTALL_VERSION-x86_64-apple-darwin-sierra.tar.xz" - echo "Fetching cabal-install from $cabal_tarball" - curl $cabal_tarball | tar -xz - mv cabal $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal new-install happy --symlink-bindir=$toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal new-install alex --symlink-bindir=$toolchain/bin -fi - ===================================== .gitlab/linters/check-makefiles.py ===================================== @@ -1,5 +1,11 @@ #!/usr/bin/env python3 +""" +Linters for testsuite makefiles +""" + +from linter import run_linters, RegexpLinter + """ Warn for use of `--interactive` inside Makefiles (#11468). @@ -7,13 +13,21 @@ Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to forget one of those flags when adding a new test. """ +interactive_linter = \ + RegexpLinter(r'--interactive', + message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`." + ).add_path_filter(lambda path: path.name == 'Makefile') -from linter import run_linters, RegexpLinter +test_hc_quotes_linter = \ + RegexpLinter('\t\\$\\(TEST_HC\\)', + message = "Warning: $(TEST_HC) should be quoted in Makefiles.", + ).add_path_filter(lambda path: path.name == 'Makefile') linters = [ - RegexpLinter(r'--interactive', - message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`.") + interactive_linter, + test_hc_quotes_linter, ] if __name__ == '__main__': - run_linters(linters) #$, subdir='testsuite') + run_linters(linters, + subdir='testsuite') ===================================== .gitlab/linters/check-version-number.sh ===================================== @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +grep -E -q '\[[0-9]+\.[0-9]+\.[0-9]+\]' configure.ac || + ( echo "error: configure.ac: GHC version number must have three components."; exit 1 ) ===================================== .gitlab/linters/linter.py ===================================== @@ -7,10 +7,11 @@ import sys import re import textwrap import subprocess -from typing import List, Optional +from pathlib import Path +from typing import List, Optional, Callable, Sequence from collections import namedtuple -def lint_failure(file, line_no, line_content, message): +def lint_failure(file, line_no: int, line_content: str, message: str): """ Print a lint failure message. """ wrapper = textwrap.TextWrapper(initial_indent=' ', subsequent_indent=' ') @@ -29,7 +30,7 @@ def lint_failure(file, line_no, line_content, message): print(textwrap.dedent(msg)) -def get_changed_files(base_commit, head_commit, +def get_changed_files(base_commit: str, head_commit: str, subdir: str = '.'): """ Get the files changed by the given range of commits. """ cmd = ['git', 'diff', '--name-only', @@ -46,12 +47,21 @@ class Linter(object): """ def __init__(self): self.warnings = [] # type: List[Warning] + self.path_filters = [] # type: List[Callable[[Path], bool]] def add_warning(self, w: Warning): self.warnings.append(w) - def lint(self, path): - pass + def add_path_filter(self, f: Callable[[Path], bool]) -> "Linter": + self.path_filters.append(f) + return self + + def do_lint(self, path: Path): + if all(f(path) for f in self.path_filters): + self.lint(path) + + def lint(self, path: Path): + raise NotImplementedError class LineLinter(Linter): """ @@ -59,44 +69,55 @@ class LineLinter(Linter): the given line from a file and calls :func:`add_warning` for any lint issues found. """ - def lint(self, path): - if os.path.isfile(path): - with open(path, 'r') as f: + def lint(self, path: Path): + if path.is_file(): + with path.open('r') as f: for line_no, line in enumerate(f): self.lint_line(path, line_no+1, line) - def lint_line(self, path, line_no, line): - pass + def lint_line(self, path: Path, line_no: int, line: str): + raise NotImplementedError class RegexpLinter(LineLinter): """ A :class:`RegexpLinter` produces the given warning message for all lines matching the given regular expression. """ - def __init__(self, regex, message): + def __init__(self, regex: str, message: str): LineLinter.__init__(self) self.re = re.compile(regex) self.message = message - def lint_line(self, path, line_no, line): + def lint_line(self, path: Path, line_no: int, line: str): if self.re.search(line): w = Warning(path=path, line_no=line_no, line_content=line[:-1], message=self.message) self.add_warning(w) -def run_linters(linters: List[Linter], +def run_linters(linters: Sequence[Linter], subdir: str = '.') -> None: import argparse parser = argparse.ArgumentParser() - parser.add_argument('base', help='Base commit') - parser.add_argument('head', help='Head commit') + subparsers = parser.add_subparsers() + + subparser = subparsers.add_parser('commits', help='Lint a range of commits') + subparser.add_argument('base', help='Base commit') + subparser.add_argument('head', help='Head commit') + subparser.set_defaults(get_linted_files=lambda args: + get_changed_files(args.base, args.head, subdir)) + + subparser = subparsers.add_parser('files', help='Lint a range of commits') + subparser.add_argument('file', nargs='+', help='File to lint') + subparser.set_defaults(get_linted_files=lambda args: args.file) + args = parser.parse_args() - for path in get_changed_files(args.base, args.head, subdir): + linted_files = args.get_linted_files(args) + for path in linted_files: if path.startswith('.gitlab/linters'): continue for linter in linters: - linter.lint(path) + linter.do_lint(Path(path)) warnings = [warning for linter in linters ===================================== .gitlab/win32-init.sh deleted ===================================== @@ -1,50 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:/mingw64/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $APPDATA/cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - case $MSYSTEM in - MINGW32) - triple="i386-unknown-mingw32" - ;; - MINGW64) - triple="x86_64-unknown-mingw32" - ;; - *) - echo "win32-init: Unknown MSYSTEM $MSYSTEM" - exit 1 - ;; - esac - if [ -z "$GHC_TARBALL_URL" ]; then - GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" - fi - curl "$GHC_TARBALL_URL" | tar -xJ - mv ghc-$GHC_VERSION toolchain -fi - -if [ ! -e $toolchain/bin/cabal ]; then - url="https://downloads.haskell.org/~cabal/cabal-install-2.4.1.0/cabal-install-2.4.1.0-x86_64-unknown-mingw32.zip" - curl $url > /tmp/cabal.zip - unzip /tmp/cabal.zip - mv cabal.exe $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal install happy - cp $APPDATA/cabal/bin/happy $toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal install alex - cp $APPDATA/cabal/bin/alex $toolchain/bin -fi - ===================================== hadrian/ci.project ===================================== @@ -0,0 +1,4 @@ +packages: ./ + +package hadrian + -- ghc-options: -Werror ===================================== hadrian/src/Hadrian/Utilities.hs ===================================== @@ -37,7 +37,6 @@ import Control.Monad.Extra import Data.Char import Data.Dynamic (Dynamic, fromDynamic, toDyn) import Data.HashMap.Strict (HashMap) -import Data.List (isPrefixOf) import Data.List.Extra import Data.Maybe import Data.Typeable (TypeRep, typeOf) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96e2e2a87837226d03a31e96b1461078c0d75705 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96e2e2a87837226d03a31e96b1461078c0d75705 You're receiving 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 Jul 11 17:57:36 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 13:57:36 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] hadrian: Add `validate` and `slow validate` flavours Message-ID: <5f09fd908f344_80b3f8490174d3826625d5@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 60a06ed6 by Ben Gamari at 2020-07-11T13:57:26-04:00 hadrian: Add `validate` and `slow validate` flavours (cherry picked from commit 9a2798e139e3d20183b59bb5a66012db495c66c7) - - - - - 4 changed files: - hadrian/doc/flavours.md - hadrian/hadrian.cabal - hadrian/src/Settings.hs - + hadrian/src/Settings/Flavours/Validate.hs Changes: ===================================== hadrian/doc/flavours.md ===================================== @@ -110,6 +110,28 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH -O0
-DDEBUG + + validate + -O0
-H64m + -fllvm-fill-undef-with-garbage + + -O
-dcore-lint
-dno-debug-output + -O2
-DDEBUG + -O
-dcore-lint
-dno-debug-output + -O + -O + + + validate + -O0
-H64m + -fllvm-fill-undef-with-garbage + + -O
-dcore-lint
-dno-debug-output + -O2
-DDEBUG + -O
-DDEBUG
-dcore-lint
-dno-debug-output + -O + -O + ## Ways ===================================== hadrian/hadrian.cabal ===================================== @@ -96,6 +96,7 @@ executable hadrian , Settings.Flavours.Quick , Settings.Flavours.QuickCross , Settings.Flavours.Quickest + , Settings.Flavours.Validate , Settings.Packages , Settings.Warnings , Stage ===================================== hadrian/src/Settings.hs ===================================== @@ -17,6 +17,7 @@ import Settings.Flavours.Profiled import Settings.Flavours.Quick import Settings.Flavours.Quickest import Settings.Flavours.QuickCross +import Settings.Flavours.Validate getArgs :: Args getArgs = expr flavour >>= args @@ -36,7 +37,7 @@ hadrianFlavours :: [Flavour] hadrianFlavours = [ defaultFlavour, developmentFlavour Stage1, developmentFlavour Stage2 , performanceFlavour, profiledFlavour, quickFlavour, quickestFlavour - , quickCrossFlavour ] + , quickCrossFlavour, validateFlavour, slowValidateFlavour ] flavour :: Action Flavour flavour = do ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -0,0 +1,46 @@ +module Settings.Flavours.Validate (validateFlavour, slowValidateFlavour) where + +import Expression +import Flavour +import Oracles.Flag +import {-# SOURCE #-} Settings.Default + +-- Please update doc/flavours.md when changing this file. +validateFlavour :: Flavour +validateFlavour = werror $ defaultFlavour + { name = "validate" + , args = defaultBuilderArgs <> validateArgs <> defaultPackageArgs + , libraryWays = mconcat [ pure [vanilla] + , notStage0 ? platformSupportsSharedLibs ? pure [dynamic] + ] + , rtsWays = mconcat [ pure [vanilla, threaded, debug, logging, threadedDebug, threadedLogging] + , notStage0 ? platformSupportsSharedLibs ? pure + [ dynamic, threadedDynamic, debugDynamic, threadedDebugDynamic + , loggingDynamic, threadedLoggingDynamic + ] + ] + } + +validateArgs :: Args +validateArgs = sourceArgs SourceArgs + { hsDefault = mconcat [ stage0 ? pure ["-O0", "-H64m"] + -- See #11487 + , notStage0 ? arg "-fllvm-fill-undef-with-garbage" + ] + , hsLibrary = pure ["-O", "-dcore-lint", "-dno-debug-output"] + , hsCompiler = mconcat [ stage0 ? pure ["-O2", "-DDEBUG"] + , notStage0 ? pure ["-O", "-dcore-lint", "-dno-debug-output"] + ] + , hsGhc = pure ["-O"] } + +slowValidateFlavour :: Flavour +slowValidateFlavour = werror $ validateFlavour + { name = "slow-validate" + , args = defaultBuilderArgs <> slowValidateArgs <> defaultPackageArgs + } + +slowValidateArgs :: Args +slowValidateArgs = + mconcat [ validateArgs + , notStage0 ? arg "-DDEBUG" + ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/60a06ed669f0982c166bfac75d64277ed075268f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/60a06ed669f0982c166bfac75d64277ed075268f You're receiving 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 Jul 11 18:03:00 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 11 Jul 2020 14:03:00 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Fix GHCi :print on big-endian platforms Message-ID: <5f09fed4a0e69_80b3f848662eb1c26654a4@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - 824f9c03 by Artem Pelenitsyn at 2020-07-11T14:02:57-04:00 add reproducer for #15630 - - - - - e22e1f11 by Andreas Klebinger at 2020-07-11T14:02:58-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - 30 changed files: - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/709797c6d0754a21a39395f5ee89ec2b978ff63e...e22e1f1119a4e57e8e5ee7fab4da165c3436ac5a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/709797c6d0754a21a39395f5ee89ec2b978ff63e...e22e1f1119a4e57e8e5ee7fab4da165c3436ac5a You're receiving 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 Jul 11 19:04:01 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 15:04:01 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] 2 commits: Backport CI infrastructure rework Message-ID: <5f0a0d21b4e2f_80b3f849c221f402670311@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 09b321ad by Ben Gamari at 2020-07-11T15:03:49-04:00 Backport CI infrastructure rework - - - - - 7d2f1478 by Ben Gamari at 2020-07-11T15:03:49-04:00 hadrian: Add `validate` and `slow validate` flavours (cherry picked from commit 9a2798e139e3d20183b59bb5a66012db495c66c7) - - - - - 14 changed files: - .gitlab-ci.yml - + .gitlab/ci.sh - − .gitlab/darwin-init.sh - .gitlab/linters/check-makefiles.py - + .gitlab/linters/check-version-number.sh - .gitlab/linters/linter.py - + .gitlab/test-metrics.sh - − .gitlab/win32-init.sh - + hadrian/ci.project - hadrian/doc/flavours.md - hadrian/hadrian.cabal - hadrian/src/Hadrian/Utilities.hs - hadrian/src/Settings.hs - + hadrian/src/Settings/Flavours/Validate.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,59 +2,45 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a + DOCKER_REV: 6223fe0b5942f4fa35bdec92c74566cf195bfb42 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/win32-init.sh. + # .gitlab/ci.sh. WINDOWS_TOOLCHAIN_VERSION: 1 -before_script: - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + # Disable shallow clones; they break our linting rules + GIT_DEPTH: 0 + + # Overridden by individual jobs + CONFIGURE_ARGS: "" + + GIT_SUBMODULE_STRATEGY: "recursive" stages: - - lint # Source linting - - build # A quick smoke-test to weed out broken commits - - full-build # Build all the things - - cleanup # See Note [Cleanup on Windows] - - packaging # Source distribution, etc. - - hackage # head.hackage testing - - deploy # push documentation - -.only-default: &only-default - rules: - - if: $CI_MERGE_REQUEST_ID - - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "master"' - - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - - if: '$CI_PIPELINE_SOURCE == "web"' + - lint # Source linting + - quick-build # A very quick smoke-test to weed out broken commits + - build # A quick smoke-test to weed out broken commits + - full-build # Build all the things + - cleanup # See Note [Cleanup after the shell executor] + - packaging # Source distribution, etc. + - testing # head.hackage correctness and compiler performance testing + - deploy # push documentation workflow: - # N.B. Don't run on wip/ branches, instead on run on merge requests. + # N.B.Don't run on wip/ branches, instead on run on merge requests. rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' -############################################################ -# Runner Tags -############################################################ -# -# * x86_64-linux: Any Docker-capable x86_64 Linux machine -# * aarch64-linux: Any Docker-capable AArch64 Linux machine -# * x86_64-windows: A x86_64 Windows machine -# * lint: Any Docker-capable x86_64 Linux machine; distinct from -# x86_64-linux to ensure low-latency availability. -# - .nightly: &nightly rules: - if: $NIGHTLY + artifacts: + when: always + expire_in: 8 weeks .release: &release variables: @@ -66,53 +52,105 @@ workflow: rules: - if: '$RELEASE == "yes"' +############################################################ +# Runner Tags +############################################################ +# +# * x86_64-linux: Any Docker-capable x86_64 Linux machine +# * aarch64-linux: Any Docker-capable AArch64 Linux machine +# * x86_64-windows: A x86_64 Windows machine +# * lint: Any Docker-capable x86_64 Linux machine; distinct from +# x86_64-linux to ensure low-latency availability. +# + ############################################################ # Linting ############################################################ ghc-linters: - allow_failure: true stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" - - "echo Merge base $base" + - "echo Linting changes between $base..$CI_COMMIT_SHA" # - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA) - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA) - - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA - - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA + - .gitlab/linters/check-makefiles.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-cpp.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-version-number.sh + - python3 utils/checkUniques/check-uniques.py . dependencies: [] tags: - lint rules: - if: $CI_MERGE_REQUEST_ID +# Run mypy Python typechecker on linter scripts. +lint-linters: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy .gitlab/linters/*.py + dependencies: [] + tags: + - lint + +# Check that .T files all parse by listing broken tests. +lint-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + script: + - make -Ctestsuite list_broken TEST_HC=ghc + dependencies: [] + tags: + - lint + +# Run mypy Python typechecker on testsuite driver +.typecheck-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy testsuite/driver/runtests.py + dependencies: [] + tags: + - lint + # We allow the submodule checker to fail when run on merge requests (to -# accomodate, e.g., haddock changes not yet upstream) but not on `master` or +# accommodate, e.g., haddock changes not yet upstream) but not on `master` or # Marge jobs. .lint-submods: stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA) + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" + - "echo Linting submodule changes between $base..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $base..$CI_COMMIT_SHA) dependencies: [] tags: - lint lint-submods: extends: .lint-submods + # Allow failure on merge requests since any necessary submodule patches may + # not be upstreamed yet. rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/' allow_failure: false - allow_failure: true -lint-submods-mr: +lint-submods-branch: extends: .lint-submods - allow_failure: true + script: + - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA) rules: - - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' .lint-changelogs: stage: lint @@ -125,6 +163,7 @@ lint-submods-mr: lint-changelogs: extends: .lint-changelogs + # Allow failure since this isn't a final release. allow_failure: true rules: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' @@ -140,71 +179,183 @@ lint-release-changelogs: ############################################################ .validate-hadrian: - <<: *only-default - allow_failure: true + variables: + FLAVOUR: "validate" script: - - cabal update - - git clean -xdf && git submodule foreach git clean -xdf - - bash .circleci/prepare-system.sh - - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi - - ./boot - - ./configure $CONFIGURE_ARGS - - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian cache: key: hadrian paths: - cabal-cache artifacts: - when: always + reports: + junit: junit.xml + expire_in: 2 week paths: - ghc.tar.xz + - junit.xml -validate-x86_64-linux-deb8-hadrian: +.validate-linux-hadrian: extends: .validate-hadrian - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + variables: + TEST_ENV: "x86_64-linux-deb9-hadrian" before_script: # workaround for docker permissions - sudo chown ghc:ghc -R . - - python3 .gitlab/fix-submodules.py - git submodule sync --recursive - git submodule update --init --recursive - git checkout .gitmodules - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + after_script: + - .gitlab/ci.sh clean tags: - x86_64-linux +validate-x86_64-linux-deb9-hadrian: + extends: .validate-linux-hadrian + stage: build + +validate-x86_64-linux-deb9-unreg-hadrian: + extends: .validate-linux-hadrian + stage: full-build + variables: + CONFIGURE_ARGS: --enable-unregisterised + TEST_ENV: "x86_64-linux-deb9-unreg-hadrian" + +.hadrian-ghc-in-ghci: + stage: quick-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + variables: + GHC_FLAGS: -Werror + tags: + - x86_64-linux + script: + - cabal update + - cd hadrian; cabal new-build --project-file=ci.project; cd .. + - git clean -xdf && git submodule foreach git clean -xdf + - .gitlab/ci.sh setup + - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi + - ./boot + - ./configure $CONFIGURE_ARGS + # 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," + cache: + key: hadrian-ghci + paths: + - cabal-cache ############################################################ # Validation via Pipelines (make) ############################################################ .validate: - <<: *only-default variables: TEST_TYPE: test - before_script: - - git clean -xdf && git submodule foreach git clean -xdf + MAKE_ARGS: "-Werror" script: - - ./boot - - ./configure $CONFIGURE_ARGS - - | - THREADS=`mk/detect-cpu-count.sh` - make V=0 -j$THREADS WERROR=-Werror - - | - make binary-dist TAR_COMP_OPTS="-1" - - | - THREADS=`mk/detect-cpu-count.sh` - make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_make + - .gitlab/ci.sh test_make dependencies: [] artifacts: reports: junit: junit.xml expire_in: 2 week paths: - - ghc-*.tar.xz + - $BIN_DIST_PREP_TAR_COMP - junit.xml + - performance-metrics.tsv + +################################# +# x86_64-freebsd +################################# + +.build-x86_64-freebsd: + extends: .validate + tags: + - x86_64-freebsd + allow_failure: true + variables: + # N.B. we use iconv from ports as I see linker errors when we attempt + # to use the "native" iconv embedded in libc as suggested by the + # porting guide [1]. + # [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + GHC_VERSION: 8.10.1 + CABAL_INSTALL_VERSION: 3.2.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd" + BUILD_FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Conditional due to lack of builder capacity +validate-x86_64-freebsd: + extends: .build-x86_64-freebsd + stage: full-build + rules: + - if: '$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/' + +nightly-x86_64-freebsd: + <<: *nightly + extends: .build-x86_64-freebsd + stage: full-build + +release-x86_64-freebsd: + <<: *release + extends: .build-x86_64-freebsd + stage: full-build + +.build-x86_64-freebsd-hadrian: + extends: .validate-hadrian + stage: full-build + tags: + - x86_64-freebsd + allow_failure: true + variables: + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + HADRIAN_ARGS: "--docs=no-sphinx" + GHC_VERSION: 8.6.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd-hadrian" + FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Disabled due to lack of builder capacity +.validate-x86_64-freebsd-hadrian: + extends: .build-x86_64-freebsd-hadrian + stage: full-build ################################# # x86_64-darwin @@ -216,54 +367,71 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: "8.8.3" - CABAL_INSTALL_VERSION: 2.4.1.0 - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz" + GHC_VERSION: 8.8.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-apple-darwin.tar.xz" MACOSX_DEPLOYMENT_TARGET: "10.7" # Only Sierra and onwards supports clock_gettime. See #12858 ac_cv_func_clock_gettime: "no" LANG: "en_US.UTF-8" - CONFIGURE_ARGS: --with-intree-gmp + CONFIGURE_ARGS: "--with-intree-gmp" TEST_ENV: "x86_64-darwin" - before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - - bash .gitlab/darwin-init.sh - - PATH="`pwd`/toolchain/bin:$PATH" + BUILD_FLAVOUR: "perf" after_script: - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean artifacts: when: always expire_in: 2 week cache: - key: darwin + key: "darwin-$GHC_VERSION" paths: - cabal-cache - toolchain +# Disabled because of OS X CI capacity +.validate-x86_64-darwin-hadrian: + stage: full-build + tags: + - x86_64-darwin + variables: + GHC_VERSION: 8.8.3 + MACOSX_DEPLOYMENT_TARGET: "10.7" + ac_cv_func_clock_gettime: "no" + LANG: "en_US.UTF-8" + CONFIGURE_ARGS: --with-intree-gmp + TEST_ENV: "x86_64-darwin-hadrian" + FLAVOUR: "validate" + script: + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + reports: + junit: junit.xml + paths: + - ghc.tar.xz + - junit.xml + .validate-linux: extends: .validate tags: - x86_64-linux + variables: + BUILD_FLAVOUR: "perf" before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" # Build hyperlinked sources for documentation when building releases - | if [[ -n "$CI_COMMIT_TAG" ]]; then - echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk + HADDOCK_HYPERLINKED_SOURCES=1 fi - - bash .circleci/prepare-system.sh # workaround for docker permissions - sudo chown ghc:ghc -R . after_script: @@ -285,9 +453,7 @@ validate-x86_64-darwin: allow_failure: true variables: TEST_ENV: "aarch64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz" - # Inexplicably makeindex fails - BUILD_SPHINX_PDF: "NO" + BIN_DIST_PREP_TAR_COMP: "ghc-aarch64-linux-deb9.tar.xz" cache: key: linux-aarch64-deb9 tags: @@ -302,8 +468,41 @@ validate-aarch64-linux-deb9: nightly-aarch64-linux-deb9: <<: *nightly extends: .build-aarch64-linux-deb9 + variables: + TEST_TYPE: slowtest + +################################# +# armv7-linux-deb9 +################################# + +.build-armv7-linux-deb9: + extends: .validate-linux + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb9:$DOCKER_REV" + # Due to linker issues + allow_failure: true + variables: + TEST_ENV: "armv7-linux-deb9" + BIN_DIST_PREP_TAR_COMP: "ghc-armv7-linux-deb9.tar.xz" + CONFIGURE_ARGS: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" + # N.B. We disable ld.lld explicitly here because it appears to fail + # non-deterministically on ARMv7. See #18280. + LD: "ld.gold" + GccUseLdOpt: "-fuse-ld=gold" + cache: + key: linux-armv7-deb9 + tags: + - armv7-linux + +validate-armv7-linux-deb9: + extends: .build-armv7-linux-deb9 artifacts: - expire_in: 2 year + when: always + expire_in: 2 week + +nightly-armv7-linux-deb9: + <<: *nightly + extends: .build-armv7-linux-deb9 variables: TEST_TYPE: slowtest @@ -317,7 +516,7 @@ nightly-aarch64-linux-deb9: image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "i386-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-i386-deb9-linux.tar.xz" cache: key: linux-i386-deb9 @@ -332,23 +531,6 @@ nightly-i386-linux-deb9: extends: .build-i386-linux-deb9 variables: TEST_TYPE: slowtest - artifacts: - when: always - expire_in: 2 week - -################################# -# x86_64-linux-deb10 -################################# - -.build-x86_64-linux-deb10: - extends: .validate-linux - stage: full-build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - variables: - TEST_ENV: "x86_64-linux-deb10" - BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" - cache: - key: linux-x86_64-deb10 ################################# # x86_64-linux-deb9 @@ -356,40 +538,62 @@ nightly-i386-linux-deb9: .build-x86_64-linux-deb9: extends: .validate-linux - stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb9-linux.tar.xz" cache: key: linux-x86_64-deb9 -validate-x86_64-linux-deb9: +# Disabled to reduce CI load +.validate-x86_64-linux-deb9: extends: .build-x86_64-linux-deb9 + stage: full-build artifacts: when: always expire_in: 2 week +release-x86_64-linux-deb9: + <<: *release + extends: .build-x86_64-linux-deb9 + stage: full-build + nightly-x86_64-linux-deb9: <<: *nightly extends: .build-x86_64-linux-deb9 - artifacts: - expire_in: 2 year + stage: full-build variables: TEST_TYPE: slowtest # N.B. Has DEBUG assertions enabled in stage2 validate-x86_64-linux-deb9-debug: extends: .build-x86_64-linux-deb9 - stage: build + stage: full-build variables: BUILD_FLAVOUR: validate + # Ensure that stage2 also has DEBUG enabled + ValidateSpeed: SLOW + # Override validate flavour default; see #16890. + BUILD_SPHINX_PDF: "YES" + TEST_TYPE: slowtest TEST_ENV: "x86_64-linux-deb9-debug" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-debug.tar.xz" + artifacts: + when: always + expire_in: 2 week -validate-x86_64-linux-deb9-llvm: +# Disabled to alleviate CI load +.validate-x86_64-linux-deb9-llvm: + extends: .build-x86_64-linux-deb9 + stage: full-build + variables: + BUILD_FLAVOUR: perf-llvm + TEST_ENV: "x86_64-linux-deb9-llvm" + +nightly-x86_64-linux-deb9-llvm: + <<: *nightly extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: BUILD_FLAVOUR: perf-llvm TEST_ENV: "x86_64-linux-deb9-llvm" @@ -397,11 +601,11 @@ validate-x86_64-linux-deb9-llvm: validate-x86_64-linux-deb9-integer-simple: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: + BUILD_FLAVOUR: validate INTEGER_LIBRARY: integer-simple - TEST_ENV: "x86_64-linux-deb9-integer-simple" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz" + TEST_ENV: "x86_64-linux-deb9-integer-simple-validate" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-integer-simple.tar.xz" nightly-x86_64-linux-deb9-integer-simple: <<: *nightly @@ -411,185 +615,205 @@ nightly-x86_64-linux-deb9-integer-simple: INTEGER_LIBRARY: integer-simple TEST_ENV: "x86_64-linux-deb9-integer-simple" TEST_TYPE: slowtest - artifacts: - expire_in: 2 year -validate-x86_64-linux-deb9-unreg: +validate-x86_64-linux-deb9-dwarf: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: - CONFIGURE_ARGS: --enable-unregisterised - TEST_ENV: "x86_64-linux-deb9-unreg" + CONFIGURE_ARGS: "--enable-dwarf-unwind" + BUILD_FLAVOUR: dwarf + TEST_ENV: "x86_64-linux-deb9-dwarf" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-dwarf.tar.xz" + +################################# +# x86_64-linux-deb10 +################################# -release-x86_64-linux-deb9-dwarf: +.build-x86_64-linux-deb10: extends: .validate-linux - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" - allow_failure: true + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb9" - artifacts: - when: always - expire_in: 2 week + TEST_ENV: "x86_64-linux-deb10" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" cache: - key: linux-x86_64-deb9 + key: linux-x86_64-deb10 +# Disabled to alleviate CI load +.validate-x86_64-linux-deb10: + extends: .build-x86_64-linux-deb10 + stage: full-build -release-x86_64-linux-deb10-dwarf: - <<: *release +nightly-x86_64-linux-deb10: + <<: *nightly extends: .build-x86_64-linux-deb10 variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb10-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb10-linux-dwarf.tar.xz" + TEST_TYPE: slowtest + +release-x86_64-linux-deb10: + <<: *release + extends: .build-x86_64-linux-deb10 ################################# # x86_64-linux-deb8 ################################# -release-x86_64-linux-deb8: - <<: *release +.build-x86_64-linux-deb8: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + # Due to #18298. + allow_failure: true variables: TEST_ENV: "x86_64-linux-deb8" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz" - # Disable sphinx PDF output as our Debian image doesn't have the requisite packages + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb8-linux.tar.xz" + # Debian 8's Sphinx is too old to support the table directive's :widths: + # option: https://sourceforge.net/p/docutils/patches/120/ + BUILD_SPHINX_HTML: "NO" + BUILD_SPHINX_INFO: "NO" BUILD_SPHINX_PDF: "NO" + BUILD_SPHINX_MAN: "NO" cache: key: linux-x86_64-deb8 + +release-x86_64-linux-deb8: + <<: *release + extends: .build-x86_64-linux-deb8 + +################################# +# x86_64-linux-alpine +################################# + +.build-x86_64-linux-alpine-hadrian: + extends: .validate-linux-hadrian + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine:$DOCKER_REV" + # There are currently a few failing tests + allow_failure: true + variables: + TEST_ENV: "x86_64-linux-alpine" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-alpine-linux.tar.xz" + # Can't use ld.gold due to #13958. + CONFIGURE_ARGS: "--disable-ld-override" + HADRIAN_ARGS: "--docs=no-sphinx" + # encoding004 due to lack of locale support + # T10458 due to fact that dynamic linker tries to reload libAS + BROKEN_TESTS: "encoding004 T10458" + cache: + key: linux-x86_64-alpine artifacts: when: always expire_in: 2 week +release-x86_64-linux-alpine: + <<: *release + extends: .build-x86_64-linux-alpine-hadrian + +nightly-x86_64-linux-alpine: + <<: *nightly + extends: .build-x86_64-linux-alpine-hadrian + ################################# # x86_64-linux-centos7 ################################# -release-x86_64-linux-centos7: - <<: *release +.build-x86_64-linux-centos7: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" variables: - # For the testsuite - LANG: "en_US.UTF-8" # The sphinx release shipped with Centos 7 fails to build out documentation BUILD_SPHINX_HTML: "NO" BUILD_SPHINX_PDF: "NO" TEST_ENV: "x86_64-linux-centos7" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz" - allow_failure: true + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-centos7-linux.tar.xz" + # CentOS seems to default to ascii + LANG: "en_US.UTF-8" cache: key: linux-x86_64-centos7 - artifacts: - when: always - expire_in: 2 week + +release-x86_64-linux-centos7: + <<: *release + extends: .build-x86_64-linux-centos7 ################################# # x86_64-linux-fedora27 ################################# -.build-x86_64-linux-fedora27: +validate-x86_64-linux-fedora27: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-fedora27" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: key: linux-x86_64-fedora27 - -validate-x86_64-linux-fedora27: - extends: .build-x86_64-linux-fedora27 artifacts: when: always # These are used for head.hackage jobs therefore we keep them around for # longer. expire_in: 8 week -release-x86_64-linux-fedora27: - <<: *release - extends: .build-x86_64-linux-fedora27 - -release-x86_64-linux-fedora27-dwarf: - <<: *release - extends: .build-x86_64-linux-fedora27 - variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-fedora27-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux-dwarf.tar.xz" - ############################################################ # Validation via Pipelines (Windows) ############################################################ .build-windows: - <<: *only-default + # For the reasons given in #17777 this build isn't reliable. + allow_failure: true before_script: - git clean -xdf - - git submodule foreach git clean -xdf - # Use a local temporary directory to ensure that concurrent builds don't - # interfere with one another - - | - mkdir tmp - set TMP=%cd%\tmp - set TEMP=%cd%\tmp - - - set PATH=C:\msys64\usr\bin;%PATH% - - python .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - bash .gitlab/win32-init.sh + # Setup toolchain + - bash .gitlab/ci.sh setup after_script: - - rd /s /q tmp - - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache - - bash -c 'make clean || true' + - | + Copy-Item -Recurse -Path $Env:APPDATA\cabal -Destination cabal-cache + - bash .gitlab/ci.sh clean dependencies: [] variables: - FORCE_SYMLINKS: 1 + #FORCE_SYMLINKS: 1 LANG: "en_US.UTF-8" SPHINXBUILD: "/mingw64/bin/sphinx-build.exe" + CABAL_INSTALL_VERSION: 3.0.0.0 + GHC_VERSION: "8.8.3" cache: paths: - cabal-cache - - ghc-8.6.2 + - toolchain - ghc-tarballs .build-windows-hadrian: extends: .build-windows stage: full-build - allow_failure: true variables: - GHC_VERSION: "8.8.3" + FLAVOUR: "validate" + # skipping perf tests for now since we build a quick-flavoured GHC, + # which might result in some broken perf tests? + HADRIAN_ARGS: "--docs=no-sphinx --skip-perf" + script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex' - - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist" - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz - # FIXME: Testsuite disabled due to #16156. - # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_hadrian + - bash .gitlab/ci.sh test_hadrian tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: + reports: + junit: junit.xml + expire_in: 2 week when: always paths: - ghc.tar.xz + - junit.xml validate-x86_64-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW64 + TEST_ENV: "x86_64-windows-hadrian" cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" @@ -598,86 +822,94 @@ nightly-i386-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW32 + TEST_ENV: "i386-windows-hadrian" cache: key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" .build-windows-make: extends: .build-windows stage: full-build - # due to #16084 - allow_failure: true variables: - BUILD_FLAVOUR: "UNSET" - GHC_VERSION: "8.8.3" - BUILD_PROF_LIBS: "YES" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz" + BUILD_FLAVOUR: "quick" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-mingw32.tar.xz" script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS' - - bash -c "echo \"include mk/flavours/${BUILD_FLAVOUR}.mk\" > mk/build.mk" - - bash -c "echo \"GhcLibHcOpts+=-haddock\" >> mk/build.mk" - - bash -c "echo \"BUILD_PROF_LIBS = $BUILD_PROF_LIBS\" >> mk/build.mk" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1" - - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_make + - bash .gitlab/ci.sh test_make tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: when: always expire_in: 2 week reports: junit: junit.xml paths: - - ghc-*.tar.xz + # N.B. variable interpolation apparently doesn't work on Windows so + # this can't be $BIN_DIST_PREP_TAR_COMP + - "ghc-x86_64-mingw32.tar.xz" - junit.xml -validate-x86_64-windows: +.build-x86_64-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" - BUILD_FLAVOUR: "quick" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" + TEST_ENV: "x86_64-windows" cache: key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-x86_64-windows: + extends: .build-x86_64-windows-make + +nightly-x86_64-windows: + <<: *nightly + extends: .build-x86_64-windows-make + stage: full-build + variables: + BUILD_FLAVOUR: "validate" + # Normal Windows validate builds are profiled; that won't do for releases. release-x86_64-windows: <<: *release extends: validate-x86_64-windows variables: - MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" - -release-i386-windows: + # +release-x86_64-windows-integer-simple: <<: *release - extends: .build-windows-make + extends: validate-x86_64-windows variables: - MSYSTEM: MINGW32 + INTEGER_LIBRARY: integer-simple BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - # Due to #15934 - BUILD_PROF_LIBS: "NO" - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows: - <<: *nightly + +.build-i386-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW32 - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - BUILD_FLAVOUR: "quick" # Due to #15934 BUILD_PROF_LIBS: "NO" + TEST_ENV: "i386-windows" + # Due to #17736 + allow_failure: true cache: key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-i386-windows: + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +release-i386-windows: + <<: *release + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +nightly-i386-windows: + <<: *nightly + extends: .build-i386-windows-make + ############################################################ # Cleanup ############################################################ @@ -687,40 +919,24 @@ nightly-i386-windows: # # As noted in [1], gitlab-runner's shell executor doesn't clean up its working # directory after builds. Unfortunately, we are forced to use the shell executor -# on Windows. To avoid running out of disk space we add a stage at the end of -# the build to remove the \GitLabRunner\builds directory. Since we only run a -# single build at a time on Windows this should be safe. +# on Darwin. To avoid running out of disk space we add a stage at the end of +# the build to remove the /.../GitLabRunner/builds directory. Since we only run a +# single build at a time on Darwin this should be safe. +# +# We used to have a similar cleanup job on Windows as well however it ended up +# being quite fragile as we have multiple Windows builders yet there is no +# guarantee that the cleanup job is run on the same machine as the build itself +# was run. Consequently we were forced to instead handle cleanup with a separate +# cleanup cron job on Windows. # # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856 -# See Note [Cleanup after shell executor] -cleanup-windows: - <<: *only-default - stage: cleanup - tags: - - x86_64-windows - dependencies: [] - before_script: - - echo "Time to clean up" - script: - - echo "Let's go" - after_script: - - set "BUILD_DIR=%CI_PROJECT_DIR%" - - set "BUILD_DIR=%BUILD_DIR:/=\%" - - echo "Cleaning %BUILD_DIR%" - - cd \GitLabRunner - # This is way more complicated than it should be: - # See https://stackoverflow.com/questions/1965787 - - del %BUILD_DIR%\* /F /Q - - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p" - - exit /b 0 - # See Note [Cleanup after shell executor] cleanup-darwin: - <<: *only-default stage: cleanup tags: - x86_64-darwin + when: always dependencies: [] before_script: - echo "Time to clean up" @@ -737,19 +953,56 @@ cleanup-darwin: # Packaging ############################################################ +doc-tarball: + stage: packaging + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + dependencies: + - validate-x86_64-linux-deb9-debug + - validate-x86_64-windows + variables: + LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz" + WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz" + # Due to Windows allow_failure + allow_failure: true + artifacts: + paths: + - haddock.html.tar.xz + - libraries.html.tar.xz + - users_guide.html.tar.xz + - index.html + - "*.pdf" + script: + - | + if [ ! -f "$LINUX_BINDIST" ]; then + echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" + exit 1 + fi + if [ ! -f "$WINDOWS_BINDIST" ]; then + echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?" + exit 1 + fi + - rm -Rf docs + - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST + - ls -lh + - mv docs/*.tar.xz docs/index.html . + source-tarball: - <<: *release stage: packaging tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" dependencies: [] + rules: + - if: $CI_COMMIT_TAG + when: always artifacts: paths: - ghc-*.tar.xz - version script: - - mk/get-win32-tarballs.sh download all + - python3 mk/get-win32-tarballs.py download all - ./boot - ./configure - make sdist @@ -770,9 +1023,8 @@ source-tarball: # pipeline. .hackage: - <<: *only-default - stage: hackage - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + stage: testing + image: ghcci/x86_64-linux-deb9:0.2 tags: - x86_64-linux dependencies: [] @@ -781,6 +1033,10 @@ source-tarball: script: - bash .gitlab/start-head.hackage.sh +hackage: + extends: .hackage + when: manual + hackage-label: extends: .hackage rules: @@ -790,3 +1046,69 @@ nightly-hackage: <<: *nightly extends: .hackage +############################################################ +# Nofib testing +############################################################ + +perf-nofib: + stage: testing + dependencies: + - validate-x86_64-linux-deb9-dwarf + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + rules: + - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + tags: + - x86_64-linux + script: + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ghc-x86_64-deb9-linux-dwarf.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - cabal update; cabal install -w $BOOT_HC regex-compat + - export PATH=$root/bin:$PATH + - make -C nofib boot mode=fast -j$CPUS + - "make -C nofib EXTRA_RUNTEST_OPTS='-cachegrind +RTS -V0 -RTS' NoFibRuns=1 mode=fast -j$CPUS 2>&1 | tee nofib.log" + artifacts: + expire_in: 12 week + when: always + paths: + - nofib.log + +############################################################ +# Documentation deployment via GitLab Pages +############################################################ + +pages: + stage: deploy + dependencies: + - doc-tarball + image: ghcci/x86_64-linux-deb9:0.2 + # Due to Windows allow_failure + allow_failure: true + tags: + - x86_64-linux + script: + - mkdir -p public/doc + - tar -xf haddock.html.tar.xz -C public/doc + - tar -xf libraries.html.tar.xz -C public/doc + - tar -xf users_guide.html.tar.xz -C public/doc + - | + cat >public/index.html < + + + EOF + - cp -f index.html public/doc + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + artifacts: + paths: + - public ===================================== .gitlab/ci.sh ===================================== @@ -0,0 +1,463 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2230 + +# This is the primary driver of the GitLab CI infrastructure. + +set -e -o pipefail + +# Configuration: +hackage_index_state="@1579718451" + +# Colors +BLACK="0;30" +GRAY="1;30" +RED="0;31" +LT_RED="1;31" +BROWN="0;33" +LT_BROWN="1;33" +GREEN="0;32" +LT_GREEN="1;32" +BLUE="0;34" +LT_BLUE="1;34" +PURPLE="0;35" +LT_PURPLE="1;35" +CYAN="0;36" +LT_CYAN="1;36" +WHITE="1;37" +LT_GRAY="0;37" + +export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 + +# GitLab Pipelines log section delimiters +# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664 +start_section() { + name="$1" + echo -e "section_start:$(date +%s):$name\015\033[0K" +} + +end_section() { + name="$1" + echo -e "section_end:$(date +%s):$name\015\033[0K" +} + +echo_color() { + local color="$1" + local msg="$2" + echo -e "\033[${color}m${msg}\033[0m" +} + +error() { echo_color "${RED}" "$1"; } +warn() { echo_color "${LT_BROWN}" "$1"; } +info() { echo_color "${LT_BLUE}" "$1"; } + +fail() { error "error: $1"; exit 1; } + +function run() { + info "Running $*..." + "$@" || ( error "$* failed"; return 1; ) +} + +TOP="$(pwd)" + +function mingw_init() { + case "$MSYSTEM" in + MINGW32) + triple="i386-unknown-mingw32" + boot_triple="i386-unknown-mingw32" # triple of bootstrap GHC + ;; + MINGW64) + triple="x86_64-unknown-mingw32" + boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC + ;; + *) + fail "win32-init: Unknown MSYSTEM $MSYSTEM" + ;; + esac + + # Bring mingw toolchain into PATH. + # This is extracted from /etc/profile since this script inexplicably fails to + # run under gitlab-runner. + # shellcheck disable=SC1091 + source /etc/msystem + MINGW_MOUNT_POINT="${MINGW_PREFIX}" + PATH="$MINGW_MOUNT_POINT/bin:$PATH" + + # We always use mingw64 Python to avoid path length issues like #17483. + export PYTHON="/mingw64/bin/python3" +} + +# This will contain GHC's local native toolchain +toolchain="$TOP/toolchain" +mkdir -p "$toolchain/bin" +PATH="$toolchain/bin:$PATH" + +export METRICS_FILE="$CI_PROJECT_DIR/performance-metrics.tsv" + +cores="$(mk/detect-cpu-count.sh)" + +# Use a local temporary directory to ensure that concurrent builds don't +# interfere with one another +mkdir -p "$TOP/tmp" +export TMP="$TOP/tmp" +export TEMP="$TOP/tmp" + +function darwin_setup() { + # It looks like we already have python2 here and just installing python3 + # does not work. + brew upgrade python + brew install ghc cabal-install ncurses gmp + + pip3 install sphinx + # PDF documentation disabled as MacTeX apparently doesn't include xelatex. + #brew cask install mactex +} + +function show_tool() { + local tool="$1" + info "$tool = ${!tool}" + ${!tool} --version +} + +function set_toolchain_paths() { + needs_toolchain=1 + case "$(uname)" in + Linux) needs_toolchain="" ;; + *) ;; + esac + + if [[ -n "$needs_toolchain" ]]; then + # These are populated by setup_toolchain + GHC="$toolchain/bin/ghc$exe" + CABAL="$toolchain/bin/cabal$exe" + HAPPY="$toolchain/bin/happy$exe" + ALEX="$toolchain/bin/alex$exe" + else + GHC="$(which ghc)" + CABAL="/usr/local/bin/cabal" + HAPPY="$HOME/.cabal/bin/happy" + ALEX="$HOME/.cabal/bin/alex" + fi + export GHC + export CABAL + export HAPPY + export ALEX +} + +# Extract GHC toolchain +function setup() { + if [ -d "$TOP/cabal-cache" ]; then + info "Extracting cabal cache..." + mkdir -p "$cabal_dir" + cp -Rf cabal-cache/* "$cabal_dir" + fi + + if [[ -n "$needs_toolchain" ]]; then + setup_toolchain + fi + case "$(uname)" in + Darwin) darwin_setup ;; + *) ;; + esac + + # Make sure that git works + git config user.email "ghc-ci at gitlab-haskell.org" + git config user.name "GHC GitLab CI" + + info "=====================================================" + info "Toolchain versions" + info "=====================================================" + show_tool GHC + show_tool CABAL + show_tool HAPPY + show_tool ALEX +} + +function fetch_ghc() { + local v="$GHC_VERSION" + if [[ -z "$v" ]]; then + fail "GHC_VERSION is not set" + fi + + if [ ! -e "$GHC" ]; then + start_section "fetch GHC" + url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple}.tar.xz" + info "Fetching GHC binary distribution from $url..." + curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution" + tar -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution" + case "$(uname)" in + MSYS_*|MINGW*) + cp -r "ghc-${GHC_VERSION}"/* "$toolchain" + ;; + *) + pushd "ghc-${GHC_VERSION}" + ./configure --prefix="$toolchain" + "$MAKE" install + popd + ;; + esac + rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz + end_section "fetch GHC" + fi + +} + +function fetch_cabal() { + local v="$CABAL_INSTALL_VERSION" + if [[ -z "$v" ]]; then + fail "CABAL_INSTALL_VERSION is not set" + fi + + if [ ! -e "$CABAL" ]; then + start_section "fetch GHC" + case "$(uname)" in + # N.B. Windows uses zip whereas all others use .tar.xz + MSYS_*|MINGW*) + case "$MSYSTEM" in + MINGW32) cabal_arch="i386" ;; + MINGW64) cabal_arch="x86_64" ;; + *) fail "unknown MSYSTEM $MSYSTEM" ;; + esac + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-unknown-mingw32.zip" + info "Fetching cabal binary distribution from $url..." + curl "$url" > "$TMP/cabal.zip" + unzip "$TMP/cabal.zip" + mv cabal.exe "$CABAL" + ;; + *) + local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/" + case "$(uname)" in + Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;; + FreeBSD) + #cabal_url="$base_url/cabal-install-$v-x86_64-portbld-freebsd.tar.xz" ;; + cabal_url="http://home.smart-cactus.org/~ben/ghc/cabal-install-3.0.0.0-x86_64-portbld-freebsd.tar.xz" ;; + *) fail "don't know where to fetch cabal-install for $(uname)" + esac + echo "Fetching cabal-install from $cabal_url" + curl "$cabal_url" > cabal.tar.xz + tar -xJf cabal.tar.xz + mv cabal "$toolchain/bin" + ;; + esac + end_section "fetch GHC" + fi +} + +# For non-Docker platforms we prepare the bootstrap toolchain +# here. For Docker platforms this is done in the Docker image +# build. +function setup_toolchain() { + fetch_ghc + fetch_cabal + cabal_install="$CABAL v2-install --index-state=$hackage_index_state --installdir=$toolchain/bin" + # Avoid symlinks on Windows + case "$(uname)" in + MSYS_*|MINGW*) cabal_install="$cabal_install --install-method=copy" ;; + *) ;; + esac + + if [ ! -e "$HAPPY" ]; then + info "Building happy..." + cabal update + $cabal_install happy + fi + + if [ ! -e "$ALEX" ]; then + info "Building alex..." + cabal update + $cabal_install alex + fi +} + +function cleanup_submodules() { + start_section "clean submodules" + info "Cleaning submodules..." + # On Windows submodules can inexplicably get into funky states where git + # believes that the submodule is initialized yet its associated repository + # is not valid. Avoid failing in this case with the following insanity. + git submodule sync --recursive || git submodule deinit --force --all + git submodule update --init --recursive + git submodule foreach git clean -xdf + end_section "clean submodules" +} + +function prepare_build_mk() { + if [[ -z "$BUILD_FLAVOUR" ]]; then fail "BUILD_FLAVOUR is not set"; fi + if [[ -z ${BUILD_SPHINX_HTML:-} ]]; then BUILD_SPHINX_HTML=YES; fi + if [[ -z ${BUILD_SPHINX_PDF:-} ]]; then BUILD_SPHINX_PDF=YES; fi + if [[ -z ${INTEGER_LIBRARY:-} ]]; then INTEGER_LIBRARY=integer-gmp; fi + + cat > mk/build.mk <> mk/build.mk + fi + + case "$(uname)" in + Darwin) echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk ;; + *) ;; + esac + + info "build.mk is:" + cat mk/build.mk +} + +function configure() { + start_section "booting" + run python3 boot + end_section "booting" + + local target_args="" + if [[ -n "$triple" ]]; then + target_args="--target=$triple" + fi + + start_section "configuring" + run ./configure \ + --enable-tarballs-autodownload \ + $target_args \ + $CONFIGURE_ARGS \ + GHC="$GHC" \ + HAPPY="$HAPPY" \ + ALEX="$ALEX" \ + || ( cat config.log; fail "configure failed" ) + end_section "configuring" +} + +function build_make() { + prepare_build_mk + if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then + fail "BIN_DIST_PREP_TAR_COMP is not set" + fi + + echo "include mk/flavours/${BUILD_FLAVOUR}.mk" > mk/build.mk + echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk + run "$MAKE" -j"$cores" $MAKE_ARGS + run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 + ls -lh "$BIN_DIST_PREP_TAR_COMP" +} + +function fetch_perf_notes() { + info "Fetching perf notes..." + "$TOP/.gitlab/test-metrics.sh" pull +} + +function push_perf_notes() { + info "Pushing perf notes..." + "$TOP/.gitlab/test-metrics.sh" push +} + +function test_make() { + run "$MAKE" test_bindist TEST_PREP=YES + run "$MAKE" V=0 test \ + THREADS="$cores" \ + JUNIT_FILE=../../junit.xml +} + +function build_hadrian() { + if [ -z "$FLAVOUR" ]; then + fail "FLAVOUR not set" + fi + + run_hadrian binary-dist + + mv _build/bindist/ghc*.tar.xz ghc.tar.xz +} + +function test_hadrian() { + cd _build/bindist/ghc-*/ + run ./configure --prefix="$TOP"/_build/install + run "$MAKE" install + cd ../../../ + + run_hadrian \ + test \ + --summary-junit=./junit.xml \ + --test-compiler="$TOP"/_build/install/bin/ghc +} + +function clean() { + rm -R tmp + run "$MAKE" --quiet clean || true + run rm -Rf _build +} + +function run_hadrian() { + run hadrian/build.cabal.sh \ + --flavour="$FLAVOUR" \ + -j"$cores" \ + $HADRIAN_ARGS \ + $@ +} + +# A convenience function to allow debugging in the CI environment. +function shell() { + local cmd=$@ + if [ -z "$cmd" ]; then + cmd="bash -i" + fi + run $cmd +} + +# Determine Cabal data directory +case "$(uname)" in + MSYS_*|MINGW*) exe=".exe"; cabal_dir="$APPDATA/cabal" ;; + *) cabal_dir="$HOME/.cabal"; exe="" ;; +esac + +# Platform-specific environment initialization +MAKE="make" +case "$(uname)" in + MSYS_*|MINGW*) mingw_init ;; + Darwin) boot_triple="x86_64-apple-darwin" ;; + FreeBSD) + boot_triple="x86_64-portbld-freebsd" + MAKE="gmake" + ;; + Linux) ;; + *) fail "uname $(uname) is not supported" ;; +esac + +set_toolchain_paths + +case $1 in + setup) setup && cleanup_submodules ;; + configure) configure ;; + build_make) build_make ;; + test_make) + fetch_perf_notes + res=0 + test_make || res=$? + push_perf_notes + exit $res ;; + build_hadrian) build_hadrian ;; + # N.B. Always push notes, even if the build fails. This is okay to do as the + # testsuite driver doesn't record notes for tests that fail due to + # correctness. + test_hadrian) + fetch_perf_notes + res=0 + test_hadrian || res=$? + push_perf_notes + exit $res ;; + run_hadrian) run_hadrian $@ ;; + clean) clean ;; + shell) shell $@ ;; + *) fail "unknown mode $1" ;; +esac ===================================== .gitlab/darwin-init.sh deleted ===================================== @@ -1,41 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $HOME/.cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - mkdir -p tmp - cd tmp - ghc_tarball="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-x86_64-apple-darwin.tar.xz" - echo "Fetching GHC from $ghc_tarball" - curl $ghc_tarball | tar -xJ - cd ghc-$GHC_VERSION - ./configure --prefix=$toolchain - make install - cd ../.. - rm -Rf tmp -fi - -if [ ! -e $toolchain/bin/cabal ]; then - cabal_tarball="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL_VERSION/cabal-install-$CABAL_INSTALL_VERSION-x86_64-apple-darwin-sierra.tar.xz" - echo "Fetching cabal-install from $cabal_tarball" - curl $cabal_tarball | tar -xz - mv cabal $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal new-install happy --symlink-bindir=$toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal new-install alex --symlink-bindir=$toolchain/bin -fi - ===================================== .gitlab/linters/check-makefiles.py ===================================== @@ -1,5 +1,11 @@ #!/usr/bin/env python3 +""" +Linters for testsuite makefiles +""" + +from linter import run_linters, RegexpLinter + """ Warn for use of `--interactive` inside Makefiles (#11468). @@ -7,13 +13,21 @@ Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to forget one of those flags when adding a new test. """ +interactive_linter = \ + RegexpLinter(r'--interactive', + message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`." + ).add_path_filter(lambda path: path.name == 'Makefile') -from linter import run_linters, RegexpLinter +test_hc_quotes_linter = \ + RegexpLinter('\t\\$\\(TEST_HC\\)', + message = "Warning: $(TEST_HC) should be quoted in Makefiles.", + ).add_path_filter(lambda path: path.name == 'Makefile') linters = [ - RegexpLinter(r'--interactive', - message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`.") + interactive_linter, + test_hc_quotes_linter, ] if __name__ == '__main__': - run_linters(linters) #$, subdir='testsuite') + run_linters(linters, + subdir='testsuite') ===================================== .gitlab/linters/check-version-number.sh ===================================== @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +grep -E -q '\[[0-9]+\.[0-9]+\.[0-9]+\]' configure.ac || + ( echo "error: configure.ac: GHC version number must have three components."; exit 1 ) ===================================== .gitlab/linters/linter.py ===================================== @@ -7,10 +7,11 @@ import sys import re import textwrap import subprocess -from typing import List, Optional +from pathlib import Path +from typing import List, Optional, Callable, Sequence from collections import namedtuple -def lint_failure(file, line_no, line_content, message): +def lint_failure(file, line_no: int, line_content: str, message: str): """ Print a lint failure message. """ wrapper = textwrap.TextWrapper(initial_indent=' ', subsequent_indent=' ') @@ -29,7 +30,7 @@ def lint_failure(file, line_no, line_content, message): print(textwrap.dedent(msg)) -def get_changed_files(base_commit, head_commit, +def get_changed_files(base_commit: str, head_commit: str, subdir: str = '.'): """ Get the files changed by the given range of commits. """ cmd = ['git', 'diff', '--name-only', @@ -46,12 +47,21 @@ class Linter(object): """ def __init__(self): self.warnings = [] # type: List[Warning] + self.path_filters = [] # type: List[Callable[[Path], bool]] def add_warning(self, w: Warning): self.warnings.append(w) - def lint(self, path): - pass + def add_path_filter(self, f: Callable[[Path], bool]) -> "Linter": + self.path_filters.append(f) + return self + + def do_lint(self, path: Path): + if all(f(path) for f in self.path_filters): + self.lint(path) + + def lint(self, path: Path): + raise NotImplementedError class LineLinter(Linter): """ @@ -59,44 +69,55 @@ class LineLinter(Linter): the given line from a file and calls :func:`add_warning` for any lint issues found. """ - def lint(self, path): - if os.path.isfile(path): - with open(path, 'r') as f: + def lint(self, path: Path): + if path.is_file(): + with path.open('r') as f: for line_no, line in enumerate(f): self.lint_line(path, line_no+1, line) - def lint_line(self, path, line_no, line): - pass + def lint_line(self, path: Path, line_no: int, line: str): + raise NotImplementedError class RegexpLinter(LineLinter): """ A :class:`RegexpLinter` produces the given warning message for all lines matching the given regular expression. """ - def __init__(self, regex, message): + def __init__(self, regex: str, message: str): LineLinter.__init__(self) self.re = re.compile(regex) self.message = message - def lint_line(self, path, line_no, line): + def lint_line(self, path: Path, line_no: int, line: str): if self.re.search(line): w = Warning(path=path, line_no=line_no, line_content=line[:-1], message=self.message) self.add_warning(w) -def run_linters(linters: List[Linter], +def run_linters(linters: Sequence[Linter], subdir: str = '.') -> None: import argparse parser = argparse.ArgumentParser() - parser.add_argument('base', help='Base commit') - parser.add_argument('head', help='Head commit') + subparsers = parser.add_subparsers() + + subparser = subparsers.add_parser('commits', help='Lint a range of commits') + subparser.add_argument('base', help='Base commit') + subparser.add_argument('head', help='Head commit') + subparser.set_defaults(get_linted_files=lambda args: + get_changed_files(args.base, args.head, subdir)) + + subparser = subparsers.add_parser('files', help='Lint a range of commits') + subparser.add_argument('file', nargs='+', help='File to lint') + subparser.set_defaults(get_linted_files=lambda args: args.file) + args = parser.parse_args() - for path in get_changed_files(args.base, args.head, subdir): + linted_files = args.get_linted_files(args) + for path in linted_files: if path.startswith('.gitlab/linters'): continue for linter in linters: - linter.lint(path) + linter.do_lint(Path(path)) warnings = [warning for linter in linters ===================================== .gitlab/test-metrics.sh ===================================== @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +# vim: sw=2 et +set -euo pipefail + +NOTES_ORIGIN="https://gitlab.haskell.org/ghc/ghc-performance-notes.git" +NOTES_ORIGIN_PUSH="git at gitlab.haskell.org:ghc/ghc-performance-notes.git" +REF="perf" + +run() { + echo "$@" + $@ +} + +fail() { + echo "ERROR: $*" >&2 + exit 1 +} + +function pull() { + local ref="refs/notes/$REF" + run git fetch -f $NOTES_ORIGIN $ref:$ref + echo "perf notes ref $ref is $(git rev-parse $ref)" +} + +function setup_ssh() { + # Add gitlab as a known host. + # This can be generated with `ssh-keyscan -H gitlab.haskell.org` + mkdir -p ~/.ssh + echo "|1|cta91z3DoAGdpX2Epe9WF+sr+Rk=|1qlsbqiTTa8YsDyQBjVnzANFQ3Y= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDSzzl8mwY6ohtW6MftKaQfta8yTL8cTxtA7lcueo2mkPpwBBQ7FA6z3nFATx25QwdV7fa7DuNRDX57f/a/W7+wMhXZ6yyQr+gwr0h4vdZ8Nt4XNfNdkdGw4fZKRApWxyvfSkxjs/E9+G0o3eQLspxjVohBkmkcsowpFUI5Aazv/K6QIf1gKt+4iPvYcB/dBJ1yF1qmpayz4htrKyUC5l3GCBEwvMdAjIQ2bX8pyjTtqcJDLosAVzQ5wprkdgkL29MgJXEbM+B1d1log0hnX4AsbOlL7tWhTO1Je2hSuEeiVaDDPFUyCoGQRFDrisQU5lb8NrzuN3jpNc+PxOHbXHfaTppAoED/++UepvgtLF1zUM13cRk56YmpmABOa48W72VJuzLLm8DF+KBWBs6TDuVk3y9z/SS6zDS0VGkHotldopW2kpsjErJIdWVKIL3RP/Flay7mzl3l/izIMTHXXKMxV3/+XaBjG/gDOCld3JjORQXah2hvJfvXeNaePE1RKAMS63cj3XTE77fsYH7VmEdE34RTBDtsZR5WhEjdf29hjEcQDPf0vDphxRHr6IqUSwVcd7ps6nVoccTfaepJm62IIXDgOsc2piWl2xXNZJVtph6U+MzsPDSSbu1MTwalwgqpApcYK7ZzUjGHA7+NBhjjSuUZO6eHzwxjAn0FXZyrpQ==" >> ~/.ssh/known_hosts + echo "|1|uZkjsBS2bmdh7L/8zBquxJd/F20=|by/tpuDAPT6BpEXrDOiOv1/Zx/A= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA7ltOZyaULDgxE3Vw6RgQVp+OPKQi79ssUenbhdWy36" >> ~/.ssh/known_hosts + + # Setup ssh keys. + eval `ssh-agent` + echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJPR1vrZgeGTXmgJw2PsJfMjf22LcDnVVwt3l0rwTZ+8Q2J0bHaYxMRKBco1sON6LGcZepw0Hy76RQ87v057pTz18SXvnfE7U/B6v9qBk0ILJz+4BOX9sEhxu2XmScp/wMxkG9IoyruMlsxXzd1sz09o+rzzx24U2Rp27PRm08vG0oipve6BWLbYEqYrE4/nCufqOJmGd56fju7OTU0lTpEkGDEDWGMxutaX2CbTbDju7qy07Ld8BjSc9aHfvuQaslUbj3ex3EF8EXahURzGpHQn/UFFzVGMokFumiJCAagHQb7cj6jOkKseZLaysbA/mTBQsOzjWiRmkN23bQf1wF ben+ghc-ci at smart-cactus.org" > ~/.ssh/perf_rsa.pub + touch ~/.ssh/perf_rsa + chmod 0600 ~/.ssh/perf_rsa + echo "$PERF_NOTE_KEY" >> ~/.ssh/perf_rsa + ssh-add ~/.ssh/perf_rsa +} + +# Reset the git notes and append the metrics file to the notes, then push and return the result. +# This is favoured over a git notes merge as it avoids potential data loss/duplication from the merge strategy. +function reset_append_note_push { + pull || true + run git notes --ref=$REF append -F $METRICS_FILE HEAD + run git push $NOTES_ORIGIN_PUSH refs/notes/$REF +} + +function push() { + # Check that private key is available (Set on all GitLab protected branches). + if [ -z ${PERF_NOTE_KEY+"$PERF_NOTE_KEY"} ] + then + echo "Not pushing performance git notes: PERF_NOTE_KEY is not set." + exit 0 + fi + + # TEST_ENV must be set. + if [ -z ${TEST_ENV+"$TEST_ENV"} ] + then + fail "Not pushing performance git notes: TEST_ENV must be set." + fi + + # Assert that the METRICS_FILE exists and can be read. + if [ -z ${METRICS_FILE+"$METRICS_FILE"} ] + then + fail "\$METRICS_FILE not set." + fi + if ! [ -r $METRICS_FILE ] + then + fail "Metrics file not found: $METRICS_FILE" + fi + + setup_ssh + + # Push the metrics file as a git note. This may fail if another task pushes a note first. In that case + # the latest note is fetched and appended. + MAX_RETRY=20 + until reset_append_note_push || [ $MAX_RETRY -le 0 ] + do + ((MAX_RETRY--)) + echo "" + echo "Failed to push git notes. Fetching, appending, and retrying... $MAX_RETRY retries left." + done +} + +case $1 in + push) push ;; + pull) pull ;; + *) fail "Invalid mode $1" ;; +esac ===================================== .gitlab/win32-init.sh deleted ===================================== @@ -1,50 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:/mingw64/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $APPDATA/cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - case $MSYSTEM in - MINGW32) - triple="i386-unknown-mingw32" - ;; - MINGW64) - triple="x86_64-unknown-mingw32" - ;; - *) - echo "win32-init: Unknown MSYSTEM $MSYSTEM" - exit 1 - ;; - esac - if [ -z "$GHC_TARBALL_URL" ]; then - GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" - fi - curl "$GHC_TARBALL_URL" | tar -xJ - mv ghc-$GHC_VERSION toolchain -fi - -if [ ! -e $toolchain/bin/cabal ]; then - url="https://downloads.haskell.org/~cabal/cabal-install-2.4.1.0/cabal-install-2.4.1.0-x86_64-unknown-mingw32.zip" - curl $url > /tmp/cabal.zip - unzip /tmp/cabal.zip - mv cabal.exe $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal install happy - cp $APPDATA/cabal/bin/happy $toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal install alex - cp $APPDATA/cabal/bin/alex $toolchain/bin -fi - ===================================== hadrian/ci.project ===================================== @@ -0,0 +1,4 @@ +packages: ./ + +package hadrian + -- ghc-options: -Werror ===================================== hadrian/doc/flavours.md ===================================== @@ -110,6 +110,28 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH -O0
-DDEBUG + + validate + -O0
-H64m + -fllvm-fill-undef-with-garbage + + -O
-dcore-lint
-dno-debug-output + -O2
-DDEBUG + -O
-dcore-lint
-dno-debug-output + -O + -O + + + validate + -O0
-H64m + -fllvm-fill-undef-with-garbage + + -O
-dcore-lint
-dno-debug-output + -O2
-DDEBUG + -O
-DDEBUG
-dcore-lint
-dno-debug-output + -O + -O + ## Ways ===================================== hadrian/hadrian.cabal ===================================== @@ -96,6 +96,7 @@ executable hadrian , Settings.Flavours.Quick , Settings.Flavours.QuickCross , Settings.Flavours.Quickest + , Settings.Flavours.Validate , Settings.Packages , Settings.Warnings , Stage ===================================== hadrian/src/Hadrian/Utilities.hs ===================================== @@ -37,7 +37,6 @@ import Control.Monad.Extra import Data.Char import Data.Dynamic (Dynamic, fromDynamic, toDyn) import Data.HashMap.Strict (HashMap) -import Data.List (isPrefixOf) import Data.List.Extra import Data.Maybe import Data.Typeable (TypeRep, typeOf) ===================================== hadrian/src/Settings.hs ===================================== @@ -17,6 +17,7 @@ import Settings.Flavours.Profiled import Settings.Flavours.Quick import Settings.Flavours.Quickest import Settings.Flavours.QuickCross +import Settings.Flavours.Validate getArgs :: Args getArgs = expr flavour >>= args @@ -36,7 +37,7 @@ hadrianFlavours :: [Flavour] hadrianFlavours = [ defaultFlavour, developmentFlavour Stage1, developmentFlavour Stage2 , performanceFlavour, profiledFlavour, quickFlavour, quickestFlavour - , quickCrossFlavour ] + , quickCrossFlavour, validateFlavour, slowValidateFlavour ] flavour :: Action Flavour flavour = do ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -0,0 +1,46 @@ +module Settings.Flavours.Validate (validateFlavour, slowValidateFlavour) where + +import Expression +import Flavour +import Oracles.Flag +import {-# SOURCE #-} Settings.Default + +-- Please update doc/flavours.md when changing this file. +validateFlavour :: Flavour +validateFlavour = werror $ defaultFlavour + { name = "validate" + , args = defaultBuilderArgs <> validateArgs <> defaultPackageArgs + , libraryWays = mconcat [ pure [vanilla] + , notStage0 ? platformSupportsSharedLibs ? pure [dynamic] + ] + , rtsWays = mconcat [ pure [vanilla, threaded, debug, logging, threadedDebug, threadedLogging] + , notStage0 ? platformSupportsSharedLibs ? pure + [ dynamic, threadedDynamic, debugDynamic, threadedDebugDynamic + , loggingDynamic, threadedLoggingDynamic + ] + ] + } + +validateArgs :: Args +validateArgs = sourceArgs SourceArgs + { hsDefault = mconcat [ stage0 ? pure ["-O0", "-H64m"] + -- See #11487 + , notStage0 ? arg "-fllvm-fill-undef-with-garbage" + ] + , hsLibrary = pure ["-O", "-dcore-lint", "-dno-debug-output"] + , hsCompiler = mconcat [ stage0 ? pure ["-O2", "-DDEBUG"] + , notStage0 ? pure ["-O", "-dcore-lint", "-dno-debug-output"] + ] + , hsGhc = pure ["-O"] } + +slowValidateFlavour :: Flavour +slowValidateFlavour = werror $ validateFlavour + { name = "slow-validate" + , args = defaultBuilderArgs <> slowValidateArgs <> defaultPackageArgs + } + +slowValidateArgs :: Args +slowValidateArgs = + mconcat [ validateArgs + , notStage0 ? arg "-DDEBUG" + ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/60a06ed669f0982c166bfac75d64277ed075268f...7d2f14789fa77312f52dff429dc56b053a6cfd2f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/60a06ed669f0982c166bfac75d64277ed075268f...7d2f14789fa77312f52dff429dc56b053a6cfd2f You're receiving 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 Jul 11 20:04:57 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 16:04:57 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] 2 commits: Backport CI infrastructure rework Message-ID: <5f0a1b69d5838_80b3f846a0d2e3c26729a3@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: c1b75180 by Ben Gamari at 2020-07-11T16:04:46-04:00 Backport CI infrastructure rework - - - - - 0737947f by Ben Gamari at 2020-07-11T16:04:46-04:00 hadrian: Add `validate` and `slow validate` flavours (cherry picked from commit 9a2798e139e3d20183b59bb5a66012db495c66c7) - - - - - 14 changed files: - .gitlab-ci.yml - + .gitlab/ci.sh - − .gitlab/darwin-init.sh - .gitlab/linters/check-makefiles.py - + .gitlab/linters/check-version-number.sh - .gitlab/linters/linter.py - + .gitlab/test-metrics.sh - − .gitlab/win32-init.sh - + hadrian/ci.project - hadrian/doc/flavours.md - hadrian/hadrian.cabal - hadrian/src/Hadrian/Utilities.hs - hadrian/src/Settings.hs - + hadrian/src/Settings/Flavours/Validate.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,59 +2,45 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a + DOCKER_REV: 6223fe0b5942f4fa35bdec92c74566cf195bfb42 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/win32-init.sh. + # .gitlab/ci.sh. WINDOWS_TOOLCHAIN_VERSION: 1 -before_script: - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + # Disable shallow clones; they break our linting rules + GIT_DEPTH: 0 + + # Overridden by individual jobs + CONFIGURE_ARGS: "" + + GIT_SUBMODULE_STRATEGY: "recursive" stages: - - lint # Source linting - - build # A quick smoke-test to weed out broken commits - - full-build # Build all the things - - cleanup # See Note [Cleanup on Windows] - - packaging # Source distribution, etc. - - hackage # head.hackage testing - - deploy # push documentation - -.only-default: &only-default - rules: - - if: $CI_MERGE_REQUEST_ID - - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "master"' - - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - - if: '$CI_PIPELINE_SOURCE == "web"' + - lint # Source linting + - quick-build # A very quick smoke-test to weed out broken commits + - build # A quick smoke-test to weed out broken commits + - full-build # Build all the things + - cleanup # See Note [Cleanup after the shell executor] + - packaging # Source distribution, etc. + - testing # head.hackage correctness and compiler performance testing + - deploy # push documentation workflow: - # N.B. Don't run on wip/ branches, instead on run on merge requests. + # N.B.Don't run on wip/ branches, instead on run on merge requests. rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' + - if: '$CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' -############################################################ -# Runner Tags -############################################################ -# -# * x86_64-linux: Any Docker-capable x86_64 Linux machine -# * aarch64-linux: Any Docker-capable AArch64 Linux machine -# * x86_64-windows: A x86_64 Windows machine -# * lint: Any Docker-capable x86_64 Linux machine; distinct from -# x86_64-linux to ensure low-latency availability. -# - .nightly: &nightly rules: - if: $NIGHTLY + artifacts: + when: always + expire_in: 8 weeks .release: &release variables: @@ -66,53 +52,105 @@ workflow: rules: - if: '$RELEASE == "yes"' +############################################################ +# Runner Tags +############################################################ +# +# * x86_64-linux: Any Docker-capable x86_64 Linux machine +# * aarch64-linux: Any Docker-capable AArch64 Linux machine +# * x86_64-windows: A x86_64 Windows machine +# * lint: Any Docker-capable x86_64 Linux machine; distinct from +# x86_64-linux to ensure low-latency availability. +# + ############################################################ # Linting ############################################################ ghc-linters: - allow_failure: true stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" - - "echo Merge base $base" + - "echo Linting changes between $base..$CI_COMMIT_SHA" # - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA) - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA) - - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA - - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA + - .gitlab/linters/check-makefiles.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-cpp.py commits $base $CI_COMMIT_SHA + - .gitlab/linters/check-version-number.sh + - python3 utils/checkUniques/check-uniques.py . dependencies: [] tags: - lint rules: - if: $CI_MERGE_REQUEST_ID +# Run mypy Python typechecker on linter scripts. +lint-linters: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy .gitlab/linters/*.py + dependencies: [] + tags: + - lint + +# Check that .T files all parse by listing broken tests. +lint-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + script: + - make -Ctestsuite list_broken TEST_HC=ghc + dependencies: [] + tags: + - lint + +# Run mypy Python typechecker on testsuite driver +.typecheck-testsuite: + stage: lint + image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" + script: + - mypy testsuite/driver/runtests.py + dependencies: [] + tags: + - lint + # We allow the submodule checker to fail when run on merge requests (to -# accomodate, e.g., haddock changes not yet upstream) but not on `master` or +# accommodate, e.g., haddock changes not yet upstream) but not on `master` or # Marge jobs. .lint-submods: stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA) + - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" + - "echo Linting submodule changes between $base..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $base..$CI_COMMIT_SHA) dependencies: [] tags: - lint lint-submods: extends: .lint-submods + # Allow failure on merge requests since any necessary submodule patches may + # not be upstreamed yet. rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/' allow_failure: false - allow_failure: true -lint-submods-mr: +lint-submods-branch: extends: .lint-submods - allow_failure: true + script: + - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" + - git submodule foreach git remote update + - submodchecker . $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA) rules: - - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' .lint-changelogs: stage: lint @@ -125,6 +163,7 @@ lint-submods-mr: lint-changelogs: extends: .lint-changelogs + # Allow failure since this isn't a final release. allow_failure: true rules: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' @@ -140,71 +179,183 @@ lint-release-changelogs: ############################################################ .validate-hadrian: - <<: *only-default - allow_failure: true + variables: + FLAVOUR: "validate" script: - - cabal update - - git clean -xdf && git submodule foreach git clean -xdf - - bash .circleci/prepare-system.sh - - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi - - ./boot - - ./configure $CONFIGURE_ARGS - - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian cache: key: hadrian paths: - cabal-cache artifacts: - when: always + reports: + junit: junit.xml + expire_in: 2 week paths: - ghc.tar.xz + - junit.xml -validate-x86_64-linux-deb8-hadrian: +.validate-linux-hadrian: extends: .validate-hadrian - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + variables: + TEST_ENV: "x86_64-linux-deb9-hadrian" before_script: # workaround for docker permissions - sudo chown ghc:ghc -R . - - python3 .gitlab/fix-submodules.py - git submodule sync --recursive - git submodule update --init --recursive - git checkout .gitmodules - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + after_script: + - .gitlab/ci.sh clean tags: - x86_64-linux +validate-x86_64-linux-deb9-hadrian: + extends: .validate-linux-hadrian + stage: build + +validate-x86_64-linux-deb9-unreg-hadrian: + extends: .validate-linux-hadrian + stage: full-build + variables: + CONFIGURE_ARGS: --enable-unregisterised + TEST_ENV: "x86_64-linux-deb9-unreg-hadrian" + +.hadrian-ghc-in-ghci: + stage: quick-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + variables: + GHC_FLAGS: -Werror + tags: + - x86_64-linux + script: + - cabal update + - cd hadrian; cabal new-build --project-file=ci.project; cd .. + - git clean -xdf && git submodule foreach git clean -xdf + - .gitlab/ci.sh setup + - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi + - ./boot + - ./configure $CONFIGURE_ARGS + # 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," + cache: + key: hadrian-ghci + paths: + - cabal-cache ############################################################ # Validation via Pipelines (make) ############################################################ .validate: - <<: *only-default variables: TEST_TYPE: test - before_script: - - git clean -xdf && git submodule foreach git clean -xdf + MAKE_ARGS: "-Werror" script: - - ./boot - - ./configure $CONFIGURE_ARGS - - | - THREADS=`mk/detect-cpu-count.sh` - make V=0 -j$THREADS WERROR=-Werror - - | - make binary-dist TAR_COMP_OPTS="-1" - - | - THREADS=`mk/detect-cpu-count.sh` - make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_make + - .gitlab/ci.sh test_make dependencies: [] artifacts: reports: junit: junit.xml expire_in: 2 week paths: - - ghc-*.tar.xz + - $BIN_DIST_PREP_TAR_COMP - junit.xml + - performance-metrics.tsv + +################################# +# x86_64-freebsd +################################# + +.build-x86_64-freebsd: + extends: .validate + tags: + - x86_64-freebsd + allow_failure: true + variables: + # N.B. we use iconv from ports as I see linker errors when we attempt + # to use the "native" iconv embedded in libc as suggested by the + # porting guide [1]. + # [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + GHC_VERSION: 8.10.1 + CABAL_INSTALL_VERSION: 3.2.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd" + BUILD_FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Conditional due to lack of builder capacity +validate-x86_64-freebsd: + extends: .build-x86_64-freebsd + stage: full-build + rules: + - if: '$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/' + +nightly-x86_64-freebsd: + <<: *nightly + extends: .build-x86_64-freebsd + stage: full-build + +release-x86_64-freebsd: + <<: *release + extends: .build-x86_64-freebsd + stage: full-build + +.build-x86_64-freebsd-hadrian: + extends: .validate-hadrian + stage: full-build + tags: + - x86_64-freebsd + allow_failure: true + variables: + CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" + HADRIAN_ARGS: "--docs=no-sphinx" + GHC_VERSION: 8.6.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + TEST_ENV: "x86_64-freebsd-hadrian" + FLAVOUR: "validate" + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + cache: + key: "freebsd-$GHC_VERSION" + paths: + - cabal-cache + - toolchain + +# Disabled due to lack of builder capacity +.validate-x86_64-freebsd-hadrian: + extends: .build-x86_64-freebsd-hadrian + stage: full-build ################################# # x86_64-darwin @@ -216,54 +367,71 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: "8.8.3" - CABAL_INSTALL_VERSION: 2.4.1.0 - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz" + GHC_VERSION: 8.8.3 + CABAL_INSTALL_VERSION: 3.0.0.0 + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-apple-darwin.tar.xz" MACOSX_DEPLOYMENT_TARGET: "10.7" # Only Sierra and onwards supports clock_gettime. See #12858 ac_cv_func_clock_gettime: "no" LANG: "en_US.UTF-8" - CONFIGURE_ARGS: --with-intree-gmp + CONFIGURE_ARGS: "--with-intree-gmp" TEST_ENV: "x86_64-darwin" - before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - - bash .gitlab/darwin-init.sh - - PATH="`pwd`/toolchain/bin:$PATH" + BUILD_FLAVOUR: "perf" after_script: - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean artifacts: when: always expire_in: 2 week cache: - key: darwin + key: "darwin-$GHC_VERSION" paths: - cabal-cache - toolchain +# Disabled because of OS X CI capacity +.validate-x86_64-darwin-hadrian: + stage: full-build + tags: + - x86_64-darwin + variables: + GHC_VERSION: 8.8.3 + MACOSX_DEPLOYMENT_TARGET: "10.7" + ac_cv_func_clock_gettime: "no" + LANG: "en_US.UTF-8" + CONFIGURE_ARGS: --with-intree-gmp + TEST_ENV: "x86_64-darwin-hadrian" + FLAVOUR: "validate" + script: + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - .gitlab/ci.sh build_hadrian + - .gitlab/ci.sh test_hadrian + after_script: + - cp -Rf $HOME/.cabal cabal-cache + - .gitlab/ci.sh clean + artifacts: + when: always + expire_in: 2 week + reports: + junit: junit.xml + paths: + - ghc.tar.xz + - junit.xml + .validate-linux: extends: .validate tags: - x86_64-linux + variables: + BUILD_FLAVOUR: "perf" before_script: - - git clean -xdf && git submodule foreach git clean -xdf - - python3 .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" # Build hyperlinked sources for documentation when building releases - | if [[ -n "$CI_COMMIT_TAG" ]]; then - echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk + HADDOCK_HYPERLINKED_SOURCES=1 fi - - bash .circleci/prepare-system.sh # workaround for docker permissions - sudo chown ghc:ghc -R . after_script: @@ -285,9 +453,7 @@ validate-x86_64-darwin: allow_failure: true variables: TEST_ENV: "aarch64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz" - # Inexplicably makeindex fails - BUILD_SPHINX_PDF: "NO" + BIN_DIST_PREP_TAR_COMP: "ghc-aarch64-linux-deb9.tar.xz" cache: key: linux-aarch64-deb9 tags: @@ -302,8 +468,41 @@ validate-aarch64-linux-deb9: nightly-aarch64-linux-deb9: <<: *nightly extends: .build-aarch64-linux-deb9 + variables: + TEST_TYPE: slowtest + +################################# +# armv7-linux-deb9 +################################# + +.build-armv7-linux-deb9: + extends: .validate-linux + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb9:$DOCKER_REV" + # Due to linker issues + allow_failure: true + variables: + TEST_ENV: "armv7-linux-deb9" + BIN_DIST_PREP_TAR_COMP: "ghc-armv7-linux-deb9.tar.xz" + CONFIGURE_ARGS: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" + # N.B. We disable ld.lld explicitly here because it appears to fail + # non-deterministically on ARMv7. See #18280. + LD: "ld.gold" + GccUseLdOpt: "-fuse-ld=gold" + cache: + key: linux-armv7-deb9 + tags: + - armv7-linux + +validate-armv7-linux-deb9: + extends: .build-armv7-linux-deb9 artifacts: - expire_in: 2 year + when: always + expire_in: 2 week + +nightly-armv7-linux-deb9: + <<: *nightly + extends: .build-armv7-linux-deb9 variables: TEST_TYPE: slowtest @@ -317,7 +516,7 @@ nightly-aarch64-linux-deb9: image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "i386-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-i386-deb9-linux.tar.xz" cache: key: linux-i386-deb9 @@ -332,23 +531,6 @@ nightly-i386-linux-deb9: extends: .build-i386-linux-deb9 variables: TEST_TYPE: slowtest - artifacts: - when: always - expire_in: 2 week - -################################# -# x86_64-linux-deb10 -################################# - -.build-x86_64-linux-deb10: - extends: .validate-linux - stage: full-build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - variables: - TEST_ENV: "x86_64-linux-deb10" - BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" - cache: - key: linux-x86_64-deb10 ################################# # x86_64-linux-deb9 @@ -356,40 +538,62 @@ nightly-i386-linux-deb9: .build-x86_64-linux-deb9: extends: .validate-linux - stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb9-linux.tar.xz" cache: key: linux-x86_64-deb9 -validate-x86_64-linux-deb9: +# Disabled to reduce CI load +.validate-x86_64-linux-deb9: extends: .build-x86_64-linux-deb9 + stage: full-build artifacts: when: always expire_in: 2 week +release-x86_64-linux-deb9: + <<: *release + extends: .build-x86_64-linux-deb9 + stage: full-build + nightly-x86_64-linux-deb9: <<: *nightly extends: .build-x86_64-linux-deb9 - artifacts: - expire_in: 2 year + stage: full-build variables: TEST_TYPE: slowtest # N.B. Has DEBUG assertions enabled in stage2 validate-x86_64-linux-deb9-debug: extends: .build-x86_64-linux-deb9 - stage: build + stage: full-build variables: BUILD_FLAVOUR: validate + # Ensure that stage2 also has DEBUG enabled + ValidateSpeed: SLOW + # Override validate flavour default; see #16890. + BUILD_SPHINX_PDF: "YES" + TEST_TYPE: slowtest TEST_ENV: "x86_64-linux-deb9-debug" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-debug.tar.xz" + artifacts: + when: always + expire_in: 2 week -validate-x86_64-linux-deb9-llvm: +# Disabled to alleviate CI load +.validate-x86_64-linux-deb9-llvm: + extends: .build-x86_64-linux-deb9 + stage: full-build + variables: + BUILD_FLAVOUR: perf-llvm + TEST_ENV: "x86_64-linux-deb9-llvm" + +nightly-x86_64-linux-deb9-llvm: + <<: *nightly extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: BUILD_FLAVOUR: perf-llvm TEST_ENV: "x86_64-linux-deb9-llvm" @@ -397,11 +601,11 @@ validate-x86_64-linux-deb9-llvm: validate-x86_64-linux-deb9-integer-simple: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: + BUILD_FLAVOUR: validate INTEGER_LIBRARY: integer-simple - TEST_ENV: "x86_64-linux-deb9-integer-simple" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz" + TEST_ENV: "x86_64-linux-deb9-integer-simple-validate" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-integer-simple.tar.xz" nightly-x86_64-linux-deb9-integer-simple: <<: *nightly @@ -411,185 +615,205 @@ nightly-x86_64-linux-deb9-integer-simple: INTEGER_LIBRARY: integer-simple TEST_ENV: "x86_64-linux-deb9-integer-simple" TEST_TYPE: slowtest - artifacts: - expire_in: 2 year -validate-x86_64-linux-deb9-unreg: +validate-x86_64-linux-deb9-dwarf: extends: .build-x86_64-linux-deb9 stage: full-build - allow_failure: true variables: - CONFIGURE_ARGS: --enable-unregisterised - TEST_ENV: "x86_64-linux-deb9-unreg" + CONFIGURE_ARGS: "--enable-dwarf-unwind" + BUILD_FLAVOUR: dwarf + TEST_ENV: "x86_64-linux-deb9-dwarf" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb9-linux-dwarf.tar.xz" + +################################# +# x86_64-linux-deb10 +################################# -release-x86_64-linux-deb9-dwarf: +.build-x86_64-linux-deb10: extends: .validate-linux - stage: build - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" - allow_failure: true + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb9" - artifacts: - when: always - expire_in: 2 week + TEST_ENV: "x86_64-linux-deb10" + BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" cache: - key: linux-x86_64-deb9 + key: linux-x86_64-deb10 +# Disabled to alleviate CI load +.validate-x86_64-linux-deb10: + extends: .build-x86_64-linux-deb10 + stage: full-build -release-x86_64-linux-deb10-dwarf: - <<: *release +nightly-x86_64-linux-deb10: + <<: *nightly extends: .build-x86_64-linux-deb10 variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-deb10-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb10-linux-dwarf.tar.xz" + TEST_TYPE: slowtest + +release-x86_64-linux-deb10: + <<: *release + extends: .build-x86_64-linux-deb10 ################################# # x86_64-linux-deb8 ################################# -release-x86_64-linux-deb8: - <<: *release +.build-x86_64-linux-deb8: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV" + # Due to #18298. + allow_failure: true variables: TEST_ENV: "x86_64-linux-deb8" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz" - # Disable sphinx PDF output as our Debian image doesn't have the requisite packages + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb8-linux.tar.xz" + # Debian 8's Sphinx is too old to support the table directive's :widths: + # option: https://sourceforge.net/p/docutils/patches/120/ + BUILD_SPHINX_HTML: "NO" + BUILD_SPHINX_INFO: "NO" BUILD_SPHINX_PDF: "NO" + BUILD_SPHINX_MAN: "NO" cache: key: linux-x86_64-deb8 + +release-x86_64-linux-deb8: + <<: *release + extends: .build-x86_64-linux-deb8 + +################################# +# x86_64-linux-alpine +################################# + +.build-x86_64-linux-alpine-hadrian: + extends: .validate-linux-hadrian + stage: full-build + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine:$DOCKER_REV" + # There are currently a few failing tests + allow_failure: true + variables: + TEST_ENV: "x86_64-linux-alpine" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-alpine-linux.tar.xz" + # Can't use ld.gold due to #13958. + CONFIGURE_ARGS: "--disable-ld-override" + HADRIAN_ARGS: "--docs=no-sphinx" + # encoding004 due to lack of locale support + # T10458 due to fact that dynamic linker tries to reload libAS + BROKEN_TESTS: "encoding004 T10458" + cache: + key: linux-x86_64-alpine artifacts: when: always expire_in: 2 week +release-x86_64-linux-alpine: + <<: *release + extends: .build-x86_64-linux-alpine-hadrian + +nightly-x86_64-linux-alpine: + <<: *nightly + extends: .build-x86_64-linux-alpine-hadrian + ################################# # x86_64-linux-centos7 ################################# -release-x86_64-linux-centos7: - <<: *release +.build-x86_64-linux-centos7: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" variables: - # For the testsuite - LANG: "en_US.UTF-8" # The sphinx release shipped with Centos 7 fails to build out documentation BUILD_SPHINX_HTML: "NO" BUILD_SPHINX_PDF: "NO" TEST_ENV: "x86_64-linux-centos7" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-centos7-linux.tar.xz" - allow_failure: true + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-centos7-linux.tar.xz" + # CentOS seems to default to ascii + LANG: "en_US.UTF-8" cache: key: linux-x86_64-centos7 - artifacts: - when: always - expire_in: 2 week + +release-x86_64-linux-centos7: + <<: *release + extends: .build-x86_64-linux-centos7 ################################# # x86_64-linux-fedora27 ################################# -.build-x86_64-linux-fedora27: +validate-x86_64-linux-fedora27: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-fedora27" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: key: linux-x86_64-fedora27 - -validate-x86_64-linux-fedora27: - extends: .build-x86_64-linux-fedora27 artifacts: when: always # These are used for head.hackage jobs therefore we keep them around for # longer. expire_in: 8 week -release-x86_64-linux-fedora27: - <<: *release - extends: .build-x86_64-linux-fedora27 - -release-x86_64-linux-fedora27-dwarf: - <<: *release - extends: .build-x86_64-linux-fedora27 - variables: - CONFIGURE_ARGS: "--enable-dwarf-unwind" - BUILD_FLAVOUR: dwarf - TEST_ENV: "x86_64-linux-fedora27-dwarf" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux-dwarf.tar.xz" - ############################################################ # Validation via Pipelines (Windows) ############################################################ .build-windows: - <<: *only-default + # For the reasons given in #17777 this build isn't reliable. + allow_failure: true before_script: - git clean -xdf - - git submodule foreach git clean -xdf - # Use a local temporary directory to ensure that concurrent builds don't - # interfere with one another - - | - mkdir tmp - set TMP=%cd%\tmp - set TEMP=%cd%\tmp - - - set PATH=C:\msys64\usr\bin;%PATH% - - python .gitlab/fix-submodules.py - - git submodule sync --recursive - - git submodule update --init --recursive - - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" - - bash .gitlab/win32-init.sh + # Setup toolchain + - bash .gitlab/ci.sh setup after_script: - - rd /s /q tmp - - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache - - bash -c 'make clean || true' + - | + Copy-Item -Recurse -Path $Env:APPDATA\cabal -Destination cabal-cache + - bash .gitlab/ci.sh clean dependencies: [] variables: - FORCE_SYMLINKS: 1 + #FORCE_SYMLINKS: 1 LANG: "en_US.UTF-8" SPHINXBUILD: "/mingw64/bin/sphinx-build.exe" + CABAL_INSTALL_VERSION: 3.0.0.0 + GHC_VERSION: "8.8.3" cache: paths: - cabal-cache - - ghc-8.6.2 + - toolchain - ghc-tarballs .build-windows-hadrian: extends: .build-windows stage: full-build - allow_failure: true variables: - GHC_VERSION: "8.8.3" + FLAVOUR: "validate" + # skipping perf tests for now since we build a quick-flavoured GHC, + # which might result in some broken perf tests? + HADRIAN_ARGS: "--docs=no-sphinx --skip-perf" + script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex' - - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist" - - mv _build/bindist/ghc*.tar.xz ghc.tar.xz - # FIXME: Testsuite disabled due to #16156. - # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_hadrian + - bash .gitlab/ci.sh test_hadrian tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: + reports: + junit: junit.xml + expire_in: 2 week when: always paths: - ghc.tar.xz + - junit.xml validate-x86_64-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW64 + TEST_ENV: "x86_64-windows-hadrian" cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" @@ -598,86 +822,94 @@ nightly-i386-windows-hadrian: extends: .build-windows-hadrian variables: MSYSTEM: MINGW32 + TEST_ENV: "i386-windows-hadrian" cache: key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" .build-windows-make: extends: .build-windows stage: full-build - # due to #16084 - allow_failure: true variables: - BUILD_FLAVOUR: "UNSET" - GHC_VERSION: "8.8.3" - BUILD_PROF_LIBS: "YES" - BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz" + BUILD_FLAVOUR: "quick" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-mingw32.tar.xz" script: - - | - python boot - bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS' - - bash -c "echo \"include mk/flavours/${BUILD_FLAVOUR}.mk\" > mk/build.mk" - - bash -c "echo \"GhcLibHcOpts+=-haddock\" >> mk/build.mk" - - bash -c "echo \"BUILD_PROF_LIBS = $BUILD_PROF_LIBS\" >> mk/build.mk" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`" - - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1" - - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml' + - bash .gitlab/ci.sh configure + - bash .gitlab/ci.sh build_make + - bash .gitlab/ci.sh test_make tags: - - x86_64-windows + - new-x86_64-windows + - test artifacts: when: always expire_in: 2 week reports: junit: junit.xml paths: - - ghc-*.tar.xz + # N.B. variable interpolation apparently doesn't work on Windows so + # this can't be $BIN_DIST_PREP_TAR_COMP + - "ghc-x86_64-mingw32.tar.xz" - junit.xml -validate-x86_64-windows: +.build-x86_64-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" - BUILD_FLAVOUR: "quick" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" + TEST_ENV: "x86_64-windows" cache: key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-x86_64-windows: + extends: .build-x86_64-windows-make + +nightly-x86_64-windows: + <<: *nightly + extends: .build-x86_64-windows-make + stage: full-build + variables: + BUILD_FLAVOUR: "validate" + # Normal Windows validate builds are profiled; that won't do for releases. release-x86_64-windows: <<: *release extends: validate-x86_64-windows variables: - MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 - GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" - -release-i386-windows: + # +release-x86_64-windows-integer-simple: <<: *release - extends: .build-windows-make + extends: validate-x86_64-windows variables: - MSYSTEM: MINGW32 + INTEGER_LIBRARY: integer-simple BUILD_FLAVOUR: "perf" - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - # Due to #15934 - BUILD_PROF_LIBS: "NO" - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows: - <<: *nightly + +.build-i386-windows-make: extends: .build-windows-make variables: MSYSTEM: MINGW32 - CONFIGURE_ARGS: "--target=i386-unknown-mingw32" - BUILD_FLAVOUR: "quick" # Due to #15934 BUILD_PROF_LIBS: "NO" + TEST_ENV: "i386-windows" + # Due to #17736 + allow_failure: true cache: key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" +validate-i386-windows: + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +release-i386-windows: + <<: *release + extends: .build-i386-windows-make + variables: + BUILD_FLAVOUR: "perf" + +nightly-i386-windows: + <<: *nightly + extends: .build-i386-windows-make + ############################################################ # Cleanup ############################################################ @@ -687,40 +919,24 @@ nightly-i386-windows: # # As noted in [1], gitlab-runner's shell executor doesn't clean up its working # directory after builds. Unfortunately, we are forced to use the shell executor -# on Windows. To avoid running out of disk space we add a stage at the end of -# the build to remove the \GitLabRunner\builds directory. Since we only run a -# single build at a time on Windows this should be safe. +# on Darwin. To avoid running out of disk space we add a stage at the end of +# the build to remove the /.../GitLabRunner/builds directory. Since we only run a +# single build at a time on Darwin this should be safe. +# +# We used to have a similar cleanup job on Windows as well however it ended up +# being quite fragile as we have multiple Windows builders yet there is no +# guarantee that the cleanup job is run on the same machine as the build itself +# was run. Consequently we were forced to instead handle cleanup with a separate +# cleanup cron job on Windows. # # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856 -# See Note [Cleanup after shell executor] -cleanup-windows: - <<: *only-default - stage: cleanup - tags: - - x86_64-windows - dependencies: [] - before_script: - - echo "Time to clean up" - script: - - echo "Let's go" - after_script: - - set "BUILD_DIR=%CI_PROJECT_DIR%" - - set "BUILD_DIR=%BUILD_DIR:/=\%" - - echo "Cleaning %BUILD_DIR%" - - cd \GitLabRunner - # This is way more complicated than it should be: - # See https://stackoverflow.com/questions/1965787 - - del %BUILD_DIR%\* /F /Q - - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p" - - exit /b 0 - # See Note [Cleanup after shell executor] cleanup-darwin: - <<: *only-default stage: cleanup tags: - x86_64-darwin + when: always dependencies: [] before_script: - echo "Time to clean up" @@ -737,19 +953,56 @@ cleanup-darwin: # Packaging ############################################################ +doc-tarball: + stage: packaging + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + dependencies: + - validate-x86_64-linux-deb9-debug + - validate-x86_64-windows + variables: + LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz" + WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz" + # Due to Windows allow_failure + allow_failure: true + artifacts: + paths: + - haddock.html.tar.xz + - libraries.html.tar.xz + - users_guide.html.tar.xz + - index.html + - "*.pdf" + script: + - | + if [ ! -f "$LINUX_BINDIST" ]; then + echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" + exit 1 + fi + if [ ! -f "$WINDOWS_BINDIST" ]; then + echo "Error: $WINDOWS_BINDIST does not exist. Did the 64-bit Windows job fail?" + exit 1 + fi + - rm -Rf docs + - bash -ex distrib/mkDocs/mkDocs $LINUX_BINDIST $WINDOWS_BINDIST + - ls -lh + - mv docs/*.tar.xz docs/index.html . + source-tarball: - <<: *release stage: packaging tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" dependencies: [] + rules: + - if: $CI_COMMIT_TAG + when: always artifacts: paths: - ghc-*.tar.xz - version script: - - mk/get-win32-tarballs.sh download all + - python3 mk/get-win32-tarballs.py download all - ./boot - ./configure - make sdist @@ -770,9 +1023,8 @@ source-tarball: # pipeline. .hackage: - <<: *only-default - stage: hackage - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + stage: testing + image: ghcci/x86_64-linux-deb9:0.2 tags: - x86_64-linux dependencies: [] @@ -781,6 +1033,10 @@ source-tarball: script: - bash .gitlab/start-head.hackage.sh +hackage: + extends: .hackage + when: manual + hackage-label: extends: .hackage rules: @@ -790,3 +1046,69 @@ nightly-hackage: <<: *nightly extends: .hackage +############################################################ +# Nofib testing +############################################################ + +perf-nofib: + stage: testing + dependencies: + - validate-x86_64-linux-deb9-dwarf + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + rules: + - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + tags: + - x86_64-linux + script: + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ghc-x86_64-deb9-linux-dwarf.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - cabal update; cabal install -w $BOOT_HC regex-compat + - export PATH=$root/bin:$PATH + - make -C nofib boot mode=fast -j$CPUS + - "make -C nofib EXTRA_RUNTEST_OPTS='-cachegrind +RTS -V0 -RTS' NoFibRuns=1 mode=fast -j$CPUS 2>&1 | tee nofib.log" + artifacts: + expire_in: 12 week + when: always + paths: + - nofib.log + +############################################################ +# Documentation deployment via GitLab Pages +############################################################ + +pages: + stage: deploy + dependencies: + - doc-tarball + image: ghcci/x86_64-linux-deb9:0.2 + # Due to Windows allow_failure + allow_failure: true + tags: + - x86_64-linux + script: + - mkdir -p public/doc + - tar -xf haddock.html.tar.xz -C public/doc + - tar -xf libraries.html.tar.xz -C public/doc + - tar -xf users_guide.html.tar.xz -C public/doc + - | + cat >public/index.html < + + + EOF + - cp -f index.html public/doc + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + artifacts: + paths: + - public ===================================== .gitlab/ci.sh ===================================== @@ -0,0 +1,461 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2230 + +# This is the primary driver of the GitLab CI infrastructure. + +set -e -o pipefail + +# Configuration: +hackage_index_state="@1579718451" + +# Colors +BLACK="0;30" +GRAY="1;30" +RED="0;31" +LT_RED="1;31" +BROWN="0;33" +LT_BROWN="1;33" +GREEN="0;32" +LT_GREEN="1;32" +BLUE="0;34" +LT_BLUE="1;34" +PURPLE="0;35" +LT_PURPLE="1;35" +CYAN="0;36" +LT_CYAN="1;36" +WHITE="1;37" +LT_GRAY="0;37" + +export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 + +# GitLab Pipelines log section delimiters +# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664 +start_section() { + name="$1" + echo -e "section_start:$(date +%s):$name\015\033[0K" +} + +end_section() { + name="$1" + echo -e "section_end:$(date +%s):$name\015\033[0K" +} + +echo_color() { + local color="$1" + local msg="$2" + echo -e "\033[${color}m${msg}\033[0m" +} + +error() { echo_color "${RED}" "$1"; } +warn() { echo_color "${LT_BROWN}" "$1"; } +info() { echo_color "${LT_BLUE}" "$1"; } + +fail() { error "error: $1"; exit 1; } + +function run() { + info "Running $*..." + "$@" || ( error "$* failed"; return 1; ) +} + +TOP="$(pwd)" + +function mingw_init() { + case "$MSYSTEM" in + MINGW32) + triple="i386-unknown-mingw32" + boot_triple="i386-unknown-mingw32" # triple of bootstrap GHC + ;; + MINGW64) + triple="x86_64-unknown-mingw32" + boot_triple="x86_64-unknown-mingw32" # triple of bootstrap GHC + ;; + *) + fail "win32-init: Unknown MSYSTEM $MSYSTEM" + ;; + esac + + # Bring mingw toolchain into PATH. + # This is extracted from /etc/profile since this script inexplicably fails to + # run under gitlab-runner. + # shellcheck disable=SC1091 + source /etc/msystem + MINGW_MOUNT_POINT="${MINGW_PREFIX}" + PATH="$MINGW_MOUNT_POINT/bin:$PATH" + + # We always use mingw64 Python to avoid path length issues like #17483. + export PYTHON="/mingw64/bin/python3" +} + +# This will contain GHC's local native toolchain +toolchain="$TOP/toolchain" +mkdir -p "$toolchain/bin" +PATH="$toolchain/bin:$PATH" + +export METRICS_FILE="$CI_PROJECT_DIR/performance-metrics.tsv" + +cores="$(mk/detect-cpu-count.sh)" + +# Use a local temporary directory to ensure that concurrent builds don't +# interfere with one another +mkdir -p "$TOP/tmp" +export TMP="$TOP/tmp" +export TEMP="$TOP/tmp" + +function darwin_setup() { + # It looks like we already have python2 here and just installing python3 + # does not work. + brew upgrade python + brew install ghc cabal-install ncurses gmp + + pip3 install sphinx + # PDF documentation disabled as MacTeX apparently doesn't include xelatex. + #brew cask install mactex +} + +function show_tool() { + local tool="$1" + info "$tool = ${!tool}" + ${!tool} --version +} + +function set_toolchain_paths() { + needs_toolchain=1 + case "$(uname)" in + Linux) needs_toolchain="" ;; + *) ;; + esac + + if [[ -n "$needs_toolchain" ]]; then + # These are populated by setup_toolchain + GHC="$toolchain/bin/ghc$exe" + CABAL="$toolchain/bin/cabal$exe" + HAPPY="$toolchain/bin/happy$exe" + ALEX="$toolchain/bin/alex$exe" + else + GHC="$(which ghc)" + CABAL="/usr/local/bin/cabal" + HAPPY="$HOME/.cabal/bin/happy" + ALEX="$HOME/.cabal/bin/alex" + fi + export GHC + export CABAL + export HAPPY + export ALEX +} + +# Extract GHC toolchain +function setup() { + if [ -d "$TOP/cabal-cache" ]; then + info "Extracting cabal cache..." + mkdir -p "$cabal_dir" + cp -Rf cabal-cache/* "$cabal_dir" + fi + + if [[ -n "$needs_toolchain" ]]; then + setup_toolchain + fi + case "$(uname)" in + Darwin) darwin_setup ;; + *) ;; + esac + + # Make sure that git works + git config user.email "ghc-ci at gitlab-haskell.org" + git config user.name "GHC GitLab CI" + + info "=====================================================" + info "Toolchain versions" + info "=====================================================" + show_tool GHC + show_tool CABAL + show_tool HAPPY + show_tool ALEX +} + +function fetch_ghc() { + local v="$GHC_VERSION" + if [[ -z "$v" ]]; then + fail "GHC_VERSION is not set" + fi + + if [ ! -e "$GHC" ]; then + start_section "fetch GHC" + url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple}.tar.xz" + info "Fetching GHC binary distribution from $url..." + curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution" + tar -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution" + case "$(uname)" in + MSYS_*|MINGW*) + cp -r "ghc-${GHC_VERSION}"/* "$toolchain" + ;; + *) + pushd "ghc-${GHC_VERSION}" + ./configure --prefix="$toolchain" + "$MAKE" install + popd + ;; + esac + rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz + end_section "fetch GHC" + fi + +} + +function fetch_cabal() { + local v="$CABAL_INSTALL_VERSION" + if [[ -z "$v" ]]; then + fail "CABAL_INSTALL_VERSION is not set" + fi + + if [ ! -e "$CABAL" ]; then + start_section "fetch GHC" + case "$(uname)" in + # N.B. Windows uses zip whereas all others use .tar.xz + MSYS_*|MINGW*) + case "$MSYSTEM" in + MINGW32) cabal_arch="i386" ;; + MINGW64) cabal_arch="x86_64" ;; + *) fail "unknown MSYSTEM $MSYSTEM" ;; + esac + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-unknown-mingw32.zip" + info "Fetching cabal binary distribution from $url..." + curl "$url" > "$TMP/cabal.zip" + unzip "$TMP/cabal.zip" + mv cabal.exe "$CABAL" + ;; + *) + local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/" + case "$(uname)" in + Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;; + FreeBSD) + #cabal_url="$base_url/cabal-install-$v-x86_64-portbld-freebsd.tar.xz" ;; + cabal_url="http://home.smart-cactus.org/~ben/ghc/cabal-install-3.0.0.0-x86_64-portbld-freebsd.tar.xz" ;; + *) fail "don't know where to fetch cabal-install for $(uname)" + esac + echo "Fetching cabal-install from $cabal_url" + curl "$cabal_url" > cabal.tar.xz + tar -xJf cabal.tar.xz + mv cabal "$toolchain/bin" + ;; + esac + end_section "fetch GHC" + fi +} + +# For non-Docker platforms we prepare the bootstrap toolchain +# here. For Docker platforms this is done in the Docker image +# build. +function setup_toolchain() { + fetch_ghc + fetch_cabal + cabal_install="$CABAL v2-install --index-state=$hackage_index_state --installdir=$toolchain/bin" + # Avoid symlinks on Windows + case "$(uname)" in + MSYS_*|MINGW*) cabal_install="$cabal_install --install-method=copy" ;; + *) ;; + esac + + if [ ! -e "$HAPPY" ]; then + info "Building happy..." + cabal update + $cabal_install happy + fi + + if [ ! -e "$ALEX" ]; then + info "Building alex..." + cabal update + $cabal_install alex + fi +} + +function cleanup_submodules() { + start_section "clean submodules" + info "Cleaning submodules..." + # On Windows submodules can inexplicably get into funky states where git + # believes that the submodule is initialized yet its associated repository + # is not valid. Avoid failing in this case with the following insanity. + git submodule sync --recursive || git submodule deinit --force --all + git submodule update --init --recursive + git submodule foreach git clean -xdf + end_section "clean submodules" +} + +function prepare_build_mk() { + if [[ -z "$BUILD_FLAVOUR" ]]; then fail "BUILD_FLAVOUR is not set"; fi + if [[ -z ${BUILD_SPHINX_HTML:-} ]]; then BUILD_SPHINX_HTML=YES; fi + if [[ -z ${BUILD_SPHINX_PDF:-} ]]; then BUILD_SPHINX_PDF=YES; fi + if [[ -z ${INTEGER_LIBRARY:-} ]]; then INTEGER_LIBRARY=integer-gmp; fi + + cat > mk/build.mk <> mk/build.mk + fi + + case "$(uname)" in + Darwin) echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk ;; + *) ;; + esac + + info "build.mk is:" + cat mk/build.mk +} + +function configure() { + start_section "booting" + run python3 boot + end_section "booting" + + local target_args="" + if [[ -n "$triple" ]]; then + target_args="--target=$triple" + fi + + start_section "configuring" + run ./configure \ + --enable-tarballs-autodownload \ + $target_args \ + $CONFIGURE_ARGS \ + GHC="$GHC" \ + HAPPY="$HAPPY" \ + ALEX="$ALEX" \ + || ( cat config.log; fail "configure failed" ) + end_section "configuring" +} + +function build_make() { + prepare_build_mk + if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then + fail "BIN_DIST_PREP_TAR_COMP is not set" + fi + + echo "include mk/flavours/${BUILD_FLAVOUR}.mk" > mk/build.mk + echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk + run "$MAKE" -j"$cores" $MAKE_ARGS + run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 + ls -lh "$BIN_DIST_PREP_TAR_COMP" +} + +function fetch_perf_notes() { + info "Fetching perf notes..." + "$TOP/.gitlab/test-metrics.sh" pull +} + +function push_perf_notes() { + info "Pushing perf notes..." + "$TOP/.gitlab/test-metrics.sh" push +} + +function test_make() { + run "$MAKE" test_bindist TEST_PREP=YES + run "$MAKE" V=0 test \ + THREADS="$cores" +} + +function build_hadrian() { + if [ -z "$FLAVOUR" ]; then + fail "FLAVOUR not set" + fi + + run_hadrian binary-dist + + mv _build/bindist/ghc*.tar.xz ghc.tar.xz +} + +function test_hadrian() { + cd _build/bindist/ghc-*/ + run ./configure --prefix="$TOP"/_build/install + run "$MAKE" install + cd ../../../ + + run_hadrian \ + test \ + --test-compiler="$TOP"/_build/install/bin/ghc +} + +function clean() { + rm -R tmp + run "$MAKE" --quiet clean || true + run rm -Rf _build +} + +function run_hadrian() { + run hadrian/build.cabal.sh \ + --flavour="$FLAVOUR" \ + -j"$cores" \ + $HADRIAN_ARGS \ + $@ +} + +# A convenience function to allow debugging in the CI environment. +function shell() { + local cmd=$@ + if [ -z "$cmd" ]; then + cmd="bash -i" + fi + run $cmd +} + +# Determine Cabal data directory +case "$(uname)" in + MSYS_*|MINGW*) exe=".exe"; cabal_dir="$APPDATA/cabal" ;; + *) cabal_dir="$HOME/.cabal"; exe="" ;; +esac + +# Platform-specific environment initialization +MAKE="make" +case "$(uname)" in + MSYS_*|MINGW*) mingw_init ;; + Darwin) boot_triple="x86_64-apple-darwin" ;; + FreeBSD) + boot_triple="x86_64-portbld-freebsd" + MAKE="gmake" + ;; + Linux) ;; + *) fail "uname $(uname) is not supported" ;; +esac + +set_toolchain_paths + +case $1 in + setup) setup && cleanup_submodules ;; + configure) configure ;; + build_make) build_make ;; + test_make) + fetch_perf_notes + res=0 + test_make || res=$? + push_perf_notes + exit $res ;; + build_hadrian) build_hadrian ;; + # N.B. Always push notes, even if the build fails. This is okay to do as the + # testsuite driver doesn't record notes for tests that fail due to + # correctness. + test_hadrian) + fetch_perf_notes + res=0 + test_hadrian || res=$? + push_perf_notes + exit $res ;; + run_hadrian) run_hadrian $@ ;; + clean) clean ;; + shell) shell $@ ;; + *) fail "unknown mode $1" ;; +esac ===================================== .gitlab/darwin-init.sh deleted ===================================== @@ -1,41 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $HOME/.cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - mkdir -p tmp - cd tmp - ghc_tarball="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-x86_64-apple-darwin.tar.xz" - echo "Fetching GHC from $ghc_tarball" - curl $ghc_tarball | tar -xJ - cd ghc-$GHC_VERSION - ./configure --prefix=$toolchain - make install - cd ../.. - rm -Rf tmp -fi - -if [ ! -e $toolchain/bin/cabal ]; then - cabal_tarball="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL_VERSION/cabal-install-$CABAL_INSTALL_VERSION-x86_64-apple-darwin-sierra.tar.xz" - echo "Fetching cabal-install from $cabal_tarball" - curl $cabal_tarball | tar -xz - mv cabal $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal new-install happy --symlink-bindir=$toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal new-install alex --symlink-bindir=$toolchain/bin -fi - ===================================== .gitlab/linters/check-makefiles.py ===================================== @@ -1,5 +1,11 @@ #!/usr/bin/env python3 +""" +Linters for testsuite makefiles +""" + +from linter import run_linters, RegexpLinter + """ Warn for use of `--interactive` inside Makefiles (#11468). @@ -7,13 +13,21 @@ Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to forget one of those flags when adding a new test. """ +interactive_linter = \ + RegexpLinter(r'--interactive', + message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`." + ).add_path_filter(lambda path: path.name == 'Makefile') -from linter import run_linters, RegexpLinter +test_hc_quotes_linter = \ + RegexpLinter('\t\\$\\(TEST_HC\\)', + message = "Warning: $(TEST_HC) should be quoted in Makefiles.", + ).add_path_filter(lambda path: path.name == 'Makefile') linters = [ - RegexpLinter(r'--interactive', - message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`.") + interactive_linter, + test_hc_quotes_linter, ] if __name__ == '__main__': - run_linters(linters) #$, subdir='testsuite') + run_linters(linters, + subdir='testsuite') ===================================== .gitlab/linters/check-version-number.sh ===================================== @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +grep -E -q '\[[0-9]+\.[0-9]+\.[0-9]+\]' configure.ac || + ( echo "error: configure.ac: GHC version number must have three components."; exit 1 ) ===================================== .gitlab/linters/linter.py ===================================== @@ -7,10 +7,11 @@ import sys import re import textwrap import subprocess -from typing import List, Optional +from pathlib import Path +from typing import List, Optional, Callable, Sequence from collections import namedtuple -def lint_failure(file, line_no, line_content, message): +def lint_failure(file, line_no: int, line_content: str, message: str): """ Print a lint failure message. """ wrapper = textwrap.TextWrapper(initial_indent=' ', subsequent_indent=' ') @@ -29,7 +30,7 @@ def lint_failure(file, line_no, line_content, message): print(textwrap.dedent(msg)) -def get_changed_files(base_commit, head_commit, +def get_changed_files(base_commit: str, head_commit: str, subdir: str = '.'): """ Get the files changed by the given range of commits. """ cmd = ['git', 'diff', '--name-only', @@ -46,12 +47,21 @@ class Linter(object): """ def __init__(self): self.warnings = [] # type: List[Warning] + self.path_filters = [] # type: List[Callable[[Path], bool]] def add_warning(self, w: Warning): self.warnings.append(w) - def lint(self, path): - pass + def add_path_filter(self, f: Callable[[Path], bool]) -> "Linter": + self.path_filters.append(f) + return self + + def do_lint(self, path: Path): + if all(f(path) for f in self.path_filters): + self.lint(path) + + def lint(self, path: Path): + raise NotImplementedError class LineLinter(Linter): """ @@ -59,44 +69,55 @@ class LineLinter(Linter): the given line from a file and calls :func:`add_warning` for any lint issues found. """ - def lint(self, path): - if os.path.isfile(path): - with open(path, 'r') as f: + def lint(self, path: Path): + if path.is_file(): + with path.open('r') as f: for line_no, line in enumerate(f): self.lint_line(path, line_no+1, line) - def lint_line(self, path, line_no, line): - pass + def lint_line(self, path: Path, line_no: int, line: str): + raise NotImplementedError class RegexpLinter(LineLinter): """ A :class:`RegexpLinter` produces the given warning message for all lines matching the given regular expression. """ - def __init__(self, regex, message): + def __init__(self, regex: str, message: str): LineLinter.__init__(self) self.re = re.compile(regex) self.message = message - def lint_line(self, path, line_no, line): + def lint_line(self, path: Path, line_no: int, line: str): if self.re.search(line): w = Warning(path=path, line_no=line_no, line_content=line[:-1], message=self.message) self.add_warning(w) -def run_linters(linters: List[Linter], +def run_linters(linters: Sequence[Linter], subdir: str = '.') -> None: import argparse parser = argparse.ArgumentParser() - parser.add_argument('base', help='Base commit') - parser.add_argument('head', help='Head commit') + subparsers = parser.add_subparsers() + + subparser = subparsers.add_parser('commits', help='Lint a range of commits') + subparser.add_argument('base', help='Base commit') + subparser.add_argument('head', help='Head commit') + subparser.set_defaults(get_linted_files=lambda args: + get_changed_files(args.base, args.head, subdir)) + + subparser = subparsers.add_parser('files', help='Lint a range of commits') + subparser.add_argument('file', nargs='+', help='File to lint') + subparser.set_defaults(get_linted_files=lambda args: args.file) + args = parser.parse_args() - for path in get_changed_files(args.base, args.head, subdir): + linted_files = args.get_linted_files(args) + for path in linted_files: if path.startswith('.gitlab/linters'): continue for linter in linters: - linter.lint(path) + linter.do_lint(Path(path)) warnings = [warning for linter in linters ===================================== .gitlab/test-metrics.sh ===================================== @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +# vim: sw=2 et +set -euo pipefail + +NOTES_ORIGIN="https://gitlab.haskell.org/ghc/ghc-performance-notes.git" +NOTES_ORIGIN_PUSH="git at gitlab.haskell.org:ghc/ghc-performance-notes.git" +REF="perf" + +run() { + echo "$@" + $@ +} + +fail() { + echo "ERROR: $*" >&2 + exit 1 +} + +function pull() { + local ref="refs/notes/$REF" + run git fetch -f $NOTES_ORIGIN $ref:$ref + echo "perf notes ref $ref is $(git rev-parse $ref)" +} + +function setup_ssh() { + # Add gitlab as a known host. + # This can be generated with `ssh-keyscan -H gitlab.haskell.org` + mkdir -p ~/.ssh + echo "|1|cta91z3DoAGdpX2Epe9WF+sr+Rk=|1qlsbqiTTa8YsDyQBjVnzANFQ3Y= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDSzzl8mwY6ohtW6MftKaQfta8yTL8cTxtA7lcueo2mkPpwBBQ7FA6z3nFATx25QwdV7fa7DuNRDX57f/a/W7+wMhXZ6yyQr+gwr0h4vdZ8Nt4XNfNdkdGw4fZKRApWxyvfSkxjs/E9+G0o3eQLspxjVohBkmkcsowpFUI5Aazv/K6QIf1gKt+4iPvYcB/dBJ1yF1qmpayz4htrKyUC5l3GCBEwvMdAjIQ2bX8pyjTtqcJDLosAVzQ5wprkdgkL29MgJXEbM+B1d1log0hnX4AsbOlL7tWhTO1Je2hSuEeiVaDDPFUyCoGQRFDrisQU5lb8NrzuN3jpNc+PxOHbXHfaTppAoED/++UepvgtLF1zUM13cRk56YmpmABOa48W72VJuzLLm8DF+KBWBs6TDuVk3y9z/SS6zDS0VGkHotldopW2kpsjErJIdWVKIL3RP/Flay7mzl3l/izIMTHXXKMxV3/+XaBjG/gDOCld3JjORQXah2hvJfvXeNaePE1RKAMS63cj3XTE77fsYH7VmEdE34RTBDtsZR5WhEjdf29hjEcQDPf0vDphxRHr6IqUSwVcd7ps6nVoccTfaepJm62IIXDgOsc2piWl2xXNZJVtph6U+MzsPDSSbu1MTwalwgqpApcYK7ZzUjGHA7+NBhjjSuUZO6eHzwxjAn0FXZyrpQ==" >> ~/.ssh/known_hosts + echo "|1|uZkjsBS2bmdh7L/8zBquxJd/F20=|by/tpuDAPT6BpEXrDOiOv1/Zx/A= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA7ltOZyaULDgxE3Vw6RgQVp+OPKQi79ssUenbhdWy36" >> ~/.ssh/known_hosts + + # Setup ssh keys. + eval `ssh-agent` + echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJPR1vrZgeGTXmgJw2PsJfMjf22LcDnVVwt3l0rwTZ+8Q2J0bHaYxMRKBco1sON6LGcZepw0Hy76RQ87v057pTz18SXvnfE7U/B6v9qBk0ILJz+4BOX9sEhxu2XmScp/wMxkG9IoyruMlsxXzd1sz09o+rzzx24U2Rp27PRm08vG0oipve6BWLbYEqYrE4/nCufqOJmGd56fju7OTU0lTpEkGDEDWGMxutaX2CbTbDju7qy07Ld8BjSc9aHfvuQaslUbj3ex3EF8EXahURzGpHQn/UFFzVGMokFumiJCAagHQb7cj6jOkKseZLaysbA/mTBQsOzjWiRmkN23bQf1wF ben+ghc-ci at smart-cactus.org" > ~/.ssh/perf_rsa.pub + touch ~/.ssh/perf_rsa + chmod 0600 ~/.ssh/perf_rsa + echo "$PERF_NOTE_KEY" >> ~/.ssh/perf_rsa + ssh-add ~/.ssh/perf_rsa +} + +# Reset the git notes and append the metrics file to the notes, then push and return the result. +# This is favoured over a git notes merge as it avoids potential data loss/duplication from the merge strategy. +function reset_append_note_push { + pull || true + run git notes --ref=$REF append -F $METRICS_FILE HEAD + run git push $NOTES_ORIGIN_PUSH refs/notes/$REF +} + +function push() { + # Check that private key is available (Set on all GitLab protected branches). + if [ -z ${PERF_NOTE_KEY+"$PERF_NOTE_KEY"} ] + then + echo "Not pushing performance git notes: PERF_NOTE_KEY is not set." + exit 0 + fi + + # TEST_ENV must be set. + if [ -z ${TEST_ENV+"$TEST_ENV"} ] + then + fail "Not pushing performance git notes: TEST_ENV must be set." + fi + + # Assert that the METRICS_FILE exists and can be read. + if [ -z ${METRICS_FILE+"$METRICS_FILE"} ] + then + fail "\$METRICS_FILE not set." + fi + if ! [ -r $METRICS_FILE ] + then + fail "Metrics file not found: $METRICS_FILE" + fi + + setup_ssh + + # Push the metrics file as a git note. This may fail if another task pushes a note first. In that case + # the latest note is fetched and appended. + MAX_RETRY=20 + until reset_append_note_push || [ $MAX_RETRY -le 0 ] + do + ((MAX_RETRY--)) + echo "" + echo "Failed to push git notes. Fetching, appending, and retrying... $MAX_RETRY retries left." + done +} + +case $1 in + push) push ;; + pull) pull ;; + *) fail "Invalid mode $1" ;; +esac ===================================== .gitlab/win32-init.sh deleted ===================================== @@ -1,50 +0,0 @@ -#!/bin/bash - -set -e - -toolchain=`pwd`/toolchain -PATH="$toolchain/bin:/mingw64/bin:$PATH" - -if [ -d "`pwd`/cabal-cache" ]; then - cp -Rf cabal-cache $APPDATA/cabal -fi - -if [ ! -e $toolchain/bin/ghc ]; then - case $MSYSTEM in - MINGW32) - triple="i386-unknown-mingw32" - ;; - MINGW64) - triple="x86_64-unknown-mingw32" - ;; - *) - echo "win32-init: Unknown MSYSTEM $MSYSTEM" - exit 1 - ;; - esac - if [ -z "$GHC_TARBALL_URL" ]; then - GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" - fi - curl "$GHC_TARBALL_URL" | tar -xJ - mv ghc-$GHC_VERSION toolchain -fi - -if [ ! -e $toolchain/bin/cabal ]; then - url="https://downloads.haskell.org/~cabal/cabal-install-2.4.1.0/cabal-install-2.4.1.0-x86_64-unknown-mingw32.zip" - curl $url > /tmp/cabal.zip - unzip /tmp/cabal.zip - mv cabal.exe $toolchain/bin -fi - -if [ ! -e $toolchain/bin/happy ]; then - cabal update - cabal install happy - cp $APPDATA/cabal/bin/happy $toolchain/bin -fi - -if [ ! -e $toolchain/bin/alex ]; then - cabal update - cabal install alex - cp $APPDATA/cabal/bin/alex $toolchain/bin -fi - ===================================== hadrian/ci.project ===================================== @@ -0,0 +1,4 @@ +packages: ./ + +package hadrian + -- ghc-options: -Werror ===================================== hadrian/doc/flavours.md ===================================== @@ -110,6 +110,28 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH -O0
-DDEBUG + + validate + -O0
-H64m + -fllvm-fill-undef-with-garbage + + -O
-dcore-lint
-dno-debug-output + -O2
-DDEBUG + -O
-dcore-lint
-dno-debug-output + -O + -O + + + validate + -O0
-H64m + -fllvm-fill-undef-with-garbage + + -O
-dcore-lint
-dno-debug-output + -O2
-DDEBUG + -O
-DDEBUG
-dcore-lint
-dno-debug-output + -O + -O + ## Ways ===================================== hadrian/hadrian.cabal ===================================== @@ -96,6 +96,7 @@ executable hadrian , Settings.Flavours.Quick , Settings.Flavours.QuickCross , Settings.Flavours.Quickest + , Settings.Flavours.Validate , Settings.Packages , Settings.Warnings , Stage ===================================== hadrian/src/Hadrian/Utilities.hs ===================================== @@ -37,7 +37,6 @@ import Control.Monad.Extra import Data.Char import Data.Dynamic (Dynamic, fromDynamic, toDyn) import Data.HashMap.Strict (HashMap) -import Data.List (isPrefixOf) import Data.List.Extra import Data.Maybe import Data.Typeable (TypeRep, typeOf) ===================================== hadrian/src/Settings.hs ===================================== @@ -17,6 +17,7 @@ import Settings.Flavours.Profiled import Settings.Flavours.Quick import Settings.Flavours.Quickest import Settings.Flavours.QuickCross +import Settings.Flavours.Validate getArgs :: Args getArgs = expr flavour >>= args @@ -36,7 +37,7 @@ hadrianFlavours :: [Flavour] hadrianFlavours = [ defaultFlavour, developmentFlavour Stage1, developmentFlavour Stage2 , performanceFlavour, profiledFlavour, quickFlavour, quickestFlavour - , quickCrossFlavour ] + , quickCrossFlavour, validateFlavour, slowValidateFlavour ] flavour :: Action Flavour flavour = do ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -0,0 +1,46 @@ +module Settings.Flavours.Validate (validateFlavour, slowValidateFlavour) where + +import Expression +import Flavour +import Oracles.Flag +import {-# SOURCE #-} Settings.Default + +-- Please update doc/flavours.md when changing this file. +validateFlavour :: Flavour +validateFlavour = werror $ defaultFlavour + { name = "validate" + , args = defaultBuilderArgs <> validateArgs <> defaultPackageArgs + , libraryWays = mconcat [ pure [vanilla] + , notStage0 ? platformSupportsSharedLibs ? pure [dynamic] + ] + , rtsWays = mconcat [ pure [vanilla, threaded, debug, logging, threadedDebug, threadedLogging] + , notStage0 ? platformSupportsSharedLibs ? pure + [ dynamic, threadedDynamic, debugDynamic, threadedDebugDynamic + , loggingDynamic, threadedLoggingDynamic + ] + ] + } + +validateArgs :: Args +validateArgs = sourceArgs SourceArgs + { hsDefault = mconcat [ stage0 ? pure ["-O0", "-H64m"] + -- See #11487 + , notStage0 ? arg "-fllvm-fill-undef-with-garbage" + ] + , hsLibrary = pure ["-O", "-dcore-lint", "-dno-debug-output"] + , hsCompiler = mconcat [ stage0 ? pure ["-O2", "-DDEBUG"] + , notStage0 ? pure ["-O", "-dcore-lint", "-dno-debug-output"] + ] + , hsGhc = pure ["-O"] } + +slowValidateFlavour :: Flavour +slowValidateFlavour = werror $ validateFlavour + { name = "slow-validate" + , args = defaultBuilderArgs <> slowValidateArgs <> defaultPackageArgs + } + +slowValidateArgs :: Args +slowValidateArgs = + mconcat [ validateArgs + , notStage0 ? arg "-DDEBUG" + ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d2f14789fa77312f52dff429dc56b053a6cfd2f...0737947ff9e03b35d0d85724cdbe1d8d841aa3a1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d2f14789fa77312f52dff429dc56b053a6cfd2f...0737947ff9e03b35d0d85724cdbe1d8d841aa3a1 You're receiving 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 Jul 12 00:58:32 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 20:58:32 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] gitlab-ci: Make before_script PowerShell compatible Message-ID: <5f0a603851345_80b3f849c221f4026794a7@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 87608fe9 by Ben Gamari at 2020-07-11T20:57:58-04:00 gitlab-ci: Make before_script PowerShell compatible - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -571,6 +571,14 @@ release-x86_64-linux-fedora27-dwarf: allow_failure: true variables: GHC_VERSION: "8.8.3" + before_script: + - python3 .gitlab/fix-submodules.py + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + # N.B. Drop bash syntax on Windows since this is interpreted by + # PowerShell. + - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf" script: - | python boot View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/87608fe9da4d992ea1651f44422d9dbef9220234 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/87608fe9da4d992ea1651f44422d9dbef9220234 You're receiving 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 Jul 12 01:00:23 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 11 Jul 2020 21:00:23 -0400 Subject: [Git][ghc/ghc][wip/backports-8.8] gitlab-ci: Bootstrap with 8.8.4-rc1 on Windows Message-ID: <5f0a60a7d2dab_80b3f849c221f402679891@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC Commits: 9a24b411 by Ben Gamari at 2020-07-11T21:00:18-04:00 gitlab-ci: Bootstrap with 8.8.4-rc1 on Windows This avoids bugs in the `process` library during bootstrapping. - - - - - 2 changed files: - .gitlab-ci.yml - .gitlab/win32-init.sh Changes: ===================================== .gitlab-ci.yml ===================================== @@ -570,7 +570,16 @@ release-x86_64-linux-fedora27-dwarf: stage: full-build allow_failure: true variables: - GHC_VERSION: "8.8.3" + GHC_VERSION: "8.8.3.20200710" + GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" + before_script: + - python3 .gitlab/fix-submodules.py + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + # N.B. Drop bash syntax on Windows since this is interpreted by + # PowerShell. + - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf" script: - | python boot @@ -608,7 +617,8 @@ nightly-i386-windows-hadrian: allow_failure: true variables: BUILD_FLAVOUR: "UNSET" - GHC_VERSION: "8.8.3" + GHC_VERSION: "8.8.3.20200710" + GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_PROF_LIBS: "YES" BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz" script: @@ -647,6 +657,8 @@ release-x86_64-windows: extends: validate-x86_64-windows variables: MSYSTEM: MINGW64 + GHC_VERSION: 8.8.4-rc1 + GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" ===================================== .gitlab/win32-init.sh ===================================== @@ -22,7 +22,10 @@ if [ ! -e $toolchain/bin/ghc ]; then exit 1 ;; esac - curl https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz | tar -xJ + if [ -z "$GHC_TARBALL_URL" ]; then + GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" + fi + curl "$GHC_TARBALL_URL" | tar -xJ mv ghc-$GHC_VERSION toolchain fi View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9a24b411bd4bea69ab292eaa5857941caae2ed73 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9a24b411bd4bea69ab292eaa5857941caae2ed73 You're receiving 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 Jul 12 01:03:15 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 11 Jul 2020 21:03:15 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: add reproducer for #15630 Message-ID: <5f0a615331ede_80b3f8486b77e4826813b3@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6fa928b8 by Artem Pelenitsyn at 2020-07-11T21:03:12-04:00 add reproducer for #15630 - - - - - 90903043 by Andreas Klebinger at 2020-07-11T21:03:13-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - 30 changed files: - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Data/FastString/Env.hs - compiler/GHC/Data/Graph/Base.hs - compiler/GHC/Data/Graph/Color.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e22e1f1119a4e57e8e5ee7fab4da165c3436ac5a...909030436b629d3e0ced782f08104c285667702f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e22e1f1119a4e57e8e5ee7fab4da165c3436ac5a...909030436b629d3e0ced782f08104c285667702f You're receiving 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 Jul 12 06:53:25 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 12 Jul 2020 02:53:25 -0400 Subject: [Git][ghc/ghc][master] add reproducer for #15630 Message-ID: <5f0ab3652f4b9_80b3f8490174d382696541@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - 2 changed files: - + testsuite/tests/perf/compiler/T15630.hs - testsuite/tests/perf/compiler/all.T Changes: ===================================== testsuite/tests/perf/compiler/T15630.hs ===================================== @@ -0,0 +1,56 @@ +module T15630 where + +data IValue = IDefault + | IInt Int + | IBlob String + +(?) :: Applicative m => (IValue -> m a) -> IValue -> m (Maybe a) +(?) _ IDefault = pure Nothing +(?) p x = Just <$> p x + +getInt :: IValue -> Either () Int +getInt (IInt i) = Right i +getInt v = Left () + +getString :: IValue -> Either () String +getString (IBlob b) = Right $ b +getString v = Left () + +(<+>) :: Applicative m => (m (a -> b), [IValue]) -> (IValue -> m a) -> (m b, [IValue]) +(<+>) (f, (v:vs)) p = (f <*> (p v), vs) + +data TestStructure = TestStructure + { _param1 :: Int + , _param2 :: Maybe String + , _param3 :: Maybe Int + , _param4 :: Maybe String + , _param5 :: Maybe Int + , _param6 :: Maybe Int + , _param7 :: Maybe String + , _param8 :: Maybe String + , _param9 :: Maybe Int + , _param10 :: Maybe Int + , _param11 :: Maybe String + , _param12 :: Maybe String + , _param13 :: Maybe Int + , _param14 :: Maybe Int + , _param15 :: Maybe String + } + +getMenuItem :: [IValue] -> Either () TestStructure +getMenuItem vs = fst $ (pure TestStructure, vs) + <+> getInt + <+> (getString ?) + <+> (getInt ?) + <+> (getString ?) + <+> (getInt ?) + <+> (getInt ?) + <+> (getString ?) + <+> (getString ?) + <+> (getInt ?) + <+> (getInt ?) + <+> (getString ?) + <+> (getString ?) + <+> (getInt ?) + <+> (getInt ?) + <+> (getString ?) ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -346,6 +346,11 @@ test ('T15164', ], compile, ['-v0 -O']) +test('T15630', + [collect_compiler_stats() + ], + compile, + ['-O2']) # See https://gitlab.haskell.org/ghc/ghc/merge_requests/312#note_186960 test ('WWRec', View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de139cc496c0e0110e252a1208ae346f47f8061e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de139cc496c0e0110e252a1208ae346f47f8061e You're receiving 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 Jul 12 06:54:02 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 12 Jul 2020 02:54:02 -0400 Subject: [Git][ghc/ghc][master] Give Uniq[D]FM a phantom type for its key. Message-ID: <5f0ab38aaf3e6_80b3f848e5b865827036c5@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - 30 changed files: - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Data/FastString/Env.hs - compiler/GHC/Data/Graph/Base.hs - compiler/GHC/Data/Graph/Color.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4de6a7a5c6433ae8c4df8a9fa09fbd9f3bbd0bf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4de6a7a5c6433ae8c4df8a9fa09fbd9f3bbd0bf You're receiving 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 Jul 12 07:06:11 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sun, 12 Jul 2020 03:06:11 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 2 commits: Address Takenobu Tani's comments. Message-ID: <5f0ab663c97ba_80bda8bdb427042d5@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 0b41dc6b by Moritz Angermann at 2020-07-12T06:19:36+00:00 Address Takenobu Tani's comments. Thanks! - - - - - 1feaa00a by Moritz Angermann at 2020-07-12T07:05:56+00:00 Fix gcd :blush: - - - - - 4 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -629,6 +629,9 @@ getRegister' config plat expr when ((isFloatFormat format_x && isIntFormat format_y) || (isIntFormat format_x && isFloatFormat format_y)) $ pprPanic "getRegister:genOp" (text "formats don't match:" <+> text (show format_x) <+> text "/=" <+> text (show format_y)) return $ Any format_x (\dst -> code_x `appOL` code_y `appOL` op (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y)) + withTempIntReg w op = OpReg w <$> getNewRegNat (intFormat w) >>= op + withTempFloatReg w op = OpReg w <$> getNewRegNat (floatFormat w) >>= op + intOp w op = do -- compute x <- x -- compute x <- y @@ -694,18 +697,20 @@ getRegister' config plat expr MO_S_Quot w -> intOp w (\d x y -> unitOL $ SDIV d x y) -- No native rem instruction. So we'll compute the following - -- Rd <- Rx / Ry | 2 <- 7 / 3 -- SDIV Rd Rx Ry - -- Rd <- Rx - Rd * Ry | 1 <- 7 - 2 * 3 -- MSUB Rd Rd Ry Rx - -- | '---|----------------|---' | - -- | '----------------|-------' - -- '--------------------------' + -- Rd <- Rx / Ry | 2 <- 7 / 3 -- SDIV Rd Rx Ry + -- Rd' <- Rx - Rd * Ry | 1 <- 7 - 2 * 3 -- MSUB Rd' Rd Ry Rx + -- | '---|----------------|---' | + -- | '----------------|-------' + -- '--------------------------' -- Note the swap in Rx and Ry. - MO_S_Rem w -> intOp w (\d x y -> toOL [ SDIV d x y, MSUB d d y x ]) + MO_S_Rem w -> withTempIntReg w $ \t -> + intOp w (\d x y -> toOL [ SDIV t x y, MSUB d t y x ]) -- Unsigned multiply/divide MO_U_MulMayOflo _w -> unsupported expr MO_U_Quot w -> intOp w (\d x y -> unitOL $ UDIV d x y) - MO_U_Rem w -> intOp w (\d x y -> toOL [ UDIV d x y, MSUB d d y x ]) + MO_U_Rem w -> withTempIntReg w $ \t -> + intOp w (\d x y -> toOL [ UDIV t x y, MSUB d t y x ]) -- Signed comparisons -- see above for the CSET discussion MO_S_Ge w -> intOp w (\d x y -> toOL [ CMP x y, CSET d SGE ]) ===================================== compiler/GHC/CmmToAsm/AArch64/Cond.hs ===================================== @@ -4,6 +4,8 @@ import GHC.Prelude import GHC.Utils.Panic +-- https://developer.arm.com/documentation/den0024/a/the-a64-instruction-set/data-processing-instructions/conditional-instructions + -- XXX: This appears to go a bit overboard? Maybe we should stick with what LLVM -- settled on for fcmp? -- false: always yields false, regardless of operands. @@ -60,7 +62,7 @@ data Cond | UOGE -- b.pl | UOGT -- b.hi -- others - | NEVER -- ne + | NEVER -- b.nv | VS -- oVerflow set | VC -- oVerflow clear deriving Eq \ No newline at end of file ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -208,7 +208,7 @@ callerSavedRegisters :: [Reg] callerSavedRegisters = map regSingle [0..18] ++ map regSingle [32..39] - ++ map regSingle [48..62] + ++ map regSingle [48..63] -- | Apply a given mapping to all the register references in this -- instruction. @@ -514,7 +514,7 @@ data Instr | MOVK Operand Operand -- | MOVN Operand Operand -- | MOVZ Operand Operand - | MVN Operand Operand -- rd = -rn + | MVN Operand Operand -- rd = ~rn | ORN Operand Operand Operand -- rd = rn | ∼op2 | ORR Operand Operand Operand -- rd = rn | op2 | ROR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -489,7 +489,7 @@ pprCond c = case c of UGE -> text "hs" -- Carry set/unsigned higher or same ; Greater than or equal, or unordered UGT -> text "hi" -- Unsigned higher ; Greater than, or unordered - NEVER -> text "ne" -- Never + NEVER -> text "nv" -- Never VS -> text "vs" -- Overflow ; Unordered (at least one NaN operand) VC -> text "vc" -- No overflow ; Not unordered View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/27ea955ba4ed6d547ac86428bbe95272652a48dc...1feaa00a0df65e15c4f170a54e14d4d1f1e5fc6a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/27ea955ba4ed6d547ac86428bbe95272652a48dc...1feaa00a0df65e15c4f170a54e14d4d1f1e5fc6a You're receiving 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 Jul 12 13:03:51 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 12 Jul 2020 09:03:51 -0400 Subject: [Git][ghc/ghc][ghc-8.8] gitlab-ci: Bootstrap with 8.8.4-rc1 on Windows Message-ID: <5f0b0a372669c_80b3f848662eb1c27199e2@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC Commits: 9a24b411 by Ben Gamari at 2020-07-11T21:00:18-04:00 gitlab-ci: Bootstrap with 8.8.4-rc1 on Windows This avoids bugs in the `process` library during bootstrapping. - - - - - 2 changed files: - .gitlab-ci.yml - .gitlab/win32-init.sh Changes: ===================================== .gitlab-ci.yml ===================================== @@ -570,7 +570,16 @@ release-x86_64-linux-fedora27-dwarf: stage: full-build allow_failure: true variables: - GHC_VERSION: "8.8.3" + GHC_VERSION: "8.8.3.20200710" + GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" + before_script: + - python3 .gitlab/fix-submodules.py + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + # N.B. Drop bash syntax on Windows since this is interpreted by + # PowerShell. + - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf" script: - | python boot @@ -608,7 +617,8 @@ nightly-i386-windows-hadrian: allow_failure: true variables: BUILD_FLAVOUR: "UNSET" - GHC_VERSION: "8.8.3" + GHC_VERSION: "8.8.3.20200710" + GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_PROF_LIBS: "YES" BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz" script: @@ -647,6 +657,8 @@ release-x86_64-windows: extends: validate-x86_64-windows variables: MSYSTEM: MINGW64 + GHC_VERSION: 8.8.4-rc1 + GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" ===================================== .gitlab/win32-init.sh ===================================== @@ -22,7 +22,10 @@ if [ ! -e $toolchain/bin/ghc ]; then exit 1 ;; esac - curl https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz | tar -xJ + if [ -z "$GHC_TARBALL_URL" ]; then + GHC_TARBALL_URL="https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-$triple.tar.xz" + fi + curl "$GHC_TARBALL_URL" | tar -xJ mv ghc-$GHC_VERSION toolchain fi View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9a24b411bd4bea69ab292eaa5857941caae2ed73 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9a24b411bd4bea69ab292eaa5857941caae2ed73 You're receiving 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 Jul 12 13:03:52 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 12 Jul 2020 09:03:52 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/backports-8.8 Message-ID: <5f0b0a3831cbd_80b3f846a0d2e3c27207a9@gitlab.haskell.org.mail> Ben Gamari deleted branch wip/backports-8.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 Sun Jul 12 13:44:17 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sun, 12 Jul 2020 09:44:17 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 4 commits: Overflow guard Message-ID: <5f0b13b19c80b_80b3f849ba1b9402722266@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 3ef94e59 by Moritz Angermann at 2020-07-12T08:27:37+00:00 Overflow guard - - - - - 36cab9a9 by Moritz Angermann at 2020-07-12T08:28:00+00:00 More annotations. - - - - - 826a9426 by Moritz Angermann at 2020-07-12T08:29:18+00:00 Revert "Overflow guard" They are Integers not Ints. This reverts commit 3ef94e593a2848cf2bdc4251f5be34536642675f. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - ce9cbc92 by Moritz Angermann at 2020-07-12T13:43:59+00:00 Add CmmAssign and CmmStore comments - - - - - 2 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -445,28 +445,28 @@ getRegister' config plat expr -- XXX hand CmmInt 0 special, use wzr or xzr. CmmInt i W8 -> do - return (Any (intFormat W8) (\dst -> unitOL $ MOV (OpReg W8 dst) (OpImm (ImmInteger (narrowS W8 i))))) + return (Any (intFormat W8) (\dst -> unitOL $ ANN (text $ show expr) (MOV (OpReg W8 dst) (OpImm (ImmInteger (narrowS W8 i)))))) CmmInt i W16 -> do - return (Any (intFormat W16) (\dst -> unitOL $ MOV (OpReg W16 dst) (OpImm (ImmInteger (narrowS W16 i))))) + return (Any (intFormat W16) (\dst -> unitOL $ ANN (text $ show expr) (MOV (OpReg W16 dst) (OpImm (ImmInteger (narrowS W16 i)))))) -- We need to be careful to not shorten this for negative literals. -- Those need the upper bits set. We'd either have to explicitly sign -- or figure out something smarter. MNV dst XZR CmmInt i w | is16bit i, i >= 0 -> do - return (Any (intFormat w) (\dst -> unitOL $ MOV (OpReg W16 dst) (OpImm (ImmInteger i)))) + return (Any (intFormat w) (\dst -> unitOL $ ANN (text $ show expr) (MOV (OpReg W16 dst) (OpImm (ImmInteger i))))) CmmInt i w | is32bit i, i >= 0 -> do let half0 = fromIntegral (fromIntegral i :: Word16) half1 = fromIntegral (fromIntegral (i `shiftR` 16) :: Word16) - return (Any (intFormat w) (\dst -> toOL [ COMMENT (text "CmmInt" <+> integer i <+> text (show w)) - , MOV (OpReg W32 dst) (OpImm (ImmInt half0)) + return (Any (intFormat w) (\dst -> toOL [ ANN (text $ show expr) + $ MOV (OpReg W32 dst) (OpImm (ImmInt half0)) , MOVK (OpReg W32 dst) (OpImmShift (ImmInt half1) SLSL 16) ])) -- fallback for W32 CmmInt i W32 -> do let half0 = fromIntegral (fromIntegral i :: Word16) half1 = fromIntegral (fromIntegral (i `shiftR` 16) :: Word16) - return (Any (intFormat W32) (\dst -> toOL [ COMMENT (ppr expr) - , MOV (OpReg W32 dst) (OpImm (ImmInt half0)) + return (Any (intFormat W32) (\dst -> toOL [ ANN (text $ show expr) + $ MOV (OpReg W32 dst) (OpImm (ImmInt half0)) , MOVK (OpReg W32 dst) (OpImmShift (ImmInt half1) SLSL 16) ])) -- anything else @@ -475,20 +475,20 @@ getRegister' config plat expr half1 = fromIntegral (fromIntegral (i `shiftR` 16) :: Word16) half2 = fromIntegral (fromIntegral (i `shiftR` 32) :: Word16) half3 = fromIntegral (fromIntegral (i `shiftR` 48) :: Word16) - return (Any (intFormat W64) (\dst -> toOL [ COMMENT (ppr expr) - , MOV (OpReg W64 dst) (OpImm (ImmInt half0)) + return (Any (intFormat W64) (\dst -> toOL [ ANN (text $ show expr) + $ MOV (OpReg W64 dst) (OpImm (ImmInt half0)) , MOVK (OpReg W64 dst) (OpImmShift (ImmInt half1) SLSL 16) , MOVK (OpReg W64 dst) (OpImmShift (ImmInt half2) SLSL 32) , MOVK (OpReg W64 dst) (OpImmShift (ImmInt half3) SLSL 48) ])) CmmInt i rep -> do (op, imm_code) <- litToImm' lit - return (Any (intFormat rep) (\dst -> imm_code `snocOL` MOV (OpReg rep dst) op)) + return (Any (intFormat rep) (\dst -> imm_code `snocOL` ANN (text $ show expr) (MOV (OpReg rep dst) op))) -- floatToBytes (fromRational f) CmmFloat 0 w -> do (op, imm_code) <- litToImm' lit - return (Any (floatFormat w) (\dst -> imm_code `snocOL` MOV (OpReg w dst) op)) + return (Any (floatFormat w) (\dst -> imm_code `snocOL` ANN (text $ show expr) (MOV (OpReg w dst) op))) CmmFloat f W8 -> pprPanic "getRegister' (CmmLit:CmmFloat), no support for bytes" (ppr expr) CmmFloat f W16 -> pprPanic "getRegister' (CmmLit:CmmFloat), no support for halfs" (ppr expr) @@ -497,7 +497,8 @@ getRegister' config plat expr half0 = fromIntegral (fromIntegral word :: Word16) half1 = fromIntegral (fromIntegral (word `shiftR` 16) :: Word16) tmp <- getNewRegNat (intFormat W32) - return (Any (floatFormat W32) (\dst -> toOL [ MOV (OpReg W32 tmp) (OpImm (ImmInt half0)) + return (Any (floatFormat W32) (\dst -> toOL [ ANN (text $ show expr) + $ MOV (OpReg W32 tmp) (OpImm (ImmInt half0)) , MOVK (OpReg W32 tmp) (OpImmShift (ImmInt half1) SLSL 16) , MOV (OpReg W32 dst) (OpReg W32 tmp) ])) @@ -508,7 +509,8 @@ getRegister' config plat expr half2 = fromIntegral (fromIntegral (word `shiftR` 32) :: Word16) half3 = fromIntegral (fromIntegral (word `shiftR` 48) :: Word16) tmp <- getNewRegNat (intFormat W64) - return (Any (floatFormat W64) (\dst -> toOL [ MOV (OpReg W64 tmp) (OpImm (ImmInt half0)) + return (Any (floatFormat W64) (\dst -> toOL [ ANN (text $ show expr) + $ MOV (OpReg W64 tmp) (OpImm (ImmInt half0)) , MOVK (OpReg W64 tmp) (OpImmShift (ImmInt half1) SLSL 16) , MOVK (OpReg W64 tmp) (OpImmShift (ImmInt half2) SLSL 32) , MOVK (OpReg W64 tmp) (OpImmShift (ImmInt half3) SLSL 48) @@ -804,12 +806,10 @@ assignMem_IntCode rep addrE srcE (src_reg, _format, code) <- getSomeReg srcE Amode addr addr_code <- getAmode addrE let AddrReg r1 = addr - return $ unitOL (COMMENT $ text "RHS:" <+> ppr srcE) - `appOL` code - `appOL` unitOL (COMMENT $ text "LHS:" <+> ppr addrE) + return $ COMMENT (text "CmmStore" <+> parens (text (show addrE)) <+> parens (text (show srcE))) + `consOL` (code `appOL` addr_code - `snocOL` COMMENT (text "Store:" <+> ppr r1 <+> text "<-" <+> ppr src_reg) - `snocOL` STR rep (OpReg (formatToWidth rep) src_reg) (OpAddr addr) + `snocOL` STR rep (OpReg (formatToWidth rep) src_reg) (OpAddr addr)) assignReg_IntCode _ reg src = do @@ -819,8 +819,8 @@ assignReg_IntCode _ reg src p = showSDocUnsafe . ppr r <- getRegister src return $ case r of - Any _ code -> code dst - Fixed format freg fcode -> fcode `snocOL` MOV (OpReg (formatToWidth format) dst) (OpReg (formatToWidth format) freg) + Any _ code -> COMMENT (text "CmmAssign" <+> parens (text (show reg)) <+> parens (text (show src))) `consOL` code dst + Fixed format freg fcode -> COMMENT (text "CmmAssign" <+> parens (text (show reg)) <+> parens (text (show src))) `consOL` (fcode `snocOL` MOV (OpReg (formatToWidth format) dst) (OpReg (formatToWidth format) freg)) -- Let's treat Floating point stuff -- as integer code for now. Opaque. ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -331,7 +331,7 @@ aarch64_mkSpillInstr -> Instr aarch64_mkSpillInstr config reg delta slot - = STR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt $ off - delta))) + = ANN (text "Spill") $ STR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt $ off - delta))) where fmt = case reg of RegReal (RealRegSingle n) | n < 32 -> II64 @@ -346,7 +346,7 @@ aarch64_mkLoadInstr -> Instr aarch64_mkLoadInstr config reg delta slot - = LDR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt $ off - delta))) + = ANN (text "Reload") $ LDR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt $ off - delta))) where fmt = case reg of RegReal (RealRegSingle n) | n < 32 -> II64 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1feaa00a0df65e15c4f170a54e14d4d1f1e5fc6a...ce9cbc92c945c350dc3cc605bc7b78c97a133719 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1feaa00a0df65e15c4f170a54e14d4d1f1e5fc6a...ce9cbc92c945c350dc3cc605bc7b78c97a133719 You're receiving 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 Jul 12 13:51:37 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sun, 12 Jul 2020 09:51:37 -0400 Subject: [Git][ghc/ghc][wip/az/exactprint] Proof of Concept implementation of in-tree API Annotations Message-ID: <5f0b1569c3df_80bda8bdb427231d6@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/exactprint at Glasgow Haskell Compiler / GHC Commits: ab141bcc by Alan Zimmerman at 2020-07-12T14:47:55+01:00 Proof of Concept implementation of in-tree API Annotations This MR introduces a possible machinery to introduce API Annotations into the TTG extension points. It is intended to be a concrete example for discussion. It still needs to process comments. ---- Work in progress, adding more TTG extensions for annotations. And fixing ppr round-trip tests by being able to blank out in-tree annotations, as done with SrcSpans. This is needed for the case of class Foo a where for which current ppr does not print the "where". Rename AA to AddApiAnn and AA to AddAnn Add XConPatIn and XConPatOut Rebase ---- First pass at bringing in LocatedA for API anns in locations Treatment of ECP in parsing is provisional at this stage, leads to some horribly stuff in Parser.y and RdrHsSyn. It is an extensive but not invasive change. I think (AZ). Locally it reports some parsing tests using less memory. Add ApiAnns to the HsExpr data structure. rebase. Change HsMatchContext and HsStmtContext to use an id, not a GhcPass parameter. Add ApiAnns to Hs/Types Rebase Rebased 2020-03-25 WIP on in-tree annotations Includes updating HsModule Imports LocateA ImportDecl so we can hang AnnSemi off it A whole bunch of stuff more InjectivityAnn and FamEqn now have annotations in them Add annotations to context srcspan ---- In-tree annotations: LHsDecl and LHsBind LocatedA ---- WIP on in-tree annotations ---- in-tree annotations: LHsType is now LocatedA ---- FunDeps is now also a HS data type ---- WIP. Added LocatedA to Pat, Expr, Decl And worked some more through Parser.y ---- LStmt now Located ---- Finished working through Parser.y, tests seem ok failures relate to annotations. Adding test infrastructure for check-exact Like check-ppr, but checking for an exact reproduction of the parsed source file. Starting to work on actual exact printer Bring in ApiAnnName As an alternative for LocatedA, to be used for names only. Carrying extra name adornments, such as locations of backticks, parens, etc. Working on changing ApiAnnName to accurately reflect actual usage Get rid of AnnApiName in favour of LocatedN Working on check-exact. Making progress Working on the ghc-exact bit Progress, can reproduce the first Test.hs file. Move API Annotations out of the extensions to annotations - - - - - 20 changed files: - .gitmodules - compiler/GHC.hs - compiler/GHC/Data/BooleanFormula.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - + compiler/GHC/Hs/Exact.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Expr.hs-boot - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Stats.hs - compiler/GHC/Hs/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab141bcc82a3c1ad5873cb22d95bc6518b057628 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab141bcc82a3c1ad5873cb22d95bc6518b057628 You're receiving 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 Jul 12 16:05:34 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 12 Jul 2020 12:05:34 -0400 Subject: [Git][ghc/ghc] Pushed new tag ghc-8.8.4-rc1 Message-ID: <5f0b34cedf933_80b114013dc273102f@gitlab.haskell.org.mail> Ben Gamari pushed new tag ghc-8.8.4-rc1 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-8.8.4-rc1 You're receiving 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 Jul 12 16:23:04 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Sun, 12 Jul 2020 12:23:04 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/no-core Message-ID: <5f0b38e888ca0_80b3f849c221f40273145e@gitlab.haskell.org.mail> Krzysztof Gogolewski pushed new branch wip/no-core at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/no-core You're receiving 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 Jul 12 22:33:16 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sun, 12 Jul 2020 18:33:16 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/famdecl-toplevel-flag Message-ID: <5f0b8fac905aa_80b3f8486b77e4827462d6@gitlab.haskell.org.mail> Alan Zimmerman pushed new branch wip/az/famdecl-toplevel-flag at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/famdecl-toplevel-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 Mon Jul 13 01:31:02 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sun, 12 Jul 2020 21:31:02 -0400 Subject: [Git][ghc/ghc][wip/use-CmmRegOff-smart-ctor] 6 commits: Define multiShotIO and use it in mkSplitUniqueSupply Message-ID: <5f0bb95695fd0_80b114013dc2753445@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/use-CmmRegOff-smart-ctor at Glasgow Haskell Compiler / GHC Commits: d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - d060c1e1 by Ben Gamari at 2020-07-12T21:31:01-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - 30 changed files: - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/208a35476efad906e1b4ba65548e44b48dc4998d...d060c1e1150eca0445ba1fc2037af97690e69d35 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/208a35476efad906e1b4ba65548e44b48dc4998d...d060c1e1150eca0445ba1fc2037af97690e69d35 You're receiving 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 Jul 13 01:38:27 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sun, 12 Jul 2020 21:38:27 -0400 Subject: [Git][ghc/ghc][wip/angerman/fix-hadrian-cross-macos] 9 commits: Define multiShotIO and use it in mkSplitUniqueSupply Message-ID: <5f0bbb135e7c0_80b3f849ba1b9402758416@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/fix-hadrian-cross-macos at Glasgow Haskell Compiler / GHC Commits: d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - 74674b14 by Moritz Angermann at 2020-07-12T21:38:26-04:00 Fix ar-stage0 having no at-file support in hadrian - - - - - c8a2323e by Moritz Angermann at 2020-07-12T21:38:26-04:00 No Undefined Oriented Programming - - - - - 7f65115c by Moritz Angermann at 2020-07-12T21:38:26-04:00 fallback - - - - - c81e408a by Moritz Angermann at 2020-07-12T21:38:26-04:00 add docs - - - - - 30 changed files: - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e479b9ae96f52bcb0140474e9ea4ad2eed74223...c81e408a767fd16fefe2423e8958a9c9a30f0db2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e479b9ae96f52bcb0140474e9ea4ad2eed74223...c81e408a767fd16fefe2423e8958a9c9a30f0db2 You're receiving 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 Jul 13 02:21:17 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sun, 12 Jul 2020 22:21:17 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] Update test.mk Message-ID: <5f0bc51d6abf5_80b3f846a0d2e3c2759165@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: def7f003 by Moritz Angermann at 2020-07-12T22:21:16-04:00 Update test.mk - - - - - 1 changed file: - testsuite/mk/test.mk Changes: ===================================== testsuite/mk/test.mk ===================================== @@ -31,6 +31,10 @@ CONFIG = $(TOP)/config/$(COMPILER) TEST_WRAPPER ?= exec export TEST_WRAPPER +# if no STRIP is set, use `strip` +STRIP ?= strip +export STRIP + ifeq "$(GhcUnregisterised)" "YES" # Otherwise C backend generates many warnings about # imcompatible proto casts for GCC's buitins: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/def7f003b7694e2f53cc719ce272f20823dedeb2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/def7f003b7694e2f53cc719ce272f20823dedeb2 You're receiving 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 Jul 13 02:21:28 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sun, 12 Jul 2020 22:21:28 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] 12 commits: Define multiShotIO and use it in mkSplitUniqueSupply Message-ID: <5f0bc5284b92f_80b3f848662eb1c27594aa@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - 9e284725 by Moritz Angermann at 2020-07-12T22:21:26-04:00 Cross Test Suite - - - - - 1ebbb45b by Moritz Angermann at 2020-07-12T22:21:26-04:00 platform backwards compat, until libraries are patched. - - - - - db6d16ea by Moritz Angermann at 2020-07-12T22:21:26-04:00 unbreak test.mk - - - - - 81cd2a94 by Moritz Angermann at 2020-07-12T22:21:26-04:00 default TEST_WRAPPER - - - - - 32579bb9 by Moritz Angermann at 2020-07-12T22:21:26-04:00 m( - - - - - 72647bfa by Moritz Angermann at 2020-07-12T22:21:26-04:00 Fixup the test-suite - - - - - 495da59b by Moritz Angermann at 2020-07-12T22:21:26-04:00 Update test.mk - - - - - 30 changed files: - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/def7f003b7694e2f53cc719ce272f20823dedeb2...495da59b1b40e9d216b7ce86f19fd6c35d23d2ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/def7f003b7694e2f53cc719ce272f20823dedeb2...495da59b1b40e9d216b7ce86f19fd6c35d23d2ce You're receiving 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 Jul 13 07:00:27 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 13 Jul 2020 03:00:27 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: add reproducer for #15630 Message-ID: <5f0c068bb518e_80b3f8490174d382764511@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - 52733674 by Aaron Allen at 2020-07-13T03:00:24-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - 78cb743f by Stefan Schulze Frielinghaus at 2020-07-13T03:00:25-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 30 changed files: - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Data/FastString/Env.hs - compiler/GHC/Data/Graph/Base.hs - compiler/GHC/Data/Graph/Color.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/909030436b629d3e0ced782f08104c285667702f...78cb743f5915a24efbc3369e9bb5f478e9a1b5b4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/909030436b629d3e0ced782f08104c285667702f...78cb743f5915a24efbc3369e9bb5f478e9a1b5b4 You're receiving 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 Jul 13 07:42:01 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 13 Jul 2020 03:42:01 -0400 Subject: [Git][ghc/ghc][wip/T18282] 55 commits: Reject nested foralls/contexts in instance types more consistently Message-ID: <5f0c104964492_80b3f8486b77e4827694e6@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18282 at Glasgow Haskell Compiler / GHC Commits: 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - d2927dbc by Simon Peyton Jones at 2020-07-13T03:41:42-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - c23021cf by Simon Peyton Jones at 2020-07-13T03:41:42-04:00 Comments only - - - - - a5ca69c2 by Simon Peyton Jones at 2020-07-13T03:41:42-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 30 changed files: - .gitlab/test-metrics.sh - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Regs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5eae4b2d5883ee27dc6df4fba86fcd6936335cd7...a5ca69c2ba72b5c08e66ac2ca55c6af35f4138e1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5eae4b2d5883ee27dc6df4fba86fcd6936335cd7...a5ca69c2ba72b5c08e66ac2ca55c6af35f4138e1 You're receiving 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 Jul 13 07:42:44 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 13 Jul 2020 03:42:44 -0400 Subject: [Git][ghc/ghc][wip/T13253] 56 commits: Reject nested foralls/contexts in instance types more consistently Message-ID: <5f0c1074cc3ff_80b3f8486b77e4827703f6@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC Commits: 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - d2927dbc by Simon Peyton Jones at 2020-07-13T03:41:42-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - c23021cf by Simon Peyton Jones at 2020-07-13T03:41:42-04:00 Comments only - - - - - a5ca69c2 by Simon Peyton Jones at 2020-07-13T03:41:42-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 818aba30 by Simon Peyton Jones at 2020-07-13T03:42:34-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes two significant changes: 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Then in postInlineUnconditionally use that info to avoid inling something many many times. Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally See Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils 2. Change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg] Current nofib run Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- VS -0.3% +115.9% +12.1% +11.2% 0.0% boyer2 -0.3% +10.0% +3.5% +4.0% 0.0% cryptarithm2 -0.3% +39.0% +16.6% +16.1% 0.0% gamteb -0.3% +4.1% -0.0% +0.4% 0.0% last-piece -0.3% +1.4% -1.1% -0.4% 0.0% mate -0.4% -11.1% -8.5% -9.0% 0.0% multiplier -0.3% -2.2% -1.5% -1.5% 0.0% transform -0.3% +3.4% +0.5% +0.8% 0.0% -------------------------------------------------------------------------------- Min -0.8% -11.1% -8.5% -9.0% 0.0% Max -0.3% +115.9% +30.1% +26.4% 0.0% Geometric Mean -0.3% +1.0% +1.0% +1.0% -0.0% Should investigate these numbers. But the tickets are indeed cured, I think. - - - - - 30 changed files: - .gitlab/test-metrics.sh - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Regs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/35bcb5fa41963d3a144a0792a7383dd168a27945...818aba30cc10ea959afa405bd7c67e1b765239b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/35bcb5fa41963d3a144a0792a7383dd168a27945...818aba30cc10ea959afa405bd7c67e1b765239b7 You're receiving 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 Jul 13 11:42:43 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Mon, 13 Jul 2020 07:42:43 -0400 Subject: [Git][ghc/ghc][wip/andreask/allocationArea] Increase -A and -O rts defaults to 4MB. Message-ID: <5f0c48b354a42_80b3f8490174d38280034e@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/allocationArea at Glasgow Haskell Compiler / GHC Commits: 420ea7b3 by Andreas Klebinger at 2020-07-13T13:41:57+02:00 Increase -A and -O rts defaults to 4MB. Fixes #16499 - - - - - 2 changed files: - docs/users_guide/runtime_control.rst - rts/RtsFlags.c Changes: ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -401,7 +401,7 @@ performance. .. rts-flag:: -A ⟨size⟩ - :default: 1MB + :default: 4MB .. index:: single: allocation area, size @@ -410,15 +410,22 @@ performance. collector. The allocation area (actually generation 0 step 0) is fixed and is never resized (unless you use :rts-flag:`-H [⟨size⟩]`, below). - Increasing the allocation area size may or may not give better - performance (a bigger allocation area means worse cache behaviour - but fewer garbage collections and less promotion). + Optimal settings depend on the actual machine, program, and other RTS options. + Increasing the allocation area size means worse cache behaviour + but fewer garbage collections and less promotion. + + In general settings >= 4MB can reduce performance in some cases, in particular for single + threaded operation. However in a parallel setting increasing the allocation area + to ``16MB``, or even ``64MB`` can increase gc throughput significantly. With only 1 generation (e.g. ``-G1``, see :rts-flag:`-G ⟨generations⟩`) the ``-A`` option specifies the minimum allocation area, since the actual size of the allocation area will be resized according to the amount of data in the heap (see :rts-flag:`-F ⟨factor⟩`, below). + When heap profiling using a smaller allocation area can increase accuracy as more frequent + major garbage collections also results in more frequent heap snapshots + .. rts-flag:: -AL ⟨size⟩ :default: :rts-flag:`-A <-A ⟨size⟩>` value @@ -450,7 +457,7 @@ performance. .. rts-flag:: -O ⟨size⟩ - :default: 1m + :default: 4m .. index:: single: old generation, size ===================================== rts/RtsFlags.c ===================================== @@ -152,10 +152,10 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.stkChunkSize = (32 * 1024) / sizeof(W_); RtsFlags.GcFlags.stkChunkBufferSize = (1 * 1024) / sizeof(W_); - RtsFlags.GcFlags.minAllocAreaSize = (1024 * 1024) / BLOCK_SIZE; + RtsFlags.GcFlags.minAllocAreaSize = (4 * 1024 * 1024) / BLOCK_SIZE; /* -A default */ RtsFlags.GcFlags.largeAllocLim = 0; /* defaults to minAllocAreasize */ RtsFlags.GcFlags.nurseryChunkSize = 0; - RtsFlags.GcFlags.minOldGenSize = (1024 * 1024) / BLOCK_SIZE; + RtsFlags.GcFlags.minOldGenSize = (4 * 1024 * 1024) / BLOCK_SIZE; /* -O default */ RtsFlags.GcFlags.maxHeapSize = 0; /* off by default */ RtsFlags.GcFlags.heapLimitGrace = (1024 * 1024); RtsFlags.GcFlags.heapSizeSuggestion = 0; /* none */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/420ea7b3deae58e7e2731564fab27995542101b4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/420ea7b3deae58e7e2731564fab27995542101b4 You're receiving 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 Jul 13 11:48:09 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Mon, 13 Jul 2020 07:48:09 -0400 Subject: [Git][ghc/ghc][wip/andreask/allocationArea] Increase -A and -O rts defaults to 4MB. Message-ID: <5f0c49f9c6a1e_80bda8bdb42802154@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/allocationArea at Glasgow Haskell Compiler / GHC Commits: 444c1e0e by Andreas Klebinger at 2020-07-13T13:47:58+02:00 Increase -A and -O rts defaults to 4MB. Fixes #16499 - - - - - 2 changed files: - docs/users_guide/runtime_control.rst - rts/RtsFlags.c Changes: ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -401,7 +401,7 @@ performance. .. rts-flag:: -A ⟨size⟩ - :default: 1MB + :default: 4MB .. index:: single: allocation area, size @@ -410,15 +410,22 @@ performance. collector. The allocation area (actually generation 0 step 0) is fixed and is never resized (unless you use :rts-flag:`-H [⟨size⟩]`, below). - Increasing the allocation area size may or may not give better - performance (a bigger allocation area means worse cache behaviour - but fewer garbage collections and less promotion). + Optimal settings depend on the actual machine, program, and other RTS options. + Increasing the allocation area size means worse cache behaviour + but fewer garbage collections and less promotion. + + In general settings >= 4MB can reduce performance in some cases, in particular for single + threaded operation. However in a parallel setting increasing the allocation area + to ``16MB``, or even ``64MB`` can increase gc throughput significantly. With only 1 generation (e.g. ``-G1``, see :rts-flag:`-G ⟨generations⟩`) the ``-A`` option specifies the minimum allocation area, since the actual size of the allocation area will be resized according to the amount of data in the heap (see :rts-flag:`-F ⟨factor⟩`, below). + When heap profiling using a smaller allocation area can increase accuracy as more frequent + major garbage collections also results in more frequent heap snapshots + .. rts-flag:: -AL ⟨size⟩ :default: :rts-flag:`-A <-A ⟨size⟩>` value @@ -450,7 +457,7 @@ performance. .. rts-flag:: -O ⟨size⟩ - :default: 1m + :default: 4m .. index:: single: old generation, size ===================================== rts/RtsFlags.c ===================================== @@ -152,10 +152,11 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.stkChunkSize = (32 * 1024) / sizeof(W_); RtsFlags.GcFlags.stkChunkBufferSize = (1 * 1024) / sizeof(W_); - RtsFlags.GcFlags.minAllocAreaSize = (1024 * 1024) / BLOCK_SIZE; + /* -A default. See #16499 for a discussion about the tradeoffs */ + RtsFlags.GcFlags.minAllocAreaSize = (4 * 1024 * 1024) / BLOCK_SIZE; RtsFlags.GcFlags.largeAllocLim = 0; /* defaults to minAllocAreasize */ RtsFlags.GcFlags.nurseryChunkSize = 0; - RtsFlags.GcFlags.minOldGenSize = (1024 * 1024) / BLOCK_SIZE; + RtsFlags.GcFlags.minOldGenSize = (4 * 1024 * 1024) / BLOCK_SIZE; /* -O default */ RtsFlags.GcFlags.maxHeapSize = 0; /* off by default */ RtsFlags.GcFlags.heapLimitGrace = (1024 * 1024); RtsFlags.GcFlags.heapSizeSuggestion = 0; /* none */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/444c1e0e9df29e3323bec9cf5d50fb88c57eaafa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/444c1e0e9df29e3323bec9cf5d50fb88c57eaafa You're receiving 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 Jul 13 13:00:39 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 13 Jul 2020 09:00:39 -0400 Subject: [Git][ghc/ghc][master] Warn about empty Char enumerations (#18402) Message-ID: <5f0c5af752c1b_80b3f84960bea14281154b@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - 4 changed files: - compiler/GHC/HsToCore/Match/Literal.hs - + testsuite/tests/warnings/should_compile/T18402.hs - + testsuite/tests/warnings/should_compile/T18402.stderr - testsuite/tests/warnings/should_compile/all.T Changes: ===================================== compiler/GHC/HsToCore/Match/Literal.hs ===================================== @@ -261,18 +261,19 @@ but perhaps that does not matter too much. warnAboutEmptyEnumerations :: FamInstEnvs -> DynFlags -> LHsExpr GhcTc -> Maybe (LHsExpr GhcTc) -> LHsExpr GhcTc -> DsM () --- ^ Warns about @[2,3 .. 1]@ which returns the empty list. --- Only works for integral types, not floating point. +-- ^ Warns about @[2,3 .. 1]@ or @['b' .. 'a']@ which return the empty list. +-- For numeric literals, only works for integral types, not floating point. warnAboutEmptyEnumerations fam_envs dflags fromExpr mThnExpr toExpr - | wopt Opt_WarnEmptyEnumerations dflags - , Just from_ty@(from,_) <- getLHsIntegralLit fromExpr + | not $ wopt Opt_WarnEmptyEnumerations dflags + = return () + -- Numeric Literals + | Just from_ty@(from,_) <- getLHsIntegralLit fromExpr , Just (_, tc) <- getNormalisedTyconName fam_envs from_ty , Just mThn <- traverse getLHsIntegralLit mThnExpr , Just (to,_) <- getLHsIntegralLit toExpr , let check :: forall a. (Enum a, Num a) => Proxy a -> DsM () check _proxy - = when (null enumeration) $ - warnDs (Reason Opt_WarnEmptyEnumerations) (text "Enumeration is empty") + = when (null enumeration) raiseWarning where enumeration :: [a] enumeration = case mThn of @@ -296,7 +297,18 @@ warnAboutEmptyEnumerations fam_envs dflags fromExpr mThnExpr toExpr -- See the T10930b test case for an example of where this matters. else return () + -- Char literals (#18402) + | Just fromChar <- getLHsCharLit fromExpr + , Just mThnChar <- traverse getLHsCharLit mThnExpr + , Just toChar <- getLHsCharLit toExpr + , let enumeration = case mThnChar of + Nothing -> [fromChar .. toChar] + Just thnChar -> [fromChar, thnChar .. toChar] + = when (null enumeration) raiseWarning + | otherwise = return () + where + raiseWarning = warnDs (Reason Opt_WarnEmptyEnumerations) (text "Enumeration is empty") getLHsIntegralLit :: LHsExpr GhcTc -> Maybe (Integer, Type) -- ^ See if the expression is an 'Integral' literal. @@ -325,6 +337,14 @@ getSimpleIntegralLit (HsWord64Prim _ i) = Just (i, word64PrimTy) getSimpleIntegralLit (HsInteger _ i ty) = Just (i, ty) getSimpleIntegralLit _ = Nothing +-- | Extract the Char if the expression is a Char literal. +getLHsCharLit :: LHsExpr GhcTc -> Maybe Char +getLHsCharLit (L _ (HsPar _ e)) = getLHsCharLit e +getLHsCharLit (L _ (HsTick _ _ e)) = getLHsCharLit e +getLHsCharLit (L _ (HsBinTick _ _ _ e)) = getLHsCharLit e +getLHsCharLit (L _ (HsLit _ (HsChar _ c))) = Just c +getLHsCharLit _ = Nothing + -- | Convert a pair (Integer, Type) to (Integer, Name) after eventually -- normalising the type getNormalisedTyconName :: FamInstEnvs -> (Integer, Type) -> Maybe (Integer, Name) ===================================== testsuite/tests/warnings/should_compile/T18402.hs ===================================== @@ -0,0 +1,8 @@ +module T18402 where + +a = ['b' .. 'a'] -- empty +b = ['b', 'a' .. 'c'] -- empty +c = ['b', 'c' .. 'a'] -- empty +d = ['a' .. 'c'] -- not empty +e = ['a', 'c' .. 'b'] -- not empty + ===================================== testsuite/tests/warnings/should_compile/T18402.stderr ===================================== @@ -0,0 +1,9 @@ + +T18402.hs:3:5: warning: [-Wempty-enumerations (in -Wdefault)] + Enumeration is empty + +T18402.hs:4:5: warning: [-Wempty-enumerations (in -Wdefault)] + Enumeration is empty + +T18402.hs:5:5: warning: [-Wempty-enumerations (in -Wdefault)] + Enumeration is empty ===================================== testsuite/tests/warnings/should_compile/all.T ===================================== @@ -30,3 +30,5 @@ test('Overflow', expect_broken_for(16543, ['hpc']), compile, ['']) test('UnusedPackages', normal, multimod_compile, ['UnusedPackages.hs', '-package=bytestring -package=base -package=process -package=ghc -Wunused-packages']) + +test('T18402', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2cfdfde20d0d6c0e16aa7a84d8ebe51501bcfa8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2cfdfde20d0d6c0e16aa7a84d8ebe51501bcfa8 You're receiving 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 Jul 13 13:01:17 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 13 Jul 2020 09:01:17 -0400 Subject: [Git][ghc/ghc][master] hadrian: build check-ppr dynamic if GHC is build dynamic Message-ID: <5f0c5b1d812ec_80b3f849c221f402818596@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 1 changed file: - hadrian/src/Rules/Test.hs Changes: ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -75,13 +75,16 @@ testRules = do bindir <- getBinaryDirectory testGhc debugged <- ghcDebugged <$> flavour + dynPrograms <- dynamicGhcPrograms =<< flavour cmd [bindir "ghc" <.> exe] $ concatMap (\p -> ["-package", pkgName p]) depsPkgs ++ ["-o", top -/- path, top -/- sourcePath] ++ -- If GHC is build with debug options, then build check-ppr -- also with debug options. This allows, e.g., to print debug -- messages of various RTS subsystems while using check-ppr. - if debugged then ["-debug"] else [] + if debugged then ["-debug"] else [] ++ + -- If GHC is build dynamic, then build check-ppr also dynamic. + if dynPrograms then ["-dynamic"] else [] root -/- ghcConfigPath %> \_ -> do args <- userSetting defaultTestArgs View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c3ac87ece2716b83ad886e81c20f4161e8ec0efd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c3ac87ece2716b83ad886e81c20f4161e8ec0efd You're receiving 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 Jul 13 15:19:31 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 13 Jul 2020 11:19:31 -0400 Subject: [Git][ghc/ghc][wip/T18412] 33 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f0c7b835979c_80bda8bdb428310af@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18412 at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 7ea0ea97 by Simon Peyton Jones at 2020-07-13T16:19:15+01:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - 30 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3ecd7b82c4ac35723d09b5e0eaf6b62808805b6e...7ea0ea9763ccce7c25bce2e943e1a3e378cc083b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3ecd7b82c4ac35723d09b5e0eaf6b62808805b6e...7ea0ea9763ccce7c25bce2e943e1a3e378cc083b You're receiving 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 Jul 13 15:26:49 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 13 Jul 2020 11:26:49 -0400 Subject: [Git][ghc/ghc][wip/T18412] Allow multiple case branches to have a higher rank type Message-ID: <5f0c7d3954892_80b114013dc2834785@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18412 at Glasgow Haskell Compiler / GHC Commits: e60ceff9 by Simon Peyton Jones at 2020-07-13T16:26:04+01:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - 18 changed files: - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/Unify.hs - testsuite/tests/simplCore/should_compile/T17901.stdout - + testsuite/tests/typecheck/should_compile/T18412.hs - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T10619.stderr - testsuite/tests/typecheck/should_fail/tcfail002.stderr - testsuite/tests/typecheck/should_fail/tcfail104.stderr Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -19,7 +19,7 @@ Note [The Type-related module hierarchy] -- We expose the relevant stuff from this module via the Type module {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE CPP, DeriveDataTypeable, MultiWayIf, PatternSynonyms, BangPatterns #-} +{-# LANGUAGE CPP, MultiWayIf, PatternSynonyms, BangPatterns, DeriveDataTypeable #-} module GHC.Core.TyCo.Rep ( TyThing(..), tyThingCategory, pprTyThingCategory, pprShortTyThing, @@ -2025,6 +2025,12 @@ GHC.Core.Multiplicity above this module. -- | A shorthand for data with an attached 'Mult' element (the multiplicity). data Scaled a = Scaled Mult a deriving (Data.Data) + -- You might think that this would be a natural candiate for + -- Functor, Traversable but Krzysztof says (!3674) "it was too easy + -- to accidentally lift functions (substitutions, zonking etc.) from + -- Type -> Type to Scaled Type -> Scaled Type, ignoring + -- multiplicities and causing bugs". So we don't. + instance (Outputable a) => Outputable (Scaled a) where ppr (Scaled _cnt t) = ppr t ===================================== compiler/GHC/Core/UsageEnv.hs ===================================== @@ -1,7 +1,7 @@ {-# LANGUAGE ViewPatterns #-} module GHC.Core.UsageEnv (UsageEnv, addUsage, scaleUsage, zeroUE, lookupUE, scaleUE, deleteUE, addUE, Usage(..), unitUE, - supUE, supUEs) where + bottomUE, supUE, supUEs) where import Data.Foldable import GHC.Prelude ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -591,10 +591,6 @@ tcExpr (HsCase x scrut matches) res_ty tcExpr (HsIf x NoSyntaxExprRn pred b1 b2) res_ty -- Ordinary 'if' = do { pred' <- tcLExpr pred (mkCheckExpType boolTy) - ; res_ty <- tauifyExpType res_ty - -- Just like Note [Case branches must never infer a non-tau type] - -- in GHC.Tc.Gen.Match (See #10619) - ; (u1,b1') <- tcCollectingUsage $ tcLExpr b1 res_ty ; (u2,b2') <- tcCollectingUsage $ tcLExpr b2 res_ty ; tcEmitBindingUsage (supUE u1 u2) @@ -611,13 +607,7 @@ tcExpr (HsIf x fun@(SyntaxExprRn {}) pred b1 b2) res_ty ; return (HsIf x fun' pred' b1' b2') } tcExpr (HsMultiIf _ alts) res_ty - = do { res_ty <- if isSingleton alts - then return res_ty - else tauifyExpType res_ty - -- Just like GHC.Tc.Gen.Match - -- Note [Case branches must never infer a non-tau type] - - ; alts' <- mapM (wrapLocM $ tcGRHS match_ctxt res_ty) alts + = do { alts' <- mapM (wrapLocM $ tcGRHS match_ctxt res_ty) alts ; res_ty <- readExpType res_ty ; return (HsMultiIf res_ty alts') } where match_ctxt = MC { mc_what = IfAlt, mc_body = tcBody } ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -164,80 +164,47 @@ tcGRHSsPat grhss res_ty = tcGRHSs match_ctxt grhss (mkCheckExpType res_ty) match_ctxt = MC { mc_what = PatBindRhs, mc_body = tcBody } -{- -************************************************************************ +{- ********************************************************************* * * -\subsection{tcMatch} + tcMatch * * -************************************************************************ - -Note [Case branches must never infer a non-tau type] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider - - case ... of - ... -> \(x :: forall a. a -> a) -> x - ... -> \y -> y - -Should that type-check? The problem is that, if we check the second branch -first, then we'll get a type (b -> b) for the branches, which won't unify -with the polytype in the first branch. If we check the first branch first, -then everything is OK. This order-dependency is terrible. So we want only -proper tau-types in branches (unless a sigma-type is pushed down). -This is what expTypeToType ensures: it replaces an Infer with a fresh -tau-type. - -An even trickier case looks like - - f x True = x undefined - f x False = x () - -Here, we see that the arguments must also be non-Infer. Thus, we must -use expTypeToType on the output of matchExpectedFunTys, not the input. - -But we make a special case for a one-branch case. This is so that - - f = \(x :: forall a. a -> a) -> x - -still gets assigned a polytype. --} +********************************************************************* -} --- | When the MatchGroup has multiple RHSs, convert an Infer ExpType in the --- expected type into TauTvs. --- See Note [Case branches must never infer a non-tau type] -tauifyMultipleMatches :: [LMatch id body] - -> [Scaled ExpType] -> TcM [Scaled ExpType] -tauifyMultipleMatches group exp_tys - | isSingletonMatchGroup group = return exp_tys - | otherwise = mapM (\(Scaled m t) -> - fmap (Scaled m) (tauifyExpType t)) exp_tys - -- NB: In the empty-match case, this ensures we fill in the ExpType +data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module + = MC { mc_what :: HsMatchContext GhcRn, -- What kind of thing this is + mc_body :: Located (body GhcRn) -- Type checker for a body of + -- an alternative + -> ExpRhoType + -> TcM (Located (body GhcTc)) } -- | Type-check a MatchGroup. tcMatches :: (Outputable (body GhcRn)) => TcMatchCtxt body -> [Scaled ExpSigmaType] -- Expected pattern types - -> ExpRhoType -- Expected result-type of the Match. + -> ExpRhoType -- Expected result-type of the Match. -> MatchGroup GhcRn (Located (body GhcRn)) -> TcM (MatchGroup GhcTc (Located (body GhcTc))) -data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module - = MC { mc_what :: HsMatchContext GhcRn, -- What kind of thing this is - mc_body :: Located (body GhcRn) -- Type checker for a body of - -- an alternative - -> ExpRhoType - -> TcM (Located (body GhcTc)) } tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches , mg_origin = origin }) - = do { (Scaled _ rhs_ty):pat_tys <- tauifyMultipleMatches matches ((Scaled One rhs_ty):pat_tys) -- return type has implicitly multiplicity 1, it doesn't matter all that much in this case since it isn't used and is eliminated immediately. - -- See Note [Case branches must never infer a non-tau type] + | null matches -- Deal with case e of {} + -- Since there are no branches, no one else will fill in rhs_ty + -- when in inference mode, so we must do it ourselves, + -- here, using expTypeToType + = do { tcEmitBindingUsage bottomUE + ; pat_tys <- mapM scaledExpTypeToType pat_tys + ; rhs_ty <- expTypeToType rhs_ty + ; return (MG { mg_alts = L l [] + , mg_ext = MatchGroupTc pat_tys rhs_ty + , mg_origin = origin }) } - ; umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches + | otherwise + = do { umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches ; let (usages,matches') = unzip umatches ; tcEmitBindingUsage $ supUEs usages - ; pat_tys <- mapM (\(Scaled m t) -> fmap (Scaled m) (readExpType t)) pat_tys + ; pat_tys <- mapM readScaledExpType pat_tys ; rhs_ty <- readExpType rhs_ty - ; return (MG { mg_alts = L l matches' - , mg_ext = MatchGroupTc pat_tys rhs_ty + ; return (MG { mg_alts = L l matches' + , mg_ext = MatchGroupTc pat_tys rhs_ty , mg_origin = origin }) } ------------- ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -220,8 +220,9 @@ tcPatBndr penv@(PE { pe_ctxt = LetPat { pc_lvl = bind_lvl = do { (co, bndr_ty) <- case scaledThing exp_pat_ty of Check pat_ty -> promoteTcType bind_lvl pat_ty Infer infer_res -> ASSERT( bind_lvl == ir_lvl infer_res ) - -- If we were under a constructor that bumped - -- the level, we'd be in checking mode + -- If we were under a constructor that bumped the + -- level, we'd be in checking mode (see tcConArg) + -- hence this assertion do { bndr_ty <- inferResultToType infer_res ; return (mkTcNomReflCo bndr_ty, bndr_ty) } ; let bndr_mult = scaledMult exp_pat_ty @@ -629,10 +630,9 @@ There are two bits of rebindable syntax: lit1_ty and lit2_ty could conceivably be different. var_ty is the type inferred for x, the variable in the pattern. -If the pushed-down pattern type isn't a tau-type, the two pat_ty's above -could conceivably be different specializations. But this is very much -like the situation in Note [Case branches must be taus] in GHC.Tc.Gen.Match. -So we tauify the pat_ty before proceeding. +If the pushed-down pattern type isn't a tau-type, the two pat_ty's +above could conceivably be different specializations. So we use +expTypeToType on pat_ty before proceeding. Note that we need to type-check the literal twice, because it is used twice, and may be used at different types. The second HsOverLit stored in the ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -36,7 +36,7 @@ import GHC.Tc.Utils.TcType import GHC.Tc.Utils.TcMType import GHC.Tc.Validity ( checkValidType ) import GHC.Tc.Utils.Unify( tcSkolemise, unifyType ) -import GHC.Tc.Utils.Instantiate( topInstantiate ) +import GHC.Tc.Utils.Instantiate( topInstantiate, tcInstTypeBndrs ) import GHC.Tc.Utils.Env( tcLookupId ) import GHC.Tc.Types.Evidence( HsWrapper, (<.>) ) import GHC.Core.Type ( mkTyVarBinders ) ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -16,6 +16,7 @@ import GHC.Prelude import GHC.Tc.Utils.Env import GHC.Tc.Utils.Monad import GHC.Tc.Utils.TcType +import GHC.Tc.Utils.Instantiate( tcInstType ) import GHC.Tc.Instance.Typeable import GHC.Tc.Utils.TcMType import GHC.Tc.Types.Evidence ===================================== compiler/GHC/Tc/Instance/Family.hs ===================================== @@ -21,6 +21,7 @@ import GHC.Core.Coercion import GHC.Tc.Types.Evidence import GHC.Iface.Load import GHC.Tc.Utils.Monad +import GHC.Tc.Utils.Instantiate( freshenTyVarBndrs, freshenCoVarBndrsX ) import GHC.Types.SrcLoc as SrcLoc import GHC.Core.TyCon import GHC.Tc.Utils.TcType @@ -35,7 +36,6 @@ import GHC.Data.Maybe import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs import GHC.Core.TyCo.Ppr ( pprWithExplicitKindsWhen ) -import GHC.Tc.Utils.TcMType import GHC.Types.Name import GHC.Utils.Panic import GHC.Types.Var.Set ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -31,11 +31,12 @@ where import GHC.Prelude import GHC.Hs -import GHC.Tc.Utils.Env import GHC.Tc.Gen.Sig import GHC.Tc.Types.Evidence ( idHsWrapper ) import GHC.Tc.Gen.Bind +import GHC.Tc.Utils.Env import GHC.Tc.Utils.Unify +import GHC.Tc.Utils.Instantiate( tcSuperSkolTyVars ) import GHC.Tc.Gen.HsType import GHC.Tc.Utils.TcMType import GHC.Core.Type ( piResultTys ) ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -16,6 +16,12 @@ module GHC.Tc.Utils.Instantiate ( instCall, instDFunType, instStupidTheta, instTyVarsWith, newWanted, newWanteds, + tcInstType, tcInstTypeBndrs, + tcInstSkolTyVars, tcInstSkolTyVarsX, tcInstSkolTyVarsAt, + tcSkolDFunType, tcSuperSkolTyVars, tcInstSuperSkolTyVarsX, + + freshenTyVarBndrs, freshenCoVarBndrsX, + tcInstInvisibleTyBindersN, tcInstInvisibleTyBinders, tcInstInvisibleTyBinder, newOverloadedLit, mkOverLit, @@ -63,7 +69,7 @@ import GHC.Types.Id.Make( mkDictFunId ) import GHC.Core( Expr(..) ) -- For the Coercion constructor import GHC.Types.Id import GHC.Types.Name -import GHC.Types.Var ( EvVar, tyVarName, VarBndr(..) ) +import GHC.Types.Var import GHC.Core.DataCon import GHC.Types.Var.Env import GHC.Builtin.Names @@ -74,7 +80,7 @@ import GHC.Utils.Outputable import GHC.Types.Basic ( TypeOrKind(..) ) import qualified GHC.LanguageExtensions as LangExt -import Data.List ( sortBy ) +import Data.List ( sortBy, mapAccumL ) import Control.Monad( unless ) import Data.Function ( on ) @@ -451,15 +457,196 @@ mkEqBoxTy co ty1 ty2 mkTyConApp (promoteDataCon eqDataCon) [k, ty1, ty2, mkCoercionTy co] where k = tcTypeKind ty1 -{- -************************************************************************ +{- ********************************************************************* * * - Literals + SkolemTvs (immutable) * * -************************************************************************ +********************************************************************* -} +tc_inst_internal :: ([VarBndr TyVar flag] -> TcM (TCvSubst, [VarBndr TcTyVar flag])) + -- ^ How to instantiate the type variables + -> [VarBndr TyVar flag] -- ^ Type variable to instantiate + -> Type -- ^ rho + -> TcM ([(Name, VarBndr TcTyVar flag)], TcThetaType, TcType) -- ^ Result + -- (type vars, preds (incl equalities), rho) +tc_inst_internal _inst_tyvars [] rho = + let -- There may be overloading despite no type variables; + -- (?x :: Int) => Int -> Int + (theta, tau) = tcSplitPhiTy rho + in + return ([], theta, tau) +tc_inst_internal inst_tyvars tyvars rho = + do { (subst, tyvars') <- inst_tyvars tyvars + ; let (theta, tau) = tcSplitPhiTy (substTyAddInScope subst rho) + tv_prs = map (tyVarName . binderVar) tyvars `zip` tyvars' + ; return (tv_prs, theta, tau) } + +tcInstType :: ([TyVar] -> TcM (TCvSubst, [TcTyVar])) + -- ^ How to instantiate the type variables + -> Id -- ^ Type to instantiate + -> TcM ([(Name, TcTyVar)], TcThetaType, TcType) -- ^ Result + -- (type vars, preds (incl equalities), rho) +tcInstType inst_tyvars id = + do { let (tyvars, rho) = splitForAllTys (idType id) + tyvars' = mkTyVarBinders () tyvars + ; (tv_prs, preds, rho) <- tc_inst_internal inst_tyvar_bndrs tyvars' rho + ; let tv_prs' = map (\(name, bndr) -> (name, binderVar bndr)) tv_prs + ; return (tv_prs', preds, rho) } + where + inst_tyvar_bndrs :: [VarBndr TyVar ()] -> TcM (TCvSubst, [VarBndr TcTyVar ()]) + inst_tyvar_bndrs bndrs = do { (subst, tvs) <- inst_tyvars $ binderVars bndrs + ; let tvbnds = map (\tv -> Bndr tv ()) tvs + ; return (subst, tvbnds) } + +tcInstTypeBndrs :: ([VarBndr TyVar Specificity] -> TcM (TCvSubst, [VarBndr TcTyVar Specificity])) + -- ^ How to instantiate the type variables + -> Id -- ^ Type to instantiate + -> TcM ([(Name, VarBndr TcTyVar Specificity)], TcThetaType, TcType) -- ^ Result + -- (type vars, preds (incl equalities), rho) +tcInstTypeBndrs inst_tyvars id = + let (tyvars, rho) = splitForAllTysInvis (idType id) + in tc_inst_internal inst_tyvars tyvars rho + +tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType) +-- Instantiate a type signature with skolem constants. +-- We could give them fresh names, but no need to do so +tcSkolDFunType dfun + = do { (tv_prs, theta, tau) <- tcInstType tcInstSuperSkolTyVars dfun + ; return (map snd tv_prs, theta, tau) } + +tcSuperSkolTyVars :: [TyVar] -> (TCvSubst, [TcTyVar]) +-- Make skolem constants, but do *not* give them new names, as above +-- Moreover, make them "super skolems"; see comments with superSkolemTv +-- see Note [Kind substitution when instantiating] +-- Precondition: tyvars should be ordered by scoping +tcSuperSkolTyVars = mapAccumL tcSuperSkolTyVar emptyTCvSubst + +tcSuperSkolTyVar :: TCvSubst -> TyVar -> (TCvSubst, TcTyVar) +tcSuperSkolTyVar subst tv + = (extendTvSubstWithClone subst tv new_tv, new_tv) + where + kind = substTyUnchecked subst (tyVarKind tv) + new_tv = mkTcTyVar (tyVarName tv) kind superSkolemTv + +-- | Given a list of @['TyVar']@, skolemize the type variables, +-- returning a substitution mapping the original tyvars to the +-- skolems, and the list of newly bound skolems. +tcInstSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSkolTyVars = tcInstSkolTyVarsX emptyTCvSubst + +tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSkolTyVarsX = tcInstSkolTyVarsPushLevel False + +tcInstSuperSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSuperSkolTyVars = tcInstSuperSkolTyVarsX emptyTCvSubst + +tcInstSuperSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSuperSkolTyVarsX subst = tcInstSkolTyVarsPushLevel True subst + +tcInstSkolTyVarsPushLevel :: Bool -> TCvSubst -> [TyVar] + -> TcM (TCvSubst, [TcTyVar]) +-- Skolemise one level deeper, hence pushTcLevel +-- See Note [Skolemising type variables] +tcInstSkolTyVarsPushLevel overlappable subst tvs + = do { tc_lvl <- getTcLevel + ; let pushed_lvl = pushTcLevel tc_lvl + ; tcInstSkolTyVarsAt pushed_lvl overlappable subst tvs } + +tcInstSkolTyVarsAt :: TcLevel -> Bool + -> TCvSubst -> [TyVar] + -> TcM (TCvSubst, [TcTyVar]) +tcInstSkolTyVarsAt lvl overlappable subst tvs + = freshenTyCoVarsX new_skol_tv subst tvs + where + details = SkolemTv lvl overlappable + new_skol_tv name kind = mkTcTyVar name kind details + +------------------ +freshenTyVarBndrs :: [TyVar] -> TcM (TCvSubst, [TyVar]) +-- ^ Give fresh uniques to a bunch of TyVars, but they stay +-- as TyVars, rather than becoming TcTyVars +-- Used in 'GHC.Tc.Instance.Family.newFamInst', and 'GHC.Tc.Utils.Instantiate.newClsInst' +freshenTyVarBndrs = freshenTyCoVars mkTyVar + +freshenCoVarBndrsX :: TCvSubst -> [CoVar] -> TcM (TCvSubst, [CoVar]) +-- ^ Give fresh uniques to a bunch of CoVars +-- Used in "GHC.Tc.Instance.Family.newFamInst" +freshenCoVarBndrsX subst = freshenTyCoVarsX mkCoVar subst + +------------------ +freshenTyCoVars :: (Name -> Kind -> TyCoVar) + -> [TyVar] -> TcM (TCvSubst, [TyCoVar]) +freshenTyCoVars mk_tcv = freshenTyCoVarsX mk_tcv emptyTCvSubst + +freshenTyCoVarsX :: (Name -> Kind -> TyCoVar) + -> TCvSubst -> [TyCoVar] + -> TcM (TCvSubst, [TyCoVar]) +freshenTyCoVarsX mk_tcv = mapAccumLM (freshenTyCoVarX mk_tcv) + +freshenTyCoVarX :: (Name -> Kind -> TyCoVar) + -> TCvSubst -> TyCoVar -> TcM (TCvSubst, TyCoVar) +-- This a complete freshening operation: +-- the skolems have a fresh unique, and a location from the monad +-- See Note [Skolemising type variables] +freshenTyCoVarX mk_tcv subst tycovar + = do { loc <- getSrcSpanM + ; uniq <- newUnique + ; let old_name = tyVarName tycovar + new_name = mkInternalName uniq (getOccName old_name) loc + new_kind = substTyUnchecked subst (tyVarKind tycovar) + new_tcv = mk_tcv new_name new_kind + subst1 = extendTCvSubstWithClone subst tycovar new_tcv + ; return (subst1, new_tcv) } + +{- Note [Skolemising type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The tcInstSkolTyVars family of functions instantiate a list of TyVars +to fresh skolem TcTyVars. Important notes: + +a) Level allocation. We generally skolemise /before/ calling + pushLevelAndCaptureConstraints. So we want their level to the level + of the soon-to-be-created implication, which has a level ONE HIGHER + than the current level. Hence the pushTcLevel. It feels like a + slight hack. + +b) The [TyVar] should be ordered (kind vars first) + See Note [Kind substitution when instantiating] + +c) It's a complete freshening operation: the skolems have a fresh + unique, and a location from the monad + +d) The resulting skolems are + non-overlappable for tcInstSkolTyVars, + but overlappable for tcInstSuperSkolTyVars + See GHC.Tc.Deriv.Infer Note [Overlap and deriving] for an example + of where this matters. + +Note [Kind substitution when instantiating] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When we instantiate a bunch of kind and type variables, first we +expect them to be topologically sorted. +Then we have to instantiate the kind variables, build a substitution +from old variables to the new variables, then instantiate the type +variables substituting the original kind. + +Exemple: If we want to instantiate + [(k1 :: *), (k2 :: *), (a :: k1 -> k2), (b :: k1)] +we want + [(?k1 :: *), (?k2 :: *), (?a :: ?k1 -> ?k2), (?b :: ?k1)] +instead of the buggous + [(?k1 :: *), (?k2 :: *), (?a :: k1 -> k2), (?b :: k1)] -} +{- ********************************************************************* +* * + Literals +* * +********************************************************************* -} + {- In newOverloadedLit we convert directly to an Int or Integer if we know that's what we want. This may save some time, by not @@ -474,8 +661,6 @@ newOverloadedLit :: HsOverLit GhcRn newOverloadedLit lit@(OverLit { ol_val = val, ol_ext = rebindable }) res_ty | not rebindable - -- all built-in overloaded lits are tau-types, so we can just - -- tauify the ExpType = do { res_ty <- expTypeToType res_ty ; dflags <- getDynFlags ; let platform = targetPlatform dflags ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -31,15 +31,6 @@ module GHC.Tc.Utils.TcMType ( newTauTvDetailsAtLevel, newMetaDetails, newMetaTyVarName, isFilledMetaTyVar_maybe, isFilledMetaTyVar, isUnfilledMetaTyVar, - -------------------------------- - -- Expected types - ExpType(..), ExpSigmaType, ExpRhoType, - mkCheckExpType, - newInferExpType, - readExpType, readExpType_maybe, - expTypeToType, checkingExpType_maybe, checkingExpType, - tauifyExpType, inferResultToType, - -------------------------------- -- Creating new evidence variables newEvVar, newEvVars, newDict, @@ -61,11 +52,15 @@ module GHC.Tc.Utils.TcMType ( newMetaTyVarTyVars, newMetaTyVarTyVarX, newTyVarTyVar, cloneTyVarTyVar, newPatSigTyVar, newSkolemTyVar, newWildCardX, - tcInstType, tcInstTypeBndrs, - tcInstSkolTyVars, tcInstSkolTyVarsX, tcInstSkolTyVarsAt, - tcSkolDFunType, tcSuperSkolTyVars, tcInstSuperSkolTyVarsX, - freshenTyVarBndrs, freshenCoVarBndrsX, + -------------------------------- + -- Expected types + ExpType(..), ExpSigmaType, ExpRhoType, + mkCheckExpType, newInferExpType, tcInfer, + readExpType, readExpType_maybe, readScaledExpType, + expTypeToType, scaledExpTypeToType, + checkingExpType_maybe, checkingExpType, + inferResultToType, fillInferResult, promoteTcType, -------------------------------- -- Zonking and tidying @@ -99,6 +94,8 @@ module GHC.Tc.Utils.TcMType ( -- friends: import GHC.Prelude +import {-# SOURCE #-} GHC.Tc.Utils.Unify( unifyType, unifyKind ) + import GHC.Core.TyCo.Rep import GHC.Core.TyCo.Ppr import GHC.Tc.Utils.TcType @@ -133,7 +130,6 @@ import GHC.Types.Basic ( TypeOrKind(..) ) import Control.Monad import GHC.Data.Maybe -import Data.List ( mapAccumL ) import Control.Arrow ( second ) import qualified Data.Semigroup as Semi @@ -387,16 +383,14 @@ checkCoercionHole cv co | otherwise = False -{- -************************************************************************ +{- ********************************************************************** * - Expected types + ExpType functions * -************************************************************************ - -Note [ExpType] -~~~~~~~~~~~~~~ +********************************************************************** -} +{- Note [ExpType] +~~~~~~~~~~~~~~~~~ An ExpType is used as the "expected type" when type-checking an expression. An ExpType can hold a "hole" that can be filled in by the type-checker. This allows us to have one tcExpr that works in both checking mode and @@ -426,14 +420,12 @@ Consider This is a classic untouchable-variable / ambiguous GADT return type scenario. But, with ExpTypes, we'll be inferring the type of the RHS. -And, because there is only one branch of the case, we won't trigger -Note [Case branches must never infer a non-tau type] of GHC.Tc.Gen.Match. We thus must track a TcLevel in an Inferring ExpType. If we try to -fill the ExpType and find that the TcLevels don't work out, we -fill the ExpType with a tau-tv at the low TcLevel, hopefully to -be worked out later by some means. This is triggered in -test gadt/gadt-escape1. +fill the ExpType and find that the TcLevels don't work out, we fill +the ExpType with a tau-tv at the low TcLevel, hopefully to be worked +out later by some means -- see fillInferResult, and Note [fillInferResult] +This behaviour triggered in test gadt/gadt-escape1. -} -- actual data definition is in GHC.Tc.Utils.TcType @@ -453,6 +445,12 @@ readExpType_maybe :: ExpType -> TcM (Maybe TcType) readExpType_maybe (Check ty) = return (Just ty) readExpType_maybe (Infer (IR { ir_ref = ref})) = readMutVar ref +-- | Same as readExpType, but for Scaled ExpTypes +readScaledExpType :: Scaled ExpType -> TcM (Scaled Type) +readScaledExpType (Scaled m exp_ty) + = do { ty <- readExpType exp_ty + ; return (Scaled m ty) } + -- | Extract a type out of an ExpType. Otherwise, panics. readExpType :: ExpType -> TcM TcType readExpType exp_ty @@ -472,12 +470,10 @@ checkingExpType :: String -> ExpType -> TcType checkingExpType _ (Check ty) = ty checkingExpType err et = pprPanic "checkingExpType" (text err $$ ppr et) -tauifyExpType :: ExpType -> TcM ExpType --- ^ Turn a (Infer hole) type into a (Check alpha), --- where alpha is a fresh unification variable -tauifyExpType (Check ty) = return (Check ty) -- No-op for (Check ty) -tauifyExpType (Infer inf_res) = do { ty <- inferResultToType inf_res - ; return (Check ty) } +scaledExpTypeToType :: Scaled ExpType -> TcM (Scaled TcType) +scaledExpTypeToType (Scaled m exp_ty) + = do { ty <- expTypeToType exp_ty + ; return (Scaled m ty) } -- | Extracts the expected type if there is one, or generates a new -- TauTv if there isn't. @@ -488,209 +484,278 @@ expTypeToType (Infer inf_res) = inferResultToType inf_res inferResultToType :: InferResult -> TcM Type inferResultToType (IR { ir_uniq = u, ir_lvl = tc_lvl , ir_ref = ref }) - = do { rr <- newMetaTyVarTyAtLevel tc_lvl runtimeRepTy - ; tau <- newMetaTyVarTyAtLevel tc_lvl (tYPE rr) - -- See Note [TcLevel of ExpType] - ; writeMutVar ref (Just tau) + = do { mb_inferred_ty <- readTcRef ref + ; tau <- case mb_inferred_ty of + Just ty -> do { ensureMonoType ty + -- See Note [inferResultToType] + ; return ty } + Nothing -> do { rr <- newMetaTyVarTyAtLevel tc_lvl runtimeRepTy + ; tau <- newMetaTyVarTyAtLevel tc_lvl (tYPE rr) + -- See Note [TcLevel of ExpType] + ; writeMutVar ref (Just tau) + ; return tau } ; traceTc "Forcing ExpType to be monomorphic:" (ppr u <+> text ":=" <+> ppr tau) ; return tau } +{- Note [inferResultToType] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +expTypeToType and inferResultType convert an InferResult to a monotype. +It must be a monotype because if the InferResult isn't already filled in, +we fill it in with a unification variable (hence monotype). So to preserve +order-independence we check for mono-type-ness even if it *is* filled in +already. + +See also Note [TcLevel of ExpType] above, and +Note [fillInferResult]. +-} + +-- | Infer a type using a fresh ExpType +-- See also Note [ExpType] in "GHC.Tc.Utils.TcMType" +tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) +tcInfer tc_check + = do { res_ty <- newInferExpType + ; result <- tc_check res_ty + ; res_ty <- readExpType res_ty + ; return (result, res_ty) } + +fillInferResult :: TcType -> InferResult -> TcM TcCoercionN +-- If co = fillInferResult t1 t2 +-- => co :: t1 ~ t2 +-- See Note [fillInferResult] +fillInferResult act_res_ty (IR { ir_uniq = u, ir_lvl = res_lvl + , ir_ref = ref }) + = do { mb_exp_res_ty <- readTcRef ref + ; case mb_exp_res_ty of + Just exp_res_ty + -> do { traceTc "Joining inferred ExpType" $ + ppr u <> colon <+> ppr act_res_ty <+> char '~' <+> ppr exp_res_ty + ; cur_lvl <- getTcLevel + ; unless (cur_lvl `sameDepthAs` res_lvl) $ + ensureMonoType act_res_ty + ; unifyType Nothing act_res_ty exp_res_ty } + Nothing + -> do { traceTc "Filling inferred ExpType" $ + ppr u <+> text ":=" <+> ppr act_res_ty + ; (prom_co, act_res_ty) <- promoteTcType res_lvl act_res_ty + ; writeTcRef ref (Just act_res_ty) + ; return prom_co } + } + + +{- Note [fillInferResult] +~~~~~~~~~~~~~~~~~~~~~~~~~ +When inferring, we use fillInferResult to "fill in" the hole in InferResult + data InferResult = IR { ir_uniq :: Unique + , ir_lvl :: TcLevel + , ir_ref :: IORef (Maybe TcType) } + +There are two things to worry about: + +1. What if it is under a GADT or existential pattern match? + - GADTs: a unification variable (and Infer's hole is similar) is untouchable + - Existentials: be careful about skolem-escape + +2. What if it is filled in more than once? E.g. multiple branches of a case + case e of + T1 -> e1 + T2 -> e2 + +Our typing rules are: + +* The RHS of a existential or GADT alternative must always be a + monotype, regardless of the number of alternatives. + +* Multiple non-existential/GADT branches can have (the same) + higher rank type (#18412). E.g. this is OK: + case e of + True -> hr + False -> hr + where hr:: (forall a. a->a) -> Int + c.f. Section 7.1 of "Practical type inference for arbitrary-rank types" + We use choice (2) in that Section. + (GHC 8.10 and earlier used choice (1).) + + But note that + case e of + True -> hr + False -> \x -> hr x + will fail, because we still /infer/ both branches, so the \x will get + a (monotype) unification variable, which will fail to unify with + (forall a. a->a) + +For (1) we can detect the GADT/existential situation by seeing that +the current TcLevel is greater than that stored in ir_lvl of the Infer +ExpType. We bump the level whenever we go past a GADT/existential match. + +Then, before filling the hole use promoteTcType to promote the type +to the outer ir_lvl. promoteTcType does this + - create a fresh unification variable alpha at level ir_lvl + - emits an equality alpha[ir_lvl] ~ ty + - fills the hole with alpha +That forces the type to be a monotype (since unification variables can +only unify with monotypes); and catches skolem-escapes because the +alpha is untouchable until the equality floats out. + +For (2), we simply look to see if the hole is filled already. + - if not, we promote (as above) and fill the hole + - if it is filled, we simply unify with the type that is + already there + +There is one wrinkle. Suppose we have + case e of + T1 -> e1 :: (forall a. a->a) -> Int + G2 -> e2 +where T1 is not GADT or existential, but G2 is a GADT. Then supppose the +T1 alternative fills the hole with (forall a. a->a) -> Int, which is fine. +But now the G2 alternative must not *just* unify with that else we'd risk +allowing through (e2 :: (forall a. a->a) -> Int). If we'd checked G2 first +we'd have filled the hole with a unification variable, which enforces a +monotype. + +So if we check G2 second, we still want to emit a constraint that restricts +the RHS to be a monotype. This is done by ensureMonoType, and it works +by simply generating a constraint (alpha ~ ty), where alpha is a fresh +unification variable. We discard the evidence. + +-} {- ********************************************************************* * * - SkolemTvs (immutable) + Promoting types * * ********************************************************************* -} -tc_inst_internal :: ([VarBndr TyVar flag] -> TcM (TCvSubst, [VarBndr TcTyVar flag])) - -- ^ How to instantiate the type variables - -> [VarBndr TyVar flag] -- ^ Type variable to instantiate - -> Type -- ^ rho - -> TcM ([(Name, VarBndr TcTyVar flag)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tc_inst_internal _inst_tyvars [] rho = - let -- There may be overloading despite no type variables; - -- (?x :: Int) => Int -> Int - (theta, tau) = tcSplitPhiTy rho - in - return ([], theta, tau) -tc_inst_internal inst_tyvars tyvars rho = - do { (subst, tyvars') <- inst_tyvars tyvars - ; let (theta, tau) = tcSplitPhiTy (substTyAddInScope subst rho) - tv_prs = map (tyVarName . binderVar) tyvars `zip` tyvars' - ; return (tv_prs, theta, tau) } - -tcInstType :: ([TyVar] -> TcM (TCvSubst, [TcTyVar])) - -- ^ How to instantiate the type variables - -> Id -- ^ Type to instantiate - -> TcM ([(Name, TcTyVar)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tcInstType inst_tyvars id = - do { let (tyvars, rho) = splitForAllTys (idType id) - tyvars' = mkTyVarBinders () tyvars - ; (tv_prs, preds, rho) <- tc_inst_internal inst_tyvar_bndrs tyvars' rho - ; let tv_prs' = map (\(name, bndr) -> (name, binderVar bndr)) tv_prs - ; return (tv_prs', preds, rho) } - where - inst_tyvar_bndrs :: [VarBndr TyVar ()] -> TcM (TCvSubst, [VarBndr TcTyVar ()]) - inst_tyvar_bndrs bndrs = do { (subst, tvs) <- inst_tyvars $ binderVars bndrs - ; let tvbnds = map (\tv -> Bndr tv ()) tvs - ; return (subst, tvbnds) } - -tcInstTypeBndrs :: ([VarBndr TyVar Specificity] -> TcM (TCvSubst, [VarBndr TcTyVar Specificity])) - -- ^ How to instantiate the type variables - -> Id -- ^ Type to instantiate - -> TcM ([(Name, VarBndr TcTyVar Specificity)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tcInstTypeBndrs inst_tyvars id = - let (tyvars, rho) = splitForAllTysInvis (idType id) - in tc_inst_internal inst_tyvars tyvars rho - -tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType) --- Instantiate a type signature with skolem constants. --- We could give them fresh names, but no need to do so -tcSkolDFunType dfun - = do { (tv_prs, theta, tau) <- tcInstType tcInstSuperSkolTyVars dfun - ; return (map snd tv_prs, theta, tau) } - -tcSuperSkolTyVars :: [TyVar] -> (TCvSubst, [TcTyVar]) --- Make skolem constants, but do *not* give them new names, as above --- Moreover, make them "super skolems"; see comments with superSkolemTv --- see Note [Kind substitution when instantiating] --- Precondition: tyvars should be ordered by scoping -tcSuperSkolTyVars = mapAccumL tcSuperSkolTyVar emptyTCvSubst - -tcSuperSkolTyVar :: TCvSubst -> TyVar -> (TCvSubst, TcTyVar) -tcSuperSkolTyVar subst tv - = (extendTvSubstWithClone subst tv new_tv, new_tv) - where - kind = substTyUnchecked subst (tyVarKind tv) - new_tv = mkTcTyVar (tyVarName tv) kind superSkolemTv - --- | Given a list of @['TyVar']@, skolemize the type variables, --- returning a substitution mapping the original tyvars to the --- skolems, and the list of newly bound skolems. -tcInstSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSkolTyVars = tcInstSkolTyVarsX emptyTCvSubst - -tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSkolTyVarsX = tcInstSkolTyVarsPushLevel False - -tcInstSuperSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSuperSkolTyVars = tcInstSuperSkolTyVarsX emptyTCvSubst - -tcInstSuperSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSuperSkolTyVarsX subst = tcInstSkolTyVarsPushLevel True subst - -tcInstSkolTyVarsPushLevel :: Bool -> TCvSubst -> [TyVar] - -> TcM (TCvSubst, [TcTyVar]) --- Skolemise one level deeper, hence pushTcLevel --- See Note [Skolemising type variables] -tcInstSkolTyVarsPushLevel overlappable subst tvs - = do { tc_lvl <- getTcLevel - ; let pushed_lvl = pushTcLevel tc_lvl - ; tcInstSkolTyVarsAt pushed_lvl overlappable subst tvs } - -tcInstSkolTyVarsAt :: TcLevel -> Bool - -> TCvSubst -> [TyVar] - -> TcM (TCvSubst, [TcTyVar]) -tcInstSkolTyVarsAt lvl overlappable subst tvs - = freshenTyCoVarsX new_skol_tv subst tvs +ensureMonoType :: TcType -> TcM () +ensureMonoType res_ty + | isTauTy res_ty -- Doesn't need zonking or anything + = return () + | otherwise + = do { mono_ty <- newOpenFlexiTyVarTy + ; let eq_orig = TypeEqOrigin { uo_actual = res_ty + , uo_expected = mono_ty + , uo_thing = Nothing + , uo_visible = False } + + ; _co <- emitWantedEq eq_orig TypeLevel Nominal res_ty mono_ty + ; return () } + +promoteTcType :: TcLevel -> TcType -> TcM (TcCoercion, TcType) +-- See Note [Promoting a type] +-- See also Note [fillInferResult] +-- promoteTcType level ty = (co, ty') +-- * Returns ty' whose max level is just 'level' +-- and whose kind is ~# to the kind of 'ty' +-- and whose kind has form TYPE rr +-- * and co :: ty ~ ty' +-- * and emits constraints to justify the coercion +promoteTcType dest_lvl ty + = do { cur_lvl <- getTcLevel + ; if (cur_lvl `sameDepthAs` dest_lvl) + then dont_promote_it + else promote_it } where - details = SkolemTv lvl overlappable - new_skol_tv name kind = mkTcTyVar name kind details - ------------------- -freshenTyVarBndrs :: [TyVar] -> TcM (TCvSubst, [TyVar]) --- ^ Give fresh uniques to a bunch of TyVars, but they stay --- as TyVars, rather than becoming TcTyVars --- Used in 'GHC.Tc.Instance.Family.newFamInst', and 'GHC.Tc.Utils.Instantiate.newClsInst' -freshenTyVarBndrs = freshenTyCoVars mkTyVar - -freshenCoVarBndrsX :: TCvSubst -> [CoVar] -> TcM (TCvSubst, [CoVar]) --- ^ Give fresh uniques to a bunch of CoVars --- Used in "GHC.Tc.Instance.Family.newFamInst" -freshenCoVarBndrsX subst = freshenTyCoVarsX mkCoVar subst - ------------------- -freshenTyCoVars :: (Name -> Kind -> TyCoVar) - -> [TyVar] -> TcM (TCvSubst, [TyCoVar]) -freshenTyCoVars mk_tcv = freshenTyCoVarsX mk_tcv emptyTCvSubst - -freshenTyCoVarsX :: (Name -> Kind -> TyCoVar) - -> TCvSubst -> [TyCoVar] - -> TcM (TCvSubst, [TyCoVar]) -freshenTyCoVarsX mk_tcv = mapAccumLM (freshenTyCoVarX mk_tcv) - -freshenTyCoVarX :: (Name -> Kind -> TyCoVar) - -> TCvSubst -> TyCoVar -> TcM (TCvSubst, TyCoVar) --- This a complete freshening operation: --- the skolems have a fresh unique, and a location from the monad --- See Note [Skolemising type variables] -freshenTyCoVarX mk_tcv subst tycovar - = do { loc <- getSrcSpanM - ; uniq <- newUnique - ; let old_name = tyVarName tycovar - new_name = mkInternalName uniq (getOccName old_name) loc - new_kind = substTyUnchecked subst (tyVarKind tycovar) - new_tcv = mk_tcv new_name new_kind - subst1 = extendTCvSubstWithClone subst tycovar new_tcv - ; return (subst1, new_tcv) } - -{- Note [Skolemising type variables] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The tcInstSkolTyVars family of functions instantiate a list of TyVars -to fresh skolem TcTyVars. Important notes: - -a) Level allocation. We generally skolemise /before/ calling - pushLevelAndCaptureConstraints. So we want their level to the level - of the soon-to-be-created implication, which has a level ONE HIGHER - than the current level. Hence the pushTcLevel. It feels like a - slight hack. - -b) The [TyVar] should be ordered (kind vars first) - See Note [Kind substitution when instantiating] - -c) It's a complete freshening operation: the skolems have a fresh - unique, and a location from the monad - -d) The resulting skolems are - non-overlappable for tcInstSkolTyVars, - but overlappable for tcInstSuperSkolTyVars - See GHC.Tc.Deriv.Infer Note [Overlap and deriving] for an example - of where this matters. - -Note [Kind substitution when instantiating] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we instantiate a bunch of kind and type variables, first we -expect them to be topologically sorted. -Then we have to instantiate the kind variables, build a substitution -from old variables to the new variables, then instantiate the type -variables substituting the original kind. - -Exemple: If we want to instantiate - [(k1 :: *), (k2 :: *), (a :: k1 -> k2), (b :: k1)] -we want - [(?k1 :: *), (?k2 :: *), (?a :: ?k1 -> ?k2), (?b :: ?k1)] -instead of the buggous - [(?k1 :: *), (?k2 :: *), (?a :: k1 -> k2), (?b :: k1)] + promote_it :: TcM (TcCoercion, TcType) + promote_it -- Emit a constraint (alpha :: TYPE rr) ~ ty + -- where alpha and rr are fresh and from level dest_lvl + = do { rr <- newMetaTyVarTyAtLevel dest_lvl runtimeRepTy + ; prom_ty <- newMetaTyVarTyAtLevel dest_lvl (tYPE rr) + ; let eq_orig = TypeEqOrigin { uo_actual = ty + , uo_expected = prom_ty + , uo_thing = Nothing + , uo_visible = False } + + ; co <- emitWantedEq eq_orig TypeLevel Nominal ty prom_ty + ; return (co, prom_ty) } + + dont_promote_it :: TcM (TcCoercion, TcType) + dont_promote_it -- Check that ty :: TYPE rr, for some (fresh) rr + = do { res_kind <- newOpenTypeKind + ; ki_co <- unifyKind Nothing (tcTypeKind ty) res_kind + ; let co = mkTcGReflRightCo Nominal ty ki_co + ; return (co, ty `mkCastTy` ki_co) } + +{- Note [Promoting a type] +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider (#12427) + + data T where + MkT :: (Int -> Int) -> a -> T + + h y = case y of MkT v w -> v + +We'll infer the RHS type with an expected type ExpType of + (IR { ir_lvl = l, ir_ref = ref, ... ) +where 'l' is the TcLevel of the RHS of 'h'. Then the MkT pattern +match will increase the level, so we'll end up in tcSubType, trying to +unify the type of v, + v :: Int -> Int +with the expected type. But this attempt takes place at level (l+1), +rightly so, since v's type could have mentioned existential variables, +(like w's does) and we want to catch that. + +So we + - create a new meta-var alpha[l+1] + - fill in the InferRes ref cell 'ref' with alpha + - emit an equality constraint, thus + [W] alpha[l+1] ~ (Int -> Int) + +That constraint will float outwards, as it should, unless v's +type mentions a skolem-captured variable. + +This approach fails if v has a higher rank type; see +Note [Promotion and higher rank types] + + +Note [Promotion and higher rank types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If v had a higher-rank type, say v :: (forall a. a->a) -> Int, +then we'd emit an equality + [W] alpha[l+1] ~ ((forall a. a->a) -> Int) +which will sadly fail because we can't unify a unification variable +with a polytype. But there is nothing really wrong with the program +here. + +We could just about solve this by "promote the type" of v, to expose +its polymorphic "shape" while still leaving constraints that will +prevent existential escape. But we must be careful! Exposing +the "shape" of the type is precisely what we must NOT do under +a GADT pattern match! So in this case we might promote the type +to + (forall a. a->a) -> alpha[l+1] +and emit the constraint + [W] alpha[l+1] ~ Int +Now the promoted type can fill the ref cell, while the emitted +equality can float or not, according to the usual rules. + +But that's not quite right! We are exposing the arrow! We could +deal with that too: + (forall a. mu[l+1] a a) -> alpha[l+1] +with constraints + [W] alpha[l+1] ~ Int + [W] mu[l+1] ~ (->) +Here we abstract over the '->' inside the forall, in case that +is subject to an equality constraint from a GADT match. + +Note that we kept the outer (->) because that's part of +the polymorphic "shape". And because of impredicativity, +GADT matches can't give equalities that affect polymorphic +shape. + +This reasoning just seems too complicated, so I decided not +to do it. These higher-rank notes are just here to record +the thinking. +-} -************************************************************************ +{- ********************************************************************* * * MetaTvs (meta type variables; mutable) * * -************************************************************************ --} +********************************************************************* -} -{- -Note [TyVarTv] -~~~~~~~~~~~~ +{- Note [TyVarTv] +~~~~~~~~~~~~~~~~~ A TyVarTv can unify with type *variables* only, including other TyVarTvs and skolems. Sometimes, they can unify with type variables that the user would ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -61,7 +61,6 @@ import GHC.Types.Name( isSystemName ) import GHC.Tc.Utils.Instantiate import GHC.Core.TyCon import GHC.Builtin.Types -import GHC.Builtin.Types.Prim( tYPE ) import GHC.Types.Var as Var import GHC.Types.Var.Set import GHC.Types.Var.Env @@ -571,10 +570,51 @@ tcSubTypeNC :: CtOrigin -- Used when instantiating -> TcM HsWrapper tcSubTypeNC inst_orig ctxt m_thing ty_actual res_ty = case res_ty of - Infer inf_res -> instantiateAndFillInferResult inst_orig ty_actual inf_res Check ty_expected -> tc_sub_type (unifyType m_thing) inst_orig ctxt ty_actual ty_expected + Infer inf_res -> do { (wrap, rho) <- topInstantiate inst_orig ty_actual + -- See Note [Instantiation of InferResult] + ; co <- fillInferResult rho inf_res + ; return (mkWpCastN co <.> wrap) } + +{- Note [Instantiation of InferResult] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We now always instantiate before filling in InferResult, so that +the result is a TcRhoType: see #17173 for discussion. + +For example: + +1. Consider + f x = (*) + We want to instantiate the type of (*) before returning, else we + will infer the type + f :: forall {a}. a -> forall b. Num b => b -> b -> b + This is surely confusing for users. + + And worse, the monomorphism restriction won't work properly. The MR is + dealt with in simplifyInfer, and simplifyInfer has no way of + instantiating. This could perhaps be worked around, but it may be + hard to know even when instantiation should happen. + +2. Another reason. Consider + f :: (?x :: Int) => a -> a + g y = let ?x = 3::Int in f + Here want to instantiate f's type so that the ?x::Int constraint + gets discharged by the enclosing implicit-parameter binding. + +3. Suppose one defines plus = (+). If we instantiate lazily, we will + infer plus :: forall a. Num a => a -> a -> a. However, the monomorphism + restriction compels us to infer + plus :: Integer -> Integer -> Integer + (or similar monotype). Indeed, the only way to know whether to apply + the monomorphism restriction at all is to instantiate + +There is one place where we don't want to instantiate eagerly, +namely in GHC.Tc.Module.tcRnExpr, which implements GHCi's :type +command. See Note [Implementing :type] in GHC.Tc.Module. +-} + --------------- tcSubTypeSigma :: UserTypeCtxt -> TcSigmaType -> TcSigmaType -> TcM HsWrapper -- External entry point, but no ExpTypes on either side @@ -768,213 +808,6 @@ tcEqMult origin w_actual w_expected = do ; coercion <- uType TypeLevel origin w_actual w_expected ; return $ if isReflCo coercion then WpHole else WpMultCoercion coercion } -{- ********************************************************************** -%* * - ExpType functions: tcInfer, instantiateAndFillInferResult -%* * -%********************************************************************* -} - --- | Infer a type using a fresh ExpType --- See also Note [ExpType] in "GHC.Tc.Utils.TcMType" -tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) -tcInfer tc_check - = do { res_ty <- newInferExpType - ; result <- tc_check res_ty - ; res_ty <- readExpType res_ty - ; return (result, res_ty) } - -instantiateAndFillInferResult :: CtOrigin -> TcType -> InferResult -> TcM HsWrapper --- If wrap = instantiateAndFillInferResult t1 t2 --- => wrap :: t1 ~> t2 --- See Note [Instantiation of InferResult] -instantiateAndFillInferResult orig ty inf_res - = do { (wrap, rho) <- topInstantiate orig ty - ; co <- fillInferResult rho inf_res - ; return (mkWpCastN co <.> wrap) } - -fillInferResult :: TcType -> InferResult -> TcM TcCoercionN --- If wrap = fillInferResult t1 t2 --- => wrap :: t1 ~> t2 -fillInferResult orig_ty (IR { ir_uniq = u, ir_lvl = res_lvl - , ir_ref = ref }) - = do { (ty_co, ty_to_fill_with) <- promoteTcType res_lvl orig_ty - - ; traceTc "Filling ExpType" $ - ppr u <+> text ":=" <+> ppr ty_to_fill_with - - ; when debugIsOn (check_hole ty_to_fill_with) - - ; writeTcRef ref (Just ty_to_fill_with) - - ; return ty_co } - where - check_hole ty -- Debug check only - = do { let ty_lvl = tcTypeLevel ty - ; MASSERT2( not (ty_lvl `strictlyDeeperThan` res_lvl), - ppr u $$ ppr res_lvl $$ ppr ty_lvl $$ - ppr ty <+> dcolon <+> ppr (tcTypeKind ty) $$ ppr orig_ty ) - ; cts <- readTcRef ref - ; case cts of - Just already_there -> pprPanic "writeExpType" - (vcat [ ppr u - , ppr ty - , ppr already_there ]) - Nothing -> return () } - -{- Note [Instantiation of InferResult] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We now always instantiate before filling in InferResult, so that -the result is a TcRhoType: see #17173 for discussion. - -For example: - -1. Consider - f x = (*) - We want to instantiate the type of (*) before returning, else we - will infer the type - f :: forall {a}. a -> forall b. Num b => b -> b -> b - This is surely confusing for users. - - And worse, the monomorphism restriction won't work properly. The MR is - dealt with in simplifyInfer, and simplifyInfer has no way of - instantiating. This could perhaps be worked around, but it may be - hard to know even when instantiation should happen. - -2. Another reason. Consider - f :: (?x :: Int) => a -> a - g y = let ?x = 3::Int in f - Here want to instantiate f's type so that the ?x::Int constraint - gets discharged by the enclosing implicit-parameter binding. - -3. Suppose one defines plus = (+). If we instantiate lazily, we will - infer plus :: forall a. Num a => a -> a -> a. However, the monomorphism - restriction compels us to infer - plus :: Integer -> Integer -> Integer - (or similar monotype). Indeed, the only way to know whether to apply - the monomorphism restriction at all is to instantiate - -There is one place where we don't want to instantiate eagerly, -namely in GHC.Tc.Module.tcRnExpr, which implements GHCi's :type -command. See Note [Implementing :type] in GHC.Tc.Module. - --} - -{- ********************************************************************* -* * - Promoting types -* * -********************************************************************* -} - -promoteTcType :: TcLevel -> TcType -> TcM (TcCoercion, TcType) --- See Note [Promoting a type] --- promoteTcType level ty = (co, ty') --- * Returns ty' whose max level is just 'level' --- and whose kind is ~# to the kind of 'ty' --- and whose kind has form TYPE rr --- * and co :: ty ~ ty' --- * and emits constraints to justify the coercion -promoteTcType dest_lvl ty - = do { cur_lvl <- getTcLevel - ; if (cur_lvl `sameDepthAs` dest_lvl) - then dont_promote_it - else promote_it } - where - promote_it :: TcM (TcCoercion, TcType) - promote_it -- Emit a constraint (alpha :: TYPE rr) ~ ty - -- where alpha and rr are fresh and from level dest_lvl - = do { rr <- newMetaTyVarTyAtLevel dest_lvl runtimeRepTy - ; prom_ty <- newMetaTyVarTyAtLevel dest_lvl (tYPE rr) - ; let eq_orig = TypeEqOrigin { uo_actual = ty - , uo_expected = prom_ty - , uo_thing = Nothing - , uo_visible = False } - - ; co <- emitWantedEq eq_orig TypeLevel Nominal ty prom_ty - ; return (co, prom_ty) } - - dont_promote_it :: TcM (TcCoercion, TcType) - dont_promote_it -- Check that ty :: TYPE rr, for some (fresh) rr - = do { res_kind <- newOpenTypeKind - ; let ty_kind = tcTypeKind ty - kind_orig = TypeEqOrigin { uo_actual = ty_kind - , uo_expected = res_kind - , uo_thing = Nothing - , uo_visible = False } - ; ki_co <- uType KindLevel kind_orig (tcTypeKind ty) res_kind - ; let co = mkTcGReflRightCo Nominal ty ki_co - ; return (co, ty `mkCastTy` ki_co) } - -{- Note [Promoting a type] -~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider (#12427) - - data T where - MkT :: (Int -> Int) -> a -> T - - h y = case y of MkT v w -> v - -We'll infer the RHS type with an expected type ExpType of - (IR { ir_lvl = l, ir_ref = ref, ... ) -where 'l' is the TcLevel of the RHS of 'h'. Then the MkT pattern -match will increase the level, so we'll end up in tcSubType, trying to -unify the type of v, - v :: Int -> Int -with the expected type. But this attempt takes place at level (l+1), -rightly so, since v's type could have mentioned existential variables, -(like w's does) and we want to catch that. - -So we - - create a new meta-var alpha[l+1] - - fill in the InferRes ref cell 'ref' with alpha - - emit an equality constraint, thus - [W] alpha[l+1] ~ (Int -> Int) - -That constraint will float outwards, as it should, unless v's -type mentions a skolem-captured variable. - -This approach fails if v has a higher rank type; see -Note [Promotion and higher rank types] - - -Note [Promotion and higher rank types] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If v had a higher-rank type, say v :: (forall a. a->a) -> Int, -then we'd emit an equality - [W] alpha[l+1] ~ ((forall a. a->a) -> Int) -which will sadly fail because we can't unify a unification variable -with a polytype. But there is nothing really wrong with the program -here. - -We could just about solve this by "promote the type" of v, to expose -its polymorphic "shape" while still leaving constraints that will -prevent existential escape. But we must be careful! Exposing -the "shape" of the type is precisely what we must NOT do under -a GADT pattern match! So in this case we might promote the type -to - (forall a. a->a) -> alpha[l+1] -and emit the constraint - [W] alpha[l+1] ~ Int -Now the promoted type can fill the ref cell, while the emitted -equality can float or not, according to the usual rules. - -But that's not quite right! We are exposing the arrow! We could -deal with that too: - (forall a. mu[l+1] a a) -> alpha[l+1] -with constraints - [W] alpha[l+1] ~ Int - [W] mu[l+1] ~ (->) -Here we abstract over the '->' inside the forall, in case that -is subject to an equality constraint from a GADT match. - -Note that we kept the outer (->) because that's part of -the polymorphic "shape". And because of impredicativity, -GADT matches can't give equalities that affect polymorphic -shape. - -This reasoning just seems too complicated, so I decided not -to do it. These higher-rank notes are just here to record -the thinking. --} {- ********************************************************************* * * ===================================== testsuite/tests/simplCore/should_compile/T17901.stdout ===================================== @@ -1,14 +1,14 @@ - (wombat1 [Occ=Once*!] :: T -> p) + (wombat1 [Occ=Once*!] :: T -> t) A -> wombat1 T17901.A; B -> wombat1 T17901.B; C -> wombat1 T17901.C - = \ (@p) (wombat1 :: T -> p) (x :: T) -> + = \ (@t) (wombat1 :: T -> t) (x :: T) -> case x of wild { __DEFAULT -> wombat1 wild } - Tmpl= \ (@p) (wombat2 [Occ=Once!] :: S -> p) (x [Occ=Once] :: S) -> + Tmpl= \ (@t) (wombat2 [Occ=Once!] :: S -> t) (x [Occ=Once] :: S) -> case x of wild [Occ=Once] { __DEFAULT -> wombat2 wild }}] - = \ (@p) (wombat2 :: S -> p) (x :: S) -> + = \ (@t) (wombat2 :: S -> t) (x :: S) -> case x of wild { __DEFAULT -> wombat2 wild } - Tmpl= \ (@p) (wombat3 [Occ=Once!] :: W -> p) (x [Occ=Once] :: W) -> + Tmpl= \ (@t) (wombat3 [Occ=Once!] :: W -> t) (x [Occ=Once] :: W) -> case x of wild [Occ=Once] { __DEFAULT -> wombat3 wild }}] - = \ (@p) (wombat3 :: W -> p) (x :: W) -> + = \ (@t) (wombat3 :: W -> t) (x :: W) -> case x of wild { __DEFAULT -> wombat3 wild } ===================================== testsuite/tests/typecheck/should_compile/T18412.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RankNTypes #-} + +module T18412 where + +hr :: (forall a. a -> a) -> () +hr _ = () + +foo x = case x of () -> hr + +-- This did not use to be allowed, because the +-- multiple branches have (the same) polytypes +-- Enhancement July 2020 +bar x = case x of True -> hr + False -> hr ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -716,3 +716,4 @@ test('T17775-viewpats-a', normal, compile, ['']) test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) test('T17775-viewpats-d', normal, compile_fail, ['']) +test('T18412', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T10619.stderr ===================================== @@ -1,13 +1,11 @@ -T10619.hs:9:15: error: - • Couldn't match type ‘p’ with ‘forall b. b -> b’ - Expected: p -> p - Actual: (forall a. a -> a) -> forall b. b -> b - ‘p’ is a rigid type variable bound by - the inferred type of foo :: p1 -> p -> p - at T10619.hs:(8,1)-(10,20) - • In the expression: - (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b +T10619.hs:10:14: error: + • Couldn't match type ‘p1’ with ‘forall a. a -> a’ + Expected: (forall a. a -> a) -> forall b. b -> b + Actual: p1 -> p1 + Cannot instantiate unification variable ‘p1’ + with a type involving polytypes: forall a. a -> a + • In the expression: \ y -> y In the expression: if True then ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) @@ -19,15 +17,13 @@ T10619.hs:9:15: error: ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) else \ y -> y - • Relevant bindings include - foo :: p1 -> p -> p (bound at T10619.hs:8:1) T10619.hs:14:15: error: • Couldn't match type ‘p’ with ‘forall a. a -> a’ Expected: p -> p Actual: (forall a. a -> a) -> forall b. b -> b ‘p’ is a rigid type variable bound by - the inferred type of bar :: p1 -> p -> p + the inferred type of bar :: p2 -> p -> p at T10619.hs:(12,1)-(14,66) • In the expression: (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b @@ -43,21 +39,16 @@ T10619.hs:14:15: error: else ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) • Relevant bindings include - bar :: p1 -> p -> p (bound at T10619.hs:12:1) + bar :: p2 -> p -> p (bound at T10619.hs:12:1) -T10619.hs:16:13: error: - • Couldn't match type ‘p’ with ‘forall b. b -> b’ - Expected: p -> p - Actual: (forall a. a -> a) -> forall b. b -> b - ‘p’ is a rigid type variable bound by - the inferred type of baz :: Bool -> p -> p - at T10619.hs:(16,1)-(17,19) - • In the expression: - (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b - In an equation for ‘baz’: - baz True = (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b - • Relevant bindings include - baz :: Bool -> p -> p (bound at T10619.hs:16:1) +T10619.hs:17:13: error: + • Couldn't match type ‘p0’ with ‘forall a. a -> a’ + Expected: (forall a. a -> a) -> forall b. b -> b + Actual: p0 -> p0 + Cannot instantiate unification variable ‘p0’ + with a type involving polytypes: forall a. a -> a + • In the expression: \ y -> y + In an equation for ‘baz’: baz False = \ y -> y T10619.hs:20:14: error: • Couldn't match type ‘p’ with ‘forall a. a -> a’ ===================================== testsuite/tests/typecheck/should_fail/tcfail002.stderr ===================================== @@ -1,8 +1,8 @@ tcfail002.hs:4:7: error: - • Couldn't match expected type ‘p’ with actual type ‘[p]’ + • Couldn't match expected type ‘a’ with actual type ‘[a]’ • In the expression: z In an equation for ‘c’: c z = z • Relevant bindings include - z :: [p] (bound at tcfail002.hs:4:3) - c :: [p] -> p (bound at tcfail002.hs:3:1) + z :: [a] (bound at tcfail002.hs:4:3) + c :: [a] -> a (bound at tcfail002.hs:3:1) ===================================== testsuite/tests/typecheck/should_fail/tcfail104.stderr ===================================== @@ -1,19 +1,22 @@ -tcfail104.hs:14:12: error: +tcfail104.hs:16:12: error: + • Couldn't match type: Char -> Char + with: forall a. a -> a + Expected: (forall a. a -> a) -> Char -> Char + Actual: (Char -> Char) -> Char -> Char + • In the expression: \ x -> x + In the expression: + if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x) + In the expression: + (if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x)) id 'c' + +tcfail104.hs:22:12: error: • Couldn't match type: forall a. a -> a with: Char -> Char Expected: (Char -> Char) -> Char -> Char Actual: (forall a. a -> a) -> Char -> Char • In the expression: \ (x :: forall a. a -> a) -> x In the expression: - if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x) + if v then (\ x -> x) else (\ (x :: forall a. a -> a) -> x) In the expression: - (if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x)) id 'c' - -tcfail104.hs:22:15: error: - • Couldn't match expected type: Char -> Char - with actual type: forall a. a -> a - • When checking that the pattern signature: forall a. a -> a - fits the type of its context: Char -> Char - In the pattern: x :: forall a. a -> a - In the expression: \ (x :: forall a. a -> a) -> x + (if v then (\ x -> x) else (\ (x :: forall a. a -> a) -> x)) id 'c' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e60ceff971787ca8cd96a522f6e901e6cde49a49 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e60ceff971787ca8cd96a522f6e901e6cde49a49 You're receiving 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 Jul 13 16:33:41 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Mon, 13 Jul 2020 12:33:41 -0400 Subject: [Git][ghc/ghc][wip/T18412] Apply fix for #18412 to n-plus-k patterns Message-ID: <5f0c8ce52ae55_80b3f84960bea142839599@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/T18412 at Glasgow Haskell Compiler / GHC Commits: 1728a8b8 by Richard Eisenberg at 2020-07-13T17:33:21+01:00 Apply fix for #18412 to n-plus-k patterns While I was there, I got distracted by linear types and did some cleaning. - - - - - 6 changed files: - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Unify.hs Changes: ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -1141,6 +1141,7 @@ dsHsWrapper (WpCast co) = ASSERT(coercionRole co == Representational) return $ \e -> mkCastDs e co dsHsWrapper (WpEvApp tm) = do { core_tm <- dsEvTerm tm ; return (\e -> App e core_tm) } + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. dsHsWrapper (WpMultCoercion co) = do { when (not (isReflexiveCo co)) $ errDs (text "Multiplicity coercions are currently not supported") ; return $ \e -> e } ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -365,7 +365,7 @@ tcExpr expr@(OpApp fix arg1 op arg2) res_ty matchActualFunTysRho doc orig1 (Just (unLoc arg1)) 1 arg1_ty ; mult_wrap <- tcSubMult AppOrigin Many (scaledMult arg2_sigma) - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. -- -- When ($) becomes multiplicity-polymorphic, then the above check will -- need to go. But in the meantime, it would produce ill-typed ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -343,7 +343,7 @@ tc_lpats tys penv pats (zipEqual "tc_lpats" pats tys) -------------------- --- See Note [tcSubMult's wrapper] in TcUnify. +-- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. checkManyPattern :: Scaled a -> TcM HsWrapper checkManyPattern pat_ty = tcSubMult NonLinearPatternOrigin Many (scaledMult pat_ty) @@ -358,7 +358,7 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of { (wrap, id) <- tcPatBndr penv name pat_ty ; (res, mult_wrap) <- tcCheckUsage name (scaledMult pat_ty) $ tcExtendIdEnv1 name id thing_inside - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; pat_ty <- readExpType (scaledThing pat_ty) ; return (mkHsWrapPat (wrap <.> mult_wrap) (VarPat x (L l id)) pat_ty, res) } @@ -372,7 +372,7 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of LazyPat x pat -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; (pat', (res, pat_ct)) <- tc_lpat pat_ty (makeLazy penv) pat $ captureConstraints thing_inside @@ -390,14 +390,14 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of WildPat _ -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; res <- thing_inside ; pat_ty <- expTypeToType (scaledThing pat_ty) ; return (mkHsWrapPat mult_wrap (WildPat pat_ty) pat_ty, res) } AsPat x (L nm_loc name) pat -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; (wrap, bndr_id) <- setSrcSpan nm_loc (tcPatBndr penv name pat_ty) ; (pat', res) <- tcExtendIdEnv1 name bndr_id $ tc_lpat (pat_ty `scaledSet`(mkCheckExpType $ idType bndr_id)) @@ -414,7 +414,7 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of ViewPat _ expr pat -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. -- -- It should be possible to have view patterns at linear (or otherwise -- non-Many) multiplicity. But it is not clear at the moment what @@ -586,7 +586,7 @@ Fortunately that's what matchExpectedFunTySigma returns anyway. -- When there is no negation, neg_lit_ty and lit_ty are the same NPat _ (L l over_lit) mb_neg eq -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. -- -- It may be possible to refine linear pattern so that they work in -- linear environments. But it is not clear how useful this is. @@ -630,10 +630,6 @@ There are two bits of rebindable syntax: lit1_ty and lit2_ty could conceivably be different. var_ty is the type inferred for x, the variable in the pattern. -If the pushed-down pattern type isn't a tau-type, the two pat_ty's -above could conceivably be different specializations. So we use -expTypeToType on pat_ty before proceeding. - Note that we need to type-check the literal twice, because it is used twice, and may be used at different types. The second HsOverLit stored in the AST is used for the subtraction operation. @@ -643,16 +639,16 @@ AST is used for the subtraction operation. NPlusKPat _ (L nm_loc name) (L loc lit) _ ge minus -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. - ; pat_ty <- expTypeToType (scaledThing pat_ty) - ; let orig = LiteralOrigin lit + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. + ; let pat_exp_ty = scaledThing pat_ty + orig = LiteralOrigin lit ; (lit1', ge') - <- tcSyntaxOp orig ge [synKnownType pat_ty, SynRho] + <- tcSyntaxOp orig ge [SynType pat_exp_ty, SynRho] (mkCheckExpType boolTy) $ \ [lit1_ty] _ -> newOverloadedLit lit (mkCheckExpType lit1_ty) ; ((lit2', minus_wrap, bndr_id), minus') - <- tcSyntaxOpGen orig minus [synKnownType pat_ty, SynRho] SynAny $ + <- tcSyntaxOpGen orig minus [SynType pat_exp_ty, SynRho] SynAny $ \ [lit2_ty, var_ty] _ -> do { lit2' <- newOverloadedLit lit (mkCheckExpType lit2_ty) ; (wrap, bndr_id) <- setSrcSpan nm_loc $ @@ -662,6 +658,7 @@ AST is used for the subtraction operation. -- minus_wrap is applicable to minus' ; return (lit2', wrap, bndr_id) } + ; pat_ty <- readExpType pat_exp_ty -- The Report says that n+k patterns must be in Integral -- but it's silly to insist on this in the RebindableSyntax case ; unlessM (xoptM LangExt.RebindableSyntax) $ @@ -984,7 +981,7 @@ tcPatSynPat penv (L con_span _) pat_syn pat_ty arg_pats thing_inside req_theta' = substTheta tenv req_theta ; mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; wrap <- tc_sub_type penv (scaledThing pat_ty) ty' ; traceTc "tcPatSynPat" (ppr pat_syn $$ ===================================== compiler/GHC/Tc/Types/Evidence.hs ===================================== @@ -229,18 +229,10 @@ data HsWrapper | WpLet TcEvBinds -- Non-empty (or possibly non-empty) evidence bindings, -- so that the identity coercion is always exactly WpHole - | WpMultCoercion Coercion - -- Note [Checking multiplicity coercions] - -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- This wrapper can be returned from tcSubMult. - -- It is used in case a variable is used with multiplicity m1, - -- we need it with multiplicity m2 and we have a coercion c :: m1 ~ m2. - -- Compiling such code would require multiplicity coercions in Core, - -- which we don't have. If the desugarer sees WpMultCoercion - -- with a non-reflexive coercion, it gives an error. - -- This is a temporary measure, as we don't really know yet exactly - -- what multiplicity coercions should be. But it serves as a good - -- approximation for the first iteration for the first iteration of linear types. + + | WpMultCoercion Coercion -- Require that a Coercion be reflexive; otherwise, + -- error in the desugarer. See GHC.Tc.Utils.Unify + -- Note [Wrapper returned from tcSubMult] -- Cannot derive Data instance because SDoc is not Data (it stores a function). -- So we do it manually: ===================================== compiler/GHC/Tc/Utils/Env.hs ===================================== @@ -628,7 +628,8 @@ tcExtendLocalTypeEnv lcl_env@(TcLclEnv { tcl_env = lcl_type_env }) tc_ty_things -- | @tcCheckUsage name mult thing_inside@ runs @thing_inside@, checks that the -- usage of @name@ is a submultiplicity of @mult@, and removes @name@ from the --- usage environment. See also Note [tcSubMult's wrapper] in TcUnify. +-- usage environment. See also Note [Wrapper returned from tcSubMult] in +-- GHC.Tc.Utils.Unify, which applies to the wrapper returned from this function. tcCheckUsage :: Name -> Mult -> TcM a -> TcM (a, HsWrapper) tcCheckUsage name id_mult thing_inside = do { (local_usage, result) <- tcCollectingUsage thing_inside ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -762,29 +762,29 @@ to a UserTypeCtxt of GenSigCtxt. Why? ambiguity check, but we don't need one for each level within it, and GHC.Tc.Utils.Unify.alwaysBuildImplication checks the UserTypeCtxt. See Note [When to build an implication] --} +Note [Wrapper returned from tcSubMult] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +There is no notion of multiplicity coercion in Core, therefore the wrapper +returned by tcSubMult (and derived functions such as tcCheckUsage and +checkManyPattern) is quite unlike any other wrapper: it checks whether the +coercion produced by the constraint solver is trivial, producing a type error +is it is not. This is implemented via the WpMultCoercion wrapper, as desugared +by GHC.HsToCore.Binds.dsHsWrapper, which does the reflexivity check. + +This wrapper needs to be placed in the term; otherwise, checking of the +eventual coercion won't be triggered during desugaring. But it can be put +anywhere, since it doesn't affect the desugared code. + +Why do we check this in the desugarer? It's a convenient place, since it's +right after all the constraints are solved. We need the constraints to be +solved to check whether they are trivial or not. Plus there is precedent for +type errors during desuraging (such as the levity polymorphism +restriction). An alternative would be to have a kind of constraint which can +only produce trivial evidence, then this check would happen in the constraint +solver. +-} --- Note [tcSubMult's wrapper] --- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --- There is no notion of multiplicity coercion in Core, therefore the wrapper --- returned by tcSubMult (and derived function such as tcCheckUsage and --- checkManyPattern) is quite unlike any other wrapper: it checks whether the --- coercion produced by the constraint solver is trivial and disappears (it --- produces a type error is the constraint is not trivial). See [Checking --- multiplicity coercions] in TcEvidence. --- --- This wrapper need to be placed in the term, otherwise checking of the --- eventual coercion won't be triggered during desuraging. But it can be put --- anywhere, since it doesn't affect the desugared code. --- --- Why do we check this in the desugarer? It's a convenient place, since it's --- right after all the constraints are solved. We need the constraints to be --- solved to check whether they are trivial or not. Plus there are precedent for --- type errors during desuraging (such as the levity polymorphism --- restriction). An alternative would be to have a kind of constraints which can --- only produce trivial evidence, then this check would happen in the constraint --- solver. tcSubMult :: CtOrigin -> Mult -> Mult -> TcM HsWrapper tcSubMult origin w_actual w_expected | Just (w1, w2) <- isMultMul w_actual = View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1728a8b8d929fbbeace3adb8b1383e192262ff9a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1728a8b8d929fbbeace3adb8b1383e192262ff9a You're receiving 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 Jul 13 17:41:43 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 13 Jul 2020 13:41:43 -0400 Subject: [Git][ghc/ghc][wip/T13253] This patch addresses the exponential blow-up in the simplifier. Message-ID: <5f0c9cd7463fe_80b3f8486b77e482857386@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC Commits: adcf83e2 by Simon Peyton Jones at 2020-07-13T13:41:03-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes two significant changes: 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Then in postInlineUnconditionally use that info to avoid inling something many many times. Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally See Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils 2. Change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg] Current nofib run Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- VS -0.3% +115.9% +12.1% +11.2% 0.0% boyer2 -0.3% +10.0% +3.5% +4.0% 0.0% cryptarithm2 -0.3% +39.0% +16.6% +16.1% 0.0% gamteb -0.3% +4.1% -0.0% +0.4% 0.0% last-piece -0.3% +1.4% -1.1% -0.4% 0.0% mate -0.4% -11.1% -8.5% -9.0% 0.0% multiplier -0.3% -2.2% -1.5% -1.5% 0.0% transform -0.3% +3.4% +0.5% +0.8% 0.0% -------------------------------------------------------------------------------- Min -0.8% -11.1% -8.5% -9.0% 0.0% Max -0.3% +115.9% +30.1% +26.4% 0.0% Geometric Mean -0.3% +1.0% +1.0% +1.0% -0.0% Should investigate these numbers. But the tickets are indeed cured, I think. - - - - - 29 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id/Info.hs - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T13253-spj.hs - + testsuite/tests/perf/compiler/T13253.hs - + testsuite/tests/perf/compiler/T18140.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T15631.stdout - testsuite/tests/simplCore/should_compile/T17901.stdout - testsuite/tests/simplCore/should_compile/T18355.stderr - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4908.stderr - testsuite/tests/simplCore/should_compile/T4930.stderr - testsuite/tests/simplCore/should_compile/T5366.stdout - testsuite/tests/simplCore/should_compile/T7360.stderr - testsuite/tests/simplCore/should_compile/T7865.stdout - testsuite/tests/simplCore/should_compile/spec-inline.stderr - testsuite/tests/stranal/should_compile/T16029.stdout Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -832,7 +832,7 @@ occAnalNonRecBind env lvl imp_rule_edges bndr rhs body_usage certainly_inline -- See Note [Cascading inlines] = case occ of - OneOcc { occ_in_lam = NotInsideLam, occ_one_br = InOneBranch } + OneOcc { occ_in_lam = NotInsideLam, occ_n_br = 1 } -> active && not_stable _ -> False @@ -2563,7 +2563,7 @@ mkOneOcc id int_cxt arity = emptyDetails where occ_info = OneOcc { occ_in_lam = NotInsideLam - , occ_one_br = InOneBranch + , occ_n_br = oneBranch , occ_int_cxt = int_cxt , occ_tail = AlwaysTailCalled arity } @@ -2967,11 +2967,15 @@ addOccInfo a1 a2 = ASSERT( not (isDeadOcc a1 || isDeadOcc a2) ) -- (orOccInfo orig new) is used -- when combining occurrence info from branches of a case -orOccInfo (OneOcc { occ_in_lam = in_lam1, occ_int_cxt = int_cxt1 - , occ_tail = tail1 }) - (OneOcc { occ_in_lam = in_lam2, occ_int_cxt = int_cxt2 - , occ_tail = tail2 }) - = OneOcc { occ_one_br = MultipleBranches -- because it occurs in both branches +orOccInfo (OneOcc { occ_in_lam = in_lam1 + , occ_n_br = nbr1 + , occ_int_cxt = int_cxt1 + , occ_tail = tail1 }) + (OneOcc { occ_in_lam = in_lam2 + , occ_n_br = nbr2 + , occ_int_cxt = int_cxt2 + , occ_tail = tail2 }) + = OneOcc { occ_n_br = nbr1 + nbr2 , occ_in_lam = in_lam1 `mappend` in_lam2 , occ_int_cxt = int_cxt1 `mappend` int_cxt2 , occ_tail = tail1 `andTailCallInfo` tail2 } ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -658,8 +658,8 @@ lvlMFE env strict_ctxt e@(_, AnnCase {}) lvlMFE env strict_ctxt ann_expr | floatTopLvlOnly env && not (isTopLvl dest_lvl) -- Only floating to the top level is allowed. - || anyDVarSet isJoinId fvs -- If there is a free join, don't float - -- See Note [Free join points] + || hasFreeJoin env fvs -- If there is a free join, don't float + -- See Note [Free join points] || isExprLevPoly expr -- We can't let-bind levity polymorphic expressions -- See Note [Levity polymorphism invariants] in GHC.Core @@ -755,6 +755,14 @@ lvlMFE env strict_ctxt ann_expr && floatConsts env && (not strict_ctxt || is_bot || exprIsHNF expr) +hasFreeJoin :: LevelEnv -> DVarSet -> Bool +-- Has a free join point which is not being floated to top level. +-- (In the latter case it won't be a join point any more.) +-- Not treating top-level ones specially had a massive effect +-- on nofib/minimax/Prog.prog +hasFreeJoin env fvs + = not (maxFvLevel isJoinId env fvs == tOP_LEVEL) + isBottomThunk :: Maybe (Arity, s) -> Bool -- See Note [Bottoming floats] (2) isBottomThunk (Just (0, _)) = True -- Zero arity ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -664,13 +664,6 @@ prepareRhs mode top_lvl occ rhs0 go _ other = return (False, emptyLetFloats, other) -makeTrivialArg :: SimplMode -> ArgSpec -> SimplM (LetFloats, ArgSpec) -makeTrivialArg mode arg@(ValArg { as_arg = e }) - = do { (floats, e') <- makeTrivial mode NotTopLevel (fsLit "arg") e - ; return (floats, arg { as_arg = e' }) } -makeTrivialArg _ arg - = return (emptyLetFloats, arg) -- CastBy, TyArg - makeTrivial :: SimplMode -> TopLevelFlag -> FastString -- ^ A "friendly name" to build the new binder from -> OutExpr -- ^ This expression satisfies the let/app invariant @@ -3325,9 +3318,11 @@ mkDupableCont env (TickIt t cont) mkDupableCont env (StrictBind { sc_bndr = bndr, sc_bndrs = bndrs , sc_body = body, sc_env = se, sc_cont = cont}) - -- See Note [Duplicating StrictBind] +-- See Note [Duplicating StrictBind] +-- K[ let x = <> in b ] --> join j x = K[ b ] +-- j <> = do { let sb_env = se `setInScopeFromE` env - ; (sb_env1, bndr') <- simplBinder sb_env bndr + ; (sb_env1, bndr') <- simplBinder sb_env bndr ; (floats1, join_inner) <- simplLam sb_env1 bndrs body cont -- No need to use mkDupableCont before simplLam; we -- use cont once here, and then share the result if necessary @@ -3335,37 +3330,21 @@ mkDupableCont env (StrictBind { sc_bndr = bndr, sc_bndrs = bndrs ; let join_body = wrapFloats floats1 join_inner res_ty = contResultType cont - ; (floats2, body2) - <- if exprIsDupable (targetPlatform (seDynFlags env)) join_body - then return (emptyFloats env, join_body) - else do { join_bndr <- newJoinId [bndr'] res_ty - ; let join_call = App (Var join_bndr) (Var bndr') - join_rhs = Lam (setOneShotLambda bndr') join_body - join_bind = NonRec join_bndr join_rhs - floats = emptyFloats env `extendFloats` join_bind - ; return (floats, join_call) } - ; return ( floats2 - , StrictBind { sc_bndr = bndr', sc_bndrs = [] - , sc_body = body2 - , sc_env = zapSubstEnv se `setInScopeFromF` floats2 - -- See Note [StaticEnv invariant] in GHC.Core.Opt.Simplify.Utils - , sc_dup = OkToDup - , sc_cont = mkBoringStop res_ty } ) } - -mkDupableCont env (StrictArg { sc_fun = info, sc_cci = cci - , sc_cont = cont, sc_fun_ty = fun_ty, sc_mult = m }) - -- See Note [Duplicating StrictArg] - -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable - = do { (floats1, cont') <- mkDupableCont env cont - ; (floats_s, args') <- mapAndUnzipM (makeTrivialArg (getMode env)) - (ai_args info) - ; return ( foldl' addLetFloats floats1 floats_s - , StrictArg { sc_fun = info { ai_args = args' } - , sc_cont = cont' - , sc_cci = cci - , sc_fun_ty = fun_ty - , sc_mult = m - , sc_dup = OkToDup} ) } + ; mkDupableStrictBind env RhsCtxt bndr' join_body res_ty } + +mkDupableCont env (StrictArg { sc_fun = fun, sc_cci = cci + , sc_cont = cont, sc_fun_ty = fun_ty + , sc_mult = m }) +-- See Note [Duplicating StrictArg] +-- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable +-- K[ f a b <> ] --> join j x = K[ f a b x ] +-- j <> + = do { let arg_ty = funArgTy fun_ty + rhs_ty = contResultType cont + ; arg_bndr <- newId (fsLit "arg") m arg_ty -- ToDo: check this linearity argument + ; let env' = env `addNewInScopeIds` [arg_bndr] + ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (m, Var arg_bndr) fun_ty) cont + ; mkDupableStrictBind env' cci arg_bndr (wrapFloats floats join_rhs) rhs_ty } mkDupableCont env (ApplyToTy { sc_cont = cont , sc_arg_ty = arg_ty, sc_hole_ty = hole_ty }) @@ -3439,6 +3418,34 @@ mkDupableCont env (Select { sc_bndr = case_bndr, sc_alts = alts -- See Note [StaticEnv invariant] in GHC.Core.Opt.Simplify.Utils , sc_cont = mkBoringStop (contResultType cont) } ) } +mkDupableStrictBind :: SimplEnv -> CallCtxt -> OutId -> OutExpr -> OutType + -> SimplM (SimplFloats, SimplCont) +mkDupableStrictBind env cci arg_bndr join_rhs res_ty + | exprIsDupable (targetPlatform (seDynFlags env)) join_rhs + = return (emptyFloats env + , StrictBind { sc_bndr = arg_bndr, sc_bndrs = [] + , sc_body = join_rhs + , sc_env = zapSubstEnv env + -- See Note [StaticEnv invariant] in GHC.Core.Opt.Simplify.Utils + , sc_dup = OkToDup + , sc_cont = mkBoringStop res_ty } ) + | otherwise + = do { join_bndr <- newJoinId [arg_bndr] res_ty + ; let arg_info = ArgInfo { ai_fun = join_bndr + , ai_rules = Nothing, ai_args = [] + , ai_encl = False, ai_strs = repeat False + , ai_discs = repeat 0 } + ; return ( addJoinFloats (emptyFloats env) $ + unitJoinFloat $ + NonRec join_bndr $ + Lam (setOneShotLambda arg_bndr) join_rhs + , StrictArg { sc_dup = OkToDup + , sc_fun = arg_info + , sc_fun_ty = idType join_bndr + , sc_cont = mkBoringStop res_ty + , sc_mult = Many -- ToDo: check this! + , sc_cci = cci } ) } + mkDupableAlt :: Platform -> OutId -> JoinFloats -> OutAlt -> SimplM (JoinFloats, OutAlt) @@ -3612,56 +3619,75 @@ type variables as well as term variables. Note [Duplicating StrictArg] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We make a StrictArg duplicable simply by making all its -stored-up arguments (in sc_fun) trivial, by let-binding -them. Thus: - f E [..hole..] - ==> let a = E - in f a [..hole..] -Now if the thing in the hole is a case expression (which is when -we'll call mkDupableCont), we'll push the function call into the -branches, which is what we want. Now RULES for f may fire, and -call-pattern specialisation. Here's an example from #3116 +What code do we want for this? + + f (case x1 of { T -> F; F -> T }) + (case x2 of { T -> F; F -> T }) + ...etc... + +when f is strict in all its arguments. (It might, for example, be a +strict data constructor whose wrapper has not yet been inlined.) + +Morally, we want to evaluate each argument in turn, and then call f. +Eavluating each argument has a case-split, so we'll get a diamond +pattern of join points, like this, assuming we evaluate the args +left-to-right: + + join { + j1 a1 = join { + j2 a2 = ..... + } in case x2 of { T -> j2 F; j2 T } + } in case x1 of { T -> j1 F; F -> j1 T } + +So when we want to duplicate a StrictArg continuation, we +want to use this transformation + K[ f a b <> ] --> join j x = K[ f a b x ] + in j <> + +-- Downsides -- + +This plan has some downsides, because now the call to 'f' can't +"see" the actual argument 'x' which might be important for RULES +or call-pattern specialisation. Here's an example from #3116 + go (n+1) (case l of 1 -> bs' _ -> Chunk p fpc (o+1) (l-1) bs') -If we can push the call for 'go' inside the case, we get + +If we pushed the entire call for 'go' inside the case, we get call-pattern specialisation for 'go', which is *crucial* for this program. -Here is the (&&) example: - && E (case x of { T -> F; F -> T }) - ==> let a = E in - case x of { T -> && a F; F -> && a T } -Much better! - -Notice that - * Arguments to f *after* the strict one are handled by - the ApplyToVal case of mkDupableCont. Eg - f [..hole..] E - - * We can only do the let-binding of E because the function - part of a StrictArg continuation is an explicit syntax - tree. In earlier versions we represented it as a function - (CoreExpr -> CoreEpxr) which we couldn't take apart. - -Historical aide: previously we did this (where E is a -big argument: - f E [..hole..] - ==> let $j = \a -> f E a - in $j [..hole..] - -But this is terrible! Here's an example: +Here is another example. With our current approach we see && E (case x of { T -> F; F -> T }) -Now, && is strict so we end up simplifying the case with -an ArgOf continuation. If we let-bind it, we get - let $j = \v -> && E v - in simplExpr (case x of { T -> F; F -> T }) - (ArgOf (\r -> $j r) -And after simplifying more we get + ==> let $j = \v -> && E v in case x of { T -> $j F; F -> $j T } -Which is a Very Bad Thing + +But we'd prefer to get + let a = E + in case x of { T -> && a F; F -> && a T } + +Pushing the whole call inwards in this way is precisely the change +that was made in #3116, but /un-done/ by my fix to #13253. Why? +Because pushing the whole call inwards works very badly in some cases. + + f (case x1 of { T->F; F->T }) (case x2..) ... + +==> GHC 8.10 duplicate StrictArg + (case x1 of { T -> f F, F -> f T }) + (case x2 ...) + (case x3 ...) +==> duplicate ApplyToVal + let a2 = case x2 of ... + a3 = case x3 of ... + in case x1 of { T -> f F a2 a3 ... ; F -> f T a2 a3 ... } + +Now there is an Awful Danger than we'll postInlineUnconditionally a2 +and a3, and repeat the whole exercise, leading to exponential code +size. Moreover, if we don't, those ai lets are really strict; so not +or later they will be dealt with via Note [Duplicating StrictBind]. +StrictArg and StrictBind should be handled the same. Note [Duplicating StrictBind] @@ -3671,9 +3697,10 @@ that for case expressions. After all, let x* = e in b is similar to case e of x -> b So we potentially make a join-point for the body, thus: - let x = [] in b ==> join j x = b - in let x = [] in j x + let x = <> in b ==> join j x = b + in j <> +Just like StrictArg in fact -- and indeed they share code. Note [Join point abstraction] Historical note ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1201,9 +1201,9 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_env extend_subst_with inl_rhs = extendIdSubst env bndr (mkContEx rhs_env inl_rhs) one_occ IAmDead = True -- Happens in ((\x.1) v) - one_occ OneOcc{ occ_one_br = InOneBranch + one_occ OneOcc{ occ_n_br = 1 , occ_in_lam = NotInsideLam } = isNotTopLevel top_lvl || early_phase - one_occ OneOcc{ occ_one_br = InOneBranch + one_occ OneOcc{ occ_n_br = 1 , occ_in_lam = IsInsideLam , occ_int_cxt = IsInteresting } = canInlineInLam rhs one_occ _ = False @@ -1329,12 +1329,17 @@ postInlineUnconditionally env top_lvl bndr occ_info rhs -- False -> case x of ... -- This is very important in practice; e.g. wheel-seive1 doubles -- in allocation if you miss this out - OneOcc { occ_in_lam = in_lam, occ_int_cxt = int_cxt } - -- OneOcc => no code-duplication issue - -> smallEnoughToInline dflags unfolding -- Small enough to dup + + OneOcc { occ_in_lam = in_lam, occ_int_cxt = int_cxt, occ_n_br = n_br } + -> -- See Note [Suppress exponential blowup] + n_br < (case int_cxt of + IsInteresting -> 16 + NotInteresting -> 4) + + && smallEnoughToInline dflags unfolding -- Small enough to dup -- ToDo: consider discount on smallEnoughToInline if int_cxt is true -- - -- NB: Do NOT inline arbitrarily big things, even if one_br is True + -- NB: Do NOT inline arbitrarily big things, even if occ_n_br=1 -- Reason: doing so risks exponential behaviour. We simplify a big -- expression, inline it, and simplify it again. But if the -- very same thing happens in the big expression, we get @@ -1381,7 +1386,35 @@ postInlineUnconditionally env top_lvl bndr occ_info rhs active = isActive (sm_phase (getMode env)) (idInlineActivation bndr) -- See Note [pre/postInlineUnconditionally in gentle mode] -{- +{- Note [Suppress exponential blowup] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In #13253, and a raft of related tickets, we got an exponential blowup +in code size from postInlineUnconditionally. The trouble comes when +we have + let j1a = case f y of { True -> p; False -> q } + j1b = case f y of { True -> q; False -> p } + j2a = case f (y+1) of { True -> j1a; False -> j1b } + j2b = case f (y+1) of { True -> j1b; False -> j1a } + ... + in case f (y+10) of { True -> j10a; False -> j10b } + +when there are many branches. In pass 1, postInlineUnconditionally +inlines j10a and j10b (they are both small). Now we have two calls +to j9a and two to j9b. In pass 2, postInlineUnconditionally inlines +all four of these calls, leaving four calls to j8a and j8b. Etc. +Yikes! This is exponential! + +Moreover, this structure can and does arise easily, as the +tickets show: it's just a sequence of diamond control flow blocks. + +Solution: stop doing postInlineUnconditionally for some fixed, +smallish number of branches, say 4. + +This still leaves the nasty possiblity that /ordinary/ inlining (not +postInlineUnconditionally) might inline these join points, each of +which is individually quiet small. I'm still not sure what to do +about this (see #15488). But let's kill off one problem anyway. + Note [Top level and postInlineUnconditionally] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We don't do postInlineUnconditionally for top-level things (even for ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -433,7 +433,7 @@ simple_bind_pair env@(SOE { soe_inl = inl_env, soe_subst = subst }) safe_to_inline IAmALoopBreaker{} = False safe_to_inline IAmDead = True safe_to_inline OneOcc{ occ_in_lam = NotInsideLam - , occ_one_br = InOneBranch } = True + , occ_n_br = 1 } = True safe_to_inline OneOcc{} = False safe_to_inline ManyOccs{} = False ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -68,7 +68,7 @@ module GHC.Types.Basic ( isNoOccInfo, strongLoopBreaker, weakLoopBreaker, InsideLam(..), - OneBranch(..), + BranchCount, oneBranch, InterestingCxt(..), TailCallInfo(..), tailCallInfo, zapOccTailCallInfo, isAlwaysTailCalled, @@ -978,7 +978,7 @@ data OccInfo -- lambda and case-bound variables. | OneOcc { occ_in_lam :: !InsideLam - , occ_one_br :: !OneBranch + , occ_n_br :: {-# UNPACK #-} !BranchCount , occ_int_cxt :: !InterestingCxt , occ_tail :: !TailCallInfo } -- ^ Occurs exactly once (per branch), not inside a rule @@ -992,6 +992,11 @@ data OccInfo type RulesOnly = Bool +type BranchCount = Int -- For OneOcc, says how many syntactic occurrences there are + +oneBranch :: BranchCount +oneBranch = 1 + {- Note [LoopBreaker OccInfo] ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1057,14 +1062,6 @@ instance Monoid InsideLam where mempty = NotInsideLam mappend = (Semi.<>) ------------------ -data OneBranch - = InOneBranch - -- ^ One syntactic occurrence: Occurs in only one case branch - -- so no code-duplication issue to worry about - | MultipleBranches - deriving (Eq) - ----------------- data TailCallInfo = AlwaysTailCalled JoinArity -- See Note [TailCallInfo] | NoTailCallInfo @@ -1124,12 +1121,10 @@ instance Outputable OccInfo where pp_ro | rule_only = char '!' | otherwise = empty ppr (OneOcc inside_lam one_branch int_cxt tail_info) - = text "Once" <> pp_lam inside_lam <> pp_br one_branch <> pp_args int_cxt <> pp_tail + = text "Once" <> pp_lam inside_lam <> ppr one_branch <> pp_args int_cxt <> pp_tail where pp_lam IsInsideLam = char 'L' pp_lam NotInsideLam = empty - pp_br MultipleBranches = char '*' - pp_br InOneBranch = empty pp_args IsInteresting = char '!' pp_args NotInteresting = empty pp_tail = pprShortTailCallInfo tail_info @@ -1156,7 +1151,7 @@ AlwaysTailCalled. Note that there is a 'TailCallInfo' on a 'ManyOccs' value. One might expect that being tail-called would mean that the variable could only appear once per branch -(thus getting a `OneOcc { occ_one_br = True }` occurrence info), but a join +(thus getting a `OneOcc { }` occurrence info), but a join point can also be invoked from other join points, not just from case branches: let j1 x = ... @@ -1167,7 +1162,7 @@ point can also be invoked from other join points, not just from case branches: C -> j2 q Here both 'j1' and 'j2' will get marked AlwaysTailCalled, but j1 will get -ManyOccs and j2 will get `OneOcc { occ_one_br = True }`. +ManyOccs and j2 will get `OneOcc { occ_n_br = 2 }`. ************************************************************************ * * ===================================== compiler/GHC/Types/Id/Info.hs ===================================== @@ -58,7 +58,7 @@ module GHC.Types.Id.Info ( isDeadOcc, isStrongLoopBreaker, isWeakLoopBreaker, occInfo, setOccInfo, - InsideLam(..), OneBranch(..), + InsideLam(..), BranchCount, TailCallInfo(..), tailCallInfo, isAlwaysTailCalled, ===================================== testsuite/tests/numeric/should_compile/T14465.stdout ===================================== @@ -82,7 +82,7 @@ plusOne :: Natural -> Natural Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (n [Occ=Once] :: Natural) -> naturalAdd n M.minusOne1}] + Tmpl= \ (n [Occ=Once1] :: Natural) -> naturalAdd n M.minusOne1}] plusOne = \ (n :: Natural) -> naturalAdd n M.minusOne1 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} ===================================== testsuite/tests/numeric/should_compile/T7116.stdout ===================================== @@ -48,7 +48,7 @@ dr :: Double -> Double Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (x [Occ=Once!] :: Double) -> + Tmpl= \ (x [Occ=Once1!] :: Double) -> case x of { GHC.Types.D# x1 -> GHC.Types.D# (GHC.Prim.+## x1 x1) }}] @@ -65,7 +65,7 @@ dl :: Double -> Double Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (x [Occ=Once!] :: Double) -> + Tmpl= \ (x [Occ=Once1!] :: Double) -> case x of { GHC.Types.D# y -> GHC.Types.D# (GHC.Prim.+## y y) }}] dl = dr @@ -78,7 +78,7 @@ fr :: Float -> Float Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (x [Occ=Once!] :: Float) -> + Tmpl= \ (x [Occ=Once1!] :: Float) -> case x of { GHC.Types.F# x1 -> GHC.Types.F# (GHC.Prim.plusFloat# x1 x1) }}] @@ -97,7 +97,7 @@ fl :: Float -> Float Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (x [Occ=Once!] :: Float) -> + Tmpl= \ (x [Occ=Once1!] :: Float) -> case x of { GHC.Types.F# y -> GHC.Types.F# (GHC.Prim.plusFloat# y y) }}] ===================================== testsuite/tests/perf/compiler/T10421.hs ===================================== @@ -0,0 +1,51 @@ +-- Exponential with GHC 8.10 + +module RegBig where + +import Prelude + +import Control.Applicative +import T10421_Form +import T10421_Y + +data Register + = Register String + String + String + String + String + String + String + String + String + String + String + String + +registerForm :: a -> IO (FormResult Register) +registerForm _ = do + (a1, _) <- mreq textField "" Nothing + (a2, _) <- mreq textField "" Nothing + (a3, _) <- mreq textField "" Nothing + (a4, _) <- mreq textField "" Nothing + (a5, _) <- mreq textField "" Nothing + (a6, _) <- mreq textField "" Nothing + (a7, _) <- mreq textField "" Nothing + (a8, _) <- mreq textField "" Nothing + (a9, _) <- mreq textField "" Nothing + (a10, _) <- mreq textField "" Nothing + (a11, _) <- mreq textField "" Nothing + (a12, _) <- mreq textField "" Nothing + return (Register <$> a1 + <*> a2 + <*> a3 + <*> a4 + <*> a5 + <*> a6 + <*> a7 + <*> a8 + <*> a9 + <*> a10 + <*> a11 + <*> a12 + ) ===================================== testsuite/tests/perf/compiler/T10421_Form.hs ===================================== @@ -0,0 +1,19 @@ +-- Form.hs +module T10421_Form where + +import Control.Applicative + +data FormResult a = FormMissing + | FormFailure [String] + | FormSuccess a +instance Functor FormResult where + fmap _ FormMissing = FormMissing + fmap _ (FormFailure errs) = FormFailure errs + fmap f (FormSuccess a) = FormSuccess $ f a +instance Applicative FormResult where + pure = FormSuccess + (FormSuccess f) <*> (FormSuccess g) = FormSuccess $ f g + (FormFailure x) <*> (FormFailure y) = FormFailure $ x ++ y + (FormFailure x) <*> _ = FormFailure x + _ <*> (FormFailure y) = FormFailure y + _ <*> _ = FormMissing ===================================== testsuite/tests/perf/compiler/T10421_Y.hs ===================================== @@ -0,0 +1,17 @@ +-- Y.hs +{-# OPTIONS_GHC -fomit-interface-pragmas #-} +-- Imagine the values defined in this module are complicated +-- and there is no useful inlining/strictness/etc. information + +module T10421_Y where + +import T10421_Form + +mreq :: a -> b -> c -> IO (FormResult d, ()) +mreq = undefined + +mopt :: a -> b -> c -> IO (FormResult d, ()) +mopt = undefined + +textField = undefined +checkBoxField = undefined ===================================== testsuite/tests/perf/compiler/T13253-spj.hs ===================================== @@ -0,0 +1,20 @@ +-- Exponential with GHC 8.10 + +module T13253 where + +f :: Int -> Bool -> Bool +{-# INLINE f #-} +f y x = case x of { True -> y>0 ; False -> y<0 } + +foo y x = f (y+1) $ + f (y+2) $ + f (y+3) $ + f (y+4) $ + f (y+5) $ + f (y+6) $ + f (y+7) $ + f (y+8) $ + f (y+9) $ + f (y+10) $ + f (y+11) $ + f y x ===================================== testsuite/tests/perf/compiler/T13253.hs ===================================== @@ -0,0 +1,122 @@ +-- Exponential with GHC 8.10 + +{-# LANGUAGE CPP #-} +{-# LANGUAGE OverloadedStrings #-} + +module T13253 where + +import Control.Monad (liftM) +import Control.Monad.Trans.RWS.Lazy -- check how strict behaves +import Control.Monad.Trans.Reader (ReaderT) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Class (MonadTrans (..)) +import Data.ByteString (ByteString) +import Data.Monoid (Any (..)) +import Data.Semigroup (Semigroup (..)) +import Data.String (IsString (..)) +import System.Environment (getEnv) + +type Handler = ReaderT () IO +type MForm = RWST (Maybe ([(String, Text)], ()), (), ()) Any [Int] +type Text = ByteString -- close enough + +data HugeStruct = HugeStruct + !Text + !Text + !Text + !Text + !Text + !Text + !Text + !Text + !Text -- 9th + !Text + !Text + +data FormResult a = FormMissing + | FormFailure [Text] + | FormSuccess a + deriving Show +instance Functor FormResult where + fmap _ FormMissing = FormMissing + fmap _ (FormFailure errs) = FormFailure errs + fmap f (FormSuccess a) = FormSuccess $ f a +instance Applicative FormResult where + pure = FormSuccess + (FormSuccess f) <*> (FormSuccess g) = FormSuccess $ f g + (FormFailure x) <*> (FormFailure y) = FormFailure $ x ++ y + (FormFailure x) <*> _ = FormFailure x + _ <*> (FormFailure y) = FormFailure y + _ <*> _ = FormMissing +instance Monoid m => Monoid (FormResult m) where + mempty = pure mempty + mappend x y = (<>) +instance Semigroup m => Semigroup (FormResult m) where + x <> y = (<>) <$> x <*> y + +mreq :: MonadIO m => String -> MForm m (FormResult Text, ()) +-- fast +--mreq v = pure (FormFailure [], ()) +-- slow +mreq v = mhelper v (\m l -> FormFailure ["fail"]) FormSuccess + +askParams :: Monad m => MForm m (Maybe [(String, Text)]) +askParams = do + (x, _, _) <- ask + return $ liftM fst x + +mhelper + :: MonadIO m + => String + -> (() -> () -> FormResult b) -- on missing + -> (Text -> FormResult b) -- on success + -> MForm m (FormResult b, ()) +mhelper v onMissing onFound = do + -- without tell, also faster + tell (Any True) + -- with different "askParams": faster. + -- mp <- liftIO $ read <$> readFile v + mp <- askParams + (res, x) <- case mp of + Nothing -> return (FormMissing, ()) + Just p -> do + return $ case lookup v p of + Nothing -> (onMissing () (), ()) + Just t -> (onFound t, ()) + return (res, x) + +-- not inlining, also faster: +-- {-# NOINLINE mhelper #-} + +sampleForm2 :: MForm Handler (FormResult HugeStruct) +sampleForm2 = do + (x01, _) <- mreq "UNUSED" + (x02, _) <- mreq "UNUSED" + (x03, _) <- mreq "UNUSED" + (x04, _) <- mreq "UNUSED" + (x05, _) <- mreq "UNUSED" + (x06, _) <- mreq "UNUSED" + (x07, _) <- mreq "UNUSED" + (x08, _) <- mreq "UNUSED" + (x09, _) <- mreq "UNUSED" + (x10, _) <- mreq "UNUSED" + (x11, _) <- mreq "UNUSED" + + let hugeStructRes = HugeStruct + <$> x01 + <*> x02 + <*> x03 + <*> x04 + <*> x05 + <*> x06 + <*> x07 + <*> x08 + <*> x09 + <*> x10 + <*> x11 + + pure hugeStructRes + + +main :: IO () +main = pure () ===================================== testsuite/tests/perf/compiler/T18140.hs ===================================== @@ -0,0 +1,57 @@ +-- Exponential with GHC 8.10 + +{-# LANGUAGE BangPatterns #-} +module T18140 where + + +data D = D + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + !(Maybe Bool) + +maMB :: Maybe Bool -> Maybe Bool -> Maybe Bool +maMB Nothing y = y +maMB x Nothing = x +maMB (Just x) (Just y) = Just (maB x y) + +maB :: Bool -> Bool -> Bool +maB _ y = y + +maD :: D -> D -> D +maD (D x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9 x'10 x'11 x'12 x'13 x'14 x'15 x'16 x'17 x'18) + (D y'1 y'2 y'3 y'4 y'5 y'6 y'7 y'8 y'9 y'10 y'11 y'12 y'13 y'14 y'15 y'16 y'17 y'18) + = D + (maMB x'1 y'1) + (maMB x'2 y'2) + (maMB x'3 y'3) + (maMB x'4 y'4) + (maMB x'5 y'5) + (maMB x'6 y'6) + (maMB x'7 y'7) + (maMB x'8 y'8) + (maMB x'9 y'9) + (maMB x'10 y'10) + (maMB x'11 y'11) + (maMB x'12 y'12) + (maMB x'13 y'13) + (maMB x'14 y'14) + (maMB x'15 y'15) + (maMB x'16 y'16) + (maMB x'17 y'17) + (maMB x'18 y'18) + ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -388,3 +388,24 @@ test ('T18282', ], compile, ['-v0 -O']) +test ('T18140', + [ collect_compiler_stats('bytes allocated',2) + ], + compile, + ['-v0 -O']) +test('T10421', + [ only_ways(['normal']), + collect_compiler_stats('bytes allocated', 1) + ], + multimod_compile, + ['T10421', '-v0 -O']) +test ('T13253', + [ collect_compiler_stats('bytes allocated',2) + ], + compile, + ['-v0 -O']) +test ('T13253-spj', + [ collect_compiler_stats('bytes allocated',2) + ], + compile, + ['-v0 -O']) ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -94,11 +94,11 @@ g [InlPrag=NOUSERINLINE[2]] :: Bool -> Bool -> Int -> Int Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) - Tmpl= \ (w [Occ=Once] :: Bool) - (w1 [Occ=Once] :: Bool) - (w2 [Occ=Once!] :: Int) -> - case w2 of { GHC.Types.I# ww1 [Occ=Once] -> - case T13143.$wg w w1 ww1 of ww2 [Occ=Once] { __DEFAULT -> + Tmpl= \ (w [Occ=Once1] :: Bool) + (w1 [Occ=Once1] :: Bool) + (w2 [Occ=Once1!] :: Int) -> + case w2 of { GHC.Types.I# ww1 [Occ=Once1] -> + case T13143.$wg w w1 ww1 of ww2 [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww2 } }}] ===================================== testsuite/tests/simplCore/should_compile/T15631.stdout ===================================== @@ -3,5 +3,5 @@ case GHC.List.reverse1 @a w (GHC.Types.[] @a) of { [] -> case Foo.f1 @a of { GHC.Types.I# v1 -> GHC.Prim.+# ww2 v1 }; case GHC.List.$wlenAcc - case Foo.$wf @a w of ww [Occ=Once] { __DEFAULT -> + case Foo.$wf @a w of ww [Occ=Once1] { __DEFAULT -> case Foo.$wf @a w of ww { __DEFAULT -> GHC.Types.I# ww } ===================================== testsuite/tests/simplCore/should_compile/T17901.stdout ===================================== @@ -1,14 +1,14 @@ - (wombat1 [Occ=Once*!] :: T -> p) + (wombat1 [Occ=Once3!] :: T -> p) A -> wombat1 T17901.A; B -> wombat1 T17901.B; C -> wombat1 T17901.C = \ (@p) (wombat1 :: T -> p) (x :: T) -> case x of wild { __DEFAULT -> wombat1 wild } - Tmpl= \ (@p) (wombat2 [Occ=Once!] :: S -> p) (x [Occ=Once] :: S) -> - case x of wild [Occ=Once] { __DEFAULT -> wombat2 wild }}] + (wombat2 [Occ=Once1!] :: S -> p) + case x of wild [Occ=Once1] { __DEFAULT -> wombat2 wild }}] = \ (@p) (wombat2 :: S -> p) (x :: S) -> case x of wild { __DEFAULT -> wombat2 wild } - Tmpl= \ (@p) (wombat3 [Occ=Once!] :: W -> p) (x [Occ=Once] :: W) -> - case x of wild [Occ=Once] { __DEFAULT -> wombat3 wild }}] + (wombat3 [Occ=Once1!] :: W -> p) + case x of wild [Occ=Once1] { __DEFAULT -> wombat3 wild }}] = \ (@p) (wombat3 :: W -> p) (x :: W) -> case x of wild { __DEFAULT -> wombat3 wild } ===================================== testsuite/tests/simplCore/should_compile/T18355.stderr ===================================== @@ -12,10 +12,10 @@ f :: forall {a}. Num a => a -> Bool -> a -> a WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=4,unsat_ok=True,boring_ok=False) Tmpl= \ (@a) - ($dNum [Occ=Once*] :: Num a) - (x [Occ=Once*] :: a) - (b [Occ=Once!] :: Bool) - (eta [Occ=Once*, OS=OneShot] :: a) -> + ($dNum [Occ=Once2] :: Num a) + (x [Occ=Once2] :: a) + (b [Occ=Once1!] :: Bool) + (eta [Occ=Once2, OS=OneShot] :: a) -> case b of { False -> - @a $dNum x eta; True -> + @a $dNum x eta @@ -41,7 +41,7 @@ T18355.$trModule4 = "main"# T18355.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T18355.$trModule3 = GHC.Types.TrNameS T18355.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -55,14 +55,14 @@ T18355.$trModule2 = "T18355"# T18355.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T18355.$trModule1 = GHC.Types.TrNameS T18355.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18355.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T18355.$trModule = GHC.Types.Module T18355.$trModule3 T18355.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T3717.stderr ===================================== @@ -61,9 +61,9 @@ foo [InlPrag=NOUSERINLINE[2]] :: Int -> Int Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (w [Occ=Once!] :: Int) -> - case w of { GHC.Types.I# ww1 [Occ=Once] -> - case T3717.$wfoo ww1 of ww2 [Occ=Once] { __DEFAULT -> + Tmpl= \ (w [Occ=Once1!] :: Int) -> + case w of { GHC.Types.I# ww1 [Occ=Once1] -> + case T3717.$wfoo ww1 of ww2 [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww2 } }}] ===================================== testsuite/tests/simplCore/should_compile/T3772.stdout ===================================== @@ -69,8 +69,8 @@ foo [InlPrag=NOUSERINLINE[final]] :: Int -> () Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (w [Occ=Once!] :: Int) -> - case w of { GHC.Types.I# ww1 [Occ=Once] -> T3772.$wfoo ww1 }}] + Tmpl= \ (w [Occ=Once1!] :: Int) -> + case w of { GHC.Types.I# ww1 [Occ=Once1] -> T3772.$wfoo ww1 }}] foo = \ (w :: Int) -> case w of { GHC.Types.I# ww1 -> T3772.$wfoo ww1 } ===================================== testsuite/tests/simplCore/should_compile/T4908.stderr ===================================== @@ -85,8 +85,8 @@ f [InlPrag=NOUSERINLINE[2]] :: Int -> (Int, Int) -> Bool Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (w [Occ=Once!] :: Int) (w1 [Occ=Once] :: (Int, Int)) -> - case w of { I# ww1 [Occ=Once] -> T4908.$wf ww1 w1 }}] + Tmpl= \ (w [Occ=Once1!] :: Int) (w1 [Occ=Once1] :: (Int, Int)) -> + case w of { I# ww1 [Occ=Once1] -> T4908.$wf ww1 w1 }}] f = \ (w :: Int) (w1 :: (Int, Int)) -> case w of { I# ww1 -> T4908.$wf ww1 w1 } ===================================== testsuite/tests/simplCore/should_compile/T4930.stderr ===================================== @@ -61,9 +61,9 @@ foo [InlPrag=NOUSERINLINE[2]] :: Int -> Int Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (w [Occ=Once!] :: Int) -> - case w of { GHC.Types.I# ww1 [Occ=Once] -> - case T4930.$wfoo ww1 of ww2 [Occ=Once] { __DEFAULT -> + Tmpl= \ (w [Occ=Once1!] :: Int) -> + case w of { GHC.Types.I# ww1 [Occ=Once1] -> + case T4930.$wfoo ww1 of ww2 [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww2 } }}] ===================================== testsuite/tests/simplCore/should_compile/T5366.stdout ===================================== @@ -1,2 +1,2 @@ - case ds of { Bar dt [Occ=Once] _ [Occ=Dead] -> GHC.Types.I# dt }}] + case ds of { Bar dt [Occ=Once1] _ [Occ=Dead] -> GHC.Types.I# dt }}] f = \ (ds :: Bar) -> case ds of { Bar dt dt1 -> GHC.Types.I# dt } ===================================== testsuite/tests/simplCore/should_compile/T7360.stderr ===================================== @@ -13,11 +13,11 @@ T7360.$WFoo3 [InlPrag=INLINE[final] CONLIKE] :: Int #-> Foo Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (dt [Occ=Once!] :: Int) -> - case dt of { GHC.Types.I# dt [Occ=Once] -> T7360.Foo3 dt }}] + Tmpl= \ (dt [Occ=Once1!] :: Int) -> + case dt of { GHC.Types.I# dt [Occ=Once1] -> T7360.Foo3 dt }}] T7360.$WFoo3 - = \ (dt [Occ=Once!] :: Int) -> - case dt of { GHC.Types.I# dt [Occ=Once] -> T7360.Foo3 dt } + = \ (dt [Occ=Once1!] :: Int) -> + case dt of { GHC.Types.I# dt [Occ=Once1] -> T7360.Foo3 dt } -- RHS size: {terms: 5, types: 2, coercions: 0, joins: 0/0} fun1 [InlPrag=NOINLINE] :: Foo -> () @@ -40,10 +40,10 @@ fun2 :: forall {a}. [a] -> ((), Int) Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (@a) (x [Occ=Once] :: [a]) -> + Tmpl= \ (@a) (x [Occ=Once1] :: [a]) -> (T7360.fun4, - case x of wild [Occ=Once] { __DEFAULT -> - case GHC.List.$wlenAcc @a wild 0# of ww2 [Occ=Once] { __DEFAULT -> + case x of wild [Occ=Once1] { __DEFAULT -> + case GHC.List.$wlenAcc @a wild 0# of ww2 [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww2 } })}] ===================================== testsuite/tests/simplCore/should_compile/T7865.stdout ===================================== @@ -1,7 +1,7 @@ T7865.$wexpensive [InlPrag=NOINLINE] T7865.$wexpensive expensive [InlPrag=NOUSERINLINE[final]] :: Int -> Int - case T7865.$wexpensive ww1 of ww2 [Occ=Once] { __DEFAULT -> + case T7865.$wexpensive ww1 of ww2 [Occ=Once1] { __DEFAULT -> expensive case T7865.$wexpensive ww1 of ww2 { __DEFAULT -> GHC.Types.I# ww2 } case T7865.$wexpensive ww1 of ww2 { __DEFAULT -> ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -118,8 +118,9 @@ Roman.foo_go [InlPrag=NOUSERINLINE[2]] Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (w [Occ=Once] :: Maybe Int) (w1 [Occ=Once] :: Maybe Int) -> - case Roman.$wgo w w1 of ww [Occ=Once] { __DEFAULT -> + Tmpl= \ (w [Occ=Once1] :: Maybe Int) + (w1 [Occ=Once1] :: Maybe Int) -> + case Roman.$wgo w w1 of ww [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww }}] Roman.foo_go @@ -149,8 +150,8 @@ foo :: Int -> Int Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (n [Occ=Once!] :: Int) -> - case n of n1 [Occ=Once] { GHC.Types.I# _ [Occ=Dead] -> + Tmpl= \ (n [Occ=Once1!] :: Int) -> + case n of n1 [Occ=Once1] { GHC.Types.I# _ [Occ=Dead] -> Roman.foo_go (GHC.Maybe.Just @Int n1) Roman.foo1 }}] foo ===================================== testsuite/tests/stranal/should_compile/T16029.stdout ===================================== @@ -1,11 +1,11 @@ T16029.$WMkT [InlPrag=INLINE[final] CONLIKE] :: Int #-> Int #-> T - Tmpl= \ (dt [Occ=Once!] :: Int) (dt [Occ=Once!] :: Int) -> - = \ (dt [Occ=Once!] :: Int) (dt [Occ=Once!] :: Int) -> + Tmpl= \ (dt [Occ=Once1!] :: Int) (dt [Occ=Once1!] :: Int) -> + = \ (dt [Occ=Once1!] :: Int) (dt [Occ=Once1!] :: Int) -> :: GHC.Prim.Int# -> GHC.Prim.Int# = \ (ww :: GHC.Prim.Int#) -> g2 [InlPrag=NOUSERINLINE[2]] :: T -> Int -> Int - Tmpl= \ (w [Occ=Once!] :: T) (w1 [Occ=Once!] :: Int) -> + Tmpl= \ (w [Occ=Once1!] :: T) (w1 [Occ=Once1!] :: Int) -> = \ (w :: T) (w1 :: Int) -> g1 [InlPrag=NOUSERINLINE[2]] :: S -> Int -> Int - Tmpl= \ (w [Occ=Once!] :: S) (w1 [Occ=Once!] :: Int) -> + Tmpl= \ (w [Occ=Once1!] :: S) (w1 [Occ=Once1!] :: Int) -> = \ (w :: S) (w1 :: Int) -> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/adcf83e20c034a1c784a85ea8ca66e3fe7d7fec4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/adcf83e20c034a1c784a85ea8ca66e3fe7d7fec4 You're receiving 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 Jul 13 18:04:14 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 13 Jul 2020 14:04:14 -0400 Subject: [Git][ghc/ghc][wip/winio] 128 commits: hadrian: add flag to skip rebuilding dependency information #17636 Message-ID: <5f0ca21e72d33_80b11684b2c28587db@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/winio at Glasgow Haskell Compiler / GHC Commits: 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 5b0477de by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - c25451f6 by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - b1d83544 by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - b9d85f5f by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Small linker comment and ifdef cleanups - - - - - 0ca94e10 by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Flush event logs eagerly. - - - - - de2f1623 by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 7038c81e by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Implement new Console API - - - - - 70a5325a by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Add IOPort synchronization primitive - - - - - 8d6c6f45 by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Add new io-manager cmdline options - - - - - 5cc2dd0a by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 4aab8b8f by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - ddc3836c by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 93adbcff by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Switch Testsuite to test winio by default - - - - - 1b3874ed by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Multiple refactorings and support changes. - - - - - 000fae31 by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: core threaded I/O manager - - - - - e28055b2 by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: core non-threaded I/O manager - - - - - 76b556fa by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 8d138432 by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Relaxing some constraints in io-manager. - - - - - c41ed24a by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - 4856b439 by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 6ad5f437 by Andreas Klebinger at 2020-07-13T13:58:07-04:00 winio: Expand comments describing non-threaded loop - - - - - 0c45acde by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: fix FileSize unstat-able handles - - - - - 8abcc5ed by Tamar Christina at 2020-07-13T13:58:07-04:00 winio: Implement new tempfile routines for winio - - - - - 7ff397e6 by Andreas Klebinger at 2020-07-13T13:58:07-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - ddcd0f09 by Andreas Klebinger at 2020-07-13T13:58:07-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - 001cc0d4 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 2ad8c2b7 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 5290a446 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - bd4755ff by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 52038bde by Andreas Klebinger at 2020-07-13T13:58:08-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 09fbcd21 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 893f9428 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Remove debug event log trace - - - - - 94ca99a6 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Fix sqrt and openFile009 test cases - - - - - f5ef1e3d by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - 68dff321 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 49f86ce3 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 4c074ce2 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 49e861a6 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Assign thread labels to IOManager threads. - - - - - 980e63a2 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - 5aa36c81 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - 0b17e03d by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - 6a75a711 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Add comments/cleanup an import in base - - - - - 39b1f14c by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - 401c890c by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Make last_event a local variable - - - - - b3c67ebe by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Add comment about thread safety of processCompletion. - - - - - d5ff4c02 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - d83de953 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - f84a3284 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - 00eb74d9 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - cc6a9bb6 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - 6653bee3 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - 56cdd4e1 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Update placeholder comment with actual function name. - - - - - 2404aa3f by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Always lock win32 event queue - - - - - 08e50974 by Andreas Klebinger at 2020-07-13T13:58:08-04:00 winio: Display thread labels when tracing scheduler events. - - - - - c2c976b0 by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 722b0b26 by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - f375933d by Tamar Christina at 2020-07-13T13:58:09-04:00 winio: Various fixes related to rebase and testdriver - - - - - a9cf0dcf by Tamar Christina at 2020-07-13T13:58:09-04:00 winio: Fix rebase artifacts - - - - - f311a21b by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - 7e4351b9 by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - f626c60a by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 95d126af by Tamar Christina at 2020-07-13T13:58:09-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - f5a50b87 by Ben Gamari at 2020-07-13T13:58:09-04:00 winio: Minor comments/renamings - - - - - f737bd3f by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 7f9f6700 by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Small refactor in withOverlappedEx - - - - - 215f6a3e by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: A few comments and commented out dbxIO - - - - - efbb57f2 by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - 94feb85d by Tamar Christina at 2020-07-13T13:58:09-04:00 winio: revert BHandle changes. - - - - - cb4d7f57 by Ben Gamari at 2020-07-13T13:58:09-04:00 winio: Fix imports - - - - - 4242c6c9 by Tamar Christina at 2020-07-13T13:58:09-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - 2fc38dbe by Ben Gamari at 2020-07-13T13:58:09-04:00 winio: Only compile sources on Windows - - - - - dca92fdc by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - aa22c560 by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - 9dcc8564 by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Deduplicate openFile logic - - - - - 73151376 by Tamar Christina at 2020-07-13T13:58:09-04:00 winio: fix -werror issue in encoding file - - - - - 34f1b4d7 by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 42a8e579 by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: add a note about file locking in the RTS. - - - - - 91344d2a by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Add version to @since annotation - - - - - 3d6b70c2 by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 2e1e764b by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - 9824bf6f by Andreas Klebinger at 2020-07-13T13:58:09-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 4032735f by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 93c73c58 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Make it explicit that we only create one IO manager - - - - - 989108cc by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Note why we don't use blocking waits. - - - - - 4c992103 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Remove commented out pragma - - - - - 2cd33b0a by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - 29e8fc53 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Rename SmartHandles to StdHandles - - - - - 135f7f81 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 5ea0f225 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Update IOPort haddocks. - - - - - 07fb00d5 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Add a note cross reference - - - - - 7ee750e5 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - b4127c30 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - b970d4c3 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Remove historical todos - - - - - 24fc5aef by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Update note, remove debugging pragma. - - - - - 82d6e86c by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - d3478ea3 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Remove obsolete comment about cond. variables - - - - - bfb23977 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: fix initial linux validate build - - - - - 74f91f86 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Fix ThreadDelay001 CPP - - - - - cf846079 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 32d670a3 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - 275dadb9 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - 3a7b7e4a by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 19ccf490 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 65037599 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 262784ab by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Also accept T7037 stderr - - - - - 93b82ba1 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: fix cabal04 by filtering rts args - - - - - cf915416 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: fix cabal01 by accepting expected stderr - - - - - aec82346 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 475be3ee by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - 81b910f8 by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: fix tempfiles test on linux - - - - - 269514fb by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Accept accepted stderr for T3807 - - - - - 6decf2ef by Andreas Klebinger at 2020-07-13T13:58:10-04:00 winio: Accept accepted stderr for linker_unload - - - - - e87c1a43 by Andreas Klebinger at 2020-07-13T13:58:11-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 8c12391f by Tamar Christina at 2020-07-13T13:58:11-04:00 winio: clarify wording on conditional variables. - - - - - 78822644 by Tamar Christina at 2020-07-13T13:58:11-04:00 winio: clarify comment on cooked mode. - - - - - b206c355 by Tamar Christina at 2020-07-13T13:58:11-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - d4efcb1d by Ben Gamari at 2020-07-13T13:58:11-04:00 winio: Bump submodules - - - - - 9514380c by Ben Gamari at 2020-07-13T14:03:54-04:00 testsuite: Add winio and winio_threaded ways - - - - - 30 changed files: - Makefile - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.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/5542c1b232f7427f93056e731980fd8e8837ca31...9514380ca0f445be9ff21fb0d1b7bedb8a22ca11 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5542c1b232f7427f93056e731980fd8e8837ca31...9514380ca0f445be9ff21fb0d1b7bedb8a22ca11 You're receiving 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 Jul 13 18:15:29 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 13 Jul 2020 14:15:29 -0400 Subject: [Git][ghc/ghc][ghc-8.8] gitlab-ci: Disable fedora27-dwarf job Message-ID: <5f0ca4c176b85_80b3f8486b77e4828594d8@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC Commits: d6c2fb7a by Ben Gamari at 2020-07-13T14:14:46-04:00 gitlab-ci: Disable fedora27-dwarf job The Docker image doesn't have libdw installed. - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -517,7 +517,7 @@ release-x86_64-linux-fedora27: <<: *release extends: .build-x86_64-linux-fedora27 -release-x86_64-linux-fedora27-dwarf: +.release-x86_64-linux-fedora27-dwarf: <<: *release extends: .build-x86_64-linux-fedora27 variables: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d6c2fb7a67bddd8ab41bc5f4f66a80f3466d41c3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d6c2fb7a67bddd8ab41bc5f4f66a80f3466d41c3 You're receiving 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 Jul 13 18:53:10 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 13 Jul 2020 14:53:10 -0400 Subject: [Git][ghc/ghc][wip/T18282] 6 commits: Warn about empty Char enumerations (#18402) Message-ID: <5f0cad96169ef_80b11684b2c28631c0@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18282 at Glasgow Haskell Compiler / GHC Commits: c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 27 changed files: - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Match/Literal.hs - compiler/GHC/Tc/Solver/Flatten.hs - hadrian/src/Rules/Test.hs - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/deSugar/should_compile/T16615.stderr - testsuite/tests/dependent/should_compile/dynamic-paper.stderr - testsuite/tests/numeric/should_compile/T14170.stdout - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/perf/compiler/T18282.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T15445.stderr - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4908.stderr - testsuite/tests/simplCore/should_compile/T4930.stderr - testsuite/tests/simplCore/should_compile/T7360.stderr - testsuite/tests/simplCore/should_compile/spec-inline.stderr - testsuite/tests/typecheck/should_compile/T13032.stderr - + testsuite/tests/warnings/should_compile/T18402.hs - + testsuite/tests/warnings/should_compile/T18402.stderr - testsuite/tests/warnings/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -1933,7 +1933,7 @@ completeCall env var cont log_inlining doc = liftIO $ dumpAction dflags - (mkUserStyle alwaysQualify AllTheWay) + (mkDumpStyle alwaysQualify) (dumpOptionsFromFlag Opt_D_dump_inlinings) "" FormatText doc ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -887,16 +887,13 @@ conSize dc n_val_args | n_val_args == 0 = SizeIs 0 emptyBag 10 -- Like variables -- See Note [Unboxed tuple size and result discount] - | isUnboxedTupleCon dc = SizeIs 0 emptyBag (10 * (1 + n_val_args)) + | isUnboxedTupleCon dc = SizeIs 0 emptyBag 10 -- See Note [Constructor size and result discount] - | otherwise = SizeIs 10 emptyBag (10 * (1 + n_val_args)) + | otherwise = SizeIs 10 emptyBag 10 --- XXX still looks to large to me - -{- -Note [Constructor size and result discount] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- 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 @@ -907,14 +904,32 @@ The "result discount" is applied if the result of the call is scrutinised (say by a case). For a constructor application that will mean the constructor application will disappear, so we don't need to charge it to the function. So the discount should at least match the -cost of the constructor application, namely 10. But to give a bit -of extra incentive we give a discount of 10*(1 + n_val_args). - -Simon M tried a MUCH bigger discount: (10 * (10 + n_val_args)), -and said it was an "unambiguous win", but its terribly dangerous -because a function with many many case branches, each finishing with -a constructor, can have an arbitrarily large discount. This led to -terrible code bloat: see #6099. +cost of the constructor application, namely 10. + +Historical note 1: Until Jun 2020 we gave it a "bit of extra +incentive" via a discount of 10*(1 + n_val_args), but that was FAR too +much (#18282). In particular, consider a huge case tree like + + let r = case y1 of + Nothing -> B1 a b c + Just v1 -> case y2 of + Nothing -> B1 c b a + Just v2 -> ... + +If conSize gives a cost of 10 (regardless of n_val_args) and a +discount of 10, that'll make each alternative RHS cost zero. We +charge 10 for each case alternative (see size_up_alt). If we give a +bigger discount (say 20) in conSize, we'll make the case expression +cost *nothing*, and that can make a huge case tree cost nothing. This +leads to massive, sometimes exponenial inlinings (#18282). In short, +don't give a discount that give a negative size to a sub-expression! + +Historical note 2: Much longer ago, Simon M tried a MUCH bigger +discount: (10 * (10 + n_val_args)), and said it was an "unambiguous +win", but its terribly dangerous because a function with many many +case branches, each finishing with a constructor, can have an +arbitrarily large discount. This led to terrible code bloat: see +#6099. Note [Unboxed tuple size and result discount] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -924,7 +939,7 @@ and f wasn't getting inlined. I tried giving unboxed tuples a *result discount* of zero (see the commented-out line). Why? When returned as a result they do not -allocate, so maybe we don't want to charge so much for them If you +allocate, so maybe we don't want to charge so much for them. If you have a non-zero discount here, we find that workers often get inlined back into wrappers, because it look like f x = case $wf x of (# a,b #) -> (a,b) @@ -933,6 +948,9 @@ shrank binary sizes by 0.5% it also made spectral/boyer allocate 5% more. All other changes were very small. So it's not a big deal but I didn't adopt the idea. +When fixing #18282 (see Note [Constructor size and result discount]) +I changed the result discount to be just 10, not 10*(1+n_val_args). + Note [Function and non-function discounts] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We want a discount if the function is applied. A good example is ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -1412,16 +1412,21 @@ defaultDynFlags mySettings llvmConfig = extensions = [], extensionFlags = flattenExtensionFlags Nothing [], - -- The ufCreationThreshold threshold must be reasonably high to - -- take account of possible discounts. - -- E.g. 450 is not enough in 'fulsom' for Interval.sqr to inline - -- into Csg.calc (The unfolding for sqr never makes it into the - -- interface file.) ufCreationThreshold = 750, - ufUseThreshold = 80, - ufFunAppDiscount = 60, - -- Be fairly keen to inline a function if that means - -- we'll be able to pick the right method from a dictionary + -- The ufCreationThreshold threshold must be reasonably high + -- to take account of possible discounts. + -- E.g. 450 is not enough in 'fulsom' for Interval.sqr to + -- inline into Csg.calc (The unfolding for sqr never makes it + -- into the interface file.) + + ufUseThreshold = 90, + -- Last adjusted upwards in #18282, when I reduced + -- the result discount for constructors. + + ufFunAppDiscount = 60, + -- Be fairly keen to inline a function if that means + -- we'll be able to pick the right method from a dictionary + ufDictDiscount = 30, ufDearOp = 40, ufVeryAggressive = False, ===================================== compiler/GHC/HsToCore/Match/Literal.hs ===================================== @@ -261,18 +261,19 @@ but perhaps that does not matter too much. warnAboutEmptyEnumerations :: FamInstEnvs -> DynFlags -> LHsExpr GhcTc -> Maybe (LHsExpr GhcTc) -> LHsExpr GhcTc -> DsM () --- ^ Warns about @[2,3 .. 1]@ which returns the empty list. --- Only works for integral types, not floating point. +-- ^ Warns about @[2,3 .. 1]@ or @['b' .. 'a']@ which return the empty list. +-- For numeric literals, only works for integral types, not floating point. warnAboutEmptyEnumerations fam_envs dflags fromExpr mThnExpr toExpr - | wopt Opt_WarnEmptyEnumerations dflags - , Just from_ty@(from,_) <- getLHsIntegralLit fromExpr + | not $ wopt Opt_WarnEmptyEnumerations dflags + = return () + -- Numeric Literals + | Just from_ty@(from,_) <- getLHsIntegralLit fromExpr , Just (_, tc) <- getNormalisedTyconName fam_envs from_ty , Just mThn <- traverse getLHsIntegralLit mThnExpr , Just (to,_) <- getLHsIntegralLit toExpr , let check :: forall a. (Enum a, Num a) => Proxy a -> DsM () check _proxy - = when (null enumeration) $ - warnDs (Reason Opt_WarnEmptyEnumerations) (text "Enumeration is empty") + = when (null enumeration) raiseWarning where enumeration :: [a] enumeration = case mThn of @@ -296,7 +297,18 @@ warnAboutEmptyEnumerations fam_envs dflags fromExpr mThnExpr toExpr -- See the T10930b test case for an example of where this matters. else return () + -- Char literals (#18402) + | Just fromChar <- getLHsCharLit fromExpr + , Just mThnChar <- traverse getLHsCharLit mThnExpr + , Just toChar <- getLHsCharLit toExpr + , let enumeration = case mThnChar of + Nothing -> [fromChar .. toChar] + Just thnChar -> [fromChar, thnChar .. toChar] + = when (null enumeration) raiseWarning + | otherwise = return () + where + raiseWarning = warnDs (Reason Opt_WarnEmptyEnumerations) (text "Enumeration is empty") getLHsIntegralLit :: LHsExpr GhcTc -> Maybe (Integer, Type) -- ^ See if the expression is an 'Integral' literal. @@ -325,6 +337,14 @@ getSimpleIntegralLit (HsWord64Prim _ i) = Just (i, word64PrimTy) getSimpleIntegralLit (HsInteger _ i ty) = Just (i, ty) getSimpleIntegralLit _ = Nothing +-- | Extract the Char if the expression is a Char literal. +getLHsCharLit :: LHsExpr GhcTc -> Maybe Char +getLHsCharLit (L _ (HsPar _ e)) = getLHsCharLit e +getLHsCharLit (L _ (HsTick _ _ e)) = getLHsCharLit e +getLHsCharLit (L _ (HsBinTick _ _ _ e)) = getLHsCharLit e +getLHsCharLit (L _ (HsLit _ (HsChar _ c))) = Just c +getLHsCharLit _ = Nothing + -- | Convert a pair (Integer, Type) to (Integer, Name) after eventually -- normalising the type getNormalisedTyconName :: FamInstEnvs -> (Integer, Type) -> Maybe (Integer, Name) ===================================== compiler/GHC/Tc/Solver/Flatten.hs ===================================== @@ -954,8 +954,11 @@ faster. This doesn't seem quite worth it, yet. Note [flatten_exact_fam_app_fully performance] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The refactor of GRefl seems to cause performance trouble for T9872x: the allocation of flatten_exact_fam_app_fully_performance increased. See note [Generalized reflexive coercion] in GHC.Core.TyCo.Rep for more information about GRefl and #15192 for the current state. +The refactor of GRefl seems to cause performance trouble for T9872x: +the allocation of flatten_exact_fam_app_fully_performance +increased. See note [Generalized reflexive coercion] in +GHC.Core.TyCo.Rep for more information about GRefl and #15192 for the +current state. The explicit pattern match in homogenise_result helps with T9872a, b, c. ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -75,13 +75,16 @@ testRules = do bindir <- getBinaryDirectory testGhc debugged <- ghcDebugged <$> flavour + dynPrograms <- dynamicGhcPrograms =<< flavour cmd [bindir "ghc" <.> exe] $ concatMap (\p -> ["-package", pkgName p]) depsPkgs ++ ["-o", top -/- path, top -/- sourcePath] ++ -- If GHC is build with debug options, then build check-ppr -- also with debug options. This allows, e.g., to print debug -- messages of various RTS subsystems while using check-ppr. - if debugged then ["-debug"] else [] + if debugged then ["-debug"] else [] ++ + -- If GHC is build dynamic, then build check-ppr also dynamic. + if dynPrograms then ["-dynamic"] else [] root -/- ghcConfigPath %> \_ -> do args <- userSetting defaultTestArgs ===================================== testsuite/tests/deSugar/should_compile/T13208.stdout ===================================== @@ -3,4 +3,4 @@ Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}] f = \ (@p) _ [Occ=Dead] -> GHC.Types.True Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] ===================================== testsuite/tests/deSugar/should_compile/T16615.stderr ===================================== @@ -7,7 +7,7 @@ Result size of Desugar (after optimization) T16615.$trModule :: GHC.Types.Module [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] T16615.$trModule = GHC.Types.Module (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "T16615"#) ===================================== testsuite/tests/dependent/should_compile/dynamic-paper.stderr ===================================== @@ -12,4 +12,4 @@ Simplifier ticks exhausted simplifier non-termination has been judged acceptable. To see detailed counts use -ddump-simpl-stats - Total ticks: 136962 + Total ticks: 136961 ===================================== testsuite/tests/numeric/should_compile/T14170.stdout ===================================== @@ -14,7 +14,7 @@ NatVal.$trModule4 = "main"# NatVal.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] NatVal.$trModule3 = GHC.Types.TrNameS NatVal.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ NatVal.$trModule2 = "NatVal"# NatVal.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] NatVal.$trModule1 = GHC.Types.TrNameS NatVal.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] NatVal.$trModule = GHC.Types.Module NatVal.$trModule3 NatVal.$trModule1 ===================================== testsuite/tests/numeric/should_compile/T14465.stdout ===================================== @@ -7,7 +7,7 @@ Result size of Tidy Core ten :: Natural [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] ten = GHC.Num.Natural.NS 10## -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -21,7 +21,7 @@ M.$trModule4 = "main"# M.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] M.$trModule3 = GHC.Types.TrNameS M.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -35,14 +35,14 @@ M.$trModule2 = "M"# M.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] M.$trModule1 = GHC.Types.TrNameS M.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} M.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] M.$trModule = GHC.Types.Module M.$trModule3 M.$trModule1 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} ===================================== testsuite/tests/numeric/should_compile/T7116.stdout ===================================== @@ -14,7 +14,7 @@ T7116.$trModule4 = "main"# T7116.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7116.$trModule3 = GHC.Types.TrNameS T7116.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T7116.$trModule2 = "T7116"# T7116.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7116.$trModule1 = GHC.Types.TrNameS T7116.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7116.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7116.$trModule = GHC.Types.Module T7116.$trModule3 T7116.$trModule1 ===================================== testsuite/tests/perf/compiler/T18282.hs ===================================== @@ -0,0 +1,40 @@ +module M + ( mkB2 + ) where + +import Control.Monad.Reader +import Data.Maybe + +data A1 = A1 (Maybe String) (Maybe String) (Maybe String) (Maybe String) +data A2 = A2 A1 (Maybe String) (Maybe String) (Maybe String) (Maybe String) + (Maybe String) (Maybe String) (Maybe String) (Maybe String) + +data B1 = B1 !String !String !String !String +data B2 = B2 !B1 !String !String !String !String !String !String !String !String + +type M a = ReaderT [(String, String)] (Either String) a + +resolve :: Maybe String -> String -> M (Maybe String) +resolve (Just x) _ = pure (Just x) +resolve Nothing v = asks $ lookup v + +mkB1 :: A1 -> M B1 +mkB1 (A1 a b c d) = do + a' <- fromMaybe "" <$> resolve a "A" + b' <- fromMaybe "" <$> resolve b "B" + c' <- fromMaybe "" <$> resolve c "C" + d' <- fromMaybe "" <$> resolve d "D" + pure $ B1 a' b' c' d' + +mkB2 :: A2 -> M B2 +mkB2 (A2 a b c d e f g h i) = do + a' <- mkB1 a + b' <- fromMaybe "db" <$> resolve b "B" + c' <- fromMaybe "dc" <$> resolve c "C" + d' <- fromMaybe "dd" <$> resolve d "D" + e' <- fromMaybe "de" <$> resolve e "E" + f' <- fromMaybe "df" <$> resolve f "F" + g' <- fromMaybe "dg" <$> resolve g "G" + h' <- fromMaybe "dh" <$> resolve h "H" + i' <- fromMaybe "di" <$> resolve i "I" + pure $ B2 a' b' c' d' e' f' g' h' i' ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -106,7 +106,7 @@ test('T5642', test('T5837', [ only_ways(['normal']), - collect_compiler_stats('bytes allocated',2) + collect_compiler_stats('bytes allocated',5) ], compile, ['-freduction-depth=50']) @@ -382,3 +382,9 @@ test ('T18304', ], compile, ['-v0 -O']) + +test ('T18282', + [ collect_compiler_stats('bytes allocated',2) + ], + compile, + ['-v0 -O']) ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -34,7 +34,7 @@ T13143.$trModule4 = "main"# T13143.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -48,14 +48,14 @@ T13143.$trModule2 = "T13143"# T13143.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T13143.$trModule1 = GHC.Types.TrNameS T13143.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T13143.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T13143.$trModule = GHC.Types.Module T13143.$trModule3 T13143.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T15445.stderr ===================================== @@ -10,4 +10,8 @@ Rule fired: Class op enumFromTo (BUILTIN) Rule fired: Class op show (BUILTIN) Rule fired: Class op enumFromTo (BUILTIN) Rule fired: eftIntList (GHC.Enum) +Rule fired: ># (BUILTIN) +Rule fired: ==# (BUILTIN) Rule fired: eftIntList (GHC.Enum) +Rule fired: ># (BUILTIN) +Rule fired: ==# (BUILTIN) ===================================== testsuite/tests/simplCore/should_compile/T18013.stderr ===================================== @@ -138,7 +138,7 @@ mapMaybeRule Arity=1, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 150 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 150 10}] mapMaybeRule = \ (@a) (@b) (f :: Rule IO a b) -> case f of { Rule @s t0 g -> @@ -178,7 +178,7 @@ T18013.$trModule4 = "main"# T18013.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + 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} @@ -192,14 +192,14 @@ T18013.$trModule2 = "T18013"# T18013.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + 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 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T18013.$trModule = GHC.Types.Module T18013.$trModule3 T18013.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T3717.stderr ===================================== @@ -14,7 +14,7 @@ T3717.$trModule4 = "main"# T3717.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3717.$trModule3 = GHC.Types.TrNameS T3717.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T3717.$trModule2 = "T3717"# T3717.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3717.$trModule1 = GHC.Types.TrNameS T3717.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T3717.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3717.$trModule = GHC.Types.Module T3717.$trModule3 T3717.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T3772.stdout ===================================== @@ -14,7 +14,7 @@ T3772.$trModule4 = "main"# T3772.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3772.$trModule3 = GHC.Types.TrNameS T3772.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T3772.$trModule2 = "T3772"# T3772.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3772.$trModule1 = GHC.Types.TrNameS T3772.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T3772.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3772.$trModule = GHC.Types.Module T3772.$trModule3 T3772.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T4908.stderr ===================================== @@ -14,7 +14,7 @@ T4908.$trModule4 = "main"# T4908.$trModule3 :: TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4908.$trModule3 = GHC.Types.TrNameS T4908.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T4908.$trModule2 = "T4908"# T4908.$trModule1 :: TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4908.$trModule1 = GHC.Types.TrNameS T4908.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T4908.$trModule :: Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4908.$trModule = GHC.Types.Module T4908.$trModule3 T4908.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T4930.stderr ===================================== @@ -14,7 +14,7 @@ T4930.$trModule4 = "main"# T4930.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4930.$trModule3 = GHC.Types.TrNameS T4930.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T4930.$trModule2 = "T4930"# T4930.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4930.$trModule1 = GHC.Types.TrNameS T4930.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T4930.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4930.$trModule = GHC.Types.Module T4930.$trModule3 T4930.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T7360.stderr ===================================== @@ -65,7 +65,7 @@ T7360.$trModule4 = "main"# T7360.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$trModule3 = GHC.Types.TrNameS T7360.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -79,14 +79,14 @@ T7360.$trModule2 = "T7360"# T7360.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$trModule1 = GHC.Types.TrNameS T7360.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7360.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$trModule = GHC.Types.Module T7360.$trModule3 T7360.$trModule1 @@ -108,14 +108,14 @@ T7360.$tcFoo2 = "Foo"# T7360.$tcFoo1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tcFoo1 = GHC.Types.TrNameS T7360.$tcFoo2 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tcFoo :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tcFoo = GHC.Types.TyCon 1581370841583180512## @@ -143,14 +143,14 @@ T7360.$tc'Foo6 = "'Foo1"# T7360.$tc'Foo5 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo5 = GHC.Types.TrNameS T7360.$tc'Foo6 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo1 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo1 = GHC.Types.TyCon 3986951253261644518## @@ -171,14 +171,14 @@ T7360.$tc'Foo8 = "'Foo2"# T7360.$tc'Foo7 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo7 = GHC.Types.TrNameS T7360.$tc'Foo8 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo2 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo2 = GHC.Types.TyCon 17325079864060690428## @@ -204,14 +204,14 @@ T7360.$tc'Foo11 = "'Foo3"# T7360.$tc'Foo10 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo10 = GHC.Types.TrNameS T7360.$tc'Foo11 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo3 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo3 = GHC.Types.TyCon 3674231676522181654## ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -14,7 +14,7 @@ Roman.$trModule4 = "main"# Roman.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] Roman.$trModule3 = GHC.Types.TrNameS Roman.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ Roman.$trModule2 = "Roman"# Roman.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] Roman.$trModule1 = GHC.Types.TrNameS Roman.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} Roman.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] Roman.$trModule = GHC.Types.Module Roman.$trModule3 Roman.$trModule1 @@ -130,14 +130,14 @@ Roman.foo_go Roman.foo2 :: Int [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] Roman.foo2 = GHC.Types.I# 6# -- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} Roman.foo1 :: Maybe Int [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] Roman.foo1 = GHC.Maybe.Just @Int Roman.foo2 -- RHS size: {terms: 11, types: 4, coercions: 0, joins: 0/0} ===================================== testsuite/tests/typecheck/should_compile/T13032.stderr ===================================== @@ -16,7 +16,7 @@ f = \ (@a) (@b) _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> T13032.$trModule :: GHC.Types.Module [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] T13032.$trModule = GHC.Types.Module (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "T13032"#) ===================================== testsuite/tests/warnings/should_compile/T18402.hs ===================================== @@ -0,0 +1,8 @@ +module T18402 where + +a = ['b' .. 'a'] -- empty +b = ['b', 'a' .. 'c'] -- empty +c = ['b', 'c' .. 'a'] -- empty +d = ['a' .. 'c'] -- not empty +e = ['a', 'c' .. 'b'] -- not empty + ===================================== testsuite/tests/warnings/should_compile/T18402.stderr ===================================== @@ -0,0 +1,9 @@ + +T18402.hs:3:5: warning: [-Wempty-enumerations (in -Wdefault)] + Enumeration is empty + +T18402.hs:4:5: warning: [-Wempty-enumerations (in -Wdefault)] + Enumeration is empty + +T18402.hs:5:5: warning: [-Wempty-enumerations (in -Wdefault)] + Enumeration is empty ===================================== testsuite/tests/warnings/should_compile/all.T ===================================== @@ -30,3 +30,5 @@ test('Overflow', expect_broken_for(16543, ['hpc']), compile, ['']) test('UnusedPackages', normal, multimod_compile, ['UnusedPackages.hs', '-package=bytestring -package=base -package=process -package=ghc -Wunused-packages']) + +test('T18402', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a5ca69c2ba72b5c08e66ac2ca55c6af35f4138e1...7f0b671ee8a65913891c07f157b21d77d6c63036 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a5ca69c2ba72b5c08e66ac2ca55c6af35f4138e1...7f0b671ee8a65913891c07f157b21d77d6c63036 You're receiving 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 Jul 13 22:01:09 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 13 Jul 2020 18:01:09 -0400 Subject: [Git][ghc/ghc][wip/T18412] Allow multiple case branches to have a higher rank type Message-ID: <5f0cd9a51d0bd_80b3f849ba1b940288684d@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18412 at Glasgow Haskell Compiler / GHC Commits: 835b5d0e by Simon Peyton Jones at 2020-07-13T23:00:00+01:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - 20 changed files: - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - testsuite/tests/simplCore/should_compile/T17901.stdout - + testsuite/tests/typecheck/should_compile/T18412.hs - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T10619.stderr - testsuite/tests/typecheck/should_fail/tcfail002.stderr - testsuite/tests/typecheck/should_fail/tcfail104.stderr Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -19,7 +19,7 @@ Note [The Type-related module hierarchy] -- We expose the relevant stuff from this module via the Type module {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE CPP, DeriveDataTypeable, MultiWayIf, PatternSynonyms, BangPatterns #-} +{-# LANGUAGE CPP, MultiWayIf, PatternSynonyms, BangPatterns, DeriveDataTypeable #-} module GHC.Core.TyCo.Rep ( TyThing(..), tyThingCategory, pprTyThingCategory, pprShortTyThing, @@ -2025,6 +2025,12 @@ GHC.Core.Multiplicity above this module. -- | A shorthand for data with an attached 'Mult' element (the multiplicity). data Scaled a = Scaled Mult a deriving (Data.Data) + -- You might think that this would be a natural candiate for + -- Functor, Traversable but Krzysztof says (!3674) "it was too easy + -- to accidentally lift functions (substitutions, zonking etc.) from + -- Type -> Type to Scaled Type -> Scaled Type, ignoring + -- multiplicities and causing bugs". So we don't. + instance (Outputable a) => Outputable (Scaled a) where ppr (Scaled _cnt t) = ppr t ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -48,7 +48,7 @@ module GHC.Core.Type ( mkSpecForAllTy, mkSpecForAllTys, mkVisForAllTys, mkTyCoInvForAllTy, mkInfForAllTy, mkInfForAllTys, - splitForAllTys, splitSomeForAllTys, + splitForAllTys, splitForAllTysReq, splitForAllTysInvis, splitForAllVarBndrs, splitForAllTy_maybe, splitForAllTy, @@ -284,7 +284,7 @@ import GHC.Data.List.SetOps import GHC.Types.Unique ( nonDetCmpUnique ) import GHC.Data.Maybe ( orElse, expectJust ) -import Data.Maybe ( isJust, mapMaybe ) +import Data.Maybe ( isJust ) import Control.Monad ( guard ) -- $type_classification @@ -1526,46 +1526,34 @@ splitForAllTys ty = split ty ty [] split orig_ty ty tvs | Just ty' <- coreView ty = split orig_ty ty' tvs split orig_ty _ tvs = (reverse tvs, orig_ty) --- | Like 'splitForAllTys', but only splits a 'ForAllTy' if @argf_pred argf@ --- is 'True', where @argf@ is the visibility of the @ForAllTy@'s binder and --- @argf_pred@ is a predicate over visibilities provided as an argument to this --- function. Furthermore, each returned tyvar is annotated with its @argf at . -splitSomeForAllTys :: (ArgFlag -> Bool) -> Type -> ([TyCoVarBinder], Type) +-- | Splits the longest initial sequence of ForAllTys' that satisfy +-- @argf_pred@, returning the binders transformed by @argf_pred@ +splitSomeForAllTys :: (ArgFlag -> Maybe af) -> Type -> ([VarBndr TyCoVar af], Type) splitSomeForAllTys argf_pred ty = split ty ty [] where - split _ (ForAllTy tvb@(Bndr _ argf) ty) tvs - | argf_pred argf = split ty ty (tvb:tvs) + split _ (ForAllTy (Bndr tcv argf) ty) tvs + | Just argf' <- argf_pred argf = split ty ty (Bndr tcv argf' : tvs) split orig_ty ty tvs | Just ty' <- coreView ty = split orig_ty ty' tvs split orig_ty _ tvs = (reverse tvs, orig_ty) -- | Like 'splitForAllTys', but only splits 'ForAllTy's with 'Required' type -- variable binders. Furthermore, each returned tyvar is annotated with '()'. splitForAllTysReq :: Type -> ([ReqTVBinder], Type) -splitForAllTysReq ty = - let (all_bndrs, body) = splitSomeForAllTys isVisibleArgFlag ty - req_bndrs = mapMaybe mk_req_bndr_maybe all_bndrs in - ASSERT( req_bndrs `equalLength` all_bndrs ) - (req_bndrs, body) +splitForAllTysReq ty = splitSomeForAllTys argf_pred ty where - mk_req_bndr_maybe :: TyCoVarBinder -> Maybe ReqTVBinder - mk_req_bndr_maybe (Bndr tv argf) = case argf of - Required -> Just $ Bndr tv () - Invisible _ -> Nothing + argf_pred :: ArgFlag -> Maybe () + argf_pred Required = Just () + argf_pred (Invisible {}) = Nothing -- | Like 'splitForAllTys', but only splits 'ForAllTy's with 'Invisible' type -- variable binders. Furthermore, each returned tyvar is annotated with its -- 'Specificity'. splitForAllTysInvis :: Type -> ([InvisTVBinder], Type) -splitForAllTysInvis ty = - let (all_bndrs, body) = splitSomeForAllTys isInvisibleArgFlag ty - inv_bndrs = mapMaybe mk_inv_bndr_maybe all_bndrs in - ASSERT( inv_bndrs `equalLength` all_bndrs ) - (inv_bndrs, body) +splitForAllTysInvis ty = splitSomeForAllTys argf_pred ty where - mk_inv_bndr_maybe :: TyCoVarBinder -> Maybe InvisTVBinder - mk_inv_bndr_maybe (Bndr tv argf) = case argf of - Invisible s -> Just $ Bndr tv s - Required -> Nothing + argf_pred :: ArgFlag -> Maybe Specificity + argf_pred Required = Nothing + argf_pred (Invisible spec) = Just spec -- | Like splitForAllTys, but split only for tyvars. -- This always succeeds, even if it returns only an empty list. Note that the ===================================== compiler/GHC/Core/UsageEnv.hs ===================================== @@ -1,7 +1,7 @@ {-# LANGUAGE ViewPatterns #-} module GHC.Core.UsageEnv (UsageEnv, addUsage, scaleUsage, zeroUE, lookupUE, scaleUE, deleteUE, addUE, Usage(..), unitUE, - supUE, supUEs) where + bottomUE, supUE, supUEs) where import Data.Foldable import GHC.Prelude ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -591,10 +591,6 @@ tcExpr (HsCase x scrut matches) res_ty tcExpr (HsIf x NoSyntaxExprRn pred b1 b2) res_ty -- Ordinary 'if' = do { pred' <- tcLExpr pred (mkCheckExpType boolTy) - ; res_ty <- tauifyExpType res_ty - -- Just like Note [Case branches must never infer a non-tau type] - -- in GHC.Tc.Gen.Match (See #10619) - ; (u1,b1') <- tcCollectingUsage $ tcLExpr b1 res_ty ; (u2,b2') <- tcCollectingUsage $ tcLExpr b2 res_ty ; tcEmitBindingUsage (supUE u1 u2) @@ -611,13 +607,7 @@ tcExpr (HsIf x fun@(SyntaxExprRn {}) pred b1 b2) res_ty ; return (HsIf x fun' pred' b1' b2') } tcExpr (HsMultiIf _ alts) res_ty - = do { res_ty <- if isSingleton alts - then return res_ty - else tauifyExpType res_ty - -- Just like GHC.Tc.Gen.Match - -- Note [Case branches must never infer a non-tau type] - - ; alts' <- mapM (wrapLocM $ tcGRHS match_ctxt res_ty) alts + = do { alts' <- mapM (wrapLocM $ tcGRHS match_ctxt res_ty) alts ; res_ty <- readExpType res_ty ; return (HsMultiIf res_ty alts') } where match_ctxt = MC { mc_what = IfAlt, mc_body = tcBody } ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -164,80 +164,47 @@ tcGRHSsPat grhss res_ty = tcGRHSs match_ctxt grhss (mkCheckExpType res_ty) match_ctxt = MC { mc_what = PatBindRhs, mc_body = tcBody } -{- -************************************************************************ +{- ********************************************************************* * * -\subsection{tcMatch} + tcMatch * * -************************************************************************ - -Note [Case branches must never infer a non-tau type] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider - - case ... of - ... -> \(x :: forall a. a -> a) -> x - ... -> \y -> y - -Should that type-check? The problem is that, if we check the second branch -first, then we'll get a type (b -> b) for the branches, which won't unify -with the polytype in the first branch. If we check the first branch first, -then everything is OK. This order-dependency is terrible. So we want only -proper tau-types in branches (unless a sigma-type is pushed down). -This is what expTypeToType ensures: it replaces an Infer with a fresh -tau-type. - -An even trickier case looks like - - f x True = x undefined - f x False = x () - -Here, we see that the arguments must also be non-Infer. Thus, we must -use expTypeToType on the output of matchExpectedFunTys, not the input. - -But we make a special case for a one-branch case. This is so that - - f = \(x :: forall a. a -> a) -> x - -still gets assigned a polytype. --} +********************************************************************* -} --- | When the MatchGroup has multiple RHSs, convert an Infer ExpType in the --- expected type into TauTvs. --- See Note [Case branches must never infer a non-tau type] -tauifyMultipleMatches :: [LMatch id body] - -> [Scaled ExpType] -> TcM [Scaled ExpType] -tauifyMultipleMatches group exp_tys - | isSingletonMatchGroup group = return exp_tys - | otherwise = mapM (\(Scaled m t) -> - fmap (Scaled m) (tauifyExpType t)) exp_tys - -- NB: In the empty-match case, this ensures we fill in the ExpType +data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module + = MC { mc_what :: HsMatchContext GhcRn, -- What kind of thing this is + mc_body :: Located (body GhcRn) -- Type checker for a body of + -- an alternative + -> ExpRhoType + -> TcM (Located (body GhcTc)) } -- | Type-check a MatchGroup. tcMatches :: (Outputable (body GhcRn)) => TcMatchCtxt body -> [Scaled ExpSigmaType] -- Expected pattern types - -> ExpRhoType -- Expected result-type of the Match. + -> ExpRhoType -- Expected result-type of the Match. -> MatchGroup GhcRn (Located (body GhcRn)) -> TcM (MatchGroup GhcTc (Located (body GhcTc))) -data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module - = MC { mc_what :: HsMatchContext GhcRn, -- What kind of thing this is - mc_body :: Located (body GhcRn) -- Type checker for a body of - -- an alternative - -> ExpRhoType - -> TcM (Located (body GhcTc)) } tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches , mg_origin = origin }) - = do { (Scaled _ rhs_ty):pat_tys <- tauifyMultipleMatches matches ((Scaled One rhs_ty):pat_tys) -- return type has implicitly multiplicity 1, it doesn't matter all that much in this case since it isn't used and is eliminated immediately. - -- See Note [Case branches must never infer a non-tau type] + | null matches -- Deal with case e of {} + -- Since there are no branches, no one else will fill in rhs_ty + -- when in inference mode, so we must do it ourselves, + -- here, using expTypeToType + = do { tcEmitBindingUsage bottomUE + ; pat_tys <- mapM scaledExpTypeToType pat_tys + ; rhs_ty <- expTypeToType rhs_ty + ; return (MG { mg_alts = L l [] + , mg_ext = MatchGroupTc pat_tys rhs_ty + , mg_origin = origin }) } - ; umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches + | otherwise + = do { umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches ; let (usages,matches') = unzip umatches ; tcEmitBindingUsage $ supUEs usages - ; pat_tys <- mapM (\(Scaled m t) -> fmap (Scaled m) (readExpType t)) pat_tys + ; pat_tys <- mapM readScaledExpType pat_tys ; rhs_ty <- readExpType rhs_ty - ; return (MG { mg_alts = L l matches' - , mg_ext = MatchGroupTc pat_tys rhs_ty + ; return (MG { mg_alts = L l matches' + , mg_ext = MatchGroupTc pat_tys rhs_ty , mg_origin = origin }) } ------------- ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -220,8 +220,9 @@ tcPatBndr penv@(PE { pe_ctxt = LetPat { pc_lvl = bind_lvl = do { (co, bndr_ty) <- case scaledThing exp_pat_ty of Check pat_ty -> promoteTcType bind_lvl pat_ty Infer infer_res -> ASSERT( bind_lvl == ir_lvl infer_res ) - -- If we were under a constructor that bumped - -- the level, we'd be in checking mode + -- If we were under a constructor that bumped the + -- level, we'd be in checking mode (see tcConArg) + -- hence this assertion do { bndr_ty <- inferResultToType infer_res ; return (mkTcNomReflCo bndr_ty, bndr_ty) } ; let bndr_mult = scaledMult exp_pat_ty @@ -629,10 +630,9 @@ There are two bits of rebindable syntax: lit1_ty and lit2_ty could conceivably be different. var_ty is the type inferred for x, the variable in the pattern. -If the pushed-down pattern type isn't a tau-type, the two pat_ty's above -could conceivably be different specializations. But this is very much -like the situation in Note [Case branches must be taus] in GHC.Tc.Gen.Match. -So we tauify the pat_ty before proceeding. +If the pushed-down pattern type isn't a tau-type, the two pat_ty's +above could conceivably be different specializations. So we use +expTypeToType on pat_ty before proceeding. Note that we need to type-check the literal twice, because it is used twice, and may be used at different types. The second HsOverLit stored in the ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -36,7 +36,7 @@ import GHC.Tc.Utils.TcType import GHC.Tc.Utils.TcMType import GHC.Tc.Validity ( checkValidType ) import GHC.Tc.Utils.Unify( tcSkolemise, unifyType ) -import GHC.Tc.Utils.Instantiate( topInstantiate ) +import GHC.Tc.Utils.Instantiate( topInstantiate, tcInstTypeBndrs ) import GHC.Tc.Utils.Env( tcLookupId ) import GHC.Tc.Types.Evidence( HsWrapper, (<.>) ) import GHC.Core.Type ( mkTyVarBinders ) @@ -488,7 +488,7 @@ tcInstSig :: TcIdSigInfo -> TcM TcIdSigInst -- Instantiate a type signature; only used with plan InferGen tcInstSig sig@(CompleteSig { sig_bndr = poly_id, sig_loc = loc }) = setSrcSpan loc $ -- Set the binding site of the tyvars - do { (tv_prs, theta, tau) <- tcInstTypeBndrs newMetaTyVarTyVars poly_id + do { (tv_prs, theta, tau) <- tcInstTypeBndrs poly_id -- See Note [Pattern bindings and complete signatures] ; return (TISI { sig_inst_sig = sig ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -16,6 +16,7 @@ import GHC.Prelude import GHC.Tc.Utils.Env import GHC.Tc.Utils.Monad import GHC.Tc.Utils.TcType +import GHC.Tc.Utils.Instantiate( tcInstType ) import GHC.Tc.Instance.Typeable import GHC.Tc.Utils.TcMType import GHC.Tc.Types.Evidence ===================================== compiler/GHC/Tc/Instance/Family.hs ===================================== @@ -21,6 +21,7 @@ import GHC.Core.Coercion import GHC.Tc.Types.Evidence import GHC.Iface.Load import GHC.Tc.Utils.Monad +import GHC.Tc.Utils.Instantiate( freshenTyVarBndrs, freshenCoVarBndrsX ) import GHC.Types.SrcLoc as SrcLoc import GHC.Core.TyCon import GHC.Tc.Utils.TcType @@ -35,7 +36,6 @@ import GHC.Data.Maybe import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs import GHC.Core.TyCo.Ppr ( pprWithExplicitKindsWhen ) -import GHC.Tc.Utils.TcMType import GHC.Types.Name import GHC.Utils.Panic import GHC.Types.Var.Set ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -31,11 +31,12 @@ where import GHC.Prelude import GHC.Hs -import GHC.Tc.Utils.Env import GHC.Tc.Gen.Sig import GHC.Tc.Types.Evidence ( idHsWrapper ) import GHC.Tc.Gen.Bind +import GHC.Tc.Utils.Env import GHC.Tc.Utils.Unify +import GHC.Tc.Utils.Instantiate( tcSuperSkolTyVars ) import GHC.Tc.Gen.HsType import GHC.Tc.Utils.TcMType import GHC.Core.Type ( piResultTys ) ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -16,6 +16,12 @@ module GHC.Tc.Utils.Instantiate ( instCall, instDFunType, instStupidTheta, instTyVarsWith, newWanted, newWanteds, + tcInstType, tcInstTypeBndrs, + tcInstSkolTyVars, tcInstSkolTyVarsX, tcInstSkolTyVarsAt, + tcSkolDFunType, tcSuperSkolTyVars, tcInstSuperSkolTyVarsX, + + freshenTyVarBndrs, freshenCoVarBndrsX, + tcInstInvisibleTyBindersN, tcInstInvisibleTyBinders, tcInstInvisibleTyBinder, newOverloadedLit, mkOverLit, @@ -63,7 +69,7 @@ import GHC.Types.Id.Make( mkDictFunId ) import GHC.Core( Expr(..) ) -- For the Coercion constructor import GHC.Types.Id import GHC.Types.Name -import GHC.Types.Var ( EvVar, tyVarName, VarBndr(..) ) +import GHC.Types.Var import GHC.Core.DataCon import GHC.Types.Var.Env import GHC.Builtin.Names @@ -74,7 +80,7 @@ import GHC.Utils.Outputable import GHC.Types.Basic ( TypeOrKind(..) ) import qualified GHC.LanguageExtensions as LangExt -import Data.List ( sortBy ) +import Data.List ( sortBy, mapAccumL ) import Control.Monad( unless ) import Data.Function ( on ) @@ -451,15 +457,192 @@ mkEqBoxTy co ty1 ty2 mkTyConApp (promoteDataCon eqDataCon) [k, ty1, ty2, mkCoercionTy co] where k = tcTypeKind ty1 -{- -************************************************************************ +{- ********************************************************************* * * - Literals + SkolemTvs (immutable) * * -************************************************************************ +********************************************************************* -} +tcInstType :: ([TyVar] -> TcM (TCvSubst, [TcTyVar])) + -- ^ How to instantiate the type variables + -> Id -- ^ Type to instantiate + -> TcM ([(Name, TcTyVar)], TcThetaType, TcType) -- ^ Result + -- (type vars, preds (incl equalities), rho) +tcInstType inst_tyvars id + | null tyvars -- There may be overloading despite no type variables; + -- (?x :: Int) => Int -> Int + = return ([], theta, tau) + | otherwise + = do { (subst, tyvars') <- inst_tyvars tyvars + ; let tv_prs = map tyVarName tyvars `zip` tyvars' + subst' = extendTCvInScopeSet subst (tyCoVarsOfType rho) + ; return (tv_prs, substTheta subst' theta, substTy subst' tau) } + where + (tyvars, rho) = tcSplitForAllTys (idType id) + (theta, tau) = tcSplitPhiTy rho + +tcInstTypeBndrs :: Id -> TcM ([(Name, InvisTVBinder)], TcThetaType, TcType) + -- (type vars, preds (incl equalities), rho) +-- Instantiate the binders of a type signature with TyVarTvs +tcInstTypeBndrs id + | null tyvars -- There may be overloading despite no type variables; + -- (?x :: Int) => Int -> Int + = return ([], theta, tau) + | otherwise + = do { (subst, tyvars') <- mapAccumLM inst_invis_bndr emptyTCvSubst tyvars + ; let tv_prs = map (tyVarName . binderVar) tyvars `zip` tyvars' + subst' = extendTCvInScopeSet subst (tyCoVarsOfType rho) + ; return (tv_prs, substTheta subst' theta, substTy subst' tau) } + where + (tyvars, rho) = splitForAllTysInvis (idType id) + (theta, tau) = tcSplitPhiTy rho + + inst_invis_bndr :: TCvSubst -> InvisTVBinder + -> TcM (TCvSubst, InvisTVBinder) + inst_invis_bndr subst (Bndr tv spec) + = do { (subst', tv') <- newMetaTyVarTyVarX subst tv + ; return (subst', Bndr tv' spec) } + +tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType) +-- Instantiate a type signature with skolem constants. +-- We could give them fresh names, but no need to do so +tcSkolDFunType dfun + = do { (tv_prs, theta, tau) <- tcInstType tcInstSuperSkolTyVars dfun + ; return (map snd tv_prs, theta, tau) } + +tcSuperSkolTyVars :: [TyVar] -> (TCvSubst, [TcTyVar]) +-- Make skolem constants, but do *not* give them new names, as above +-- Moreover, make them "super skolems"; see comments with superSkolemTv +-- see Note [Kind substitution when instantiating] +-- Precondition: tyvars should be ordered by scoping +tcSuperSkolTyVars = mapAccumL tcSuperSkolTyVar emptyTCvSubst + +tcSuperSkolTyVar :: TCvSubst -> TyVar -> (TCvSubst, TcTyVar) +tcSuperSkolTyVar subst tv + = (extendTvSubstWithClone subst tv new_tv, new_tv) + where + kind = substTyUnchecked subst (tyVarKind tv) + new_tv = mkTcTyVar (tyVarName tv) kind superSkolemTv + +-- | Given a list of @['TyVar']@, skolemize the type variables, +-- returning a substitution mapping the original tyvars to the +-- skolems, and the list of newly bound skolems. +tcInstSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSkolTyVars = tcInstSkolTyVarsX emptyTCvSubst + +tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSkolTyVarsX = tcInstSkolTyVarsPushLevel False + +tcInstSuperSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSuperSkolTyVars = tcInstSuperSkolTyVarsX emptyTCvSubst + +tcInstSuperSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSuperSkolTyVarsX subst = tcInstSkolTyVarsPushLevel True subst + +tcInstSkolTyVarsPushLevel :: Bool -> TCvSubst -> [TyVar] + -> TcM (TCvSubst, [TcTyVar]) +-- Skolemise one level deeper, hence pushTcLevel +-- See Note [Skolemising type variables] +tcInstSkolTyVarsPushLevel overlappable subst tvs + = do { tc_lvl <- getTcLevel + ; let pushed_lvl = pushTcLevel tc_lvl + ; tcInstSkolTyVarsAt pushed_lvl overlappable subst tvs } + +tcInstSkolTyVarsAt :: TcLevel -> Bool + -> TCvSubst -> [TyVar] + -> TcM (TCvSubst, [TcTyVar]) +tcInstSkolTyVarsAt lvl overlappable subst tvs + = freshenTyCoVarsX new_skol_tv subst tvs + where + details = SkolemTv lvl overlappable + new_skol_tv name kind = mkTcTyVar name kind details + +------------------ +freshenTyVarBndrs :: [TyVar] -> TcM (TCvSubst, [TyVar]) +-- ^ Give fresh uniques to a bunch of TyVars, but they stay +-- as TyVars, rather than becoming TcTyVars +-- Used in 'GHC.Tc.Instance.Family.newFamInst', and 'GHC.Tc.Utils.Instantiate.newClsInst' +freshenTyVarBndrs = freshenTyCoVars mkTyVar + +freshenCoVarBndrsX :: TCvSubst -> [CoVar] -> TcM (TCvSubst, [CoVar]) +-- ^ Give fresh uniques to a bunch of CoVars +-- Used in "GHC.Tc.Instance.Family.newFamInst" +freshenCoVarBndrsX subst = freshenTyCoVarsX mkCoVar subst + +------------------ +freshenTyCoVars :: (Name -> Kind -> TyCoVar) + -> [TyVar] -> TcM (TCvSubst, [TyCoVar]) +freshenTyCoVars mk_tcv = freshenTyCoVarsX mk_tcv emptyTCvSubst + +freshenTyCoVarsX :: (Name -> Kind -> TyCoVar) + -> TCvSubst -> [TyCoVar] + -> TcM (TCvSubst, [TyCoVar]) +freshenTyCoVarsX mk_tcv = mapAccumLM (freshenTyCoVarX mk_tcv) + +freshenTyCoVarX :: (Name -> Kind -> TyCoVar) + -> TCvSubst -> TyCoVar -> TcM (TCvSubst, TyCoVar) +-- This a complete freshening operation: +-- the skolems have a fresh unique, and a location from the monad +-- See Note [Skolemising type variables] +freshenTyCoVarX mk_tcv subst tycovar + = do { loc <- getSrcSpanM + ; uniq <- newUnique + ; let old_name = tyVarName tycovar + new_name = mkInternalName uniq (getOccName old_name) loc + new_kind = substTyUnchecked subst (tyVarKind tycovar) + new_tcv = mk_tcv new_name new_kind + subst1 = extendTCvSubstWithClone subst tycovar new_tcv + ; return (subst1, new_tcv) } + +{- Note [Skolemising type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The tcInstSkolTyVars family of functions instantiate a list of TyVars +to fresh skolem TcTyVars. Important notes: + +a) Level allocation. We generally skolemise /before/ calling + pushLevelAndCaptureConstraints. So we want their level to the level + of the soon-to-be-created implication, which has a level ONE HIGHER + than the current level. Hence the pushTcLevel. It feels like a + slight hack. + +b) The [TyVar] should be ordered (kind vars first) + See Note [Kind substitution when instantiating] + +c) It's a complete freshening operation: the skolems have a fresh + unique, and a location from the monad + +d) The resulting skolems are + non-overlappable for tcInstSkolTyVars, + but overlappable for tcInstSuperSkolTyVars + See GHC.Tc.Deriv.Infer Note [Overlap and deriving] for an example + of where this matters. + +Note [Kind substitution when instantiating] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When we instantiate a bunch of kind and type variables, first we +expect them to be topologically sorted. +Then we have to instantiate the kind variables, build a substitution +from old variables to the new variables, then instantiate the type +variables substituting the original kind. + +Exemple: If we want to instantiate + [(k1 :: *), (k2 :: *), (a :: k1 -> k2), (b :: k1)] +we want + [(?k1 :: *), (?k2 :: *), (?a :: ?k1 -> ?k2), (?b :: ?k1)] +instead of the bogus + [(?k1 :: *), (?k2 :: *), (?a :: k1 -> k2), (?b :: k1)] -} +{- ********************************************************************* +* * + Literals +* * +********************************************************************* -} + {- In newOverloadedLit we convert directly to an Int or Integer if we know that's what we want. This may save some time, by not @@ -474,8 +657,6 @@ newOverloadedLit :: HsOverLit GhcRn newOverloadedLit lit@(OverLit { ol_val = val, ol_ext = rebindable }) res_ty | not rebindable - -- all built-in overloaded lits are tau-types, so we can just - -- tauify the ExpType = do { res_ty <- expTypeToType res_ty ; dflags <- getDynFlags ; let platform = targetPlatform dflags ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -31,15 +31,6 @@ module GHC.Tc.Utils.TcMType ( newTauTvDetailsAtLevel, newMetaDetails, newMetaTyVarName, isFilledMetaTyVar_maybe, isFilledMetaTyVar, isUnfilledMetaTyVar, - -------------------------------- - -- Expected types - ExpType(..), ExpSigmaType, ExpRhoType, - mkCheckExpType, - newInferExpType, - readExpType, readExpType_maybe, - expTypeToType, checkingExpType_maybe, checkingExpType, - tauifyExpType, inferResultToType, - -------------------------------- -- Creating new evidence variables newEvVar, newEvVars, newDict, @@ -58,14 +49,18 @@ module GHC.Tc.Utils.TcMType ( -------------------------------- -- Instantiation newMetaTyVars, newMetaTyVarX, newMetaTyVarsX, - newMetaTyVarTyVars, newMetaTyVarTyVarX, + newMetaTyVarTyVarX, newTyVarTyVar, cloneTyVarTyVar, newPatSigTyVar, newSkolemTyVar, newWildCardX, - tcInstType, tcInstTypeBndrs, - tcInstSkolTyVars, tcInstSkolTyVarsX, tcInstSkolTyVarsAt, - tcSkolDFunType, tcSuperSkolTyVars, tcInstSuperSkolTyVarsX, - freshenTyVarBndrs, freshenCoVarBndrsX, + -------------------------------- + -- Expected types + ExpType(..), ExpSigmaType, ExpRhoType, + mkCheckExpType, newInferExpType, tcInfer, + readExpType, readExpType_maybe, readScaledExpType, + expTypeToType, scaledExpTypeToType, + checkingExpType_maybe, checkingExpType, + inferResultToType, fillInferResult, promoteTcType, -------------------------------- -- Zonking and tidying @@ -99,6 +94,8 @@ module GHC.Tc.Utils.TcMType ( -- friends: import GHC.Prelude +import {-# SOURCE #-} GHC.Tc.Utils.Unify( unifyType, unifyKind ) + import GHC.Core.TyCo.Rep import GHC.Core.TyCo.Ppr import GHC.Tc.Utils.TcType @@ -133,7 +130,6 @@ import GHC.Types.Basic ( TypeOrKind(..) ) import Control.Monad import GHC.Data.Maybe -import Data.List ( mapAccumL ) import Control.Arrow ( second ) import qualified Data.Semigroup as Semi @@ -387,16 +383,14 @@ checkCoercionHole cv co | otherwise = False -{- -************************************************************************ +{- ********************************************************************** * - Expected types + ExpType functions * -************************************************************************ - -Note [ExpType] -~~~~~~~~~~~~~~ +********************************************************************** -} +{- Note [ExpType] +~~~~~~~~~~~~~~~~~ An ExpType is used as the "expected type" when type-checking an expression. An ExpType can hold a "hole" that can be filled in by the type-checker. This allows us to have one tcExpr that works in both checking mode and @@ -426,14 +420,12 @@ Consider This is a classic untouchable-variable / ambiguous GADT return type scenario. But, with ExpTypes, we'll be inferring the type of the RHS. -And, because there is only one branch of the case, we won't trigger -Note [Case branches must never infer a non-tau type] of GHC.Tc.Gen.Match. We thus must track a TcLevel in an Inferring ExpType. If we try to -fill the ExpType and find that the TcLevels don't work out, we -fill the ExpType with a tau-tv at the low TcLevel, hopefully to -be worked out later by some means. This is triggered in -test gadt/gadt-escape1. +fill the ExpType and find that the TcLevels don't work out, we fill +the ExpType with a tau-tv at the low TcLevel, hopefully to be worked +out later by some means -- see fillInferResult, and Note [fillInferResult] +This behaviour triggered in test gadt/gadt-escape1. -} -- actual data definition is in GHC.Tc.Utils.TcType @@ -453,6 +445,12 @@ readExpType_maybe :: ExpType -> TcM (Maybe TcType) readExpType_maybe (Check ty) = return (Just ty) readExpType_maybe (Infer (IR { ir_ref = ref})) = readMutVar ref +-- | Same as readExpType, but for Scaled ExpTypes +readScaledExpType :: Scaled ExpType -> TcM (Scaled Type) +readScaledExpType (Scaled m exp_ty) + = do { ty <- readExpType exp_ty + ; return (Scaled m ty) } + -- | Extract a type out of an ExpType. Otherwise, panics. readExpType :: ExpType -> TcM TcType readExpType exp_ty @@ -472,12 +470,10 @@ checkingExpType :: String -> ExpType -> TcType checkingExpType _ (Check ty) = ty checkingExpType err et = pprPanic "checkingExpType" (text err $$ ppr et) -tauifyExpType :: ExpType -> TcM ExpType --- ^ Turn a (Infer hole) type into a (Check alpha), --- where alpha is a fresh unification variable -tauifyExpType (Check ty) = return (Check ty) -- No-op for (Check ty) -tauifyExpType (Infer inf_res) = do { ty <- inferResultToType inf_res - ; return (Check ty) } +scaledExpTypeToType :: Scaled ExpType -> TcM (Scaled TcType) +scaledExpTypeToType (Scaled m exp_ty) + = do { ty <- expTypeToType exp_ty + ; return (Scaled m ty) } -- | Extracts the expected type if there is one, or generates a new -- TauTv if there isn't. @@ -488,209 +484,283 @@ expTypeToType (Infer inf_res) = inferResultToType inf_res inferResultToType :: InferResult -> TcM Type inferResultToType (IR { ir_uniq = u, ir_lvl = tc_lvl , ir_ref = ref }) - = do { rr <- newMetaTyVarTyAtLevel tc_lvl runtimeRepTy - ; tau <- newMetaTyVarTyAtLevel tc_lvl (tYPE rr) - -- See Note [TcLevel of ExpType] - ; writeMutVar ref (Just tau) + = do { mb_inferred_ty <- readTcRef ref + ; tau <- case mb_inferred_ty of + Just ty -> do { ensureMonoType ty + -- See Note [inferResultToType] + ; return ty } + Nothing -> do { rr <- newMetaTyVarTyAtLevel tc_lvl runtimeRepTy + ; tau <- newMetaTyVarTyAtLevel tc_lvl (tYPE rr) + -- See Note [TcLevel of ExpType] + ; writeMutVar ref (Just tau) + ; return tau } ; traceTc "Forcing ExpType to be monomorphic:" (ppr u <+> text ":=" <+> ppr tau) ; return tau } +{- Note [inferResultToType] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +expTypeToType and inferResultType convert an InferResult to a monotype. +It must be a monotype because if the InferResult isn't already filled in, +we fill it in with a unification variable (hence monotype). So to preserve +order-independence we check for mono-type-ness even if it *is* filled in +already. + +See also Note [TcLevel of ExpType] above, and +Note [fillInferResult]. +-} + +-- | Infer a type using a fresh ExpType +-- See also Note [ExpType] in "GHC.Tc.Utils.TcMType" +tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) +tcInfer tc_check + = do { res_ty <- newInferExpType + ; result <- tc_check res_ty + ; res_ty <- readExpType res_ty + ; return (result, res_ty) } + +fillInferResult :: TcType -> InferResult -> TcM TcCoercionN +-- If co = fillInferResult t1 t2 +-- => co :: t1 ~ t2 +-- See Note [fillInferResult] +fillInferResult act_res_ty (IR { ir_uniq = u, ir_lvl = res_lvl + , ir_ref = ref }) + = do { mb_exp_res_ty <- readTcRef ref + ; case mb_exp_res_ty of + Just exp_res_ty + -> do { traceTc "Joining inferred ExpType" $ + ppr u <> colon <+> ppr act_res_ty <+> char '~' <+> ppr exp_res_ty + ; cur_lvl <- getTcLevel + ; unless (cur_lvl `sameDepthAs` res_lvl) $ + ensureMonoType act_res_ty + ; unifyType Nothing act_res_ty exp_res_ty } + Nothing + -> do { traceTc "Filling inferred ExpType" $ + ppr u <+> text ":=" <+> ppr act_res_ty + ; (prom_co, act_res_ty) <- promoteTcType res_lvl act_res_ty + ; writeTcRef ref (Just act_res_ty) + ; return prom_co } + } + + +{- Note [fillInferResult] +~~~~~~~~~~~~~~~~~~~~~~~~~ +When inferring, we use fillInferResult to "fill in" the hole in InferResult + data InferResult = IR { ir_uniq :: Unique + , ir_lvl :: TcLevel + , ir_ref :: IORef (Maybe TcType) } + +There are two things to worry about: + +1. What if it is under a GADT or existential pattern match? + - GADTs: a unification variable (and Infer's hole is similar) is untouchable + - Existentials: be careful about skolem-escape + +2. What if it is filled in more than once? E.g. multiple branches of a case + case e of + T1 -> e1 + T2 -> e2 + +Our typing rules are: + +* The RHS of a existential or GADT alternative must always be a + monotype, regardless of the number of alternatives. + +* Multiple non-existential/GADT branches can have (the same) + higher rank type (#18412). E.g. this is OK: + case e of + True -> hr + False -> hr + where hr:: (forall a. a->a) -> Int + c.f. Section 7.1 of "Practical type inference for arbitrary-rank types" + We use choice (2) in that Section. + (GHC 8.10 and earlier used choice (1).) + + But note that + case e of + True -> hr + False -> \x -> hr x + will fail, because we still /infer/ both branches, so the \x will get + a (monotype) unification variable, which will fail to unify with + (forall a. a->a) + +For (1) we can detect the GADT/existential situation by seeing that +the current TcLevel is greater than that stored in ir_lvl of the Infer +ExpType. We bump the level whenever we go past a GADT/existential match. + +Then, before filling the hole use promoteTcType to promote the type +to the outer ir_lvl. promoteTcType does this + - create a fresh unification variable alpha at level ir_lvl + - emits an equality alpha[ir_lvl] ~ ty + - fills the hole with alpha +That forces the type to be a monotype (since unification variables can +only unify with monotypes); and catches skolem-escapes because the +alpha is untouchable until the equality floats out. + +For (2), we simply look to see if the hole is filled already. + - if not, we promote (as above) and fill the hole + - if it is filled, we simply unify with the type that is + already there + +There is one wrinkle. Suppose we have + case e of + T1 -> e1 :: (forall a. a->a) -> Int + G2 -> e2 +where T1 is not GADT or existential, but G2 is a GADT. Then supppose the +T1 alternative fills the hole with (forall a. a->a) -> Int, which is fine. +But now the G2 alternative must not *just* unify with that else we'd risk +allowing through (e2 :: (forall a. a->a) -> Int). If we'd checked G2 first +we'd have filled the hole with a unification variable, which enforces a +monotype. + +So if we check G2 second, we still want to emit a constraint that restricts +the RHS to be a monotype. This is done by ensureMonoType, and it works +by simply generating a constraint (alpha ~ ty), where alpha is a fresh +unification variable. We discard the evidence. + +-} {- ********************************************************************* * * - SkolemTvs (immutable) + Promoting types * * ********************************************************************* -} -tc_inst_internal :: ([VarBndr TyVar flag] -> TcM (TCvSubst, [VarBndr TcTyVar flag])) - -- ^ How to instantiate the type variables - -> [VarBndr TyVar flag] -- ^ Type variable to instantiate - -> Type -- ^ rho - -> TcM ([(Name, VarBndr TcTyVar flag)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tc_inst_internal _inst_tyvars [] rho = - let -- There may be overloading despite no type variables; - -- (?x :: Int) => Int -> Int - (theta, tau) = tcSplitPhiTy rho - in - return ([], theta, tau) -tc_inst_internal inst_tyvars tyvars rho = - do { (subst, tyvars') <- inst_tyvars tyvars - ; let (theta, tau) = tcSplitPhiTy (substTyAddInScope subst rho) - tv_prs = map (tyVarName . binderVar) tyvars `zip` tyvars' - ; return (tv_prs, theta, tau) } - -tcInstType :: ([TyVar] -> TcM (TCvSubst, [TcTyVar])) - -- ^ How to instantiate the type variables - -> Id -- ^ Type to instantiate - -> TcM ([(Name, TcTyVar)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tcInstType inst_tyvars id = - do { let (tyvars, rho) = splitForAllTys (idType id) - tyvars' = mkTyVarBinders () tyvars - ; (tv_prs, preds, rho) <- tc_inst_internal inst_tyvar_bndrs tyvars' rho - ; let tv_prs' = map (\(name, bndr) -> (name, binderVar bndr)) tv_prs - ; return (tv_prs', preds, rho) } - where - inst_tyvar_bndrs :: [VarBndr TyVar ()] -> TcM (TCvSubst, [VarBndr TcTyVar ()]) - inst_tyvar_bndrs bndrs = do { (subst, tvs) <- inst_tyvars $ binderVars bndrs - ; let tvbnds = map (\tv -> Bndr tv ()) tvs - ; return (subst, tvbnds) } - -tcInstTypeBndrs :: ([VarBndr TyVar Specificity] -> TcM (TCvSubst, [VarBndr TcTyVar Specificity])) - -- ^ How to instantiate the type variables - -> Id -- ^ Type to instantiate - -> TcM ([(Name, VarBndr TcTyVar Specificity)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tcInstTypeBndrs inst_tyvars id = - let (tyvars, rho) = splitForAllTysInvis (idType id) - in tc_inst_internal inst_tyvars tyvars rho - -tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType) --- Instantiate a type signature with skolem constants. --- We could give them fresh names, but no need to do so -tcSkolDFunType dfun - = do { (tv_prs, theta, tau) <- tcInstType tcInstSuperSkolTyVars dfun - ; return (map snd tv_prs, theta, tau) } - -tcSuperSkolTyVars :: [TyVar] -> (TCvSubst, [TcTyVar]) --- Make skolem constants, but do *not* give them new names, as above --- Moreover, make them "super skolems"; see comments with superSkolemTv --- see Note [Kind substitution when instantiating] --- Precondition: tyvars should be ordered by scoping -tcSuperSkolTyVars = mapAccumL tcSuperSkolTyVar emptyTCvSubst - -tcSuperSkolTyVar :: TCvSubst -> TyVar -> (TCvSubst, TcTyVar) -tcSuperSkolTyVar subst tv - = (extendTvSubstWithClone subst tv new_tv, new_tv) - where - kind = substTyUnchecked subst (tyVarKind tv) - new_tv = mkTcTyVar (tyVarName tv) kind superSkolemTv - --- | Given a list of @['TyVar']@, skolemize the type variables, --- returning a substitution mapping the original tyvars to the --- skolems, and the list of newly bound skolems. -tcInstSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSkolTyVars = tcInstSkolTyVarsX emptyTCvSubst - -tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSkolTyVarsX = tcInstSkolTyVarsPushLevel False - -tcInstSuperSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSuperSkolTyVars = tcInstSuperSkolTyVarsX emptyTCvSubst - -tcInstSuperSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSuperSkolTyVarsX subst = tcInstSkolTyVarsPushLevel True subst - -tcInstSkolTyVarsPushLevel :: Bool -> TCvSubst -> [TyVar] - -> TcM (TCvSubst, [TcTyVar]) --- Skolemise one level deeper, hence pushTcLevel --- See Note [Skolemising type variables] -tcInstSkolTyVarsPushLevel overlappable subst tvs - = do { tc_lvl <- getTcLevel - ; let pushed_lvl = pushTcLevel tc_lvl - ; tcInstSkolTyVarsAt pushed_lvl overlappable subst tvs } - -tcInstSkolTyVarsAt :: TcLevel -> Bool - -> TCvSubst -> [TyVar] - -> TcM (TCvSubst, [TcTyVar]) -tcInstSkolTyVarsAt lvl overlappable subst tvs - = freshenTyCoVarsX new_skol_tv subst tvs +ensureMonoType :: TcType -> TcM () +-- Assuming that the argument type is of kind (TYPE r), +-- ensure that it is a /monotype/ +-- If it is not a monotype we can see right away (since unification +-- varibles and type-function applications stand for monotypes), but +-- we emit a Wanted equality just to delay the error message until later +ensureMonoType res_ty + | isTauTy res_ty -- isTauTy doesn't need zonking or anything + = return () + | otherwise + = do { mono_ty <- newOpenFlexiTyVarTy + ; let eq_orig = TypeEqOrigin { uo_actual = res_ty + , uo_expected = mono_ty + , uo_thing = Nothing + , uo_visible = False } + + ; _co <- emitWantedEq eq_orig TypeLevel Nominal res_ty mono_ty + ; return () } + +promoteTcType :: TcLevel -> TcType -> TcM (TcCoercion, TcType) +-- See Note [Promoting a type] +-- See also Note [fillInferResult] +-- promoteTcType level ty = (co, ty') +-- * Returns ty' whose max level is just 'level' +-- and whose kind is ~# to the kind of 'ty' +-- and whose kind has form TYPE rr +-- * and co :: ty ~ ty' +-- * and emits constraints to justify the coercion +promoteTcType dest_lvl ty + = do { cur_lvl <- getTcLevel + ; if (cur_lvl `sameDepthAs` dest_lvl) + then dont_promote_it + else promote_it } where - details = SkolemTv lvl overlappable - new_skol_tv name kind = mkTcTyVar name kind details - ------------------- -freshenTyVarBndrs :: [TyVar] -> TcM (TCvSubst, [TyVar]) --- ^ Give fresh uniques to a bunch of TyVars, but they stay --- as TyVars, rather than becoming TcTyVars --- Used in 'GHC.Tc.Instance.Family.newFamInst', and 'GHC.Tc.Utils.Instantiate.newClsInst' -freshenTyVarBndrs = freshenTyCoVars mkTyVar - -freshenCoVarBndrsX :: TCvSubst -> [CoVar] -> TcM (TCvSubst, [CoVar]) --- ^ Give fresh uniques to a bunch of CoVars --- Used in "GHC.Tc.Instance.Family.newFamInst" -freshenCoVarBndrsX subst = freshenTyCoVarsX mkCoVar subst - ------------------- -freshenTyCoVars :: (Name -> Kind -> TyCoVar) - -> [TyVar] -> TcM (TCvSubst, [TyCoVar]) -freshenTyCoVars mk_tcv = freshenTyCoVarsX mk_tcv emptyTCvSubst - -freshenTyCoVarsX :: (Name -> Kind -> TyCoVar) - -> TCvSubst -> [TyCoVar] - -> TcM (TCvSubst, [TyCoVar]) -freshenTyCoVarsX mk_tcv = mapAccumLM (freshenTyCoVarX mk_tcv) - -freshenTyCoVarX :: (Name -> Kind -> TyCoVar) - -> TCvSubst -> TyCoVar -> TcM (TCvSubst, TyCoVar) --- This a complete freshening operation: --- the skolems have a fresh unique, and a location from the monad --- See Note [Skolemising type variables] -freshenTyCoVarX mk_tcv subst tycovar - = do { loc <- getSrcSpanM - ; uniq <- newUnique - ; let old_name = tyVarName tycovar - new_name = mkInternalName uniq (getOccName old_name) loc - new_kind = substTyUnchecked subst (tyVarKind tycovar) - new_tcv = mk_tcv new_name new_kind - subst1 = extendTCvSubstWithClone subst tycovar new_tcv - ; return (subst1, new_tcv) } - -{- Note [Skolemising type variables] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The tcInstSkolTyVars family of functions instantiate a list of TyVars -to fresh skolem TcTyVars. Important notes: - -a) Level allocation. We generally skolemise /before/ calling - pushLevelAndCaptureConstraints. So we want their level to the level - of the soon-to-be-created implication, which has a level ONE HIGHER - than the current level. Hence the pushTcLevel. It feels like a - slight hack. - -b) The [TyVar] should be ordered (kind vars first) - See Note [Kind substitution when instantiating] - -c) It's a complete freshening operation: the skolems have a fresh - unique, and a location from the monad - -d) The resulting skolems are - non-overlappable for tcInstSkolTyVars, - but overlappable for tcInstSuperSkolTyVars - See GHC.Tc.Deriv.Infer Note [Overlap and deriving] for an example - of where this matters. - -Note [Kind substitution when instantiating] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we instantiate a bunch of kind and type variables, first we -expect them to be topologically sorted. -Then we have to instantiate the kind variables, build a substitution -from old variables to the new variables, then instantiate the type -variables substituting the original kind. - -Exemple: If we want to instantiate - [(k1 :: *), (k2 :: *), (a :: k1 -> k2), (b :: k1)] -we want - [(?k1 :: *), (?k2 :: *), (?a :: ?k1 -> ?k2), (?b :: ?k1)] -instead of the buggous - [(?k1 :: *), (?k2 :: *), (?a :: k1 -> k2), (?b :: k1)] + promote_it :: TcM (TcCoercion, TcType) + promote_it -- Emit a constraint (alpha :: TYPE rr) ~ ty + -- where alpha and rr are fresh and from level dest_lvl + = do { rr <- newMetaTyVarTyAtLevel dest_lvl runtimeRepTy + ; prom_ty <- newMetaTyVarTyAtLevel dest_lvl (tYPE rr) + ; let eq_orig = TypeEqOrigin { uo_actual = ty + , uo_expected = prom_ty + , uo_thing = Nothing + , uo_visible = False } + + ; co <- emitWantedEq eq_orig TypeLevel Nominal ty prom_ty + ; return (co, prom_ty) } + + dont_promote_it :: TcM (TcCoercion, TcType) + dont_promote_it -- Check that ty :: TYPE rr, for some (fresh) rr + = do { res_kind <- newOpenTypeKind + ; ki_co <- unifyKind Nothing (tcTypeKind ty) res_kind + ; let co = mkTcGReflRightCo Nominal ty ki_co + ; return (co, ty `mkCastTy` ki_co) } + +{- Note [Promoting a type] +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider (#12427) + + data T where + MkT :: (Int -> Int) -> a -> T + + h y = case y of MkT v w -> v + +We'll infer the RHS type with an expected type ExpType of + (IR { ir_lvl = l, ir_ref = ref, ... ) +where 'l' is the TcLevel of the RHS of 'h'. Then the MkT pattern +match will increase the level, so we'll end up in tcSubType, trying to +unify the type of v, + v :: Int -> Int +with the expected type. But this attempt takes place at level (l+1), +rightly so, since v's type could have mentioned existential variables, +(like w's does) and we want to catch that. + +So we + - create a new meta-var alpha[l+1] + - fill in the InferRes ref cell 'ref' with alpha + - emit an equality constraint, thus + [W] alpha[l+1] ~ (Int -> Int) + +That constraint will float outwards, as it should, unless v's +type mentions a skolem-captured variable. + +This approach fails if v has a higher rank type; see +Note [Promotion and higher rank types] + + +Note [Promotion and higher rank types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If v had a higher-rank type, say v :: (forall a. a->a) -> Int, +then we'd emit an equality + [W] alpha[l+1] ~ ((forall a. a->a) -> Int) +which will sadly fail because we can't unify a unification variable +with a polytype. But there is nothing really wrong with the program +here. + +We could just about solve this by "promote the type" of v, to expose +its polymorphic "shape" while still leaving constraints that will +prevent existential escape. But we must be careful! Exposing +the "shape" of the type is precisely what we must NOT do under +a GADT pattern match! So in this case we might promote the type +to + (forall a. a->a) -> alpha[l+1] +and emit the constraint + [W] alpha[l+1] ~ Int +Now the promoted type can fill the ref cell, while the emitted +equality can float or not, according to the usual rules. + +But that's not quite right! We are exposing the arrow! We could +deal with that too: + (forall a. mu[l+1] a a) -> alpha[l+1] +with constraints + [W] alpha[l+1] ~ Int + [W] mu[l+1] ~ (->) +Here we abstract over the '->' inside the forall, in case that +is subject to an equality constraint from a GADT match. + +Note that we kept the outer (->) because that's part of +the polymorphic "shape". And because of impredicativity, +GADT matches can't give equalities that affect polymorphic +shape. + +This reasoning just seems too complicated, so I decided not +to do it. These higher-rank notes are just here to record +the thinking. +-} -************************************************************************ +{- ********************************************************************* * * MetaTvs (meta type variables; mutable) * * -************************************************************************ --} +********************************************************************* -} -{- -Note [TyVarTv] -~~~~~~~~~~~~ +{- Note [TyVarTv] +~~~~~~~~~~~~~~~~~ A TyVarTv can unify with type *variables* only, including other TyVarTvs and skolems. Sometimes, they can unify with type variables that the user would @@ -1031,18 +1101,11 @@ newMetaTyVarsX subst = mapAccumLM newMetaTyVarX subst newMetaTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) -- Make a new unification variable tyvar whose Name and Kind come from -- an existing TyVar. We substitute kind variables in the kind. -newMetaTyVarX subst tyvar = new_meta_tv_x TauTv subst tyvar - -newMetaTyVarTyVars :: [VarBndr TyVar Specificity] - -> TcM (TCvSubst, [VarBndr TcTyVar Specificity]) -newMetaTyVarTyVars = mapAccumLM newMetaTyVarTyVarX emptyTCvSubst +newMetaTyVarX = new_meta_tv_x TauTv -newMetaTyVarTyVarX :: TCvSubst -> (VarBndr TyVar Specificity) - -> TcM (TCvSubst, VarBndr TcTyVar Specificity) +newMetaTyVarTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) -- Just like newMetaTyVarX, but make a TyVarTv -newMetaTyVarTyVarX subst (Bndr tv spec) = - do { (subst', tv') <- new_meta_tv_x TyVarTv subst tv - ; return (subst', (Bndr tv' spec)) } +newMetaTyVarTyVarX = new_meta_tv_x TyVarTv newWildCardX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) newWildCardX subst tv ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -57,7 +57,7 @@ module GHC.Tc.Utils.TcType ( -- These are important because they do not look through newtypes getTyVar, tcSplitForAllTy_maybe, - tcSplitForAllTys, tcSplitSomeForAllTys, + tcSplitForAllTys, tcSplitForAllTysReq, tcSplitForAllTysInvis, tcSplitPiTys, tcSplitPiTy_maybe, tcSplitForAllVarBndrs, tcSplitPhiTy, tcSplitPredFunTy_maybe, @@ -1221,14 +1221,6 @@ tcSplitForAllTys ty = ASSERT( all isTyVar (fst sty) ) sty where sty = splitForAllTys ty --- | Like 'tcSplitForAllTys', but only splits a 'ForAllTy' if @argf_pred argf@ --- is 'True', where @argf@ is the visibility of the @ForAllTy@'s binder and --- @argf_pred@ is a predicate over visibilities provided as an argument to this --- function. All split tyvars are annotated with their @argf at . -tcSplitSomeForAllTys :: (ArgFlag -> Bool) -> Type -> ([TyCoVarBinder], Type) -tcSplitSomeForAllTys argf_pred ty = ASSERT( all (isTyVar . binderVar) (fst sty) ) sty - where sty = splitSomeForAllTys argf_pred ty - -- | Like 'tcSplitForAllTys', but only splits 'ForAllTy's with 'Required' type -- variable binders. All split tyvars are annotated with '()'. tcSplitForAllTysReq :: Type -> ([TcReqTVBinder], Type) ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -61,7 +61,6 @@ import GHC.Types.Name( isSystemName ) import GHC.Tc.Utils.Instantiate import GHC.Core.TyCon import GHC.Builtin.Types -import GHC.Builtin.Types.Prim( tYPE ) import GHC.Types.Var as Var import GHC.Types.Var.Set import GHC.Types.Var.Env @@ -571,10 +570,51 @@ tcSubTypeNC :: CtOrigin -- Used when instantiating -> TcM HsWrapper tcSubTypeNC inst_orig ctxt m_thing ty_actual res_ty = case res_ty of - Infer inf_res -> instantiateAndFillInferResult inst_orig ty_actual inf_res Check ty_expected -> tc_sub_type (unifyType m_thing) inst_orig ctxt ty_actual ty_expected + Infer inf_res -> do { (wrap, rho) <- topInstantiate inst_orig ty_actual + -- See Note [Instantiation of InferResult] + ; co <- fillInferResult rho inf_res + ; return (mkWpCastN co <.> wrap) } + +{- Note [Instantiation of InferResult] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We now always instantiate before filling in InferResult, so that +the result is a TcRhoType: see #17173 for discussion. + +For example: + +1. Consider + f x = (*) + We want to instantiate the type of (*) before returning, else we + will infer the type + f :: forall {a}. a -> forall b. Num b => b -> b -> b + This is surely confusing for users. + + And worse, the monomorphism restriction won't work properly. The MR is + dealt with in simplifyInfer, and simplifyInfer has no way of + instantiating. This could perhaps be worked around, but it may be + hard to know even when instantiation should happen. + +2. Another reason. Consider + f :: (?x :: Int) => a -> a + g y = let ?x = 3::Int in f + Here want to instantiate f's type so that the ?x::Int constraint + gets discharged by the enclosing implicit-parameter binding. + +3. Suppose one defines plus = (+). If we instantiate lazily, we will + infer plus :: forall a. Num a => a -> a -> a. However, the monomorphism + restriction compels us to infer + plus :: Integer -> Integer -> Integer + (or similar monotype). Indeed, the only way to know whether to apply + the monomorphism restriction at all is to instantiate + +There is one place where we don't want to instantiate eagerly, +namely in GHC.Tc.Module.tcRnExpr, which implements GHCi's :type +command. See Note [Implementing :type] in GHC.Tc.Module. +-} + --------------- tcSubTypeSigma :: UserTypeCtxt -> TcSigmaType -> TcSigmaType -> TcM HsWrapper -- External entry point, but no ExpTypes on either side @@ -768,213 +808,6 @@ tcEqMult origin w_actual w_expected = do ; coercion <- uType TypeLevel origin w_actual w_expected ; return $ if isReflCo coercion then WpHole else WpMultCoercion coercion } -{- ********************************************************************** -%* * - ExpType functions: tcInfer, instantiateAndFillInferResult -%* * -%********************************************************************* -} - --- | Infer a type using a fresh ExpType --- See also Note [ExpType] in "GHC.Tc.Utils.TcMType" -tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) -tcInfer tc_check - = do { res_ty <- newInferExpType - ; result <- tc_check res_ty - ; res_ty <- readExpType res_ty - ; return (result, res_ty) } - -instantiateAndFillInferResult :: CtOrigin -> TcType -> InferResult -> TcM HsWrapper --- If wrap = instantiateAndFillInferResult t1 t2 --- => wrap :: t1 ~> t2 --- See Note [Instantiation of InferResult] -instantiateAndFillInferResult orig ty inf_res - = do { (wrap, rho) <- topInstantiate orig ty - ; co <- fillInferResult rho inf_res - ; return (mkWpCastN co <.> wrap) } - -fillInferResult :: TcType -> InferResult -> TcM TcCoercionN --- If wrap = fillInferResult t1 t2 --- => wrap :: t1 ~> t2 -fillInferResult orig_ty (IR { ir_uniq = u, ir_lvl = res_lvl - , ir_ref = ref }) - = do { (ty_co, ty_to_fill_with) <- promoteTcType res_lvl orig_ty - - ; traceTc "Filling ExpType" $ - ppr u <+> text ":=" <+> ppr ty_to_fill_with - - ; when debugIsOn (check_hole ty_to_fill_with) - - ; writeTcRef ref (Just ty_to_fill_with) - - ; return ty_co } - where - check_hole ty -- Debug check only - = do { let ty_lvl = tcTypeLevel ty - ; MASSERT2( not (ty_lvl `strictlyDeeperThan` res_lvl), - ppr u $$ ppr res_lvl $$ ppr ty_lvl $$ - ppr ty <+> dcolon <+> ppr (tcTypeKind ty) $$ ppr orig_ty ) - ; cts <- readTcRef ref - ; case cts of - Just already_there -> pprPanic "writeExpType" - (vcat [ ppr u - , ppr ty - , ppr already_there ]) - Nothing -> return () } - -{- Note [Instantiation of InferResult] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We now always instantiate before filling in InferResult, so that -the result is a TcRhoType: see #17173 for discussion. - -For example: - -1. Consider - f x = (*) - We want to instantiate the type of (*) before returning, else we - will infer the type - f :: forall {a}. a -> forall b. Num b => b -> b -> b - This is surely confusing for users. - - And worse, the monomorphism restriction won't work properly. The MR is - dealt with in simplifyInfer, and simplifyInfer has no way of - instantiating. This could perhaps be worked around, but it may be - hard to know even when instantiation should happen. - -2. Another reason. Consider - f :: (?x :: Int) => a -> a - g y = let ?x = 3::Int in f - Here want to instantiate f's type so that the ?x::Int constraint - gets discharged by the enclosing implicit-parameter binding. - -3. Suppose one defines plus = (+). If we instantiate lazily, we will - infer plus :: forall a. Num a => a -> a -> a. However, the monomorphism - restriction compels us to infer - plus :: Integer -> Integer -> Integer - (or similar monotype). Indeed, the only way to know whether to apply - the monomorphism restriction at all is to instantiate - -There is one place where we don't want to instantiate eagerly, -namely in GHC.Tc.Module.tcRnExpr, which implements GHCi's :type -command. See Note [Implementing :type] in GHC.Tc.Module. - --} - -{- ********************************************************************* -* * - Promoting types -* * -********************************************************************* -} - -promoteTcType :: TcLevel -> TcType -> TcM (TcCoercion, TcType) --- See Note [Promoting a type] --- promoteTcType level ty = (co, ty') --- * Returns ty' whose max level is just 'level' --- and whose kind is ~# to the kind of 'ty' --- and whose kind has form TYPE rr --- * and co :: ty ~ ty' --- * and emits constraints to justify the coercion -promoteTcType dest_lvl ty - = do { cur_lvl <- getTcLevel - ; if (cur_lvl `sameDepthAs` dest_lvl) - then dont_promote_it - else promote_it } - where - promote_it :: TcM (TcCoercion, TcType) - promote_it -- Emit a constraint (alpha :: TYPE rr) ~ ty - -- where alpha and rr are fresh and from level dest_lvl - = do { rr <- newMetaTyVarTyAtLevel dest_lvl runtimeRepTy - ; prom_ty <- newMetaTyVarTyAtLevel dest_lvl (tYPE rr) - ; let eq_orig = TypeEqOrigin { uo_actual = ty - , uo_expected = prom_ty - , uo_thing = Nothing - , uo_visible = False } - - ; co <- emitWantedEq eq_orig TypeLevel Nominal ty prom_ty - ; return (co, prom_ty) } - - dont_promote_it :: TcM (TcCoercion, TcType) - dont_promote_it -- Check that ty :: TYPE rr, for some (fresh) rr - = do { res_kind <- newOpenTypeKind - ; let ty_kind = tcTypeKind ty - kind_orig = TypeEqOrigin { uo_actual = ty_kind - , uo_expected = res_kind - , uo_thing = Nothing - , uo_visible = False } - ; ki_co <- uType KindLevel kind_orig (tcTypeKind ty) res_kind - ; let co = mkTcGReflRightCo Nominal ty ki_co - ; return (co, ty `mkCastTy` ki_co) } - -{- Note [Promoting a type] -~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider (#12427) - - data T where - MkT :: (Int -> Int) -> a -> T - - h y = case y of MkT v w -> v - -We'll infer the RHS type with an expected type ExpType of - (IR { ir_lvl = l, ir_ref = ref, ... ) -where 'l' is the TcLevel of the RHS of 'h'. Then the MkT pattern -match will increase the level, so we'll end up in tcSubType, trying to -unify the type of v, - v :: Int -> Int -with the expected type. But this attempt takes place at level (l+1), -rightly so, since v's type could have mentioned existential variables, -(like w's does) and we want to catch that. - -So we - - create a new meta-var alpha[l+1] - - fill in the InferRes ref cell 'ref' with alpha - - emit an equality constraint, thus - [W] alpha[l+1] ~ (Int -> Int) - -That constraint will float outwards, as it should, unless v's -type mentions a skolem-captured variable. - -This approach fails if v has a higher rank type; see -Note [Promotion and higher rank types] - - -Note [Promotion and higher rank types] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If v had a higher-rank type, say v :: (forall a. a->a) -> Int, -then we'd emit an equality - [W] alpha[l+1] ~ ((forall a. a->a) -> Int) -which will sadly fail because we can't unify a unification variable -with a polytype. But there is nothing really wrong with the program -here. - -We could just about solve this by "promote the type" of v, to expose -its polymorphic "shape" while still leaving constraints that will -prevent existential escape. But we must be careful! Exposing -the "shape" of the type is precisely what we must NOT do under -a GADT pattern match! So in this case we might promote the type -to - (forall a. a->a) -> alpha[l+1] -and emit the constraint - [W] alpha[l+1] ~ Int -Now the promoted type can fill the ref cell, while the emitted -equality can float or not, according to the usual rules. - -But that's not quite right! We are exposing the arrow! We could -deal with that too: - (forall a. mu[l+1] a a) -> alpha[l+1] -with constraints - [W] alpha[l+1] ~ Int - [W] mu[l+1] ~ (->) -Here we abstract over the '->' inside the forall, in case that -is subject to an equality constraint from a GADT match. - -Note that we kept the outer (->) because that's part of -the polymorphic "shape". And because of impredicativity, -GADT matches can't give equalities that affect polymorphic -shape. - -This reasoning just seems too complicated, so I decided not -to do it. These higher-rank notes are just here to record -the thinking. --} {- ********************************************************************* * * ===================================== testsuite/tests/simplCore/should_compile/T17901.stdout ===================================== @@ -1,14 +1,14 @@ - (wombat1 [Occ=Once*!] :: T -> p) + (wombat1 [Occ=Once*!] :: T -> t) A -> wombat1 T17901.A; B -> wombat1 T17901.B; C -> wombat1 T17901.C - = \ (@p) (wombat1 :: T -> p) (x :: T) -> + = \ (@t) (wombat1 :: T -> t) (x :: T) -> case x of wild { __DEFAULT -> wombat1 wild } - Tmpl= \ (@p) (wombat2 [Occ=Once!] :: S -> p) (x [Occ=Once] :: S) -> + Tmpl= \ (@t) (wombat2 [Occ=Once!] :: S -> t) (x [Occ=Once] :: S) -> case x of wild [Occ=Once] { __DEFAULT -> wombat2 wild }}] - = \ (@p) (wombat2 :: S -> p) (x :: S) -> + = \ (@t) (wombat2 :: S -> t) (x :: S) -> case x of wild { __DEFAULT -> wombat2 wild } - Tmpl= \ (@p) (wombat3 [Occ=Once!] :: W -> p) (x [Occ=Once] :: W) -> + Tmpl= \ (@t) (wombat3 [Occ=Once!] :: W -> t) (x [Occ=Once] :: W) -> case x of wild [Occ=Once] { __DEFAULT -> wombat3 wild }}] - = \ (@p) (wombat3 :: W -> p) (x :: W) -> + = \ (@t) (wombat3 :: W -> t) (x :: W) -> case x of wild { __DEFAULT -> wombat3 wild } ===================================== testsuite/tests/typecheck/should_compile/T18412.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RankNTypes #-} + +module T18412 where + +hr :: (forall a. a -> a) -> () +hr _ = () + +foo x = case x of () -> hr + +-- This did not use to be allowed, because the +-- multiple branches have (the same) polytypes +-- Enhancement July 2020 +bar x = case x of True -> hr + False -> hr ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -716,3 +716,4 @@ test('T17775-viewpats-a', normal, compile, ['']) test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) test('T17775-viewpats-d', normal, compile_fail, ['']) +test('T18412', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T10619.stderr ===================================== @@ -1,13 +1,11 @@ -T10619.hs:9:15: error: - • Couldn't match type ‘p’ with ‘forall b. b -> b’ - Expected: p -> p - Actual: (forall a. a -> a) -> forall b. b -> b - ‘p’ is a rigid type variable bound by - the inferred type of foo :: p1 -> p -> p - at T10619.hs:(8,1)-(10,20) - • In the expression: - (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b +T10619.hs:10:14: error: + • Couldn't match type ‘p1’ with ‘forall a. a -> a’ + Expected: (forall a. a -> a) -> forall b. b -> b + Actual: p1 -> p1 + Cannot instantiate unification variable ‘p1’ + with a type involving polytypes: forall a. a -> a + • In the expression: \ y -> y In the expression: if True then ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) @@ -19,15 +17,13 @@ T10619.hs:9:15: error: ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) else \ y -> y - • Relevant bindings include - foo :: p1 -> p -> p (bound at T10619.hs:8:1) T10619.hs:14:15: error: • Couldn't match type ‘p’ with ‘forall a. a -> a’ Expected: p -> p Actual: (forall a. a -> a) -> forall b. b -> b ‘p’ is a rigid type variable bound by - the inferred type of bar :: p1 -> p -> p + the inferred type of bar :: p2 -> p -> p at T10619.hs:(12,1)-(14,66) • In the expression: (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b @@ -43,21 +39,16 @@ T10619.hs:14:15: error: else ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) • Relevant bindings include - bar :: p1 -> p -> p (bound at T10619.hs:12:1) + bar :: p2 -> p -> p (bound at T10619.hs:12:1) -T10619.hs:16:13: error: - • Couldn't match type ‘p’ with ‘forall b. b -> b’ - Expected: p -> p - Actual: (forall a. a -> a) -> forall b. b -> b - ‘p’ is a rigid type variable bound by - the inferred type of baz :: Bool -> p -> p - at T10619.hs:(16,1)-(17,19) - • In the expression: - (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b - In an equation for ‘baz’: - baz True = (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b - • Relevant bindings include - baz :: Bool -> p -> p (bound at T10619.hs:16:1) +T10619.hs:17:13: error: + • Couldn't match type ‘p0’ with ‘forall a. a -> a’ + Expected: (forall a. a -> a) -> forall b. b -> b + Actual: p0 -> p0 + Cannot instantiate unification variable ‘p0’ + with a type involving polytypes: forall a. a -> a + • In the expression: \ y -> y + In an equation for ‘baz’: baz False = \ y -> y T10619.hs:20:14: error: • Couldn't match type ‘p’ with ‘forall a. a -> a’ ===================================== testsuite/tests/typecheck/should_fail/tcfail002.stderr ===================================== @@ -1,8 +1,8 @@ tcfail002.hs:4:7: error: - • Couldn't match expected type ‘p’ with actual type ‘[p]’ + • Couldn't match expected type ‘a’ with actual type ‘[a]’ • In the expression: z In an equation for ‘c’: c z = z • Relevant bindings include - z :: [p] (bound at tcfail002.hs:4:3) - c :: [p] -> p (bound at tcfail002.hs:3:1) + z :: [a] (bound at tcfail002.hs:4:3) + c :: [a] -> a (bound at tcfail002.hs:3:1) ===================================== testsuite/tests/typecheck/should_fail/tcfail104.stderr ===================================== @@ -1,19 +1,22 @@ -tcfail104.hs:14:12: error: +tcfail104.hs:16:12: error: + • Couldn't match type: Char -> Char + with: forall a. a -> a + Expected: (forall a. a -> a) -> Char -> Char + Actual: (Char -> Char) -> Char -> Char + • In the expression: \ x -> x + In the expression: + if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x) + In the expression: + (if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x)) id 'c' + +tcfail104.hs:22:12: error: • Couldn't match type: forall a. a -> a with: Char -> Char Expected: (Char -> Char) -> Char -> Char Actual: (forall a. a -> a) -> Char -> Char • In the expression: \ (x :: forall a. a -> a) -> x In the expression: - if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x) + if v then (\ x -> x) else (\ (x :: forall a. a -> a) -> x) In the expression: - (if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x)) id 'c' - -tcfail104.hs:22:15: error: - • Couldn't match expected type: Char -> Char - with actual type: forall a. a -> a - • When checking that the pattern signature: forall a. a -> a - fits the type of its context: Char -> Char - In the pattern: x :: forall a. a -> a - In the expression: \ (x :: forall a. a -> a) -> x + (if v then (\ x -> x) else (\ (x :: forall a. a -> a) -> x)) id 'c' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/835b5d0ef18db26e93e355e55928059c86f8a688 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/835b5d0ef18db26e93e355e55928059c86f8a688 You're receiving 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 Jul 13 23:08:34 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 13 Jul 2020 19:08:34 -0400 Subject: [Git][ghc/ghc][wip/T18412] Allow multiple case branches to have a higher rank type Message-ID: <5f0ce972755f2_80bda8bdb4291336e@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18412 at Glasgow Haskell Compiler / GHC Commits: e108dd1a by Simon Peyton Jones at 2020-07-14T00:08:10+01:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - 20 changed files: - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - testsuite/tests/simplCore/should_compile/T17901.stdout - + testsuite/tests/typecheck/should_compile/T18412.hs - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T10619.stderr - testsuite/tests/typecheck/should_fail/tcfail002.stderr - testsuite/tests/typecheck/should_fail/tcfail104.stderr Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -19,7 +19,7 @@ Note [The Type-related module hierarchy] -- We expose the relevant stuff from this module via the Type module {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE CPP, DeriveDataTypeable, MultiWayIf, PatternSynonyms, BangPatterns #-} +{-# LANGUAGE CPP, MultiWayIf, PatternSynonyms, BangPatterns, DeriveDataTypeable #-} module GHC.Core.TyCo.Rep ( TyThing(..), tyThingCategory, pprTyThingCategory, pprShortTyThing, @@ -2025,6 +2025,12 @@ GHC.Core.Multiplicity above this module. -- | A shorthand for data with an attached 'Mult' element (the multiplicity). data Scaled a = Scaled Mult a deriving (Data.Data) + -- You might think that this would be a natural candiate for + -- Functor, Traversable but Krzysztof says (!3674) "it was too easy + -- to accidentally lift functions (substitutions, zonking etc.) from + -- Type -> Type to Scaled Type -> Scaled Type, ignoring + -- multiplicities and causing bugs". So we don't. + instance (Outputable a) => Outputable (Scaled a) where ppr (Scaled _cnt t) = ppr t ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -48,7 +48,7 @@ module GHC.Core.Type ( mkSpecForAllTy, mkSpecForAllTys, mkVisForAllTys, mkTyCoInvForAllTy, mkInfForAllTy, mkInfForAllTys, - splitForAllTys, splitSomeForAllTys, + splitForAllTys, splitForAllTysReq, splitForAllTysInvis, splitForAllVarBndrs, splitForAllTy_maybe, splitForAllTy, @@ -284,7 +284,7 @@ import GHC.Data.List.SetOps import GHC.Types.Unique ( nonDetCmpUnique ) import GHC.Data.Maybe ( orElse, expectJust ) -import Data.Maybe ( isJust, mapMaybe ) +import Data.Maybe ( isJust ) import Control.Monad ( guard ) -- $type_classification @@ -1526,46 +1526,34 @@ splitForAllTys ty = split ty ty [] split orig_ty ty tvs | Just ty' <- coreView ty = split orig_ty ty' tvs split orig_ty _ tvs = (reverse tvs, orig_ty) --- | Like 'splitForAllTys', but only splits a 'ForAllTy' if @argf_pred argf@ --- is 'True', where @argf@ is the visibility of the @ForAllTy@'s binder and --- @argf_pred@ is a predicate over visibilities provided as an argument to this --- function. Furthermore, each returned tyvar is annotated with its @argf at . -splitSomeForAllTys :: (ArgFlag -> Bool) -> Type -> ([TyCoVarBinder], Type) +-- | Splits the longest initial sequence of ForAllTys' that satisfy +-- @argf_pred@, returning the binders transformed by @argf_pred@ +splitSomeForAllTys :: (ArgFlag -> Maybe af) -> Type -> ([VarBndr TyCoVar af], Type) splitSomeForAllTys argf_pred ty = split ty ty [] where - split _ (ForAllTy tvb@(Bndr _ argf) ty) tvs - | argf_pred argf = split ty ty (tvb:tvs) + split _ (ForAllTy (Bndr tcv argf) ty) tvs + | Just argf' <- argf_pred argf = split ty ty (Bndr tcv argf' : tvs) split orig_ty ty tvs | Just ty' <- coreView ty = split orig_ty ty' tvs split orig_ty _ tvs = (reverse tvs, orig_ty) -- | Like 'splitForAllTys', but only splits 'ForAllTy's with 'Required' type -- variable binders. Furthermore, each returned tyvar is annotated with '()'. splitForAllTysReq :: Type -> ([ReqTVBinder], Type) -splitForAllTysReq ty = - let (all_bndrs, body) = splitSomeForAllTys isVisibleArgFlag ty - req_bndrs = mapMaybe mk_req_bndr_maybe all_bndrs in - ASSERT( req_bndrs `equalLength` all_bndrs ) - (req_bndrs, body) +splitForAllTysReq ty = splitSomeForAllTys argf_pred ty where - mk_req_bndr_maybe :: TyCoVarBinder -> Maybe ReqTVBinder - mk_req_bndr_maybe (Bndr tv argf) = case argf of - Required -> Just $ Bndr tv () - Invisible _ -> Nothing + argf_pred :: ArgFlag -> Maybe () + argf_pred Required = Just () + argf_pred (Invisible {}) = Nothing -- | Like 'splitForAllTys', but only splits 'ForAllTy's with 'Invisible' type -- variable binders. Furthermore, each returned tyvar is annotated with its -- 'Specificity'. splitForAllTysInvis :: Type -> ([InvisTVBinder], Type) -splitForAllTysInvis ty = - let (all_bndrs, body) = splitSomeForAllTys isInvisibleArgFlag ty - inv_bndrs = mapMaybe mk_inv_bndr_maybe all_bndrs in - ASSERT( inv_bndrs `equalLength` all_bndrs ) - (inv_bndrs, body) +splitForAllTysInvis ty = splitSomeForAllTys argf_pred ty where - mk_inv_bndr_maybe :: TyCoVarBinder -> Maybe InvisTVBinder - mk_inv_bndr_maybe (Bndr tv argf) = case argf of - Invisible s -> Just $ Bndr tv s - Required -> Nothing + argf_pred :: ArgFlag -> Maybe Specificity + argf_pred Required = Nothing + argf_pred (Invisible spec) = Just spec -- | Like splitForAllTys, but split only for tyvars. -- This always succeeds, even if it returns only an empty list. Note that the ===================================== compiler/GHC/Core/UsageEnv.hs ===================================== @@ -1,7 +1,7 @@ {-# LANGUAGE ViewPatterns #-} module GHC.Core.UsageEnv (UsageEnv, addUsage, scaleUsage, zeroUE, lookupUE, scaleUE, deleteUE, addUE, Usage(..), unitUE, - supUE, supUEs) where + bottomUE, supUE, supUEs) where import Data.Foldable import GHC.Prelude ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -591,10 +591,6 @@ tcExpr (HsCase x scrut matches) res_ty tcExpr (HsIf x NoSyntaxExprRn pred b1 b2) res_ty -- Ordinary 'if' = do { pred' <- tcLExpr pred (mkCheckExpType boolTy) - ; res_ty <- tauifyExpType res_ty - -- Just like Note [Case branches must never infer a non-tau type] - -- in GHC.Tc.Gen.Match (See #10619) - ; (u1,b1') <- tcCollectingUsage $ tcLExpr b1 res_ty ; (u2,b2') <- tcCollectingUsage $ tcLExpr b2 res_ty ; tcEmitBindingUsage (supUE u1 u2) @@ -611,13 +607,7 @@ tcExpr (HsIf x fun@(SyntaxExprRn {}) pred b1 b2) res_ty ; return (HsIf x fun' pred' b1' b2') } tcExpr (HsMultiIf _ alts) res_ty - = do { res_ty <- if isSingleton alts - then return res_ty - else tauifyExpType res_ty - -- Just like GHC.Tc.Gen.Match - -- Note [Case branches must never infer a non-tau type] - - ; alts' <- mapM (wrapLocM $ tcGRHS match_ctxt res_ty) alts + = do { alts' <- mapM (wrapLocM $ tcGRHS match_ctxt res_ty) alts ; res_ty <- readExpType res_ty ; return (HsMultiIf res_ty alts') } where match_ctxt = MC { mc_what = IfAlt, mc_body = tcBody } ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -164,80 +164,47 @@ tcGRHSsPat grhss res_ty = tcGRHSs match_ctxt grhss (mkCheckExpType res_ty) match_ctxt = MC { mc_what = PatBindRhs, mc_body = tcBody } -{- -************************************************************************ +{- ********************************************************************* * * -\subsection{tcMatch} + tcMatch * * -************************************************************************ - -Note [Case branches must never infer a non-tau type] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider - - case ... of - ... -> \(x :: forall a. a -> a) -> x - ... -> \y -> y - -Should that type-check? The problem is that, if we check the second branch -first, then we'll get a type (b -> b) for the branches, which won't unify -with the polytype in the first branch. If we check the first branch first, -then everything is OK. This order-dependency is terrible. So we want only -proper tau-types in branches (unless a sigma-type is pushed down). -This is what expTypeToType ensures: it replaces an Infer with a fresh -tau-type. - -An even trickier case looks like - - f x True = x undefined - f x False = x () - -Here, we see that the arguments must also be non-Infer. Thus, we must -use expTypeToType on the output of matchExpectedFunTys, not the input. - -But we make a special case for a one-branch case. This is so that - - f = \(x :: forall a. a -> a) -> x - -still gets assigned a polytype. --} +********************************************************************* -} --- | When the MatchGroup has multiple RHSs, convert an Infer ExpType in the --- expected type into TauTvs. --- See Note [Case branches must never infer a non-tau type] -tauifyMultipleMatches :: [LMatch id body] - -> [Scaled ExpType] -> TcM [Scaled ExpType] -tauifyMultipleMatches group exp_tys - | isSingletonMatchGroup group = return exp_tys - | otherwise = mapM (\(Scaled m t) -> - fmap (Scaled m) (tauifyExpType t)) exp_tys - -- NB: In the empty-match case, this ensures we fill in the ExpType +data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module + = MC { mc_what :: HsMatchContext GhcRn, -- What kind of thing this is + mc_body :: Located (body GhcRn) -- Type checker for a body of + -- an alternative + -> ExpRhoType + -> TcM (Located (body GhcTc)) } -- | Type-check a MatchGroup. tcMatches :: (Outputable (body GhcRn)) => TcMatchCtxt body -> [Scaled ExpSigmaType] -- Expected pattern types - -> ExpRhoType -- Expected result-type of the Match. + -> ExpRhoType -- Expected result-type of the Match. -> MatchGroup GhcRn (Located (body GhcRn)) -> TcM (MatchGroup GhcTc (Located (body GhcTc))) -data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module - = MC { mc_what :: HsMatchContext GhcRn, -- What kind of thing this is - mc_body :: Located (body GhcRn) -- Type checker for a body of - -- an alternative - -> ExpRhoType - -> TcM (Located (body GhcTc)) } tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches , mg_origin = origin }) - = do { (Scaled _ rhs_ty):pat_tys <- tauifyMultipleMatches matches ((Scaled One rhs_ty):pat_tys) -- return type has implicitly multiplicity 1, it doesn't matter all that much in this case since it isn't used and is eliminated immediately. - -- See Note [Case branches must never infer a non-tau type] + | null matches -- Deal with case e of {} + -- Since there are no branches, no one else will fill in rhs_ty + -- when in inference mode, so we must do it ourselves, + -- here, using expTypeToType + = do { tcEmitBindingUsage bottomUE + ; pat_tys <- mapM scaledExpTypeToType pat_tys + ; rhs_ty <- expTypeToType rhs_ty + ; return (MG { mg_alts = L l [] + , mg_ext = MatchGroupTc pat_tys rhs_ty + , mg_origin = origin }) } - ; umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches + | otherwise + = do { umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches ; let (usages,matches') = unzip umatches ; tcEmitBindingUsage $ supUEs usages - ; pat_tys <- mapM (\(Scaled m t) -> fmap (Scaled m) (readExpType t)) pat_tys + ; pat_tys <- mapM readScaledExpType pat_tys ; rhs_ty <- readExpType rhs_ty - ; return (MG { mg_alts = L l matches' - , mg_ext = MatchGroupTc pat_tys rhs_ty + ; return (MG { mg_alts = L l matches' + , mg_ext = MatchGroupTc pat_tys rhs_ty , mg_origin = origin }) } ------------- ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -220,8 +220,9 @@ tcPatBndr penv@(PE { pe_ctxt = LetPat { pc_lvl = bind_lvl = do { (co, bndr_ty) <- case scaledThing exp_pat_ty of Check pat_ty -> promoteTcType bind_lvl pat_ty Infer infer_res -> ASSERT( bind_lvl == ir_lvl infer_res ) - -- If we were under a constructor that bumped - -- the level, we'd be in checking mode + -- If we were under a constructor that bumped the + -- level, we'd be in checking mode (see tcConArg) + -- hence this assertion do { bndr_ty <- inferResultToType infer_res ; return (mkTcNomReflCo bndr_ty, bndr_ty) } ; let bndr_mult = scaledMult exp_pat_ty @@ -629,10 +630,9 @@ There are two bits of rebindable syntax: lit1_ty and lit2_ty could conceivably be different. var_ty is the type inferred for x, the variable in the pattern. -If the pushed-down pattern type isn't a tau-type, the two pat_ty's above -could conceivably be different specializations. But this is very much -like the situation in Note [Case branches must be taus] in GHC.Tc.Gen.Match. -So we tauify the pat_ty before proceeding. +If the pushed-down pattern type isn't a tau-type, the two pat_ty's +above could conceivably be different specializations. So we use +expTypeToType on pat_ty before proceeding. Note that we need to type-check the literal twice, because it is used twice, and may be used at different types. The second HsOverLit stored in the ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -36,7 +36,7 @@ import GHC.Tc.Utils.TcType import GHC.Tc.Utils.TcMType import GHC.Tc.Validity ( checkValidType ) import GHC.Tc.Utils.Unify( tcSkolemise, unifyType ) -import GHC.Tc.Utils.Instantiate( topInstantiate ) +import GHC.Tc.Utils.Instantiate( topInstantiate, tcInstTypeBndrs ) import GHC.Tc.Utils.Env( tcLookupId ) import GHC.Tc.Types.Evidence( HsWrapper, (<.>) ) import GHC.Core.Type ( mkTyVarBinders ) @@ -488,7 +488,7 @@ tcInstSig :: TcIdSigInfo -> TcM TcIdSigInst -- Instantiate a type signature; only used with plan InferGen tcInstSig sig@(CompleteSig { sig_bndr = poly_id, sig_loc = loc }) = setSrcSpan loc $ -- Set the binding site of the tyvars - do { (tv_prs, theta, tau) <- tcInstTypeBndrs newMetaTyVarTyVars poly_id + do { (tv_prs, theta, tau) <- tcInstTypeBndrs poly_id -- See Note [Pattern bindings and complete signatures] ; return (TISI { sig_inst_sig = sig ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -16,6 +16,7 @@ import GHC.Prelude import GHC.Tc.Utils.Env import GHC.Tc.Utils.Monad import GHC.Tc.Utils.TcType +import GHC.Tc.Utils.Instantiate( tcInstType ) import GHC.Tc.Instance.Typeable import GHC.Tc.Utils.TcMType import GHC.Tc.Types.Evidence ===================================== compiler/GHC/Tc/Instance/Family.hs ===================================== @@ -21,6 +21,7 @@ import GHC.Core.Coercion import GHC.Tc.Types.Evidence import GHC.Iface.Load import GHC.Tc.Utils.Monad +import GHC.Tc.Utils.Instantiate( freshenTyVarBndrs, freshenCoVarBndrsX ) import GHC.Types.SrcLoc as SrcLoc import GHC.Core.TyCon import GHC.Tc.Utils.TcType @@ -35,7 +36,6 @@ import GHC.Data.Maybe import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs import GHC.Core.TyCo.Ppr ( pprWithExplicitKindsWhen ) -import GHC.Tc.Utils.TcMType import GHC.Types.Name import GHC.Utils.Panic import GHC.Types.Var.Set ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -31,11 +31,12 @@ where import GHC.Prelude import GHC.Hs -import GHC.Tc.Utils.Env import GHC.Tc.Gen.Sig import GHC.Tc.Types.Evidence ( idHsWrapper ) import GHC.Tc.Gen.Bind +import GHC.Tc.Utils.Env import GHC.Tc.Utils.Unify +import GHC.Tc.Utils.Instantiate( tcSuperSkolTyVars ) import GHC.Tc.Gen.HsType import GHC.Tc.Utils.TcMType import GHC.Core.Type ( piResultTys ) ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -16,6 +16,12 @@ module GHC.Tc.Utils.Instantiate ( instCall, instDFunType, instStupidTheta, instTyVarsWith, newWanted, newWanteds, + tcInstType, tcInstTypeBndrs, + tcInstSkolTyVars, tcInstSkolTyVarsX, tcInstSkolTyVarsAt, + tcSkolDFunType, tcSuperSkolTyVars, tcInstSuperSkolTyVarsX, + + freshenTyVarBndrs, freshenCoVarBndrsX, + tcInstInvisibleTyBindersN, tcInstInvisibleTyBinders, tcInstInvisibleTyBinder, newOverloadedLit, mkOverLit, @@ -63,7 +69,7 @@ import GHC.Types.Id.Make( mkDictFunId ) import GHC.Core( Expr(..) ) -- For the Coercion constructor import GHC.Types.Id import GHC.Types.Name -import GHC.Types.Var ( EvVar, tyVarName, VarBndr(..) ) +import GHC.Types.Var import GHC.Core.DataCon import GHC.Types.Var.Env import GHC.Builtin.Names @@ -74,7 +80,7 @@ import GHC.Utils.Outputable import GHC.Types.Basic ( TypeOrKind(..) ) import qualified GHC.LanguageExtensions as LangExt -import Data.List ( sortBy ) +import Data.List ( sortBy, mapAccumL ) import Control.Monad( unless ) import Data.Function ( on ) @@ -451,15 +457,192 @@ mkEqBoxTy co ty1 ty2 mkTyConApp (promoteDataCon eqDataCon) [k, ty1, ty2, mkCoercionTy co] where k = tcTypeKind ty1 -{- -************************************************************************ +{- ********************************************************************* * * - Literals + SkolemTvs (immutable) * * -************************************************************************ +********************************************************************* -} +tcInstType :: ([TyVar] -> TcM (TCvSubst, [TcTyVar])) + -- ^ How to instantiate the type variables + -> Id -- ^ Type to instantiate + -> TcM ([(Name, TcTyVar)], TcThetaType, TcType) -- ^ Result + -- (type vars, preds (incl equalities), rho) +tcInstType inst_tyvars id + | null tyvars -- There may be overloading despite no type variables; + -- (?x :: Int) => Int -> Int + = return ([], theta, tau) + | otherwise + = do { (subst, tyvars') <- inst_tyvars tyvars + ; let tv_prs = map tyVarName tyvars `zip` tyvars' + subst' = extendTCvInScopeSet subst (tyCoVarsOfType rho) + ; return (tv_prs, substTheta subst' theta, substTy subst' tau) } + where + (tyvars, rho) = tcSplitForAllTys (idType id) + (theta, tau) = tcSplitPhiTy rho + +tcInstTypeBndrs :: Id -> TcM ([(Name, InvisTVBinder)], TcThetaType, TcType) + -- (type vars, preds (incl equalities), rho) +-- Instantiate the binders of a type signature with TyVarTvs +tcInstTypeBndrs id + | null tyvars -- There may be overloading despite no type variables; + -- (?x :: Int) => Int -> Int + = return ([], theta, tau) + | otherwise + = do { (subst, tyvars') <- mapAccumLM inst_invis_bndr emptyTCvSubst tyvars + ; let tv_prs = map (tyVarName . binderVar) tyvars `zip` tyvars' + subst' = extendTCvInScopeSet subst (tyCoVarsOfType rho) + ; return (tv_prs, substTheta subst' theta, substTy subst' tau) } + where + (tyvars, rho) = splitForAllTysInvis (idType id) + (theta, tau) = tcSplitPhiTy rho + + inst_invis_bndr :: TCvSubst -> InvisTVBinder + -> TcM (TCvSubst, InvisTVBinder) + inst_invis_bndr subst (Bndr tv spec) + = do { (subst', tv') <- newMetaTyVarTyVarX subst tv + ; return (subst', Bndr tv' spec) } + +tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType) +-- Instantiate a type signature with skolem constants. +-- We could give them fresh names, but no need to do so +tcSkolDFunType dfun + = do { (tv_prs, theta, tau) <- tcInstType tcInstSuperSkolTyVars dfun + ; return (map snd tv_prs, theta, tau) } + +tcSuperSkolTyVars :: [TyVar] -> (TCvSubst, [TcTyVar]) +-- Make skolem constants, but do *not* give them new names, as above +-- Moreover, make them "super skolems"; see comments with superSkolemTv +-- see Note [Kind substitution when instantiating] +-- Precondition: tyvars should be ordered by scoping +tcSuperSkolTyVars = mapAccumL tcSuperSkolTyVar emptyTCvSubst + +tcSuperSkolTyVar :: TCvSubst -> TyVar -> (TCvSubst, TcTyVar) +tcSuperSkolTyVar subst tv + = (extendTvSubstWithClone subst tv new_tv, new_tv) + where + kind = substTyUnchecked subst (tyVarKind tv) + new_tv = mkTcTyVar (tyVarName tv) kind superSkolemTv + +-- | Given a list of @['TyVar']@, skolemize the type variables, +-- returning a substitution mapping the original tyvars to the +-- skolems, and the list of newly bound skolems. +tcInstSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSkolTyVars = tcInstSkolTyVarsX emptyTCvSubst + +tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSkolTyVarsX = tcInstSkolTyVarsPushLevel False + +tcInstSuperSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSuperSkolTyVars = tcInstSuperSkolTyVarsX emptyTCvSubst + +tcInstSuperSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSuperSkolTyVarsX subst = tcInstSkolTyVarsPushLevel True subst + +tcInstSkolTyVarsPushLevel :: Bool -> TCvSubst -> [TyVar] + -> TcM (TCvSubst, [TcTyVar]) +-- Skolemise one level deeper, hence pushTcLevel +-- See Note [Skolemising type variables] +tcInstSkolTyVarsPushLevel overlappable subst tvs + = do { tc_lvl <- getTcLevel + ; let pushed_lvl = pushTcLevel tc_lvl + ; tcInstSkolTyVarsAt pushed_lvl overlappable subst tvs } + +tcInstSkolTyVarsAt :: TcLevel -> Bool + -> TCvSubst -> [TyVar] + -> TcM (TCvSubst, [TcTyVar]) +tcInstSkolTyVarsAt lvl overlappable subst tvs + = freshenTyCoVarsX new_skol_tv subst tvs + where + details = SkolemTv lvl overlappable + new_skol_tv name kind = mkTcTyVar name kind details + +------------------ +freshenTyVarBndrs :: [TyVar] -> TcM (TCvSubst, [TyVar]) +-- ^ Give fresh uniques to a bunch of TyVars, but they stay +-- as TyVars, rather than becoming TcTyVars +-- Used in 'GHC.Tc.Instance.Family.newFamInst', and 'GHC.Tc.Utils.Instantiate.newClsInst' +freshenTyVarBndrs = freshenTyCoVars mkTyVar + +freshenCoVarBndrsX :: TCvSubst -> [CoVar] -> TcM (TCvSubst, [CoVar]) +-- ^ Give fresh uniques to a bunch of CoVars +-- Used in "GHC.Tc.Instance.Family.newFamInst" +freshenCoVarBndrsX subst = freshenTyCoVarsX mkCoVar subst + +------------------ +freshenTyCoVars :: (Name -> Kind -> TyCoVar) + -> [TyVar] -> TcM (TCvSubst, [TyCoVar]) +freshenTyCoVars mk_tcv = freshenTyCoVarsX mk_tcv emptyTCvSubst + +freshenTyCoVarsX :: (Name -> Kind -> TyCoVar) + -> TCvSubst -> [TyCoVar] + -> TcM (TCvSubst, [TyCoVar]) +freshenTyCoVarsX mk_tcv = mapAccumLM (freshenTyCoVarX mk_tcv) + +freshenTyCoVarX :: (Name -> Kind -> TyCoVar) + -> TCvSubst -> TyCoVar -> TcM (TCvSubst, TyCoVar) +-- This a complete freshening operation: +-- the skolems have a fresh unique, and a location from the monad +-- See Note [Skolemising type variables] +freshenTyCoVarX mk_tcv subst tycovar + = do { loc <- getSrcSpanM + ; uniq <- newUnique + ; let old_name = tyVarName tycovar + new_name = mkInternalName uniq (getOccName old_name) loc + new_kind = substTyUnchecked subst (tyVarKind tycovar) + new_tcv = mk_tcv new_name new_kind + subst1 = extendTCvSubstWithClone subst tycovar new_tcv + ; return (subst1, new_tcv) } + +{- Note [Skolemising type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The tcInstSkolTyVars family of functions instantiate a list of TyVars +to fresh skolem TcTyVars. Important notes: + +a) Level allocation. We generally skolemise /before/ calling + pushLevelAndCaptureConstraints. So we want their level to the level + of the soon-to-be-created implication, which has a level ONE HIGHER + than the current level. Hence the pushTcLevel. It feels like a + slight hack. + +b) The [TyVar] should be ordered (kind vars first) + See Note [Kind substitution when instantiating] + +c) It's a complete freshening operation: the skolems have a fresh + unique, and a location from the monad + +d) The resulting skolems are + non-overlappable for tcInstSkolTyVars, + but overlappable for tcInstSuperSkolTyVars + See GHC.Tc.Deriv.Infer Note [Overlap and deriving] for an example + of where this matters. + +Note [Kind substitution when instantiating] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When we instantiate a bunch of kind and type variables, first we +expect them to be topologically sorted. +Then we have to instantiate the kind variables, build a substitution +from old variables to the new variables, then instantiate the type +variables substituting the original kind. + +Exemple: If we want to instantiate + [(k1 :: *), (k2 :: *), (a :: k1 -> k2), (b :: k1)] +we want + [(?k1 :: *), (?k2 :: *), (?a :: ?k1 -> ?k2), (?b :: ?k1)] +instead of the bogus + [(?k1 :: *), (?k2 :: *), (?a :: k1 -> k2), (?b :: k1)] -} +{- ********************************************************************* +* * + Literals +* * +********************************************************************* -} + {- In newOverloadedLit we convert directly to an Int or Integer if we know that's what we want. This may save some time, by not @@ -474,8 +657,6 @@ newOverloadedLit :: HsOverLit GhcRn newOverloadedLit lit@(OverLit { ol_val = val, ol_ext = rebindable }) res_ty | not rebindable - -- all built-in overloaded lits are tau-types, so we can just - -- tauify the ExpType = do { res_ty <- expTypeToType res_ty ; dflags <- getDynFlags ; let platform = targetPlatform dflags ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -31,15 +31,6 @@ module GHC.Tc.Utils.TcMType ( newTauTvDetailsAtLevel, newMetaDetails, newMetaTyVarName, isFilledMetaTyVar_maybe, isFilledMetaTyVar, isUnfilledMetaTyVar, - -------------------------------- - -- Expected types - ExpType(..), ExpSigmaType, ExpRhoType, - mkCheckExpType, - newInferExpType, - readExpType, readExpType_maybe, - expTypeToType, checkingExpType_maybe, checkingExpType, - tauifyExpType, inferResultToType, - -------------------------------- -- Creating new evidence variables newEvVar, newEvVars, newDict, @@ -58,14 +49,18 @@ module GHC.Tc.Utils.TcMType ( -------------------------------- -- Instantiation newMetaTyVars, newMetaTyVarX, newMetaTyVarsX, - newMetaTyVarTyVars, newMetaTyVarTyVarX, + newMetaTyVarTyVarX, newTyVarTyVar, cloneTyVarTyVar, newPatSigTyVar, newSkolemTyVar, newWildCardX, - tcInstType, tcInstTypeBndrs, - tcInstSkolTyVars, tcInstSkolTyVarsX, tcInstSkolTyVarsAt, - tcSkolDFunType, tcSuperSkolTyVars, tcInstSuperSkolTyVarsX, - freshenTyVarBndrs, freshenCoVarBndrsX, + -------------------------------- + -- Expected types + ExpType(..), ExpSigmaType, ExpRhoType, + mkCheckExpType, newInferExpType, tcInfer, + readExpType, readExpType_maybe, readScaledExpType, + expTypeToType, scaledExpTypeToType, + checkingExpType_maybe, checkingExpType, + inferResultToType, fillInferResult, promoteTcType, -------------------------------- -- Zonking and tidying @@ -99,6 +94,8 @@ module GHC.Tc.Utils.TcMType ( -- friends: import GHC.Prelude +import {-# SOURCE #-} GHC.Tc.Utils.Unify( unifyType {- , unifyKind -} ) + import GHC.Core.TyCo.Rep import GHC.Core.TyCo.Ppr import GHC.Tc.Utils.TcType @@ -133,7 +130,6 @@ import GHC.Types.Basic ( TypeOrKind(..) ) import Control.Monad import GHC.Data.Maybe -import Data.List ( mapAccumL ) import Control.Arrow ( second ) import qualified Data.Semigroup as Semi @@ -387,16 +383,14 @@ checkCoercionHole cv co | otherwise = False -{- -************************************************************************ +{- ********************************************************************** * - Expected types + ExpType functions * -************************************************************************ - -Note [ExpType] -~~~~~~~~~~~~~~ +********************************************************************** -} +{- Note [ExpType] +~~~~~~~~~~~~~~~~~ An ExpType is used as the "expected type" when type-checking an expression. An ExpType can hold a "hole" that can be filled in by the type-checker. This allows us to have one tcExpr that works in both checking mode and @@ -426,14 +420,12 @@ Consider This is a classic untouchable-variable / ambiguous GADT return type scenario. But, with ExpTypes, we'll be inferring the type of the RHS. -And, because there is only one branch of the case, we won't trigger -Note [Case branches must never infer a non-tau type] of GHC.Tc.Gen.Match. We thus must track a TcLevel in an Inferring ExpType. If we try to -fill the ExpType and find that the TcLevels don't work out, we -fill the ExpType with a tau-tv at the low TcLevel, hopefully to -be worked out later by some means. This is triggered in -test gadt/gadt-escape1. +fill the ExpType and find that the TcLevels don't work out, we fill +the ExpType with a tau-tv at the low TcLevel, hopefully to be worked +out later by some means -- see fillInferResult, and Note [fillInferResult] +This behaviour triggered in test gadt/gadt-escape1. -} -- actual data definition is in GHC.Tc.Utils.TcType @@ -453,6 +445,12 @@ readExpType_maybe :: ExpType -> TcM (Maybe TcType) readExpType_maybe (Check ty) = return (Just ty) readExpType_maybe (Infer (IR { ir_ref = ref})) = readMutVar ref +-- | Same as readExpType, but for Scaled ExpTypes +readScaledExpType :: Scaled ExpType -> TcM (Scaled Type) +readScaledExpType (Scaled m exp_ty) + = do { ty <- readExpType exp_ty + ; return (Scaled m ty) } + -- | Extract a type out of an ExpType. Otherwise, panics. readExpType :: ExpType -> TcM TcType readExpType exp_ty @@ -472,12 +470,10 @@ checkingExpType :: String -> ExpType -> TcType checkingExpType _ (Check ty) = ty checkingExpType err et = pprPanic "checkingExpType" (text err $$ ppr et) -tauifyExpType :: ExpType -> TcM ExpType --- ^ Turn a (Infer hole) type into a (Check alpha), --- where alpha is a fresh unification variable -tauifyExpType (Check ty) = return (Check ty) -- No-op for (Check ty) -tauifyExpType (Infer inf_res) = do { ty <- inferResultToType inf_res - ; return (Check ty) } +scaledExpTypeToType :: Scaled ExpType -> TcM (Scaled TcType) +scaledExpTypeToType (Scaled m exp_ty) + = do { ty <- expTypeToType exp_ty + ; return (Scaled m ty) } -- | Extracts the expected type if there is one, or generates a new -- TauTv if there isn't. @@ -488,209 +484,284 @@ expTypeToType (Infer inf_res) = inferResultToType inf_res inferResultToType :: InferResult -> TcM Type inferResultToType (IR { ir_uniq = u, ir_lvl = tc_lvl , ir_ref = ref }) - = do { rr <- newMetaTyVarTyAtLevel tc_lvl runtimeRepTy - ; tau <- newMetaTyVarTyAtLevel tc_lvl (tYPE rr) - -- See Note [TcLevel of ExpType] - ; writeMutVar ref (Just tau) + = do { mb_inferred_ty <- readTcRef ref + ; tau <- case mb_inferred_ty of + Just ty -> do { ensureMonoType ty + -- See Note [inferResultToType] + ; return ty } + Nothing -> do { rr <- newMetaTyVarTyAtLevel tc_lvl runtimeRepTy + ; tau <- newMetaTyVarTyAtLevel tc_lvl (tYPE rr) + -- See Note [TcLevel of ExpType] + ; writeMutVar ref (Just tau) + ; return tau } ; traceTc "Forcing ExpType to be monomorphic:" (ppr u <+> text ":=" <+> ppr tau) ; return tau } +{- Note [inferResultToType] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +expTypeToType and inferResultType convert an InferResult to a monotype. +It must be a monotype because if the InferResult isn't already filled in, +we fill it in with a unification variable (hence monotype). So to preserve +order-independence we check for mono-type-ness even if it *is* filled in +already. + +See also Note [TcLevel of ExpType] above, and +Note [fillInferResult]. +-} + +-- | Infer a type using a fresh ExpType +-- See also Note [ExpType] in "GHC.Tc.Utils.TcMType" +tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) +tcInfer tc_check + = do { res_ty <- newInferExpType + ; result <- tc_check res_ty + ; res_ty <- readExpType res_ty + ; return (result, res_ty) } + +fillInferResult :: TcType -> InferResult -> TcM TcCoercionN +-- If co = fillInferResult t1 t2 +-- => co :: t1 ~ t2 +-- See Note [fillInferResult] +fillInferResult act_res_ty (IR { ir_uniq = u, ir_lvl = res_lvl + , ir_ref = ref }) + = do { mb_exp_res_ty <- readTcRef ref + ; case mb_exp_res_ty of + Just exp_res_ty + -> do { traceTc "Joining inferred ExpType" $ + ppr u <> colon <+> ppr act_res_ty <+> char '~' <+> ppr exp_res_ty + ; cur_lvl <- getTcLevel + ; unless (cur_lvl `sameDepthAs` res_lvl) $ + ensureMonoType act_res_ty + ; unifyType Nothing act_res_ty exp_res_ty } + Nothing + -> do { traceTc "Filling inferred ExpType" $ + ppr u <+> text ":=" <+> ppr act_res_ty + ; (prom_co, act_res_ty) <- promoteTcType res_lvl act_res_ty + ; writeTcRef ref (Just act_res_ty) + ; return prom_co } + } + + +{- Note [fillInferResult] +~~~~~~~~~~~~~~~~~~~~~~~~~ +When inferring, we use fillInferResult to "fill in" the hole in InferResult + data InferResult = IR { ir_uniq :: Unique + , ir_lvl :: TcLevel + , ir_ref :: IORef (Maybe TcType) } + +There are two things to worry about: + +1. What if it is under a GADT or existential pattern match? + - GADTs: a unification variable (and Infer's hole is similar) is untouchable + - Existentials: be careful about skolem-escape + +2. What if it is filled in more than once? E.g. multiple branches of a case + case e of + T1 -> e1 + T2 -> e2 + +Our typing rules are: + +* The RHS of a existential or GADT alternative must always be a + monotype, regardless of the number of alternatives. + +* Multiple non-existential/GADT branches can have (the same) + higher rank type (#18412). E.g. this is OK: + case e of + True -> hr + False -> hr + where hr:: (forall a. a->a) -> Int + c.f. Section 7.1 of "Practical type inference for arbitrary-rank types" + We use choice (2) in that Section. + (GHC 8.10 and earlier used choice (1).) + + But note that + case e of + True -> hr + False -> \x -> hr x + will fail, because we still /infer/ both branches, so the \x will get + a (monotype) unification variable, which will fail to unify with + (forall a. a->a) + +For (1) we can detect the GADT/existential situation by seeing that +the current TcLevel is greater than that stored in ir_lvl of the Infer +ExpType. We bump the level whenever we go past a GADT/existential match. + +Then, before filling the hole use promoteTcType to promote the type +to the outer ir_lvl. promoteTcType does this + - create a fresh unification variable alpha at level ir_lvl + - emits an equality alpha[ir_lvl] ~ ty + - fills the hole with alpha +That forces the type to be a monotype (since unification variables can +only unify with monotypes); and catches skolem-escapes because the +alpha is untouchable until the equality floats out. + +For (2), we simply look to see if the hole is filled already. + - if not, we promote (as above) and fill the hole + - if it is filled, we simply unify with the type that is + already there + +There is one wrinkle. Suppose we have + case e of + T1 -> e1 :: (forall a. a->a) -> Int + G2 -> e2 +where T1 is not GADT or existential, but G2 is a GADT. Then supppose the +T1 alternative fills the hole with (forall a. a->a) -> Int, which is fine. +But now the G2 alternative must not *just* unify with that else we'd risk +allowing through (e2 :: (forall a. a->a) -> Int). If we'd checked G2 first +we'd have filled the hole with a unification variable, which enforces a +monotype. + +So if we check G2 second, we still want to emit a constraint that restricts +the RHS to be a monotype. This is done by ensureMonoType, and it works +by simply generating a constraint (alpha ~ ty), where alpha is a fresh +unification variable. We discard the evidence. + +-} {- ********************************************************************* * * - SkolemTvs (immutable) + Promoting types * * ********************************************************************* -} -tc_inst_internal :: ([VarBndr TyVar flag] -> TcM (TCvSubst, [VarBndr TcTyVar flag])) - -- ^ How to instantiate the type variables - -> [VarBndr TyVar flag] -- ^ Type variable to instantiate - -> Type -- ^ rho - -> TcM ([(Name, VarBndr TcTyVar flag)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tc_inst_internal _inst_tyvars [] rho = - let -- There may be overloading despite no type variables; - -- (?x :: Int) => Int -> Int - (theta, tau) = tcSplitPhiTy rho - in - return ([], theta, tau) -tc_inst_internal inst_tyvars tyvars rho = - do { (subst, tyvars') <- inst_tyvars tyvars - ; let (theta, tau) = tcSplitPhiTy (substTyAddInScope subst rho) - tv_prs = map (tyVarName . binderVar) tyvars `zip` tyvars' - ; return (tv_prs, theta, tau) } - -tcInstType :: ([TyVar] -> TcM (TCvSubst, [TcTyVar])) - -- ^ How to instantiate the type variables - -> Id -- ^ Type to instantiate - -> TcM ([(Name, TcTyVar)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tcInstType inst_tyvars id = - do { let (tyvars, rho) = splitForAllTys (idType id) - tyvars' = mkTyVarBinders () tyvars - ; (tv_prs, preds, rho) <- tc_inst_internal inst_tyvar_bndrs tyvars' rho - ; let tv_prs' = map (\(name, bndr) -> (name, binderVar bndr)) tv_prs - ; return (tv_prs', preds, rho) } - where - inst_tyvar_bndrs :: [VarBndr TyVar ()] -> TcM (TCvSubst, [VarBndr TcTyVar ()]) - inst_tyvar_bndrs bndrs = do { (subst, tvs) <- inst_tyvars $ binderVars bndrs - ; let tvbnds = map (\tv -> Bndr tv ()) tvs - ; return (subst, tvbnds) } - -tcInstTypeBndrs :: ([VarBndr TyVar Specificity] -> TcM (TCvSubst, [VarBndr TcTyVar Specificity])) - -- ^ How to instantiate the type variables - -> Id -- ^ Type to instantiate - -> TcM ([(Name, VarBndr TcTyVar Specificity)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tcInstTypeBndrs inst_tyvars id = - let (tyvars, rho) = splitForAllTysInvis (idType id) - in tc_inst_internal inst_tyvars tyvars rho - -tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType) --- Instantiate a type signature with skolem constants. --- We could give them fresh names, but no need to do so -tcSkolDFunType dfun - = do { (tv_prs, theta, tau) <- tcInstType tcInstSuperSkolTyVars dfun - ; return (map snd tv_prs, theta, tau) } - -tcSuperSkolTyVars :: [TyVar] -> (TCvSubst, [TcTyVar]) --- Make skolem constants, but do *not* give them new names, as above --- Moreover, make them "super skolems"; see comments with superSkolemTv --- see Note [Kind substitution when instantiating] --- Precondition: tyvars should be ordered by scoping -tcSuperSkolTyVars = mapAccumL tcSuperSkolTyVar emptyTCvSubst - -tcSuperSkolTyVar :: TCvSubst -> TyVar -> (TCvSubst, TcTyVar) -tcSuperSkolTyVar subst tv - = (extendTvSubstWithClone subst tv new_tv, new_tv) - where - kind = substTyUnchecked subst (tyVarKind tv) - new_tv = mkTcTyVar (tyVarName tv) kind superSkolemTv - --- | Given a list of @['TyVar']@, skolemize the type variables, --- returning a substitution mapping the original tyvars to the --- skolems, and the list of newly bound skolems. -tcInstSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSkolTyVars = tcInstSkolTyVarsX emptyTCvSubst - -tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSkolTyVarsX = tcInstSkolTyVarsPushLevel False - -tcInstSuperSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSuperSkolTyVars = tcInstSuperSkolTyVarsX emptyTCvSubst - -tcInstSuperSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSuperSkolTyVarsX subst = tcInstSkolTyVarsPushLevel True subst - -tcInstSkolTyVarsPushLevel :: Bool -> TCvSubst -> [TyVar] - -> TcM (TCvSubst, [TcTyVar]) --- Skolemise one level deeper, hence pushTcLevel --- See Note [Skolemising type variables] -tcInstSkolTyVarsPushLevel overlappable subst tvs - = do { tc_lvl <- getTcLevel - ; let pushed_lvl = pushTcLevel tc_lvl - ; tcInstSkolTyVarsAt pushed_lvl overlappable subst tvs } - -tcInstSkolTyVarsAt :: TcLevel -> Bool - -> TCvSubst -> [TyVar] - -> TcM (TCvSubst, [TcTyVar]) -tcInstSkolTyVarsAt lvl overlappable subst tvs - = freshenTyCoVarsX new_skol_tv subst tvs +ensureMonoType :: TcType -> TcM () +-- Assuming that the argument type is of kind (TYPE r), +-- ensure that it is a /monotype/ +-- If it is not a monotype we can see right away (since unification +-- varibles and type-function applications stand for monotypes), but +-- we emit a Wanted equality just to delay the error message until later +ensureMonoType res_ty + | isTauTy res_ty -- isTauTy doesn't need zonking or anything + = return () + | otherwise + = do { mono_ty <- newOpenFlexiTyVarTy + ; let eq_orig = TypeEqOrigin { uo_actual = res_ty + , uo_expected = mono_ty + , uo_thing = Nothing + , uo_visible = False } + + ; _co <- emitWantedEq eq_orig TypeLevel Nominal res_ty mono_ty + ; return () } + +promoteTcType :: TcLevel -> TcType -> TcM (TcCoercionN, TcType) +-- See Note [Promoting a type] +-- See also Note [fillInferResult] +-- promoteTcType level ty = (co, ty') +-- * Returns ty' whose max level is just 'level' +-- and whose kind is ~# to the kind of 'ty' +-- and whose kind has form TYPE rr +-- * and co :: ty ~ ty' +-- * and emits constraints to justify the coercion +promoteTcType dest_lvl ty + = do { cur_lvl <- getTcLevel + ; if (cur_lvl `sameDepthAs` dest_lvl) + then return (mkTcNomReflCo ty, ty) + else promote_it } where - details = SkolemTv lvl overlappable - new_skol_tv name kind = mkTcTyVar name kind details - ------------------- -freshenTyVarBndrs :: [TyVar] -> TcM (TCvSubst, [TyVar]) --- ^ Give fresh uniques to a bunch of TyVars, but they stay --- as TyVars, rather than becoming TcTyVars --- Used in 'GHC.Tc.Instance.Family.newFamInst', and 'GHC.Tc.Utils.Instantiate.newClsInst' -freshenTyVarBndrs = freshenTyCoVars mkTyVar - -freshenCoVarBndrsX :: TCvSubst -> [CoVar] -> TcM (TCvSubst, [CoVar]) --- ^ Give fresh uniques to a bunch of CoVars --- Used in "GHC.Tc.Instance.Family.newFamInst" -freshenCoVarBndrsX subst = freshenTyCoVarsX mkCoVar subst - ------------------- -freshenTyCoVars :: (Name -> Kind -> TyCoVar) - -> [TyVar] -> TcM (TCvSubst, [TyCoVar]) -freshenTyCoVars mk_tcv = freshenTyCoVarsX mk_tcv emptyTCvSubst - -freshenTyCoVarsX :: (Name -> Kind -> TyCoVar) - -> TCvSubst -> [TyCoVar] - -> TcM (TCvSubst, [TyCoVar]) -freshenTyCoVarsX mk_tcv = mapAccumLM (freshenTyCoVarX mk_tcv) - -freshenTyCoVarX :: (Name -> Kind -> TyCoVar) - -> TCvSubst -> TyCoVar -> TcM (TCvSubst, TyCoVar) --- This a complete freshening operation: --- the skolems have a fresh unique, and a location from the monad --- See Note [Skolemising type variables] -freshenTyCoVarX mk_tcv subst tycovar - = do { loc <- getSrcSpanM - ; uniq <- newUnique - ; let old_name = tyVarName tycovar - new_name = mkInternalName uniq (getOccName old_name) loc - new_kind = substTyUnchecked subst (tyVarKind tycovar) - new_tcv = mk_tcv new_name new_kind - subst1 = extendTCvSubstWithClone subst tycovar new_tcv - ; return (subst1, new_tcv) } - -{- Note [Skolemising type variables] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The tcInstSkolTyVars family of functions instantiate a list of TyVars -to fresh skolem TcTyVars. Important notes: - -a) Level allocation. We generally skolemise /before/ calling - pushLevelAndCaptureConstraints. So we want their level to the level - of the soon-to-be-created implication, which has a level ONE HIGHER - than the current level. Hence the pushTcLevel. It feels like a - slight hack. - -b) The [TyVar] should be ordered (kind vars first) - See Note [Kind substitution when instantiating] - -c) It's a complete freshening operation: the skolems have a fresh - unique, and a location from the monad - -d) The resulting skolems are - non-overlappable for tcInstSkolTyVars, - but overlappable for tcInstSuperSkolTyVars - See GHC.Tc.Deriv.Infer Note [Overlap and deriving] for an example - of where this matters. - -Note [Kind substitution when instantiating] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we instantiate a bunch of kind and type variables, first we -expect them to be topologically sorted. -Then we have to instantiate the kind variables, build a substitution -from old variables to the new variables, then instantiate the type -variables substituting the original kind. + promote_it :: TcM (TcCoercion, TcType) + promote_it -- Emit a constraint (alpha :: TYPE rr) ~ ty + -- where alpha and rr are fresh and from level dest_lvl + = do { rr <- newMetaTyVarTyAtLevel dest_lvl runtimeRepTy + ; prom_ty <- newMetaTyVarTyAtLevel dest_lvl (tYPE rr) + ; let eq_orig = TypeEqOrigin { uo_actual = ty + , uo_expected = prom_ty + , uo_thing = Nothing + , uo_visible = False } + + ; co <- emitWantedEq eq_orig TypeLevel Nominal ty prom_ty + ; return (co, prom_ty) } +{- + dont_promote_it :: TcM (TcCoercion, TcType) + dont_promote_it -- Check that ty :: TYPE rr, for some (fresh) rr + = do { res_kind <- newOpenTypeKind + ; ki_co <- unifyKind Nothing (tcTypeKind ty) res_kind + ; let co = mkTcGReflRightCo Nominal ty ki_co + ; return (co, ty `mkCastTy` ki_co) } +-} -Exemple: If we want to instantiate - [(k1 :: *), (k2 :: *), (a :: k1 -> k2), (b :: k1)] -we want - [(?k1 :: *), (?k2 :: *), (?a :: ?k1 -> ?k2), (?b :: ?k1)] -instead of the buggous - [(?k1 :: *), (?k2 :: *), (?a :: k1 -> k2), (?b :: k1)] +{- Note [Promoting a type] +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider (#12427) + + data T where + MkT :: (Int -> Int) -> a -> T + + h y = case y of MkT v w -> v + +We'll infer the RHS type with an expected type ExpType of + (IR { ir_lvl = l, ir_ref = ref, ... ) +where 'l' is the TcLevel of the RHS of 'h'. Then the MkT pattern +match will increase the level, so we'll end up in tcSubType, trying to +unify the type of v, + v :: Int -> Int +with the expected type. But this attempt takes place at level (l+1), +rightly so, since v's type could have mentioned existential variables, +(like w's does) and we want to catch that. + +So we + - create a new meta-var alpha[l+1] + - fill in the InferRes ref cell 'ref' with alpha + - emit an equality constraint, thus + [W] alpha[l+1] ~ (Int -> Int) + +That constraint will float outwards, as it should, unless v's +type mentions a skolem-captured variable. + +This approach fails if v has a higher rank type; see +Note [Promotion and higher rank types] + + +Note [Promotion and higher rank types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If v had a higher-rank type, say v :: (forall a. a->a) -> Int, +then we'd emit an equality + [W] alpha[l+1] ~ ((forall a. a->a) -> Int) +which will sadly fail because we can't unify a unification variable +with a polytype. But there is nothing really wrong with the program +here. + +We could just about solve this by "promote the type" of v, to expose +its polymorphic "shape" while still leaving constraints that will +prevent existential escape. But we must be careful! Exposing +the "shape" of the type is precisely what we must NOT do under +a GADT pattern match! So in this case we might promote the type +to + (forall a. a->a) -> alpha[l+1] +and emit the constraint + [W] alpha[l+1] ~ Int +Now the promoted type can fill the ref cell, while the emitted +equality can float or not, according to the usual rules. + +But that's not quite right! We are exposing the arrow! We could +deal with that too: + (forall a. mu[l+1] a a) -> alpha[l+1] +with constraints + [W] alpha[l+1] ~ Int + [W] mu[l+1] ~ (->) +Here we abstract over the '->' inside the forall, in case that +is subject to an equality constraint from a GADT match. + +Note that we kept the outer (->) because that's part of +the polymorphic "shape". And because of impredicativity, +GADT matches can't give equalities that affect polymorphic +shape. + +This reasoning just seems too complicated, so I decided not +to do it. These higher-rank notes are just here to record +the thinking. +-} -************************************************************************ +{- ********************************************************************* * * MetaTvs (meta type variables; mutable) * * -************************************************************************ --} +********************************************************************* -} -{- -Note [TyVarTv] -~~~~~~~~~~~~ +{- Note [TyVarTv] +~~~~~~~~~~~~~~~~~ A TyVarTv can unify with type *variables* only, including other TyVarTvs and skolems. Sometimes, they can unify with type variables that the user would @@ -1031,18 +1102,11 @@ newMetaTyVarsX subst = mapAccumLM newMetaTyVarX subst newMetaTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) -- Make a new unification variable tyvar whose Name and Kind come from -- an existing TyVar. We substitute kind variables in the kind. -newMetaTyVarX subst tyvar = new_meta_tv_x TauTv subst tyvar - -newMetaTyVarTyVars :: [VarBndr TyVar Specificity] - -> TcM (TCvSubst, [VarBndr TcTyVar Specificity]) -newMetaTyVarTyVars = mapAccumLM newMetaTyVarTyVarX emptyTCvSubst +newMetaTyVarX = new_meta_tv_x TauTv -newMetaTyVarTyVarX :: TCvSubst -> (VarBndr TyVar Specificity) - -> TcM (TCvSubst, VarBndr TcTyVar Specificity) +newMetaTyVarTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) -- Just like newMetaTyVarX, but make a TyVarTv -newMetaTyVarTyVarX subst (Bndr tv spec) = - do { (subst', tv') <- new_meta_tv_x TyVarTv subst tv - ; return (subst', (Bndr tv' spec)) } +newMetaTyVarTyVarX = new_meta_tv_x TyVarTv newWildCardX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) newWildCardX subst tv ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -57,7 +57,7 @@ module GHC.Tc.Utils.TcType ( -- These are important because they do not look through newtypes getTyVar, tcSplitForAllTy_maybe, - tcSplitForAllTys, tcSplitSomeForAllTys, + tcSplitForAllTys, tcSplitForAllTysReq, tcSplitForAllTysInvis, tcSplitPiTys, tcSplitPiTy_maybe, tcSplitForAllVarBndrs, tcSplitPhiTy, tcSplitPredFunTy_maybe, @@ -1221,14 +1221,6 @@ tcSplitForAllTys ty = ASSERT( all isTyVar (fst sty) ) sty where sty = splitForAllTys ty --- | Like 'tcSplitForAllTys', but only splits a 'ForAllTy' if @argf_pred argf@ --- is 'True', where @argf@ is the visibility of the @ForAllTy@'s binder and --- @argf_pred@ is a predicate over visibilities provided as an argument to this --- function. All split tyvars are annotated with their @argf at . -tcSplitSomeForAllTys :: (ArgFlag -> Bool) -> Type -> ([TyCoVarBinder], Type) -tcSplitSomeForAllTys argf_pred ty = ASSERT( all (isTyVar . binderVar) (fst sty) ) sty - where sty = splitSomeForAllTys argf_pred ty - -- | Like 'tcSplitForAllTys', but only splits 'ForAllTy's with 'Required' type -- variable binders. All split tyvars are annotated with '()'. tcSplitForAllTysReq :: Type -> ([TcReqTVBinder], Type) ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -61,7 +61,6 @@ import GHC.Types.Name( isSystemName ) import GHC.Tc.Utils.Instantiate import GHC.Core.TyCon import GHC.Builtin.Types -import GHC.Builtin.Types.Prim( tYPE ) import GHC.Types.Var as Var import GHC.Types.Var.Set import GHC.Types.Var.Env @@ -571,10 +570,51 @@ tcSubTypeNC :: CtOrigin -- Used when instantiating -> TcM HsWrapper tcSubTypeNC inst_orig ctxt m_thing ty_actual res_ty = case res_ty of - Infer inf_res -> instantiateAndFillInferResult inst_orig ty_actual inf_res Check ty_expected -> tc_sub_type (unifyType m_thing) inst_orig ctxt ty_actual ty_expected + Infer inf_res -> do { (wrap, rho) <- topInstantiate inst_orig ty_actual + -- See Note [Instantiation of InferResult] + ; co <- fillInferResult rho inf_res + ; return (mkWpCastN co <.> wrap) } + +{- Note [Instantiation of InferResult] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We now always instantiate before filling in InferResult, so that +the result is a TcRhoType: see #17173 for discussion. + +For example: + +1. Consider + f x = (*) + We want to instantiate the type of (*) before returning, else we + will infer the type + f :: forall {a}. a -> forall b. Num b => b -> b -> b + This is surely confusing for users. + + And worse, the monomorphism restriction won't work properly. The MR is + dealt with in simplifyInfer, and simplifyInfer has no way of + instantiating. This could perhaps be worked around, but it may be + hard to know even when instantiation should happen. + +2. Another reason. Consider + f :: (?x :: Int) => a -> a + g y = let ?x = 3::Int in f + Here want to instantiate f's type so that the ?x::Int constraint + gets discharged by the enclosing implicit-parameter binding. + +3. Suppose one defines plus = (+). If we instantiate lazily, we will + infer plus :: forall a. Num a => a -> a -> a. However, the monomorphism + restriction compels us to infer + plus :: Integer -> Integer -> Integer + (or similar monotype). Indeed, the only way to know whether to apply + the monomorphism restriction at all is to instantiate + +There is one place where we don't want to instantiate eagerly, +namely in GHC.Tc.Module.tcRnExpr, which implements GHCi's :type +command. See Note [Implementing :type] in GHC.Tc.Module. +-} + --------------- tcSubTypeSigma :: UserTypeCtxt -> TcSigmaType -> TcSigmaType -> TcM HsWrapper -- External entry point, but no ExpTypes on either side @@ -768,213 +808,6 @@ tcEqMult origin w_actual w_expected = do ; coercion <- uType TypeLevel origin w_actual w_expected ; return $ if isReflCo coercion then WpHole else WpMultCoercion coercion } -{- ********************************************************************** -%* * - ExpType functions: tcInfer, instantiateAndFillInferResult -%* * -%********************************************************************* -} - --- | Infer a type using a fresh ExpType --- See also Note [ExpType] in "GHC.Tc.Utils.TcMType" -tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) -tcInfer tc_check - = do { res_ty <- newInferExpType - ; result <- tc_check res_ty - ; res_ty <- readExpType res_ty - ; return (result, res_ty) } - -instantiateAndFillInferResult :: CtOrigin -> TcType -> InferResult -> TcM HsWrapper --- If wrap = instantiateAndFillInferResult t1 t2 --- => wrap :: t1 ~> t2 --- See Note [Instantiation of InferResult] -instantiateAndFillInferResult orig ty inf_res - = do { (wrap, rho) <- topInstantiate orig ty - ; co <- fillInferResult rho inf_res - ; return (mkWpCastN co <.> wrap) } - -fillInferResult :: TcType -> InferResult -> TcM TcCoercionN --- If wrap = fillInferResult t1 t2 --- => wrap :: t1 ~> t2 -fillInferResult orig_ty (IR { ir_uniq = u, ir_lvl = res_lvl - , ir_ref = ref }) - = do { (ty_co, ty_to_fill_with) <- promoteTcType res_lvl orig_ty - - ; traceTc "Filling ExpType" $ - ppr u <+> text ":=" <+> ppr ty_to_fill_with - - ; when debugIsOn (check_hole ty_to_fill_with) - - ; writeTcRef ref (Just ty_to_fill_with) - - ; return ty_co } - where - check_hole ty -- Debug check only - = do { let ty_lvl = tcTypeLevel ty - ; MASSERT2( not (ty_lvl `strictlyDeeperThan` res_lvl), - ppr u $$ ppr res_lvl $$ ppr ty_lvl $$ - ppr ty <+> dcolon <+> ppr (tcTypeKind ty) $$ ppr orig_ty ) - ; cts <- readTcRef ref - ; case cts of - Just already_there -> pprPanic "writeExpType" - (vcat [ ppr u - , ppr ty - , ppr already_there ]) - Nothing -> return () } - -{- Note [Instantiation of InferResult] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We now always instantiate before filling in InferResult, so that -the result is a TcRhoType: see #17173 for discussion. - -For example: - -1. Consider - f x = (*) - We want to instantiate the type of (*) before returning, else we - will infer the type - f :: forall {a}. a -> forall b. Num b => b -> b -> b - This is surely confusing for users. - - And worse, the monomorphism restriction won't work properly. The MR is - dealt with in simplifyInfer, and simplifyInfer has no way of - instantiating. This could perhaps be worked around, but it may be - hard to know even when instantiation should happen. - -2. Another reason. Consider - f :: (?x :: Int) => a -> a - g y = let ?x = 3::Int in f - Here want to instantiate f's type so that the ?x::Int constraint - gets discharged by the enclosing implicit-parameter binding. - -3. Suppose one defines plus = (+). If we instantiate lazily, we will - infer plus :: forall a. Num a => a -> a -> a. However, the monomorphism - restriction compels us to infer - plus :: Integer -> Integer -> Integer - (or similar monotype). Indeed, the only way to know whether to apply - the monomorphism restriction at all is to instantiate - -There is one place where we don't want to instantiate eagerly, -namely in GHC.Tc.Module.tcRnExpr, which implements GHCi's :type -command. See Note [Implementing :type] in GHC.Tc.Module. - --} - -{- ********************************************************************* -* * - Promoting types -* * -********************************************************************* -} - -promoteTcType :: TcLevel -> TcType -> TcM (TcCoercion, TcType) --- See Note [Promoting a type] --- promoteTcType level ty = (co, ty') --- * Returns ty' whose max level is just 'level' --- and whose kind is ~# to the kind of 'ty' --- and whose kind has form TYPE rr --- * and co :: ty ~ ty' --- * and emits constraints to justify the coercion -promoteTcType dest_lvl ty - = do { cur_lvl <- getTcLevel - ; if (cur_lvl `sameDepthAs` dest_lvl) - then dont_promote_it - else promote_it } - where - promote_it :: TcM (TcCoercion, TcType) - promote_it -- Emit a constraint (alpha :: TYPE rr) ~ ty - -- where alpha and rr are fresh and from level dest_lvl - = do { rr <- newMetaTyVarTyAtLevel dest_lvl runtimeRepTy - ; prom_ty <- newMetaTyVarTyAtLevel dest_lvl (tYPE rr) - ; let eq_orig = TypeEqOrigin { uo_actual = ty - , uo_expected = prom_ty - , uo_thing = Nothing - , uo_visible = False } - - ; co <- emitWantedEq eq_orig TypeLevel Nominal ty prom_ty - ; return (co, prom_ty) } - - dont_promote_it :: TcM (TcCoercion, TcType) - dont_promote_it -- Check that ty :: TYPE rr, for some (fresh) rr - = do { res_kind <- newOpenTypeKind - ; let ty_kind = tcTypeKind ty - kind_orig = TypeEqOrigin { uo_actual = ty_kind - , uo_expected = res_kind - , uo_thing = Nothing - , uo_visible = False } - ; ki_co <- uType KindLevel kind_orig (tcTypeKind ty) res_kind - ; let co = mkTcGReflRightCo Nominal ty ki_co - ; return (co, ty `mkCastTy` ki_co) } - -{- Note [Promoting a type] -~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider (#12427) - - data T where - MkT :: (Int -> Int) -> a -> T - - h y = case y of MkT v w -> v - -We'll infer the RHS type with an expected type ExpType of - (IR { ir_lvl = l, ir_ref = ref, ... ) -where 'l' is the TcLevel of the RHS of 'h'. Then the MkT pattern -match will increase the level, so we'll end up in tcSubType, trying to -unify the type of v, - v :: Int -> Int -with the expected type. But this attempt takes place at level (l+1), -rightly so, since v's type could have mentioned existential variables, -(like w's does) and we want to catch that. - -So we - - create a new meta-var alpha[l+1] - - fill in the InferRes ref cell 'ref' with alpha - - emit an equality constraint, thus - [W] alpha[l+1] ~ (Int -> Int) - -That constraint will float outwards, as it should, unless v's -type mentions a skolem-captured variable. - -This approach fails if v has a higher rank type; see -Note [Promotion and higher rank types] - - -Note [Promotion and higher rank types] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If v had a higher-rank type, say v :: (forall a. a->a) -> Int, -then we'd emit an equality - [W] alpha[l+1] ~ ((forall a. a->a) -> Int) -which will sadly fail because we can't unify a unification variable -with a polytype. But there is nothing really wrong with the program -here. - -We could just about solve this by "promote the type" of v, to expose -its polymorphic "shape" while still leaving constraints that will -prevent existential escape. But we must be careful! Exposing -the "shape" of the type is precisely what we must NOT do under -a GADT pattern match! So in this case we might promote the type -to - (forall a. a->a) -> alpha[l+1] -and emit the constraint - [W] alpha[l+1] ~ Int -Now the promoted type can fill the ref cell, while the emitted -equality can float or not, according to the usual rules. - -But that's not quite right! We are exposing the arrow! We could -deal with that too: - (forall a. mu[l+1] a a) -> alpha[l+1] -with constraints - [W] alpha[l+1] ~ Int - [W] mu[l+1] ~ (->) -Here we abstract over the '->' inside the forall, in case that -is subject to an equality constraint from a GADT match. - -Note that we kept the outer (->) because that's part of -the polymorphic "shape". And because of impredicativity, -GADT matches can't give equalities that affect polymorphic -shape. - -This reasoning just seems too complicated, so I decided not -to do it. These higher-rank notes are just here to record -the thinking. --} {- ********************************************************************* * * ===================================== testsuite/tests/simplCore/should_compile/T17901.stdout ===================================== @@ -1,14 +1,14 @@ - (wombat1 [Occ=Once*!] :: T -> p) + (wombat1 [Occ=Once*!] :: T -> t) A -> wombat1 T17901.A; B -> wombat1 T17901.B; C -> wombat1 T17901.C - = \ (@p) (wombat1 :: T -> p) (x :: T) -> + = \ (@t) (wombat1 :: T -> t) (x :: T) -> case x of wild { __DEFAULT -> wombat1 wild } - Tmpl= \ (@p) (wombat2 [Occ=Once!] :: S -> p) (x [Occ=Once] :: S) -> + Tmpl= \ (@t) (wombat2 [Occ=Once!] :: S -> t) (x [Occ=Once] :: S) -> case x of wild [Occ=Once] { __DEFAULT -> wombat2 wild }}] - = \ (@p) (wombat2 :: S -> p) (x :: S) -> + = \ (@t) (wombat2 :: S -> t) (x :: S) -> case x of wild { __DEFAULT -> wombat2 wild } - Tmpl= \ (@p) (wombat3 [Occ=Once!] :: W -> p) (x [Occ=Once] :: W) -> + Tmpl= \ (@t) (wombat3 [Occ=Once!] :: W -> t) (x [Occ=Once] :: W) -> case x of wild [Occ=Once] { __DEFAULT -> wombat3 wild }}] - = \ (@p) (wombat3 :: W -> p) (x :: W) -> + = \ (@t) (wombat3 :: W -> t) (x :: W) -> case x of wild { __DEFAULT -> wombat3 wild } ===================================== testsuite/tests/typecheck/should_compile/T18412.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RankNTypes #-} + +module T18412 where + +hr :: (forall a. a -> a) -> () +hr _ = () + +foo x = case x of () -> hr + +-- This did not use to be allowed, because the +-- multiple branches have (the same) polytypes +-- Enhancement July 2020 +bar x = case x of True -> hr + False -> hr ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -716,3 +716,4 @@ test('T17775-viewpats-a', normal, compile, ['']) test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) test('T17775-viewpats-d', normal, compile_fail, ['']) +test('T18412', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T10619.stderr ===================================== @@ -1,13 +1,11 @@ -T10619.hs:9:15: error: - • Couldn't match type ‘p’ with ‘forall b. b -> b’ - Expected: p -> p - Actual: (forall a. a -> a) -> forall b. b -> b - ‘p’ is a rigid type variable bound by - the inferred type of foo :: p1 -> p -> p - at T10619.hs:(8,1)-(10,20) - • In the expression: - (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b +T10619.hs:10:14: error: + • Couldn't match type ‘p1’ with ‘forall a. a -> a’ + Expected: (forall a. a -> a) -> forall b. b -> b + Actual: p1 -> p1 + Cannot instantiate unification variable ‘p1’ + with a type involving polytypes: forall a. a -> a + • In the expression: \ y -> y In the expression: if True then ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) @@ -19,15 +17,13 @@ T10619.hs:9:15: error: ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) else \ y -> y - • Relevant bindings include - foo :: p1 -> p -> p (bound at T10619.hs:8:1) T10619.hs:14:15: error: • Couldn't match type ‘p’ with ‘forall a. a -> a’ Expected: p -> p Actual: (forall a. a -> a) -> forall b. b -> b ‘p’ is a rigid type variable bound by - the inferred type of bar :: p1 -> p -> p + the inferred type of bar :: p2 -> p -> p at T10619.hs:(12,1)-(14,66) • In the expression: (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b @@ -43,21 +39,16 @@ T10619.hs:14:15: error: else ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) • Relevant bindings include - bar :: p1 -> p -> p (bound at T10619.hs:12:1) + bar :: p2 -> p -> p (bound at T10619.hs:12:1) -T10619.hs:16:13: error: - • Couldn't match type ‘p’ with ‘forall b. b -> b’ - Expected: p -> p - Actual: (forall a. a -> a) -> forall b. b -> b - ‘p’ is a rigid type variable bound by - the inferred type of baz :: Bool -> p -> p - at T10619.hs:(16,1)-(17,19) - • In the expression: - (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b - In an equation for ‘baz’: - baz True = (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b - • Relevant bindings include - baz :: Bool -> p -> p (bound at T10619.hs:16:1) +T10619.hs:17:13: error: + • Couldn't match type ‘p0’ with ‘forall a. a -> a’ + Expected: (forall a. a -> a) -> forall b. b -> b + Actual: p0 -> p0 + Cannot instantiate unification variable ‘p0’ + with a type involving polytypes: forall a. a -> a + • In the expression: \ y -> y + In an equation for ‘baz’: baz False = \ y -> y T10619.hs:20:14: error: • Couldn't match type ‘p’ with ‘forall a. a -> a’ ===================================== testsuite/tests/typecheck/should_fail/tcfail002.stderr ===================================== @@ -1,8 +1,8 @@ tcfail002.hs:4:7: error: - • Couldn't match expected type ‘p’ with actual type ‘[p]’ + • Couldn't match expected type ‘a’ with actual type ‘[a]’ • In the expression: z In an equation for ‘c’: c z = z • Relevant bindings include - z :: [p] (bound at tcfail002.hs:4:3) - c :: [p] -> p (bound at tcfail002.hs:3:1) + z :: [a] (bound at tcfail002.hs:4:3) + c :: [a] -> a (bound at tcfail002.hs:3:1) ===================================== testsuite/tests/typecheck/should_fail/tcfail104.stderr ===================================== @@ -1,19 +1,22 @@ -tcfail104.hs:14:12: error: +tcfail104.hs:16:12: error: + • Couldn't match type: Char -> Char + with: forall a. a -> a + Expected: (forall a. a -> a) -> Char -> Char + Actual: (Char -> Char) -> Char -> Char + • In the expression: \ x -> x + In the expression: + if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x) + In the expression: + (if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x)) id 'c' + +tcfail104.hs:22:12: error: • Couldn't match type: forall a. a -> a with: Char -> Char Expected: (Char -> Char) -> Char -> Char Actual: (forall a. a -> a) -> Char -> Char • In the expression: \ (x :: forall a. a -> a) -> x In the expression: - if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x) + if v then (\ x -> x) else (\ (x :: forall a. a -> a) -> x) In the expression: - (if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x)) id 'c' - -tcfail104.hs:22:15: error: - • Couldn't match expected type: Char -> Char - with actual type: forall a. a -> a - • When checking that the pattern signature: forall a. a -> a - fits the type of its context: Char -> Char - In the pattern: x :: forall a. a -> a - In the expression: \ (x :: forall a. a -> a) -> x + (if v then (\ x -> x) else (\ (x :: forall a. a -> a) -> x)) id 'c' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e108dd1afca64f72e526fc8eef94a0a607c63cac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e108dd1afca64f72e526fc8eef94a0a607c63cac You're receiving 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 Jul 14 02:11:25 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 13 Jul 2020 22:11:25 -0400 Subject: [Git][ghc/ghc][ghc-8.8] gitlab-ci: Fix version of Windows bootstrap compiler Message-ID: <5f0d144de388e_80b3f846a0d2e3c2927590@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC Commits: e89007db by Ben Gamari at 2020-07-13T22:10:28-04:00 gitlab-ci: Fix version of Windows bootstrap compiler Naturally, the one job that was incorrect was the release job. - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -657,7 +657,7 @@ release-x86_64-windows: extends: validate-x86_64-windows variables: MSYSTEM: MINGW64 - GHC_VERSION: 8.8.4-rc1 + GHC_VERSION: "8.8.3.20200710" GHC_TARBALL_URL: "http://home.smart-cactus.org/~ben/ghc/release-prep/8.8.4-rc1/ghc-8.8.3.20200710-x86_64-unknown-mingw32.tar.xz" BUILD_FLAVOUR: "perf" CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e89007db569349fa9b51b5b94e26fa04584deabb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e89007db569349fa9b51b5b94e26fa04584deabb You're receiving 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 Jul 14 05:08:46 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 14 Jul 2020 01:08:46 -0400 Subject: [Git][ghc/ghc][ghc-8.8] gitlab-ci: Work around PowerShell incompatibility Message-ID: <5f0d3ddebf5fd_80b3f848700d4d029300e8@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC Commits: 6cf8f835 by Ben Gamari at 2020-07-14T01:08:31-04:00 gitlab-ci: Work around PowerShell incompatibility - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -548,7 +548,7 @@ release-x86_64-linux-fedora27: - git submodule sync --recursive - git submodule update --init --recursive - git checkout .gitmodules - - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true" + - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf" - bash .gitlab/win32-init.sh after_script: - rd /s /q tmp View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6cf8f835267581d551ca6695b3b02c34797e2cf4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6cf8f835267581d551ca6695b3b02c34797e2cf4 You're receiving 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 Jul 14 06:12:27 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 14 Jul 2020 02:12:27 -0400 Subject: [Git][ghc/ghc][wip/use-CmmRegOff-smart-ctor] 3 commits: Warn about empty Char enumerations (#18402) Message-ID: <5f0d4ccb2cbcb_80b3f849c221f402933895@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/use-CmmRegOff-smart-ctor at Glasgow Haskell Compiler / GHC Commits: c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 6c2f69c6 by Ben Gamari at 2020-07-14T02:12:23-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - 6 changed files: - compiler/GHC/HsToCore/Match/Literal.hs - compiler/GHC/StgToCmm/CgUtils.hs - hadrian/src/Rules/Test.hs - + testsuite/tests/warnings/should_compile/T18402.hs - + testsuite/tests/warnings/should_compile/T18402.stderr - testsuite/tests/warnings/should_compile/all.T Changes: ===================================== compiler/GHC/HsToCore/Match/Literal.hs ===================================== @@ -261,18 +261,19 @@ but perhaps that does not matter too much. warnAboutEmptyEnumerations :: FamInstEnvs -> DynFlags -> LHsExpr GhcTc -> Maybe (LHsExpr GhcTc) -> LHsExpr GhcTc -> DsM () --- ^ Warns about @[2,3 .. 1]@ which returns the empty list. --- Only works for integral types, not floating point. +-- ^ Warns about @[2,3 .. 1]@ or @['b' .. 'a']@ which return the empty list. +-- For numeric literals, only works for integral types, not floating point. warnAboutEmptyEnumerations fam_envs dflags fromExpr mThnExpr toExpr - | wopt Opt_WarnEmptyEnumerations dflags - , Just from_ty@(from,_) <- getLHsIntegralLit fromExpr + | not $ wopt Opt_WarnEmptyEnumerations dflags + = return () + -- Numeric Literals + | Just from_ty@(from,_) <- getLHsIntegralLit fromExpr , Just (_, tc) <- getNormalisedTyconName fam_envs from_ty , Just mThn <- traverse getLHsIntegralLit mThnExpr , Just (to,_) <- getLHsIntegralLit toExpr , let check :: forall a. (Enum a, Num a) => Proxy a -> DsM () check _proxy - = when (null enumeration) $ - warnDs (Reason Opt_WarnEmptyEnumerations) (text "Enumeration is empty") + = when (null enumeration) raiseWarning where enumeration :: [a] enumeration = case mThn of @@ -296,7 +297,18 @@ warnAboutEmptyEnumerations fam_envs dflags fromExpr mThnExpr toExpr -- See the T10930b test case for an example of where this matters. else return () + -- Char literals (#18402) + | Just fromChar <- getLHsCharLit fromExpr + , Just mThnChar <- traverse getLHsCharLit mThnExpr + , Just toChar <- getLHsCharLit toExpr + , let enumeration = case mThnChar of + Nothing -> [fromChar .. toChar] + Just thnChar -> [fromChar, thnChar .. toChar] + = when (null enumeration) raiseWarning + | otherwise = return () + where + raiseWarning = warnDs (Reason Opt_WarnEmptyEnumerations) (text "Enumeration is empty") getLHsIntegralLit :: LHsExpr GhcTc -> Maybe (Integer, Type) -- ^ See if the expression is an 'Integral' literal. @@ -325,6 +337,14 @@ getSimpleIntegralLit (HsWord64Prim _ i) = Just (i, word64PrimTy) getSimpleIntegralLit (HsInteger _ i ty) = Just (i, ty) getSimpleIntegralLit _ = Nothing +-- | Extract the Char if the expression is a Char literal. +getLHsCharLit :: LHsExpr GhcTc -> Maybe Char +getLHsCharLit (L _ (HsPar _ e)) = getLHsCharLit e +getLHsCharLit (L _ (HsTick _ _ e)) = getLHsCharLit e +getLHsCharLit (L _ (HsBinTick _ _ _ e)) = getLHsCharLit e +getLHsCharLit (L _ (HsLit _ (HsChar _ c))) = Just c +getLHsCharLit _ = Nothing + -- | Convert a pair (Integer, Type) to (Integer, Name) after eventually -- normalising the type getNormalisedTyconName :: FamInstEnvs -> (Integer, Type) -> Maybe (Integer, Name) ===================================== compiler/GHC/StgToCmm/CgUtils.hs ===================================== @@ -121,7 +121,7 @@ regTableOffset dflags n = get_Regtable_addr_from_offset :: DynFlags -> Int -> CmmExpr get_Regtable_addr_from_offset dflags offset = if haveRegBase (targetPlatform dflags) - then CmmRegOff baseReg offset + then cmmRegOff baseReg offset else regTableOffset dflags offset -- | Fixup global registers so that they assign to locations within the ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -75,13 +75,16 @@ testRules = do bindir <- getBinaryDirectory testGhc debugged <- ghcDebugged <$> flavour + dynPrograms <- dynamicGhcPrograms =<< flavour cmd [bindir "ghc" <.> exe] $ concatMap (\p -> ["-package", pkgName p]) depsPkgs ++ ["-o", top -/- path, top -/- sourcePath] ++ -- If GHC is build with debug options, then build check-ppr -- also with debug options. This allows, e.g., to print debug -- messages of various RTS subsystems while using check-ppr. - if debugged then ["-debug"] else [] + if debugged then ["-debug"] else [] ++ + -- If GHC is build dynamic, then build check-ppr also dynamic. + if dynPrograms then ["-dynamic"] else [] root -/- ghcConfigPath %> \_ -> do args <- userSetting defaultTestArgs ===================================== testsuite/tests/warnings/should_compile/T18402.hs ===================================== @@ -0,0 +1,8 @@ +module T18402 where + +a = ['b' .. 'a'] -- empty +b = ['b', 'a' .. 'c'] -- empty +c = ['b', 'c' .. 'a'] -- empty +d = ['a' .. 'c'] -- not empty +e = ['a', 'c' .. 'b'] -- not empty + ===================================== testsuite/tests/warnings/should_compile/T18402.stderr ===================================== @@ -0,0 +1,9 @@ + +T18402.hs:3:5: warning: [-Wempty-enumerations (in -Wdefault)] + Enumeration is empty + +T18402.hs:4:5: warning: [-Wempty-enumerations (in -Wdefault)] + Enumeration is empty + +T18402.hs:5:5: warning: [-Wempty-enumerations (in -Wdefault)] + Enumeration is empty ===================================== testsuite/tests/warnings/should_compile/all.T ===================================== @@ -30,3 +30,5 @@ test('Overflow', expect_broken_for(16543, ['hpc']), compile, ['']) test('UnusedPackages', normal, multimod_compile, ['UnusedPackages.hs', '-package=bytestring -package=base -package=process -package=ghc -Wunused-packages']) + +test('T18402', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d060c1e1150eca0445ba1fc2037af97690e69d35...6c2f69c68956be6b956d589ad838be3c1d986f49 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d060c1e1150eca0445ba1fc2037af97690e69d35...6c2f69c68956be6b956d589ad838be3c1d986f49 You're receiving 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 Jul 14 06:39:46 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 14 Jul 2020 02:39:46 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Warn about empty Char enumerations (#18402) Message-ID: <5f0d533277c63_80b3f848700d4d02947497@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 6581abf7 by Alp Mestanogullari at 2020-07-14T02:39:38-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 350a19bb by Sergei Trofimovich at 2020-07-14T02:39:40-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 428b033b by Sergei Trofimovich at 2020-07-14T02:39:40-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 6337efd6 by Stefan Schulze Frielinghaus at 2020-07-14T02:39:42-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - fefb266c by Matthias Andreas Benkard at 2020-07-14T02:39:43-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - acdbc051 by Matthias Andreas Benkard at 2020-07-14T02:39:43-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Match/Literal.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Utils/Binary.hs - compiler/ghc.cabal.in - docs/users_guide/exts/template_haskell.rst - ghc/GHCi/UI.hs - ghc/GHCi/UI/Info.hs - hadrian/src/Rules/Test.hs - includes/stg/Types.h - libraries/ghc-bignum/src/GHC/Num/BigNat.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78cb743f5915a24efbc3369e9bb5f478e9a1b5b4...acdbc05125c70aed67599704b1ac33ddb21ba69f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78cb743f5915a24efbc3369e9bb5f478e9a1b5b4...acdbc05125c70aed67599704b1ac33ddb21ba69f You're receiving 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 Jul 14 09:23:30 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 14 Jul 2020 05:23:30 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] 6 commits: Fix T13350 Message-ID: <5f0d799253b35_80b3f846a0d2e3c29634f6@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: bfa015bf by Moritz Angermann at 2020-07-14T08:47:46+00:00 Fix T13350 - - - - - 0299dfa1 by Moritz Angermann at 2020-07-14T08:50:16+00:00 Fix T1372 - - - - - adbc6213 by Moritz Angermann at 2020-07-14T09:18:25+00:00 Drop exec, use identity wrapper - - - - - acf51185 by Moritz Angermann at 2020-07-14T09:18:48+00:00 Fix T13168 - - - - - 58c97f5d by Moritz Angermann at 2020-07-14T09:18:58+00:00 Fix T3007 - - - - - ead8ecc4 by Moritz Angermann at 2020-07-14T09:23:10+00:00 Fix recomp007 - - - - - 7 changed files: - + testsuite/driver/id - testsuite/mk/test.mk - testsuite/tests/driver/T1372/Makefile - testsuite/tests/driver/T3007/Makefile - testsuite/tests/driver/recomp007/Makefile - testsuite/tests/patsyn/should_compile/T13350/Makefile - testsuite/tests/typecheck/T13168/Makefile Changes: ===================================== testsuite/driver/id ===================================== @@ -0,0 +1,9 @@ +#! /usr/bin/env bash +# +# This is the identity test-wrapper. For native tests we do not need to run +# executables through a wrapper, as we would need for cross compiled binaries. +# Cross compiled binaries can be evaluated through WINE, qemu-xxx, nodejs, ... +# +# Therefore this backup identity test-wrapper is the default for native builds. +# +"$@" \ No newline at end of file ===================================== testsuite/mk/test.mk ===================================== @@ -27,8 +27,8 @@ RUNTESTS = $(TOP)/driver/runtests.py COMPILER = ghc CONFIG = $(TOP)/config/$(COMPILER) -# if no TEST_WRAPPER is set, use exec -TEST_WRAPPER ?= exec +# if no TEST_WRAPPER is set, use an identity wrapper. +TEST_WRAPPER ?= $(TOP_ABS)/driver/id export TEST_WRAPPER # if no STRIP is set, use `strip` ===================================== testsuite/tests/driver/T1372/Makefile ===================================== @@ -4,11 +4,11 @@ include $(TOP)/mk/test.mk LOCAL_PKGCONF=local.package.conf -SETUP='$(TEST_WRAPPER)' '$(PWD)/Setup' -v0 +SETUP='$(TEST_WRAPPER)' './Setup' -v0 clean: - rm -f p1/setup p1/Setup.o p1/Setup.hi - rm -f p2/setup p2/Setup.o p2/Setup.hi + rm -f p1/Setup p1/Setup.o p1/Setup.hi + rm -f p2/Setup p2/Setup.o p2/Setup.hi rm -rf p1/dist p2/dist rm -f *.o *.hi rm -f clean.out prep.out ===================================== testsuite/tests/driver/T3007/Makefile ===================================== @@ -15,10 +15,10 @@ clean: T3007: $(MAKE) -s --no-print-directory clean '$(GHC_PKG)' init package.conf - cd A && '$(TEST_HC)' $(TEST_HC_OPTS) --make Setup + cd A && '$(TEST_HC)' $(TEST_HC_OPTS) --make Setup -v0 cd A && $(SETUP) configure --with-compiler='$(TEST_HC)' --ghc-pkg-option=--global-package-db=../package.conf --ghc-pkg-option=--no-user-package-db --ghc-option=-package-db../package.conf cd A && $(SETUP) build cd A && $(SETUP) register --inplace - cd B && '$(TEST_HC)' $(TEST_HC_OPTS) --make Setup + cd B && '$(TEST_HC)' $(TEST_HC_OPTS) --make Setup -v0 cd B && $(SETUP) configure --with-compiler='$(TEST_HC)' --ghc-pkg-option=--global-package-db=../package.conf --ghc-pkg-option=--no-user-package-db --ghc-option=-package-db../package.conf cd B && $(SETUP) build ===================================== testsuite/tests/driver/recomp007/Makefile ===================================== @@ -4,7 +4,7 @@ include $(TOP)/mk/test.mk LOCAL_PKGCONF=local.package.conf -SETUP='$(TEST_WRAPPER)' ../Setup -v0 +SETUP='$(TEST_WRAPPER)' ../Setup clean: rm -f Setup$(exeext) ===================================== testsuite/tests/patsyn/should_compile/T13350/Makefile ===================================== @@ -4,11 +4,11 @@ include $(TOP)/mk/test.mk LOCAL_PKGCONF=local.package.conf -SETUP='$(TEST_WRAPPER)' Setup -v0 +SETUP='$(TEST_WRAPPER)' ./Setup -v0 T13350: "$(GHC_PKG)" init $(LOCAL_PKGCONF) - cd boolean && "$(TEST_HC)" $(TEST_HC_OPTS) -v0 --make Setup.hs + cd boolean && "$(TEST_HC)" $(TEST_HC_OPTS) -v0 --make Setup.hs -o Setup cd boolean && $(SETUP) configure --with-compiler="$(TEST_HC)" --with-hc-pkg="$(GHC_PKG)" --package-db=../$(LOCAL_PKGCONF) cd boolean && $(SETUP) build cd boolean && $(SETUP) register --inplace ===================================== testsuite/tests/typecheck/T13168/Makefile ===================================== @@ -2,7 +2,7 @@ TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk -SETUP='$(TEST_WRAPPER)' ../Setup -v0 +SETUP='$(TEST_WRAPPER)' $(PWD)/Setup -v0 CONFIGURE=$(SETUP) configure --with-ghc='$(TEST_HC)' --with-strip='$(STRIP)' --ghc-options='$(TEST_HC_OPTS)' --package-db='$(PWD)/tmp.d' --prefix='$(PWD)/inst' T13168: clean View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/495da59b1b40e9d216b7ce86f19fd6c35d23d2ce...ead8ecc42e2ddeaf149c0a3812f306eb61cfce63 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/495da59b1b40e9d216b7ce86f19fd6c35d23d2ce...ead8ecc42e2ddeaf149c0a3812f306eb61cfce63 You're receiving 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 Jul 14 12:06:00 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 14 Jul 2020 08:06:00 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 16 commits: Revert "Overflow guard" Message-ID: <5f0d9fa81742_80b3f848a2b147c29872f6@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 566e5330 by Moritz Angermann at 2020-07-12T00:00:00+00:00 Revert "Overflow guard" They are Integers not Ints. This reverts commit 3ef94e593a2848cf2bdc4251f5be34536642675f. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - b3902d8c by Moritz Angermann at 2020-07-12T00:00:00+00:00 Add CmmAssign and CmmStore comments - - - - - 1670ab82 by Moritz Angermann at 2020-07-13T00:00:00+00:00 Minor address mode changes - - - - - 9b8edfa6 by Moritz Angermann at 2020-07-13T00:00:00+00:00 More Amode optimizations - - - - - ba1fd295 by Moritz Angermann at 2020-07-13T00:00:00+00:00 I think this shoudl work for all Registers, not just CmmGlobal - - - - - cee1984b by Moritz Angermann at 2020-07-13T00:00:00+00:00 Opt <<, >> - - - - - 8f290367 by Moritz Angermann at 2020-07-13T00:00:00+00:00 Opt &&, || - - - - - 590eec2c by Moritz Angermann at 2020-07-13T00:00:00+00:00 Add branch ANNotations. - - - - - d5835570 by Moritz Angermann at 2020-07-13T00:00:00+00:00 Disable Opt &&, ||, due to mask immediate - - - - - 0037d5d5 by Moritz Angermann at 2020-07-13T00:00:00+00:00 Opt: Adds CBZ, CBNZ - - - - - 244e836e by Moritz Angermann at 2020-07-14T00:00:00+00:00 More generic CBZ, CBNZ - - - - - 1590c456 by Moritz Angermann at 2020-07-14T00:00:00+00:00 Fixup - - - - - eb22b846 by Moritz Angermann at 2020-07-14T00:00:00+00:00 very rudimentary bitmask support. - - - - - 8a45c408 by Moritz Angermann at 2020-07-14T00:00:00+00:00 Add some more bitmasks - - - - - 0bdf6cb2 by Moritz Angermann at 2020-07-14T00:00:00+00:00 Opt STR - - - - - fe3aeaff by Moritz Angermann at 2020-07-14T00:00:00+00:00 Fixup - - - - - 3 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -2,7 +2,7 @@ {-# language GADTs #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE BangPatterns #-} - +{-# LANGUAGE BinaryLiterals, NumericUnderscores #-} module GHC.CmmToAsm.AArch64.CodeGen ( cmmTopCodeGen , generateJumpTableForInstr @@ -427,12 +427,10 @@ getRegister' :: NCGConfig -> Platform -> CmmExpr -> NatM Register -- OPTIMIZATION WARNING: CmmExpr rewrites -- 1. Rewrite: Reg + (-n) => Reg - n -- XXX: this expression souldn't even be generated to begin with. --- NOTE: i /= (minBound::Int) is for overflow checking. As negating woudl case --- an overflow. -getRegister' config plat (CmmMachOp (MO_Add w0) [x, CmmLit (CmmInt i w1)]) | i < 0 && i /= (minBound::Int) +getRegister' config plat (CmmMachOp (MO_Add w0) [x, CmmLit (CmmInt i w1)]) | i < 0 = getRegister' config plat (CmmMachOp (MO_Sub w0) [x, CmmLit (CmmInt (-i) w1)]) -getRegister' config plat (CmmMachOp (MO_Sub w0) [x, CmmLit (CmmInt i w1)]) | i < 0 && i /= (minBound::Int) +getRegister' config plat (CmmMachOp (MO_Sub w0) [x, CmmLit (CmmInt i w1)]) | i < 0 = getRegister' config plat (CmmMachOp (MO_Add w0) [x, CmmLit (CmmInt (-i) w1)]) @@ -545,7 +543,7 @@ getRegister' config plat expr CmmBlock _ -> pprPanic "getRegister' (CmmLit:CmmLabelOff): " (ppr expr) CmmHighStackMark -> pprPanic "getRegister' (CmmLit:CmmLabelOff): " (ppr expr) CmmLoad mem rep -> do - Amode addr addr_code <- getAmode mem + Amode addr addr_code <- getAmode plat mem let format = cmmTypeFormat rep return (Any format (\dst -> addr_code `snocOL` LDR format (OpReg (formatToWidth format) dst) (OpAddr addr))) CmmStackSlot _ _ @@ -610,16 +608,40 @@ 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@(CmmGlobal _)), CmmLit (CmmInt n _)] + CmmMachOp (MO_Add w) [(CmmReg reg), CmmLit (CmmInt n _)] | n > 0 && n < 4096 -> return $ Any (intFormat w) (\d -> unitOL $ ANN (text $ show expr) (ADD (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) -- XXX: 12bits lsl #12; e.g. lower 12 bits of n are 0; shift n >> 12, and set lsl to #12. - -- OPTIMIZATION WARNING: This only works because reg is CmmGlobal where w' = formatToWidth (cmmTypeFormat (cmmRegType plat reg)) r' = getRegisterReg plat reg - CmmMachOp (MO_Sub w) [(CmmReg reg@(CmmGlobal _)), CmmLit (CmmInt n _)] + CmmMachOp (MO_Sub w) [(CmmReg reg), CmmLit (CmmInt n _)] | n > 0 && n < 4096 -> return $ Any (intFormat w) (\d -> unitOL $ ANN (text $ show expr) (SUB (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) -- XXX: 12bits lsl #12; e.g. lower 12 bits of n are 0; shift n >> 12, and set lsl to #12. - -- OPTIMIZATION WARNING: This only works because reg is CmmGlobal + where w' = formatToWidth (cmmTypeFormat (cmmRegType plat reg)) + r' = getRegisterReg plat reg + + -- 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` ANN (text $ show 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 + (reg_x, _format_x, code_x) <- getSomeReg x + return $ Any (intFormat w) (\dst -> code_x `snocOL` ANN (text $ show expr) (LSL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) + + 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` ANN (text $ show 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 + (reg_x, _format_x, code_x) <- getSomeReg x + return $ Any (intFormat w) (\dst -> code_x `snocOL` ANN (text $ show expr) (LSR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) + + -- 3. Logic &&, || + CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isBitMaskImmediate (fromIntegral n) -> + return $ Any (intFormat w) (\d -> unitOL $ ANN (text $ show expr) (AND (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) + where w' = formatToWidth (cmmTypeFormat (cmmRegType plat reg)) + r' = getRegisterReg plat reg + + CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isBitMaskImmediate (fromIntegral n) -> + return $ Any (intFormat w) (\d -> unitOL $ ANN (text $ show expr) (ORR (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) where w' = formatToWidth (cmmTypeFormat (cmmRegType plat reg)) r' = getRegisterReg plat reg @@ -773,15 +795,64 @@ getRegister' config plat expr is16bit i = (-1 `shiftL` 15) <= i && i < (1 `shiftL` 15) is32bit :: Integer -> Bool is32bit i = (-1 `shiftL` 31) <= i && i < (1 `shiftL` 31) + -- This needs to check if n can be encoded as a bitmask immediate: + -- + -- See https://stackoverflow.com/questions/30904718/range-of-immediate-values-in-armv8-a64-assembly + -- + isBitMaskImmediate :: Integer -> Bool + isBitMaskImmediate i = i `elem` [0b0000_0001, 0b0000_0010, 0b0000_0100, 0b0000_1000, 0b0001_0000, 0b0010_0000, 0b0100_0000, 0b1000_0000 + ,0b0000_0011, 0b0000_0110, 0b0000_1100, 0b0001_1000, 0b0011_0000, 0b0110_0000, 0b1100_0000 + ,0b0000_0111, 0b0000_1110, 0b0001_1100, 0b0011_1000, 0b0111_0000, 0b1110_0000 + ,0b0000_1111, 0b0001_1110, 0b0011_1100, 0b0111_1000, 0b1111_0000 + ,0b0001_1111, 0b0011_1110, 0b0111_1100, 0b1111_1000 + ,0b0011_1111, 0b0111_1110, 0b1111_1100 + ,0b0111_1111, 0b1111_1110 + ,0b1111_1111] + -- ----------------------------------------------------------------------------- -- The 'Amode' type: Memory addressing modes passed up the tree. data Amode = Amode AddrMode InstrBlock -getAmode :: CmmExpr -> NatM Amode +getAmode :: Platform -> CmmExpr -> NatM Amode -- XXX: Specialize stuff we can destructure here. + +-- 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 (CmmRegOff reg off) + | typeWidth (cmmRegType platform reg) == W32, 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 (CmmRegOff reg off) + | typeWidth (cmmRegType platform reg) == W64, 0 <= off, off <= 32760, off `mod` 8 == 0 + = return $ Amode (AddrRegImm reg' off') nilOL + where reg' = getRegisterReg platform reg + off' = ImmInt off + +-- For Stores we often see something like this: +-- 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 + = 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 + = do (reg, _format, code) <- getSomeReg expr + return $ Amode (AddrRegImm reg (ImmInteger (-off))) code + -- Generic case -getAmode expr +getAmode _plat expr = do (reg, _format, code) <- getSomeReg expr return $ Amode (AddrReg reg) code @@ -806,14 +877,13 @@ assignReg_FltCode :: Format -> CmmReg -> CmmExpr -> NatM InstrBlock assignMem_IntCode rep addrE srcE = do (src_reg, _format, code) <- getSomeReg srcE - Amode addr addr_code <- getAmode addrE + platform <- getPlatform + Amode addr addr_code <- getAmode platform addrE let AddrReg r1 = addr - return $ unitOL (COMMENT $ text "RHS:" <+> ppr srcE) - `appOL` code - `appOL` unitOL (COMMENT $ text "LHS:" <+> ppr addrE) + return $ COMMENT (text "CmmStore" <+> parens (text (show addrE)) <+> parens (text (show srcE))) + `consOL` (code `appOL` addr_code - `snocOL` COMMENT (text "Store:" <+> ppr r1 <+> text "<-" <+> ppr src_reg) - `snocOL` STR rep (OpReg (formatToWidth rep) src_reg) (OpAddr addr) + `snocOL` STR rep (OpReg (formatToWidth rep) src_reg) (OpAddr addr)) assignReg_IntCode _ reg src = do @@ -823,8 +893,8 @@ assignReg_IntCode _ reg src p = showSDocUnsafe . ppr r <- getRegister src return $ case r of - Any _ code -> code dst - Fixed format freg fcode -> fcode `snocOL` MOV (OpReg (formatToWidth format) dst) (OpReg (formatToWidth format) freg) + Any _ code -> COMMENT (text "CmmAssign" <+> parens (text (show reg)) <+> parens (text (show src))) `consOL` code dst + Fixed format freg fcode -> COMMENT (text "CmmAssign" <+> parens (text (show reg)) <+> parens (text (show src))) `consOL` (fcode `snocOL` MOV (OpReg (formatToWidth format) dst) (OpReg (formatToWidth format) freg)) -- Let's treat Floating point stuff -- as integer code for now. Opaque. @@ -843,7 +913,7 @@ genJump (CmmLit (CmmLabel lbl)) regs -- , DELTA 0] ) genJump expr regs = do (target, _format, code) <- getSomeReg expr - return (code `appOL` unitOL (B (TReg target)) + return (code `appOL` unitOL (ANN (text $ show expr) (B (TReg target))) -- toOL [ PUSH_STACK_FRAME -- , DELTA (-16) -- , B (TReg target) @@ -863,20 +933,31 @@ genCondJump :: BlockId -> CmmExpr -> NatM InstrBlock -genCondJump bid expr - = case expr of +genCondJump bid expr = do + case expr of + -- Optimized == 0 case. + CmmMachOp (MO_Eq w) [x, CmmLit (CmmInt 0 _)] -> do + (reg_x, _format_x, code_x) <- getSomeReg x + return $ code_x `snocOL` (ANN (text $ show expr) (CBZ (OpReg w reg_x) (TBlock bid))) + + -- Optimized /= 0 case. + CmmMachOp (MO_Ne w) [x, CmmLit (CmmInt 0 _)] -> do + (reg_x, _format_x, code_x) <- getSomeReg x + return $ code_x `snocOL` (ANN (text $ show expr) (CBNZ (OpReg w reg_x) (TBlock bid))) + + -- Generic case. CmmMachOp mop [x, y] -> do let bcond w cmp = do -- compute both sides. (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ code_x `appOL` code_y `snocOL` CMP (OpReg w reg_x) (OpReg w reg_y) `snocOL` BCOND cmp (TBlock bid) + return $ code_x `appOL` code_y `snocOL` CMP (OpReg w reg_x) (OpReg w reg_y) `snocOL` (ANN (text $ show expr) (BCOND cmp (TBlock bid))) fbcond w cmp = do -- ensure we get float regs (reg_fx, _format_fx, code_fx) <- getFloatReg x (reg_fy, _format_fy, code_fy) <- getFloatReg y - return $ code_fx `appOL` code_fy `snocOL` CMP (OpReg w reg_fx) (OpReg w reg_fy) `snocOL` BCOND cmp (TBlock bid) + return $ code_fx `appOL` code_fy `snocOL` CMP (OpReg w reg_fx) (OpReg w reg_fy) `snocOL` (ANN (text $ show expr) (BCOND cmp (TBlock bid))) case mop of MO_F_Eq w -> fbcond w EQ ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -134,6 +134,8 @@ aarch64_regUsageOfInstr platform instr = case instr of -- 5. Atomic Instructions ---------------------------------------------------- -- 6. Conditional Instructions ----------------------------------------------- CSET dst _ -> usage ([], regOp dst) + CBZ src _ -> usage (regOp src, []) + CBNZ src _ -> usage (regOp src, []) -- 7. Load and Store Instructions -------------------------------------------- STR _ src dst -> usage (regOp src ++ regOp dst, []) LDR _ dst src -> usage (regOp src, regOp dst) @@ -257,7 +259,8 @@ aarch64_patchRegsOfInstr instr env = case instr of -- 5. Atomic Instructions -------------------------------------------------- -- 6. Conditional Instructions --------------------------------------------- CSET o c -> CSET (patchOp o) c - + CBZ o l -> CBZ (patchOp o) l + CBNZ o l -> CBNZ (patchOp o) l -- 7. Load and Store Instructions ------------------------------------------ STR f o1 o2 -> STR f (patchOp o1) (patchOp o2) LDR f o1 o2 -> LDR f (patchOp o1) (patchOp o2) @@ -293,6 +296,8 @@ aarch64_patchRegsOfInstr instr env = case instr of aarch64_isJumpishInstr :: Instr -> Bool aarch64_isJumpishInstr instr = case instr of ANN _ i -> aarch64_isJumpishInstr i + CBZ{} -> True + CBNZ{} -> True B{} -> True BL{} -> True BCOND{} -> True @@ -303,6 +308,8 @@ aarch64_isJumpishInstr instr = case instr of -- register allocator needs to worry about. aarch64_jumpDestsOfInstr :: Instr -> [BlockId] aarch64_jumpDestsOfInstr (ANN _ i) = aarch64_jumpDestsOfInstr i +aarch64_jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] +aarch64_jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] aarch64_jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] aarch64_jumpDestsOfInstr (BL t) = [ id | TBlock id <- [t]] aarch64_jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] @@ -315,6 +322,8 @@ aarch64_patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr aarch64_patchJumpInstr instr patchF = case instr of ANN d i -> ANN d (aarch64_patchJumpInstr i patchF) + CBZ r (TBlock bid) -> CBZ r (TBlock (patchF bid)) + CBNZ r (TBlock bid) -> CBNZ r (TBlock (patchF bid)) B (TBlock bid) -> B (TBlock (patchF bid)) BL (TBlock bid) -> BL (TBlock (patchF bid)) BCOND c (TBlock bid) -> BCOND c (TBlock (patchF bid)) @@ -527,12 +536,14 @@ data Instr | LDP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn <- *addr, Xm <- *(addr + 8) -- Conditional instructions - | CSET Operand Cond -- if(cond) op <- 1 else op <- 0 + | CSET Operand Cond -- if(cond) op <- 1 else op <- 0 + | CBZ Operand Target -- if op == 0, then branch. + | CBNZ Operand Target -- if op /= 0, then branch. -- Branching. - | B Target -- unconditional branching b/br. (To a blockid, label or register) - | BL Target -- branch and link (e.g. set x30 to next pc, and branch) - | BCOND Cond Target -- branch with condition. b. + | B Target -- unconditional branching b/br. (To a blockid, label or register) + | BL Target -- branch and link (e.g. set x30 to next pc, and branch) + | BCOND Cond Target -- branch with condition. b. -- 8. Synchronization Instructions ----------------------------------------- | DMBSY ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -435,6 +435,14 @@ pprInstr platform instr = case instr of -- 6. Conditional Instructions ----------------------------------------------- CSET o c -> text "\tcset" <+> pprOp o <> comma <+> pprCond c + CBZ o (TBlock bid) -> text "\tcbz" <+> pprOp o <> comma <+> ppr (mkLocalBlockLabel (getUnique bid)) + CBZ o (TLabel lbl) -> text "\tcbz" <+> pprOp o <> comma <+> ppr lbl + CBZ c (TReg r) -> panic "AArch64.ppr: No conditional (cbz) branching to registers!" + + CBNZ o (TBlock bid) -> text "\tcbnz" <+> pprOp o <> comma <+> ppr (mkLocalBlockLabel (getUnique bid)) + CBNZ o (TLabel lbl) -> text "\tcbnz" <+> pprOp o <> comma <+> ppr lbl + CBNZ c (TReg r) -> panic "AArch64.ppr: No conditional (cbz) branching to registers!" + -- 7. Load and Store Instructions -------------------------------------------- -- NOTE: GHC may do whacky things where it only load the lower part of an -- address. Not observing the correct size when loading will lead View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ce9cbc92c945c350dc3cc605bc7b78c97a133719...fe3aeaff2444881ef30adb9a82870f81a8880e7e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ce9cbc92c945c350dc3cc605bc7b78c97a133719...fe3aeaff2444881ef30adb9a82870f81a8880e7e You're receiving 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 Jul 14 12:10:13 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 14 Jul 2020 08:10:13 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: compiler: re-engineer the treatment of rebindable if Message-ID: <5f0da0a5288c6_80b3f849ca082f429909fa@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e8e75736 by Alp Mestanogullari at 2020-07-14T08:10:02-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 0c79634a by Sergei Trofimovich at 2020-07-14T08:10:04-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 0de16132 by Sergei Trofimovich at 2020-07-14T08:10:04-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 7b8595ff by Stefan Schulze Frielinghaus at 2020-07-14T08:10:09-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - bb30d9ce by Matthias Andreas Benkard at 2020-07-14T08:10:10-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - a2489006 by Matthias Andreas Benkard at 2020-07-14T08:10:10-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.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/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Utils/Binary.hs - compiler/ghc.cabal.in - docs/users_guide/exts/template_haskell.rst - ghc/GHCi/UI.hs - ghc/GHCi/UI/Info.hs - includes/stg/Types.h - libraries/ghc-bignum/src/GHC/Num/BigNat.hs-boot - libraries/ghc-bignum/src/GHC/Num/Natural.hs-boot - rts/Disassembler.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/acdbc05125c70aed67599704b1ac33ddb21ba69f...a2489006dac3b2181fb5e046cad6741575f38c2e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/acdbc05125c70aed67599704b1ac33ddb21ba69f...a2489006dac3b2181fb5e046cad6741575f38c2e You're receiving 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 Jul 14 12:59:18 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 14 Jul 2020 08:59:18 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] 2 commits: use $* Message-ID: <5f0dac26bd469_80b3f848700d4d03004780@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: cfe0671f by Moritz Angermann at 2020-07-14T12:58:48+00:00 use $* - - - - - c4b83631 by Moritz Angermann at 2020-07-14T12:59:11+00:00 fix concio001 - - - - - 2 changed files: - libraries/base/tests/IO/Makefile - testsuite/driver/id Changes: ===================================== libraries/base/tests/IO/Makefile ===================================== @@ -6,13 +6,14 @@ TOP=../../../../testsuite include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk +# NB. sleep for 3s. When we use TEST_WRAPPERs they might have a delay to come up. test.concio001: "$(TEST_HC)" $(TEST_HC_OPTS) --make -fforce-recomp -v0 concio001 -o concio001 - (sleep 1; echo x) | '$(TEST_WRAPPER)' ./concio001 + (sleep 3; echo x) | '$(TEST_WRAPPER)' ./concio001 test.concio001.thr: "$(TEST_HC)" $(TEST_HC_OPTS) --make -fforce-recomp -v0 -threaded concio001 -o concio001 - (sleep 1; echo x) | '$(TEST_WRAPPER)' ./concio001 + (sleep 3; echo x) | '$(TEST_WRAPPER)' ./concio001 # NB. utf8-test should *not* have a final newline. The last char should be 'X'. utf16-test: utf8-test ===================================== testsuite/driver/id ===================================== @@ -6,4 +6,4 @@ # # Therefore this backup identity test-wrapper is the default for native builds. # -"$@" \ No newline at end of file +"$*" \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ead8ecc42e2ddeaf149c0a3812f306eb61cfce63...c4b836312a39b6416b5c8057149f2b170d24be91 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ead8ecc42e2ddeaf149c0a3812f306eb61cfce63...c4b836312a39b6416b5c8057149f2b170d24be91 You're receiving 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 Jul 14 13:33:28 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Tue, 14 Jul 2020 09:33:28 -0400 Subject: [Git][ghc/ghc][wip/andreask/allocationArea] 8 commits: Define multiShotIO and use it in mkSplitUniqueSupply Message-ID: <5f0db428166b2_80b3f849ca082f430076ef@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/allocationArea at Glasgow Haskell Compiler / GHC Commits: d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - d5275f44 by Andreas Klebinger at 2020-07-14T09:33:25-04:00 Increase -A and -O rts defaults to 4MB. Fixes #16499 - - - - - 30 changed files: - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/444c1e0e9df29e3323bec9cf5d50fb88c57eaafa...d5275f44a45317d9806fb28ff94bc0b7d9aa99d1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/444c1e0e9df29e3323bec9cf5d50fb88c57eaafa...d5275f44a45317d9806fb28ff94bc0b7d9aa99d1 You're receiving 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 Jul 14 13:56:10 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 14 Jul 2020 09:56:10 -0400 Subject: [Git][ghc/ghc][master] 4 commits: Use dumpStyle when printing inlinings Message-ID: <5f0db97ad1970_80b3f8486fb6f7c30139c3@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 22 changed files: - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Solver/Flatten.hs - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/deSugar/should_compile/T16615.stderr - testsuite/tests/dependent/should_compile/dynamic-paper.stderr - testsuite/tests/numeric/should_compile/T14170.stdout - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/perf/compiler/T18282.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T15445.stderr - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4908.stderr - testsuite/tests/simplCore/should_compile/T4930.stderr - testsuite/tests/simplCore/should_compile/T7360.stderr - testsuite/tests/simplCore/should_compile/spec-inline.stderr - testsuite/tests/typecheck/should_compile/T13032.stderr Changes: ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -1933,7 +1933,7 @@ completeCall env var cont log_inlining doc = liftIO $ dumpAction dflags - (mkUserStyle alwaysQualify AllTheWay) + (mkDumpStyle alwaysQualify) (dumpOptionsFromFlag Opt_D_dump_inlinings) "" FormatText doc ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -887,16 +887,13 @@ conSize dc n_val_args | n_val_args == 0 = SizeIs 0 emptyBag 10 -- Like variables -- See Note [Unboxed tuple size and result discount] - | isUnboxedTupleCon dc = SizeIs 0 emptyBag (10 * (1 + n_val_args)) + | isUnboxedTupleCon dc = SizeIs 0 emptyBag 10 -- See Note [Constructor size and result discount] - | otherwise = SizeIs 10 emptyBag (10 * (1 + n_val_args)) + | otherwise = SizeIs 10 emptyBag 10 --- XXX still looks to large to me - -{- -Note [Constructor size and result discount] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- 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 @@ -907,14 +904,32 @@ The "result discount" is applied if the result of the call is scrutinised (say by a case). For a constructor application that will mean the constructor application will disappear, so we don't need to charge it to the function. So the discount should at least match the -cost of the constructor application, namely 10. But to give a bit -of extra incentive we give a discount of 10*(1 + n_val_args). - -Simon M tried a MUCH bigger discount: (10 * (10 + n_val_args)), -and said it was an "unambiguous win", but its terribly dangerous -because a function with many many case branches, each finishing with -a constructor, can have an arbitrarily large discount. This led to -terrible code bloat: see #6099. +cost of the constructor application, namely 10. + +Historical note 1: Until Jun 2020 we gave it a "bit of extra +incentive" via a discount of 10*(1 + n_val_args), but that was FAR too +much (#18282). In particular, consider a huge case tree like + + let r = case y1 of + Nothing -> B1 a b c + Just v1 -> case y2 of + Nothing -> B1 c b a + Just v2 -> ... + +If conSize gives a cost of 10 (regardless of n_val_args) and a +discount of 10, that'll make each alternative RHS cost zero. We +charge 10 for each case alternative (see size_up_alt). If we give a +bigger discount (say 20) in conSize, we'll make the case expression +cost *nothing*, and that can make a huge case tree cost nothing. This +leads to massive, sometimes exponenial inlinings (#18282). In short, +don't give a discount that give a negative size to a sub-expression! + +Historical note 2: Much longer ago, Simon M tried a MUCH bigger +discount: (10 * (10 + n_val_args)), and said it was an "unambiguous +win", but its terribly dangerous because a function with many many +case branches, each finishing with a constructor, can have an +arbitrarily large discount. This led to terrible code bloat: see +#6099. Note [Unboxed tuple size and result discount] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -924,7 +939,7 @@ and f wasn't getting inlined. I tried giving unboxed tuples a *result discount* of zero (see the commented-out line). Why? When returned as a result they do not -allocate, so maybe we don't want to charge so much for them If you +allocate, so maybe we don't want to charge so much for them. If you have a non-zero discount here, we find that workers often get inlined back into wrappers, because it look like f x = case $wf x of (# a,b #) -> (a,b) @@ -933,6 +948,9 @@ shrank binary sizes by 0.5% it also made spectral/boyer allocate 5% more. All other changes were very small. So it's not a big deal but I didn't adopt the idea. +When fixing #18282 (see Note [Constructor size and result discount]) +I changed the result discount to be just 10, not 10*(1+n_val_args). + Note [Function and non-function discounts] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We want a discount if the function is applied. A good example is ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -1412,16 +1412,21 @@ defaultDynFlags mySettings llvmConfig = extensions = [], extensionFlags = flattenExtensionFlags Nothing [], - -- The ufCreationThreshold threshold must be reasonably high to - -- take account of possible discounts. - -- E.g. 450 is not enough in 'fulsom' for Interval.sqr to inline - -- into Csg.calc (The unfolding for sqr never makes it into the - -- interface file.) ufCreationThreshold = 750, - ufUseThreshold = 80, - ufFunAppDiscount = 60, - -- Be fairly keen to inline a function if that means - -- we'll be able to pick the right method from a dictionary + -- The ufCreationThreshold threshold must be reasonably high + -- to take account of possible discounts. + -- E.g. 450 is not enough in 'fulsom' for Interval.sqr to + -- inline into Csg.calc (The unfolding for sqr never makes it + -- into the interface file.) + + ufUseThreshold = 90, + -- Last adjusted upwards in #18282, when I reduced + -- the result discount for constructors. + + ufFunAppDiscount = 60, + -- Be fairly keen to inline a function if that means + -- we'll be able to pick the right method from a dictionary + ufDictDiscount = 30, ufDearOp = 40, ufVeryAggressive = False, ===================================== compiler/GHC/Tc/Solver/Flatten.hs ===================================== @@ -954,8 +954,11 @@ faster. This doesn't seem quite worth it, yet. Note [flatten_exact_fam_app_fully performance] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The refactor of GRefl seems to cause performance trouble for T9872x: the allocation of flatten_exact_fam_app_fully_performance increased. See note [Generalized reflexive coercion] in GHC.Core.TyCo.Rep for more information about GRefl and #15192 for the current state. +The refactor of GRefl seems to cause performance trouble for T9872x: +the allocation of flatten_exact_fam_app_fully_performance +increased. See note [Generalized reflexive coercion] in +GHC.Core.TyCo.Rep for more information about GRefl and #15192 for the +current state. The explicit pattern match in homogenise_result helps with T9872a, b, c. ===================================== testsuite/tests/deSugar/should_compile/T13208.stdout ===================================== @@ -3,4 +3,4 @@ Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}] f = \ (@p) _ [Occ=Dead] -> GHC.Types.True Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] ===================================== testsuite/tests/deSugar/should_compile/T16615.stderr ===================================== @@ -7,7 +7,7 @@ Result size of Desugar (after optimization) T16615.$trModule :: GHC.Types.Module [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] T16615.$trModule = GHC.Types.Module (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "T16615"#) ===================================== testsuite/tests/dependent/should_compile/dynamic-paper.stderr ===================================== @@ -12,4 +12,4 @@ Simplifier ticks exhausted simplifier non-termination has been judged acceptable. To see detailed counts use -ddump-simpl-stats - Total ticks: 136962 + Total ticks: 136961 ===================================== testsuite/tests/numeric/should_compile/T14170.stdout ===================================== @@ -14,7 +14,7 @@ NatVal.$trModule4 = "main"# NatVal.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] NatVal.$trModule3 = GHC.Types.TrNameS NatVal.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ NatVal.$trModule2 = "NatVal"# NatVal.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] NatVal.$trModule1 = GHC.Types.TrNameS NatVal.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] NatVal.$trModule = GHC.Types.Module NatVal.$trModule3 NatVal.$trModule1 ===================================== testsuite/tests/numeric/should_compile/T14465.stdout ===================================== @@ -7,7 +7,7 @@ Result size of Tidy Core ten :: Natural [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] ten = GHC.Num.Natural.NS 10## -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -21,7 +21,7 @@ M.$trModule4 = "main"# M.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] M.$trModule3 = GHC.Types.TrNameS M.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -35,14 +35,14 @@ M.$trModule2 = "M"# M.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] M.$trModule1 = GHC.Types.TrNameS M.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} M.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] M.$trModule = GHC.Types.Module M.$trModule3 M.$trModule1 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} ===================================== testsuite/tests/numeric/should_compile/T7116.stdout ===================================== @@ -14,7 +14,7 @@ T7116.$trModule4 = "main"# T7116.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7116.$trModule3 = GHC.Types.TrNameS T7116.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T7116.$trModule2 = "T7116"# T7116.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7116.$trModule1 = GHC.Types.TrNameS T7116.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7116.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7116.$trModule = GHC.Types.Module T7116.$trModule3 T7116.$trModule1 ===================================== testsuite/tests/perf/compiler/T18282.hs ===================================== @@ -0,0 +1,40 @@ +module M + ( mkB2 + ) where + +import Control.Monad.Reader +import Data.Maybe + +data A1 = A1 (Maybe String) (Maybe String) (Maybe String) (Maybe String) +data A2 = A2 A1 (Maybe String) (Maybe String) (Maybe String) (Maybe String) + (Maybe String) (Maybe String) (Maybe String) (Maybe String) + +data B1 = B1 !String !String !String !String +data B2 = B2 !B1 !String !String !String !String !String !String !String !String + +type M a = ReaderT [(String, String)] (Either String) a + +resolve :: Maybe String -> String -> M (Maybe String) +resolve (Just x) _ = pure (Just x) +resolve Nothing v = asks $ lookup v + +mkB1 :: A1 -> M B1 +mkB1 (A1 a b c d) = do + a' <- fromMaybe "" <$> resolve a "A" + b' <- fromMaybe "" <$> resolve b "B" + c' <- fromMaybe "" <$> resolve c "C" + d' <- fromMaybe "" <$> resolve d "D" + pure $ B1 a' b' c' d' + +mkB2 :: A2 -> M B2 +mkB2 (A2 a b c d e f g h i) = do + a' <- mkB1 a + b' <- fromMaybe "db" <$> resolve b "B" + c' <- fromMaybe "dc" <$> resolve c "C" + d' <- fromMaybe "dd" <$> resolve d "D" + e' <- fromMaybe "de" <$> resolve e "E" + f' <- fromMaybe "df" <$> resolve f "F" + g' <- fromMaybe "dg" <$> resolve g "G" + h' <- fromMaybe "dh" <$> resolve h "H" + i' <- fromMaybe "di" <$> resolve i "I" + pure $ B2 a' b' c' d' e' f' g' h' i' ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -106,7 +106,7 @@ test('T5642', test('T5837', [ only_ways(['normal']), - collect_compiler_stats('bytes allocated',2) + collect_compiler_stats('bytes allocated',5) ], compile, ['-freduction-depth=50']) @@ -382,3 +382,9 @@ test ('T18304', ], compile, ['-v0 -O']) + +test ('T18282', + [ collect_compiler_stats('bytes allocated',2) + ], + compile, + ['-v0 -O']) ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -34,7 +34,7 @@ T13143.$trModule4 = "main"# T13143.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -48,14 +48,14 @@ T13143.$trModule2 = "T13143"# T13143.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T13143.$trModule1 = GHC.Types.TrNameS T13143.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T13143.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T13143.$trModule = GHC.Types.Module T13143.$trModule3 T13143.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T15445.stderr ===================================== @@ -10,4 +10,8 @@ Rule fired: Class op enumFromTo (BUILTIN) Rule fired: Class op show (BUILTIN) Rule fired: Class op enumFromTo (BUILTIN) Rule fired: eftIntList (GHC.Enum) +Rule fired: ># (BUILTIN) +Rule fired: ==# (BUILTIN) Rule fired: eftIntList (GHC.Enum) +Rule fired: ># (BUILTIN) +Rule fired: ==# (BUILTIN) ===================================== testsuite/tests/simplCore/should_compile/T18013.stderr ===================================== @@ -138,7 +138,7 @@ mapMaybeRule Arity=1, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 150 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 150 10}] mapMaybeRule = \ (@a) (@b) (f :: Rule IO a b) -> case f of { Rule @s t0 g -> @@ -178,7 +178,7 @@ T18013.$trModule4 = "main"# T18013.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + 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} @@ -192,14 +192,14 @@ T18013.$trModule2 = "T18013"# T18013.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + 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 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T18013.$trModule = GHC.Types.Module T18013.$trModule3 T18013.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T3717.stderr ===================================== @@ -14,7 +14,7 @@ T3717.$trModule4 = "main"# T3717.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3717.$trModule3 = GHC.Types.TrNameS T3717.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T3717.$trModule2 = "T3717"# T3717.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3717.$trModule1 = GHC.Types.TrNameS T3717.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T3717.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3717.$trModule = GHC.Types.Module T3717.$trModule3 T3717.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T3772.stdout ===================================== @@ -14,7 +14,7 @@ T3772.$trModule4 = "main"# T3772.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3772.$trModule3 = GHC.Types.TrNameS T3772.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T3772.$trModule2 = "T3772"# T3772.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3772.$trModule1 = GHC.Types.TrNameS T3772.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T3772.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T3772.$trModule = GHC.Types.Module T3772.$trModule3 T3772.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T4908.stderr ===================================== @@ -14,7 +14,7 @@ T4908.$trModule4 = "main"# T4908.$trModule3 :: TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4908.$trModule3 = GHC.Types.TrNameS T4908.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T4908.$trModule2 = "T4908"# T4908.$trModule1 :: TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4908.$trModule1 = GHC.Types.TrNameS T4908.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T4908.$trModule :: Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4908.$trModule = GHC.Types.Module T4908.$trModule3 T4908.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T4930.stderr ===================================== @@ -14,7 +14,7 @@ T4930.$trModule4 = "main"# T4930.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4930.$trModule3 = GHC.Types.TrNameS T4930.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T4930.$trModule2 = "T4930"# T4930.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4930.$trModule1 = GHC.Types.TrNameS T4930.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T4930.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T4930.$trModule = GHC.Types.Module T4930.$trModule3 T4930.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T7360.stderr ===================================== @@ -65,7 +65,7 @@ T7360.$trModule4 = "main"# T7360.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$trModule3 = GHC.Types.TrNameS T7360.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -79,14 +79,14 @@ T7360.$trModule2 = "T7360"# T7360.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$trModule1 = GHC.Types.TrNameS T7360.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7360.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$trModule = GHC.Types.Module T7360.$trModule3 T7360.$trModule1 @@ -108,14 +108,14 @@ T7360.$tcFoo2 = "Foo"# T7360.$tcFoo1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tcFoo1 = GHC.Types.TrNameS T7360.$tcFoo2 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tcFoo :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tcFoo = GHC.Types.TyCon 1581370841583180512## @@ -143,14 +143,14 @@ T7360.$tc'Foo6 = "'Foo1"# T7360.$tc'Foo5 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo5 = GHC.Types.TrNameS T7360.$tc'Foo6 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo1 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo1 = GHC.Types.TyCon 3986951253261644518## @@ -171,14 +171,14 @@ T7360.$tc'Foo8 = "'Foo2"# T7360.$tc'Foo7 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo7 = GHC.Types.TrNameS T7360.$tc'Foo8 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo2 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo2 = GHC.Types.TyCon 17325079864060690428## @@ -204,14 +204,14 @@ T7360.$tc'Foo11 = "'Foo3"# T7360.$tc'Foo10 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo10 = GHC.Types.TrNameS T7360.$tc'Foo11 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo3 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo3 = GHC.Types.TyCon 3674231676522181654## ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -14,7 +14,7 @@ Roman.$trModule4 = "main"# Roman.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] Roman.$trModule3 = GHC.Types.TrNameS Roman.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ Roman.$trModule2 = "Roman"# Roman.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] Roman.$trModule1 = GHC.Types.TrNameS Roman.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} Roman.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] Roman.$trModule = GHC.Types.Module Roman.$trModule3 Roman.$trModule1 @@ -130,14 +130,14 @@ Roman.foo_go Roman.foo2 :: Int [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] Roman.foo2 = GHC.Types.I# 6# -- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} Roman.foo1 :: Maybe Int [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] Roman.foo1 = GHC.Maybe.Just @Int Roman.foo2 -- RHS size: {terms: 11, types: 4, coercions: 0, joins: 0/0} ===================================== testsuite/tests/typecheck/should_compile/T13032.stderr ===================================== @@ -16,7 +16,7 @@ f = \ (@a) (@b) _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> T13032.$trModule :: GHC.Types.Module [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] T13032.$trModule = GHC.Types.Module (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "T13032"#) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c3ac87ece2716b83ad886e81c20f4161e8ec0efd...7f0b671ee8a65913891c07f157b21d77d6c63036 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c3ac87ece2716b83ad886e81c20f4161e8ec0efd...7f0b671ee8a65913891c07f157b21d77d6c63036 You're receiving 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 Jul 14 14:00:24 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 14 Jul 2020 10:00:24 -0400 Subject: [Git][ghc/ghc][wip/T13253] 7 commits: Warn about empty Char enumerations (#18402) Message-ID: <5f0dba78ac295_80bda8bdb4301553b@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC Commits: c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - dfa4a337 by Simon Peyton Jones at 2020-07-14T10:00:00-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes two significant changes: 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Then in postInlineUnconditionally use that info to avoid inling something many many times. Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally See Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils 2. Change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg] Current nofib run Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- VS -0.3% +115.9% +12.1% +11.2% 0.0% boyer2 -0.3% +10.0% +3.5% +4.0% 0.0% cryptarithm2 -0.3% +39.0% +16.6% +16.1% 0.0% gamteb -0.3% +4.1% -0.0% +0.4% 0.0% last-piece -0.3% +1.4% -1.1% -0.4% 0.0% mate -0.4% -11.1% -8.5% -9.0% 0.0% multiplier -0.3% -2.2% -1.5% -1.5% 0.0% transform -0.3% +3.4% +0.5% +0.8% 0.0% -------------------------------------------------------------------------------- Min -0.8% -11.1% -8.5% -9.0% 0.0% Max -0.3% +115.9% +30.1% +26.4% 0.0% Geometric Mean -0.3% +1.0% +1.0% +1.0% -0.0% Should investigate these numbers. But the tickets are indeed cured, I think. - - - - - 30 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Match/Literal.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id/Info.hs - hadrian/src/Rules/Test.hs - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/deSugar/should_compile/T16615.stderr - testsuite/tests/dependent/should_compile/dynamic-paper.stderr - testsuite/tests/numeric/should_compile/T14170.stdout - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T13253-spj.hs - + testsuite/tests/perf/compiler/T13253.hs - + testsuite/tests/perf/compiler/T18140.hs - + testsuite/tests/perf/compiler/T18282.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T15445.stderr - testsuite/tests/simplCore/should_compile/T15631.stdout - testsuite/tests/simplCore/should_compile/T17901.stdout The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/adcf83e20c034a1c784a85ea8ca66e3fe7d7fec4...dfa4a337ecb33314d8ceaef6a9266cd95005e22e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/adcf83e20c034a1c784a85ea8ca66e3fe7d7fec4...dfa4a337ecb33314d8ceaef6a9266cd95005e22e You're receiving 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 Jul 14 14:16:12 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Tue, 14 Jul 2020 10:16:12 -0400 Subject: [Git][ghc/ghc][wip/andreask/exprSizeBangs] Make sizeExpr strict in the size threshold to facilitate WW. Message-ID: <5f0dbe2ce8e41_80b3f8469e288943020322@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/exprSizeBangs at Glasgow Haskell Compiler / GHC Commits: d1dae72e by Andreas Klebinger at 2020-07-14T16:15:54+02:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - 1 changed file: - compiler/GHC/Core/Unfold.hs Changes: ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -16,6 +16,7 @@ find, unsurprisingly, a Core expression. -} {-# LANGUAGE CPP #-} +{-# LANGUAGE BangPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -612,7 +613,9 @@ sizeExpr :: DynFlags -- Note [Computing the size of an expression] -sizeExpr dflags bOMB_OUT_SIZE top_args expr +-- Forcing bOMB_OUT_SIZE early prevents repeated +-- unboxing of the Int argument. +sizeExpr dflags !bOMB_OUT_SIZE top_args expr = size_up expr where size_up (Cast e _) = size_up e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1dae72ee1b62054d8056d32578d222550f047b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1dae72ee1b62054d8056d32578d222550f047b7 You're receiving 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 Jul 14 14:24:00 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 14 Jul 2020 10:24:00 -0400 Subject: [Git][ghc/ghc][wip/T18412] Allow multiple case branches to have a higher rank type Message-ID: <5f0dc00092c1d_80b3f849ca082f4302787b@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18412 at Glasgow Haskell Compiler / GHC Commits: a60e30e0 by Simon Peyton Jones at 2020-07-14T15:22:15+01:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - 21 changed files: - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - testsuite/tests/simplCore/should_compile/T17901.stdout - + testsuite/tests/typecheck/should_compile/T18412.hs - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T10619.stderr - testsuite/tests/typecheck/should_fail/VtaFail.stderr - testsuite/tests/typecheck/should_fail/tcfail002.stderr - testsuite/tests/typecheck/should_fail/tcfail104.stderr Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -19,7 +19,7 @@ Note [The Type-related module hierarchy] -- We expose the relevant stuff from this module via the Type module {-# OPTIONS_HADDOCK not-home #-} -{-# LANGUAGE CPP, DeriveDataTypeable, MultiWayIf, PatternSynonyms, BangPatterns #-} +{-# LANGUAGE CPP, MultiWayIf, PatternSynonyms, BangPatterns, DeriveDataTypeable #-} module GHC.Core.TyCo.Rep ( TyThing(..), tyThingCategory, pprTyThingCategory, pprShortTyThing, @@ -2025,6 +2025,12 @@ GHC.Core.Multiplicity above this module. -- | A shorthand for data with an attached 'Mult' element (the multiplicity). data Scaled a = Scaled Mult a deriving (Data.Data) + -- You might think that this would be a natural candiate for + -- Functor, Traversable but Krzysztof says (!3674) "it was too easy + -- to accidentally lift functions (substitutions, zonking etc.) from + -- Type -> Type to Scaled Type -> Scaled Type, ignoring + -- multiplicities and causing bugs". So we don't. + instance (Outputable a) => Outputable (Scaled a) where ppr (Scaled _cnt t) = ppr t ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -48,7 +48,7 @@ module GHC.Core.Type ( mkSpecForAllTy, mkSpecForAllTys, mkVisForAllTys, mkTyCoInvForAllTy, mkInfForAllTy, mkInfForAllTys, - splitForAllTys, splitSomeForAllTys, + splitForAllTys, splitForAllTysReq, splitForAllTysInvis, splitForAllVarBndrs, splitForAllTy_maybe, splitForAllTy, @@ -284,7 +284,7 @@ import GHC.Data.List.SetOps import GHC.Types.Unique ( nonDetCmpUnique ) import GHC.Data.Maybe ( orElse, expectJust ) -import Data.Maybe ( isJust, mapMaybe ) +import Data.Maybe ( isJust ) import Control.Monad ( guard ) -- $type_classification @@ -1526,46 +1526,34 @@ splitForAllTys ty = split ty ty [] split orig_ty ty tvs | Just ty' <- coreView ty = split orig_ty ty' tvs split orig_ty _ tvs = (reverse tvs, orig_ty) --- | Like 'splitForAllTys', but only splits a 'ForAllTy' if @argf_pred argf@ --- is 'True', where @argf@ is the visibility of the @ForAllTy@'s binder and --- @argf_pred@ is a predicate over visibilities provided as an argument to this --- function. Furthermore, each returned tyvar is annotated with its @argf at . -splitSomeForAllTys :: (ArgFlag -> Bool) -> Type -> ([TyCoVarBinder], Type) +-- | Splits the longest initial sequence of ForAllTys' that satisfy +-- @argf_pred@, returning the binders transformed by @argf_pred@ +splitSomeForAllTys :: (ArgFlag -> Maybe af) -> Type -> ([VarBndr TyCoVar af], Type) splitSomeForAllTys argf_pred ty = split ty ty [] where - split _ (ForAllTy tvb@(Bndr _ argf) ty) tvs - | argf_pred argf = split ty ty (tvb:tvs) + split _ (ForAllTy (Bndr tcv argf) ty) tvs + | Just argf' <- argf_pred argf = split ty ty (Bndr tcv argf' : tvs) split orig_ty ty tvs | Just ty' <- coreView ty = split orig_ty ty' tvs split orig_ty _ tvs = (reverse tvs, orig_ty) -- | Like 'splitForAllTys', but only splits 'ForAllTy's with 'Required' type -- variable binders. Furthermore, each returned tyvar is annotated with '()'. splitForAllTysReq :: Type -> ([ReqTVBinder], Type) -splitForAllTysReq ty = - let (all_bndrs, body) = splitSomeForAllTys isVisibleArgFlag ty - req_bndrs = mapMaybe mk_req_bndr_maybe all_bndrs in - ASSERT( req_bndrs `equalLength` all_bndrs ) - (req_bndrs, body) +splitForAllTysReq ty = splitSomeForAllTys argf_pred ty where - mk_req_bndr_maybe :: TyCoVarBinder -> Maybe ReqTVBinder - mk_req_bndr_maybe (Bndr tv argf) = case argf of - Required -> Just $ Bndr tv () - Invisible _ -> Nothing + argf_pred :: ArgFlag -> Maybe () + argf_pred Required = Just () + argf_pred (Invisible {}) = Nothing -- | Like 'splitForAllTys', but only splits 'ForAllTy's with 'Invisible' type -- variable binders. Furthermore, each returned tyvar is annotated with its -- 'Specificity'. splitForAllTysInvis :: Type -> ([InvisTVBinder], Type) -splitForAllTysInvis ty = - let (all_bndrs, body) = splitSomeForAllTys isInvisibleArgFlag ty - inv_bndrs = mapMaybe mk_inv_bndr_maybe all_bndrs in - ASSERT( inv_bndrs `equalLength` all_bndrs ) - (inv_bndrs, body) +splitForAllTysInvis ty = splitSomeForAllTys argf_pred ty where - mk_inv_bndr_maybe :: TyCoVarBinder -> Maybe InvisTVBinder - mk_inv_bndr_maybe (Bndr tv argf) = case argf of - Invisible s -> Just $ Bndr tv s - Required -> Nothing + argf_pred :: ArgFlag -> Maybe Specificity + argf_pred Required = Nothing + argf_pred (Invisible spec) = Just spec -- | Like splitForAllTys, but split only for tyvars. -- This always succeeds, even if it returns only an empty list. Note that the ===================================== compiler/GHC/Core/UsageEnv.hs ===================================== @@ -1,7 +1,7 @@ {-# LANGUAGE ViewPatterns #-} module GHC.Core.UsageEnv (UsageEnv, addUsage, scaleUsage, zeroUE, lookupUE, scaleUE, deleteUE, addUE, Usage(..), unitUE, - supUE, supUEs) where + bottomUE, supUE, supUEs) where import Data.Foldable import GHC.Prelude ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -591,10 +591,6 @@ tcExpr (HsCase x scrut matches) res_ty tcExpr (HsIf x NoSyntaxExprRn pred b1 b2) res_ty -- Ordinary 'if' = do { pred' <- tcLExpr pred (mkCheckExpType boolTy) - ; res_ty <- tauifyExpType res_ty - -- Just like Note [Case branches must never infer a non-tau type] - -- in GHC.Tc.Gen.Match (See #10619) - ; (u1,b1') <- tcCollectingUsage $ tcLExpr b1 res_ty ; (u2,b2') <- tcCollectingUsage $ tcLExpr b2 res_ty ; tcEmitBindingUsage (supUE u1 u2) @@ -611,13 +607,7 @@ tcExpr (HsIf x fun@(SyntaxExprRn {}) pred b1 b2) res_ty ; return (HsIf x fun' pred' b1' b2') } tcExpr (HsMultiIf _ alts) res_ty - = do { res_ty <- if isSingleton alts - then return res_ty - else tauifyExpType res_ty - -- Just like GHC.Tc.Gen.Match - -- Note [Case branches must never infer a non-tau type] - - ; alts' <- mapM (wrapLocM $ tcGRHS match_ctxt res_ty) alts + = do { alts' <- mapM (wrapLocM $ tcGRHS match_ctxt res_ty) alts ; res_ty <- readExpType res_ty ; return (HsMultiIf res_ty alts') } where match_ctxt = MC { mc_what = IfAlt, mc_body = tcBody } ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -164,80 +164,47 @@ tcGRHSsPat grhss res_ty = tcGRHSs match_ctxt grhss (mkCheckExpType res_ty) match_ctxt = MC { mc_what = PatBindRhs, mc_body = tcBody } -{- -************************************************************************ +{- ********************************************************************* * * -\subsection{tcMatch} + tcMatch * * -************************************************************************ - -Note [Case branches must never infer a non-tau type] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider - - case ... of - ... -> \(x :: forall a. a -> a) -> x - ... -> \y -> y - -Should that type-check? The problem is that, if we check the second branch -first, then we'll get a type (b -> b) for the branches, which won't unify -with the polytype in the first branch. If we check the first branch first, -then everything is OK. This order-dependency is terrible. So we want only -proper tau-types in branches (unless a sigma-type is pushed down). -This is what expTypeToType ensures: it replaces an Infer with a fresh -tau-type. - -An even trickier case looks like - - f x True = x undefined - f x False = x () - -Here, we see that the arguments must also be non-Infer. Thus, we must -use expTypeToType on the output of matchExpectedFunTys, not the input. - -But we make a special case for a one-branch case. This is so that - - f = \(x :: forall a. a -> a) -> x - -still gets assigned a polytype. --} +********************************************************************* -} --- | When the MatchGroup has multiple RHSs, convert an Infer ExpType in the --- expected type into TauTvs. --- See Note [Case branches must never infer a non-tau type] -tauifyMultipleMatches :: [LMatch id body] - -> [Scaled ExpType] -> TcM [Scaled ExpType] -tauifyMultipleMatches group exp_tys - | isSingletonMatchGroup group = return exp_tys - | otherwise = mapM (\(Scaled m t) -> - fmap (Scaled m) (tauifyExpType t)) exp_tys - -- NB: In the empty-match case, this ensures we fill in the ExpType +data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module + = MC { mc_what :: HsMatchContext GhcRn, -- What kind of thing this is + mc_body :: Located (body GhcRn) -- Type checker for a body of + -- an alternative + -> ExpRhoType + -> TcM (Located (body GhcTc)) } -- | Type-check a MatchGroup. tcMatches :: (Outputable (body GhcRn)) => TcMatchCtxt body -> [Scaled ExpSigmaType] -- Expected pattern types - -> ExpRhoType -- Expected result-type of the Match. + -> ExpRhoType -- Expected result-type of the Match. -> MatchGroup GhcRn (Located (body GhcRn)) -> TcM (MatchGroup GhcTc (Located (body GhcTc))) -data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module - = MC { mc_what :: HsMatchContext GhcRn, -- What kind of thing this is - mc_body :: Located (body GhcRn) -- Type checker for a body of - -- an alternative - -> ExpRhoType - -> TcM (Located (body GhcTc)) } tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches , mg_origin = origin }) - = do { (Scaled _ rhs_ty):pat_tys <- tauifyMultipleMatches matches ((Scaled One rhs_ty):pat_tys) -- return type has implicitly multiplicity 1, it doesn't matter all that much in this case since it isn't used and is eliminated immediately. - -- See Note [Case branches must never infer a non-tau type] + | null matches -- Deal with case e of {} + -- Since there are no branches, no one else will fill in rhs_ty + -- when in inference mode, so we must do it ourselves, + -- here, using expTypeToType + = do { tcEmitBindingUsage bottomUE + ; pat_tys <- mapM scaledExpTypeToType pat_tys + ; rhs_ty <- expTypeToType rhs_ty + ; return (MG { mg_alts = L l [] + , mg_ext = MatchGroupTc pat_tys rhs_ty + , mg_origin = origin }) } - ; umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches + | otherwise + = do { umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches ; let (usages,matches') = unzip umatches ; tcEmitBindingUsage $ supUEs usages - ; pat_tys <- mapM (\(Scaled m t) -> fmap (Scaled m) (readExpType t)) pat_tys + ; pat_tys <- mapM readScaledExpType pat_tys ; rhs_ty <- readExpType rhs_ty - ; return (MG { mg_alts = L l matches' - , mg_ext = MatchGroupTc pat_tys rhs_ty + ; return (MG { mg_alts = L l matches' + , mg_ext = MatchGroupTc pat_tys rhs_ty , mg_origin = origin }) } ------------- ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -220,8 +220,9 @@ tcPatBndr penv@(PE { pe_ctxt = LetPat { pc_lvl = bind_lvl = do { (co, bndr_ty) <- case scaledThing exp_pat_ty of Check pat_ty -> promoteTcType bind_lvl pat_ty Infer infer_res -> ASSERT( bind_lvl == ir_lvl infer_res ) - -- If we were under a constructor that bumped - -- the level, we'd be in checking mode + -- If we were under a constructor that bumped the + -- level, we'd be in checking mode (see tcConArg) + -- hence this assertion do { bndr_ty <- inferResultToType infer_res ; return (mkTcNomReflCo bndr_ty, bndr_ty) } ; let bndr_mult = scaledMult exp_pat_ty @@ -629,10 +630,9 @@ There are two bits of rebindable syntax: lit1_ty and lit2_ty could conceivably be different. var_ty is the type inferred for x, the variable in the pattern. -If the pushed-down pattern type isn't a tau-type, the two pat_ty's above -could conceivably be different specializations. But this is very much -like the situation in Note [Case branches must be taus] in GHC.Tc.Gen.Match. -So we tauify the pat_ty before proceeding. +If the pushed-down pattern type isn't a tau-type, the two pat_ty's +above could conceivably be different specializations. So we use +expTypeToType on pat_ty before proceeding. Note that we need to type-check the literal twice, because it is used twice, and may be used at different types. The second HsOverLit stored in the ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -36,7 +36,7 @@ import GHC.Tc.Utils.TcType import GHC.Tc.Utils.TcMType import GHC.Tc.Validity ( checkValidType ) import GHC.Tc.Utils.Unify( tcSkolemise, unifyType ) -import GHC.Tc.Utils.Instantiate( topInstantiate ) +import GHC.Tc.Utils.Instantiate( topInstantiate, tcInstTypeBndrs ) import GHC.Tc.Utils.Env( tcLookupId ) import GHC.Tc.Types.Evidence( HsWrapper, (<.>) ) import GHC.Core.Type ( mkTyVarBinders ) @@ -488,7 +488,7 @@ tcInstSig :: TcIdSigInfo -> TcM TcIdSigInst -- Instantiate a type signature; only used with plan InferGen tcInstSig sig@(CompleteSig { sig_bndr = poly_id, sig_loc = loc }) = setSrcSpan loc $ -- Set the binding site of the tyvars - do { (tv_prs, theta, tau) <- tcInstTypeBndrs newMetaTyVarTyVars poly_id + do { (tv_prs, theta, tau) <- tcInstTypeBndrs poly_id -- See Note [Pattern bindings and complete signatures] ; return (TISI { sig_inst_sig = sig ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -16,6 +16,7 @@ import GHC.Prelude import GHC.Tc.Utils.Env import GHC.Tc.Utils.Monad import GHC.Tc.Utils.TcType +import GHC.Tc.Utils.Instantiate( tcInstType ) import GHC.Tc.Instance.Typeable import GHC.Tc.Utils.TcMType import GHC.Tc.Types.Evidence ===================================== compiler/GHC/Tc/Instance/Family.hs ===================================== @@ -21,6 +21,7 @@ import GHC.Core.Coercion import GHC.Tc.Types.Evidence import GHC.Iface.Load import GHC.Tc.Utils.Monad +import GHC.Tc.Utils.Instantiate( freshenTyVarBndrs, freshenCoVarBndrsX ) import GHC.Types.SrcLoc as SrcLoc import GHC.Core.TyCon import GHC.Tc.Utils.TcType @@ -35,7 +36,6 @@ import GHC.Data.Maybe import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs import GHC.Core.TyCo.Ppr ( pprWithExplicitKindsWhen ) -import GHC.Tc.Utils.TcMType import GHC.Types.Name import GHC.Utils.Panic import GHC.Types.Var.Set ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -31,11 +31,12 @@ where import GHC.Prelude import GHC.Hs -import GHC.Tc.Utils.Env import GHC.Tc.Gen.Sig import GHC.Tc.Types.Evidence ( idHsWrapper ) import GHC.Tc.Gen.Bind +import GHC.Tc.Utils.Env import GHC.Tc.Utils.Unify +import GHC.Tc.Utils.Instantiate( tcSuperSkolTyVars ) import GHC.Tc.Gen.HsType import GHC.Tc.Utils.TcMType import GHC.Core.Type ( piResultTys ) ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -16,6 +16,12 @@ module GHC.Tc.Utils.Instantiate ( instCall, instDFunType, instStupidTheta, instTyVarsWith, newWanted, newWanteds, + tcInstType, tcInstTypeBndrs, + tcInstSkolTyVars, tcInstSkolTyVarsX, tcInstSkolTyVarsAt, + tcSkolDFunType, tcSuperSkolTyVars, tcInstSuperSkolTyVarsX, + + freshenTyVarBndrs, freshenCoVarBndrsX, + tcInstInvisibleTyBindersN, tcInstInvisibleTyBinders, tcInstInvisibleTyBinder, newOverloadedLit, mkOverLit, @@ -63,7 +69,7 @@ import GHC.Types.Id.Make( mkDictFunId ) import GHC.Core( Expr(..) ) -- For the Coercion constructor import GHC.Types.Id import GHC.Types.Name -import GHC.Types.Var ( EvVar, tyVarName, VarBndr(..) ) +import GHC.Types.Var import GHC.Core.DataCon import GHC.Types.Var.Env import GHC.Builtin.Names @@ -74,7 +80,7 @@ import GHC.Utils.Outputable import GHC.Types.Basic ( TypeOrKind(..) ) import qualified GHC.LanguageExtensions as LangExt -import Data.List ( sortBy ) +import Data.List ( sortBy, mapAccumL ) import Control.Monad( unless ) import Data.Function ( on ) @@ -451,15 +457,192 @@ mkEqBoxTy co ty1 ty2 mkTyConApp (promoteDataCon eqDataCon) [k, ty1, ty2, mkCoercionTy co] where k = tcTypeKind ty1 -{- -************************************************************************ +{- ********************************************************************* * * - Literals + SkolemTvs (immutable) * * -************************************************************************ +********************************************************************* -} +tcInstType :: ([TyVar] -> TcM (TCvSubst, [TcTyVar])) + -- ^ How to instantiate the type variables + -> Id -- ^ Type to instantiate + -> TcM ([(Name, TcTyVar)], TcThetaType, TcType) -- ^ Result + -- (type vars, preds (incl equalities), rho) +tcInstType inst_tyvars id + | null tyvars -- There may be overloading despite no type variables; + -- (?x :: Int) => Int -> Int + = return ([], theta, tau) + | otherwise + = do { (subst, tyvars') <- inst_tyvars tyvars + ; let tv_prs = map tyVarName tyvars `zip` tyvars' + subst' = extendTCvInScopeSet subst (tyCoVarsOfType rho) + ; return (tv_prs, substTheta subst' theta, substTy subst' tau) } + where + (tyvars, rho) = tcSplitForAllTys (idType id) + (theta, tau) = tcSplitPhiTy rho + +tcInstTypeBndrs :: Id -> TcM ([(Name, InvisTVBinder)], TcThetaType, TcType) + -- (type vars, preds (incl equalities), rho) +-- Instantiate the binders of a type signature with TyVarTvs +tcInstTypeBndrs id + | null tyvars -- There may be overloading despite no type variables; + -- (?x :: Int) => Int -> Int + = return ([], theta, tau) + | otherwise + = do { (subst, tyvars') <- mapAccumLM inst_invis_bndr emptyTCvSubst tyvars + ; let tv_prs = map (tyVarName . binderVar) tyvars `zip` tyvars' + subst' = extendTCvInScopeSet subst (tyCoVarsOfType rho) + ; return (tv_prs, substTheta subst' theta, substTy subst' tau) } + where + (tyvars, rho) = splitForAllTysInvis (idType id) + (theta, tau) = tcSplitPhiTy rho + + inst_invis_bndr :: TCvSubst -> InvisTVBinder + -> TcM (TCvSubst, InvisTVBinder) + inst_invis_bndr subst (Bndr tv spec) + = do { (subst', tv') <- newMetaTyVarTyVarX subst tv + ; return (subst', Bndr tv' spec) } + +tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType) +-- Instantiate a type signature with skolem constants. +-- We could give them fresh names, but no need to do so +tcSkolDFunType dfun + = do { (tv_prs, theta, tau) <- tcInstType tcInstSuperSkolTyVars dfun + ; return (map snd tv_prs, theta, tau) } + +tcSuperSkolTyVars :: [TyVar] -> (TCvSubst, [TcTyVar]) +-- Make skolem constants, but do *not* give them new names, as above +-- Moreover, make them "super skolems"; see comments with superSkolemTv +-- see Note [Kind substitution when instantiating] +-- Precondition: tyvars should be ordered by scoping +tcSuperSkolTyVars = mapAccumL tcSuperSkolTyVar emptyTCvSubst + +tcSuperSkolTyVar :: TCvSubst -> TyVar -> (TCvSubst, TcTyVar) +tcSuperSkolTyVar subst tv + = (extendTvSubstWithClone subst tv new_tv, new_tv) + where + kind = substTyUnchecked subst (tyVarKind tv) + new_tv = mkTcTyVar (tyVarName tv) kind superSkolemTv + +-- | Given a list of @['TyVar']@, skolemize the type variables, +-- returning a substitution mapping the original tyvars to the +-- skolems, and the list of newly bound skolems. +tcInstSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSkolTyVars = tcInstSkolTyVarsX emptyTCvSubst + +tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSkolTyVarsX = tcInstSkolTyVarsPushLevel False + +tcInstSuperSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSuperSkolTyVars = tcInstSuperSkolTyVarsX emptyTCvSubst + +tcInstSuperSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) +-- See Note [Skolemising type variables] +tcInstSuperSkolTyVarsX subst = tcInstSkolTyVarsPushLevel True subst + +tcInstSkolTyVarsPushLevel :: Bool -> TCvSubst -> [TyVar] + -> TcM (TCvSubst, [TcTyVar]) +-- Skolemise one level deeper, hence pushTcLevel +-- See Note [Skolemising type variables] +tcInstSkolTyVarsPushLevel overlappable subst tvs + = do { tc_lvl <- getTcLevel + ; let pushed_lvl = pushTcLevel tc_lvl + ; tcInstSkolTyVarsAt pushed_lvl overlappable subst tvs } + +tcInstSkolTyVarsAt :: TcLevel -> Bool + -> TCvSubst -> [TyVar] + -> TcM (TCvSubst, [TcTyVar]) +tcInstSkolTyVarsAt lvl overlappable subst tvs + = freshenTyCoVarsX new_skol_tv subst tvs + where + details = SkolemTv lvl overlappable + new_skol_tv name kind = mkTcTyVar name kind details + +------------------ +freshenTyVarBndrs :: [TyVar] -> TcM (TCvSubst, [TyVar]) +-- ^ Give fresh uniques to a bunch of TyVars, but they stay +-- as TyVars, rather than becoming TcTyVars +-- Used in 'GHC.Tc.Instance.Family.newFamInst', and 'GHC.Tc.Utils.Instantiate.newClsInst' +freshenTyVarBndrs = freshenTyCoVars mkTyVar + +freshenCoVarBndrsX :: TCvSubst -> [CoVar] -> TcM (TCvSubst, [CoVar]) +-- ^ Give fresh uniques to a bunch of CoVars +-- Used in "GHC.Tc.Instance.Family.newFamInst" +freshenCoVarBndrsX subst = freshenTyCoVarsX mkCoVar subst + +------------------ +freshenTyCoVars :: (Name -> Kind -> TyCoVar) + -> [TyVar] -> TcM (TCvSubst, [TyCoVar]) +freshenTyCoVars mk_tcv = freshenTyCoVarsX mk_tcv emptyTCvSubst + +freshenTyCoVarsX :: (Name -> Kind -> TyCoVar) + -> TCvSubst -> [TyCoVar] + -> TcM (TCvSubst, [TyCoVar]) +freshenTyCoVarsX mk_tcv = mapAccumLM (freshenTyCoVarX mk_tcv) + +freshenTyCoVarX :: (Name -> Kind -> TyCoVar) + -> TCvSubst -> TyCoVar -> TcM (TCvSubst, TyCoVar) +-- This a complete freshening operation: +-- the skolems have a fresh unique, and a location from the monad +-- See Note [Skolemising type variables] +freshenTyCoVarX mk_tcv subst tycovar + = do { loc <- getSrcSpanM + ; uniq <- newUnique + ; let old_name = tyVarName tycovar + new_name = mkInternalName uniq (getOccName old_name) loc + new_kind = substTyUnchecked subst (tyVarKind tycovar) + new_tcv = mk_tcv new_name new_kind + subst1 = extendTCvSubstWithClone subst tycovar new_tcv + ; return (subst1, new_tcv) } + +{- Note [Skolemising type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The tcInstSkolTyVars family of functions instantiate a list of TyVars +to fresh skolem TcTyVars. Important notes: + +a) Level allocation. We generally skolemise /before/ calling + pushLevelAndCaptureConstraints. So we want their level to the level + of the soon-to-be-created implication, which has a level ONE HIGHER + than the current level. Hence the pushTcLevel. It feels like a + slight hack. + +b) The [TyVar] should be ordered (kind vars first) + See Note [Kind substitution when instantiating] + +c) It's a complete freshening operation: the skolems have a fresh + unique, and a location from the monad + +d) The resulting skolems are + non-overlappable for tcInstSkolTyVars, + but overlappable for tcInstSuperSkolTyVars + See GHC.Tc.Deriv.Infer Note [Overlap and deriving] for an example + of where this matters. + +Note [Kind substitution when instantiating] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When we instantiate a bunch of kind and type variables, first we +expect them to be topologically sorted. +Then we have to instantiate the kind variables, build a substitution +from old variables to the new variables, then instantiate the type +variables substituting the original kind. + +Exemple: If we want to instantiate + [(k1 :: *), (k2 :: *), (a :: k1 -> k2), (b :: k1)] +we want + [(?k1 :: *), (?k2 :: *), (?a :: ?k1 -> ?k2), (?b :: ?k1)] +instead of the bogus + [(?k1 :: *), (?k2 :: *), (?a :: k1 -> k2), (?b :: k1)] -} +{- ********************************************************************* +* * + Literals +* * +********************************************************************* -} + {- In newOverloadedLit we convert directly to an Int or Integer if we know that's what we want. This may save some time, by not @@ -474,8 +657,6 @@ newOverloadedLit :: HsOverLit GhcRn newOverloadedLit lit@(OverLit { ol_val = val, ol_ext = rebindable }) res_ty | not rebindable - -- all built-in overloaded lits are tau-types, so we can just - -- tauify the ExpType = do { res_ty <- expTypeToType res_ty ; dflags <- getDynFlags ; let platform = targetPlatform dflags ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -31,15 +31,6 @@ module GHC.Tc.Utils.TcMType ( newTauTvDetailsAtLevel, newMetaDetails, newMetaTyVarName, isFilledMetaTyVar_maybe, isFilledMetaTyVar, isUnfilledMetaTyVar, - -------------------------------- - -- Expected types - ExpType(..), ExpSigmaType, ExpRhoType, - mkCheckExpType, - newInferExpType, - readExpType, readExpType_maybe, - expTypeToType, checkingExpType_maybe, checkingExpType, - tauifyExpType, inferResultToType, - -------------------------------- -- Creating new evidence variables newEvVar, newEvVars, newDict, @@ -58,14 +49,18 @@ module GHC.Tc.Utils.TcMType ( -------------------------------- -- Instantiation newMetaTyVars, newMetaTyVarX, newMetaTyVarsX, - newMetaTyVarTyVars, newMetaTyVarTyVarX, + newMetaTyVarTyVarX, newTyVarTyVar, cloneTyVarTyVar, newPatSigTyVar, newSkolemTyVar, newWildCardX, - tcInstType, tcInstTypeBndrs, - tcInstSkolTyVars, tcInstSkolTyVarsX, tcInstSkolTyVarsAt, - tcSkolDFunType, tcSuperSkolTyVars, tcInstSuperSkolTyVarsX, - freshenTyVarBndrs, freshenCoVarBndrsX, + -------------------------------- + -- Expected types + ExpType(..), ExpSigmaType, ExpRhoType, + mkCheckExpType, newInferExpType, tcInfer, + readExpType, readExpType_maybe, readScaledExpType, + expTypeToType, scaledExpTypeToType, + checkingExpType_maybe, checkingExpType, + inferResultToType, fillInferResult, promoteTcType, -------------------------------- -- Zonking and tidying @@ -99,6 +94,8 @@ module GHC.Tc.Utils.TcMType ( -- friends: import GHC.Prelude +import {-# SOURCE #-} GHC.Tc.Utils.Unify( unifyType {- , unifyKind -} ) + import GHC.Core.TyCo.Rep import GHC.Core.TyCo.Ppr import GHC.Tc.Utils.TcType @@ -133,7 +130,6 @@ import GHC.Types.Basic ( TypeOrKind(..) ) import Control.Monad import GHC.Data.Maybe -import Data.List ( mapAccumL ) import Control.Arrow ( second ) import qualified Data.Semigroup as Semi @@ -387,16 +383,14 @@ checkCoercionHole cv co | otherwise = False -{- -************************************************************************ +{- ********************************************************************** * - Expected types + ExpType functions * -************************************************************************ - -Note [ExpType] -~~~~~~~~~~~~~~ +********************************************************************** -} +{- Note [ExpType] +~~~~~~~~~~~~~~~~~ An ExpType is used as the "expected type" when type-checking an expression. An ExpType can hold a "hole" that can be filled in by the type-checker. This allows us to have one tcExpr that works in both checking mode and @@ -426,14 +420,12 @@ Consider This is a classic untouchable-variable / ambiguous GADT return type scenario. But, with ExpTypes, we'll be inferring the type of the RHS. -And, because there is only one branch of the case, we won't trigger -Note [Case branches must never infer a non-tau type] of GHC.Tc.Gen.Match. We thus must track a TcLevel in an Inferring ExpType. If we try to -fill the ExpType and find that the TcLevels don't work out, we -fill the ExpType with a tau-tv at the low TcLevel, hopefully to -be worked out later by some means. This is triggered in -test gadt/gadt-escape1. +fill the ExpType and find that the TcLevels don't work out, we fill +the ExpType with a tau-tv at the low TcLevel, hopefully to be worked +out later by some means -- see fillInferResult, and Note [fillInferResult] +This behaviour triggered in test gadt/gadt-escape1. -} -- actual data definition is in GHC.Tc.Utils.TcType @@ -453,6 +445,12 @@ readExpType_maybe :: ExpType -> TcM (Maybe TcType) readExpType_maybe (Check ty) = return (Just ty) readExpType_maybe (Infer (IR { ir_ref = ref})) = readMutVar ref +-- | Same as readExpType, but for Scaled ExpTypes +readScaledExpType :: Scaled ExpType -> TcM (Scaled Type) +readScaledExpType (Scaled m exp_ty) + = do { ty <- readExpType exp_ty + ; return (Scaled m ty) } + -- | Extract a type out of an ExpType. Otherwise, panics. readExpType :: ExpType -> TcM TcType readExpType exp_ty @@ -472,12 +470,10 @@ checkingExpType :: String -> ExpType -> TcType checkingExpType _ (Check ty) = ty checkingExpType err et = pprPanic "checkingExpType" (text err $$ ppr et) -tauifyExpType :: ExpType -> TcM ExpType --- ^ Turn a (Infer hole) type into a (Check alpha), --- where alpha is a fresh unification variable -tauifyExpType (Check ty) = return (Check ty) -- No-op for (Check ty) -tauifyExpType (Infer inf_res) = do { ty <- inferResultToType inf_res - ; return (Check ty) } +scaledExpTypeToType :: Scaled ExpType -> TcM (Scaled TcType) +scaledExpTypeToType (Scaled m exp_ty) + = do { ty <- expTypeToType exp_ty + ; return (Scaled m ty) } -- | Extracts the expected type if there is one, or generates a new -- TauTv if there isn't. @@ -488,209 +484,284 @@ expTypeToType (Infer inf_res) = inferResultToType inf_res inferResultToType :: InferResult -> TcM Type inferResultToType (IR { ir_uniq = u, ir_lvl = tc_lvl , ir_ref = ref }) - = do { rr <- newMetaTyVarTyAtLevel tc_lvl runtimeRepTy - ; tau <- newMetaTyVarTyAtLevel tc_lvl (tYPE rr) - -- See Note [TcLevel of ExpType] - ; writeMutVar ref (Just tau) + = do { mb_inferred_ty <- readTcRef ref + ; tau <- case mb_inferred_ty of + Just ty -> do { ensureMonoType ty + -- See Note [inferResultToType] + ; return ty } + Nothing -> do { rr <- newMetaTyVarTyAtLevel tc_lvl runtimeRepTy + ; tau <- newMetaTyVarTyAtLevel tc_lvl (tYPE rr) + -- See Note [TcLevel of ExpType] + ; writeMutVar ref (Just tau) + ; return tau } ; traceTc "Forcing ExpType to be monomorphic:" (ppr u <+> text ":=" <+> ppr tau) ; return tau } +{- Note [inferResultToType] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +expTypeToType and inferResultType convert an InferResult to a monotype. +It must be a monotype because if the InferResult isn't already filled in, +we fill it in with a unification variable (hence monotype). So to preserve +order-independence we check for mono-type-ness even if it *is* filled in +already. + +See also Note [TcLevel of ExpType] above, and +Note [fillInferResult]. +-} + +-- | Infer a type using a fresh ExpType +-- See also Note [ExpType] in "GHC.Tc.Utils.TcMType" +tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) +tcInfer tc_check + = do { res_ty <- newInferExpType + ; result <- tc_check res_ty + ; res_ty <- readExpType res_ty + ; return (result, res_ty) } + +fillInferResult :: TcType -> InferResult -> TcM TcCoercionN +-- If co = fillInferResult t1 t2 +-- => co :: t1 ~ t2 +-- See Note [fillInferResult] +fillInferResult act_res_ty (IR { ir_uniq = u, ir_lvl = res_lvl + , ir_ref = ref }) + = do { mb_exp_res_ty <- readTcRef ref + ; case mb_exp_res_ty of + Just exp_res_ty + -> do { traceTc "Joining inferred ExpType" $ + ppr u <> colon <+> ppr act_res_ty <+> char '~' <+> ppr exp_res_ty + ; cur_lvl <- getTcLevel + ; unless (cur_lvl `sameDepthAs` res_lvl) $ + ensureMonoType act_res_ty + ; unifyType Nothing act_res_ty exp_res_ty } + Nothing + -> do { traceTc "Filling inferred ExpType" $ + ppr u <+> text ":=" <+> ppr act_res_ty + ; (prom_co, act_res_ty) <- promoteTcType res_lvl act_res_ty + ; writeTcRef ref (Just act_res_ty) + ; return prom_co } + } + + +{- Note [fillInferResult] +~~~~~~~~~~~~~~~~~~~~~~~~~ +When inferring, we use fillInferResult to "fill in" the hole in InferResult + data InferResult = IR { ir_uniq :: Unique + , ir_lvl :: TcLevel + , ir_ref :: IORef (Maybe TcType) } + +There are two things to worry about: + +1. What if it is under a GADT or existential pattern match? + - GADTs: a unification variable (and Infer's hole is similar) is untouchable + - Existentials: be careful about skolem-escape + +2. What if it is filled in more than once? E.g. multiple branches of a case + case e of + T1 -> e1 + T2 -> e2 + +Our typing rules are: + +* The RHS of a existential or GADT alternative must always be a + monotype, regardless of the number of alternatives. + +* Multiple non-existential/GADT branches can have (the same) + higher rank type (#18412). E.g. this is OK: + case e of + True -> hr + False -> hr + where hr:: (forall a. a->a) -> Int + c.f. Section 7.1 of "Practical type inference for arbitrary-rank types" + We use choice (2) in that Section. + (GHC 8.10 and earlier used choice (1).) + + But note that + case e of + True -> hr + False -> \x -> hr x + will fail, because we still /infer/ both branches, so the \x will get + a (monotype) unification variable, which will fail to unify with + (forall a. a->a) + +For (1) we can detect the GADT/existential situation by seeing that +the current TcLevel is greater than that stored in ir_lvl of the Infer +ExpType. We bump the level whenever we go past a GADT/existential match. + +Then, before filling the hole use promoteTcType to promote the type +to the outer ir_lvl. promoteTcType does this + - create a fresh unification variable alpha at level ir_lvl + - emits an equality alpha[ir_lvl] ~ ty + - fills the hole with alpha +That forces the type to be a monotype (since unification variables can +only unify with monotypes); and catches skolem-escapes because the +alpha is untouchable until the equality floats out. + +For (2), we simply look to see if the hole is filled already. + - if not, we promote (as above) and fill the hole + - if it is filled, we simply unify with the type that is + already there + +There is one wrinkle. Suppose we have + case e of + T1 -> e1 :: (forall a. a->a) -> Int + G2 -> e2 +where T1 is not GADT or existential, but G2 is a GADT. Then supppose the +T1 alternative fills the hole with (forall a. a->a) -> Int, which is fine. +But now the G2 alternative must not *just* unify with that else we'd risk +allowing through (e2 :: (forall a. a->a) -> Int). If we'd checked G2 first +we'd have filled the hole with a unification variable, which enforces a +monotype. + +So if we check G2 second, we still want to emit a constraint that restricts +the RHS to be a monotype. This is done by ensureMonoType, and it works +by simply generating a constraint (alpha ~ ty), where alpha is a fresh +unification variable. We discard the evidence. + +-} {- ********************************************************************* * * - SkolemTvs (immutable) + Promoting types * * ********************************************************************* -} -tc_inst_internal :: ([VarBndr TyVar flag] -> TcM (TCvSubst, [VarBndr TcTyVar flag])) - -- ^ How to instantiate the type variables - -> [VarBndr TyVar flag] -- ^ Type variable to instantiate - -> Type -- ^ rho - -> TcM ([(Name, VarBndr TcTyVar flag)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tc_inst_internal _inst_tyvars [] rho = - let -- There may be overloading despite no type variables; - -- (?x :: Int) => Int -> Int - (theta, tau) = tcSplitPhiTy rho - in - return ([], theta, tau) -tc_inst_internal inst_tyvars tyvars rho = - do { (subst, tyvars') <- inst_tyvars tyvars - ; let (theta, tau) = tcSplitPhiTy (substTyAddInScope subst rho) - tv_prs = map (tyVarName . binderVar) tyvars `zip` tyvars' - ; return (tv_prs, theta, tau) } - -tcInstType :: ([TyVar] -> TcM (TCvSubst, [TcTyVar])) - -- ^ How to instantiate the type variables - -> Id -- ^ Type to instantiate - -> TcM ([(Name, TcTyVar)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tcInstType inst_tyvars id = - do { let (tyvars, rho) = splitForAllTys (idType id) - tyvars' = mkTyVarBinders () tyvars - ; (tv_prs, preds, rho) <- tc_inst_internal inst_tyvar_bndrs tyvars' rho - ; let tv_prs' = map (\(name, bndr) -> (name, binderVar bndr)) tv_prs - ; return (tv_prs', preds, rho) } - where - inst_tyvar_bndrs :: [VarBndr TyVar ()] -> TcM (TCvSubst, [VarBndr TcTyVar ()]) - inst_tyvar_bndrs bndrs = do { (subst, tvs) <- inst_tyvars $ binderVars bndrs - ; let tvbnds = map (\tv -> Bndr tv ()) tvs - ; return (subst, tvbnds) } - -tcInstTypeBndrs :: ([VarBndr TyVar Specificity] -> TcM (TCvSubst, [VarBndr TcTyVar Specificity])) - -- ^ How to instantiate the type variables - -> Id -- ^ Type to instantiate - -> TcM ([(Name, VarBndr TcTyVar Specificity)], TcThetaType, TcType) -- ^ Result - -- (type vars, preds (incl equalities), rho) -tcInstTypeBndrs inst_tyvars id = - let (tyvars, rho) = splitForAllTysInvis (idType id) - in tc_inst_internal inst_tyvars tyvars rho - -tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType) --- Instantiate a type signature with skolem constants. --- We could give them fresh names, but no need to do so -tcSkolDFunType dfun - = do { (tv_prs, theta, tau) <- tcInstType tcInstSuperSkolTyVars dfun - ; return (map snd tv_prs, theta, tau) } - -tcSuperSkolTyVars :: [TyVar] -> (TCvSubst, [TcTyVar]) --- Make skolem constants, but do *not* give them new names, as above --- Moreover, make them "super skolems"; see comments with superSkolemTv --- see Note [Kind substitution when instantiating] --- Precondition: tyvars should be ordered by scoping -tcSuperSkolTyVars = mapAccumL tcSuperSkolTyVar emptyTCvSubst - -tcSuperSkolTyVar :: TCvSubst -> TyVar -> (TCvSubst, TcTyVar) -tcSuperSkolTyVar subst tv - = (extendTvSubstWithClone subst tv new_tv, new_tv) - where - kind = substTyUnchecked subst (tyVarKind tv) - new_tv = mkTcTyVar (tyVarName tv) kind superSkolemTv - --- | Given a list of @['TyVar']@, skolemize the type variables, --- returning a substitution mapping the original tyvars to the --- skolems, and the list of newly bound skolems. -tcInstSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSkolTyVars = tcInstSkolTyVarsX emptyTCvSubst - -tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSkolTyVarsX = tcInstSkolTyVarsPushLevel False - -tcInstSuperSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSuperSkolTyVars = tcInstSuperSkolTyVarsX emptyTCvSubst - -tcInstSuperSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) --- See Note [Skolemising type variables] -tcInstSuperSkolTyVarsX subst = tcInstSkolTyVarsPushLevel True subst - -tcInstSkolTyVarsPushLevel :: Bool -> TCvSubst -> [TyVar] - -> TcM (TCvSubst, [TcTyVar]) --- Skolemise one level deeper, hence pushTcLevel --- See Note [Skolemising type variables] -tcInstSkolTyVarsPushLevel overlappable subst tvs - = do { tc_lvl <- getTcLevel - ; let pushed_lvl = pushTcLevel tc_lvl - ; tcInstSkolTyVarsAt pushed_lvl overlappable subst tvs } - -tcInstSkolTyVarsAt :: TcLevel -> Bool - -> TCvSubst -> [TyVar] - -> TcM (TCvSubst, [TcTyVar]) -tcInstSkolTyVarsAt lvl overlappable subst tvs - = freshenTyCoVarsX new_skol_tv subst tvs +ensureMonoType :: TcType -> TcM () +-- Assuming that the argument type is of kind (TYPE r), +-- ensure that it is a /monotype/ +-- If it is not a monotype we can see right away (since unification +-- varibles and type-function applications stand for monotypes), but +-- we emit a Wanted equality just to delay the error message until later +ensureMonoType res_ty + | isTauTy res_ty -- isTauTy doesn't need zonking or anything + = return () + | otherwise + = do { mono_ty <- newOpenFlexiTyVarTy + ; let eq_orig = TypeEqOrigin { uo_actual = res_ty + , uo_expected = mono_ty + , uo_thing = Nothing + , uo_visible = False } + + ; _co <- emitWantedEq eq_orig TypeLevel Nominal res_ty mono_ty + ; return () } + +promoteTcType :: TcLevel -> TcType -> TcM (TcCoercionN, TcType) +-- See Note [Promoting a type] +-- See also Note [fillInferResult] +-- promoteTcType level ty = (co, ty') +-- * Returns ty' whose max level is just 'level' +-- and whose kind is ~# to the kind of 'ty' +-- and whose kind has form TYPE rr +-- * and co :: ty ~ ty' +-- * and emits constraints to justify the coercion +promoteTcType dest_lvl ty + = do { cur_lvl <- getTcLevel + ; if (cur_lvl `sameDepthAs` dest_lvl) + then return (mkTcNomReflCo ty, ty) + else promote_it } where - details = SkolemTv lvl overlappable - new_skol_tv name kind = mkTcTyVar name kind details - ------------------- -freshenTyVarBndrs :: [TyVar] -> TcM (TCvSubst, [TyVar]) --- ^ Give fresh uniques to a bunch of TyVars, but they stay --- as TyVars, rather than becoming TcTyVars --- Used in 'GHC.Tc.Instance.Family.newFamInst', and 'GHC.Tc.Utils.Instantiate.newClsInst' -freshenTyVarBndrs = freshenTyCoVars mkTyVar - -freshenCoVarBndrsX :: TCvSubst -> [CoVar] -> TcM (TCvSubst, [CoVar]) --- ^ Give fresh uniques to a bunch of CoVars --- Used in "GHC.Tc.Instance.Family.newFamInst" -freshenCoVarBndrsX subst = freshenTyCoVarsX mkCoVar subst - ------------------- -freshenTyCoVars :: (Name -> Kind -> TyCoVar) - -> [TyVar] -> TcM (TCvSubst, [TyCoVar]) -freshenTyCoVars mk_tcv = freshenTyCoVarsX mk_tcv emptyTCvSubst - -freshenTyCoVarsX :: (Name -> Kind -> TyCoVar) - -> TCvSubst -> [TyCoVar] - -> TcM (TCvSubst, [TyCoVar]) -freshenTyCoVarsX mk_tcv = mapAccumLM (freshenTyCoVarX mk_tcv) - -freshenTyCoVarX :: (Name -> Kind -> TyCoVar) - -> TCvSubst -> TyCoVar -> TcM (TCvSubst, TyCoVar) --- This a complete freshening operation: --- the skolems have a fresh unique, and a location from the monad --- See Note [Skolemising type variables] -freshenTyCoVarX mk_tcv subst tycovar - = do { loc <- getSrcSpanM - ; uniq <- newUnique - ; let old_name = tyVarName tycovar - new_name = mkInternalName uniq (getOccName old_name) loc - new_kind = substTyUnchecked subst (tyVarKind tycovar) - new_tcv = mk_tcv new_name new_kind - subst1 = extendTCvSubstWithClone subst tycovar new_tcv - ; return (subst1, new_tcv) } - -{- Note [Skolemising type variables] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The tcInstSkolTyVars family of functions instantiate a list of TyVars -to fresh skolem TcTyVars. Important notes: - -a) Level allocation. We generally skolemise /before/ calling - pushLevelAndCaptureConstraints. So we want their level to the level - of the soon-to-be-created implication, which has a level ONE HIGHER - than the current level. Hence the pushTcLevel. It feels like a - slight hack. - -b) The [TyVar] should be ordered (kind vars first) - See Note [Kind substitution when instantiating] - -c) It's a complete freshening operation: the skolems have a fresh - unique, and a location from the monad - -d) The resulting skolems are - non-overlappable for tcInstSkolTyVars, - but overlappable for tcInstSuperSkolTyVars - See GHC.Tc.Deriv.Infer Note [Overlap and deriving] for an example - of where this matters. - -Note [Kind substitution when instantiating] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When we instantiate a bunch of kind and type variables, first we -expect them to be topologically sorted. -Then we have to instantiate the kind variables, build a substitution -from old variables to the new variables, then instantiate the type -variables substituting the original kind. + promote_it :: TcM (TcCoercion, TcType) + promote_it -- Emit a constraint (alpha :: TYPE rr) ~ ty + -- where alpha and rr are fresh and from level dest_lvl + = do { rr <- newMetaTyVarTyAtLevel dest_lvl runtimeRepTy + ; prom_ty <- newMetaTyVarTyAtLevel dest_lvl (tYPE rr) + ; let eq_orig = TypeEqOrigin { uo_actual = ty + , uo_expected = prom_ty + , uo_thing = Nothing + , uo_visible = False } + + ; co <- emitWantedEq eq_orig TypeLevel Nominal ty prom_ty + ; return (co, prom_ty) } +{- + dont_promote_it :: TcM (TcCoercion, TcType) + dont_promote_it -- Check that ty :: TYPE rr, for some (fresh) rr + = do { res_kind <- newOpenTypeKind + ; ki_co <- unifyKind Nothing (tcTypeKind ty) res_kind + ; let co = mkTcGReflRightCo Nominal ty ki_co + ; return (co, ty `mkCastTy` ki_co) } +-} -Exemple: If we want to instantiate - [(k1 :: *), (k2 :: *), (a :: k1 -> k2), (b :: k1)] -we want - [(?k1 :: *), (?k2 :: *), (?a :: ?k1 -> ?k2), (?b :: ?k1)] -instead of the buggous - [(?k1 :: *), (?k2 :: *), (?a :: k1 -> k2), (?b :: k1)] +{- Note [Promoting a type] +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider (#12427) + + data T where + MkT :: (Int -> Int) -> a -> T + + h y = case y of MkT v w -> v + +We'll infer the RHS type with an expected type ExpType of + (IR { ir_lvl = l, ir_ref = ref, ... ) +where 'l' is the TcLevel of the RHS of 'h'. Then the MkT pattern +match will increase the level, so we'll end up in tcSubType, trying to +unify the type of v, + v :: Int -> Int +with the expected type. But this attempt takes place at level (l+1), +rightly so, since v's type could have mentioned existential variables, +(like w's does) and we want to catch that. + +So we + - create a new meta-var alpha[l+1] + - fill in the InferRes ref cell 'ref' with alpha + - emit an equality constraint, thus + [W] alpha[l+1] ~ (Int -> Int) + +That constraint will float outwards, as it should, unless v's +type mentions a skolem-captured variable. + +This approach fails if v has a higher rank type; see +Note [Promotion and higher rank types] + + +Note [Promotion and higher rank types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If v had a higher-rank type, say v :: (forall a. a->a) -> Int, +then we'd emit an equality + [W] alpha[l+1] ~ ((forall a. a->a) -> Int) +which will sadly fail because we can't unify a unification variable +with a polytype. But there is nothing really wrong with the program +here. + +We could just about solve this by "promote the type" of v, to expose +its polymorphic "shape" while still leaving constraints that will +prevent existential escape. But we must be careful! Exposing +the "shape" of the type is precisely what we must NOT do under +a GADT pattern match! So in this case we might promote the type +to + (forall a. a->a) -> alpha[l+1] +and emit the constraint + [W] alpha[l+1] ~ Int +Now the promoted type can fill the ref cell, while the emitted +equality can float or not, according to the usual rules. + +But that's not quite right! We are exposing the arrow! We could +deal with that too: + (forall a. mu[l+1] a a) -> alpha[l+1] +with constraints + [W] alpha[l+1] ~ Int + [W] mu[l+1] ~ (->) +Here we abstract over the '->' inside the forall, in case that +is subject to an equality constraint from a GADT match. + +Note that we kept the outer (->) because that's part of +the polymorphic "shape". And because of impredicativity, +GADT matches can't give equalities that affect polymorphic +shape. + +This reasoning just seems too complicated, so I decided not +to do it. These higher-rank notes are just here to record +the thinking. +-} -************************************************************************ +{- ********************************************************************* * * MetaTvs (meta type variables; mutable) * * -************************************************************************ --} +********************************************************************* -} -{- -Note [TyVarTv] -~~~~~~~~~~~~ +{- Note [TyVarTv] +~~~~~~~~~~~~~~~~~ A TyVarTv can unify with type *variables* only, including other TyVarTvs and skolems. Sometimes, they can unify with type variables that the user would @@ -1031,18 +1102,11 @@ newMetaTyVarsX subst = mapAccumLM newMetaTyVarX subst newMetaTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) -- Make a new unification variable tyvar whose Name and Kind come from -- an existing TyVar. We substitute kind variables in the kind. -newMetaTyVarX subst tyvar = new_meta_tv_x TauTv subst tyvar - -newMetaTyVarTyVars :: [VarBndr TyVar Specificity] - -> TcM (TCvSubst, [VarBndr TcTyVar Specificity]) -newMetaTyVarTyVars = mapAccumLM newMetaTyVarTyVarX emptyTCvSubst +newMetaTyVarX = new_meta_tv_x TauTv -newMetaTyVarTyVarX :: TCvSubst -> (VarBndr TyVar Specificity) - -> TcM (TCvSubst, VarBndr TcTyVar Specificity) +newMetaTyVarTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) -- Just like newMetaTyVarX, but make a TyVarTv -newMetaTyVarTyVarX subst (Bndr tv spec) = - do { (subst', tv') <- new_meta_tv_x TyVarTv subst tv - ; return (subst', (Bndr tv' spec)) } +newMetaTyVarTyVarX = new_meta_tv_x TyVarTv newWildCardX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) newWildCardX subst tv ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -57,7 +57,7 @@ module GHC.Tc.Utils.TcType ( -- These are important because they do not look through newtypes getTyVar, tcSplitForAllTy_maybe, - tcSplitForAllTys, tcSplitSomeForAllTys, + tcSplitForAllTys, tcSplitForAllTysReq, tcSplitForAllTysInvis, tcSplitPiTys, tcSplitPiTy_maybe, tcSplitForAllVarBndrs, tcSplitPhiTy, tcSplitPredFunTy_maybe, @@ -1221,14 +1221,6 @@ tcSplitForAllTys ty = ASSERT( all isTyVar (fst sty) ) sty where sty = splitForAllTys ty --- | Like 'tcSplitForAllTys', but only splits a 'ForAllTy' if @argf_pred argf@ --- is 'True', where @argf@ is the visibility of the @ForAllTy@'s binder and --- @argf_pred@ is a predicate over visibilities provided as an argument to this --- function. All split tyvars are annotated with their @argf at . -tcSplitSomeForAllTys :: (ArgFlag -> Bool) -> Type -> ([TyCoVarBinder], Type) -tcSplitSomeForAllTys argf_pred ty = ASSERT( all (isTyVar . binderVar) (fst sty) ) sty - where sty = splitSomeForAllTys argf_pred ty - -- | Like 'tcSplitForAllTys', but only splits 'ForAllTy's with 'Required' type -- variable binders. All split tyvars are annotated with '()'. tcSplitForAllTysReq :: Type -> ([TcReqTVBinder], Type) ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -61,7 +61,6 @@ import GHC.Types.Name( isSystemName ) import GHC.Tc.Utils.Instantiate import GHC.Core.TyCon import GHC.Builtin.Types -import GHC.Builtin.Types.Prim( tYPE ) import GHC.Types.Var as Var import GHC.Types.Var.Set import GHC.Types.Var.Env @@ -571,10 +570,51 @@ tcSubTypeNC :: CtOrigin -- Used when instantiating -> TcM HsWrapper tcSubTypeNC inst_orig ctxt m_thing ty_actual res_ty = case res_ty of - Infer inf_res -> instantiateAndFillInferResult inst_orig ty_actual inf_res Check ty_expected -> tc_sub_type (unifyType m_thing) inst_orig ctxt ty_actual ty_expected + Infer inf_res -> do { (wrap, rho) <- topInstantiate inst_orig ty_actual + -- See Note [Instantiation of InferResult] + ; co <- fillInferResult rho inf_res + ; return (mkWpCastN co <.> wrap) } + +{- Note [Instantiation of InferResult] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We now always instantiate before filling in InferResult, so that +the result is a TcRhoType: see #17173 for discussion. + +For example: + +1. Consider + f x = (*) + We want to instantiate the type of (*) before returning, else we + will infer the type + f :: forall {a}. a -> forall b. Num b => b -> b -> b + This is surely confusing for users. + + And worse, the monomorphism restriction won't work properly. The MR is + dealt with in simplifyInfer, and simplifyInfer has no way of + instantiating. This could perhaps be worked around, but it may be + hard to know even when instantiation should happen. + +2. Another reason. Consider + f :: (?x :: Int) => a -> a + g y = let ?x = 3::Int in f + Here want to instantiate f's type so that the ?x::Int constraint + gets discharged by the enclosing implicit-parameter binding. + +3. Suppose one defines plus = (+). If we instantiate lazily, we will + infer plus :: forall a. Num a => a -> a -> a. However, the monomorphism + restriction compels us to infer + plus :: Integer -> Integer -> Integer + (or similar monotype). Indeed, the only way to know whether to apply + the monomorphism restriction at all is to instantiate + +There is one place where we don't want to instantiate eagerly, +namely in GHC.Tc.Module.tcRnExpr, which implements GHCi's :type +command. See Note [Implementing :type] in GHC.Tc.Module. +-} + --------------- tcSubTypeSigma :: UserTypeCtxt -> TcSigmaType -> TcSigmaType -> TcM HsWrapper -- External entry point, but no ExpTypes on either side @@ -768,213 +808,6 @@ tcEqMult origin w_actual w_expected = do ; coercion <- uType TypeLevel origin w_actual w_expected ; return $ if isReflCo coercion then WpHole else WpMultCoercion coercion } -{- ********************************************************************** -%* * - ExpType functions: tcInfer, instantiateAndFillInferResult -%* * -%********************************************************************* -} - --- | Infer a type using a fresh ExpType --- See also Note [ExpType] in "GHC.Tc.Utils.TcMType" -tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) -tcInfer tc_check - = do { res_ty <- newInferExpType - ; result <- tc_check res_ty - ; res_ty <- readExpType res_ty - ; return (result, res_ty) } - -instantiateAndFillInferResult :: CtOrigin -> TcType -> InferResult -> TcM HsWrapper --- If wrap = instantiateAndFillInferResult t1 t2 --- => wrap :: t1 ~> t2 --- See Note [Instantiation of InferResult] -instantiateAndFillInferResult orig ty inf_res - = do { (wrap, rho) <- topInstantiate orig ty - ; co <- fillInferResult rho inf_res - ; return (mkWpCastN co <.> wrap) } - -fillInferResult :: TcType -> InferResult -> TcM TcCoercionN --- If wrap = fillInferResult t1 t2 --- => wrap :: t1 ~> t2 -fillInferResult orig_ty (IR { ir_uniq = u, ir_lvl = res_lvl - , ir_ref = ref }) - = do { (ty_co, ty_to_fill_with) <- promoteTcType res_lvl orig_ty - - ; traceTc "Filling ExpType" $ - ppr u <+> text ":=" <+> ppr ty_to_fill_with - - ; when debugIsOn (check_hole ty_to_fill_with) - - ; writeTcRef ref (Just ty_to_fill_with) - - ; return ty_co } - where - check_hole ty -- Debug check only - = do { let ty_lvl = tcTypeLevel ty - ; MASSERT2( not (ty_lvl `strictlyDeeperThan` res_lvl), - ppr u $$ ppr res_lvl $$ ppr ty_lvl $$ - ppr ty <+> dcolon <+> ppr (tcTypeKind ty) $$ ppr orig_ty ) - ; cts <- readTcRef ref - ; case cts of - Just already_there -> pprPanic "writeExpType" - (vcat [ ppr u - , ppr ty - , ppr already_there ]) - Nothing -> return () } - -{- Note [Instantiation of InferResult] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We now always instantiate before filling in InferResult, so that -the result is a TcRhoType: see #17173 for discussion. - -For example: - -1. Consider - f x = (*) - We want to instantiate the type of (*) before returning, else we - will infer the type - f :: forall {a}. a -> forall b. Num b => b -> b -> b - This is surely confusing for users. - - And worse, the monomorphism restriction won't work properly. The MR is - dealt with in simplifyInfer, and simplifyInfer has no way of - instantiating. This could perhaps be worked around, but it may be - hard to know even when instantiation should happen. - -2. Another reason. Consider - f :: (?x :: Int) => a -> a - g y = let ?x = 3::Int in f - Here want to instantiate f's type so that the ?x::Int constraint - gets discharged by the enclosing implicit-parameter binding. - -3. Suppose one defines plus = (+). If we instantiate lazily, we will - infer plus :: forall a. Num a => a -> a -> a. However, the monomorphism - restriction compels us to infer - plus :: Integer -> Integer -> Integer - (or similar monotype). Indeed, the only way to know whether to apply - the monomorphism restriction at all is to instantiate - -There is one place where we don't want to instantiate eagerly, -namely in GHC.Tc.Module.tcRnExpr, which implements GHCi's :type -command. See Note [Implementing :type] in GHC.Tc.Module. - --} - -{- ********************************************************************* -* * - Promoting types -* * -********************************************************************* -} - -promoteTcType :: TcLevel -> TcType -> TcM (TcCoercion, TcType) --- See Note [Promoting a type] --- promoteTcType level ty = (co, ty') --- * Returns ty' whose max level is just 'level' --- and whose kind is ~# to the kind of 'ty' --- and whose kind has form TYPE rr --- * and co :: ty ~ ty' --- * and emits constraints to justify the coercion -promoteTcType dest_lvl ty - = do { cur_lvl <- getTcLevel - ; if (cur_lvl `sameDepthAs` dest_lvl) - then dont_promote_it - else promote_it } - where - promote_it :: TcM (TcCoercion, TcType) - promote_it -- Emit a constraint (alpha :: TYPE rr) ~ ty - -- where alpha and rr are fresh and from level dest_lvl - = do { rr <- newMetaTyVarTyAtLevel dest_lvl runtimeRepTy - ; prom_ty <- newMetaTyVarTyAtLevel dest_lvl (tYPE rr) - ; let eq_orig = TypeEqOrigin { uo_actual = ty - , uo_expected = prom_ty - , uo_thing = Nothing - , uo_visible = False } - - ; co <- emitWantedEq eq_orig TypeLevel Nominal ty prom_ty - ; return (co, prom_ty) } - - dont_promote_it :: TcM (TcCoercion, TcType) - dont_promote_it -- Check that ty :: TYPE rr, for some (fresh) rr - = do { res_kind <- newOpenTypeKind - ; let ty_kind = tcTypeKind ty - kind_orig = TypeEqOrigin { uo_actual = ty_kind - , uo_expected = res_kind - , uo_thing = Nothing - , uo_visible = False } - ; ki_co <- uType KindLevel kind_orig (tcTypeKind ty) res_kind - ; let co = mkTcGReflRightCo Nominal ty ki_co - ; return (co, ty `mkCastTy` ki_co) } - -{- Note [Promoting a type] -~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider (#12427) - - data T where - MkT :: (Int -> Int) -> a -> T - - h y = case y of MkT v w -> v - -We'll infer the RHS type with an expected type ExpType of - (IR { ir_lvl = l, ir_ref = ref, ... ) -where 'l' is the TcLevel of the RHS of 'h'. Then the MkT pattern -match will increase the level, so we'll end up in tcSubType, trying to -unify the type of v, - v :: Int -> Int -with the expected type. But this attempt takes place at level (l+1), -rightly so, since v's type could have mentioned existential variables, -(like w's does) and we want to catch that. - -So we - - create a new meta-var alpha[l+1] - - fill in the InferRes ref cell 'ref' with alpha - - emit an equality constraint, thus - [W] alpha[l+1] ~ (Int -> Int) - -That constraint will float outwards, as it should, unless v's -type mentions a skolem-captured variable. - -This approach fails if v has a higher rank type; see -Note [Promotion and higher rank types] - - -Note [Promotion and higher rank types] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If v had a higher-rank type, say v :: (forall a. a->a) -> Int, -then we'd emit an equality - [W] alpha[l+1] ~ ((forall a. a->a) -> Int) -which will sadly fail because we can't unify a unification variable -with a polytype. But there is nothing really wrong with the program -here. - -We could just about solve this by "promote the type" of v, to expose -its polymorphic "shape" while still leaving constraints that will -prevent existential escape. But we must be careful! Exposing -the "shape" of the type is precisely what we must NOT do under -a GADT pattern match! So in this case we might promote the type -to - (forall a. a->a) -> alpha[l+1] -and emit the constraint - [W] alpha[l+1] ~ Int -Now the promoted type can fill the ref cell, while the emitted -equality can float or not, according to the usual rules. - -But that's not quite right! We are exposing the arrow! We could -deal with that too: - (forall a. mu[l+1] a a) -> alpha[l+1] -with constraints - [W] alpha[l+1] ~ Int - [W] mu[l+1] ~ (->) -Here we abstract over the '->' inside the forall, in case that -is subject to an equality constraint from a GADT match. - -Note that we kept the outer (->) because that's part of -the polymorphic "shape". And because of impredicativity, -GADT matches can't give equalities that affect polymorphic -shape. - -This reasoning just seems too complicated, so I decided not -to do it. These higher-rank notes are just here to record -the thinking. --} {- ********************************************************************* * * ===================================== testsuite/tests/simplCore/should_compile/T17901.stdout ===================================== @@ -1,14 +1,14 @@ - (wombat1 [Occ=Once*!] :: T -> p) + (wombat1 [Occ=Once*!] :: T -> t) A -> wombat1 T17901.A; B -> wombat1 T17901.B; C -> wombat1 T17901.C - = \ (@p) (wombat1 :: T -> p) (x :: T) -> + = \ (@t) (wombat1 :: T -> t) (x :: T) -> case x of wild { __DEFAULT -> wombat1 wild } - Tmpl= \ (@p) (wombat2 [Occ=Once!] :: S -> p) (x [Occ=Once] :: S) -> + Tmpl= \ (@t) (wombat2 [Occ=Once!] :: S -> t) (x [Occ=Once] :: S) -> case x of wild [Occ=Once] { __DEFAULT -> wombat2 wild }}] - = \ (@p) (wombat2 :: S -> p) (x :: S) -> + = \ (@t) (wombat2 :: S -> t) (x :: S) -> case x of wild { __DEFAULT -> wombat2 wild } - Tmpl= \ (@p) (wombat3 [Occ=Once!] :: W -> p) (x [Occ=Once] :: W) -> + Tmpl= \ (@t) (wombat3 [Occ=Once!] :: W -> t) (x [Occ=Once] :: W) -> case x of wild [Occ=Once] { __DEFAULT -> wombat3 wild }}] - = \ (@p) (wombat3 :: W -> p) (x :: W) -> + = \ (@t) (wombat3 :: W -> t) (x :: W) -> case x of wild { __DEFAULT -> wombat3 wild } ===================================== testsuite/tests/typecheck/should_compile/T18412.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RankNTypes #-} + +module T18412 where + +hr :: (forall a. a -> a) -> () +hr _ = () + +foo x = case x of () -> hr + +-- This did not use to be allowed, because the +-- multiple branches have (the same) polytypes +-- Enhancement July 2020 +bar x = case x of True -> hr + False -> hr ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -716,3 +716,4 @@ test('T17775-viewpats-a', normal, compile, ['']) test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) test('T17775-viewpats-d', normal, compile_fail, ['']) +test('T18412', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T10619.stderr ===================================== @@ -1,13 +1,11 @@ -T10619.hs:9:15: error: - • Couldn't match type ‘p’ with ‘forall b. b -> b’ - Expected: p -> p - Actual: (forall a. a -> a) -> forall b. b -> b - ‘p’ is a rigid type variable bound by - the inferred type of foo :: p1 -> p -> p - at T10619.hs:(8,1)-(10,20) - • In the expression: - (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b +T10619.hs:10:14: error: + • Couldn't match type ‘p1’ with ‘forall a. a -> a’ + Expected: (forall a. a -> a) -> forall b. b -> b + Actual: p1 -> p1 + Cannot instantiate unification variable ‘p1’ + with a type involving polytypes: forall a. a -> a + • In the expression: \ y -> y In the expression: if True then ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) @@ -19,15 +17,13 @@ T10619.hs:9:15: error: ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) else \ y -> y - • Relevant bindings include - foo :: p1 -> p -> p (bound at T10619.hs:8:1) T10619.hs:14:15: error: • Couldn't match type ‘p’ with ‘forall a. a -> a’ Expected: p -> p Actual: (forall a. a -> a) -> forall b. b -> b ‘p’ is a rigid type variable bound by - the inferred type of bar :: p1 -> p -> p + the inferred type of bar :: p2 -> p -> p at T10619.hs:(12,1)-(14,66) • In the expression: (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b @@ -43,21 +39,16 @@ T10619.hs:14:15: error: else ((\ x -> x) :: (forall a. a -> a) -> forall b. b -> b) • Relevant bindings include - bar :: p1 -> p -> p (bound at T10619.hs:12:1) + bar :: p2 -> p -> p (bound at T10619.hs:12:1) -T10619.hs:16:13: error: - • Couldn't match type ‘p’ with ‘forall b. b -> b’ - Expected: p -> p - Actual: (forall a. a -> a) -> forall b. b -> b - ‘p’ is a rigid type variable bound by - the inferred type of baz :: Bool -> p -> p - at T10619.hs:(16,1)-(17,19) - • In the expression: - (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b - In an equation for ‘baz’: - baz True = (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b - • Relevant bindings include - baz :: Bool -> p -> p (bound at T10619.hs:16:1) +T10619.hs:17:13: error: + • Couldn't match type ‘p0’ with ‘forall a. a -> a’ + Expected: (forall a. a -> a) -> forall b. b -> b + Actual: p0 -> p0 + Cannot instantiate unification variable ‘p0’ + with a type involving polytypes: forall a. a -> a + • In the expression: \ y -> y + In an equation for ‘baz’: baz False = \ y -> y T10619.hs:20:14: error: • Couldn't match type ‘p’ with ‘forall a. a -> a’ ===================================== testsuite/tests/typecheck/should_fail/VtaFail.stderr ===================================== @@ -7,7 +7,7 @@ VtaFail.hs:7:16: error: answer_nosig = pairup_nosig @Int @Bool 5 True VtaFail.hs:14:17: error: - • Cannot apply expression of type ‘p0 -> p0’ + • Cannot apply expression of type ‘p1 -> p1’ to a visible type argument ‘Int’ • In the expression: (\ x -> x) @Int 12 In an equation for ‘answer_lambda’: ===================================== testsuite/tests/typecheck/should_fail/tcfail002.stderr ===================================== @@ -1,8 +1,8 @@ tcfail002.hs:4:7: error: - • Couldn't match expected type ‘p’ with actual type ‘[p]’ + • Couldn't match expected type ‘a’ with actual type ‘[a]’ • In the expression: z In an equation for ‘c’: c z = z • Relevant bindings include - z :: [p] (bound at tcfail002.hs:4:3) - c :: [p] -> p (bound at tcfail002.hs:3:1) + z :: [a] (bound at tcfail002.hs:4:3) + c :: [a] -> a (bound at tcfail002.hs:3:1) ===================================== testsuite/tests/typecheck/should_fail/tcfail104.stderr ===================================== @@ -1,19 +1,22 @@ -tcfail104.hs:14:12: error: +tcfail104.hs:16:12: error: + • Couldn't match type: Char -> Char + with: forall a. a -> a + Expected: (forall a. a -> a) -> Char -> Char + Actual: (Char -> Char) -> Char -> Char + • In the expression: \ x -> x + In the expression: + if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x) + In the expression: + (if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x)) id 'c' + +tcfail104.hs:22:12: error: • Couldn't match type: forall a. a -> a with: Char -> Char Expected: (Char -> Char) -> Char -> Char Actual: (forall a. a -> a) -> Char -> Char • In the expression: \ (x :: forall a. a -> a) -> x In the expression: - if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x) + if v then (\ x -> x) else (\ (x :: forall a. a -> a) -> x) In the expression: - (if v then (\ (x :: forall a. a -> a) -> x) else (\ x -> x)) id 'c' - -tcfail104.hs:22:15: error: - • Couldn't match expected type: Char -> Char - with actual type: forall a. a -> a - • When checking that the pattern signature: forall a. a -> a - fits the type of its context: Char -> Char - In the pattern: x :: forall a. a -> a - In the expression: \ (x :: forall a. a -> a) -> x + (if v then (\ x -> x) else (\ (x :: forall a. a -> a) -> x)) id 'c' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a60e30e08a0c59687e39f0eee9be1e539ee6f0d1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a60e30e08a0c59687e39f0eee9be1e539ee6f0d1 You're receiving 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 Jul 14 14:29:04 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 14 Jul 2020 10:29:04 -0400 Subject: [Git][ghc/ghc][wip/winio] 118 commits: Bump Cabal submodule Message-ID: <5f0dc130180b2_80b3f848700d4d03031935@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/winio at Glasgow Haskell Compiler / GHC Commits: 7414bb9f by GHC GitLab CI at 2020-07-14T14:16:51+00:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - 4b63e5ae by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 9c6b4ea4 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 88e15f1c by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - a5beb87b by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Small linker comment and ifdef cleanups - - - - - 88d0181e by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Flush event logs eagerly. - - - - - 104c4dd7 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 4116bd45 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Implement new Console API - - - - - 2ed238ba by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Add IOPort synchronization primitive - - - - - e15ddec5 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Add new io-manager cmdline options - - - - - 8d80cb96 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Init Windows console Codepage to UTF-8. - - - - - f0c1027b by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - 757ced44 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 9f00cf41 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Switch Testsuite to test winio by default - - - - - edac4e53 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Multiple refactorings and support changes. - - - - - 37f42e37 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: core threaded I/O manager - - - - - ec55d928 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: core non-threaded I/O manager - - - - - 7ed5b3bd by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - aee27b18 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Relaxing some constraints in io-manager. - - - - - 282207ee by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - be768949 by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: Remove some barf statements that are a bit strict. - - - - - 9c1fbf81 by Andreas Klebinger at 2020-07-14T14:17:44+00:00 winio: Expand comments describing non-threaded loop - - - - - a7d6477a by Tamar Christina at 2020-07-14T14:17:44+00:00 winio: fix FileSize unstat-able handles - - - - - 85159715 by Tamar Christina at 2020-07-14T14:17:45+00:00 winio: Implement new tempfile routines for winio - - - - - ac14ed16 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - 7c1ce17f by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Fix output truncation for writes larger than buffer size - - - - - 0359fccb by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 4bd58460 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - d19c5d06 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - 48a557a8 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - ac11323c by Andreas Klebinger at 2020-07-14T14:17:45+00:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 98e35ec5 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 71fdbf8c by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Remove debug event log trace - - - - - 42f2b188 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Fix sqrt and openFile009 test cases - - - - - 96d478d6 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Allow hp2ps to build with -DDEBUG - - - - - 7a5961ad by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Update output of T9681 since we now actually run it. - - - - - 4e535138 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: A few more improvements to the IOPort primitives. - - - - - 5f9d13f1 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 6e9fa407 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Assign thread labels to IOManager threads. - - - - - a4fa84f5 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Properly check for the tso of an incall to be zero. - - - - - c62059e1 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Mark FD instances as unsupported under WINIO. - - - - - 8522127e by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - b1e43de4 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Add comments/cleanup an import in base - - - - - 601df27a by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - 0385034f by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Make last_event a local variable - - - - - 5a6aaf7c by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Add comment about thread safety of processCompletion. - - - - - a461995e by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - 1f11b48a by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - 72f5aa6a by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - ac87ed52 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 907b4667 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - 9717c5e9 by Andreas Klebinger at 2020-07-14T14:17:45+00:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - 3cf285b7 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Update placeholder comment with actual function name. - - - - - a5fa1e36 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Always lock win32 event queue - - - - - 7b630395 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Display thread labels when tracing scheduler events. - - - - - 9983e9e7 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 87ec98a5 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 1691c26e by Tamar Christina at 2020-07-14T14:17:46+00:00 winio: Various fixes related to rebase and testdriver - - - - - a18f715c by Tamar Christina at 2020-07-14T14:17:46+00:00 winio: Fix rebase artifacts - - - - - b48ee522 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - 31a83586 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Remove unused size/iterate operations from IntTable - - - - - bbcde8c3 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - be753e3e by Tamar Christina at 2020-07-14T14:17:46+00:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 939d7203 by Ben Gamari at 2020-07-14T14:17:46+00:00 winio: Minor comments/renamings - - - - - f6dd6e60 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Checking if an error code indicates completion is now a function. - - - - - a4ab2634 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Small refactor in withOverlappedEx - - - - - 784a6576 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: A few comments and commented out dbxIO - - - - - 974ec46b by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - 429b041b by Tamar Christina at 2020-07-14T14:17:46+00:00 winio: revert BHandle changes. - - - - - b5714218 by Ben Gamari at 2020-07-14T14:17:46+00:00 winio: Fix imports - - - - - a2620b47 by Tamar Christina at 2020-07-14T14:17:46+00:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - 423a469e by Ben Gamari at 2020-07-14T14:17:46+00:00 winio: Only compile sources on Windows - - - - - df2da8a3 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - cbb75c74 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - 88209a68 by Andreas Klebinger at 2020-07-14T14:17:46+00:00 winio: Deduplicate openFile logic - - - - - 0d842fed by Tamar Christina at 2020-07-14T14:17:46+00:00 winio: fix -werror issue in encoding file - - - - - 01ab8d05 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Don't mention windows specific functions when building on Linux. - - - - - d8e15ee7 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: add a note about file locking in the RTS. - - - - - 61c785b5 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Add version to @since annotation - - - - - b481f7d0 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 01495032 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - 8099d43a by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 2cf0711b by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - f8645b51 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Make it explicit that we only create one IO manager - - - - - b29e1b98 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Note why we don't use blocking waits. - - - - - 9d93ffec by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Remove commented out pragma - - - - - 0ea48212 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - 0594ce08 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Rename SmartHandles to StdHandles - - - - - 19cd1ef7 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - aa95057b by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Update IOPort haddocks. - - - - - f6c52683 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Add a note cross reference - - - - - 918f0dcf by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - 56446ea4 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Expand BlockedOnIOCompletion description. - - - - - e5bf2284 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Remove historical todos - - - - - e1b3cb4f by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Update note, remove debugging pragma. - - - - - bb6f9515 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - c738b105 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Remove obsolete comment about cond. variables - - - - - c51e15fe by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: fix initial linux validate build - - - - - 37d86f01 by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Fix ThreadDelay001 CPP - - - - - 38de3c4a by Andreas Klebinger at 2020-07-14T14:17:47+00:00 winio: Fix openFile009 merge conflict leftover - - - - - 890fe21c by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - 0b8b2407 by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - fc765ba5 by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 89e01afc by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 74dd99d9 by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 3cb4ea6e by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: Also accept T7037 stderr - - - - - cb04f2a8 by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: fix cabal04 by filtering rts args - - - - - b1233d19 by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: fix cabal01 by accepting expected stderr - - - - - c35d2640 by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: fix safePkg01 by accepting expected stderr - - - - - f7c41db5 by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - 20e6175b by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: fix tempfiles test on linux - - - - - 7f264f8d by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: Accept accepted stderr for T3807 - - - - - 0a7093e4 by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: Accept accepted stderr for linker_unload - - - - - ea6fd1d7 by Andreas Klebinger at 2020-07-14T14:17:48+00:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 63b9ef60 by Tamar Christina at 2020-07-14T14:17:48+00:00 winio: clarify wording on conditional variables. - - - - - 8c70997d by Tamar Christina at 2020-07-14T14:17:48+00:00 winio: clarify comment on cooked mode. - - - - - 28968bda by Tamar Christina at 2020-07-14T14:17:48+00:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 180f07a9 by Ben Gamari at 2020-07-14T14:17:48+00:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - 30 changed files: - Makefile - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Info.hs - configure.ac - hadrian/src/Settings/Packages.hs - includes/rts/Constants.h - includes/rts/FileLock.h - includes/rts/Flags.h - includes/rts/IOManager.h - includes/rts/OSThreads.h - includes/rts/storage/TSO.h - includes/stg/MiscClosures.h - libraries/Cabal - + libraries/base/Control/Concurrent.hs-boot - libraries/base/GHC/Conc/IO.hs - + libraries/base/GHC/Conc/POSIX.hs - + libraries/base/GHC/Conc/POSIX/Const.hsc - libraries/base/GHC/Conc/Sync.hs - + libraries/base/GHC/Conc/Sync.hs-boot - + libraries/base/GHC/Conc/WinIO.hs - libraries/base/GHC/Conc/Windows.hs - libraries/base/GHC/ConsoleHandler.hs → libraries/base/GHC/ConsoleHandler.hsc - libraries/base/GHC/Event/Array.hs - libraries/base/GHC/Event/IntTable.hs - libraries/base/GHC/Event/Internal.hs - + libraries/base/GHC/Event/Internal/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9514380ca0f445be9ff21fb0d1b7bedb8a22ca11...180f07a91a3b91225c178a7a9faf432fc1c9c976 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9514380ca0f445be9ff21fb0d1b7bedb8a22ca11...180f07a91a3b91225c178a7a9faf432fc1c9c976 You're receiving 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 Jul 14 14:56:44 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 14 Jul 2020 10:56:44 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] 2 commits: disable flakey divbyzero test Message-ID: <5f0dc7ac28e11_80b3f8486b77e4830434cd@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 8cc21fdf by Moritz Angermann at 2020-07-14T14:00:38+00:00 disable flakey divbyzero test - - - - - 52fa3a95 by Moritz Angermann at 2020-07-14T14:56:28+00:00 add python :( - - - - - 2 changed files: - testsuite/driver/id - testsuite/tests/rts/all.T Changes: ===================================== testsuite/driver/id ===================================== @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#! /usr/bin/env python3 # # This is the identity test-wrapper. For native tests we do not need to run # executables through a wrapper, as we would need for cross compiled binaries. @@ -6,4 +6,10 @@ # # Therefore this backup identity test-wrapper is the default for native builds. # -"$*" \ No newline at end of file +import sys +import subprocess + +if __name__ == "__main__": + if len(sys.argv) < 2: + exit(1) + exit(subprocess.run(sys.argv[1:]).returncode) \ No newline at end of file ===================================== testsuite/tests/rts/all.T ===================================== @@ -50,6 +50,9 @@ test('divbyzero', # behavior on division-by-zero (#10332). omit_ways(llvm_ways), when(not(have_ncg()), skip), + # This test is so flaky, and with test-wrappers, and cross compilers there + # is almost no way to make this test pass consistently. + when(cross(), skip), # Apparently the output can be different on different # Linux setups, so just ignore it. As long as we get # the right exit code we're OK. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c4b836312a39b6416b5c8057149f2b170d24be91...52fa3a951161a72babc72d282ef8f1b18066ec33 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c4b836312a39b6416b5c8057149f2b170d24be91...52fa3a951161a72babc72d282ef8f1b18066ec33 You're receiving 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 Jul 14 14:57:32 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 14 Jul 2020 10:57:32 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18449 Message-ID: <5f0dc7dc62075_80b11047b883043730@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T18449 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18449 You're receiving 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 Jul 14 15:28:34 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 14 Jul 2020 11:28:34 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T17744 Message-ID: <5f0dcf224262_80b3f849c221f4030629c7@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T17744 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T17744 You're receiving 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 Jul 14 15:43:34 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 14 Jul 2020 11:43:34 -0400 Subject: [Git][ghc/ghc][wip/T18412] Improve typechecking of NPlusK patterns Message-ID: <5f0dd2a6be8bd_80b8e25ed430660f0@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18412 at Glasgow Haskell Compiler / GHC Commits: e37cbc69 by Simon Peyton Jones at 2020-07-14T16:41:03+01:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 6 changed files: - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Unify.hs Changes: ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -1141,6 +1141,7 @@ dsHsWrapper (WpCast co) = ASSERT(coercionRole co == Representational) return $ \e -> mkCastDs e co dsHsWrapper (WpEvApp tm) = do { core_tm <- dsEvTerm tm ; return (\e -> App e core_tm) } + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. dsHsWrapper (WpMultCoercion co) = do { when (not (isReflexiveCo co)) $ errDs (text "Multiplicity coercions are currently not supported") ; return $ \e -> e } ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -365,7 +365,7 @@ tcExpr expr@(OpApp fix arg1 op arg2) res_ty matchActualFunTysRho doc orig1 (Just (unLoc arg1)) 1 arg1_ty ; mult_wrap <- tcSubMult AppOrigin Many (scaledMult arg2_sigma) - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. -- -- When ($) becomes multiplicity-polymorphic, then the above check will -- need to go. But in the meantime, it would produce ill-typed ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -343,7 +343,7 @@ tc_lpats tys penv pats (zipEqual "tc_lpats" pats tys) -------------------- --- See Note [tcSubMult's wrapper] in TcUnify. +-- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. checkManyPattern :: Scaled a -> TcM HsWrapper checkManyPattern pat_ty = tcSubMult NonLinearPatternOrigin Many (scaledMult pat_ty) @@ -358,7 +358,7 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of { (wrap, id) <- tcPatBndr penv name pat_ty ; (res, mult_wrap) <- tcCheckUsage name (scaledMult pat_ty) $ tcExtendIdEnv1 name id thing_inside - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; pat_ty <- readExpType (scaledThing pat_ty) ; return (mkHsWrapPat (wrap <.> mult_wrap) (VarPat x (L l id)) pat_ty, res) } @@ -372,7 +372,7 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of LazyPat x pat -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; (pat', (res, pat_ct)) <- tc_lpat pat_ty (makeLazy penv) pat $ captureConstraints thing_inside @@ -390,14 +390,14 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of WildPat _ -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; res <- thing_inside ; pat_ty <- expTypeToType (scaledThing pat_ty) ; return (mkHsWrapPat mult_wrap (WildPat pat_ty) pat_ty, res) } AsPat x (L nm_loc name) pat -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; (wrap, bndr_id) <- setSrcSpan nm_loc (tcPatBndr penv name pat_ty) ; (pat', res) <- tcExtendIdEnv1 name bndr_id $ tc_lpat (pat_ty `scaledSet`(mkCheckExpType $ idType bndr_id)) @@ -414,7 +414,7 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of ViewPat _ expr pat -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. -- -- It should be possible to have view patterns at linear (or otherwise -- non-Many) multiplicity. But it is not clear at the moment what @@ -586,7 +586,7 @@ Fortunately that's what matchExpectedFunTySigma returns anyway. -- When there is no negation, neg_lit_ty and lit_ty are the same NPat _ (L l over_lit) mb_neg eq -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. -- -- It may be possible to refine linear pattern so that they work in -- linear environments. But it is not clear how useful this is. @@ -630,10 +630,6 @@ There are two bits of rebindable syntax: lit1_ty and lit2_ty could conceivably be different. var_ty is the type inferred for x, the variable in the pattern. -If the pushed-down pattern type isn't a tau-type, the two pat_ty's -above could conceivably be different specializations. So we use -expTypeToType on pat_ty before proceeding. - Note that we need to type-check the literal twice, because it is used twice, and may be used at different types. The second HsOverLit stored in the AST is used for the subtraction operation. @@ -643,16 +639,16 @@ AST is used for the subtraction operation. NPlusKPat _ (L nm_loc name) (L loc lit) _ ge minus -> do { mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. - ; pat_ty <- expTypeToType (scaledThing pat_ty) - ; let orig = LiteralOrigin lit + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. + ; let pat_exp_ty = scaledThing pat_ty + orig = LiteralOrigin lit ; (lit1', ge') - <- tcSyntaxOp orig ge [synKnownType pat_ty, SynRho] + <- tcSyntaxOp orig ge [SynType pat_exp_ty, SynRho] (mkCheckExpType boolTy) $ \ [lit1_ty] _ -> newOverloadedLit lit (mkCheckExpType lit1_ty) ; ((lit2', minus_wrap, bndr_id), minus') - <- tcSyntaxOpGen orig minus [synKnownType pat_ty, SynRho] SynAny $ + <- tcSyntaxOpGen orig minus [SynType pat_exp_ty, SynRho] SynAny $ \ [lit2_ty, var_ty] _ -> do { lit2' <- newOverloadedLit lit (mkCheckExpType lit2_ty) ; (wrap, bndr_id) <- setSrcSpan nm_loc $ @@ -662,6 +658,7 @@ AST is used for the subtraction operation. -- minus_wrap is applicable to minus' ; return (lit2', wrap, bndr_id) } + ; pat_ty <- readExpType pat_exp_ty -- The Report says that n+k patterns must be in Integral -- but it's silly to insist on this in the RebindableSyntax case ; unlessM (xoptM LangExt.RebindableSyntax) $ @@ -984,7 +981,7 @@ tcPatSynPat penv (L con_span _) pat_syn pat_ty arg_pats thing_inside req_theta' = substTheta tenv req_theta ; mult_wrap <- checkManyPattern pat_ty - -- See Note [tcSubMult's wrapper] in TcUnify. + -- See Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify. ; wrap <- tc_sub_type penv (scaledThing pat_ty) ty' ; traceTc "tcPatSynPat" (ppr pat_syn $$ ===================================== compiler/GHC/Tc/Types/Evidence.hs ===================================== @@ -229,18 +229,10 @@ data HsWrapper | WpLet TcEvBinds -- Non-empty (or possibly non-empty) evidence bindings, -- so that the identity coercion is always exactly WpHole - | WpMultCoercion Coercion - -- Note [Checking multiplicity coercions] - -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- This wrapper can be returned from tcSubMult. - -- It is used in case a variable is used with multiplicity m1, - -- we need it with multiplicity m2 and we have a coercion c :: m1 ~ m2. - -- Compiling such code would require multiplicity coercions in Core, - -- which we don't have. If the desugarer sees WpMultCoercion - -- with a non-reflexive coercion, it gives an error. - -- This is a temporary measure, as we don't really know yet exactly - -- what multiplicity coercions should be. But it serves as a good - -- approximation for the first iteration for the first iteration of linear types. + + | WpMultCoercion Coercion -- Require that a Coercion be reflexive; otherwise, + -- error in the desugarer. See GHC.Tc.Utils.Unify + -- Note [Wrapper returned from tcSubMult] -- Cannot derive Data instance because SDoc is not Data (it stores a function). -- So we do it manually: ===================================== compiler/GHC/Tc/Utils/Env.hs ===================================== @@ -628,7 +628,8 @@ tcExtendLocalTypeEnv lcl_env@(TcLclEnv { tcl_env = lcl_type_env }) tc_ty_things -- | @tcCheckUsage name mult thing_inside@ runs @thing_inside@, checks that the -- usage of @name@ is a submultiplicity of @mult@, and removes @name@ from the --- usage environment. See also Note [tcSubMult's wrapper] in TcUnify. +-- usage environment. See also Note [Wrapper returned from tcSubMult] in +-- GHC.Tc.Utils.Unify, which applies to the wrapper returned from this function. tcCheckUsage :: Name -> Mult -> TcM a -> TcM (a, HsWrapper) tcCheckUsage name id_mult thing_inside = do { (local_usage, result) <- tcCollectingUsage thing_inside ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -762,29 +762,29 @@ to a UserTypeCtxt of GenSigCtxt. Why? ambiguity check, but we don't need one for each level within it, and GHC.Tc.Utils.Unify.alwaysBuildImplication checks the UserTypeCtxt. See Note [When to build an implication] --} +Note [Wrapper returned from tcSubMult] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +There is no notion of multiplicity coercion in Core, therefore the wrapper +returned by tcSubMult (and derived functions such as tcCheckUsage and +checkManyPattern) is quite unlike any other wrapper: it checks whether the +coercion produced by the constraint solver is trivial, producing a type error +is it is not. This is implemented via the WpMultCoercion wrapper, as desugared +by GHC.HsToCore.Binds.dsHsWrapper, which does the reflexivity check. + +This wrapper needs to be placed in the term; otherwise, checking of the +eventual coercion won't be triggered during desugaring. But it can be put +anywhere, since it doesn't affect the desugared code. + +Why do we check this in the desugarer? It's a convenient place, since it's +right after all the constraints are solved. We need the constraints to be +solved to check whether they are trivial or not. Plus there is precedent for +type errors during desuraging (such as the levity polymorphism +restriction). An alternative would be to have a kind of constraint which can +only produce trivial evidence, then this check would happen in the constraint +solver. +-} --- Note [tcSubMult's wrapper] --- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --- There is no notion of multiplicity coercion in Core, therefore the wrapper --- returned by tcSubMult (and derived function such as tcCheckUsage and --- checkManyPattern) is quite unlike any other wrapper: it checks whether the --- coercion produced by the constraint solver is trivial and disappears (it --- produces a type error is the constraint is not trivial). See [Checking --- multiplicity coercions] in TcEvidence. --- --- This wrapper need to be placed in the term, otherwise checking of the --- eventual coercion won't be triggered during desuraging. But it can be put --- anywhere, since it doesn't affect the desugared code. --- --- Why do we check this in the desugarer? It's a convenient place, since it's --- right after all the constraints are solved. We need the constraints to be --- solved to check whether they are trivial or not. Plus there are precedent for --- type errors during desuraging (such as the levity polymorphism --- restriction). An alternative would be to have a kind of constraints which can --- only produce trivial evidence, then this check would happen in the constraint --- solver. tcSubMult :: CtOrigin -> Mult -> Mult -> TcM HsWrapper tcSubMult origin w_actual w_expected | Just (w1, w2) <- isMultMul w_actual = View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e37cbc69a81f7fc07cb87cd8b3adeab377c3c52b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e37cbc69a81f7fc07cb87cd8b3adeab377c3c52b You're receiving 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 Jul 14 15:47:38 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 14 Jul 2020 11:47:38 -0400 Subject: [Git][ghc/ghc][wip/T18412] 6 commits: Use dumpStyle when printing inlinings Message-ID: <5f0dd39ab1332_80b3f8486b77e48306673b@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18412 at Glasgow Haskell Compiler / GHC Commits: 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 52f28cd6 by Simon Peyton Jones at 2020-07-14T16:47:35+01:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - 20037a90 by Simon Peyton Jones at 2020-07-14T16:47:35+01:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 30 changed files: - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/deSugar/should_compile/T16615.stderr - testsuite/tests/dependent/should_compile/dynamic-paper.stderr - testsuite/tests/numeric/should_compile/T14170.stdout - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/perf/compiler/T18282.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T13143.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e37cbc69a81f7fc07cb87cd8b3adeab377c3c52b...20037a90d0a8a24a5dc31603cd2374f769e4f109 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e37cbc69a81f7fc07cb87cd8b3adeab377c3c52b...20037a90d0a8a24a5dc31603cd2374f769e4f109 You're receiving 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 Jul 14 19:30:46 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 14 Jul 2020 15:30:46 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 13 commits: Use dumpStyle when printing inlinings Message-ID: <5f0e07e673b65_80b3f849ca082f431028cc@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 78e6abb1 by Alp Mestanogullari at 2020-07-14T15:30:32-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - fe3f68a1 by Andreas Klebinger at 2020-07-14T15:30:33-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - df7d3f07 by Ben Gamari at 2020-07-14T15:30:33-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 9862dd43 by Andreas Klebinger at 2020-07-14T15:30:34-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - eaaea960 by Sergei Trofimovich at 2020-07-14T15:30:36-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 2387c02c by Sergei Trofimovich at 2020-07-14T15:30:36-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - d5059b87 by Stefan Schulze Frielinghaus at 2020-07-14T15:30:42-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 463653c5 by Matthias Andreas Benkard at 2020-07-14T15:30:43-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - 44fb6184 by Matthias Andreas Benkard at 2020-07-14T15:30:43-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.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/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Utils/Binary.hs - compiler/ghc.cabal.in - docs/users_guide/exts/template_haskell.rst - docs/users_guide/using-optimisation.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a2489006dac3b2181fb5e046cad6741575f38c2e...44fb61843006ef01fb06d3380d87d257bf5181d4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a2489006dac3b2181fb5e046cad6741575f38c2e...44fb61843006ef01fb06d3380d87d257bf5181d4 You're receiving 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 Jul 15 01:30:57 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 14 Jul 2020 21:30:57 -0400 Subject: [Git][ghc/ghc][master] compiler: re-engineer the treatment of rebindable if Message-ID: <5f0e5c51a318b_80b3f8486b77e483127483@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 30 changed files: - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.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/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Utils/Binary.hs - compiler/ghc.cabal.in - docs/users_guide/exts/template_haskell.rst - ghc/GHCi/UI.hs - ghc/GHCi/UI/Info.hs - testsuite/tests/ghc-api/show-srcspan/showsrcspan.stdout - testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr - testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs - testsuite/tests/rebindable/all.T - + testsuite/tests/rebindable/rebindable11.hs - + testsuite/tests/rebindable/rebindable11.stderr - + testsuite/tests/rebindable/rebindable12.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/118e1c3da622f17c67b4e0fbc12ed7c7084055dc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/118e1c3da622f17c67b4e0fbc12ed7c7084055dc You're receiving 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 Jul 15 01:31:33 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 14 Jul 2020 21:31:33 -0400 Subject: [Git][ghc/ghc][master] Explain why keeping DynFlags in AnalEnv saves allocation. Message-ID: <5f0e5c75accd1_80b8e25ed4313154f@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 1 changed file: - compiler/GHC/Core/Opt/DmdAnal.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -1179,8 +1179,26 @@ type DFunFlag = Bool -- indicates if the lambda being considered is in the notArgOfDfun :: DFunFlag notArgOfDfun = False +{- Note [dmdAnalEnv performance] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +It's tempting to think that removing the dynflags from AnalEnv would improve +performance. After all when analysing recursive groups we end up allocating +a lot of environments. However this is not the case. + +We do get some performance by making AnalEnv smaller. However very often we +defer computation which means we have to capture the dynflags in the thunks +we allocate. Doing this naively in practice causes more allocation than the +removal of DynFlags saves us. + +In theory it should be possible to make this better if we are stricter in +the analysis and therefore allocate fewer thunks. But I couldn't get there +in a few hours and overall the impact on GHC here is small, and there are +bigger fish to fry. So for new the env will keep a reference to the flags. +-} + data AnalEnv - = AE { ae_dflags :: DynFlags + = AE { ae_dflags :: DynFlags -- See Note [dmdAnalEnv performance] , ae_sigs :: SigEnv , ae_virgin :: Bool -- True on first iteration only -- See Note [Initialising strictness] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/64c774b043a2d9be3b98e445990c795f070dab3f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/64c774b043a2d9be3b98e445990c795f070dab3f You're receiving 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 Jul 15 01:32:12 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 14 Jul 2020 21:32:12 -0400 Subject: [Git][ghc/ghc][master] docs/users-guide: Update default -funfolding-use-threshold value Message-ID: <5f0e5c9c86bec_80b3f848700d4d03136847@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 1 changed file: - docs/users_guide/using-optimisation.rst Changes: ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1240,11 +1240,11 @@ by saying ``-fno-wombat``. How eager should the compiler be to inline functions? .. ghc-flag:: -funfolding-use-threshold=⟨n⟩ - :shortdesc: *default: 60.* Tweak unfolding settings. + :shortdesc: *default: 80.* Tweak unfolding settings. :type: dynamic :category: - :default: 60 + :default: 80 .. index:: single: inlining, controlling View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/254245d01e3c1d4f9072abc4372fd3fb0a6ece9f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/254245d01e3c1d4f9072abc4372fd3fb0a6ece9f You're receiving 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 Jul 15 01:32:50 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 14 Jul 2020 21:32:50 -0400 Subject: [Git][ghc/ghc][master] Escape backslashes in json profiling reports properly. Message-ID: <5f0e5cc2aecf0_80b3f848e63c81831409ab@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 1 changed file: - rts/ProfilerReportJson.c Changes: ===================================== rts/ProfilerReportJson.c ===================================== @@ -15,23 +15,35 @@ #include "ProfilerReportJson.h" #include "Profiling.h" -// This only handles characters that you might see in a Haskell cost-centre -// name. -static void escapeString(char const* str, char *out, int len) +#include + +// I don't think this code is all that perf critical. +// So we just allocate a new buffer each time around. +static void escapeString(char const* str, char **buf) { - len--; // reserve character in output for terminating NUL - for (; *str != '\0' && len > 0; str++) { + char *out; + size_t req_size; //Max required size for decoding. + size_t in_size; //Input size, including zero. + + in_size = strlen(str) + 1; + // The strings are generally small and short + // lived so should be ok to just double the size. + req_size = in_size * 2; + out = stgMallocBytes(req_size, "writeCCSReportJson"); + *buf = out; + // We provide an outputbuffer twice the size of the input, + // and at worse double the output size. So we can skip + // length checks. + for (; *str != '\0'; str++) { char c = *str; if (c == '\\') { - if (len < 2) break; - *out = '\\'; out++; len--; - *out = '\\'; out++; len--; + *out = '\\'; out++; + *out = '\\'; out++; } else if (c == '\n') { - if (len < 2) break; - *out = '\\'; out++; len--; - *out = 'n'; out++; len--; + *out = '\\'; out++; + *out = 'n'; out++; } else { - *out = c; out++; len--; + *out = c; out++; } } *out = '\0'; @@ -40,11 +52,13 @@ static void escapeString(char const* str, char *out, int len) static void logCostCentres(FILE *prof_file) { - char tmp[256]; + char* lbl; + char* src_loc; bool needs_comma = false; fprintf(prof_file, "[\n"); for (CostCentre *cc = CC_LIST; cc != NULL; cc = cc->link) { - escapeString(cc->label, tmp, sizeof(tmp)); + escapeString(cc->label, &lbl); + escapeString(cc->srcloc, &src_loc); fprintf(prof_file, "%s" "{\"id\": %" FMT_Int ", " @@ -53,11 +67,13 @@ logCostCentres(FILE *prof_file) "\"src_loc\": \"%s\", " "\"is_caf\": %s}", needs_comma ? ", " : "", - cc->ccID, tmp, cc->module, cc->srcloc, + cc->ccID, lbl, cc->module, src_loc, cc->is_caf ? "true" : "false"); needs_comma = true; } fprintf(prof_file, "]\n"); + stgFree(lbl); + stgFree(src_loc); } static void @@ -92,15 +108,24 @@ writeCCSReportJson(FILE *prof_file, CostCentreStack const *stack, ProfilerTotals totals) { + fprintf(prof_file, "{\n\"program\": \"%s\",\n", prog_name); fprintf(prof_file, "\"arguments\": ["); - for (int count = 0; prog_argv[count]; count++) + for (int count = 0; prog_argv[count]; count++) { + char* arg; + escapeString(prog_argv[count], &arg); fprintf(prof_file, "%s\"%s\"", - count == 0 ? "" : ", ", prog_argv[count]); + count == 0 ? "" : ", ", arg); + stgFree(arg); + } fprintf(prof_file, "],\n\"rts_arguments\": ["); - for (int count = 0; rts_argv[count]; count++) + for (int count = 0; rts_argv[count]; count++) { + char* arg; + escapeString(rts_argv[count], &arg); fprintf(prof_file, "%s\"%s\"", - count == 0 ? "" : ", ", rts_argv[count]); + count == 0 ? "" : ", ", arg); + stgFree(arg); + } fprintf(prof_file, "],\n"); fprintf(prof_file, "\"end_time\": \"%s\",\n", time_str()); @@ -121,6 +146,7 @@ writeCCSReportJson(FILE *prof_file, fprintf(prof_file, ",\n\"profile\": "); logCostCentreStack(prof_file, stack); fprintf(prof_file, "}\n"); + } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c259f86938f4016f4bd4fde7a300fa83591036f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c259f86938f4016f4bd4fde7a300fa83591036f You're receiving 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 Jul 15 01:33:28 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 14 Jul 2020 21:33:28 -0400 Subject: [Git][ghc/ghc][master] 2 commits: .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Message-ID: <5f0e5ce8564d2_80b3f8486fb6f7c3143075@gitlab.haskell.org.mail> Spam detection software, running on the system "mail.haskell.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) [...] Content analysis details: (5.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.1 URI_HEX URI: URI hostname has long hexadecimal sequence 5.0 UNWANTED_LANGUAGE_BODY BODY: Message written in an undesired language -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 HTML_MESSAGE BODY: HTML included in message 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid The original message was not completely plain text, and may be unsafe to open with some email clients; in particular, it may contain a virus, or confirm that your address can receive spam. If you wish to view it, it may be safer to save it to a file and open it with an editor. -------------- next part -------------- An embedded message was scrubbed... From: Marge Bot Subject: [Git][ghc/ghc][master] 2 commits: .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Date: Tue, 14 Jul 2020 21:33:28 -0400 Size: 102990 URL: From gitlab at gitlab.haskell.org Wed Jul 15 01:34:06 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 14 Jul 2020 21:34:06 -0400 Subject: [Git][ghc/ghc][master] rts/Disassembler.c: Use FMT_HexWord for printing values in hex format Message-ID: <5f0e5d0e13d12_80b11047b8831467c6@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 2 changed files: - includes/stg/Types.h - rts/Disassembler.c Changes: ===================================== includes/stg/Types.h ===================================== @@ -76,6 +76,7 @@ typedef uint8_t StgWord8; #define STG_WORD8_MAX UINT8_MAX #define FMT_Word8 PRIu8 +#define FMT_HexWord8 PRIx8 typedef int16_t StgInt16; typedef uint16_t StgWord16; @@ -85,6 +86,7 @@ typedef uint16_t StgWord16; #define STG_WORD16_MAX UINT16_MAX #define FMT_Word16 PRIu16 +#define FMT_HexWord16 PRIx16 typedef int32_t StgInt32; typedef uint32_t StgWord32; ===================================== rts/Disassembler.c ===================================== @@ -80,7 +80,7 @@ disInstr ( StgBCO *bco, int pc ) instrs[pc], (signed int)instrs[pc+1]); pc += 2; break; case bci_CCALL: - debugBelch("CCALL marshaller at 0x%" FMT_Word "\n", + debugBelch("CCALL marshaller at 0x%" FMT_HexWord "\n", literals[instrs[pc]] ); pc += 1; break; case bci_STKCHECK: { @@ -159,26 +159,23 @@ disInstr ( StgBCO *bco, int pc ) pc += 1; break; case bci_PUSH_UBX8: debugBelch( - "PUSH_UBX8 0x%" FMT_Word8 " ", + "PUSH_UBX8 0x%" FMT_HexWord8 "\n", (StgWord8) literals[instrs[pc]] ); - debugBelch("\n"); pc += 1; break; case bci_PUSH_UBX16: debugBelch( - "PUSH_UBX16 0x%" FMT_Word16 " ", + "PUSH_UBX16 0x%" FMT_HexWord16 "\n", (StgWord16) literals[instrs[pc]] ); - debugBelch("\n"); pc += 1; break; case bci_PUSH_UBX32: debugBelch( - "PUSH_UBX32 0x%" FMT_Word32 " ", + "PUSH_UBX32 0x%" FMT_HexWord32 "\n", (StgWord32) literals[instrs[pc]] ); - debugBelch("\n"); pc += 1; break; case bci_PUSH_UBX: debugBelch("PUSH_UBX "); for (i = 0; i < instrs[pc+1]; i++) - debugBelch("0x%" FMT_Word " ", literals[i + instrs[pc]] ); + debugBelch("0x%" FMT_HexWord " ", literals[i + instrs[pc]] ); debugBelch("\n"); pc += 2; break; case bci_PUSH_APPLY_N: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9f65c369a60467dcaf2b37d5f41f00565b4fe25 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9f65c369a60467dcaf2b37d5f41f00565b4fe25 You're receiving 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 Jul 15 01:34:40 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 14 Jul 2020 21:34:40 -0400 Subject: [Git][ghc/ghc][master] 2 commits: macOS: Load frameworks without stating them first. Message-ID: <5f0e5d30eb5cd_80b3f848a2b147c31486cb@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 1 changed file: - compiler/GHC/Runtime/Linker.hs Changes: ===================================== compiler/GHC/Runtime/Linker.hs ===================================== @@ -1705,17 +1705,26 @@ loadFramework hsc_env extraPaths rootname Left _ -> [] Right dir -> [dir "Library/Frameworks"] ps = extraPaths ++ homeFrameworkPath ++ defaultFrameworkPaths - ; mb_fwk <- findFile ps fwk_file - ; case mb_fwk of - Just fwk_path -> loadDLL hsc_env fwk_path - Nothing -> return (Just "not found") } - -- Tried all our known library paths, but dlopen() - -- has no built-in paths for frameworks: give up + ; errs <- findLoadDLL ps [] + ; return $ fmap (intercalate ", ") errs + } where fwk_file = rootname <.> "framework" rootname - -- sorry for the hardcoded paths, I hope they won't change anytime soon: + + -- sorry for the hardcoded paths, I hope they won't change anytime soon: defaultFrameworkPaths = ["/Library/Frameworks", "/System/Library/Frameworks"] + findLoadDLL [] errs = + -- Tried all our known library paths, but dlopen() + -- has no built-in paths for frameworks: give up + return $ Just errs + findLoadDLL (p:ps) errs = + do { dll <- loadDLL hsc_env (p fwk_file) + ; case dll of + Nothing -> return Nothing + Just err -> findLoadDLL ps ((p ++ ": " ++ err):errs) + } + {- ********************************************************************** Helper functions View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9f65c369a60467dcaf2b37d5f41f00565b4fe25...cdc4a6b0f71bbd16a11f23e455b28c0c15720b38 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9f65c369a60467dcaf2b37d5f41f00565b4fe25...cdc4a6b0f71bbd16a11f23e455b28c0c15720b38 You're receiving 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 Jul 15 01:57:02 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 14 Jul 2020 21:57:02 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] ??? Message-ID: <5f0e626ee08e4_80b3f849c221f4031498b7@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 03061b9e by Moritz Angermann at 2020-07-15T01:56:41+00:00 ??? - - - - - 1 changed file: - testsuite/driver/id Changes: ===================================== testsuite/driver/id ===================================== @@ -1,4 +1,4 @@ -#! /usr/bin/env python3 +#! /usr/bin/env bash # # This is the identity test-wrapper. For native tests we do not need to run # executables through a wrapper, as we would need for cross compiled binaries. @@ -6,10 +6,4 @@ # # Therefore this backup identity test-wrapper is the default for native builds. # -import sys -import subprocess - -if __name__ == "__main__": - if len(sys.argv) < 2: - exit(1) - exit(subprocess.run(sys.argv[1:]).returncode) \ No newline at end of file +"$@" \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03061b9e0edd2aa117403a64402f597271eb7a33 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03061b9e0edd2aa117403a64402f597271eb7a33 You're receiving 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 Jul 15 02:05:29 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 14 Jul 2020 22:05:29 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 11 commits: compiler: re-engineer the treatment of rebindable if Message-ID: <5f0e6469aa626_80b3f848700d4d031525d0@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - ff4e35e4 by Ben Gamari at 2020-07-14T22:05:21-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ed714af2 by Ben Gamari at 2020-07-14T22:05:23-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.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/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/StgToCmm/CgUtils.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Utils/Binary.hs - compiler/ghc.cabal.in - docs/users_guide/exts/template_haskell.rst - docs/users_guide/using-optimisation.rst - ghc/GHCi/UI.hs - ghc/GHCi/UI/Info.hs - includes/stg/Types.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/44fb61843006ef01fb06d3380d87d257bf5181d4...ed714af2a35797b6fbbfa7948ee5862184063013 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/44fb61843006ef01fb06d3380d87d257bf5181d4...ed714af2a35797b6fbbfa7948ee5862184063013 You're receiving 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 Jul 15 06:57:15 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 15 Jul 2020 02:57:15 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] 2 commits: Fix T13168 Message-ID: <5f0ea8cb13d91_80b11047b8831638c1@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: dfd79868 by Moritz Angermann at 2020-07-15T06:34:53+00:00 Fix T13168 - - - - - cb8df4a4 by Moritz Angermann at 2020-07-15T06:57:01+00:00 What is going on in CI? Why can't I reproduce this locally? - - - - - 4 changed files: - testsuite/mk/boilerplate.mk - testsuite/tests/rts/T9579/all.T - testsuite/tests/typecheck/T13168/Makefile - testsuite/tests/unboxedsums/all.T Changes: ===================================== testsuite/mk/boilerplate.mk ===================================== @@ -236,8 +236,7 @@ endif # This way we cache the results for different values of $(TEST_HC) $(TOP)/mk/ghc-config : $(TOP)/mk/ghc-config.hs -# "$(TEST_HC)" --make -o $@ $< - ghc --make -o $@ $< + "$(TEST_HC)" --make -o $@ $< empty= space=$(empty) $(empty) @@ -245,7 +244,7 @@ ifeq "$(ghc_config_mk)" "" ghc_config_mk = $(TOP)/mk/ghcconfig$(subst $(space),_,$(subst :,_,$(subst /,_,$(subst \,_,$(TEST_HC))))).mk $(ghc_config_mk) : $(TOP)/mk/ghc-config - $(TOP)/mk/ghc-config "$(TEST_HC)" >"$@"; if [ $$? != 0 ]; then $(RM) "$@"; exit 1; fi + '$(TEST_WRAPPER)' $(TOP)/mk/ghc-config "$(TEST_HC)" >"$@"; if [ $$? != 0 ]; then $(RM) "$@"; exit 1; fi # If the ghc-config fails, remove $@, and fail endif ===================================== testsuite/tests/rts/T9579/all.T ===================================== @@ -9,6 +9,7 @@ def T9579_run_test(binName, expExitCode): # 3. capture exitcode using echo # 4. replace actual number with NUM testCommandTemplate = """ + echo "TEST_WRAPPER=$TEST_WRAPPER" $MAKE -s --no-print-directory T9579_{binName} \ && ( ( "$TEST_WRAPPER" ./T9579_{binName} 2>&1; echo $?) \ | sed -e 's/[0-9]* bytes/NUM bytes/g' ) \ ===================================== testsuite/tests/typecheck/T13168/Makefile ===================================== @@ -2,7 +2,7 @@ TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk -SETUP='$(TEST_WRAPPER)' $(PWD)/Setup -v0 +SETUP='$(TEST_WRAPPER)' '$(PWD)/Setup' -v0 CONFIGURE=$(SETUP) configure --with-ghc='$(TEST_HC)' --with-strip='$(STRIP)' --ghc-options='$(TEST_HC_OPTS)' --package-db='$(PWD)/tmp.d' --prefix='$(PWD)/inst' T13168: clean ===================================== testsuite/tests/unboxedsums/all.T ===================================== @@ -24,12 +24,12 @@ test('empty_sum', only_ways(['normal']), compile_and_run, ['']) test('sum_rr', normal, compile, ['']) test('T12711', only_ways(['ghci']), ghci_script, ['T12711.script']) - -test('sum_api_annots', - [only_ways(['normal']), - when(fast(), skip), when(cross(), skip), - extra_files([ "unboxedsums" + str(i) + ".hs" for i in range(1, 12) ])], - makefile_test, []) +# TODO: Need to run this in --slow mode only +# test('sum_api_annots', +# [only_ways(['normal']), +# when(fast(), skip), when(cross(), skip), +# extra_files([ "unboxedsums" + str(i) + ".hs" for i in range(1, 12) ])], +# makefile_test, []) test('UbxSumLevPoly', normal, compile, ['']) test('T14051', normal, multi_compile, ['T14051.hs', [('T14051a.hs', '')], '-O2 -v0']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/03061b9e0edd2aa117403a64402f597271eb7a33...cb8df4a4de6a06026832ab7ef81179eead47f732 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/03061b9e0edd2aa117403a64402f597271eb7a33...cb8df4a4de6a06026832ab7ef81179eead47f732 You're receiving 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 Jul 15 08:05:40 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 15 Jul 2020 04:05:40 -0400 Subject: [Git][ghc/ghc][master] StgToCmm: Use CmmRegOff smart constructor Message-ID: <5f0eb8d4f1904_80b3f849c221f40317992b@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - 1 changed file: - compiler/GHC/StgToCmm/CgUtils.hs Changes: ===================================== compiler/GHC/StgToCmm/CgUtils.hs ===================================== @@ -121,7 +121,7 @@ regTableOffset dflags n = get_Regtable_addr_from_offset :: DynFlags -> Int -> CmmExpr get_Regtable_addr_from_offset dflags offset = if haveRegBase (targetPlatform dflags) - then CmmRegOff baseReg offset + then cmmRegOff baseReg offset else regTableOffset dflags offset -- | Fixup global registers so that they assign to locations within the View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/51dbfa52df483822b99bb191d2ffc0943954e1d3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/51dbfa52df483822b99bb191d2ffc0943954e1d3 You're receiving 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 Jul 15 08:06:13 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 15 Jul 2020 04:06:13 -0400 Subject: [Git][ghc/ghc][master] testsuite: Add regression test for #17744 Message-ID: <5f0eb8f5d9c86_80b3f848e63c81831802af@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 4 changed files: - + testsuite/tests/simplCore/should_run/T17744.hs - + testsuite/tests/simplCore/should_run/T17744.stdout - + testsuite/tests/simplCore/should_run/T17744A.hs - testsuite/tests/simplCore/should_run/all.T Changes: ===================================== testsuite/tests/simplCore/should_run/T17744.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Main where + +import T17744A + +main :: IO () +main = print $ completeResults $ feed "f" $ parse uriScheme + +uriScheme :: Format (Parser LeftBiasedLocal) Maybe +uriScheme = satisfy_ mytake + +ipV4address :: Format (Parser LeftBiasedLocal) Maybe +ipV4address = satisfy_ mytake2 ===================================== testsuite/tests/simplCore/should_run/T17744.stdout ===================================== @@ -0,0 +1 @@ +1 ===================================== testsuite/tests/simplCore/should_run/T17744A.hs ===================================== @@ -0,0 +1,91 @@ +{-# LANGUAGE FlexibleContexts, FlexibleInstances, GADTs, UndecidableInstances #-} + +module T17744A where + +import Control.Applicative +import Data.ByteString (ByteString) +import qualified Data.ByteString as ByteString + + +data Parser t r where + Failure :: Parser t r + Result :: ByteString -> r -> Parser t r + Delay :: Parser t r -> (ByteString -> Parser t r) -> Parser t r + +instance Functor (Parser t) where + fmap f (Result s r) = Result s (f r) + fmap f p = apply (fmap f) p + +instance Applicative (Parser t) where + pure = return + +instance Monad (Parser t) where + return = Result mempty + Result s r >>= f = feed s (f r) + p >>= f = apply (>>= f) p + +data LeftBiasedLocal + +instance Alternative (Parser LeftBiasedLocal) + +instance (Alternative (Parser t)) => LookAheadParsing (Parser t) + +class Alternative m => Parsing m where + unexpected :: m a + +instance (Alternative (Parser t)) => Parsing (Parser t) where + unexpected = undefined + +class Parsing m => LookAheadParsing m + +class LookAheadParsing m => InputParsing m where + takex :: m ByteString + +class (Parsing m, InputParsing m) => InputCharParsing m + +feed :: ByteString -> Parser t r -> Parser t r +feed s (Result s' r) = Result (mappend s' s) r +feed s (Delay _ f) = f s + +completeResults :: Parser t r -> Int +completeResults (Result _ _) = 1 +completeResults _ = 0 + + +apply :: (Parser t r -> Parser t r') -> Parser t r -> Parser t r' +apply _ Failure = Failure +apply g (Delay e f) = Delay (g e) (g . f) +apply f p = Delay (f p) (\s-> f $ feed s p) + + +instance (Alternative (Parser t )) => + InputParsing (Parser t ) where + takex = p + where p = Delay Failure f + f s = if ByteString.null s then p else + case ByteString.splitAt 1 s of + (first, rest) -> Result rest first + + +instance (LookAheadParsing (Parser t)) => InputCharParsing (Parser t) where + +data Format m n = Format { + parse :: m ByteString, + serialize :: n () + } + +mytake :: (InputParsing m, Alternative n) => Format m n +mytake = Format{ + parse = takex, + serialize = pure () + } + +mytake2 :: (InputCharParsing m, Alternative n) => Format m n +mytake2 = mytake + +satisfy_ :: (Parsing m, Monad m) => Format m n -> Format m n +satisfy_ f = Format{ + parse = parse f >>= pure, + serialize = undefined + } + ===================================== testsuite/tests/simplCore/should_run/all.T ===================================== @@ -91,3 +91,4 @@ test('T16066', exit_code(1), compile_and_run, ['-O1']) test('T17206', exit_code(1), compile_and_run, ['']) test('T17151', [], multimod_compile_and_run, ['T17151', '']) test('T18012', normal, compile_and_run, ['']) +test('T17744', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ae11bdfd98a10266bfc7de9e16b500be220307ac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ae11bdfd98a10266bfc7de9e16b500be220307ac You're receiving 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 Jul 15 08:43:06 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Wed, 15 Jul 2020 04:43:06 -0400 Subject: [Git][ghc/ghc][wip/T18412] 13 commits: compiler: re-engineer the treatment of rebindable if Message-ID: <5f0ec19a7e516_80b3f848639200c3189641@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18412 at Glasgow Haskell Compiler / GHC Commits: 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 7e741433 by Simon Peyton Jones at 2020-07-15T09:42:46+01:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - 52bdb5bb by Simon Peyton Jones at 2020-07-15T09:42:46+01:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Coverage.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/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/StgToCmm/CgUtils.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Types/Evidence.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/20037a90d0a8a24a5dc31603cd2374f769e4f109...52bdb5bb05bd6c10b84c69e98587f4e1b65110e1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/20037a90d0a8a24a5dc31603cd2374f769e4f109...52bdb5bb05bd6c10b84c69e98587f4e1b65110e1 You're receiving 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 Jul 15 12:36:26 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 15 Jul 2020 08:36:26 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] Fix test-wrapper in python, so hadrian gets the benefit. Message-ID: <5f0ef84ad3719_80b3f848e63c8183218953@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 2f96bd31 by Moritz Angermann at 2020-07-15T12:36:13+00:00 Fix test-wrapper in python, so hadrian gets the benefit. - - - - - 2 changed files: - testsuite/driver/testglobals.py - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testglobals.py ===================================== @@ -188,6 +188,10 @@ class TestConfig: # I have no idea what this does self.package_conf_cache_file = None # type: Optional[Path] + # test-wrapper, a program to run the executable through. + # the driver/id program is the identity test-wrapper. + self.test_wrapper = None + global config config = TestConfig() ===================================== testsuite/driver/testlib.py ===================================== @@ -1649,7 +1649,14 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) -> if opts.cmd_wrapper is not None: cmd = opts.cmd_wrapper(cmd) - cmd = 'cd "{opts.testdir}" && {cmd}'.format(**locals()) + # The test wrapper. Default to $TOP / driver / id + # for the identity test-wrapper. + if config.test_wrapper is None: + test_wrapper = config.top / "driver" / "id" + else: + test_wrapper = config.test_wrapper + + cmd = 'cd "{opts.testdir}" && TEST_WRAPPER="{test_wrapper}" {cmd}'.format(**locals()) # run the command exit_code = runCmd(cmd, stdin_arg, stdout_arg, stderr_arg, opts.run_timeout_multiplier) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2f96bd31a0108aa4fcf26d470f5ceb5fd5662b75 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2f96bd31a0108aa4fcf26d470f5ceb5fd5662b75 You're receiving 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 Jul 15 14:08:00 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 15 Jul 2020 10:08:00 -0400 Subject: [Git][ghc/ghc][wip/winio] 133 commits: Use dumpStyle when printing inlinings Message-ID: <5f0f0dc049f72_80b3f84870971943232575@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/winio at Glasgow Haskell Compiler / GHC Commits: 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - f01bb58b by Ben Gamari at 2020-07-15T10:07:02-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - 56e898b5 by Tamar Christina at 2020-07-15T10:07:11-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 734357c5 by Tamar Christina at 2020-07-15T10:07:11-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 92d5db44 by Tamar Christina at 2020-07-15T10:07:11-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 750dde43 by Tamar Christina at 2020-07-15T10:07:11-04:00 winio: Small linker comment and ifdef cleanups - - - - - 703ddf53 by Tamar Christina at 2020-07-15T10:07:11-04:00 winio: Flush event logs eagerly. - - - - - 7dfb6e2c by Tamar Christina at 2020-07-15T10:07:11-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 3bdad474 by Tamar Christina at 2020-07-15T10:07:12-04:00 winio: Implement new Console API - - - - - eb0685f0 by Tamar Christina at 2020-07-15T10:07:12-04:00 winio: Add IOPort synchronization primitive - - - - - b7f92624 by Tamar Christina at 2020-07-15T10:07:12-04:00 winio: Add new io-manager cmdline options - - - - - 90aa8ccd by Tamar Christina at 2020-07-15T10:07:12-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 2e75228f by Tamar Christina at 2020-07-15T10:07:12-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d9c96472 by Tamar Christina at 2020-07-15T10:07:12-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - b574f72f by Tamar Christina at 2020-07-15T10:07:12-04:00 winio: Switch Testsuite to test winio by default - - - - - b53894a6 by Tamar Christina at 2020-07-15T10:07:12-04:00 winio: Multiple refactorings and support changes. - - - - - 2a9f74c5 by Tamar Christina at 2020-07-15T10:07:12-04:00 winio: core threaded I/O manager - - - - - 9c8c8220 by Tamar Christina at 2020-07-15T10:07:13-04:00 winio: core non-threaded I/O manager - - - - - 6c8793dd by Tamar Christina at 2020-07-15T10:07:13-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - ac3ec238 by Tamar Christina at 2020-07-15T10:07:13-04:00 winio: Relaxing some constraints in io-manager. - - - - - 46b352ef by Tamar Christina at 2020-07-15T10:07:13-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - db5207b2 by Tamar Christina at 2020-07-15T10:07:13-04:00 winio: Remove some barf statements that are a bit strict. - - - - - d2c1d3d3 by Andreas Klebinger at 2020-07-15T10:07:13-04:00 winio: Expand comments describing non-threaded loop - - - - - 2dd81508 by Tamar Christina at 2020-07-15T10:07:13-04:00 winio: fix FileSize unstat-able handles - - - - - 94b0ce97 by Tamar Christina at 2020-07-15T10:07:13-04:00 winio: Implement new tempfile routines for winio - - - - - e6e5e74d by Andreas Klebinger at 2020-07-15T10:07:13-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - 5bab211e by Andreas Klebinger at 2020-07-15T10:07:13-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - 19b4b95a by Andreas Klebinger at 2020-07-15T10:07:13-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - c025dc0a by Andreas Klebinger at 2020-07-15T10:07:13-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - a0745334 by Andreas Klebinger at 2020-07-15T10:07:13-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - e04d6ad7 by Andreas Klebinger at 2020-07-15T10:07:13-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 28018610 by Andreas Klebinger at 2020-07-15T10:07:13-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 0387643d by Andreas Klebinger at 2020-07-15T10:07:13-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - e0881756 by Andreas Klebinger at 2020-07-15T10:07:13-04:00 winio: Remove debug event log trace - - - - - 1423e25e by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 9e3e992d by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - 9e707b4b by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Update output of T9681 since we now actually run it. - - - - - ef15cfaa by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: A few more improvements to the IOPort primitives. - - - - - b52555e3 by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - be254ea3 by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Assign thread labels to IOManager threads. - - - - - efe74586 by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - f3dbf47f by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - 017675ab by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - 05165f61 by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Add comments/cleanup an import in base - - - - - 2b9b1b79 by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - 47eb6529 by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Make last_event a local variable - - - - - 06a7e5c0 by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 69942bd9 by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - 8474ed10 by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - f3098c35 by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - b5e0793b by Andreas Klebinger at 2020-07-15T10:07:14-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 63f8bcc4 by Andreas Klebinger at 2020-07-15T10:07:15-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - 24fd01e4 by Andreas Klebinger at 2020-07-15T10:07:15-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - 71bd74be by Andreas Klebinger at 2020-07-15T10:07:15-04:00 winio: Update placeholder comment with actual function name. - - - - - 3af6274f by Andreas Klebinger at 2020-07-15T10:07:15-04:00 winio: Always lock win32 event queue - - - - - 81bf51fa by Andreas Klebinger at 2020-07-15T10:07:15-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 9dcb46d2 by Andreas Klebinger at 2020-07-15T10:07:15-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 3c813de3 by Andreas Klebinger at 2020-07-15T10:07:15-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - db4e2293 by Tamar Christina at 2020-07-15T10:07:15-04:00 winio: Various fixes related to rebase and testdriver - - - - - abab0ab1 by Tamar Christina at 2020-07-15T10:07:15-04:00 winio: Fix rebase artifacts - - - - - 2bf6f425 by Andreas Klebinger at 2020-07-15T10:07:15-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - 2efbbb02 by Andreas Klebinger at 2020-07-15T10:07:15-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 396ef150 by Andreas Klebinger at 2020-07-15T10:07:15-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - f50b6ae0 by Tamar Christina at 2020-07-15T10:07:15-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - da48d0e8 by Ben Gamari at 2020-07-15T10:07:15-04:00 winio: Minor comments/renamings - - - - - 928f6462 by Andreas Klebinger at 2020-07-15T10:07:15-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 555ec3a0 by Andreas Klebinger at 2020-07-15T10:07:16-04:00 winio: Small refactor in withOverlappedEx - - - - - ad8c6b54 by Andreas Klebinger at 2020-07-15T10:07:16-04:00 winio: A few comments and commented out dbxIO - - - - - c6b96ba4 by Andreas Klebinger at 2020-07-15T10:07:16-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - 3d404cce by Tamar Christina at 2020-07-15T10:07:16-04:00 winio: revert BHandle changes. - - - - - 7bd1d16d by Ben Gamari at 2020-07-15T10:07:16-04:00 winio: Fix imports - - - - - 5ff47b0a by Tamar Christina at 2020-07-15T10:07:16-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - 564e5c7f by Ben Gamari at 2020-07-15T10:07:16-04:00 winio: Only compile sources on Windows - - - - - c1299149 by Andreas Klebinger at 2020-07-15T10:07:16-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 9df13b96 by Andreas Klebinger at 2020-07-15T10:07:16-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - 72d37ac3 by Andreas Klebinger at 2020-07-15T10:07:16-04:00 winio: Deduplicate openFile logic - - - - - 584e50d5 by Tamar Christina at 2020-07-15T10:07:16-04:00 winio: fix -werror issue in encoding file - - - - - 51fbb022 by Andreas Klebinger at 2020-07-15T10:07:16-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - c1577409 by Andreas Klebinger at 2020-07-15T10:07:16-04:00 winio: add a note about file locking in the RTS. - - - - - 0db9dbf1 by Andreas Klebinger at 2020-07-15T10:07:16-04:00 winio: Add version to @since annotation - - - - - 3ba07510 by Andreas Klebinger at 2020-07-15T10:07:16-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 084e303d by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - 537ee1cb by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 2f8a5009 by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 4722b04a by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Make it explicit that we only create one IO manager - - - - - 25eb478d by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Note why we don't use blocking waits. - - - - - f0535881 by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Remove commented out pragma - - - - - b0bab0ec by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - ba18e20a by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Rename SmartHandles to StdHandles - - - - - a050d144 by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 634e2a57 by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Update IOPort haddocks. - - - - - 8a2333b3 by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Add a note cross reference - - - - - 14052f31 by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - d154bbe0 by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - 14c8b0a6 by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Remove historical todos - - - - - 542004ac by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Update note, remove debugging pragma. - - - - - f4411c81 by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - 006102d9 by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: Remove obsolete comment about cond. variables - - - - - 1812a2e9 by Andreas Klebinger at 2020-07-15T10:07:17-04:00 winio: fix initial linux validate build - - - - - 2f9c2f72 by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: Fix ThreadDelay001 CPP - - - - - eec25db9 by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: Fix openFile009 merge conflict leftover - - - - - b186dbc2 by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - 69da3095 by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - 3177416b by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 30502b52 by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - fe83623c by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 208833c1 by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: Also accept T7037 stderr - - - - - 1c5b024a by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: fix cabal04 by filtering rts args - - - - - 85b8f8e8 by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: fix cabal01 by accepting expected stderr - - - - - e093bc0b by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - e06c93cd by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - 251b3962 by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: fix tempfiles test on linux - - - - - 5e00db58 by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: Accept accepted stderr for T3807 - - - - - e1b10e9f by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: Accept accepted stderr for linker_unload - - - - - 72b4541c by Andreas Klebinger at 2020-07-15T10:07:18-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 29fe8fe3 by Tamar Christina at 2020-07-15T10:07:18-04:00 winio: clarify wording on conditional variables. - - - - - 2e46072f by Tamar Christina at 2020-07-15T10:07:19-04:00 winio: clarify comment on cooked mode. - - - - - 926c6147 by Tamar Christina at 2020-07-15T10:07:19-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 867843e0 by Ben Gamari at 2020-07-15T10:07:19-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - Makefile - compiler/GHC/Builtin/Names.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.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/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/StgToCmm/CgUtils.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Info.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Tc/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/180f07a91a3b91225c178a7a9faf432fc1c9c976...867843e0d2d7edcaa1906c8b7fffb89a0a4e92eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/180f07a91a3b91225c178a7a9faf432fc1c9c976...867843e0d2d7edcaa1906c8b7fffb89a0a4e92eb You're receiving 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 Jul 15 15:28:00 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 15 Jul 2020 11:28:00 -0400 Subject: [Git][ghc/ghc][wip/backports] 7 commits: gitlab-ci: Bump Docker images Message-ID: <5f0f2080978ff_80b8e25ed43250925@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: 408b6714 by Ben Gamari at 2020-07-15T11:26:48-04:00 gitlab-ci: Bump Docker images - - - - - 410f53a9 by Ben Gamari at 2020-07-15T11:26:48-04:00 hadrian: Eliminate some redundant imports - - - - - e2bed3ee by GHC GitLab CI at 2020-07-15T11:26:48-04:00 Accept testsuite changes - - - - - 5018cad4 by Kevin Buhr at 2020-07-15T11:26:48-04:00 Add "-Iw" RTS flag for minimum wait between idle GCs (#11134) This wasn't originally slated for 8.10 but the documentation part of this patch snuck into the ghc-8.10 branch via a backport. Instead of backing out the documentation and causing further user confusion I've opted just to backport this functional change as well. (cherry picked from commit 859ebdd446eda446d38708a587503c255b58c4c6) - - - - - edc36a91 by Ben Gamari at 2020-07-15T11:26:48-04:00 user-guide: Add release notes for 8.10.2 - - - - - 46e3ceca by Ben Gamari at 2020-07-15T11:27:30-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. (cherry picked from commit 8cc7274b8de254c7266b61fadbc6795dc37bd1e9) - - - - - ca146208 by Ben Gamari at 2020-07-15T11:27:40-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. (cherry picked from commit b835112cbeaa6e34a8bae7b7697bdf2826edaa9a) - - - - - 16 changed files: - .gitlab-ci.yml - + docs/users_guide/8.10.2-notes.rst - docs/users_guide/index.rst - hadrian/src/Hadrian/Utilities.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Builders/Ghc.hs - includes/rts/Flags.h - rts/ProfHeap.c - rts/RtsFlags.c - rts/Timer.c - testsuite/tests/dependent/should_fail/SelfDep.stderr - testsuite/tests/dependent/should_fail/T16344.stderr - testsuite/tests/partial-sigs/should_compile/T15039b.stderr - testsuite/tests/partial-sigs/should_compile/T15039d.stderr - testsuite/tests/polykinds/PolyKinds06.stderr - testsuite/tests/typecheck/should_fail/T7892.stderr Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,7 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 408eff66aef6ca2b44446c694c5a56d6ca0460cc + DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a # Sequential version number capturing the versions of all tools fetched by # .gitlab/ci.sh. ===================================== docs/users_guide/8.10.2-notes.rst ===================================== @@ -0,0 +1,115 @@ +.. _release-8-10-2: + +Release notes for version 8.10.2 +================================ + +The significant changes to the various parts of the compiler are listed in the +following sections. + + +Highlights +---------- + +- A few important correctness fixes for the low-latency garbage collector. + +Full details +------------ + +Language +~~~~~~~~ + + +Compiler +~~~~~~~~ + + - A simplifier panic manifesting when DWARF debug information is enabled has + been fixed (:ghc-ticket:`18162`, :ghc-ticket:`17619`) + +GHC API +~~~~~~~ + + +GHCi +~~~~ + + +Runtime system +~~~~~~~~~~~~~~ + +- The RTS now allows the user to specify a minimum time between idle GCs with + the :rts-flag:`-Iw ⟨seconds⟩` flag. 8.10.1 contained a users guide reference + to this flag but did not include the associated implementation. + + - A memory leak in the cost-center profiler has been fixed + (:ghc-ticket:`18348`) + + - A potential integer overflow in the compact normal form import logic has + been fixed (:ghc-ticket:`16992`) + + - We now workaround a Linux kernel bug in the implementation of timerfd which + could previously result in program crashes (:ghc-ticket:`18033`) + +Template Haskell +~~~~~~~~~~~~~~~~ + + + +``ghc-prim`` library +~~~~~~~~~~~~~~~~~~~~ + + + +``ghc`` library +~~~~~~~~~~~~~~~ + +``base`` library +~~~~~~~~~~~~~~~~ + +Build system +~~~~~~~~~~~~ + + + +Included libraries +------------------ + +The package database provided with this distribution also contains a number of +packages other than GHC itself. See the changelogs provided with these packages +for further change information. + +.. ghc-package-list:: + + libraries/array/array.cabal: Dependency of ``ghc`` library + libraries/base/base.cabal: Core library + libraries/binary/binary.cabal: Dependency of ``ghc`` library + libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library + libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility + libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library + libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library + libraries/directory/directory.cabal: Dependency of ``ghc`` library + libraries/exceptions/exceptions.cabal: Dependency of ``haskeline`` library + libraries/filepath/filepath.cabal: Dependency of ``ghc`` library + compiler/ghc.cabal: The compiler itself + libraries/ghci/ghci.cabal: The REPL interface + libraries/ghc-boot/ghc-boot.cabal: Internal compiler library + libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library + libraries/ghc-compact/ghc-compact.cabal: Core library + libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library + libraries/ghc-prim/ghc-prim.cabal: Core library + libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable + libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable + libraries/integer-gmp/integer-gmp.cabal: Core library + libraries/libiserv/libiserv.cabal: Internal compiler library + libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library + libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library + libraries/pretty/pretty.cabal: Dependency of ``ghc`` library + libraries/process/process.cabal: Dependency of ``ghc`` library + libraries/stm/stm.cabal: Dependency of ``haskeline`` library + libraries/template-haskell/template-haskell.cabal: Core library + libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library + libraries/text/text.cabal: Dependency of ``Cabal`` library + libraries/time/time.cabal: Dependency of ``ghc`` library + libraries/transformers/transformers.cabal: Dependency of ``ghc`` library + libraries/unix/unix.cabal: Dependency of ``ghc`` library + libraries/Win32/Win32.cabal: Dependency of ``ghc`` library + libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable ===================================== docs/users_guide/index.rst ===================================== @@ -13,6 +13,7 @@ Contents: license intro 8.10.1-notes + 8.10.2-notes ghci runghc usage ===================================== hadrian/src/Hadrian/Utilities.hs ===================================== @@ -39,8 +39,8 @@ import Control.Monad.Extra import Data.Char import Data.Dynamic (Dynamic, fromDynamic, toDyn) import Data.HashMap.Strict (HashMap) +import Data.List.Extra (repeatedly, dropWhileEnd) import Data.List (isPrefixOf) -import Data.List.Extra import Data.Maybe import Data.Typeable (TypeRep, typeOf) import Development.Shake hiding (Normal) ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -1,6 +1,5 @@ module Settings.Builders.Cabal (cabalBuilderArgs) where -import Hadrian.Builder (getBuilderPath, needBuilder) import Hadrian.Haskell.Cabal import Builder ===================================== hadrian/src/Settings/Builders/Ghc.hs ===================================== @@ -2,8 +2,6 @@ module Settings.Builders.Ghc (ghcBuilderArgs, haddockGhcArgs) where -import Data.List.Extra (splitOn) - import Hadrian.Haskell.Cabal import Hadrian.Haskell.Cabal.Type ===================================== includes/rts/Flags.h ===================================== @@ -66,6 +66,7 @@ typedef struct _GC_FLAGS { bool ringBell; Time idleGCDelayTime; /* units: TIME_RESOLUTION */ + Time interIdleGCWait; /* units: TIME_RESOLUTION */ bool doIdleGC; Time longGCSync; /* units: TIME_RESOLUTION */ ===================================== rts/ProfHeap.c ===================================== @@ -260,6 +260,16 @@ LDV_recordDead( const StgClosure *c, uint32_t size ) STATIC_INLINE void initEra(Census *census) { + // N.B. When not LDV profiling we reinitialise the same Census over + // and over again. Consequently, we need to ensure that we free the + // resources from the previous census. + if (census->hash) { + freeHashTable(census->hash, NULL); + } + if (census->arena) { + arenaFree(census->arena); + } + census->hash = allocHashTable(); census->ctrs = NULL; census->arena = newArena(); @@ -407,18 +417,24 @@ initHeapProfiling(void) #if defined(PROFILING) if (doingLDVProfiling()) { era = 1; + n_censuses = 32; } else #endif { era = 0; + n_censuses = 1; } // max_era = 2^LDV_SHIFT max_era = 1 << LDV_SHIFT; - n_censuses = 32; censuses = stgMallocBytes(sizeof(Census) * n_censuses, "initHeapProfiling"); + // Ensure that arena and hash are NULL since otherwise initEra will attempt to free them. + for (unsigned int i=0; i < n_censuses; i++) { + censuses[i].arena = NULL; + censuses[i].hash = NULL; + } initEra( &censuses[era] ); /* initProfilingLogFile(); */ ===================================== rts/RtsFlags.c ===================================== @@ -164,6 +164,7 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.compactThreshold = 30.0; RtsFlags.GcFlags.sweep = false; RtsFlags.GcFlags.idleGCDelayTime = USToTime(300000); // 300ms + RtsFlags.GcFlags.interIdleGCWait = 0; #if defined(THREADED_RTS) RtsFlags.GcFlags.doIdleGC = true; #else @@ -1180,19 +1181,33 @@ error = true; break; case 'I': /* idle GC delay */ - OPTION_UNSAFE; - if (rts_argv[arg][2] == '\0') { - /* use default */ - } else { - Time t = fsecondsToTime(atof(rts_argv[arg]+2)); - if (t == 0) { - RtsFlags.GcFlags.doIdleGC = false; - } else { - RtsFlags.GcFlags.doIdleGC = true; - RtsFlags.GcFlags.idleGCDelayTime = t; - } - } - break; + OPTION_UNSAFE; + switch (rts_argv[arg][2]) { + /* minimum inter-idle GC wait time */ + case 'w': + if (rts_argv[arg][3] == '\0') { + /* use default */ + } else { + RtsFlags.GcFlags.interIdleGCWait = fsecondsToTime(atof(rts_argv[arg]+3)); + } + break; + /* idle delay before GC */ + case '\0': + /* use default */ + break; + default: + { + Time t = fsecondsToTime(atof(rts_argv[arg]+2)); + if (t == 0) { + RtsFlags.GcFlags.doIdleGC = false; + } else { + RtsFlags.GcFlags.doIdleGC = true; + RtsFlags.GcFlags.idleGCDelayTime = t; + } + } + break; + } + break; case 'T': OPTION_SAFE; ===================================== rts/Timer.c ===================================== @@ -28,8 +28,11 @@ /* ticks left before next pre-emptive context switch */ static int ticks_to_ctxt_switch = 0; -/* idle ticks left before we perform a GC */ -static int ticks_to_gc = 0; +/* idle ticks left before GC allowed */ +static int idle_ticks_to_gc = 0; + +/* inter-idle GC ticks left before GC allowed */ +static int inter_gc_ticks_to_gc = 0; /* * Function: handle_tick() @@ -53,18 +56,21 @@ handle_tick(int unused STG_UNUSED) /* * If we've been inactive for idleGCDelayTime (set by +RTS * -I), tell the scheduler to wake up and do a GC, to check - * for threads that are deadlocked. + * for threads that are deadlocked. However, ensure we wait + * at least interIdleGCWait (+RTS -Iw) between idle GCs. */ switch (recent_activity) { case ACTIVITY_YES: recent_activity = ACTIVITY_MAYBE_NO; - ticks_to_gc = RtsFlags.GcFlags.idleGCDelayTime / - RtsFlags.MiscFlags.tickInterval; + idle_ticks_to_gc = RtsFlags.GcFlags.idleGCDelayTime / + RtsFlags.MiscFlags.tickInterval; break; case ACTIVITY_MAYBE_NO: - if (ticks_to_gc == 0) { + if (idle_ticks_to_gc == 0 && inter_gc_ticks_to_gc == 0) { if (RtsFlags.GcFlags.doIdleGC) { recent_activity = ACTIVITY_INACTIVE; + inter_gc_ticks_to_gc = RtsFlags.GcFlags.interIdleGCWait / + RtsFlags.MiscFlags.tickInterval; #if defined(THREADED_RTS) wakeUpRts(); // The scheduler will call stopTimer() when it has done @@ -86,7 +92,8 @@ handle_tick(int unused STG_UNUSED) #endif } } else { - ticks_to_gc--; + if (idle_ticks_to_gc) idle_ticks_to_gc--; + if (inter_gc_ticks_to_gc) inter_gc_ticks_to_gc--; } break; default: ===================================== testsuite/tests/dependent/should_fail/SelfDep.stderr ===================================== @@ -3,4 +3,3 @@ SelfDep.hs:5:11: error: • Type constructor ‘T’ cannot be used here (it is defined and used in the same recursive group) • In the kind ‘T -> *’ - In the data type declaration for ‘T’ ===================================== testsuite/tests/dependent/should_fail/T16344.stderr ===================================== @@ -4,3 +4,7 @@ T16344.hs:7:46: error: • In the second argument of ‘T’, namely ‘Int’ In the type ‘(T Type Int Bool)’ In the definition of data constructor ‘MkT’ + NB: Type ‘T’ was inferred to use visible dependent quantification. + Most types with visible dependent quantification are + polymorphically recursive and need a standalone kind + signature. Perhaps supply one, with StandaloneKindSignatures. ===================================== testsuite/tests/partial-sigs/should_compile/T15039b.stderr ===================================== @@ -52,6 +52,6 @@ T15039b.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘Coercible @* a b’ Where: ‘a’, ‘b’ are rigid type variables bound by the inferred type of ex7 :: Coercible @* a b => Coercion @{*} a b - at T15039b.hs:36:1-14 + at T15039b.hs:35:1-44 • In the type signature: ex7 :: _ => Coercion (a :: Type) (b :: Type) ===================================== testsuite/tests/partial-sigs/should_compile/T15039d.stderr ===================================== @@ -53,6 +53,6 @@ T15039d.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘Coercible @* a b’ Where: ‘a’, ‘b’ are rigid type variables bound by the inferred type of ex7 :: Coercible @* a b => Coercion @{*} a b - at T15039d.hs:36:1-14 + at T15039d.hs:35:1-44 • In the type signature: ex7 :: _ => Coercion (a :: Type) (b :: Type) ===================================== testsuite/tests/polykinds/PolyKinds06.stderr ===================================== @@ -3,4 +3,3 @@ PolyKinds06.hs:9:11: error: • Type constructor ‘A’ cannot be used here (it is defined and used in the same recursive group) • In the kind ‘A -> *’ - In the data type declaration for ‘B’ ===================================== testsuite/tests/typecheck/should_fail/T7892.stderr ===================================== @@ -1,4 +1,2 @@ -T7892.hs:5:4: error: - • Expected kind ‘* -> *’, but ‘f’ has kind ‘*’ - • In the associated type family declaration for ‘F’ +T7892.hs:5:4: error: Expected kind ‘* -> *’, but ‘f’ has kind ‘*’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/04dce49825c5124d942846902d97b42c33ca26e7...ca146208a210242904edde77633ef857200dd45f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/04dce49825c5124d942846902d97b42c33ca26e7...ca146208a210242904edde77633ef857200dd45f You're receiving 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 Jul 15 18:48:34 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 15 Jul 2020 14:48:34 -0400 Subject: [Git][ghc/ghc] Pushed new tag ghc-8.8.4-release Message-ID: <5f0f4f825c43_80b3f848709719432771b0@gitlab.haskell.org.mail> Ben Gamari pushed new tag ghc-8.8.4-release at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-8.8.4-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 Wed Jul 15 20:41:15 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 15 Jul 2020 16:41:15 -0400 Subject: [Git][ghc/ghc][wip/winio] 118 commits: Bump Cabal submodule Message-ID: <5f0f69eb8b2da_80b3f848a2b147c3279399@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/winio at Glasgow Haskell Compiler / GHC Commits: 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - 30 changed files: - Makefile - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Info.hs - configure.ac - hadrian/src/Settings/Packages.hs - includes/rts/Constants.h - includes/rts/FileLock.h - includes/rts/Flags.h - includes/rts/IOManager.h - includes/rts/OSThreads.h - includes/rts/storage/TSO.h - includes/stg/MiscClosures.h - libraries/Cabal - + libraries/base/Control/Concurrent.hs-boot - libraries/base/GHC/Conc/IO.hs - + libraries/base/GHC/Conc/POSIX.hs - + libraries/base/GHC/Conc/POSIX/Const.hsc - libraries/base/GHC/Conc/Sync.hs - + libraries/base/GHC/Conc/Sync.hs-boot - + libraries/base/GHC/Conc/WinIO.hs - libraries/base/GHC/Conc/Windows.hs - libraries/base/GHC/ConsoleHandler.hs → libraries/base/GHC/ConsoleHandler.hsc - libraries/base/GHC/Event/Array.hs - libraries/base/GHC/Event/IntTable.hs - libraries/base/GHC/Event/Internal.hs - + libraries/base/GHC/Event/Internal/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/867843e0d2d7edcaa1906c8b7fffb89a0a4e92eb...2143c49273d7d87ee2f3ef1211856d60b1427af1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/867843e0d2d7edcaa1906c8b7fffb89a0a4e92eb...2143c49273d7d87ee2f3ef1211856d60b1427af1 You're receiving 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 Jul 15 20:48:37 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Wed, 15 Jul 2020 16:48:37 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T14620 Message-ID: <5f0f6ba58f9e_80b3f8487097194328028b@gitlab.haskell.org.mail> Sebastian Graf pushed new branch wip/T14620 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T14620 You're receiving 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 Jul 15 22:43:20 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 15 Jul 2020 18:43:20 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/backports Message-ID: <5f0f86888169f_80b3f848a2b147c32879a0@gitlab.haskell.org.mail> Ben Gamari deleted branch wip/backports 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 Jul 15 22:43:20 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 15 Jul 2020 18:43:20 -0400 Subject: [Git][ghc/ghc][ghc-8.10] 24 commits: iserv: Don't pass --export-dynamic on FreeBSD Message-ID: <5f0f8688f188f_80b3f848e63c81832881ae@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.10 at Glasgow Haskell Compiler / GHC Commits: 10f80ca8 by Ben Gamari at 2020-05-30T09:56:23-04:00 iserv: Don't pass --export-dynamic on FreeBSD This is definitely a hack but it's probably the best we can do for now. Hadrian does the right thing here by passing --export-dynamic only to the linker. (cherry picked from commit 2290eb02cf95e9cfffcb15fc9c593d5ef79c75d9) - - - - - 94562bbf by Ben Gamari at 2020-05-30T09:56:30-04:00 hadrian: Use --export-dynamic when linking iserv As noticed in #17962, the make build system currently does this (see 3ce0e0ba) but the change was never ported to Hadrian. (cherry picked from commit eba58110538686d8fe57d5dd372624b50f1fa2b7) - - - - - b3330c2d by Ben Gamari at 2020-05-30T09:58:52-04:00 Coverage: Don't produce ModBreaks if not HscInterpreted emptyModBreaks contains a bottom and consequently it's important that we don't use it unless necessary. (cherry picked from commit f684a7d505f19bd78f178e01bbd8e4467aaa00ea) - - - - - 295735ae by Ben Gamari at 2020-05-30T10:00:15-04:00 Bump process submodule Fixes #17926. - - - - - 285f92bb by Sylvain Henry at 2020-05-30T10:03:03-04:00 RTS: workaround a Linux kernel bug in timerfd Reading a timerfd may return 0: https://lkml.org/lkml/2019/8/16/335. This is currently undocumented behavior and documentation "won't happen anytime soon" (https://lkml.org/lkml/2020/2/13/295). With this patch, we just ignore the result instead of crashing. It may fix #18033 but we can't be sure because we don't have enough information. See also this discussion about the kernel bug: https://github.com/Azure/sonic-swss-common/pull/302/files/1f070e7920c2e5d63316c0105bf4481e73d72dc9 (cherry picked from commit 8ea37b01b6ab16937f7b528b6bbae9fade9f1361) - - - - - 88fd4829 by Ryan Scott at 2020-05-31T18:03:38-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. (cherry picked from commit 6ca3d6a6c19dcd885f3b0beeda192cd90e83e0bd) - - - - - a6befeb3 by Ben Gamari at 2020-05-31T18:03:38-04:00 simplCore: Ignore ticks in rule templates This fixes #17619, where a tick snuck in to the template of a rule, resulting in a panic during rule matching. The tick in question was introduced via post-inlining, as discussed in `Note [Simplifying rules]`. The solution we decided upon was to simply ignore ticks in the rule template, as discussed in `Note [Tick annotations in RULE matching]`. Fixes #18162. Fixes #17619. (cherry picked from commit dcd6bdcce57430d08b335014625722c487ea08e4) - - - - - fa36474d by Tuan Le at 2020-05-31T18:03:38-04:00 llvmGen: Consider Relocatable read-only data as not constantReferences: #18137 (cherry picked from commit 0004ccb885e534c386ceae21580fc59ec7ad0ede) - - - - - 4a73e707 by Ben Gamari at 2020-05-31T18:03:38-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 (cherry picked from commit cf4f1e2f78840d25b132de55bce1e02256334ace) - - - - - 4219e9c1 by Ryan Scott at 2020-05-31T18:03:38-04:00 Make boxed 1-tuples have known keys Unlike other tuples, which use special syntax and are "known" by way of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not use special syntax. Therefore, in order to make sure that the internals of GHC are aware of the `data Unit a = Unit a` definition in `GHC.Tuple`, we give `Unit` known keys. For the full details, see `Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)` in `GHC.Builtin.Types`. Fixes #18097. (cherry picked from commit 518a63d4d7e31e49a81ad66d5e5ccb1f790f6de9) - - - - - 761909b9 by Ryan Scott at 2020-05-31T18:03:38-04:00 Create di_scoped_tvs for associated data family instances properly See `Note [Associated data family instances and di_scoped_tvs]` in `GHC.Tc.TyCl.Instance`, which explains all of the moving parts. Fixes #18055. (cherry picked from commit cd8409c26d4370bf2cdcd76801974e99a9adf7b0) - - - - - 30037e6d by Sebastian Graf at 2020-05-31T18:03:38-04:00 PmCheck: Adjust recursion depth for inhabitation test In #17977, we ran into the reduction depth limit of the typechecker. That was only a symptom of a much broader issue: The recursion depth of the coverage checker for trying to instantiate strict fields in the `nonVoid` test was far too high (100, the `defaultMaxTcBound`). As a result, we were performing quite poorly on `T17977`. Short of a proper termination analysis to prove emptyness of a type, we just arbitrarily default to a much lower recursion limit of 3. Fixes #17977. (cherry picked from commit ed58d4fdcbc7b4fa8fbdf3d638a8d53c444ef4f2) - - - - - 1666baa6 by Simon Peyton Jones at 2020-05-31T18:03:38-04:00 Improve skolemisation This patch avoids skolemiseUnboundMetaTyVar making up a fresh Name when it doesn't need to. See Note [Skolemising and identity] Improves error messsages for partial type signatures. (cherry picked from commit d7002bccd7d131f8ee9b1ddcd83d62262622294d) - - - - - 84ba6d2c by Simon Peyton Jones at 2020-05-31T18:03:38-04:00 Improve pretty-printing for TyConBinders In particular, show their kinds. (cherry picked from commit fa37940cd72f82abc460f5c0a5de64dd75cee6ae) - - - - - 35277140 by Simon Peyton Jones at 2020-05-31T18:03:38-04:00 Fix scoping of TyCon binders in TcTyClsDecls This patch fixes #17566 by refactoring the way we decide the final identity of the tyvars in the TyCons of a possibly-recursive nest of type and class decls, possibly with associated types. It's all laid out in Note [Swizzling the tyvars before generaliseTcTyCon] Main changes: * We have to generalise each decl (with its associated types) all at once: TcTyClsDecls.generaliseTyClDecl * The main new work is done in TcTyClsDecls.swizzleTcTyConBndrs * The mysterious TcHsSyn.zonkRecTyVarBndrs dies altogether Other smaller things: * A little refactoring, moving bindTyClTyVars from tcTyClDecl1 to tcDataDefn, tcSynRhs, etc. Clearer, reduces the number of parameters * Reduce the amount of swizzling required. Specifically, bindExplicitTKBndrs_Q_Tv doesn't need to clone a new Name for the TyVarTv, and not cloning means that in the vasly common case, swizzleTyConBndrs is a no-op In detail: Rename newTyVarTyVar --> cloneTyVarTyVar Add newTyVarTyTyVar that doesn't clone Use the non-cloning newTyVarTyVar in bindExplicitTKBndrs_Q_Tv Rename newFlexiKindedTyVarTyVar --> cloneFlexiKindedTyVarTyVar * Define new utility function and use it HsDecls.familyDeclName :: FamilyDecl (GhcPass p) -> IdP (GhcPass p) Updates haddock submodule. (cherry picked from commit b9605396f1f1560aea94792646b835cadcb49f45) - - - - - 540d5562 by Ben Gamari at 2020-06-02T10:07:07-04:00 CorePrep: Print type if we fail to split - - - - - 26386f0c by Ben Gamari at 2020-06-20T15:26:31-04:00 gitlab-ci: Introduce DWARF release jobs for Deb10 and Fedora 27 (cherry picked from commit 481e31740672a37c5b3a8924bba7e15c4080bc2e) - - - - - 408b6714 by Ben Gamari at 2020-07-15T11:26:48-04:00 gitlab-ci: Bump Docker images - - - - - 410f53a9 by Ben Gamari at 2020-07-15T11:26:48-04:00 hadrian: Eliminate some redundant imports - - - - - e2bed3ee by GHC GitLab CI at 2020-07-15T11:26:48-04:00 Accept testsuite changes - - - - - 5018cad4 by Kevin Buhr at 2020-07-15T11:26:48-04:00 Add "-Iw" RTS flag for minimum wait between idle GCs (#11134) This wasn't originally slated for 8.10 but the documentation part of this patch snuck into the ghc-8.10 branch via a backport. Instead of backing out the documentation and causing further user confusion I've opted just to backport this functional change as well. (cherry picked from commit 859ebdd446eda446d38708a587503c255b58c4c6) - - - - - edc36a91 by Ben Gamari at 2020-07-15T11:26:48-04:00 user-guide: Add release notes for 8.10.2 - - - - - 46e3ceca by Ben Gamari at 2020-07-15T11:27:30-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. (cherry picked from commit 8cc7274b8de254c7266b61fadbc6795dc37bd1e9) - - - - - ca146208 by Ben Gamari at 2020-07-15T11:27:40-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. (cherry picked from commit b835112cbeaa6e34a8bae7b7697bdf2826edaa9a) - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Hs/Decls.hs - compiler/GHC/HsToCore/PmCheck/Oracle.hs - compiler/cmm/Cmm.hs - compiler/cmm/PprC.hs - compiler/coreSyn/CorePrep.hs - compiler/deSugar/Coverage.hs - compiler/llvmGen/LlvmCodeGen/Data.hs - compiler/prelude/PrelInfo.hs - compiler/prelude/PrelNames.hs - compiler/prelude/TysWiredIn.hs - compiler/simplCore/SimplUtils.hs - compiler/specialise/Rules.hs - compiler/typecheck/TcHsSyn.hs - compiler/typecheck/TcHsType.hs - compiler/typecheck/TcInstDcls.hs - compiler/typecheck/TcMType.hs - compiler/typecheck/TcTyClsDecls.hs - compiler/types/TyCon.hs - + docs/users_guide/8.10.2-notes.rst - docs/users_guide/index.rst - hadrian/src/Hadrian/Utilities.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Builders/Ghc.hs - hadrian/src/Settings/Packages.hs - includes/rts/Flags.h - + libraries/ghc-compact/tests/T16992.hs - + libraries/ghc-compact/tests/T16992.stdout - libraries/ghc-compact/tests/all.T - libraries/process The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/79da3ca28d12306e5bc073d2f1b7ba130e12cd99...ca146208a210242904edde77633ef857200dd45f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/79da3ca28d12306e5bc073d2f1b7ba130e12cd99...ca146208a210242904edde77633ef857200dd45f You're receiving 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 Jul 16 00:20:47 2020 From: gitlab at gitlab.haskell.org (Simon Jakobi) Date: Wed, 15 Jul 2020 20:20:47 -0400 Subject: [Git][ghc/ghc][wip/sjakobi/update-containers] 145 commits: codeGen: Don't discard live case binders in unsafeEqualityProof logic Message-ID: <5f0f9d5fd8b61_80b3f8487097194329266b@gitlab.haskell.org.mail> Simon Jakobi pushed to branch wip/sjakobi/update-containers at Glasgow Haskell Compiler / GHC Commits: 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - a5bbaf0a by Simon Jakobi at 2020-07-16T02:15:50+02:00 Update containers to v0.6.3.1 See https://github.com/haskell/containers/issues/737 in case of doubt about the correct release tag. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/test-metrics.sh - .gitmodules - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/ProcPoint.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2db248150018080a901dcf3dcdaa4d6c741e385...a5bbaf0a8f93d969ebba89f7c8f12b30686f0f29 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2db248150018080a901dcf3dcdaa4d6c741e385...a5bbaf0a8f93d969ebba89f7c8f12b30686f0f29 You're receiving 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 Jul 16 01:43:21 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 15 Jul 2020 21:43:21 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] make it a Path! Message-ID: <5f0fb0b97f466_80b3f8486fb6f7c32949ea@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 8d0c0d95 by Moritz Angermann at 2020-07-16T01:43:09+00:00 make it a Path! - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -1652,7 +1652,7 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) -> # The test wrapper. Default to $TOP / driver / id # for the identity test-wrapper. if config.test_wrapper is None: - test_wrapper = config.top / "driver" / "id" + test_wrapper = Path(config.top) / "driver" / "id" else: test_wrapper = config.test_wrapper @@ -2370,7 +2370,7 @@ def does_ghostscript_work() -> bool: return False try: - if runCmd(genGSCmd(config.top / 'config' / 'good.ps')) != 0: + if runCmd(genGSCmd(Path(config.top) / 'config' / 'good.ps')) != 0: gsNotWorking("gs can't process good input") return False except Exception as e: @@ -2378,7 +2378,7 @@ def does_ghostscript_work() -> bool: return False try: - cmd = genGSCmd(config.top / 'config' / 'bad.ps') + ' >/dev/null 2>&1' + cmd = genGSCmd(Path(config.top) / 'config' / 'bad.ps') + ' >/dev/null 2>&1' if runCmd(cmd) == 0: gsNotWorking('gs accepts bad input') return False View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d0c0d9544c9b01e6e67d9646c68f4d01da0008a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d0c0d9544c9b01e6e67d9646c68f4d01da0008a You're receiving 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 Jul 16 03:39:49 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 15 Jul 2020 23:39:49 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/backports Message-ID: <5f0fcc05896ff_80bda8bdb433228bb@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/backports at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/backports You're receiving 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 Jul 16 03:47:34 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 15 Jul 2020 23:47:34 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] Drop left debug statement Message-ID: <5f0fcdd6a600c_80b3f848700d4d03323011@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 05b7696d by Moritz Angermann at 2020-07-16T03:47:18+00:00 Drop left debug statement - - - - - 1 changed file: - testsuite/tests/rts/T9579/all.T Changes: ===================================== testsuite/tests/rts/T9579/all.T ===================================== @@ -9,7 +9,6 @@ def T9579_run_test(binName, expExitCode): # 3. capture exitcode using echo # 4. replace actual number with NUM testCommandTemplate = """ - echo "TEST_WRAPPER=$TEST_WRAPPER" $MAKE -s --no-print-directory T9579_{binName} \ && ( ( "$TEST_WRAPPER" ./T9579_{binName} 2>&1; echo $?) \ | sed -e 's/[0-9]* bytes/NUM bytes/g' ) \ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/05b7696ddad183d51698895164473fef34640de3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/05b7696ddad183d51698895164473fef34640de3 You're receiving 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 Jul 16 03:55:27 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 15 Jul 2020 23:55:27 -0400 Subject: [Git][ghc/ghc][wip/T18281] 98 commits: Enable large address space optimization on windows. Message-ID: <5f0fcfaf48352_80bda8bdb4332765d@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18281 at Glasgow Haskell Compiler / GHC Commits: 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - b5991f01 by Ben Gamari at 2020-07-15T23:55:23-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/test-metrics.sh - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2dee9ba9b690cb4eb6a897b7f636cbd68ed5cc59...b5991f01753f30cd8c72a74c87a1f1cbcef6a814 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2dee9ba9b690cb4eb6a897b7f636cbd68ed5cc59...b5991f01753f30cd8c72a74c87a1f1cbcef6a814 You're receiving 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 Jul 16 03:57:10 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 15 Jul 2020 23:57:10 -0400 Subject: [Git][ghc/ghc][wip/backports] 8 commits: [linker/rtsSymbols] More linker symbols Message-ID: <5f0fd0164f6f5_80b3f848a2b147c3330254@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: aa2e5863 by Moritz Angermann at 2020-07-15T23:42:39-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC (cherry picked from commit 5bc6082fdcb278be878f01a2eeb9741d7d82bb49) - - - - - dfffd9eb by Artem Pelenitsyn at 2020-07-15T23:50:11-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. (cherry picked from commit af5e3a885ddd09dd5f550552c535af3661ff3dbf) - - - - - 93c06518 by Moritz Angermann at 2020-07-15T23:51:27-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. (cherry picked from commit b455074875d3c8fd3a5787e01dc6f922f3a97bc2) - - - - - b33a20c5 by Moritz Angermann at 2020-07-15T23:51:39-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. (cherry picked from commit 3fd12af1eaafe304e5916bc1fcfdf31709d360b8) - - - - - 6560fa8f by Moritz Angermann at 2020-07-15T23:52:20-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf (cherry picked from commit f2446ff1578a37822488e0e3968694f66712b969) - - - - - 820d9ed2 by Ben Gamari at 2020-07-15T23:55:55-04:00 testsuite: Add test for #18151 (cherry picked from commit bd9f558924755f965f5136b5e3d4fa88d34c9778) - - - - - be443156 by Ben Gamari at 2020-07-15T23:56:02-04:00 testsuite: Add test for desugaring of PostfixOperators (cherry picked from commit 95a9eb7396912314f6cfd971fb4523e4062acec6) - - - - - cc8800f9 by Ben Gamari at 2020-07-15T23:56:42-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. (cherry picked from commit b1dbd625493ae1bf984cf51177011baf9c677c0a) - - - - - 11 changed files: - compiler/deSugar/DsExpr.hs - libraries/base/GHC/Float.hs - libraries/ghc-prim/ghc-prim.cabal - rts/RtsSymbols.c - rts/linker/LoadArchive.c - rts/linker/elf_reloc_aarch64.c - + testsuite/tests/deSugar/should_run/DsPostfixOperators.hs - + testsuite/tests/deSugar/should_run/DsPostfixOperators.stdout - + testsuite/tests/deSugar/should_run/T18151.hs - + testsuite/tests/deSugar/should_run/T18151.stdout - testsuite/tests/deSugar/should_run/all.T Changes: ===================================== compiler/deSugar/DsExpr.hs ===================================== @@ -331,26 +331,47 @@ Then we get That 'g' in the 'in' part is an evidence variable, and when converting to core it must become a CO. -Operator sections. At first it looks as if we can convert -\begin{verbatim} - (expr op) -\end{verbatim} -to -\begin{verbatim} - \x -> op expr x -\end{verbatim} + +Note [Desugaring operator sections] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +At first it looks as if we can convert + + (expr `op`) + +naively to + + \x -> op expr x But no! expr might be a redex, and we can lose laziness badly this way. Consider -\begin{verbatim} - map (expr op) xs -\end{verbatim} -for example. So we convert instead to -\begin{verbatim} - let y = expr in \x -> op y x -\end{verbatim} -If \tr{expr} is actually just a variable, say, then the simplifier -will sort it out. + + map (expr `op`) xs + +for example. If expr were a redex then eta-expanding naively would +result in multiple evaluations where the user might only have expected one. + +So we convert instead to + + let y = expr in \x -> op y x + +Also, note that we must do this for both right and (perhaps surprisingly) left +sections. Why are left sections necessary? Consider the program (found in #18151), + + seq (True `undefined`) () + +according to the Haskell Report this should reduce to () (as it specifies +desugaring via eta expansion). However, if we fail to eta expand we will rather +bottom. Consequently, we must eta expand even in the case of a left section. + +If `expr` is actually just a variable, say, then the simplifier +will inline `y`, eliminating the redundant `let`. + +Note that this works even in the case that `expr` is unlifted. In this case +bindNonRec will automatically do the right thing, giving us: + + case expr of y -> (\x -> op y x) + +See #18151. -} ds_expr _ e@(OpApp _ e1 op e2) @@ -359,17 +380,35 @@ ds_expr _ e@(OpApp _ e1 op e2) ; dsWhenNoErrs (mapM dsLExprNoLP [e1, e2]) (\exprs' -> mkCoreAppsDs (text "opapp" <+> ppr e) op' exprs') } -ds_expr _ (SectionL _ expr op) -- Desugar (e !) to ((!) e) - = do { op' <- dsLExpr op - ; dsWhenNoErrs (dsLExprNoLP expr) - (\expr' -> mkCoreAppDs (text "sectionl" <+> ppr expr) op' expr') } - --- dsLExpr (SectionR op expr) -- \ x -> op x expr +-- dsExpr (SectionL op expr) === (expr `op`) ~> \y -> op expr y +-- +-- See Note [Desugaring operator sections]. +-- N.B. this also must handle postfix operator sections due to -XPostfixOperators. +ds_expr _ e@(SectionL _ expr op) = do + core_op <- dsLExpr op + x_core <- dsLExpr expr + case splitFunTys (exprType core_op) of + -- Binary operator section + (x_ty:y_ty:_, _) -> do + dsWhenNoErrs + (mapM newSysLocalDsNoLP [x_ty, y_ty]) + (\[x_id, y_id] -> + bindNonRec x_id x_core + $ Lam y_id (mkCoreAppsDs (text "sectionl" <+> ppr e) + core_op [Var x_id, Var y_id])) + + -- Postfix operator section + (_:_, _) -> do + return $ mkCoreAppDs (text "sectionl" <+> ppr e) core_op x_core + + _ -> pprPanic "dsExpr(SectionL)" (ppr e) + +-- dsExpr (SectionR op expr) === (`op` expr) ~> \x -> op x expr +-- +-- See Note [Desugaring operator sections]. ds_expr _ e@(SectionR _ op expr) = do core_op <- dsLExpr op - -- for the type of x, we need the type of op's 2nd argument let (x_ty:y_ty:_, _) = splitFunTys (exprType core_op) - -- See comment with SectionL y_core <- dsLExpr expr dsWhenNoErrs (mapM newSysLocalDsNoLP [x_ty, y_ty]) (\[x_id, y_id] -> bindNonRec y_id y_core $ ===================================== libraries/base/GHC/Float.hs ===================================== @@ -141,6 +141,14 @@ class (Fractional a) => Floating a where log1pexp x = log1p (exp x) log1mexp x = log1p (negate (exp x)) +-- | Default implementation for @'log1mexp'@ requiring @'Ord'@ to test +-- against a threshold to decide which implementation variant to use. +log1mexpOrd :: (Ord a, Floating a) => a -> a +{-# INLINE log1mexpOrd #-} +log1mexpOrd a + | a > -(log 2) = log (negate (expm1 a)) + | otherwise = log1p (negate (exp a)) + -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat a where @@ -398,9 +406,7 @@ instance Floating Float where log1p = log1pFloat expm1 = expm1Float - log1mexp a - | a <= log 2 = log (negate (expm1Float a)) - | otherwise = log1pFloat (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pFloat (exp a) @@ -539,9 +545,7 @@ instance Floating Double where log1p = log1pDouble expm1 = expm1Double - log1mexp a - | a <= log 2 = log (negate (expm1Double a)) - | otherwise = log1pDouble (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pDouble (exp a) ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -67,6 +67,11 @@ Library -- on Windows. Required because of mingw32. extra-libraries: user32, mingw32, mingwex + if os(linux) + -- we need libm, but for musl and other's we might need libc, as libm + -- is just an empty shell. + extra-libraries: c, m + c-sources: cbits/atomic.c cbits/bswap.c ===================================== rts/RtsSymbols.c ===================================== @@ -58,7 +58,6 @@ SymI_HasProto(signal_handlers) \ SymI_HasProto(stg_sig_install) \ SymI_HasProto(rtsTimerSignal) \ - SymI_HasProto(atexit) \ SymI_NeedsDataProto(nocldstop) #endif @@ -977,29 +976,213 @@ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS - // 64-bit support functions in libgcc.a -#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) -#define RTS_LIBGCC_SYMBOLS \ - SymI_NeedsProto(__divdi3) \ - SymI_NeedsProto(__udivdi3) \ - SymI_NeedsProto(__moddi3) \ - SymI_NeedsProto(__umoddi3) \ - SymI_NeedsProto(__muldi3) \ - SymI_NeedsProto(__ashldi3) \ - SymI_NeedsProto(__ashrdi3) \ - SymI_NeedsProto(__lshrdi3) \ - SymI_NeedsProto(__fixunsdfdi) -#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 -#define RTS_LIBGCC_SYMBOLS \ +// See https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc +#define RTS_LIBGCC_SYMBOLS_32 \ + SymI_NeedsProto(__fixunsdfdi) \ + /* 4 The GCC low-level runtime library */\ + /* 4.1.1 Arithmetic functions */\ + /* SymI_NeedsProto(__ashlsi3) */\ + SymI_NeedsProto(__ashldi3) \ + /* SymI_NeedsProto(__ashlti3) */\ + /* These functions return the result of shifting a left by b bits. */\ + /* SymI_NeedsProto(__ashrsi3) */\ + SymI_NeedsProto(__ashrdi3) \ + /* SymI_NeedsProto(__ashrti3) */\ + /* These functions return the result of arithmetically shifting a right by b bits. */\ + /* SymI_NeedsProto(__divsi3) */\ + SymI_NeedsProto(__divdi3) \ + /* SymI_NeedsProto(__divti3) */\ + /* These functions return the quotient of the signed division of a and b. */\ + /* SymI_NeedsProto(__lshrsi3) */ \ + SymI_NeedsProto(__lshrdi3) \ + /* SymI_NeedsProto(__lshrti3) */ \ + /* These functions return the result of logically shifting a right by b bits. */\ + /* SymI_NeedsProto(__modsi3) */ \ + SymI_NeedsProto(__moddi3) \ + /* SymI_NeedsProto(__modti3) */ \ + /* These functions return the remainder of the signed division of a and b. */\ + /* SymI_NeedsProto(__mulsi3) */ \ + SymI_NeedsProto(__muldi3) \ + /* SymI_NeedsProto(__multi3) */ \ + /* These functions return the product of a and b. */\ + SymI_NeedsProto(__negdi2) \ + /* SymI_NeedsProto(__negti2) */ \ + /* These functions return the negation of a. */\ + /* SymI_NeedsProto(__udivsi3) */ \ + SymI_NeedsProto(__udivdi3) \ + /* SymI_NeedsProto(__udivti3) */ \ + /* These functions return the quotient of the unsigned division of a and b. */\ + SymI_NeedsProto(__udivmoddi4) \ + /* SymI_NeedsProto(__udivmodti4) */ \ + /* These functions calculate both the quotient and remainder of the unsigned division of a and b. The return value is the quotient, and the remainder is placed in variable pointed to by c. */\ + /* SymI_NeedsProto(__umodsi3) */ \ + SymI_NeedsProto(__umoddi3) \ + /* SymI_NeedsProto(__umodti3) */ \ + /* These functions return the remainder of the unsigned division of a and b. */\ + /* 4.1.2 Comparison functions */\ + /* The following functions implement integral comparisons. These functions implement a low-level compare, upon which the higher level comparison operators (such as less than and greater than or equal to) can be constructed. The returned values lie in the range zero to two, to allow the high-level operators to be implemented by testing the returned result using either signed or unsigned comparison. */\ + SymI_NeedsProto(__cmpdi2) \ + /* SymI_NeedsProto(__cmpti2) */ \ + /* These functions perform a signed comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\ + SymI_NeedsProto(__ucmpdi2) \ + /* SymI_NeedsProto(__ucmpti2) */ \ + /* These functions perform an unsigned comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\ + /* 4.1.3 Trapping arithmetic functions */\ + /* The following functions implement trapping arithmetic. These functions call the libc function abort upon signed arithmetic overflow. */\ + SymI_NeedsProto(__absvsi2) \ + SymI_NeedsProto(__absvdi2) \ + /* These functions return the absolute value of a. */\ + /* SymI_NeedsProto(__addvsi3) */ \ + SymI_NeedsProto(__addvdi3) \ + /* These functions return the sum of a and b; that is a + b. */\ + /* SymI_NeedsProto(__mulvsi3) */ \ + SymI_NeedsProto(__mulvdi3) \ + /* The functions return the product of a and b; that is a * b. */\ + SymI_NeedsProto(__negvsi2) \ + SymI_NeedsProto(__negvdi2) \ + /* These functions return the negation of a; that is -a. */\ + /* SymI_NeedsProto(__subvsi3) */ \ + SymI_NeedsProto(__subvdi3) \ + /* These functions return the difference between b and a; that is a - b. */\ + /* 4.1.4 Bit operations */\ + SymI_NeedsProto(__clzsi2) \ + SymI_NeedsProto(__clzdi2) \ + /* SymI_NeedsProto(__clzti2) */ \ + /* These functions return the number of leading 0-bits in a, starting at the most significant bit position. If a is zero, the result is undefined. */\ + SymI_NeedsProto(__ctzsi2) \ + SymI_NeedsProto(__ctzdi2) \ + /* SymI_NeedsProto(__ctzti2) */ \ + /* These functions return the number of trailing 0-bits in a, starting at the least significant bit position. If a is zero, the result is undefined. */\ + SymI_NeedsProto(__ffsdi2) \ + /* SymI_NeedsProto(__ffsti2) */ \ + /* These functions return the index of the least significant 1-bit in a, or the value zero if a is zero. The least significant bit is index one. */\ + SymI_NeedsProto(__paritysi2) \ + SymI_NeedsProto(__paritydi2) \ + /* SymI_NeedsProto(__parityti2) */\ + /* These functions return the value zero if the number of bits set in a is even, and the value one otherwise. */\ + SymI_NeedsProto(__popcountsi2) \ + SymI_NeedsProto(__popcountdi2) \ + /* SymI_NeedsProto(__popcountti2) */ \ + /* These functions return the number of bits set in a. */\ + SymI_NeedsProto(__bswapsi2) \ + SymI_NeedsProto(__bswapdi2) +#define RTS_LIBGCC_SYMBOLS_aarch32 \ + /* armv6l */\ + /* TODO: should check for __ARM_EABI__ */\ + SymI_NeedsProto(__aeabi_d2f) \ + SymI_NeedsProto(__aeabi_d2iz) \ + SymI_NeedsProto(__aeabi_d2lz) \ + SymI_NeedsProto(__aeabi_d2uiz) \ + SymI_NeedsProto(__aeabi_d2ulz) \ + SymI_NeedsProto(__aeabi_dadd) \ + SymI_NeedsProto(__aeabi_dcmpeq) \ + SymI_NeedsProto(__aeabi_dcmpge) \ + SymI_NeedsProto(__aeabi_dcmpgt) \ + SymI_NeedsProto(__aeabi_dcmple) \ + SymI_NeedsProto(__aeabi_dcmplt) \ + SymI_NeedsProto(__aeabi_dcmpun) \ + SymI_NeedsProto(__aeabi_ddiv) \ + SymI_NeedsProto(__aeabi_dmul) \ + SymI_NeedsProto(__aeabi_dneg) \ + SymI_NeedsProto(__aeabi_dsub) \ + SymI_NeedsProto(__aeabi_f2d) \ + SymI_NeedsProto(__aeabi_f2iz) \ + SymI_NeedsProto(__aeabi_f2lz) \ + SymI_NeedsProto(__aeabi_f2uiz) \ + SymI_NeedsProto(__aeabi_f2ulz) \ + SymI_NeedsProto(__aeabi_fadd) \ + SymI_NeedsProto(__aeabi_fcmpeq) \ + SymI_NeedsProto(__aeabi_fcmpge) \ + SymI_NeedsProto(__aeabi_fcmpgt) \ + SymI_NeedsProto(__aeabi_fcmple) \ + SymI_NeedsProto(__aeabi_fcmplt) \ + SymI_NeedsProto(__aeabi_fcmpun) \ + SymI_NeedsProto(__aeabi_fdiv) \ + SymI_NeedsProto(__aeabi_fmul) \ + SymI_NeedsProto(__aeabi_fneg) \ + SymI_NeedsProto(__aeabi_fsub) \ + SymI_NeedsProto(__aeabi_i2d) \ + SymI_NeedsProto(__aeabi_i2f) \ + SymI_NeedsProto(__aeabi_idiv) \ + SymI_NeedsProto(__aeabi_idivmod) \ + SymI_NeedsProto(__aeabi_l2d) \ + SymI_NeedsProto(__aeabi_l2f) \ + SymI_NeedsProto(__aeabi_lasr) \ + SymI_NeedsProto(__aeabi_lcmp) \ + SymI_NeedsProto(__aeabi_ldivmod) \ + SymI_NeedsProto(__aeabi_llsl) \ + SymI_NeedsProto(__aeabi_llsr) \ + SymI_NeedsProto(__aeabi_lmul) \ + SymI_NeedsProto(__aeabi_ui2d) \ + SymI_NeedsProto(__aeabi_ui2f) \ + SymI_NeedsProto(__aeabi_uidiv) \ + SymI_NeedsProto(__aeabi_uidivmod) \ + SymI_NeedsProto(__aeabi_ul2d) \ + SymI_NeedsProto(__aeabi_ul2f) \ + SymI_NeedsProto(__aeabi_ulcmp) \ + SymI_NeedsProto(__aeabi_uldivmod) +#define RTS_LIBGCC_SYMBOLS_64 \ SymI_NeedsProto(__udivti3) \ SymI_NeedsProto(__umodti3) + +/* for aarch64 */ +#define RTS_LIBGCC_SYMBOLS_aarch64 \ + SymI_NeedsProto(__netf2) \ + SymI_NeedsProto(__addtf3) \ + SymI_NeedsProto(__subtf3) \ + SymI_NeedsProto(__multf3) \ + SymI_NeedsProto(__extenddftf2) \ + SymI_NeedsProto(__fixtfsi) \ + SymI_NeedsProto(__fixunstfsi) \ + SymI_NeedsProto(__floatsitf) \ + SymI_NeedsProto(__floatunsitf) + +#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && defined(arm_HOST_OS) +#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 RTS_LIBGCC_SYMBOLS_aarch32 +#elif defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) +#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 +#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 && defined(aarch64_HOST_OS) +#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 RTS_LIBGCC_SYMBOLS_aarch64 +#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 +#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 #else #define RTS_LIBGCC_SYMBOLS #endif +#if !defined(mingw32_HOST_OS) && !defined(DYNAMIC) && (defined(_FORTIFY_SOURCE) || defined(__SSP__)) +#define RTS_SSP_SYMBOLS \ + SymI_NeedsProto(__stack_chk_guard) \ + SymI_NeedsProto(__stack_chk_fail) +#else +#define RTS_SSP_SYMBOLS +#endif +#if !defined(DYNAMIC) && defined(linux_HOST_OS) +// we need these for static musl builds. However when +// linking shared objects (DLLs) this will fail, hence +// we do not include them when building with -DDYNAMIC +#define RTS_LINKER_SYMBOLS \ + SymI_NeedsProto(__fini_array_start) \ + SymI_NeedsProto(__fini_array_end) +#else +#define RTS_LINKER_SYMBOLS +#endif + +#if defined(darwin_HOST_OS) && defined(powerpc_HOST_ARCH) + // Symbols that don't have a leading underscore + // on Mac OS X. They have to receive special treatment, + // see machoInitSymbolsWithoutUnderscore() +#define RTS_MACHO_NOUNDERLINE_SYMBOLS \ + SymI_NeedsProto(saveFP) \ + SymI_NeedsProto(restFP) +#endif + /* entirely bogus claims about types of these symbols */ -#define SymI_NeedsProto(vvv) extern void vvv(void); +/* to prevent a bit of define expansion, SymI_NeedsProto is a variadic + * macro. And we'll concat vvv with the __VA_ARGS__. This prevents + * vvv from getting macro expanded. + */ +#define SymI_NeedsProto(vvv,...) extern void vvv ## __VA_ARGS__ (void); #define SymI_NeedsDataProto(vvv) extern StgWord vvv[]; #if defined(COMPILING_WINDOWS_DLL) #define SymE_HasProto(vvv) SymE_HasProto(vvv); @@ -1026,6 +1209,8 @@ RTS_DARWIN_ONLY_SYMBOLS RTS_OPENBSD_ONLY_SYMBOLS RTS_LIBGCC_SYMBOLS RTS_LIBFFI_SYMBOLS +RTS_SSP_SYMBOLS +RTS_LINKER_SYMBOLS #undef SymI_NeedsProto #undef SymI_NeedsDataProto #undef SymI_HasProto @@ -1045,7 +1230,7 @@ RTS_LIBFFI_SYMBOLS #define SymE_HasDataProto(vvv) \ SymE_HasProto(vvv) -#define SymI_NeedsProto(vvv) SymI_HasProto(vvv) +#define SymI_NeedsProto(vvv,...) SymI_HasProto(vvv ## __VA_ARGS__) #define SymI_NeedsDataProto(vvv) SymI_HasDataProto(vvv) #define SymE_NeedsProto(vvv) SymE_HasProto(vvv) #define SymE_NeedsDataProto(vvv) SymE_HasDataProto(vvv) @@ -1066,6 +1251,8 @@ RTS_LIBFFI_SYMBOLS #define SymI_HasProto_deprecated(vvv) \ { #vvv, (void*)0xBAADF00D, true }, +void *RTS_DYNAMIC = NULL; + RtsSymbolVal rtsSyms[] = { RTS_SYMBOLS RTS_RET_SYMBOLS @@ -1077,11 +1264,14 @@ RtsSymbolVal rtsSyms[] = { RTS_LIBGCC_SYMBOLS RTS_LIBFFI_SYMBOLS SymI_HasDataProto(nonmoving_write_barrier_enabled) + RTS_SSP_SYMBOLS + RTS_LINKER_SYMBOLS #if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH) // dyld stub code contains references to this, // but it should never be called because we treat // lazy pointers as nonlazy. { "dyld_stub_binding_helper", (void*)0xDEADBEEF, false }, #endif + { "_DYNAMIC", (void*)(&RTS_DYNAMIC), false }, { 0, 0, false } /* sentinel */ }; ===================================== rts/linker/LoadArchive.c ===================================== @@ -461,6 +461,7 @@ static HsInt loadArchive_ (pathchar *path) /* TODO: Stop relying on file extensions to determine input formats. Instead try to match file headers. See #13103. */ isObject = (thisFileNameSize >= 2 && strncmp(fileName + thisFileNameSize - 2, ".o" , 2) == 0) + || (thisFileNameSize >= 3 && strncmp(fileName + thisFileNameSize - 3, ".lo" , 3) == 0) || (thisFileNameSize >= 4 && strncmp(fileName + thisFileNameSize - 4, ".p_o", 4) == 0) || (thisFileNameSize >= 4 && strncmp(fileName + thisFileNameSize - 4, ".obj", 4) == 0); ===================================== rts/linker/elf_reloc_aarch64.c ===================================== @@ -93,12 +93,14 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) { // ... hi ] [ Rd ] // // imm64 = SignExtend(hi:lo:0x000,64) - assert(isInt64(32, addend)); + // Range is 21 bits + the 12 page relative bits + // known to be 0. -2^32 <= X < 2^32 + assert(isInt64(21+12, addend)); assert((addend & 0xfff) == 0); /* page relative */ *(inst_t *)P = (*(inst_t *)P & 0x9f00001f) - | (inst_t) (((uint64_t) addend << 17) & 0x60000000) - | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0); + | (inst_t) (((uint64_t) addend << 17) & 0x60000000) + | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0); break; } /* - control flow relocations */ @@ -111,8 +113,8 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) { break; } case COMPAT_R_AARCH64_ADR_GOT_PAGE: { - - assert(isInt64(32, addend)); /* X in range */ + /* range is -2^32 <= X < 2^32 */ + assert(isInt64(21+12, addend)); /* X in range */ assert((addend & 0xfff) == 0); /* page relative */ *(inst_t *)P = (*(inst_t *)P & 0x9f00001f) ===================================== testsuite/tests/deSugar/should_run/DsPostfixOperators.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE PostfixOperators #-} + +main :: IO () +main = do + print (42 `negate`) ===================================== testsuite/tests/deSugar/should_run/DsPostfixOperators.stdout ===================================== @@ -0,0 +1,2 @@ +-42 + ===================================== testsuite/tests/deSugar/should_run/T18151.hs ===================================== @@ -0,0 +1,10 @@ +-- According to the Report this should reduce to (). However, in #18151 it was +-- reported that GHC bottoms. +x :: () +x = seq (True `undefined`) () +{-# NOINLINE x #-} + +main :: IO () +main = do + print x + ===================================== testsuite/tests/deSugar/should_run/T18151.stdout ===================================== @@ -0,0 +1 @@ +() \ No newline at end of file ===================================== testsuite/tests/deSugar/should_run/all.T ===================================== @@ -57,9 +57,11 @@ test('T10215', normal, compile_and_run, ['']) test('DsStrictData', normal, compile_and_run, ['']) test('DsStrict', normal, compile_and_run, ['']) test('DsStrictLet', normal, compile_and_run, ['-O']) +test('DsPostfixOperators', normal, compile_and_run, ['']) test('T11193', exit_code(1), compile_and_run, ['']) test('T11572', exit_code(1), compile_and_run, ['']) test('T11601', exit_code(1), compile_and_run, ['']) test('T11747', normal, compile_and_run, ['-dcore-lint']) test('T12595', normal, compile_and_run, ['']) test('T13285', normal, compile_and_run, ['']) +test('T18151', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9770ef3821b1539f24c7207ac50c04597856b65...cc8800f9f482460ceb2d450137766e0350551740 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9770ef3821b1539f24c7207ac50c04597856b65...cc8800f9f482460ceb2d450137766e0350551740 You're receiving 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 Jul 16 07:13:41 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Thu, 16 Jul 2020 03:13:41 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] Better TEST_WRAPPER injection. Message-ID: <5f0ffe2557535_80b3f848a2b147c333813d@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: cdb0d3ea by Moritz Angermann at 2020-07-16T07:13:26+00:00 Better TEST_WRAPPER injection. - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -1643,12 +1643,11 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) -> else: stats_args = '' + # 1. Build command # Put extra_run_opts last: extra_run_opts('+RTS foo') should work. cmd = ' '.join([prog, stats_args, my_rts_flags, extra_run_opts]) - if opts.cmd_wrapper is not None: - cmd = opts.cmd_wrapper(cmd) - + # 2. prefix with TEST_WRAPPER # The test wrapper. Default to $TOP / driver / id # for the identity test-wrapper. if config.test_wrapper is None: @@ -1656,9 +1655,15 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) -> else: test_wrapper = config.test_wrapper - cmd = 'cd "{opts.testdir}" && TEST_WRAPPER="{test_wrapper}" {cmd}'.format(**locals()) + cmd = 'TEST_WRAPPER="{test_wrapper}" && {cmd}'.format(**locals()) + + # 3. Apply cmd_wrapper if set. + if opts.cmd_wrapper is not None: + cmd = opts.cmd_wrapper(cmd) + + cmd = 'cd "{opts.testdir}" && {cmd}'.format(**locals()) - # run the command + # 4. Finally, run the command exit_code = runCmd(cmd, stdin_arg, stdout_arg, stderr_arg, opts.run_timeout_multiplier) # check the exit code View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdb0d3ea29109e4d409d415cfe19d84fc949e7af -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdb0d3ea29109e4d409d415cfe19d84fc949e7af You're receiving 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 Jul 16 09:20:30 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Thu, 16 Jul 2020 05:20:30 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] Split wrapper and prefix Message-ID: <5f101bde3258f_80bda8bdb4334923d@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 6fe49760 by Moritz Angermann at 2020-07-16T09:20:12+00:00 Split wrapper and prefix - - - - - 2 changed files: - testsuite/driver/testglobals.py - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testglobals.py ===================================== @@ -371,6 +371,9 @@ class TestOptions: # Command to run before the test self.pre_cmd = None + # Command prefix: a function to add a prefix to the command before running it + self.cmd_prefix = None + # Command wrapper: a function to apply to the command before running it self.cmd_wrapper = None ===================================== testsuite/driver/testlib.py ===================================== @@ -678,7 +678,7 @@ def cmd_prefix( prefix ): return lambda name, opts, p=prefix: _cmd_prefix(name, opts, prefix) def _cmd_prefix( name, opts, prefix ): - opts.cmd_wrapper = lambda cmd, p=prefix: p + ' ' + cmd; + opts.cmd_prefix = lambda cmd, p=prefix: p + ' ' + cmd; # ---- @@ -1647,7 +1647,13 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) -> # Put extra_run_opts last: extra_run_opts('+RTS foo') should work. cmd = ' '.join([prog, stats_args, my_rts_flags, extra_run_opts]) - # 2. prefix with TEST_WRAPPER + # 2. Apply the command prefix. This needs to happen before we apply + # the test-wrapper. + + if opts.cmd_prefix is not None: + cmd = opts.cmd_prefix(cmd) + + # 3. prefix with TEST_WRAPPER # The test wrapper. Default to $TOP / driver / id # for the identity test-wrapper. if config.test_wrapper is None: @@ -1657,13 +1663,13 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) -> cmd = 'TEST_WRAPPER="{test_wrapper}" && {cmd}'.format(**locals()) - # 3. Apply cmd_wrapper if set. + # 4. Apply cmd_wrapper if set. if opts.cmd_wrapper is not None: cmd = opts.cmd_wrapper(cmd) cmd = 'cd "{opts.testdir}" && {cmd}'.format(**locals()) - # 4. Finally, run the command + # 5. Finally, run the command exit_code = runCmd(cmd, stdin_arg, stdout_arg, stderr_arg, opts.run_timeout_multiplier) # check the exit code @@ -1751,6 +1757,9 @@ def interpreter_run(name: TestName, cmd = ('{{compiler}} {srcname} {flags} {extra_hc_opts}' ).format(**locals()) + if opts.cmd_prefix is not None: + cmd = opts.cmd_prefix(cmd); + if opts.cmd_wrapper is not None: cmd = opts.cmd_wrapper(cmd); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6fe49760d3c03f492a9712220584988b25cbdb9d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6fe49760d3c03f492a9712220584988b25cbdb9d You're receiving 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 Jul 16 10:25:19 2020 From: gitlab at gitlab.haskell.org (Simon Jakobi) Date: Thu, 16 Jul 2020 06:25:19 -0400 Subject: [Git][ghc/ghc][wip/sjakobi/update-containers] Update containers to v0.6.3.1 Message-ID: <5f102b0fb2498_80b3f8486fb6f7c3350945@gitlab.haskell.org.mail> Simon Jakobi pushed to branch wip/sjakobi/update-containers at Glasgow Haskell Compiler / GHC Commits: 211f9526 by Simon Jakobi at 2020-07-16T12:25:03+02:00 Update containers to v0.6.3.1 See https://github.com/haskell/containers/issues/737 in case of doubt about the correct release tag. - - - - - 2 changed files: - libraries/containers - testsuite/tests/driver/T10970.stdout Changes: ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit aaeda192b34a66b1c5359a85271adf8fed26dd12 +Subproject commit 97fe43c54c5c8a9b93ecf5abd7509e8085b63d41 ===================================== testsuite/tests/driver/T10970.stdout ===================================== @@ -1,2 +1,2 @@ -0.6.2.1 +0.6.3.1 OK View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/211f9526c3662a443e3564a8aebb87290aa75a67 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/211f9526c3662a443e3564a8aebb87290aa75a67 You're receiving 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 Jul 16 11:13:57 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 16 Jul 2020 07:13:57 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: StgToCmm: Use CmmRegOff smart constructor Message-ID: <5f10367555633_80b3f8486fb6f7c3354483@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - b5991f01 by Ben Gamari at 2020-07-15T23:55:23-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - f02edd80 by Krzysztof Gogolewski at 2020-07-16T07:13:51-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - 19 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/StgToCmm/CgUtils.hs - compiler/GHC/Tc/Gen/Expr.hs - docs/users_guide/runtime_control.rst - rts/RtsFlags.c - testsuite/tests/ghc-api/annotations/T10313.stdout - testsuite/tests/ghc-api/annotations/Test10313.hs - testsuite/tests/ghc-api/annotations/stringSource.hs - testsuite/tests/printer/Ppr009.hs - + testsuite/tests/simplCore/should_run/T17744.hs - + testsuite/tests/simplCore/should_run/T17744.stdout - + testsuite/tests/simplCore/should_run/T17744A.hs - testsuite/tests/simplCore/should_run/all.T - utils/haddock Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -829,14 +829,6 @@ data HsPragE p SourceText -- Note [Pragma source text] in GHC.Types.Basic StringLiteral -- "set cost centre" SCC pragma - -- | - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnOpen' @'{-\# CORE'@, - -- 'GHC.Parser.Annotation.AnnVal', 'GHC.Parser.Annotation.AnnClose' @'\#-}'@ - - -- For details on above see note [Api annotations] in GHC.Parser.Annotation - | HsPragCore (XCoreAnn p) - SourceText -- Note [Pragma source text] in GHC.Types.Basic - StringLiteral -- hdaume: core annotation - -- | - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnOpen', -- 'GHC.Parser.Annotation.AnnOpen' @'{-\# GENERATED'@, -- 'GHC.Parser.Annotation.AnnVal','GHC.Parser.Annotation.AnnVal', @@ -1399,9 +1391,6 @@ isAtomicHsExpr (XExpr x) isAtomicHsExpr _ = False instance Outputable (HsPragE (GhcPass p)) where - ppr (HsPragCore _ stc (StringLiteral sta s)) = - pprWithSourceText stc (text "{-# CORE") - <+> pprWithSourceText sta (doubleQuotes $ ftext s) <+> text "#-}" ppr (HsPragSCC _ st (StringLiteral stl lbl)) = pprWithSourceText st (text "{-# SCC") -- no doublequotes if stl empty, for the case where the SCC was written ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -820,8 +820,6 @@ ds_prag_expr (HsPragSCC _ _ cc) expr = do Tick (ProfNote (mkUserCC nm mod_name (getLoc expr) flavour) count True) <$> dsLExpr expr else dsLExpr expr -ds_prag_expr (HsPragCore _ _ _) expr - = dsLExpr expr ds_prag_expr (HsPragTick _ _ _ _) expr = do dflags <- getDynFlags if gopt Opt_Hpc dflags ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -1570,7 +1570,6 @@ repE (HsUnboundVar _ uv) = do sname <- repNameS occ repUnboundVar sname repE (XExpr (HsExpanded _ b)) = repE b -repE e@(HsPragE _ HsPragCore {} _) = notHandled "Core annotations" (ppr e) repE e@(HsPragE _ HsPragSCC {} _) = notHandled "Cost centres" (ppr e) repE e@(HsPragE _ HsPragTick {} _) = notHandled "Tick Pragma" (ppr e) repE e = notHandled "Expression form" (ppr e) ===================================== compiler/GHC/Parser.y ===================================== @@ -521,7 +521,6 @@ are the most common patterns, rewritten as regular expressions for clarity: '{-# SPECIALISE_INLINE' { L _ (ITspec_inline_prag _ _) } '{-# SOURCE' { L _ (ITsource_prag _) } '{-# RULES' { L _ (ITrules_prag _) } - '{-# CORE' { L _ (ITcore_prag _) } -- hdaume: annotated core '{-# SCC' { L _ (ITscc_prag _)} '{-# GENERATED' { L _ (ITgenerated_prag _) } '{-# DEPRECATED' { L _ (ITdeprecated_prag _) } @@ -2695,7 +2694,7 @@ optSemi :: { ([Located Token],Bool) } {- Note [Pragmas and operator fixity] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -'prag_e' is an expression pragma, such as {-# SCC ... #-}, {-# CORE ... #-}, or +'prag_e' is an expression pragma, such as {-# SCC ... #-} or {-# GENERATED ... #-}. It must be used with care, or else #15730 happens. Consider this infix @@ -2764,11 +2763,6 @@ prag_e :: { Located ([AddAnn], HsPragE GhcPs) } (getINT $7, getINT $9)) ((getINTEGERs $3, getINTEGERs $5), (getINTEGERs $7, getINTEGERs $9) )) } - | '{-# CORE' STRING '#-}' - { sLL $1 $> $ - ([mo $1,mj AnnVal $2,mc $3], - HsPragCore noExtField (getCORE_PRAGs $1) (getStringLiteral $2)) } - fexp :: { ECP } : fexp aexp { ECP $ superFunArg $ @@ -3915,7 +3909,6 @@ getWARNING_PRAGs (L _ (ITwarning_prag src)) = src getDEPRECATED_PRAGs (L _ (ITdeprecated_prag src)) = src getSCC_PRAGs (L _ (ITscc_prag src)) = src getGENERATED_PRAGs (L _ (ITgenerated_prag src)) = src -getCORE_PRAGs (L _ (ITcore_prag src)) = src getUNPACK_PRAGs (L _ (ITunpack_prag src)) = src getNOUNPACK_PRAGs (L _ (ITnounpack_prag src)) = src getANN_PRAGs (L _ (ITann_prag src)) = src ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -743,7 +743,6 @@ data Token | ITcolumn_prag SourceText -- not usually produced, see 'UsePosPragsBit' | ITscc_prag SourceText | ITgenerated_prag SourceText - | ITcore_prag SourceText -- hdaume: core annotations | ITunpack_prag SourceText | ITnounpack_prag SourceText | ITann_prag SourceText @@ -3230,7 +3229,6 @@ oneWordPrags = Map.fromList [ ("deprecated", strtoken (\s -> ITdeprecated_prag (SourceText s))), ("scc", strtoken (\s -> ITscc_prag (SourceText s))), ("generated", strtoken (\s -> ITgenerated_prag (SourceText s))), - ("core", strtoken (\s -> ITcore_prag (SourceText s))), ("unpack", strtoken (\s -> ITunpack_prag (SourceText s))), ("nounpack", strtoken (\s -> ITnounpack_prag (SourceText s))), ("ann", strtoken (\s -> ITann_prag (SourceText s))), ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -242,7 +242,6 @@ rnExpr (HsPragE x prag expr) where rn_prag :: HsPragE GhcPs -> HsPragE GhcRn rn_prag (HsPragSCC x1 src ann) = HsPragSCC x1 src ann - rn_prag (HsPragCore x1 src lbl) = HsPragCore x1 src lbl rn_prag (HsPragTick x1 src info srcInfo) = HsPragTick x1 src info srcInfo rnExpr (HsLam x matches) ===================================== compiler/GHC/StgToCmm/CgUtils.hs ===================================== @@ -121,7 +121,7 @@ regTableOffset dflags n = get_Regtable_addr_from_offset :: DynFlags -> Int -> CmmExpr get_Regtable_addr_from_offset dflags offset = if haveRegBase (targetPlatform dflags) - then CmmRegOff baseReg offset + then cmmRegOff baseReg offset else regTableOffset dflags offset -- | Fixup global registers so that they assign to locations within the ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -1091,7 +1091,6 @@ tcExpr other _ = pprPanic "tcLExpr" (ppr other) tcExprPrag :: HsPragE GhcRn -> HsPragE GhcTc tcExprPrag (HsPragSCC x1 src ann) = HsPragSCC x1 src ann -tcExprPrag (HsPragCore x1 src lbl) = HsPragCore x1 src lbl tcExprPrag (HsPragTick x1 src info srcInfo) = HsPragTick x1 src info srcInfo ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -373,10 +373,19 @@ collection. Hopefully, you won't need any of these in normal operation, but there are several things that can be tweaked for maximum performance. +.. rts-flag:: --copying-gc + :default: on + :since: 8.10.2 + :reverse: --nonmoving-gc + + Uses the generational copying garbage collector for all generations. + This is the default. + .. rts-flag:: --nonmoving-gc :default: off :since: 8.10.1 + :reverse: --copying-gc .. index:: single: concurrent mark and sweep ===================================== rts/RtsFlags.c ===================================== @@ -292,6 +292,12 @@ usage_text[] = { " -? Prints this message and exits; the program is not executed", " --info Print information about the RTS used by this program", "", +" --nonmoving-gc", +" Selects the non-moving mark-and-sweep garbage collector to", +" manage the oldest generation.", +" --copying-gc", +" Selects the copying garbage collector to manage all generations.", +"", " -K Sets the maximum stack size (default: 80% of the heap)", " Egs: -K32k -K512k -K8M", " -ki Sets the initial thread stack size (default 1k) Egs: -ki4k -ki2m", @@ -939,6 +945,11 @@ error = true; printRtsInfo(rtsConfig); stg_exit(0); } + else if (strequal("copying-gc", + &rts_argv[arg][2])) { + OPTION_SAFE; + RtsFlags.GcFlags.useNonmoving = false; + } else if (strequal("nonmoving-gc", &rts_argv[arg][2])) { OPTION_SAFE; ===================================== testsuite/tests/ghc-api/annotations/T10313.stdout ===================================== @@ -10,8 +10,5 @@ ([c], [(SourceText "foo\x63", fooc), (SourceText "b\x61r", bar)]), ([r], [(SourceText "foo1\x67", foo1g)]), ([s, t], [(SourceText "a\x62", ab)]), - ([c, o], - [(SourceText "Strict Bitstream stre\x61m", - Strict Bitstream stream)]), ([s, c], [(SourceText "foo\x64", food)]), ([t, p], [(SourceText "foob\x61r", foobar)])] ===================================== testsuite/tests/ghc-api/annotations/Test10313.hs ===================================== @@ -28,8 +28,7 @@ foreign import prim unsafe "a\x62" a :: IO Int {-# INLINE strictStream #-} strictStream (Bitstream l v) - = {-# CORE "Strict Bitstream stre\x61m" #-} - S.concatMap stream (GV.stream v) + = S.concatMap stream (GV.stream v) `S.sized` Exact l ===================================== testsuite/tests/ghc-api/annotations/stringSource.hs ===================================== @@ -84,7 +84,6 @@ testOneFile libdir fileName = do doHsExpr _ = [] doPragE :: HsPragE GhcPs -> [(String,[Located (SourceText,FastString)])] - doPragE (HsPragCore _ src ss) = [("co",[conv (noLoc ss)])] doPragE (HsPragSCC _ src ss) = [("sc",[conv (noLoc ss)])] doPragE (HsPragTick _ src (ss,_,_) _ss2) = [("tp",[conv (noLoc ss)])] ===================================== testsuite/tests/printer/Ppr009.hs ===================================== @@ -3,7 +3,6 @@ module Ppr009 where {-# INLINE strictStream #-} strictStream (Bitstream l v) - = {-# CORE "Strict Bitstream stream" #-} - S.concatMap stream (GV.stream v) + = S.concatMap stream (GV.stream v) `S.sized` Exact l ===================================== testsuite/tests/simplCore/should_run/T17744.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Main where + +import T17744A + +main :: IO () +main = print $ completeResults $ feed "f" $ parse uriScheme + +uriScheme :: Format (Parser LeftBiasedLocal) Maybe +uriScheme = satisfy_ mytake + +ipV4address :: Format (Parser LeftBiasedLocal) Maybe +ipV4address = satisfy_ mytake2 ===================================== testsuite/tests/simplCore/should_run/T17744.stdout ===================================== @@ -0,0 +1 @@ +1 ===================================== testsuite/tests/simplCore/should_run/T17744A.hs ===================================== @@ -0,0 +1,91 @@ +{-# LANGUAGE FlexibleContexts, FlexibleInstances, GADTs, UndecidableInstances #-} + +module T17744A where + +import Control.Applicative +import Data.ByteString (ByteString) +import qualified Data.ByteString as ByteString + + +data Parser t r where + Failure :: Parser t r + Result :: ByteString -> r -> Parser t r + Delay :: Parser t r -> (ByteString -> Parser t r) -> Parser t r + +instance Functor (Parser t) where + fmap f (Result s r) = Result s (f r) + fmap f p = apply (fmap f) p + +instance Applicative (Parser t) where + pure = return + +instance Monad (Parser t) where + return = Result mempty + Result s r >>= f = feed s (f r) + p >>= f = apply (>>= f) p + +data LeftBiasedLocal + +instance Alternative (Parser LeftBiasedLocal) + +instance (Alternative (Parser t)) => LookAheadParsing (Parser t) + +class Alternative m => Parsing m where + unexpected :: m a + +instance (Alternative (Parser t)) => Parsing (Parser t) where + unexpected = undefined + +class Parsing m => LookAheadParsing m + +class LookAheadParsing m => InputParsing m where + takex :: m ByteString + +class (Parsing m, InputParsing m) => InputCharParsing m + +feed :: ByteString -> Parser t r -> Parser t r +feed s (Result s' r) = Result (mappend s' s) r +feed s (Delay _ f) = f s + +completeResults :: Parser t r -> Int +completeResults (Result _ _) = 1 +completeResults _ = 0 + + +apply :: (Parser t r -> Parser t r') -> Parser t r -> Parser t r' +apply _ Failure = Failure +apply g (Delay e f) = Delay (g e) (g . f) +apply f p = Delay (f p) (\s-> f $ feed s p) + + +instance (Alternative (Parser t )) => + InputParsing (Parser t ) where + takex = p + where p = Delay Failure f + f s = if ByteString.null s then p else + case ByteString.splitAt 1 s of + (first, rest) -> Result rest first + + +instance (LookAheadParsing (Parser t)) => InputCharParsing (Parser t) where + +data Format m n = Format { + parse :: m ByteString, + serialize :: n () + } + +mytake :: (InputParsing m, Alternative n) => Format m n +mytake = Format{ + parse = takex, + serialize = pure () + } + +mytake2 :: (InputCharParsing m, Alternative n) => Format m n +mytake2 = mytake + +satisfy_ :: (Parsing m, Monad m) => Format m n -> Format m n +satisfy_ f = Format{ + parse = parse f >>= pure, + serialize = undefined + } + ===================================== testsuite/tests/simplCore/should_run/all.T ===================================== @@ -91,3 +91,4 @@ test('T16066', exit_code(1), compile_and_run, ['-O1']) test('T17206', exit_code(1), compile_and_run, ['']) test('T17151', [], multimod_compile_and_run, ['T17151', '']) test('T18012', normal, compile_and_run, ['']) +test('T17744', normal, compile_and_run, ['']) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 075067254fc30ef56bad67ac65dd3c5f4101f8fa +Subproject commit 22b42eab6ec6b3b321b6d54041b7b3a6e54af3c9 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed714af2a35797b6fbbfa7948ee5862184063013...f02edd8079113c1ea7af47d5585f0d5f9fed599b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed714af2a35797b6fbbfa7948ee5862184063013...f02edd8079113c1ea7af47d5585f0d5f9fed599b You're receiving 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 Jul 16 12:57:50 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Thu, 16 Jul 2020 08:57:50 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] Maybe the test-wrapper logic should become a cmd_prefix? Message-ID: <5f104ecea3c95_80b8e25ed433622d3@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 8ca1568f by Moritz Angermann at 2020-07-16T12:57:39+00:00 Maybe the test-wrapper logic should become a cmd_prefix? - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -1652,16 +1652,20 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) -> if opts.cmd_prefix is not None: cmd = opts.cmd_prefix(cmd) - - # 3. prefix with TEST_WRAPPER - # The test wrapper. Default to $TOP / driver / id - # for the identity test-wrapper. - if config.test_wrapper is None: - test_wrapper = Path(config.top) / "driver" / "id" else: - test_wrapper = config.test_wrapper + # (optional) 3. prefix with TEST_WRAPPER + # + # The test wrapper. Default to $TOP / driver / id + # for the identity test-wrapper. + # + # We won't do this if command prefix is set, as the + # set prefix and the test-wrapper might interfere. + if config.test_wrapper is None: + test_wrapper = Path(config.top) / "driver" / "id" + else: + test_wrapper = config.test_wrapper - cmd = 'TEST_WRAPPER="{test_wrapper}" && {cmd}'.format(**locals()) + cmd = 'TEST_WRAPPER="{test_wrapper}" && {cmd}'.format(**locals()) # 4. Apply cmd_wrapper if set. if opts.cmd_wrapper is not None: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8ca1568f27e646248687e78c7b6559910877027f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8ca1568f27e646248687e78c7b6559910877027f You're receiving 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 Jul 16 13:43:30 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 16 Jul 2020 09:43:30 -0400 Subject: [Git][ghc/ghc][ghc-8.10] 9 commits: Escape backslashes in json profiling reports properly. Message-ID: <5f105982ae62f_80b3f8486fb6f7c336953f@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.10 at Glasgow Haskell Compiler / GHC Commits: c9770ef3 by Andreas Klebinger at 2020-07-15T23:39:35-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. (cherry picked from commit fecafac8065d951c14a23de2395e078328f856cd) - - - - - aa2e5863 by Moritz Angermann at 2020-07-15T23:42:39-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC (cherry picked from commit 5bc6082fdcb278be878f01a2eeb9741d7d82bb49) - - - - - dfffd9eb by Artem Pelenitsyn at 2020-07-15T23:50:11-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. (cherry picked from commit af5e3a885ddd09dd5f550552c535af3661ff3dbf) - - - - - 93c06518 by Moritz Angermann at 2020-07-15T23:51:27-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. (cherry picked from commit b455074875d3c8fd3a5787e01dc6f922f3a97bc2) - - - - - b33a20c5 by Moritz Angermann at 2020-07-15T23:51:39-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. (cherry picked from commit 3fd12af1eaafe304e5916bc1fcfdf31709d360b8) - - - - - 6560fa8f by Moritz Angermann at 2020-07-15T23:52:20-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf (cherry picked from commit f2446ff1578a37822488e0e3968694f66712b969) - - - - - 820d9ed2 by Ben Gamari at 2020-07-15T23:55:55-04:00 testsuite: Add test for #18151 (cherry picked from commit bd9f558924755f965f5136b5e3d4fa88d34c9778) - - - - - be443156 by Ben Gamari at 2020-07-15T23:56:02-04:00 testsuite: Add test for desugaring of PostfixOperators (cherry picked from commit 95a9eb7396912314f6cfd971fb4523e4062acec6) - - - - - cc8800f9 by Ben Gamari at 2020-07-15T23:56:42-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. (cherry picked from commit b1dbd625493ae1bf984cf51177011baf9c677c0a) - - - - - 12 changed files: - compiler/deSugar/DsExpr.hs - libraries/base/GHC/Float.hs - libraries/ghc-prim/ghc-prim.cabal - rts/ProfilerReportJson.c - rts/RtsSymbols.c - rts/linker/LoadArchive.c - rts/linker/elf_reloc_aarch64.c - + testsuite/tests/deSugar/should_run/DsPostfixOperators.hs - + testsuite/tests/deSugar/should_run/DsPostfixOperators.stdout - + testsuite/tests/deSugar/should_run/T18151.hs - + testsuite/tests/deSugar/should_run/T18151.stdout - testsuite/tests/deSugar/should_run/all.T Changes: ===================================== compiler/deSugar/DsExpr.hs ===================================== @@ -331,26 +331,47 @@ Then we get That 'g' in the 'in' part is an evidence variable, and when converting to core it must become a CO. -Operator sections. At first it looks as if we can convert -\begin{verbatim} - (expr op) -\end{verbatim} -to -\begin{verbatim} - \x -> op expr x -\end{verbatim} + +Note [Desugaring operator sections] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +At first it looks as if we can convert + + (expr `op`) + +naively to + + \x -> op expr x But no! expr might be a redex, and we can lose laziness badly this way. Consider -\begin{verbatim} - map (expr op) xs -\end{verbatim} -for example. So we convert instead to -\begin{verbatim} - let y = expr in \x -> op y x -\end{verbatim} -If \tr{expr} is actually just a variable, say, then the simplifier -will sort it out. + + map (expr `op`) xs + +for example. If expr were a redex then eta-expanding naively would +result in multiple evaluations where the user might only have expected one. + +So we convert instead to + + let y = expr in \x -> op y x + +Also, note that we must do this for both right and (perhaps surprisingly) left +sections. Why are left sections necessary? Consider the program (found in #18151), + + seq (True `undefined`) () + +according to the Haskell Report this should reduce to () (as it specifies +desugaring via eta expansion). However, if we fail to eta expand we will rather +bottom. Consequently, we must eta expand even in the case of a left section. + +If `expr` is actually just a variable, say, then the simplifier +will inline `y`, eliminating the redundant `let`. + +Note that this works even in the case that `expr` is unlifted. In this case +bindNonRec will automatically do the right thing, giving us: + + case expr of y -> (\x -> op y x) + +See #18151. -} ds_expr _ e@(OpApp _ e1 op e2) @@ -359,17 +380,35 @@ ds_expr _ e@(OpApp _ e1 op e2) ; dsWhenNoErrs (mapM dsLExprNoLP [e1, e2]) (\exprs' -> mkCoreAppsDs (text "opapp" <+> ppr e) op' exprs') } -ds_expr _ (SectionL _ expr op) -- Desugar (e !) to ((!) e) - = do { op' <- dsLExpr op - ; dsWhenNoErrs (dsLExprNoLP expr) - (\expr' -> mkCoreAppDs (text "sectionl" <+> ppr expr) op' expr') } - --- dsLExpr (SectionR op expr) -- \ x -> op x expr +-- dsExpr (SectionL op expr) === (expr `op`) ~> \y -> op expr y +-- +-- See Note [Desugaring operator sections]. +-- N.B. this also must handle postfix operator sections due to -XPostfixOperators. +ds_expr _ e@(SectionL _ expr op) = do + core_op <- dsLExpr op + x_core <- dsLExpr expr + case splitFunTys (exprType core_op) of + -- Binary operator section + (x_ty:y_ty:_, _) -> do + dsWhenNoErrs + (mapM newSysLocalDsNoLP [x_ty, y_ty]) + (\[x_id, y_id] -> + bindNonRec x_id x_core + $ Lam y_id (mkCoreAppsDs (text "sectionl" <+> ppr e) + core_op [Var x_id, Var y_id])) + + -- Postfix operator section + (_:_, _) -> do + return $ mkCoreAppDs (text "sectionl" <+> ppr e) core_op x_core + + _ -> pprPanic "dsExpr(SectionL)" (ppr e) + +-- dsExpr (SectionR op expr) === (`op` expr) ~> \x -> op x expr +-- +-- See Note [Desugaring operator sections]. ds_expr _ e@(SectionR _ op expr) = do core_op <- dsLExpr op - -- for the type of x, we need the type of op's 2nd argument let (x_ty:y_ty:_, _) = splitFunTys (exprType core_op) - -- See comment with SectionL y_core <- dsLExpr expr dsWhenNoErrs (mapM newSysLocalDsNoLP [x_ty, y_ty]) (\[x_id, y_id] -> bindNonRec y_id y_core $ ===================================== libraries/base/GHC/Float.hs ===================================== @@ -141,6 +141,14 @@ class (Fractional a) => Floating a where log1pexp x = log1p (exp x) log1mexp x = log1p (negate (exp x)) +-- | Default implementation for @'log1mexp'@ requiring @'Ord'@ to test +-- against a threshold to decide which implementation variant to use. +log1mexpOrd :: (Ord a, Floating a) => a -> a +{-# INLINE log1mexpOrd #-} +log1mexpOrd a + | a > -(log 2) = log (negate (expm1 a)) + | otherwise = log1p (negate (exp a)) + -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat a where @@ -398,9 +406,7 @@ instance Floating Float where log1p = log1pFloat expm1 = expm1Float - log1mexp a - | a <= log 2 = log (negate (expm1Float a)) - | otherwise = log1pFloat (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pFloat (exp a) @@ -539,9 +545,7 @@ instance Floating Double where log1p = log1pDouble expm1 = expm1Double - log1mexp a - | a <= log 2 = log (negate (expm1Double a)) - | otherwise = log1pDouble (negate (exp a)) + log1mexp x = log1mexpOrd x {-# INLINE log1mexp #-} log1pexp a | a <= 18 = log1pDouble (exp a) ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -67,6 +67,11 @@ Library -- on Windows. Required because of mingw32. extra-libraries: user32, mingw32, mingwex + if os(linux) + -- we need libm, but for musl and other's we might need libc, as libm + -- is just an empty shell. + extra-libraries: c, m + c-sources: cbits/atomic.c cbits/bswap.c ===================================== rts/ProfilerReportJson.c ===================================== @@ -15,23 +15,35 @@ #include "ProfilerReportJson.h" #include "Profiling.h" -// This only handles characters that you might see in a Haskell cost-centre -// name. -static void escapeString(char const* str, char *out, int len) +#include + +// I don't think this code is all that perf critical. +// So we just allocate a new buffer each time around. +static void escapeString(char const* str, char **buf) { - len--; // reserve character in output for terminating NUL - for (; *str != '\0' && len > 0; str++) { + char *out; + size_t req_size; //Max required size for decoding. + size_t in_size; //Input size, including zero. + + in_size = strlen(str) + 1; + // The strings are generally small and short + // lived so should be ok to just double the size. + req_size = in_size * 2; + out = stgMallocBytes(req_size, "writeCCSReportJson"); + *buf = out; + // We provide an outputbuffer twice the size of the input, + // and at worse double the output size. So we can skip + // length checks. + for (; *str != '\0'; str++) { char c = *str; if (c == '\\') { - if (len < 2) break; - *out = '\\'; out++; len--; - *out = '\\'; out++; len--; + *out = '\\'; out++; + *out = '\\'; out++; } else if (c == '\n') { - if (len < 2) break; - *out = '\\'; out++; len--; - *out = 'n'; out++; len--; + *out = '\\'; out++; + *out = 'n'; out++; } else { - *out = c; out++; len--; + *out = c; out++; } } *out = '\0'; @@ -40,11 +52,13 @@ static void escapeString(char const* str, char *out, int len) static void logCostCentres(FILE *prof_file) { - char tmp[256]; + char* lbl; + char* src_loc; bool needs_comma = false; fprintf(prof_file, "[\n"); for (CostCentre *cc = CC_LIST; cc != NULL; cc = cc->link) { - escapeString(cc->label, tmp, sizeof(tmp)); + escapeString(cc->label, &lbl); + escapeString(cc->srcloc, &src_loc); fprintf(prof_file, "%s" "{\"id\": %" FMT_Int ", " @@ -53,11 +67,13 @@ logCostCentres(FILE *prof_file) "\"src_loc\": \"%s\", " "\"is_caf\": %s}", needs_comma ? ", " : "", - cc->ccID, tmp, cc->module, cc->srcloc, + cc->ccID, lbl, cc->module, src_loc, cc->is_caf ? "true" : "false"); needs_comma = true; } fprintf(prof_file, "]\n"); + stgFree(lbl); + stgFree(src_loc); } static void @@ -92,15 +108,24 @@ writeCCSReportJson(FILE *prof_file, CostCentreStack const *stack, ProfilerTotals totals) { + fprintf(prof_file, "{\n\"program\": \"%s\",\n", prog_name); fprintf(prof_file, "\"arguments\": ["); - for (int count = 0; prog_argv[count]; count++) + for (int count = 0; prog_argv[count]; count++) { + char* arg; + escapeString(prog_argv[count], &arg); fprintf(prof_file, "%s\"%s\"", - count == 0 ? "" : ", ", prog_argv[count]); + count == 0 ? "" : ", ", arg); + stgFree(arg); + } fprintf(prof_file, "],\n\"rts_arguments\": ["); - for (int count = 0; rts_argv[count]; count++) + for (int count = 0; rts_argv[count]; count++) { + char* arg; + escapeString(rts_argv[count], &arg); fprintf(prof_file, "%s\"%s\"", - count == 0 ? "" : ", ", rts_argv[count]); + count == 0 ? "" : ", ", arg); + stgFree(arg); + } fprintf(prof_file, "],\n"); fprintf(prof_file, "\"end_time\": \"%s\",\n", time_str()); @@ -121,6 +146,7 @@ writeCCSReportJson(FILE *prof_file, fprintf(prof_file, ",\n\"profile\": "); logCostCentreStack(prof_file, stack); fprintf(prof_file, "}\n"); + } ===================================== rts/RtsSymbols.c ===================================== @@ -58,7 +58,6 @@ SymI_HasProto(signal_handlers) \ SymI_HasProto(stg_sig_install) \ SymI_HasProto(rtsTimerSignal) \ - SymI_HasProto(atexit) \ SymI_NeedsDataProto(nocldstop) #endif @@ -977,29 +976,213 @@ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS - // 64-bit support functions in libgcc.a -#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) -#define RTS_LIBGCC_SYMBOLS \ - SymI_NeedsProto(__divdi3) \ - SymI_NeedsProto(__udivdi3) \ - SymI_NeedsProto(__moddi3) \ - SymI_NeedsProto(__umoddi3) \ - SymI_NeedsProto(__muldi3) \ - SymI_NeedsProto(__ashldi3) \ - SymI_NeedsProto(__ashrdi3) \ - SymI_NeedsProto(__lshrdi3) \ - SymI_NeedsProto(__fixunsdfdi) -#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 -#define RTS_LIBGCC_SYMBOLS \ +// See https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc +#define RTS_LIBGCC_SYMBOLS_32 \ + SymI_NeedsProto(__fixunsdfdi) \ + /* 4 The GCC low-level runtime library */\ + /* 4.1.1 Arithmetic functions */\ + /* SymI_NeedsProto(__ashlsi3) */\ + SymI_NeedsProto(__ashldi3) \ + /* SymI_NeedsProto(__ashlti3) */\ + /* These functions return the result of shifting a left by b bits. */\ + /* SymI_NeedsProto(__ashrsi3) */\ + SymI_NeedsProto(__ashrdi3) \ + /* SymI_NeedsProto(__ashrti3) */\ + /* These functions return the result of arithmetically shifting a right by b bits. */\ + /* SymI_NeedsProto(__divsi3) */\ + SymI_NeedsProto(__divdi3) \ + /* SymI_NeedsProto(__divti3) */\ + /* These functions return the quotient of the signed division of a and b. */\ + /* SymI_NeedsProto(__lshrsi3) */ \ + SymI_NeedsProto(__lshrdi3) \ + /* SymI_NeedsProto(__lshrti3) */ \ + /* These functions return the result of logically shifting a right by b bits. */\ + /* SymI_NeedsProto(__modsi3) */ \ + SymI_NeedsProto(__moddi3) \ + /* SymI_NeedsProto(__modti3) */ \ + /* These functions return the remainder of the signed division of a and b. */\ + /* SymI_NeedsProto(__mulsi3) */ \ + SymI_NeedsProto(__muldi3) \ + /* SymI_NeedsProto(__multi3) */ \ + /* These functions return the product of a and b. */\ + SymI_NeedsProto(__negdi2) \ + /* SymI_NeedsProto(__negti2) */ \ + /* These functions return the negation of a. */\ + /* SymI_NeedsProto(__udivsi3) */ \ + SymI_NeedsProto(__udivdi3) \ + /* SymI_NeedsProto(__udivti3) */ \ + /* These functions return the quotient of the unsigned division of a and b. */\ + SymI_NeedsProto(__udivmoddi4) \ + /* SymI_NeedsProto(__udivmodti4) */ \ + /* These functions calculate both the quotient and remainder of the unsigned division of a and b. The return value is the quotient, and the remainder is placed in variable pointed to by c. */\ + /* SymI_NeedsProto(__umodsi3) */ \ + SymI_NeedsProto(__umoddi3) \ + /* SymI_NeedsProto(__umodti3) */ \ + /* These functions return the remainder of the unsigned division of a and b. */\ + /* 4.1.2 Comparison functions */\ + /* The following functions implement integral comparisons. These functions implement a low-level compare, upon which the higher level comparison operators (such as less than and greater than or equal to) can be constructed. The returned values lie in the range zero to two, to allow the high-level operators to be implemented by testing the returned result using either signed or unsigned comparison. */\ + SymI_NeedsProto(__cmpdi2) \ + /* SymI_NeedsProto(__cmpti2) */ \ + /* These functions perform a signed comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\ + SymI_NeedsProto(__ucmpdi2) \ + /* SymI_NeedsProto(__ucmpti2) */ \ + /* These functions perform an unsigned comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\ + /* 4.1.3 Trapping arithmetic functions */\ + /* The following functions implement trapping arithmetic. These functions call the libc function abort upon signed arithmetic overflow. */\ + SymI_NeedsProto(__absvsi2) \ + SymI_NeedsProto(__absvdi2) \ + /* These functions return the absolute value of a. */\ + /* SymI_NeedsProto(__addvsi3) */ \ + SymI_NeedsProto(__addvdi3) \ + /* These functions return the sum of a and b; that is a + b. */\ + /* SymI_NeedsProto(__mulvsi3) */ \ + SymI_NeedsProto(__mulvdi3) \ + /* The functions return the product of a and b; that is a * b. */\ + SymI_NeedsProto(__negvsi2) \ + SymI_NeedsProto(__negvdi2) \ + /* These functions return the negation of a; that is -a. */\ + /* SymI_NeedsProto(__subvsi3) */ \ + SymI_NeedsProto(__subvdi3) \ + /* These functions return the difference between b and a; that is a - b. */\ + /* 4.1.4 Bit operations */\ + SymI_NeedsProto(__clzsi2) \ + SymI_NeedsProto(__clzdi2) \ + /* SymI_NeedsProto(__clzti2) */ \ + /* These functions return the number of leading 0-bits in a, starting at the most significant bit position. If a is zero, the result is undefined. */\ + SymI_NeedsProto(__ctzsi2) \ + SymI_NeedsProto(__ctzdi2) \ + /* SymI_NeedsProto(__ctzti2) */ \ + /* These functions return the number of trailing 0-bits in a, starting at the least significant bit position. If a is zero, the result is undefined. */\ + SymI_NeedsProto(__ffsdi2) \ + /* SymI_NeedsProto(__ffsti2) */ \ + /* These functions return the index of the least significant 1-bit in a, or the value zero if a is zero. The least significant bit is index one. */\ + SymI_NeedsProto(__paritysi2) \ + SymI_NeedsProto(__paritydi2) \ + /* SymI_NeedsProto(__parityti2) */\ + /* These functions return the value zero if the number of bits set in a is even, and the value one otherwise. */\ + SymI_NeedsProto(__popcountsi2) \ + SymI_NeedsProto(__popcountdi2) \ + /* SymI_NeedsProto(__popcountti2) */ \ + /* These functions return the number of bits set in a. */\ + SymI_NeedsProto(__bswapsi2) \ + SymI_NeedsProto(__bswapdi2) +#define RTS_LIBGCC_SYMBOLS_aarch32 \ + /* armv6l */\ + /* TODO: should check for __ARM_EABI__ */\ + SymI_NeedsProto(__aeabi_d2f) \ + SymI_NeedsProto(__aeabi_d2iz) \ + SymI_NeedsProto(__aeabi_d2lz) \ + SymI_NeedsProto(__aeabi_d2uiz) \ + SymI_NeedsProto(__aeabi_d2ulz) \ + SymI_NeedsProto(__aeabi_dadd) \ + SymI_NeedsProto(__aeabi_dcmpeq) \ + SymI_NeedsProto(__aeabi_dcmpge) \ + SymI_NeedsProto(__aeabi_dcmpgt) \ + SymI_NeedsProto(__aeabi_dcmple) \ + SymI_NeedsProto(__aeabi_dcmplt) \ + SymI_NeedsProto(__aeabi_dcmpun) \ + SymI_NeedsProto(__aeabi_ddiv) \ + SymI_NeedsProto(__aeabi_dmul) \ + SymI_NeedsProto(__aeabi_dneg) \ + SymI_NeedsProto(__aeabi_dsub) \ + SymI_NeedsProto(__aeabi_f2d) \ + SymI_NeedsProto(__aeabi_f2iz) \ + SymI_NeedsProto(__aeabi_f2lz) \ + SymI_NeedsProto(__aeabi_f2uiz) \ + SymI_NeedsProto(__aeabi_f2ulz) \ + SymI_NeedsProto(__aeabi_fadd) \ + SymI_NeedsProto(__aeabi_fcmpeq) \ + SymI_NeedsProto(__aeabi_fcmpge) \ + SymI_NeedsProto(__aeabi_fcmpgt) \ + SymI_NeedsProto(__aeabi_fcmple) \ + SymI_NeedsProto(__aeabi_fcmplt) \ + SymI_NeedsProto(__aeabi_fcmpun) \ + SymI_NeedsProto(__aeabi_fdiv) \ + SymI_NeedsProto(__aeabi_fmul) \ + SymI_NeedsProto(__aeabi_fneg) \ + SymI_NeedsProto(__aeabi_fsub) \ + SymI_NeedsProto(__aeabi_i2d) \ + SymI_NeedsProto(__aeabi_i2f) \ + SymI_NeedsProto(__aeabi_idiv) \ + SymI_NeedsProto(__aeabi_idivmod) \ + SymI_NeedsProto(__aeabi_l2d) \ + SymI_NeedsProto(__aeabi_l2f) \ + SymI_NeedsProto(__aeabi_lasr) \ + SymI_NeedsProto(__aeabi_lcmp) \ + SymI_NeedsProto(__aeabi_ldivmod) \ + SymI_NeedsProto(__aeabi_llsl) \ + SymI_NeedsProto(__aeabi_llsr) \ + SymI_NeedsProto(__aeabi_lmul) \ + SymI_NeedsProto(__aeabi_ui2d) \ + SymI_NeedsProto(__aeabi_ui2f) \ + SymI_NeedsProto(__aeabi_uidiv) \ + SymI_NeedsProto(__aeabi_uidivmod) \ + SymI_NeedsProto(__aeabi_ul2d) \ + SymI_NeedsProto(__aeabi_ul2f) \ + SymI_NeedsProto(__aeabi_ulcmp) \ + SymI_NeedsProto(__aeabi_uldivmod) +#define RTS_LIBGCC_SYMBOLS_64 \ SymI_NeedsProto(__udivti3) \ SymI_NeedsProto(__umodti3) + +/* for aarch64 */ +#define RTS_LIBGCC_SYMBOLS_aarch64 \ + SymI_NeedsProto(__netf2) \ + SymI_NeedsProto(__addtf3) \ + SymI_NeedsProto(__subtf3) \ + SymI_NeedsProto(__multf3) \ + SymI_NeedsProto(__extenddftf2) \ + SymI_NeedsProto(__fixtfsi) \ + SymI_NeedsProto(__fixunstfsi) \ + SymI_NeedsProto(__floatsitf) \ + SymI_NeedsProto(__floatunsitf) + +#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && defined(arm_HOST_OS) +#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 RTS_LIBGCC_SYMBOLS_aarch32 +#elif defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) +#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 +#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 && defined(aarch64_HOST_OS) +#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 RTS_LIBGCC_SYMBOLS_aarch64 +#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 +#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 #else #define RTS_LIBGCC_SYMBOLS #endif +#if !defined(mingw32_HOST_OS) && !defined(DYNAMIC) && (defined(_FORTIFY_SOURCE) || defined(__SSP__)) +#define RTS_SSP_SYMBOLS \ + SymI_NeedsProto(__stack_chk_guard) \ + SymI_NeedsProto(__stack_chk_fail) +#else +#define RTS_SSP_SYMBOLS +#endif +#if !defined(DYNAMIC) && defined(linux_HOST_OS) +// we need these for static musl builds. However when +// linking shared objects (DLLs) this will fail, hence +// we do not include them when building with -DDYNAMIC +#define RTS_LINKER_SYMBOLS \ + SymI_NeedsProto(__fini_array_start) \ + SymI_NeedsProto(__fini_array_end) +#else +#define RTS_LINKER_SYMBOLS +#endif + +#if defined(darwin_HOST_OS) && defined(powerpc_HOST_ARCH) + // Symbols that don't have a leading underscore + // on Mac OS X. They have to receive special treatment, + // see machoInitSymbolsWithoutUnderscore() +#define RTS_MACHO_NOUNDERLINE_SYMBOLS \ + SymI_NeedsProto(saveFP) \ + SymI_NeedsProto(restFP) +#endif + /* entirely bogus claims about types of these symbols */ -#define SymI_NeedsProto(vvv) extern void vvv(void); +/* to prevent a bit of define expansion, SymI_NeedsProto is a variadic + * macro. And we'll concat vvv with the __VA_ARGS__. This prevents + * vvv from getting macro expanded. + */ +#define SymI_NeedsProto(vvv,...) extern void vvv ## __VA_ARGS__ (void); #define SymI_NeedsDataProto(vvv) extern StgWord vvv[]; #if defined(COMPILING_WINDOWS_DLL) #define SymE_HasProto(vvv) SymE_HasProto(vvv); @@ -1026,6 +1209,8 @@ RTS_DARWIN_ONLY_SYMBOLS RTS_OPENBSD_ONLY_SYMBOLS RTS_LIBGCC_SYMBOLS RTS_LIBFFI_SYMBOLS +RTS_SSP_SYMBOLS +RTS_LINKER_SYMBOLS #undef SymI_NeedsProto #undef SymI_NeedsDataProto #undef SymI_HasProto @@ -1045,7 +1230,7 @@ RTS_LIBFFI_SYMBOLS #define SymE_HasDataProto(vvv) \ SymE_HasProto(vvv) -#define SymI_NeedsProto(vvv) SymI_HasProto(vvv) +#define SymI_NeedsProto(vvv,...) SymI_HasProto(vvv ## __VA_ARGS__) #define SymI_NeedsDataProto(vvv) SymI_HasDataProto(vvv) #define SymE_NeedsProto(vvv) SymE_HasProto(vvv) #define SymE_NeedsDataProto(vvv) SymE_HasDataProto(vvv) @@ -1066,6 +1251,8 @@ RTS_LIBFFI_SYMBOLS #define SymI_HasProto_deprecated(vvv) \ { #vvv, (void*)0xBAADF00D, true }, +void *RTS_DYNAMIC = NULL; + RtsSymbolVal rtsSyms[] = { RTS_SYMBOLS RTS_RET_SYMBOLS @@ -1077,11 +1264,14 @@ RtsSymbolVal rtsSyms[] = { RTS_LIBGCC_SYMBOLS RTS_LIBFFI_SYMBOLS SymI_HasDataProto(nonmoving_write_barrier_enabled) + RTS_SSP_SYMBOLS + RTS_LINKER_SYMBOLS #if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH) // dyld stub code contains references to this, // but it should never be called because we treat // lazy pointers as nonlazy. { "dyld_stub_binding_helper", (void*)0xDEADBEEF, false }, #endif + { "_DYNAMIC", (void*)(&RTS_DYNAMIC), false }, { 0, 0, false } /* sentinel */ }; ===================================== rts/linker/LoadArchive.c ===================================== @@ -461,6 +461,7 @@ static HsInt loadArchive_ (pathchar *path) /* TODO: Stop relying on file extensions to determine input formats. Instead try to match file headers. See #13103. */ isObject = (thisFileNameSize >= 2 && strncmp(fileName + thisFileNameSize - 2, ".o" , 2) == 0) + || (thisFileNameSize >= 3 && strncmp(fileName + thisFileNameSize - 3, ".lo" , 3) == 0) || (thisFileNameSize >= 4 && strncmp(fileName + thisFileNameSize - 4, ".p_o", 4) == 0) || (thisFileNameSize >= 4 && strncmp(fileName + thisFileNameSize - 4, ".obj", 4) == 0); ===================================== rts/linker/elf_reloc_aarch64.c ===================================== @@ -93,12 +93,14 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) { // ... hi ] [ Rd ] // // imm64 = SignExtend(hi:lo:0x000,64) - assert(isInt64(32, addend)); + // Range is 21 bits + the 12 page relative bits + // known to be 0. -2^32 <= X < 2^32 + assert(isInt64(21+12, addend)); assert((addend & 0xfff) == 0); /* page relative */ *(inst_t *)P = (*(inst_t *)P & 0x9f00001f) - | (inst_t) (((uint64_t) addend << 17) & 0x60000000) - | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0); + | (inst_t) (((uint64_t) addend << 17) & 0x60000000) + | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0); break; } /* - control flow relocations */ @@ -111,8 +113,8 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) { break; } case COMPAT_R_AARCH64_ADR_GOT_PAGE: { - - assert(isInt64(32, addend)); /* X in range */ + /* range is -2^32 <= X < 2^32 */ + assert(isInt64(21+12, addend)); /* X in range */ assert((addend & 0xfff) == 0); /* page relative */ *(inst_t *)P = (*(inst_t *)P & 0x9f00001f) ===================================== testsuite/tests/deSugar/should_run/DsPostfixOperators.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE PostfixOperators #-} + +main :: IO () +main = do + print (42 `negate`) ===================================== testsuite/tests/deSugar/should_run/DsPostfixOperators.stdout ===================================== @@ -0,0 +1,2 @@ +-42 + ===================================== testsuite/tests/deSugar/should_run/T18151.hs ===================================== @@ -0,0 +1,10 @@ +-- According to the Report this should reduce to (). However, in #18151 it was +-- reported that GHC bottoms. +x :: () +x = seq (True `undefined`) () +{-# NOINLINE x #-} + +main :: IO () +main = do + print x + ===================================== testsuite/tests/deSugar/should_run/T18151.stdout ===================================== @@ -0,0 +1 @@ +() \ No newline at end of file ===================================== testsuite/tests/deSugar/should_run/all.T ===================================== @@ -57,9 +57,11 @@ test('T10215', normal, compile_and_run, ['']) test('DsStrictData', normal, compile_and_run, ['']) test('DsStrict', normal, compile_and_run, ['']) test('DsStrictLet', normal, compile_and_run, ['-O']) +test('DsPostfixOperators', normal, compile_and_run, ['']) test('T11193', exit_code(1), compile_and_run, ['']) test('T11572', exit_code(1), compile_and_run, ['']) test('T11601', exit_code(1), compile_and_run, ['']) test('T11747', normal, compile_and_run, ['-dcore-lint']) test('T12595', normal, compile_and_run, ['']) test('T13285', normal, compile_and_run, ['']) +test('T18151', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca146208a210242904edde77633ef857200dd45f...cc8800f9f482460ceb2d450137766e0350551740 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca146208a210242904edde77633ef857200dd45f...cc8800f9f482460ceb2d450137766e0350551740 You're receiving 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 Jul 16 14:27:59 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Thu, 16 Jul 2020 10:27:59 -0400 Subject: [Git][ghc/ghc][wip/T18449] 16 commits: Use dumpStyle when printing inlinings Message-ID: <5f1063ef848e2_80b3f8486b77e4833754af@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18449 at Glasgow Haskell Compiler / GHC Commits: 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 45af3f08 by Simon Peyton Jones at 2020-07-16T15:27:20+01:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.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/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/StgToCmm/CgUtils.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/GHC/Types/SrcLoc.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f956dd21af022123e43fa8cd74f15a715c65a93a...45af3f080462c297eb3c186303040e21a880d2d2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f956dd21af022123e43fa8cd74f15a715c65a93a...45af3f080462c297eb3c186303040e21a880d2d2 You're receiving 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 Jul 16 14:33:06 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Thu, 16 Jul 2020 10:33:06 -0400 Subject: [Git][ghc/ghc][wip/T18126] 83 commits: Implement the proposed -XQualifiedDo extension Message-ID: <5f10652275ba0_80b3f848e63c8183380531@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - f117f273 by Simon Peyton Jones at 2020-07-16T14:44:56+01:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity, sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to a new module GHC.Tc.Gen.App which deals with typechecking n-ary applications. It contains a good deal of documentation. Two other loosely-related change is in this patch: * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. modified: compiler/GHC/Runtime/Heap/Inspect.hs - - - - - 30e875f4 by Simon Peyton Jones at 2020-07-16T14:49:00+01:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typeecheck/polykinds/T16245a - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/test-metrics.sh - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/05df195d9c818ddda655de7d60f15ff23a82f755...30e875f4a002a9e1434ef3478210f31b3f928051 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/05df195d9c818ddda655de7d60f15ff23a82f755...30e875f4a002a9e1434ef3478210f31b3f928051 You're receiving 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 Jul 16 14:46:15 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Thu, 16 Jul 2020 10:46:15 -0400 Subject: [Git][ghc/ghc][wip/T18126] 2 commits: Implement Quick Look impredicativity Message-ID: <5f10683783586_80b3f848e63c81833862d9@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: 7b0a925d by Simon Peyton Jones at 2020-07-16T15:45:07+01:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity, sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to a new module GHC.Tc.Gen.App which deals with typechecking n-ary applications. It contains a good deal of documentation. Two other loosely-related change is in this patch: * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. modified: compiler/GHC/Runtime/Heap/Inspect.hs - - - - - ca6505d4 by Simon Peyton Jones at 2020-07-16T15:45:07+01:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typeecheck/polykinds/T16245a - - - - - 16 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Hole.hs - + compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Default.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/30e875f4a002a9e1434ef3478210f31b3f928051...ca6505d4b811b4cb95344ebdc420876000b7a518 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/30e875f4a002a9e1434ef3478210f31b3f928051...ca6505d4b811b4cb95344ebdc420876000b7a518 You're receiving 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 Jul 16 14:59:29 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 16 Jul 2020 10:59:29 -0400 Subject: [Git][ghc/ghc][master] 119 commits: Bump Cabal submodule Message-ID: <5f106b51f0116_80b3f848a2b147c33901b1@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 30 changed files: - Makefile - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Info.hs - configure.ac - hadrian/src/Settings/Packages.hs - includes/rts/Constants.h - includes/rts/FileLock.h - includes/rts/Flags.h - includes/rts/IOManager.h - includes/rts/OSThreads.h - includes/rts/storage/TSO.h - includes/stg/MiscClosures.h - libraries/Cabal - + libraries/base/Control/Concurrent.hs-boot - libraries/base/GHC/Conc/IO.hs - + libraries/base/GHC/Conc/POSIX.hs - + libraries/base/GHC/Conc/POSIX/Const.hsc - libraries/base/GHC/Conc/Sync.hs - + libraries/base/GHC/Conc/Sync.hs-boot - + libraries/base/GHC/Conc/WinIO.hs - libraries/base/GHC/Conc/Windows.hs - libraries/base/GHC/ConsoleHandler.hs → libraries/base/GHC/ConsoleHandler.hsc - libraries/base/GHC/Event/Array.hs - libraries/base/GHC/Event/IntTable.hs - libraries/base/GHC/Event/Internal.hs - + libraries/base/GHC/Event/Internal/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae11bdfd98a10266bfc7de9e16b500be220307ac...c0979cc53442b3a6202acab9cf164f0a4beea0b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae11bdfd98a10266bfc7de9e16b500be220307ac...c0979cc53442b3a6202acab9cf164f0a4beea0b7 You're receiving 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 Jul 16 17:24:14 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 16 Jul 2020 13:24:14 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 125 commits: Bump Cabal submodule Message-ID: <5f108d3eeaf9f_80b3f8487097194343107c@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 17b7a76e by Ben Gamari at 2020-07-16T13:24:06-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 2245d75e by Simon Peyton Jones at 2020-07-16T13:24:07-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - ba55b498 by Simon Peyton Jones at 2020-07-16T13:24:07-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 192b7d1b by Krzysztof Gogolewski at 2020-07-16T13:24:08-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - 68e48a6d by Chaitanya Koparkar at 2020-07-16T13:24:10-04:00 Fix minor typos in a Core.hs note - - - - - b6ef4d29 by Stefan Schulze Frielinghaus at 2020-07-16T13:24:11-04:00 GHCi: Fix isLittleEndian - - - - - 30 changed files: - Makefile - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Info.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f02edd8079113c1ea7af47d5585f0d5f9fed599b...b6ef4d2998d9fdfcdd3bf2e3c8636e9f0014932b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f02edd8079113c1ea7af47d5585f0d5f9fed599b...b6ef4d2998d9fdfcdd3bf2e3c8636e9f0014932b You're receiving 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 Jul 16 17:43:01 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 16 Jul 2020 13:43:01 -0400 Subject: [Git][ghc/ghc][wip/win32-missing-tarball] 342 commits: gitlab-ci: Allow ARMv7 job to fail Message-ID: <5f1091a563259_80b3f848a2b147c3461334@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/win32-missing-tarball at Glasgow Haskell Compiler / GHC Commits: cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00 gitlab-ci: Allow ARMv7 job to fail Due to #18298. - - - - - 32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00 Clean up boot vs non-boot disambiguating types We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule. - - - - - c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00 docs: Add more details on InterruptibleFFI. Details from https://gitlab.haskell.org/ghc/ghc/issues/8684 and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430 - - - - - 1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00 Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr. MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd. This regression did not make it into a release of GHC. Here, the original behavior is restored, and FinalPtr is given the same treatment as PlainPtr. - - - - - 2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00 Fix documentation on type families not being extracted It looks like the location of the Names used for CoAxioms on type families are now located at their type constructors. Previously, Docs.hs thought the Names were located in the RHS, so the RealSrcSpan in the instanceMap and getInstLoc didn't match up. Fixes #18241 - - - - - 6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00 GHC.Hs.Instances: Compile with -O0 This module contains exclusively Data instances, which are going to be slow no matter what we do. Furthermore, they are incredibly slow to compile with optimisation (see #9557). Consequently we compile this with -O0. See #18254. - - - - - c330331a by nineonine at 2020-06-04T04:37:59-04:00 Add test for #17669 - - - - - cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00 rts: Add Windows-specific implementation of rtsSleep Previously we would use the POSIX path, which uses `nanosleep`. However, it turns out that `nanosleep` is provided by `libpthread` on Windows. In general we don't want to incur such a dependency. Avoid this by simply using `Sleep` on Windows. Fixes #18272. - - - - - ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00 compiler: Disable use of process jobs with process < 1.6.9 Due to #17926. - - - - - 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 08b9ece7 by Ben Gamari at 2020-07-16T13:42:59-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/test-metrics.sh - .gitmodules - Makefile - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Node.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62c3f42b66d39fdad0c8c12c373765fa4ff2606e...08b9ece7275f27d64ecd2d2a9efa69c9e6b6385b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62c3f42b66d39fdad0c8c12c373765fa4ff2606e...08b9ece7275f27d64ecd2d2a9efa69c9e6b6385b You're receiving 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 Jul 16 17:47:52 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 16 Jul 2020 13:47:52 -0400 Subject: [Git][ghc/ghc][wip/D4333] 2721 commits: Text.ParserCombinators.ReadP: use NonEmpty in Final Message-ID: <5f1092c8b2cbd_80b3f849c221f403493536@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/D4333 at Glasgow Haskell Compiler / GHC Commits: 2a0be146 by Vaibhav Sagar at 2019-02-21T04:14:01-05:00 Text.ParserCombinators.ReadP: use NonEmpty in Final The `Final` constructor needed to maintain the invariant that the list it is provided is always non-empty. Since NonEmpty is in `base` now, I think it would be better to use it for this purpose. - - - - - 32f44ed8 by David Eichmann at 2019-02-21T04:20:09-05:00 Fix test runner crash when not in a git repo Respect `inside_git_repo()` when checking performance stats. - - - - - 2f4af71e by Vladislav Zavialov at 2019-02-21T04:26:15-05:00 Dot/bang operators in export lists (Trac #16339) The dot type operator was handled in the 'tyvarop' parser production, and the bang type operator in 'tyapp'. However, export lists and role annotations use 'oqtycon', so these type operators could not be exported or assigned roles. The fix is to handle them in a lower level production, 'tyconsym'. - - - - - e204431e by Vladislav Zavialov at 2019-02-21T04:26:15-05:00 Handle the (~) type operator in 'tyconsym' By parsing '~' in 'tyconsym' instead of 'oqtycon', we get one less shift/reduce conflict. - - - - - 48aafc24 by Tamar Christina at 2019-02-21T20:52:42-05:00 Testsuite: opt-in to symlinks on Windows - - - - - 9db92cf0 by Tamar Christina at 2019-02-21T20:52:42-05:00 Set builder env - - - - - 0e2d300a by Niklas Hambüchen at 2019-02-21T20:58:47-05:00 compiler: Write .o files atomically. See #14533 This issue was reproduced with, and the fix confirmed with, the `hatrace` tool for syscall-based fault injection: https://github.com/nh2/hatrace The concrete test case for GHC is at https://github.com/nh2/hatrace/blob/e23d35a2d2c79e8bf49e9e2266b3ff7094267f29/test/HatraceSpec.hs#L185 A previous, nondeterministic reproducer for the issue was provided by Alexey Kuleshevich in https://github.com/lehins/exec-kill-loop Signed-off-by: Niklas Hambüchen <niklas at fpcomplete.com> Reviewed-by: Alexey Kuleshevich <alexey at fpcomplete.com> - - - - - e8a08f40 by Niklas Hambüchen at 2019-02-21T20:58:47-05:00 compiler: Refactor: extract `withAtomicRename` - - - - - 473632d7 by klebinger.andreas at gmx.at at 2019-02-21T21:04:55-05:00 Bump nofib submodule. - - - - - a07f46ea by Simon Peyton Jones at 2019-02-22T06:56:08+00:00 Remove tcTyConUserTyVars The tcTyConUserTyVars field of TcTyCon was entirely unused. This patch kills it off entirely. - - - - - 0eb7cf03 by Simon Peyton Jones at 2019-02-22T06:56:08+00:00 Don't do binder-swap for GlobalIds This patch disables the binder-swap transformation in the (relatively rare) case when the scrutinee is a GlobalId. Reason: we are getting Lint errors so that GHC doesn't even validate. Trac #16346. This is NOT the final solution -- it's just a stop-gap to get us running again. The final solution is in Trac #16296 - - - - - c25b135f by Simon Peyton Jones at 2019-02-22T06:56:08+00:00 Fix exprIsConApp_maybe In this commit commit 7833cf407d1f608bebb1d38bb99d3035d8d735e6 Date: Thu Jan 24 17:58:50 2019 +0100 Look through newtype wrappers (Trac #16254) we made exprIsConApp_maybe quite a bit cleverer. But I had not paid enough attention to keeping exactly the correct substitution and in-scope set, which led to Trac #16348. There were several buglets (like applying the substitution twice in exprIsConApp_maybe, but the proximate source of the bug was that we were calling addNewInScopeIds, which deleted things from the substitution as well as adding them to the in-scope set. That's usually right, but not here! This was quite tricky to track down. But it is nicer now. - - - - - 44ad7215 by Matthew Pickering at 2019-02-22T06:56:08+00:00 Use validate flavour rather than devel2 for DEBUG CI job This also builds stage2 with optimisations and -dcore-lint - - - - - 806cc234 by David Eichmann at 2019-02-22T23:35:18-05:00 Build and copy libffi shared libraries correctly and enable dynamically linking ghc. Test Plan: Ensure build environment does NOT have a system libffi installed (you may want to use a nix environment). Then `hadrian/build.sh -c --flavour=default` Reviewers: bgamari Subscribers: rwbarton, carter GHC Trac Issues: #15837 - - - - - 4b752d52 by Oleg Grenrus at 2019-02-22T23:41:25-05:00 Update CI images to GHC-8.4.4 & cabal-install-2.4.1.0 Use official bindists, except for Debian 9/Stretch http://downloads.haskell.org/debian/ is used. (There are no recent GHC/cabal-install for Debian 8/Jessie there) Use v2-update/v2-install to install Haskell tools. Try to unify structure of the different Dockerfiles, incl installing GHC in one step (this will prevent sublayers from existing, making final image slightly smaller) - - - - - e87ae473 by Artem Pyanykh at 2019-02-22T23:47:32-05:00 Drop support for i386 and PowerPC in MachO linker Some code is broken, there are no CI targets (so not obvious how to test), and no one seems to have built GHC for any of the above platforms in years. - - - - - 04b7f4c1 by Ben Gamari at 2019-02-22T23:53:36-05:00 ghc-in-ghci: Fix capitalization of hieFile - - - - - 2e9426df by Tom Sydney Kerckhove at 2019-02-23T21:25:41-05:00 hWaitForInput-accurate-socket test - - - - - ac34e784 by Simon Peyton Jones at 2019-02-23T21:31:47-05:00 Remove bogus assertion Remove a bogus assertion in FamInst.newFamInst (There is a comment to explain.) This fixes Trac #16112. - - - - - 6cce36f8 by Simon Peyton Jones at 2019-02-23T21:31:47-05:00 Add AnonArgFlag to FunTy The big payload of this patch is: Add an AnonArgFlag to the FunTy constructor of Type, so that (FunTy VisArg t1 t2) means (t1 -> t2) (FunTy InvisArg t1 t2) means (t1 => t2) The big payoff is that we have a simple, local test to make when decomposing a type, leading to many fewer calls to isPredTy. To me the code seems a lot tidier, and probably more efficient (isPredTy has to take the kind of the type). See Note [Function types] in TyCoRep. There are lots of consequences * I made FunTy into a record, so that it'll be easier when we add a linearity field, something that is coming down the road. * Lots of code gets touched in a routine way, simply because it pattern matches on FunTy. * I wanted to make a pattern synonym for (FunTy2 arg res), which picks out just the argument and result type from the record. But alas the pattern-match overlap checker has a heart attack, and either reports false positives, or takes too long. In the end I gave up on pattern synonyms. There's some commented-out code in TyCoRep that shows what I wanted to do. * Much more clarity about predicate types, constraint types and (in particular) equality constraints in kinds. See TyCoRep Note [Types for coercions, predicates, and evidence] and Note [Constraints in kinds]. This made me realise that we need an AnonArgFlag on AnonTCB in a TyConBinder, something that was really plain wrong before. See TyCon Note [AnonTCB InivsArg] * When building function types we must know whether we need VisArg (mkVisFunTy) or InvisArg (mkInvisFunTy). This turned out to be pretty easy in practice. * Pretty-printing of types, esp in IfaceType, gets tidier, because we were already recording the (->) vs (=>) distinction in an ad-hoc way. Death to IfaceFunTy. * mkLamType needs to keep track of whether it is building (t1 -> t2) or (t1 => t2). See Type Note [mkLamType: dictionary arguments] Other minor stuff * Some tidy-up in validity checking involving constraints; Trac #16263 - - - - - e61f6e35 by Vladislav Zavialov at 2019-02-23T21:37:52-05:00 Expression/command ambiguity resolution This patch removes 'HsArrApp' and 'HsArrForm' from 'HsExpr' by introducing a new ambiguity resolution system in the parser. Problem: there are places in the grammar where we do not know whether we are parsing an expression or a command: proc x -> do { (stuff) -< x } -- 'stuff' is an expression proc x -> do { (stuff) } -- 'stuff' is a command Until we encounter arrow syntax (-<) we don't know whether to parse 'stuff' as an expression or a command. The old solution was to parse as HsExpr always, and rejig later: checkCommand :: LHsExpr GhcPs -> P (LHsCmd GhcPs) This meant polluting 'HsExpr' with command-related constructors. In other words, limitations of the parser were affecting the AST, and all other code (the renamer, the typechecker) had to deal with these extra constructors by panicking. We fix this abstraction leak by parsing into an intermediate representation, 'ExpCmd': data ExpCmdG b where ExpG :: ExpCmdG HsExpr CmdG :: ExpCmdG HsCmd type ExpCmd = forall b. ExpCmdG b -> PV (Located (b GhcPs)) checkExp :: ExpCmd -> PV (LHsExpr GhcPs) checkCmd :: ExpCmd -> PV (LHsCmd GhcPs) checkExp f = f ExpG -- interpret as an expression checkCmd f = f CmdG -- interpret as a command See Note [Ambiguous syntactic categories] for details. Now the intricacies of parsing have no effect on the hsSyn AST when it comes to the expression/command ambiguity. Future work: apply the same principles to the expression/pattern ambiguity. - - - - - ee284b85 by Herbert Valerio Riedel at 2019-02-23T21:43:58-05:00 Fix regression incorrectly advertising TH support `--supported-languages` must only advertise language extensions which are supported by the compiler in order for tooling such as Cabal relying on this signalling not to behave incorrectly. Fixes #16331 - - - - - a990312e by Matthew Pickering at 2019-02-23T21:50:02-05:00 Exit with exit code 1 when tests unexpectedly pass This was causing gitlab to not report from builds as failing. It also highlighted a problem with the LLVM tests where some of the external interpreter tests are failing. - - - - - 1059e234 by Ben Gamari at 2019-02-23T21:56:06-05:00 gitlab-ci: Only build x86_64-deb8 and fedora27 for releases These are largely redundant as they are covered by x86_64-deb9. - - - - - b85068f6 by Sebastian Graf at 2019-02-23T22:02:10-05:00 Include closure header size in StgLamLift's estimations While playing around with late lambda lifting, I realised that StgLamLift.Analysis doesn't consider the removed closure header in its allocation estimations. That's because contrary to what I thought, the total word count returned by `mkVirtHeapOffsets` doesn't include the size of the closure header. We just add the header size manually now. - - - - - 88970187 by Vladislav Zavialov at 2019-02-23T22:08:15-05:00 User's Guide: update info on kind inference We no longer put class variables in front, see "Taming the Kind Inference Monster" (also fix some markup issues) - - - - - ae7d1ff6 by Vladislav Zavialov at 2019-02-23T22:14:19-05:00 User's Guide: forall is a keyword nowadays - - - - - 6ba3421e by Ben Gamari at 2019-02-23T22:20:25-05:00 testsuite: Fix whitespace in hp2ps error message - - - - - 9059343e by Alexandre at 2019-02-24T16:17:06-05:00 base: Allow fusion for zip7 and related Fixes #14037. Metric Decrease: T9872b T9872d Reviewers: bgamari, simonpj, hvr Reviewed By: simonpj Subscribers: AndreasK, simonpj, osa1, dfeuer, rwbarton, carter GHC Trac Issues: #14037 Differential Revision: https://phabricator.haskell.org/D5249 - - - - - 14586f5d by Vladislav Zavialov at 2019-02-24T16:23:11-05:00 Disable fragile test cases: T14697 T5559 T3424 See Trac #15072, Trac #16349, Trac #16350 - - - - - f320f3b2 by Vladislav Zavialov at 2019-02-25T19:19:24+03:00 Fix the ghci063 test on Darwin (Trac #16201) We use "touch -r" to set modification timestamps, which leads to precision loss on Darwin. For example, before: 2019-02-25 01:11:23.807627350 +0300 after: 2019-02-25 01:11:23.807627000 +0300 ^^^ This means we can't trick GHCi into thinking the file hasn't been changed by restoring its old timestamp, as we cannot faithfully restore all digits. The solution is to nullify the insignificant digits before the first :load - - - - - 4dbacba5 by Vladislav Zavialov at 2019-02-26T12:36:42-05:00 Skip T3424 when fast() 14586f5d removed this by accident. - - - - - 5bc195b1 by Vladislav Zavialov at 2019-02-27T09:53:52-05:00 Treat kind/type variables identically, demolish FKTV Implements GHC Proposal #24: .../ghc-proposals/blob/master/proposals/0024-no-kind-vars.rst Fixes Trac #16334, Trac #16315 With this patch, scoping rules for type and kind variables have been unified: kind variables no longer receieve special treatment. This simplifies both the language and the implementation. User-facing changes ------------------- * Kind variables are no longer implicitly quantified when an explicit forall is used: p :: Proxy (a :: k) -- still accepted p :: forall k a. Proxy (a :: k) -- still accepted p :: forall a. Proxy (a :: k) -- no longer accepted In other words, now we adhere to the "forall-or-nothing" rule more strictly. Related function: RnTypes.rnImplicitBndrs * The -Wimplicit-kind-vars warning has been deprecated. * Kind variables are no longer implicitly quantified in constructor declarations: data T a = T1 (S (a :: k) | forall (b::k). T2 (S b) -- no longer accepted data T (a :: k) = T1 (S (a :: k) | forall (b::k). T2 (S b) -- still accepted Related function: RnTypes.extractRdrKindSigVars * Implicitly quantified kind variables are no longer put in front of other variables: f :: Proxy (a :: k) -> Proxy (b :: j) f :: forall k j (a :: k) (b :: j). Proxy a -> Proxy b -- old order f :: forall k (a :: k) j (b :: j). Proxy a -> Proxy b -- new order This is a breaking change for users of TypeApplications. Note that we still respect the dpendency order: 'k' before 'a', 'j' before 'b'. See "Ordering of specified variables" in the User's Guide. Related function: RnTypes.rnImplicitBndrs * In type synonyms and type family equations, free variables on the RHS are no longer implicitly quantified unless used in an outermost kind annotation: type T = Just (Nothing :: Maybe a) -- no longer accepted type T = Just Nothing :: Maybe (Maybe a) -- still accepted The latter form is a workaround due to temporary lack of an explicit quantification method. Ideally, we would write something along these lines: type T @a = Just (Nothing :: Maybe a) Related function: RnTypes.extractHsTyRdrTyVarsKindVars * Named wildcards in kinds are fixed (Trac #16334): x :: (Int :: _t) -- this compiles, infers (_t ~ Type) Related function: RnTypes.partition_nwcs Implementation notes -------------------- * One of the key changes is the removal of FKTV in RnTypes: - data FreeKiTyVars = FKTV { fktv_kis :: [Located RdrName] - , fktv_tys :: [Located RdrName] } + type FreeKiTyVars = [Located RdrName] We used to keep track of type and kind variables separately, but now that they are on equal footing when it comes to scoping, we can put them in the same list. * extract_lty and family are no longer parametrized by TypeOrKind, as we now do not distinguish kind variables from type variables. * PatSynExPE and the related Note [Pattern synonym existentials do not scope] have been removed (Trac #16315). With no implicit kind quantification, we can no longer trigger the error. * reportFloatingKvs and the related Note [Free-floating kind vars] have been removed. With no implicit kind quantification, we can no longer trigger the error. - - - - - 5c084e04 by Peter Trommler at 2019-02-27T09:59:59-05:00 RTS: Add missing memory barrier In the work stealing queue a load-load-barrier is required to ensure that a read of queue data cannot be reordered before a read of the bottom pointer into the queue. The added load-load-barrier ensures that the ordering of writes enforced at the end of `pushWSDeque` is also respected in the order of reads in `stealWSDeque_`. In other words, when reading `q->bottom` we want to make sure that we see the updates to `q->elements`. Fixes #13633 - - - - - 2e8f6649 by Vladislav Zavialov at 2019-02-27T10:06:05-05:00 Fix intermittent hie002 failure hie002 is a performance test that used to fail unpredictably: max_bytes_used Decrease from x86_64-linux-deb9-debug baseline @ HEAD~2: Expected hie002 (normal) max_bytes_used: 1190923992.0 +/-20% Lower bound hie002 (normal) max_bytes_used: 952739193 Upper bound hie002 (normal) max_bytes_used: 1429108791 Actual hie002 (normal) max_bytes_used: 726270784 Deviation hie002 (normal) max_bytes_used: -39.0 % peak_megabytes_allocated Decrease from x86_64-linux-deb9-debug baseline @ HEAD~2: Expected hie002 (normal) peak_megabytes_allocated: 2538.0 +/-20% Lower bound hie002 (normal) peak_megabytes_allocated: 2030 Upper bound hie002 (normal) peak_megabytes_allocated: 3046 Actual hie002 (normal) peak_megabytes_allocated: 1587 Deviation hie002 (normal) peak_megabytes_allocated: -37.5 % *** unexpected stat test failure for hie002(normal) 'max_bytes_used' and 'peak_megabytes_allocated' are too unstable without careful control of the runtime configuration. We fix this by using a more predictable metric, 'bytes allocated'. - - - - - f838809f by Moritz Angermann at 2019-02-28T02:20:05-05:00 Cleanup iserv/iserv-proxy This adds trace messages that include the processes name and as such make debugging and following the communication easier. It also adds a note regarding the fwd*Call proxy-communication logic between the proxy and the slave. The proxy will now also poll for 60s to wait for the remote iserv to come up. (Alternatively you can start the remote process beforehand; and just have iserv-proxy connect to it) - - - - - c26d299d by Ryan Scott at 2019-03-01T16:26:02-05:00 Visible dependent quantification This implements GHC proposal 35 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0035-forall-arrow.rst) by adding the ability to write kinds with visible dependent quantification (VDQ). Most of the work for supporting VDQ was actually done _before_ this patch. That is, GHC has been able to reason about kinds with VDQ for some time, but it lacked the ability to let programmers directly write these kinds in the source syntax. This patch is primarly about exposing this ability, by: * Changing `HsForAllTy` to add an additional field of type `ForallVisFlag` to distinguish between invisible `forall`s (i.e, with dots) and visible `forall`s (i.e., with arrows) * Changing `Parser.y` accordingly The rest of the patch mostly concerns adding validity checking to ensure that VDQ is never used in the type of a term (as permitting this would require full-spectrum dependent types). This is accomplished by: * Adding a `vdqAllowed` predicate to `TcValidity`. * Introducing `splitLHsSigmaTyInvis`, a variant of `splitLHsSigmaTy` that only splits invisible `forall`s. This function is used in certain places (e.g., in instance declarations) to ensure that GHC doesn't try to split visible `forall`s (e.g., if it tried splitting `instance forall a -> Show (Blah a)`, then GHC would mistakenly allow that declaration!) This also updates Template Haskell by introducing a new `ForallVisT` constructor to `Type`. Fixes #16326. Also fixes #15658 by documenting this feature in the users' guide. - - - - - f37efb11 by Alec Theriault at 2019-03-01T16:32:09-05:00 Lexer: turn some fatal errors into non-fatal ones The following previously fatal lexer errors are now non-fatal: * errors about enabling `LambdaCase` * errors about enabling `NumericUnderscores` * errors about having valid characters in primitive strings See #16270 - - - - - 8442103a by Alp Mestanogullari at 2019-03-01T16:38:15-05:00 Hadrian: introduce ways to skip some documentation targets The initial motivation for this is to have a chance to run the binary distribution rules in our Windows CI without having to install sphinx-build and xelatex there, while retaining the ability to generate haddocks. I just ended up extending this idea a little bit so as to have control over whether we build haddocks, (sphinx) HTML manuals, (sphinx) PDF manuals and (sphinx) manpages. - - - - - 9aa27273 by Alp Mestanogullari at 2019-03-01T16:38:15-05:00 use --docs=no-sphinx in both Hadrian CI jobs - - - - - b1c7ffaf by David Eichmann at 2019-03-01T16:44:22-05:00 Fix parsing of expected performance changes for tests with non-alpha characters. Python's split() function is used to split on all white space. - - - - - b90695cd by Ben Gamari at 2019-03-01T17:06:49-05:00 gitlab-ci: Pull docker images from ghc/ci-images registry - - - - - 161f102b by Ben Gamari at 2019-03-01T17:07:28-05:00 Drop Docker images These have been moved to the ghc/ci-images project. - - - - - d298cb9c by Ben Gamari at 2019-03-01T17:07:28-05:00 gitlab-ci: Produce DWARF-enabled binary distribution - - - - - aeefc90c by Ben Gamari at 2019-03-01T17:07:28-05:00 testsuite: Suppress ticks when comparing -ddump-simpl output Otherwise these tests break spuriously when core libraries are compiled with source notes. - - - - - 1bceb643 by Ben Gamari at 2019-03-01T17:07:28-05:00 gitlab-ci: Give deb9-unreg job a distinct cache key - - - - - 1285d6b9 by Ben Gamari at 2019-03-02T18:32:22-05:00 gitlab-ci: A bit of reorganization - - - - - f77229e3 by Alp Mestanogullari at 2019-03-03T19:35:18-05:00 detect 'autoreconf' path during configure, and use it in hadrian - - - - - e2ae52c3 by Alec Theriault at 2019-03-04T10:18:41-05:00 Don't leave .hi files after running Haddock tests RyanGlScott observed in https://github.com/haskell/haddock/issues/1030 that running Haddock tests in GHC's testsuite left some `.hi` files around in `utils/haddock`. This should fix that problem. - - - - - 22c2713b by Alp Mestanogullari at 2019-03-04T10:18:41-05:00 Hadrian: track mingw, ship it in bindists, more robust install script - - - - - e7080bef by Ben Gamari at 2019-03-04T10:18:41-05:00 Revert "compiler: Refactor: extract `withAtomicRename`" This reverts commit e8a08f400744a860d1366c6680c8419d30f7cc2a. - - - - - e6ce1743 by Ben Gamari at 2019-03-04T10:18:41-05:00 Revert "compiler: Write .o files atomically. See #14533" This reverts commit 0e2d300a59b1b5c167d2e7d99a448c8663ba6d7d. - - - - - 80dfcee6 by Simon Peyton Jones at 2019-03-05T03:09:41-05:00 Be more careful when naming TyCon binders This patch fixes two rather gnarly test cases: * Trac #16342 (mutual recursion) See Note [Tricky scoping in generaliseTcTyCon] * Trac #16221 (shadowing) See Note [Unification variables need fresh Names] The main changes are: * Substantial reworking of TcTyClsDecls.generaliseTcTyCon This is the big change, and involves the rather tricky function TcHsSyn.zonkRecTyVarBndrs. See Note [Inferring kinds for type declarations] and Note [Tricky scoping in generaliseTcTyCon] for the details. * bindExplicitTKBndrs_Tv and bindImplicitTKBndrs_Tv both now allocate /freshly-named/ unification variables. Indeed, more generally, unification variables are always fresh; see Note [Unification variables need fresh Names] in TcMType * Clarify the role of tcTyConScopedTyVars. See Note [Scoped tyvars in a TcTyCon] in TyCon As usual, this dragged in some more refactoring: * Renamed TcMType.zonkTyCoVarBndr to zonkAndSkolemise * I renamed checkValidTelescope to checkTyConTelescope; it's only used on TyCons, and indeed takes a TyCon as argument. * I folded the slightly-mysterious reportFloatingKvs into checkTyConTelescope. (Previously all its calls immediately followed a call to checkTyConTelescope.) It makes much more sense there. * I inlined some called-once functions to simplify checkValidTyFamEqn. It's less spaghetti-like now. * This patch also fixes Trac #16251. I'm not quite sure why #16251 went wrong in the first place, nor how this patch fixes it, but hey, it's good, and life is short. - - - - - 6c4e45b0 by David Eichmann at 2019-03-05T03:15:47-05:00 Test Runner: don't show missing baseline warning for performance tests with expected changes on the current commit. Trac #16359 - - - - - 646b6dfb by Krzysztof Gogolewski at 2019-03-05T03:21:53-05:00 Fix map/coerce rule for newtypes with wrappers This addresses Trac #16208 by marking newtype wrapper unfoldings as compulsory. Furthermore, we can remove the special case for newtypes in exprIsConApp_maybe (introduced in 7833cf407d1f). - - - - - 37f257af by Ben Gamari at 2019-03-05T22:22:40-05:00 Rip out object splitting The splitter is an evil Perl script that processes assembler code. Its job can be done better by the linker's --gc-sections flag. GHC passes this flag to the linker whenever -split-sections is passed on the command line. This is based on @DemiMarie's D2768. Fixes Trac #11315 Fixes Trac #9832 Fixes Trac #8964 Fixes Trac #8685 Fixes Trac #8629 - - - - - 23342e1f by Ömer Sinan Ağacan at 2019-03-05T22:28:45-05:00 rts/Printer: Introduce a few more printing utilities These include printLargeAndPinnedObjects, printWeakLists, and printStaticObjects. These are generally useful things to have. - - - - - c19a401d by Ömer Sinan Ağacan at 2019-03-05T22:28:45-05:00 rts/Printer: Print forwarding pointers - - - - - db039a4a by Ryan Scott at 2019-03-05T22:40:54-05:00 Add regression test for #15918 The test case in #15918 no longer triggers an `ASSERT` failure on GHC HEAD, likely due to commit 682783828275cca5fd8bf5be5b52054c75e0e22c (`Make a smart mkAppTyM`). This patch adds a regression test for #15918 to finally put it to rest. - - - - - 2ff77b98 by P.C. Shyamshankar at 2019-03-06T09:17:22-05:00 Handle absolute paths to build roots in Hadrian. Fixes #16187. This patch fixes various path concatenation issues to allow functioning builds with hadrian when the build root location is specified with an absolute path. Remarks: - The path concatenation operator (-/-) now handles absolute second operands appropriately. Its behavior should match that of POSIX (</>) in this regard. - The `getDirectoryFiles*` family of functions only searches for matches under the directory tree rooted by its first argument; all of the results are also relative to this root. If the first argument is the empty string, the current working directory is used. This patch passes the appropriate directory (almost always either `top` or `root`), and subsequently attaches that directory prefix so that the paths refer to the appropriate files. - Windows `tar` does not like colons (':') in paths to archive files, it tries to resolve them as remote paths. The `--force-local` option remedies this, and is applied on windows builds. - - - - - 5aab1d9c by Ömer Sinan Ağacan at 2019-03-06T15:53:32-05:00 rts: Unglobalize dead_weak_ptr_list and resurrected_threads In the concurrent nonmoving collector we will need the ability to call `traverseWeakPtrList` concurrently with minor generation collections. This global state stands in the way of this. However, refactoring it away is straightforward since this list only persists the length of a single GC. - - - - - a4944d8d by Ben Gamari at 2019-03-06T15:53:32-05:00 Fix it - - - - - 78dd04f9 by Ryan Scott at 2019-03-06T16:05:45-05:00 Fix #16385 by appending _maybe to a use of lookupGlobalOcc `instance forall c. c` claimed that `c` was out of scope because the renamer was invoking `lookupGlobalOcc` on `c` (in `RnNames.getLocalNonValBinders`) without binding `c` first. To avoid this, this patch changes GHC to invoke `lookupGlobalOcc_maybe` on `c` instead, and if that returns `Nothing`, then bail out, resulting in a better error message. - - - - - 3caeb443 by Zejun Wu at 2019-03-06T16:11:52-05:00 Move reifyGHCi function into GhciMonad type class This was the suggested change in !176 but missed the batch merge (!263). - - - - - 4ca271d1 by Ben Gamari at 2019-03-06T21:48:10-05:00 testsuite: Introduce fragile modifier Now since we have been a bit more stringent in testsuite cleanliness we have been marking a lot of tests as fragile using the `skip` modifier. However, this unfortunately means that we lose the association with the ticket number documenting the fragility. Here we introduce `fragile` and `fragile_for` to retain this information. - - - - - 910185a3 by Ben Gamari at 2019-03-06T21:48:10-05:00 testsuite: Mark heapprof001 as fragile on i386 - - - - - a65bcbe7 by Ben Gamari at 2019-03-06T21:48:10-05:00 testsuite: Use fragile modifier for more tests - - - - - f624dc15 by Ben Gamari at 2019-03-06T21:48:10-05:00 gitlab-ci: Don't allow i386-deb9 to fail Also account for testsuite metric drift. Metric Increase: haddock.Cabal haddock.base T14683 - - - - - 07f378ce by Simon Peyton Jones at 2019-03-06T21:54:17-05:00 Add tests for Trac #16221 and #16342 - - - - - 25c3dd39 by Simon Peyton Jones at 2019-03-06T21:54:17-05:00 Test Trac #16263 - - - - - 7a68254a by Phuong Trinh at 2019-03-07T14:01:42-05:00 Fix #16392: revertCAFs in external interpreter when necessary We revert CAFs when loading/adding modules in ghci (presumably to refresh execution states and to allow for object code to be unloaded from the runtime). However, with `-fexternal-interpreter` enabled, we are only doing it in the ghci process instead of the external interpreter process where the cafs are allocated and computed. This makes sure that revertCAFs is done in the appropriate process no matter if that flag is present or not. - - - - - 068b7e98 by Ryan Scott at 2019-03-07T14:07:49-05:00 Fix #16391 by using occCheckExpand in TcValidity The type-variables-escaping-their-scope-via-kinds check in `TcValidity` was failing to properly expand type synonyms, which led to #16391. This is easily fixed by using `occCheckExpand` before performing the validity check. Along the way, I refactored this check out into its own function, and sprinkled references to Notes to better explain all of the moving parts. Many thanks to @simonpj for the suggestions. Bumps the haddock submodule. - - - - - 1675d40a by Sebastian Graf at 2019-03-07T20:44:08-05:00 Always do the worker/wrapper split for NOINLINEs Trac #10069 revealed that small NOINLINE functions didn't get split into worker and wrapper. This was due to `certainlyWillInline` saying that any unfoldings with a guidance of `UnfWhen` inline unconditionally. That isn't the case for NOINLINE functions, so we catch this case earlier now. Nofib results: -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- fannkuch-redux -0.3% 0.0% gg +0.0% +0.1% maillist -0.2% -0.2% minimax 0.0% -0.8% -------------------------------------------------------------------------------- Min -0.3% -0.8% Max +0.0% +0.1% Geometric Mean -0.0% -0.0% Fixes #10069. ------------------------- Metric Increase: T9233 ------------------------- - - - - - 48927a9a by Alp Mestanogullari at 2019-03-08T05:50:26-05:00 Hadrian: various improvements around the 'test' rule - introduce a -k/--keep-test-files flag to prevent cleanup - add -dstg-lint to the options that are always passed to tests - infer library ways from the compiler to be tested instead of getting them from the flavour (like make) - likewise for figuring out whether the compiler to be tested is "debugged" - specify config.exeext - correctly specify config.in_tree_compiler, instead of always passing True - fix formatting of how we pass a few test options - add (potential) extensions to check-* program names - build check-* programs with the compiler to be tested - set TEST_HC_OPTS_INTERACTIVE and PYTHON env vars when running tests - - - - - 5d744143 by Andrey Mokhov at 2019-03-08T05:56:32-05:00 Hadrian: Drop remaining symlink traversal code from build scripts This partly resolves #16325 (https://ghc.haskell.org/trac/ghc/ticket/16325). As previously discussed in https://github.com/snowleopard/hadrian/issues/667, we do not need the symlink traversal code in build scripts. However, it appears we forgot to delete this code from our Stack-based build scripts, which led to placing all build artefacts in an unexpected location when using Hadrian in combination with symlink trees. This commit fixes this. - - - - - 82628254 by Vladislav Zavialov at 2019-03-08T06:02:37-05:00 Testsuite: use 'fragile' instead of 'skip' for T3424, T14697 Also, replace some tabs with spaces to avoid a "mixed indent" warning that vim gives me. - - - - - 5be7ad78 by Simon Peyton Jones at 2019-03-08T06:08:41-05:00 Use captureTopConstraints in TcRnDriver calls Trac #16376 showed the danger of failing to report an error that exists only in the unsolved constraints, if an exception is raised (via failM). Well, the commit 5c1f268e (Fail fast in solveLocalEqualities) did just that -- i.e. it found errors in the constraints, and called failM to avoid a misleading cascade. So we need to be sure to call captureTopConstraints to report those insolubles. This was wrong in TcRnDriver.tcRnExpr and in TcRnDriver.tcRnType. As a result the error messages from test T13466 improved slightly, a happy outcome. - - - - - 224a6b86 by Sylvain Henry at 2019-03-08T14:05:10-05:00 TH: support raw bytes literals (#14741) GHC represents String literals as ByteString internally for efficiency reasons. However, until now it wasn't possible to efficiently create large string literals with TH (e.g. to embed a file in a binary, cf #14741): TH code had to unpack the bytes into a [Word8] that GHC then had to re-pack into a ByteString. This patch adds the possibility to efficiently create a "string" literal from raw bytes. We get the following compile times for different sizes of TH created literals: || Size || Before || After || Gain || || 30K || 2.307s || 2.299 || 0% || || 3M || 3.073s || 2.400s || 21% || || 30M || 8.517s || 3.390s || 60% || Ticket #14741 can be fixed if the original code uses this new TH feature. - - - - - 2762f94d by Roland Senn at 2019-03-08T14:11:19-05:00 Fix #13839: GHCi warnings do not respect the default module header - - - - - 1f5cc9dc by Simon Peyton Jones at 2019-03-09T02:07:53-05:00 Stop inferring over-polymorphic kinds Before this patch GHC was trying to be too clever (Trac #16344); it succeeded in kind-checking this polymorphic-recursive declaration data T ka (a::ka) b = MkT (T Type Int Bool) (T (Type -> Type) Maybe Bool) As Note [No polymorphic recursion] discusses, the "solution" was horribly fragile. So this patch deletes the key lines in TcHsType, and a wodge of supporting stuff in the renamer. There were two regressions, both the same: a closed type family decl like this (T12785b) does not have a CUSK: type family Payload (n :: Peano) (s :: HTree n x) where Payload Z (Point a) = a Payload (S n) (a `Branch` stru) = a To kind-check the equations we need a dependent kind for Payload, and we don't get that any more. Solution: make it a CUSK by giving the result kind -- probably a good thing anyway. The other case (T12442) was very similar: a close type family declaration without a CUSK. - - - - - cfbedf17 by Niklas Hambüchen at 2019-03-09T02:14:13-05:00 compiler: Write .o files atomically. See #14533 This issue was reproduced with, and the fix confirmed with, the `hatrace` tool for syscall-based fault injection: https://github.com/nh2/hatrace The concrete test case for GHC is at https://github.com/nh2/hatrace/blob/e23d35a2d2c79e8bf49e9e2266b3ff7094267f29/test/HatraceSpec.hs#L185 A previous, nondeterministic reproducer for the issue was provided by Alexey Kuleshevich in https://github.com/lehins/exec-kill-loop Signed-off-by: Niklas Hambüchen <niklas at fpcomplete.com> Reviewed-by: Alexey Kuleshevich <alexey at fpcomplete.com> - - - - - 08ad38a9 by Niklas Hambüchen at 2019-03-09T02:14:13-05:00 compiler: Refactor: extract `withAtomicRename` - - - - - e76ee675 by Ben Gamari at 2019-03-09T07:30:17-05:00 rts: Factor out large bitmap walking This will be needed by the mark phase of the non-moving collector so let's factor it out. - - - - - 6e3e537e by Edward Z. Yang at 2019-03-09T07:36:26-05:00 Make bkpcabal01 test compatible with new ordering requirements. Previously, our test did something like this: 1. Typecheck p 2. Typecheck q (which made use of an instantiated p) 3. Build instantiated p 4. Build instantiated q Cabal previously permitted this, under the reasoning that during typechecking there's no harm in using the instantiated p even if we haven't build it yet; we'll just instantiate it on the fly with p. However, this is not true! If q makes use of a Template Haskell splice from p, we absolutely must have built the instantiated p before we typecheck q, since this typechecking will need to run some splices. Cabal now complains that you haven't done it correctly, which we indeed have not! Reordering so that we do this: 1. Typecheck p 3. Build instantiated p 2. Typecheck q (which made use of an instantiated p) 4. Build instantiated q Fixes the problem. If Cabal had managed the ordering itself, it would have gotten it right. Signed-off-by: Edward Z. Yang <ezyang at fb.com> - - - - - 6b2f0991 by Sylvain Henry at 2019-03-09T07:42:34-05:00 NCG: correctly escape path strings on Windows (#16389) GHC native code generator generates .incbin and .file directives. We need to escape those strings correctly on Windows (see #16389). - - - - - b760269c by Ben Gamari at 2019-03-09T07:48:38-05:00 Rip out perl dependency The object splitter was the last major user of perl. There remain a few uses in nofib but we can just rely on the system's perl for this since it's not critical to the build. - - - - - 0cd98957 by Ben Gamari at 2019-03-09T07:48:38-05:00 Drop utils/count_lines This doesn't appear to be used anywhere in the build system and it relies on perl. Drop it. - - - - - bcb6769c by Alec Theriault at 2019-03-11T18:11:59-04:00 Ignore more version numbers in the testsuite Prevents some tests from failing just due to mismatched version numbers. These version numbers shouldn't cause tests to fail, especially since we *expect* them to be regularly incremented. The motivation for this particular set of changes came from the changes that came along with the `base` version bump in 8f19ecc95fbaf2cc977531d721085d8441dc09b7. - - - - - 60b03ade by Krzysztof Gogolewski at 2019-03-11T18:18:06-04:00 Change the warning in substTy back to an assertion We'd like to enforce the substitution invariant (Trac #11371). In a492af06d326453 the assertion was downgraded to a warning; I'm restoring the assertion and making the calls that don't maintain the invariant as unchecked. - - - - - 2f453414 by Krzysztof Gogolewski at 2019-03-11T18:18:06-04:00 Add a test for Trac #13951 It no longer gives a warning. - - - - - b2322310 by Matthew Pickering at 2019-03-12T09:04:52-04:00 Hadrian: Allow passing CABFLAGS into build.cabal.sh Setting `CABFLAGS=args` will pass the additional arguments to cabal when it is invoked. - - - - - 61264556 by Matthew Pickering at 2019-03-12T09:04:52-04:00 Hadrian: Make libsuf and distDir stage aware The version suffix needs to be the version of the stage 0 compiler when building shared libraries with the stage 0 compiler. - - - - - 705fa21d by Matthew Pickering at 2019-03-12T09:04:52-04:00 Hadrian: Make makeRelativeNoSysLink total makeRelativeNoSysLink would previously crash for no reason if the first argument as `./` due to the call to `head`. This refactoring keeps the behaviour the same but doesn't crash in this corner case. - - - - - 4cf2160a by Matthew Pickering at 2019-03-12T09:04:52-04:00 Hadrian: Fix rpath so shared objects work after being copied After being copied all the shared objects end up in the same directory. Therefore the correct rpath is `$ORIGIN` rather than the computed path which is relative to the directory where it is built. - - - - - 2d7dd028 by Matthew Pickering at 2019-03-12T09:04:52-04:00 Hadrian: Add ./hadrian/ghci.sh script for fast development feedback Running the `./hadrian/ghci` target will load the main compiler into a ghci session. This is intended for fast development feedback, modules are only typechecked so it isn't possible to run any functions in the repl. You can also use this target with `ghcid`. The first time this command is run hadrian will need to compile a few dependencies which will take 1-2 minutes. Loading GHC into GHCi itself takes about 30 seconds. Internally this works by calling a new hadrian target called `tool-args`. This target prints out the package and include flags which are necessary to load files into ghci. The same target is intended to be used by other tooling which uses the GHC API in order to set up the correct GHC API session. For example, using this target it is also possible to use HIE when developing on GHC. - - - - - bb684e65 by Matthew Pickering at 2019-03-12T09:04:52-04:00 Remove training whitespace - - - - - 72c455a4 by Matthew Pickering at 2019-03-12T09:04:52-04:00 CI: Add ghc-in-ghci build job This is a separate build job to the other hadrian jobs as it only takes about 2-3 minutes to run from cold. The CI tests that the `./hadrian/ghci` script loads `ghc/Main.hs` successfully. - - - - - 5165378d by Matthew Pickering at 2019-03-12T09:04:52-04:00 Remove trailing whitespace - - - - - 50249a9f by Simon Peyton Jones at 2019-03-12T09:13:28-04:00 Use transSuperClasses in TcErrors Code in TcErrors was recursively using immSuperClasses, which loops in the presence of UndecidableSuperClasses. Better to use transSuperClasses instead, which has a loop-breaker mechanism built in. Fixes issue #16414. - - - - - 62db9295 by Ömer Sinan Ağacan at 2019-03-12T09:19:29-04:00 Remove duplicate functions in StgCmmUtils, use functions from CgUtils Also remove unused arg from get_Regtable_addr_from_offset - - - - - 4db9bdd9 by Ryan Scott at 2019-03-12T09:25:39-04:00 Add regression test for #16347 Commit 1f5cc9dc8aeeafa439d6d12c3c4565ada524b926 ended up fixing #16347. Let's add a regression test to ensure that it stays fixed. - - - - - 02ddf947 by Matthew Pickering at 2019-03-12T09:42:53-04:00 CI: Update ci-images commit - - - - - a0cab873 by Matthew Pickering at 2019-03-12T09:44:45-04:00 Revert: Update ci-images commit - - - - - 23fc6156 by Ben Gamari at 2019-03-13T15:03:53-04:00 testsuite: Mark heapprof001 as fragile on all platforms See #15382. - - - - - cb17c2da by Alp Mestanogullari at 2019-03-13T15:10:01-04:00 Hadrian: build (and retrieve) binary distributions in CI With all the recent fixes to the binary-dist rule in Hadrian, we can now run that rule in CI and keep the bindists around in gitlab as artifacts, just like we do for the make CI jobs. To get 'autoreconf' to work in the Windows CI, we have to run it through the shell interpreter, so this commit does that along the way. - - - - - 36546a43 by Ryan Scott at 2019-03-13T15:16:08-04:00 Fix #16411 by making dataConCannotMatch aware of (~~) The `dataConCannotMatch` function (which powers the `-Wpartial-fields` warning, among other things) had special reasoning for explicit equality constraints of the form `a ~ b`, but it did not extend that reasoning to `a ~~ b` constraints, leading to #16411. Easily fixed. - - - - - 10a97120 by Ben Gamari at 2019-03-14T12:20:50-04:00 testsuite: Add testcase for #16394 - - - - - 8162eab2 by Ryan Scott at 2019-03-15T09:59:30-04:00 Remove the GHCi debugger's panicking isUnliftedType check The GHCi debugger has never been that robust in the face of higher-rank types, or even types that are _interally_ higher-rank, such as the types of many class methods (e.g., `fmap`). In GHC 8.2, however, things became even worse, as the debugger would start to _panic_ when a user tries passing the name of a higher-rank thing to `:print`. This all ties back to a strange `isUnliftedType` check in `Debugger` that was mysteriously added 11 years ago (in commit 4d71f5ee6dbbfedb4a55767e4375f4c0aadf70bb) with no explanation whatsoever. After some experimentation, no one is quite sure what this `isUnliftedType` check is actually accomplishing. The test suite still passes if it's removed, and I am unable to observe any differences in debugger before even with data types that _do_ have fields of unlifted types (e.g., `data T = MkT Int#`). Given that this is actively causing problems (see #14828), the prudent thing to do seems to be just removing this `isUnliftedType` check, and waiting to see if anyone shouts about it. This patch accomplishes just that. Note that this patch fix the underlying issues behind #14828, as the debugger will still print unhelpful info if you try this: ``` λ> f :: (forall a. a -> a) -> b -> b; f g x = g x λ> :print f f = (_t1::t1) ``` But fixing this will require much more work, so let's start with the simple stuff for now. - - - - - d10e2368 by David Eichmann at 2019-03-15T10:05:38-04:00 Hadrian: remove unneeded imports. - - - - - 4df75772 by David Eichmann at 2019-03-15T10:05:38-04:00 Hadrian: remove unneeded rpaths. Issue #12770 - - - - - afc80730 by David Eichmann at 2019-03-15T10:11:47-04:00 Git ignore .hadrian_ghci (generated by the ./hadrian/ghci.sh) [skip ci] - - - - - 610ec224 by Ryan Scott at 2019-03-15T10:17:54-04:00 Update Trac ticket URLs to point to GitLab This moves all URL references to Trac tickets to their corresponding GitLab counterparts. - - - - - 97032ed9 by Simon Peyton Jones at 2019-03-15T10:24:01-04:00 Report better suggestion for GADT data constructor This addresses issue #16427. An easy fix. - - - - - 83e09d3c by Peter Trommler at 2019-03-15T10:30:08-04:00 PPC NCG: Use liveness information in CmmCall We make liveness information for global registers available on `JMP` and `BCTR`, which were the last instructions missing. With complete liveness information we do not need to reserve global registers in `freeReg` anymore. Moreover we assign R9 and R10 to callee saves registers. Cleanup by removing `Reg_Su`, which was unused, from `freeReg` and removing unused register definitions. The calculation of the number of floating point registers is too conservative. Just follow X86 and specify the constants directly. Overall on PowerPC this results in 0.3 % smaller code size in nofib while runtime is slightly better in some tests. - - - - - 57201beb by Simon Peyton Jones at 2019-03-15T10:36:14-04:00 Add flavours link - - - - - 4927117c by Simon Peyton Jones at 2019-03-16T08:08:25-04:00 Improve error recovery in the typechecker Issue #16418 showed that we were carrying on too eagerly after a bogus type signature was identified (a bad telescope in fact), leading to a subsequent crash. This led me in to a maze of twisty little passages in the typechecker's error recovery, and I ended up doing some refactoring in TcRnMonad. Some specfifics * TcRnMonad.try_m is now called attemptM. * I switched the order of the result pair in tryTc, to make it consistent with other similar functions. * The actual exception used in the Tc monad is irrelevant so, to avoid polluting type signatures, I made tcTryM, a simple wrapper around tryM, and used it. The more important changes are in * TcSimplify.captureTopConstraints, where we should have been calling simplifyTop rather than reportUnsolved, so that levity defaulting takes place properly. * TcUnify.emitResidualTvConstraint, where we need to set the correct status for a new implication constraint. (Previously we ended up with an Insoluble constraint wrapped in an Unsolved implication, which meant that insolubleWC gave the wrong answer. - - - - - 600a1ac3 by Simon Peyton Jones at 2019-03-16T08:08:25-04:00 Add location to the extra-constraints wildcard The extra-constraints wildcard had lost its location (issue #16431). Happily this is easy to fix. Lots of error improvements. - - - - - 1c1b63d6 by Ben Gamari at 2019-03-16T19:13:36-04:00 compiler: Disable atomic renaming on Windows As discussed in #16450, this feature regresses CI on Windows, causing non-deterministic failures due to missing files. - - - - - 6764da43 by Ben Gamari at 2019-03-16T19:16:56-04:00 gitlab-ci: Explicitly set bindist tarball name - - - - - ad79ccd9 by Ben Gamari at 2019-03-16T19:17:46-04:00 gitlab-ci: Generate documentation tarball - - - - - 3f2291e4 by Ben Gamari at 2019-03-16T19:17:46-04:00 gitlab-ci: Generate source tarballs - - - - - cb61371e by Ben Gamari at 2019-03-17T05:05:10-04:00 ghc-heap: Introduce closureSize This function allows the user to compute the (non-transitive) size of a heap object in words. The "closure" in the name is admittedly confusing but we are stuck with this nomenclature at this point. - - - - - c01d5af3 by Michael Sloan at 2019-03-17T22:23:19-04:00 Extract out use of UnboxedTuples from GHCi.Leak See #13101 + #15454 for motivation. This change reduces the number of modules that need to be compiled to object code when loading GHC into GHCi. - - - - - 6113d0d4 by Radosław Rowicki at 2019-03-17T22:29:25-04:00 Update bug tracker link to point to gitlab instead of deprecated trac - - - - - b8326897 by Ben Gamari at 2019-03-17T23:16:12-04:00 gitlab-ci: Always build fedora27 This ends up being much easier to use than Debian 9 under NixOS. - - - - - acf2129d by Ben Gamari at 2019-03-17T23:17:36-04:00 gitlab-ci: Implement head.hackage jobs - - - - - 71648c35 by Ben Gamari at 2019-03-19T23:04:18-04:00 gitlab-ci: Implement support for i386/Windows bindists - - - - - d94ca74f by Tamar Christina at 2019-03-19T23:10:23-04:00 err: clean up error handler - - - - - 398f2cbc by Ben Gamari at 2019-03-19T23:16:32-04:00 Bump Cabal submodule to 3.0 Metric Increase: haddock.Cabal - - - - - 89a201e8 by Takenobu Tani at 2019-03-19T23:22:36-04:00 users-guide: Update Wiki URLs to point to GitLab The user's guide uses the `ghc-wiki` macro, and substitution rules are complicated. So I manually edited `.rst` files without sed. I changed `Commentary/Latedmd` only to a different page. It is more appropriate as an example. [ci skip] - - - - - 98ff1a56 by Krzysztof Gogolewski at 2019-03-19T23:28:42-04:00 Replace nOfThem by replicate - - - - - 6a47414f by Krzysztof Gogolewski at 2019-03-19T23:28:42-04:00 Fix typos - - - - - 1e26e60d by Krzysztof Gogolewski at 2019-03-19T23:28:42-04:00 Simplify monadic code - - - - - c045bd7c by Krzysztof Gogolewski at 2019-03-19T23:28:42-04:00 Remove deprecated reinitializeGlobals - - - - - 6d19ad72 by Ben Gamari at 2019-03-19T23:34:49-04:00 gitlab-ci: Bump docker images To install lndir and un-break the source distribution job. - - - - - c7a84a60 by Matthew Pickering at 2019-03-19T23:34:50-04:00 Update .gitlab-ci.yml - - - - - db136237 by Ben Gamari at 2019-03-20T18:41:32-04:00 testsuite: Mark T16219 and cabal09 as broken on Windows See #16386. - - - - - 7cd8e330 by Ben Gamari at 2019-03-20T18:41:32-04:00 testsuite: Fix expected output on Windows for various ghci tests Broke as -Wimplicit-kind-vars no longer exists. Specifically ghci024, ghci057 and T9293. - - - - - 23b639fd by Ben Gamari at 2019-03-20T18:41:32-04:00 testsuite: Mark T5836 as broken on Windows See #16387. - - - - - a1bda08d by Ben Gamari at 2019-03-20T18:41:32-04:00 testsuite: Mark T15904 as broken on Windows It seems to look for some sort of manifest file. See #16388. - - - - - b7f5d552 by Ben Gamari at 2019-03-20T18:41:32-04:00 testsuite: Mark T16190 as broken on Windows There seems to be some filepath funniness due to TH embedding going on here. See #16389. - - - - - a0c31f78 by Ben Gamari at 2019-03-20T18:41:32-04:00 testsuite/plugins: Add multi_cpu_race modifier on Windows A few tests previously failed with various failure modes. For instance, `plugin-recomp-change` fails with: ``` Wrong exit code for plugin-recomp-change()(expected 0 , actual 2 ) Stderr ( plugin-recomp-change ): Simple Plugin Passes Queried Got options: Simple Plugin Pass Run C://GitLabRunner//builds//8fc0e283//0//ghc//ghc//inplace//mingw//bin/ld.exe: cannot find -lHSplugin-recompilation-0.1-CPeObcGoBuvHdwBnpK9jQq collect2.exe: error: ld returned 1 exit status `gcc.exe' failed in phase `Linker'. (Exit code: 1) make[2]: *** [Makefile:112: plugin-recomp-change] Error 1 *** unexpected failure for plugin-recomp-change(normal) ``` It's unclear whether the ghc-pkg concurrency issue mentioned in all.T is the culprit but the set of tests that fail overlaps strongly with the set of tests that lack the `multi_cpu_race` modifier. Let's see if adding it fixes them. - - - - - 88a6e9a4 by Ben Gamari at 2019-03-20T18:41:32-04:00 testsuite: Mark T10672 as broken This test, which is only run on Windows, seems to be reliably timing out. See #16390. - - - - - f4d3aaaf by Ben Gamari at 2019-03-20T18:41:32-04:00 testsuite/plugins: Increase compile timeout on Windows I think the linker is routinely eating through the timeout, leading to many spurious failures. - - - - - ae382245 by Ben Gamari at 2019-03-20T18:41:32-04:00 rts/RtsSymbols: Drop __mingw_vsnwprintf As described in #16387, this is already defined by mingw and consequently defining it in the RTS as well leads to multiple definition errors from the RTS linker at runtime. - - - - - f79f93e4 by Ben Gamari at 2019-03-20T18:41:32-04:00 Don't mark cabal09 as broken It doesn't fail reliably. - - - - - d98cb763 by Ben Gamari at 2019-03-20T18:41:32-04:00 testsuite: Don't mark T5836 as broken I believe removing __mingw_vsnwprintf from RtsSymbols fixed #16387. - - - - - 8c1a2743 by Ben Gamari at 2019-03-20T18:41:32-04:00 Try again - - - - - 3394a7cd by Ben Gamari at 2019-03-20T18:41:32-04:00 testsuite: Display observed exit code on failure due to bad exit code - - - - - 36818759 by Artem Pyanykh at 2019-03-20T19:52:39-04:00 Adjust section placement and relocation logic for Mach-O 1. Place each section on a separate page to ensure required alignment (wastes lots ot space, needs to be improved). 2. Unwire relocation logic from macho sections (the most fiddly part is adjusting internal relocations). Other todos: 0. Add a test for section alignment. 1. Investigate 32bit relocations! 2. Fix memory leak in ZEROPAGE section allocation. 3. Fix creating redundant jump islands for GOT. 4. Investigate more compact section placement. - - - - - 78c61acf by Artem Pyanykh at 2019-03-20T19:52:39-04:00 Use segments for section layout - - - - - 7bbfb789 by Artem Pyanykh at 2019-03-20T19:52:39-04:00 Address some todos and fixmes - - - - - 3cdcc0b5 by Artem Pyanykh at 2019-03-20T19:52:39-04:00 Add a linker test re: section alignment - - - - - cb745c84 by Artem Pyanykh at 2019-03-20T19:52:39-04:00 Add missing levels to SegmentProt enum - - - - - d950f11e by Artem Pyanykh at 2019-03-20T19:52:39-04:00 Directly test section alignment, fix internal reloc probing length - - - - - 3fb10fcf by Artem Pyanykh at 2019-03-20T19:52:39-04:00 Gracefully handle error condition in Mach-O relocateSection - - - - - dc713c71 by Ben Gamari at 2019-03-20T19:58:49-04:00 ci: Move validate-x86_64-linux-deb9 to full-build stage The `build` stage is meant to be a minimal smoke test to weed out broken commits. The `validate-x86_64-linux-deb9` build will generally catch a subset of issues caught by `validate-x86_64-linux-deb9-debug` so only the latter should be in `build`. - - - - - 505c5ab2 by Ben Gamari at 2019-03-20T19:58:49-04:00 ci: Add some descriptions of the stages - - - - - 646e3dc2 by Sebastian Graf at 2019-03-20T20:04:49-04:00 Add a bench flavour to Hadrian - - - - - 8d18a873 by Ryan Scott at 2019-03-20T20:10:57-04:00 Reject nested predicates in impredicativity checking When GHC attempts to unify a metavariable with a type containing foralls, it will be rejected as an occurrence of impredicativity. GHC was /not/ extending the same treatment to predicate types, such as in the following (erroneous) example from #11514: ```haskell foo :: forall a. (Show a => a -> a) -> () foo = undefined ``` This will attempt to instantiate `undefined` at `(Show a => a -> a) -> ()`, which is impredicative. This patch catches impredicativity arising from predicates in this fashion. Since GHC is pickier about impredicative instantiations, some test cases needed to be updated to be updated so as not to fall afoul of the new validity check. (There were a surprising number of impredicative uses of `undefined`!) Moreover, the `T14828` test case now has slightly less informative types shown with `:print`. This is due to a a much deeper issue with the GHCi debugger (see #14828). Fixes #11514. - - - - - 7b213b8d by Ömer Sinan Ağacan at 2019-03-20T20:17:05-04:00 Print test suite results ("unexpected failures" etc.) in sorted order Fixes #16425 - - - - - f199a843 by Simon Jakobi at 2019-03-20T20:23:15-04:00 Check.hs: Fix a few typos - - - - - 07d44ed1 by Ben Gamari at 2019-03-20T20:29:20-04:00 base: Depend upon shlwapi on Windows As noted in #16466, `System.Environment.getExecutablePath` depends upon `PathFileExistsW` which is defined by `shlwapi`. Fixes #16466. - - - - - 1382d09e by Ryan Scott at 2019-03-20T20:35:28-04:00 Remove unused XArrApp and XArrForm extension points !301 removed the `HsArrApp` and `HsArrForm` constructors, which renders the corresponding extension points `XArrApp` and `XArrForm` useless. This patch finally rips them out. - - - - - 3423664b by Peter Trommler at 2019-03-20T20:41:35-04:00 Fix specification of load_load_barrier [skip-ci] - - - - - 84c77a67 by Alexandre Esteves at 2019-03-21T17:43:03-04:00 Fix typo [skip ci] - - - - - 7092b2de by Matthew Pickering at 2019-03-21T23:38:58-04:00 Only run check-makefiles.py linter in testsuite dir - - - - - 322239de by Matthew Pickering at 2019-03-21T23:38:58-04:00 Run linters on merge requests It seems that it has failed to execute at all since it was implemented. We now run the linters on merge requests. - - - - - 8f8d532c by Ben Gamari at 2019-03-21T23:45:03-04:00 gitlab-ci: Do full `perf` build when building Windows releases - - - - - 2ef72d3f by Ben Gamari at 2019-03-21T23:45:03-04:00 gitlab-ci: Pass --target explicitly to configure on Windows Otherwise configure fails in the 32-bit case with ``` This GHC (c:/GitLabRunner/builds/8fc0e283/0/ghc/ghc/toolchain/bin/ghc) does not generate code for the build platform GHC target platform : x86_64-unknown-mingw32 Desired build platform : i386-unknown-mingw32 ``` - - - - - 8b14f536 by Ben Gamari at 2019-03-21T23:51:08-04:00 Bump cabal submodule Due to https://github.com/haskell/cabal/issues/5953. - - - - - dbe4557f by Matthew Pickering at 2019-03-22T10:02:32-04:00 CI: Allow failure in packaging step This depends on the windows build which is still allowed to fail. If that job fails then the packaging job will also fail. - - - - - 366f1c68 by Ben Gamari at 2019-03-22T10:08:38-04:00 gitlab: Deploy documentation snapshot via GitLab Pages - - - - - d608d543 by Tamar Christina at 2019-03-22T10:14:45-04:00 Force LF line ending for md5sum [skip-ci] - - - - - cd07086a by Ben Gamari at 2019-03-22T10:34:51-04:00 gitlab-ci: Fix linters - - - - - ab51bee4 by Herbert Valerio Riedel at 2019-03-22T10:34:51-04:00 base: Remove `Monad(fail)` method and reexport `MonadFail(fail)` instead As per https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail Coauthored-by: Ben Gamari <ben at well-typed.com> - - - - - 266b49ca by Ben Gamari at 2019-03-22T18:33:20-04:00 gitlab-ci: Clean up linter I'm not sure why these steps were done but they seem counterproductive and unnecessary. - - - - - 44b08ede by Ben Gamari at 2019-03-22T18:38:11-04:00 gitlab-ci: Fix YAML syntax - - - - - 971f4530 by Ben Gamari at 2019-03-22T18:49:34-04:00 gitlab-ci: Compute merge base against remote tracking branch Previously we would use the local branch with the name `$CI_MERGE_REQUEST_TARGET_BRANCH_NAME` to compute the merge base when linting. However, this branch isn't necessarily up-to-date. We should rather use `origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME`. - - - - - 8d01b572 by Ben Gamari at 2019-03-23T12:37:56-04:00 gitlab-ci: Explicitly fetch target branch `git fetch`, which we used previously, doesn't update the remote tracking branches. - - - - - cd85f8a7 by Ben Gamari at 2019-03-24T08:46:13-04:00 gitlab-ci: Allow linters to fail for now They are broken and I don't have time to fix them at the moment. - - - - - d763b2e7 by Haskell-mouse at 2019-03-25T14:02:22-04:00 User's Guide: extensions compatibility Adds the mention that extensions "AllowAmbiguousTypes" and "RankNTypes" are not always compatible with each other. Specifies the conditions and causes of failing in resolving of ambiguity. - - - - - 200d65ef by Matthew Pickering at 2019-03-25T14:02:25-04:00 Check hadrian/ghci.sh script output to determine pass/fail ghci always exits with exit code 0 so you have to check the output to see if the modules loaded succesfully. - - - - - 8e07368f by Matthew Pickering at 2019-03-25T14:02:27-04:00 Refactor ./hadrian/ghci.sh for better error messages By separating these two lines, if the first command fails then `ghci` is not loaded. Before it would still load ghci but display lots of errors about not being able to find modules. - - - - - 3769e3a8 by Takenobu Tani at 2019-03-25T14:02:29-04:00 Update Wiki URLs to point to GitLab This moves all URL references to Trac Wiki to their corresponding GitLab counterparts. This substitution is classified as follows: 1. Automated substitution using sed with Ben's mapping rule [1] Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy... New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy... 2. Manual substitution for URLs containing `#` index Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy...#Zzz New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy...#zzz 3. Manual substitution for strings starting with `Commentary` Old: Commentary/XxxYyy... New: commentary/xxx-yyy... See also !539 [1]: https://gitlab.haskell.org/bgamari/gitlab-migration/blob/master/wiki-mapping.json - - - - - b9da2868 by Ryan Scott at 2019-03-25T14:02:33-04:00 Correct duplicate 4.12.0.0 entry in base's changelog See #16490. [ci skip] - - - - - ab41c1b4 by Andrey Mokhov at 2019-03-27T07:20:03-04:00 Hadrian: Bump Shake to 0.17.6 The new release of Shake comes with these relevant features: * use symlinks for --shared * add --compact for a Bazel/Buck style output - - - - - 646f2e79 by Andrey Mokhov at 2019-03-27T07:20:03-04:00 Hadrian: trace the execution of expensive Cabal calls We use Cabal to parse, configure, register and copy packages, which are expensive operations that are currently not visible to Shake's profiling infrastructure. By using `traced` we tell Shake to add these IO actions to the profiling report, helping us to identify performance bottlenecks. We use short tracing keys, as recommended in Shake docs: the name of the current target is already available in the rest of the profiling information. - - - - - fb12f53c by Alp Mestanogullari at 2019-03-27T07:20:05-04:00 Hadrian: introduce an easy way for users to build with -split-sections Any user can now trivially build any number of Haskell packages with `-split-sections` by using `splitSections`/`splitSectionsIf` on any existing or new flavour: -- build all packages but the ghc library with -split-sections splitSections :: Flavour -> Flavour -- build all packages that satisfy the given predicate -- with --split-sections splitSectionsIf :: (Package -> Bool) -> Flavour -> Flavour See the new section in `doc/user-settings.md`. - - - - - 3dec527a by David Eichmann at 2019-03-27T07:20:09-04:00 Hadrian: don't use -zorigin on darwin. - - - - - 5730f863 by Ömer Sinan Ağacan at 2019-03-27T07:20:10-04:00 Minor refactoring in copy array primops: - `emitCopySmallArray` now checks size before generating code and doesn't generate any code when size is 0. `emitCopyArray` already does this so this makes small/large array cases the same in argument checking. - In both `emitCopySmallArray` and `emitCopyArray` read the `dflags` after checking the argument. - - - - - 4acdb769 by Chaitanya Koparkar at 2019-03-27T07:20:11-04:00 Fix a few broken Trac links [skip ci] This patch only attempts to fix links that don't automatically re-direct to the correct URL. - - - - - 97ad5cfb by Artem Pelenitsyn at 2019-03-29T14:18:12-04:00 Add some tips to the Troubleshooting section of README - - - - - 8a20bfc2 by Michael Peyton Jones at 2019-03-29T14:18:14-04:00 Visibility: handle multiple units with the same name Fixes #16228. The included test case is adapted from the reproduction in the issue, and fails without this patch. ------ We compute an initial visilibity mapping for units based on what is present in the package databases. To seed this, we compute a set of all the package configs to add visibilities for. However, this set was keyed off the unit's *package name*. This is correct, since we compare packages across databases by version. However, we would only ever consider a single, most-preferable unit from the database in which it was found. The effect of this was that only one of the libraries in a Cabal package would be added to this initial set. This would cause attempts to use modules from the omitted libraries to fail, claiming that the package was hidden (even though `ghc-pkg` would correctly show it as visible). A solution is to do the selection of the most preferable packages separately, and then be sure to consider exposing all units in the same package in the same package db. We can do this by picking a most-preferable unit for each package name, and then considering exposing all units that are equi-preferable with that unit. ------ Why wasn't this bug apparent to all people trying to use sub-libraries in Cabal? The answer is that Cabal explicitly passes `-package` and `-package-id` flags for all the packages it wants to use, rather than relying on the state of the package database. So this bug only really affects people who are trying to use package databases produced by Cabal outside of Cabal itself. One particular example of this is the way that the Nixpkgs Haskell infrastructure provides wrapped GHCs: typically these are equipped with a package database containing all the needed package dependencies, and the user is not expected to pass `-package` flags explicitly. - - - - - 754b5455 by Artem Pelenitsyn at 2019-03-29T14:18:20-04:00 docs: make nfib compute the Fibonacci sequence [skipci] - - - - - 1a567133 by Ben Gamari at 2019-03-29T14:18:20-04:00 ci: Check that changelogs don't contain "TBA" This ensures that the release dates in the library changelogs are properly set. - - - - - 6e15ca54 by Ben Gamari at 2019-03-29T14:18:22-04:00 Bump transformers to 0.5.6.2 See #16199. - - - - - 6f7115df by Ben Gamari at 2019-03-30T07:42:38-04:00 ci: Ensure index.html is preserved in documentation tarball - - - - - 33173a51 by Alexandre at 2019-04-01T03:32:28-04:00 Add support for bitreverse primop This commit includes the necessary changes in code and documentation to support a primop that reverses a word's bits. It also includes a test. - - - - - a3971b4e by Alexandre at 2019-04-01T03:32:28-04:00 Bump ghc-prim's version where needed - - - - - 061276ea by Michael Sloan at 2019-04-01T03:32:30-04:00 Remove unnecessary uses of UnboxedTuples pragma (see #13101 / #15454) Also removes a couple unnecessary MagicHash pragmas - - - - - e468c613 by David Eichmann at 2019-04-01T03:32:34-04:00 Support Shake's --lint-fsatrace feature. Using this feature requires fsatrace (e.g. https://github.com/jacereda/fsatrace). Simply use the `--lint-fsatrace` option when running hadrian. Shake version >= 0.17.7 is required to support linting out of tree build dirs. - - - - - 1e9e4197 by Ben Gamari at 2019-04-01T03:32:34-04:00 gitlab: Add merge request template for backports for 8.8 - - - - - 55650d14 by Ben Gamari at 2019-04-01T03:32:34-04:00 gitlab: Add some simply issue templates - - - - - 27b99ed8 by Takenobu Tani at 2019-04-01T03:32:36-04:00 Clean up URLs to point to GitLab This moves URL references to old Trac to their corresponding GitLab counterparts. This patch does not update the submodule library, such as libraries/Cabal. See also !539, !606, !618 [ci skip] - - - - - 18d1555d by Adam Sandberg Eriksson at 2019-04-01T03:32:38-04:00 configure: document the use of the LD variable - - - - - 10352efa by Ben Gamari at 2019-04-01T18:22:34-04:00 gitlab: Add feature request MR template - - - - - 1e52054b by Ben Gamari at 2019-04-01T19:16:21-04:00 gitlab: Move feature request template to issue_templates Whoops. - - - - - e5c21ca9 by Ben Gamari at 2019-04-01T19:16:25-04:00 gitlab: Mention ~"user facing" label - - - - - 39282422 by Ryan Scott at 2019-04-01T20:01:38-04:00 Bump array submodule This bumps `array` to version 0.5.4.0 so that we can distinguish it with `MIN_VERSION_array` (as it introduces some changes to the `Show` instance for `UArray`). - - - - - 7cf5ba3d by Michal Terepeta at 2019-04-01T20:07:49-04:00 Improve performance of newSmallArray# This: - Hoists part of the condition outside of the initialization loop in `stg_newSmallArrayzh`. - Annotates one of the unlikely branches as unlikely, also in `stg_newSmallArrayzh`. - Adds a couple of annotations to `allocateMightFail` indicating which branches are likely to be taken. Together this gives about 5% improvement. Signed-off-by: Michal Terepeta <michal.terepeta at gmail.com> - - - - - dd9c82ef by David Eichmann at 2019-04-01T20:13:55-04:00 Hadrian: correct deps for ghc builder. Previously, when needing ghc as a builder, the ghcDeps (Files the GHC binary depends on) for the current stage were needed. This is incorrect as the previous stage's ghc is used for building. This commit fixes the issue, needing the previous stage's ghcDeps. - - - - - 345306d3 by Alexandre Baldé at 2019-04-02T12:34:30-04:00 Fix formatting issue in ghc-prim's changelog [skip ci] - - - - - f54b5124 by David Eichmann at 2019-04-02T12:40:39-04:00 Hadrian: traceAllow deep dependencies when compilling haskell object files. - - - - - d132b30a by David Eichmann at 2019-04-02T12:40:39-04:00 Hadrian: lint ignore autom4te and ghc-pkg cache files. - - - - - bf734195 by Simon Marlow at 2019-04-02T12:46:46-04:00 Add myself to libraries/ghci - - - - - 5a75ccd0 by klebinger.andreas at gmx.at at 2019-04-03T00:34:57-04:00 Fix faulty substitutions in StgCse (#11532). `substBndr` should rename bindings which shadow existing ids. However while it was renaming the bindings it was not adding proper substitutions for renamed bindings. Instead of adding a substitution of the form `old -> new` for renamed bindings it mistakenly added `old -> old` if no replacement had taken place while adding none if `old` had been renamed. As a byproduct this should improve performance, as we no longer add useless substitutions for unshadowed bindings. - - - - - 2ec749b5 by Nathan Collins at 2019-04-03T00:41:05-04:00 users-guide: Fix typo - - - - - ea192a09 by Andrew Martin at 2019-04-03T00:41:05-04:00 base: Add documentation that liftA2 used to not be a typeclass method - - - - - 733f1b52 by Frank Steffahn at 2019-04-03T00:41:05-04:00 users-guide: Typo in Users Guide, Glasgow Exts - - - - - 3364def0 by Ben Gamari at 2019-04-03T00:41:05-04:00 integer-gmp: Write friendlier documentation for Integer - - - - - dd3a3d08 by Ben Gamari at 2019-04-03T00:41:05-04:00 integer-simple: Add documentation for Integer type - - - - - 722fdddf by Chris Martin at 2019-04-03T00:41:05-04:00 Correct two misspellings of "separately" - - - - - bf6dbe3d by Chris Martin at 2019-04-03T00:41:05-04:00 Inline the definition of 'ap' in the Monad laws The law as it is currently written is meaningless, because nowhere have we defined the implementation of 'ap'. The reader of the Control.Monad documentation is provided with only a type signature, > ap :: Monad m => m (a -> b) -> m a -> m b an informal description, > In many situations, the liftM operations can be replaced by uses of > ap, which promotes function application. and a relationship between 'ap' and the 'liftM' functions > return f `ap` x1 `ap` ... `ap` xn > is equivalent to > liftMn f x1 x2 ... xn Without knowing how 'ap' is defined, a law involving 'ap' cannot provide any guidance for how to write a lawful Monad instance, nor can we conclude anything from the law. I suspect that a reader equipped with the understanding that 'ap' was defined prior to the invention of the Applicative class could deduce that 'ap' must be defined in terms of (>>=), but nowhere as far as I can tell have we written this down explicitly for readers without the benefit of historical context. If the law is meant to express a relationship among (<*>), (>>=), and 'return', it seems that it is better off making this statement directly, sidestepping 'ap' altogether. - - - - - 7b090b53 by Ben Gamari at 2019-04-03T03:57:40-04:00 configure: Always use AC_LINK_ELSEIF when testing against assembler This fixes #16440, where the build system incorrectly concluded that the `.subsections_via_symbols` assembler directive was supported on a Linux system. This was caused by the fact that gcc was invoked with `-flto`; when so-configured gcc does not call the assembler but rather simply serialises its AST for compilation during the final link. This is described in Note [autoconf assembler checks and -flto]. - - - - - 4626cf21 by Sebastian Graf at 2019-04-03T04:03:47-04:00 Fix Uncovered set of literal patterns Issues #16289 and #15713 are proof that the pattern match checker did an unsound job of estimating the value set abstraction corresponding to the uncovered set. The reason is that the fix from #11303 introducing `NLit` was incomplete: The `LitCon` case desugared to `Var` rather than `LitVar`, which would have done the necessary case splitting analogous to the `ConVar` case. This patch rectifies that by introducing the fresh unification variable in `LitCon` in value abstraction position rather than pattern postition, recording a constraint equating it to the constructor expression rather than the literal. Fixes #16289 and #15713. - - - - - 6f13e7b1 by Ben Gamari at 2019-04-03T08:12:26-04:00 gitlab-ci: Build hyperlinked sources for releases Fixes #16445. - - - - - 895394c2 by Ben Gamari at 2019-04-03T08:15:06-04:00 gitlab: Fix label names in issue templates - - - - - 75abaaea by Yuriy Syrovetskiy at 2019-04-04T04:23:19-04:00 Replace git.haskell.org with gitlab.haskell.org (#16196) - - - - - 25c02ea1 by Ryan Scott at 2019-04-04T04:29:29-04:00 Fix #16518 with some more kind-splitting smarts This patch corrects two simple oversights that led to #16518: 1. `HsUtils.typeToLHsType` was taking visibility into account in the `TyConApp` case, but not the `AppTy` case. I've factored out the visibility-related logic into its own `go_app` function and now invoke `go_app` from both the `TyConApp` and `AppTy` cases. 2. `Type.fun_kind_arg_flags` did not properly split kinds with nested `forall`s, such as `(forall k. k -> Type) -> (forall k. k -> Type)`. This was simply because `fun_kind_arg_flags`'s `FunTy` case always bailed out and assumed all subsequent arguments were `Required`, which clearly isn't the case for nested `forall`s. I tweaked the `FunTy` case to recur on the result kind. - - - - - 51fd3571 by Ryan Scott at 2019-04-04T04:35:39-04:00 Use funPrec, not topPrec, to parenthesize GADT argument types A simple oversight. Fixes #16527. - - - - - 6c0dd085 by Ben Gamari at 2019-04-04T08:12:24-04:00 testsuite: Add testcase for #16111 - - - - - cbb88865 by klebinger.andreas at gmx.at at 2019-04-04T08:12:25-04:00 Restore Xmm registers properly in StgCRun.c This fixes #16514: Xmm6-15 was restored based off rax instead of rsp. The code was introduced in the fix for #14619. - - - - - 33b0a291 by Ryan Scott at 2019-04-04T08:12:28-04:00 Tweak error messages for narrowly-kinded assoc default decls This program, from #13971, currently has a rather confusing error message: ```hs class C a where type T a :: k type T a = Int ``` ``` • Kind mis-match on LHS of default declaration for ‘T’ • In the default type instance declaration for ‘T’ In the class declaration for ‘C’ ``` It's not at all obvious why GHC is complaining about the LHS until you realize that the default, when printed with `-fprint-explicit-kinds`, is actually `type T @{k} @* a = Int`. That is to say, the kind of `a` is being instantiated to `Type`, whereas it ought to be a kind variable. The primary thrust of this patch is to weak the error message to make this connection more obvious: ``` • Illegal argument ‘*’ in: ‘type T @{k} @* a = Int’ The arguments to ‘T’ must all be type variables • In the default type instance declaration for ‘T’ In the class declaration for ‘C’ ``` Along the way, I performed some code cleanup suggested by @rae in https://gitlab.haskell.org/ghc/ghc/issues/13971#note_191287. Before, we were creating a substitution from the default declaration's type variables to the type family tycon's type variables by way of `tcMatchTys`. But this is overkill, since we already know (from the aforementioned validity checking) that all the arguments in a default declaration must be type variables anyway. Therefore, creating the substitution is as simple as using `zipTvSubst`. I took the opportunity to perform this refactoring while I was in town. Fixes #13971. - - - - - 3a38ea44 by Eric Crockett at 2019-04-07T15:21:59-04:00 Fix #16282. Previously, -W(all-)missed-specs was created with 'NoReason', so no information about the flag was printed along with the warning. Now, -Wall-missed-specs is listed as the Reason if it was set, otherwise -Wmissed-specs is listed as the reason. - - - - - 63b7d5fb by Michal Terepeta at 2019-04-08T14:29:34-04:00 Generate straightline code for inline array allocation GHC has an optimization for allocating arrays when the size is statically known -- it'll generate the code allocating and initializing the array inline (instead of a call to a procedure from `rts/PrimOps.cmm`). However, the generated code uses a loop to do the initialization. Since we already check that the requested size is small (we check against `maxInlineAllocSize`), we can generate faster straightline code instead. This brings about 15% improvement for `newSmallArray#` in my testing and slightly simplifies the code in GHC. Signed-off-by: Michal Terepeta <michal.terepeta at gmail.com> - - - - - 2b3f4718 by Phuong Trinh at 2019-04-08T14:35:43-04:00 Fix #16500: look for interface files in -hidir flag in OneShot mode We are currently ignoring options set in the hiDir field of hsc_dflags when looking for interface files while compiling in OneShot mode. This is inconsistent with the behaviour of other directory redirecting fields (such as objectDir or hieDir). It is also inconsistent with the behaviour of compilation in CompManager mode (a.k.a `ghc --make`) which looks for interface files in the directory set in hidir flag. This changes Finder.hs so that we use the value of hiDir while looking for interface in OneShot mode. - - - - - 97502be8 by Yuriy Syrovetskiy at 2019-04-08T14:41:51-04:00 Add `-optcxx` option (#16477) - - - - - 97d3d546 by Ben Gamari at 2019-04-08T14:47:54-04:00 testsuite: Unmark T16190 as broken Was broken via #16389 yet strangely it has started passing despite the fact that the suggested root cause has not changed. - - - - - a42d206a by Yuriy Syrovetskiy at 2019-04-08T14:54:02-04:00 Fix whitespace style - - - - - 4dda2270 by Matthew Pickering at 2019-04-08T15:00:08-04:00 Use ./hadrian/ghci.sh in .ghcid - - - - - d236d9d0 by Sebastian Graf at 2019-04-08T15:06:15-04:00 Make `singleConstructor` cope with pattern synonyms Previously, `singleConstructor` didn't handle singleton `COMPLETE` sets of a single pattern synonym, resulting in incomplete pattern warnings in #15753. This is fixed by making `singleConstructor` (now named `singleMatchConstructor`) query `allCompleteMatches`, necessarily making it effectful. As a result, most of this patch is concerned with threading the side-effect through to `singleMatchConstructor`. Unfortunately, this is not enough to completely fix the original reproduction from #15753 and #15884, which are related to function applications in pattern guards being translated too conservatively. - - - - - 1085090e by Ömer Sinan Ağacan at 2019-04-08T15:12:22-04:00 Skip test ArithInt16 and ArithWord16 in GHCi way These tests use unboxed tuples, which GHCi doesn't support - - - - - 7287bb9e by Ömer Sinan Ağacan at 2019-04-08T15:18:33-04:00 testsuite: Show exit code of GHCi tests on failure - - - - - f5604d37 by John Ericson at 2019-04-08T15:24:43-04:00 settings.in: Reformat We're might be about to switch to generating it in Hadrian/Make. This reformat makes it easier to programmingmatically generate and end up with the exact same thing, which is good for diffing to ensure no regressions. I had this as part of !712, but given the difficulty of satisfying CI, I figured I should break things up even further. - - - - - cf9e1837 by Ryan Scott at 2019-04-08T15:30:51-04:00 Bump hpc submodule Currently, the `hpc` submodule is pinned against the `wip/final-mfp` branch, not against `master`. This pins it back against `master`. - - - - - 36d38047 by Ben Gamari at 2019-04-09T10:23:47-04:00 users-guide: Document how to disable package environments As noted in #16309 this somehow went undocumented. - - - - - af4cea7f by Artem Pyanykh at 2019-04-09T10:30:13-04:00 codegen: fix memset unroll for small bytearrays, add 64-bit sets Fixes #16052 When the offset in `setByteArray#` is statically known, we can provide better alignment guarantees then just 1 byte. Also, memset can now do 64-bit wide sets. The current memset intrinsic is not optimal however and can be improved for the case when we know that we deal with (baseAddress at known alignment) + offset For instance, on 64-bit `setByteArray# s 1# 23# 0#` given that bytearray is 8 bytes aligned could be unrolled into `movb, movw, movl, movq, movq`; but currently it is `movb x23` since alignment of 1 is all we can embed into MO_Memset op. - - - - - bd2de4f0 by Artem Pyanykh at 2019-04-09T10:30:13-04:00 codegen: use newtype for Alignment in BasicTypes - - - - - 14a78707 by Artem Pyanykh at 2019-04-09T10:30:13-04:00 docs: add a note about changes in memset unrolling to 8.10.1-notes - - - - - fe40ddd9 by Sylvain Henry at 2019-04-09T12:50:15-04:00 Hadrian: fix library install paths in bindist Makefile (#16498) GHC now works out-of-the-box (i.e. without any wrapper script) by assuming that @bin@ and @lib@ directories sit next to each other. In particular, its RUNPATH uses $ORIGIN-based relative path to find the libraries. However, to be good citizens we want to support the case where @bin@ and @lib@ directories (respectively BINDIR and LIBDIR) don't sit next to each other or are renamed. To do that the install script simply creates GHC specific @bin@ and @lib@ siblings directories into: LIBDIR/ghc-VERSION/{bin,lib} Then it installs wrapper scripts into BINDIR that call the appropriate programs into LIBDIR/ghc-VERSION/bin/. The issue fixed by this patch is that libraries were not installed into LIBDIR/ghc-VERSION/lib but directly into LIBDIR. - - - - - 9acdc4c0 by Ben Gamari at 2019-04-09T12:56:38-04:00 gitlab: Bump cabal-install version used by Windows builds to 2.4 Hopefully fixes Windows Hadrian build. - - - - - fc3f421b by Joachim Breitner at 2019-04-09T23:17:37-04:00 GHC no longer ever defines TABLES_NEXT_TO_CODE on its own It should be entirely the responsibility of make/Hadrian to ensure that everything that needs this flag gets it. GHC shouldn't be hardcoded to assist with bootstrapping since it builds other things besides itself. Reviewers: Subscribers: TerrorJack, rwbarton, carter GHC Trac Issues: #15548 -- progress towards but not fix Differential Revision: https://phabricator.haskell.org/D5082 -- extract from that - - - - - be0dde8e by Ryan Scott at 2019-04-09T23:23:50-04:00 Use ghc-prim < 0.7, not <= 0.6.1, as upper version bounds Using `ghc-prim <= 0.6.1` is somewhat dodgy from a PVP point of view, as it makes it awkward to support new minor releases of `ghc-prim`. Let's instead use `< 0.7`, which is the idiomatic way of expressing PVP-compliant upper version bounds. - - - - - 42504f4a by Carter Schonwald at 2019-04-10T20:28:41-04:00 removing x87 register support from native code gen * simplifies registers to have GPR, Float and Double, by removing the SSE2 and X87 Constructors * makes -msse2 assumed/default for x86 platforms, fixing a long standing nondeterminism in rounding behavior in 32bit haskell code * removes the 80bit floating point representation from the supported float sizes * theres still 1 tiny bit of x87 support needed, for handling float and double return values in FFI calls wrt the C ABI on x86_32, but this one piece does not leak into the rest of NCG. * Lots of code thats not been touched in a long time got deleted as a consequence of all of this all in all, this change paves the way towards a lot of future further improvements in how GHC handles floating point computations, along with making the native code gen more accessible to a larger pool of contributors. - - - - - c401f8a4 by Sylvain Henry at 2019-04-11T19:51:24-04:00 Hadrian: fix binary-dir with --docs=none Hadrian's "binary-dist" target must check that the "docs" directory exists (it may not since we can disable docs generation). - - - - - 091195a4 by Ömer Sinan Ağacan at 2019-04-11T19:57:38-04:00 Remove unused remilestoning script - - - - - fa0ccbb8 by Ömer Sinan Ağacan at 2019-04-11T19:57:38-04:00 Update a panic message Point users to the right URL - - - - - beaa07d2 by Sylvain Henry at 2019-04-12T13:17:21-04:00 Hadrian: fix ghci wrapper script generation (#16508) - - - - - e05df3e1 by Ben Gamari at 2019-04-12T13:23:30-04:00 gitlab-ci: Ensure that version number has three components - - - - - 885d2e04 by klebinger.andreas at gmx.at at 2019-04-12T14:40:04-04:00 Add -ddump-stg-final to dump stg as it is used for codegen. Intermediate STG does not contain free variables which can be useful sometimes. So adding a flag to dump that info. - - - - - 3c759ced by Alp Mestanogullari at 2019-04-12T14:46:54-04:00 Hadrian: add a --test-accept/-a flag, to mimic 'make accept' When -a or --test-accept is passed, and if one runs the 'test' target, then any test failing because of mismatching output and which is not expected to fail will have its expected output adjusted by the test driver, effectively considering the new output correct from now on. When this flag is passed, hadrian's 'test' target becomes sensitive to the PLATFORM and OS environment variable, just like the Make build system: - when the PLATFORM env var is set to "YES", when accepting a result, accept it for the current platform; - when the OS env var is set to "YES", when accepting a result, accept it for all wordsizes of the current operating system. This can all be combined with `--only="..."` and `TEST="..." to only accept the new output of a subset of tests. - - - - - f4b5a6c0 by Alp Mestanogullari at 2019-04-12T14:46:54-04:00 Hadrian: document -a/--test-accept - - - - - 30a0988d by Ben Gamari at 2019-04-12T15:41:07-04:00 gitlab: Disable windows-hadrian job Not only is it reliably failing due to #16574 but all of the quickly failing builds also causes the Windows runners to run out of disk space. - - - - - 8870a51b by Ben Gamari at 2019-04-12T15:41:07-04:00 gitlab: Don't run lint-submods job on Marge branches This broke Marge by creating a second pipeline (consisting of only the `lint-submods` job). Marge then looked at this pipeline and concluded that CI for her merge branch passed. However, this is ignores the fact that the majority of the CI jobs are triggered on `merge_request` and are therefore in another pipeline. - - - - - 7876d088 by Ben Gamari at 2019-04-13T09:51:59-04:00 linters: Fix check-version-number This should have used `grep -E`, not `grep -e` - - - - - 2e7b2e55 by Ara Adkins at 2019-04-13T10:00:02-04:00 [skip ci] Update CI badge in readme This trivial MR updates the CI badge in the readme to point to the new CI on gitlab, rather than the very out-of-date badge from Travis. - - - - - 40848a43 by Ben Gamari at 2019-04-13T10:02:36-04:00 base: Better document implementation implications of Data.Timeout As noted in #16546 timeout uses asynchronous exceptions internally, an implementation detail which can leak out in surprising ways. Note this fact. Also expose the `Timeout` tycon. [skip ci] - - - - - 5f183081 by David Eichmann at 2019-04-14T01:08:15-04:00 Hadrian: add rts shared library symlinks for backwards compatability Fixes test T3807 when building with Hadrian. Trac #16370 - - - - - 9b142c53 by Sylvain Henry at 2019-04-14T01:14:23-04:00 Hadrian: add binary-dist-dir target This patch adds an Hadrian target "binary-dist-dir". Compared to "binary-dist", it only builds a binary distribution directory without creating the Tar archive. It makes the use/test of the bindist installation script easier. - - - - - 6febc444 by Krzysztof Gogolewski at 2019-04-14T01:20:29-04:00 Fix assertion failures reported in #16533 - - - - - edcef7b3 by Artem Pyanykh at 2019-04-14T01:26:35-04:00 codegen: unroll memcpy calls for small bytearrays - - - - - 6094d43f by Artem Pyanykh at 2019-04-14T01:26:35-04:00 docs: mention memcpy optimization for ByteArrays in 8.10.1-notes - - - - - d2271fe4 by Simon Jakobi at 2019-04-14T08:43:17-04:00 Ord docs: Add explanation on 'min' and 'max' operator interactions [ci skip] - - - - - e7cad16c by Krzysztof Gogolewski at 2019-04-14T08:49:23-04:00 Add a safeguard to Core Lint Lint returns a pair (Maybe a, WarnsAndErrs). The Maybe monad allows to handle an unrecoverable failure. In case of such a failure, the error should be added to the second component of the pair. If this is not done, Lint will silently accept bad programs. This situation actually happened during development of linear types. This adds a safeguard. - - - - - c54a093f by Ben Gamari at 2019-04-14T08:55:29-04:00 CODEOWNERS: Add simonmar as owner of rts/linker I suspect this is why @simonmar wasn't notified of !706. [skip ci] - - - - - 1825f50d by Alp Mestanogullari at 2019-04-14T09:01:38-04:00 Hadrian: don't accept p_dyn for executables, to fix --flavour=prof - - - - - b024e289 by Giles Anderson at 2019-04-15T06:20:29-04:00 Document how -O3 is handled by GHC -O2 is the highest value of optimization. -O3 will be reverted to -O2. - - - - - 4b1ef06d by Giles Anderson at 2019-04-15T06:20:29-04:00 Apply suggestion to docs/users_guide/using-optimisation.rst - - - - - 71cf94db by Fraser Tweedale at 2019-04-15T06:26:37-04:00 GHCi: fix load order of .ghci files Directives in .ghci files in the current directory ("local .ghci") can be overridden by global files. Change the order in which the configs are loaded: global and $HOME/.ghci first, then local. Also introduce a new field to GHCiState to control whether local .ghci gets sourced or ignored. This commit does not add a way to set this value (a subsequent commit will add this), but the .ghci sourcing routine respects its value. Fixes: https://gitlab.haskell.org/ghc/ghc/issues/14689 Related: https://gitlab.haskell.org/ghc/ghc/issues/6017 Related: https://gitlab.haskell.org/ghc/ghc/issues/14250 - - - - - 5c06b60d by Fraser Tweedale at 2019-04-15T06:26:38-04:00 users-guide: update startup script order Update users guide to match the new startup script order. Also clarify that -ignore-dot-ghci does not apply to scripts specified via the -ghci-script option. Part of: https://gitlab.haskell.org/ghc/ghc/issues/14689 - - - - - aa490b35 by Fraser Tweedale at 2019-04-15T06:26:38-04:00 GHCi: add 'local-config' setting Add the ':set local-config { source | ignore }' setting to control whether .ghci file in current directory will be sourced or not. The directive can be set in global config or $HOME/.ghci, which are processed before local .ghci files. The default is "source", preserving current behaviour. Related: https://gitlab.haskell.org/ghc/ghc/issues/6017 Related: https://gitlab.haskell.org/ghc/ghc/issues/14250 - - - - - ed94d345 by Fraser Tweedale at 2019-04-15T06:26:38-04:00 users-guide: document :set local-config Document the ':set local-config' command and add a warning about sourcing untrusted local .ghci scripts. Related: https://gitlab.haskell.org/ghc/ghc/issues/6017 Related: https://gitlab.haskell.org/ghc/ghc/issues/14250 - - - - - be05bd81 by Gabor Greif at 2019-04-15T17:19:03-04:00 asm-emit-time IND_STATIC elimination When a new closure identifier is being established to a local or exported closure already emitted into the same module, refrain from adding an IND_STATIC closure, and instead emit an assembly-language alias. Inter-module IND_STATIC objects still remain, and need to be addressed by other measures. Binary-size savings on nofib are around 0.1%. - - - - - 57eb5bc6 by erthalion at 2019-04-16T15:40:36-04:00 Show dynamic object files (#16062) Closes #16062. When -dynamic-too is specified, reflect that in the progress message, like: $ ghc Main.hs -dynamic-too [1 of 1] Compiling Lib ( Main.hs, Main.o, Main.dyn_o ) instead of: $ ghc Main.hs -dynamic-too [1 of 1] Compiling Lib ( Main.hs, Main.o ) - - - - - 894ec447 by Andrey Mokhov at 2019-04-16T15:46:44-04:00 Hadrian: Generate GHC wrapper scripts This is a temporary workaround for #16534. We generate wrapper scripts <build-root>/ghc-stage1 and <build-root>/ghc-stage2 that can be used to run Stage1 and Stage2 GHCs with the right arguments. See https://gitlab.haskell.org/ghc/ghc/issues/16534. - - - - - e142ec99 by Sven Tennie at 2019-04-17T23:19:00-04:00 Typeset Big-O complexities with Tex-style notation (#16090) E.g. use `\(\mathcal{O}(n^2)\)` instead of `/O(n^2)/`. - - - - - f0f495f0 by klebinger.andreas at gmx.at at 2019-04-17T23:25:10-04:00 Add an Outputable instance for SDoc with ppr = id. When printf debugging this can be helpful. - - - - - e28706ea by Sylvain Henry at 2019-04-18T08:12:07-04:00 Gitlab: allow execution of CI pipeline from the web interface [skip ci] - - - - - 4c8a67a4 by Alp Mestanogullari at 2019-04-18T08:18:18-04:00 Hadrian: fix ghcDebugged and document it - - - - - 5988f17a by Alp Mestanogullari at 2019-04-18T22:46:12-04:00 Hadrian: fix the value we pass to the test driver for config.compiler_debugged We used to pass YES/NO, while that particular field is set to True/False. This happens to fix an unexpected pass, T9208. - - - - - 57cf1133 by Alec Theriault at 2019-04-18T22:52:25-04:00 TH: make `Lift` and `TExp` levity-polymorphic Besides the obvious benefits of being able to manipulate `TExp`'s of unboxed types, this also simplified `-XDeriveLift` all while making it more capable. * `ghc-prim` is explicitly depended upon by `template-haskell` * The following TH things are parametrized over `RuntimeRep`: - `TExp(..)` - `unTypeQ` - `unsafeTExpCoerce` - `Lift(..)` * The following instances have been added to `Lift`: - `Int#`, `Word#`, `Float#`, `Double#`, `Char#`, `Addr#` - unboxed tuples of lifted types up to arity 7 - unboxed sums of lifted types up to arity 7 Ideally we would have levity-polymorphic _instances_ of unboxed tuples and sums. * The code generated by `-XDeriveLift` uses expression quotes instead of generating large amounts of TH code and having special hard-coded cases for some unboxed types. - - - - - fdfd9731 by Alec Theriault at 2019-04-18T22:52:25-04:00 Add test case for #16384 Now that `TExp` accepts unlifted types, #16384 is fixed. Since the real issue there was GHC letting through an ill-kinded type which `-dcore-lint` rightly rejected, a reasonable regression test is that the program from #16384 can now be accepted without `-dcore-lint` complaining. - - - - - eb2a4df8 by Michal Terepeta at 2019-04-19T23:32:08-04:00 StgCmmPrim: remove an unnecessary instruction in doNewArrayOp Previously we would generate a local variable pointing after the array header and use it to initialize the array elements. But we already use stores with offset, so it's easy to just add the header to those offsets during compilation and avoid generating the local variable (which would become a LEA instruction when using native codegen; LLVM already optimizes it away). Signed-off-by: Michal Terepeta <michal.terepeta at gmail.com> - - - - - fcef26b6 by klebinger.andreas at gmx.at at 2019-04-19T23:38:16-04:00 Don't indent single alternative case expressions for STG. Makes the width of STG dumps slightly saner. Especially for things like unboxing. Fixes #16580 - - - - - e7280c93 by Vladislav Zavialov at 2019-04-19T23:44:24-04:00 Tagless final encoding of ExpCmdI in the parser Before this change, we used a roundabout encoding: 1. a GADT (ExpCmdG) 2. a class to pass it around (ExpCmdI) 3. helpers to match on it (ecHsApp, ecHsIf, ecHsCase, ...) It is more straightforward to turn these helpers into class methods, removing the need for a GADT. - - - - - 99dd5d6b by Alec Theriault at 2019-04-19T23:50:29-04:00 Haddock: support strict GADT args with docs Rather than massaging the output of the parser to re-arrange docs and bangs, it is simpler to patch the two places in which the strictness info is needed (to accept that the `HsBangTy` may be inside an `HsDocTy`). Fixes #16585. - - - - - 10776562 by Andrey Mokhov at 2019-04-19T23:56:38-04:00 Hadrian: Drop old/unused CI scripts - - - - - 37b1a6da by Ben Gamari at 2019-04-20T11:55:20-04:00 gitlab-ci: Improve error message on failure of doc-tarball job Previously the failure was quite nondescript. - - - - - e3fe2601 by Ben Gamari at 2019-04-20T11:55:35-04:00 gitlab-ci: Allow doc-tarball job to fail Due to allowed failure of Windows job. - - - - - bd3872df by Ben Gamari at 2019-04-20T11:55:38-04:00 gitlab-ci: Only run release notes lint on release tags - - - - - 2145b738 by Ben Gamari at 2019-04-20T11:55:38-04:00 gitlab-ci: Add centos7 release job - - - - - 983c53c3 by Ben Gamari at 2019-04-20T11:55:38-04:00 gitlab-ci: Do not build profiled libraries on 32-bit Windows Due to #15934. - - - - - 5cf771f3 by Ben Gamari at 2019-04-21T09:07:13-04:00 users-guide: Add pretty to package list - - - - - 6ac5da78 by Ben Gamari at 2019-04-21T09:07:13-04:00 users-guide: Add libraries section to 8.10.1 release notes - - - - - 3e963de3 by Andrew Martin at 2019-04-21T09:13:20-04:00 improve docs for casArray and casSmallArray - - - - - 98bffb07 by Andrew Martin at 2019-04-21T09:13:20-04:00 [skip ci] say "machine words" instead of "Int units" in the primops docs - - - - - 3aefc14a by Andrew Martin at 2019-04-21T09:13:20-04:00 [skip ci] correct formatting of casArray# in docs for casSmallArray# - - - - - 0e96d120 by Andrew Martin at 2019-04-21T09:13:20-04:00 [skip ci] correct the docs for casArray a little more. clarify that the returned element may be two different things - - - - - 687152f2 by Artem Pyanykh at 2019-04-21T09:19:29-04:00 testsuite: move tests related to linker under tests/rts/linker - - - - - 36e51406 by Artem Pyanykh at 2019-04-21T09:19:29-04:00 testsuite: fix ifdef lint errors under tests/rts/linker - - - - - 1a7a329b by Matthew Pickering at 2019-04-22T14:37:30-04:00 Correct off by one error in ghci +c Fixes #16569 - - - - - 51655fd8 by Alp Mestanogullari at 2019-04-22T14:44:11-04:00 Hadrian: use the testsuite driver's config.haddock arg more correctly 4 haddock tests assume that .haddock files have been produced, by using the 'req_haddock' modifier. The testsuite driver assumes that this condition is satisfied if 'config.haddock' is non-empty, but before this patch Hadrian was always passing the path to where the haddock executable should be, regardless of whether it is actually there or not. Instead, we now pass an empty config.haddock when we can't find all of <build root>/docs/html/libraries/<pkg>/<pkg>.haddock>, where <pkg> ranges over array, base, ghc-prim, process and template-haskell, and pass the path to haddock when all those file exists. This has the (desired) effect of skipping the 4 tests (marked as 'missing library') when the docs haven't been built, and running the haddock tests when they have. - - - - - 1959bad3 by Vladislav Zavialov at 2019-04-22T14:50:18-04:00 Stop misusing EWildPat in pattern match coverage checking EWildPat is a constructor of HsExpr used in the parser to represent wildcards in ambiguous positions: * in expression context, EWildPat is turned into hsHoleExpr (see rnExpr) * in pattern context, EWildPat is turned into WildPat (see checkPattern) Since EWildPat exists solely for the needs of the parser, we could remove it by improving the parser. However, EWildPat has also been used for a different purpose since 8a50610: to represent patterns that the coverage checker cannot handle. Not only this is a misuse of EWildPat, it also stymies the removal of EWildPat. - - - - - 6a491726 by Fraser Tweedale at 2019-04-23T09:27:30-04:00 osReserveHeapMemory: handle signed rlim_t rlim_t is a signed type on FreeBSD, and the build fails with a sign-compare error. Add explicit (unsigned) cast to handle this case. - - - - - ab9b3ace by Alexandre Baldé at 2019-04-23T09:33:37-04:00 Fix error message for './configure' regarding '--with-ghc' [skip ci] - - - - - 465f8f48 by Ben Gamari at 2019-04-24T12:19:24-04:00 gitlab-ci: source-tarball job should have no dependencies - - - - - 0fc69416 by Vladislav Zavialov at 2019-04-25T14:28:56-04:00 Introduce MonadP, make PV a newtype Previously we defined type PV = P, this had the downside that if we wanted to change PV, we would have to modify P as well. Now PV is free to evolve independently from P. The common operations addError, addFatalError, getBit, addAnnsAt, were abstracted into a class called MonadP. - - - - - f85efdec by Vladislav Zavialov at 2019-04-25T14:28:56-04:00 checkPattern error hint is PV context There is a hint added to error messages reported in checkPattern. Instead of passing it manually, we put it in a ReaderT environment inside PV. - - - - - 4e228267 by Ömer Sinan Ağacan at 2019-04-25T14:35:09-04:00 Minor RTS refactoring: - Remove redundant casting in evacuate_static_object - Remove redundant parens in STATIC_LINK - Fix a typo in GC.c - - - - - faa94d47 by Ben Gamari at 2019-04-25T17:16:21-04:00 update-autoconf: Initial commit - - - - - 4811cd39 by Ben Gamari at 2019-04-25T17:16:21-04:00 Update autoconf scripts Scripts taken from autoconf a8d79c3130da83c7cacd6fee31b9acc53799c406 - - - - - 0040af59 by Ben Gamari at 2019-04-25T17:16:21-04:00 gitlab-ci: Reintroduce DWARF-enabled bindists It seems that this was inadvertently dropped in 1285d6b95fbae7858abbc4722bc2301d7fe40425. - - - - - 2c115085 by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 rename: hadle type signatures with typos When encountering type signatures for unknown names, suggest similar alternatives. This fixes issue #16504 - - - - - fb9408dd by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 Print suggestions in a single message - - - - - e8bf8834 by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 osa1's patch: consistent suggestion message - - - - - 1deb2bb0 by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 Comment on 'candidates' function - - - - - 8ee47432 by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 Suggest only local candidates from global env - - - - - e23f78ba by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 Use pp_item - - - - - 1abb76ab by Ben Gamari at 2019-04-29T21:08:45-04:00 ghci: Ensure that system libffi include path is searched Previously hsc2hs failed when building against a system FFI. - - - - - 014ed644 by Sebastian Graf at 2019-04-30T20:23:21-04:00 Compute demand signatures assuming idArity This does four things: 1. Look at `idArity` instead of manifest lambdas to decide whether to use LetUp 2. Compute the strictness signature in LetDown assuming at least `idArity` incoming arguments 3. Remove the special case for trivial RHSs, which is subsumed by 2 4. Don't perform the W/W split when doing so would eta expand a binding. Otherwise we would eta expand PAPs, causing unnecessary churn in the Simplifier. NoFib Results -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- fannkuch-redux +0.3% 0.0% gg -0.0% -0.1% maillist +0.2% +0.2% minimax 0.0% +0.8% pretty 0.0% -0.1% reptile -0.0% -1.2% -------------------------------------------------------------------------------- Min -0.0% -1.2% Max +0.3% +0.8% Geometric Mean +0.0% -0.0% - - - - - d37d91e9 by John Ericson at 2019-04-30T20:29:31-04:00 Generate settings by make/hadrian instead of configure This allows it to eventually become stage-specific - - - - - 53d1cd96 by John Ericson at 2019-04-30T20:29:31-04:00 Remove settings.in It is no longer needed - - - - - 2988ef5e by John Ericson at 2019-04-30T20:29:31-04:00 Move cGHC_UNLIT_PGM to be "unlit command" in settings The bulk of the work was done in #712, making settings be make/Hadrian controlled. This commit then just moves the unlit command rules in make/Hadrian from the `Config.hs` generator to the `settings` generator in each build system. I think this is a good change because the crucial benefit is *settings* don't affect the build: ghc gets one baby step closer to being a regular cabal executable, and make/Hadrian just maintains settings as part of bootstrapping. - - - - - 37a4fd97 by Alp Mestanogullari at 2019-04-30T20:35:35-04:00 Build Hadrian with -Werror in the 'ghc-in-ghci' CI job - - - - - 1bef62c3 by Ben Gamari at 2019-04-30T20:41:42-04:00 ErrUtils: Emit progress messages to eventlog - - - - - ebfa3528 by Ben Gamari at 2019-04-30T20:41:42-04:00 Emit GHC timing events to eventlog - - - - - 4186b410 by Sven Tennie at 2019-05-03T13:40:36-04:00 Typeset Big-O complexities with Tex-style notation (#16090) Use `\min` instead of `min` to typeset it as an operator. - - - - - 9047f184 by Shayne Fletcher at 2019-05-03T21:54:50+03:00 Make Extension derive Bounded - - - - - 0dde64f2 by Ben Gamari at 2019-05-03T21:54:50+03:00 testsuite: Mark concprog001 as fragile Due to #16604. - - - - - 8f929388 by Alp Mestanogullari at 2019-05-03T21:54:50+03:00 Hadrian: generate JUnit testsuite report in Linux CI job We also keep it as an artifact, like we do for non-Hadrian jobs, and list it as a junit report, so that the test results are reported in the GitLab UI for merge requests. - - - - - 52fc2719 by Vladislav Zavialov at 2019-05-03T21:54:50+03:00 Pattern/expression ambiguity resolution This patch removes 'EWildPat', 'EAsPat', 'EViewPat', and 'ELazyPat' from 'HsExpr' by using the ambiguity resolution system introduced earlier for the command/expression ambiguity. Problem: there are places in the grammar where we do not know whether we are parsing an expression or a pattern, for example: do { Con a b <- x } -- 'Con a b' is a pattern do { Con a b } -- 'Con a b' is an expression Until we encounter binding syntax (<-) we don't know whether to parse 'Con a b' as an expression or a pattern. The old solution was to parse as HsExpr always, and rejig later: checkPattern :: LHsExpr GhcPs -> P (LPat GhcPs) This meant polluting 'HsExpr' with pattern-related constructors. In other words, limitations of the parser were affecting the AST, and all other code (the renamer, the typechecker) had to deal with these extra constructors. We fix this abstraction leak by parsing into an overloaded representation: class DisambECP b where ... newtype ECP = ECP { runECP_PV :: forall b. DisambECP b => PV (Located b) } See Note [Ambiguous syntactic categories] for details. Now the intricacies of parsing have no effect on the hsSyn AST when it comes to the expression/pattern ambiguity. - - - - - 9b59e126 by Ningning Xie at 2019-05-03T21:54:50+03:00 Only skip decls with CUSKs with PolyKinds on (fix #16609) - - - - - 87bc954a by Ömer Sinan Ağacan at 2019-05-03T21:54:50+03:00 Fix interface version number printing in --show-iface Before Version: Wanted [8, 0, 9, 0, 2, 0, 1, 9, 0, 4, 2, 5], got [8, 0, 9, 0, 2, 0, 1, 9, 0, 4, 2, 5] After Version: Wanted 809020190425, got 809020190425 - - - - - cc495d57 by Ryan Scott at 2019-05-03T21:54:50+03:00 Make equality constraints in kinds invisible Issues #12102 and #15872 revealed something strange about the way GHC handles equality constraints in kinds: it treats them as _visible_ arguments! This causes a litany of strange effects, from strange error messages (https://gitlab.haskell.org/ghc/ghc/issues/12102#note_169035) to bizarre `Eq#`-related things leaking through to GHCi output, even without any special flags enabled. This patch is an attempt to contain some of this strangeness. In particular: * In `TcHsType.etaExpandAlgTyCon`, we propagate through the `AnonArgFlag`s of any `Anon` binders. Previously, we were always hard-coding them to `VisArg`, which meant that invisible binders (like those whose kinds were equality constraint) would mistakenly get flagged as visible. * In `ToIface.toIfaceAppArgsX`, we previously assumed that the argument to a `FunTy` always corresponding to a `Required` argument. We now dispatch on the `FunTy`'s `AnonArgFlag` and map `VisArg` to `Required` and `InvisArg` to `Inferred`. As a consequence, the iface pretty-printer correctly recognizes that equality coercions are inferred arguments, and as a result, only displays them in `-fprint-explicit-kinds` is enabled. * Speaking of iface pretty-printing, `Anon InvisArg` binders were previously being pretty-printed like `T (a :: b ~ c)`, as if they were required. This seemed inconsistent with other invisible arguments (that are printed like `T @{d}`), so I decided to switch this to `T @{a :: b ~ c}`. Along the way, I also cleaned up a minor inaccuracy in the users' guide section for constraints in kinds that was spotted in https://gitlab.haskell.org/ghc/ghc/issues/12102#note_136220. Fixes #12102 and #15872. - - - - - f862963b by Ömer Sinan Ağacan at 2019-05-03T20:50:03-04:00 rts: Properly free the RTSSummaryStats structure `stat_exit` always allocates a `RTSSummaryStats` but only sometimes frees it, which casues leaks. With this patch we unconditionally free the structure, fixing the leak. Fixes #16584 - - - - - 0af93d16 by Ömer Sinan Ağacan at 2019-05-03T20:56:18-04:00 StgCmmMonad: remove emitProc_, don't export emitProc - - - - - 0a3e4db3 by Ömer Sinan Ağacan at 2019-05-03T20:56:18-04:00 PrimOps.cmm: remove unused stuff - - - - - 63150b9e by iustin at 2019-05-04T17:54:23-04:00 Fix typo in 8.8.1 notes related to traceBinaryEvent - fixes double mention of `traceBinaryEvent#` (the second one should be `traceEvent#`, I think) - fixes note about `traceEvent#` taking a `String` - the docs say it takes a zero-terminated ByteString. - - - - - dc8a5868 by gallais at 2019-05-04T18:00:30-04:00 [ typo ] 'castFloatToWord32' -> 'castFloatToWord64' Probably due to a copy/paste gone wrong. - - - - - 615b4be6 by Chaitanya Koparkar at 2019-05-05T10:39:24-04:00 Fix #16593 by having only one definition of -fprint-explicit-runtime-reps [skip ci] - - - - - ead3f835 by Vladislav Zavialov at 2019-05-05T10:39:24-04:00 'warnSpaceAfterBang' only in patterns (#16619) - - - - - 27941064 by John Ericson at 2019-05-06T14:59:29-04:00 Remove cGhcEnableTablesNextToCode Get "Tables next to code" from the settings file instead. - - - - - 821fa9e8 by Takenobu Tani at 2019-05-06T15:05:36-04:00 Remove `$(TOP)/ANNOUNCE` file Remove `$(TOP)/ANNOUNCE` because maintaining this file is expensive for each release. Currently, release announcements of ghc are made on ghc blogs and wikis. [skip ci] - - - - - e172a6d1 by Alp Mestanogullari at 2019-05-06T15:11:43-04:00 Enable external interpreter when TH is requested but no internal interpreter is available - - - - - ba0aed2e by Alp Mestanogullari at 2019-05-06T17:32:56-04:00 Hadrian: override $(ghc-config-mk), to prevent redundant config generation This required making the 'ghc-config-mk' variable overridable in testsuite/mk/boilerplate.mk, and then making use of this in hadrian to point to '<build root>/test/ghcconfig' instead, which is where we always put the test config. Previously, we would build ghc-config and run it against the GHC to be tested, a second time, while we're running the tests, because some include testsuite/mk/boilerplate.mk. This was causing unexpected output failures. - - - - - 96197961 by Ryan Scott at 2019-05-07T06:35:58-04:00 Add /includes/dist to .gitignore As of commit d37d91e9a444a7822eef1558198d21511558515e, the GHC build now autogenerates a `includes/dist/build/settings` file. To avoid dirtying the current `git` status, this adds `includes/dist` to `.gitignore`. [ci skip] - - - - - 78a5c4ce by Ryan Scott at 2019-05-07T17:03:04-04:00 Check for duplicate variables in associated default equations A follow-up to !696's, which attempted to clean up the error messages for ill formed associated type family default equations. The previous attempt, !696, forgot to account for the possibility of duplicate kind variable arguments, as in the following example: ```hs class C (a :: j) where type T (a :: j) (b :: k) type T (a :: k) (b :: k) = k ``` This patch addresses this shortcoming by adding an additional check for this. Fixes #13971 (hopefully for good this time). - - - - - f58ea556 by Kevin Buhr at 2019-05-07T17:09:13-04:00 Add regression test for old typechecking issue #505 - - - - - 786e665b by Ryan Scott at 2019-05-08T01:55:45-04:00 Fix #16603 by documenting some important changes in changelogs This addresses some glaring omissions from `libraries/base/changelog.md` and `docs/users_guide/8.8.1-notes.rst`, fixing #16603 in the process. - - - - - 0eeb4cfa by Ryan Scott at 2019-05-08T02:01:54-04:00 Fix #16632 by using the correct SrcSpan in checkTyClHdr `checkTyClHdr`'s case for `HsTyVar` was grabbing the wrong `SrcSpan`, which lead to error messages pointing to the wrong location. Easily fixed. - - - - - ed5f858b by Shayne Fletcher at 2019-05-08T15:29:01-04:00 Implement ImportQualifiedPost - - - - - d9bdff60 by Kevin Buhr at 2019-05-08T15:35:13-04:00 stg_floatToWord32zh: zero-extend the Word32 (#16617) The primop stgFloatToWord32 was sign-extending the 32-bit word, resulting in weird negative Word32s. Zero-extend them instead. Closes #16617. - - - - - 9a3acac9 by Ömer Sinan Ağacan at 2019-05-08T15:41:17-04:00 Print PAP object address in stg_PAP_info entry code Continuation to ce23451c - - - - - 4c86187c by Richard Eisenberg at 2019-05-08T15:47:33-04:00 Regression test for #16627. test: typecheck/should_fail/T16627 - - - - - 93f34bbd by John Ericson at 2019-05-08T15:53:40-04:00 Purge TargetPlatform_NAME and cTargetPlatformString - - - - - 9d9af0ee by Kevin Buhr at 2019-05-08T15:59:46-04:00 Add regression test for old issue #507 - - - - - 396e01b4 by Vladislav Zavialov at 2019-05-08T16:05:52-04:00 Add a regression test for #14548 - - - - - 5eb94454 by Oleg Grenrus at 2019-05-10T16:26:28-04:00 Add Generic tuple instances up to 15-tuple Why 15? Because we have Eq instances up to 15. Metric Increase: T9630 haddock.base - - - - - c7913f71 by Roland Senn at 2019-05-10T16:32:38-04:00 Fix bugs and documentation for #13456 - - - - - bfcd986d by David Eichmann at 2019-05-10T16:38:57-04:00 Hadrian: programs need registered ghc-pkg libraries In Hadrian, building programs (e.g. `ghc` or `haddock`) requires libraries located in the ghc-pkg package database i.e. _build/stage1/lib/x86_64-linux-ghc-8.9.0.20190430/libHSdeepseq-1.4.4.0-ghc8.9.0.20190430.so Add the corresponding `need`s for these library files and the subsequent rules. - - - - - 10f579ad by Ben Gamari at 2019-05-10T16:45:05-04:00 gitlab-ci: Disable cleanup job on Windows As discussed in the Note, we now have a cron job to handle this and the cleanup job itself is quite fragile. [skip ci] - - - - - 6f07f828 by Kevin Buhr at 2019-05-10T16:51:11-04:00 Add regression test case for old issue #493 - - - - - 4e25bf46 by Giles Anderson at 2019-05-13T19:01:52-04:00 Change GHC.hs to Packages.hs in Hadrian user-settings.md ... "all packages that are currently built as part of the GHC are defined in src/Packages.hs" - - - - - 357be128 by Kevin Buhr at 2019-05-14T16:41:19-04:00 Add regression test for old parser issue #504 - - - - - 015a21b8 by John Ericson at 2019-05-14T16:41:19-04:00 hadrian: Make settings stage specific - - - - - f9e4ea40 by John Ericson at 2019-05-14T16:41:19-04:00 Dont refer to `cLeadingUnderscore` in test Can't use this config entry because it's about to go away - - - - - e529c65e by John Ericson at 2019-05-14T16:41:19-04:00 Remove all target-specific portions of Config.hs 1. If GHC is to be multi-target, these cannot be baked in at compile time. 2. Compile-time flags have a higher maintenance than run-time flags. 3. The old way makes build system implementation (various bootstrapping details) with the thing being built. E.g. GHC doesn't need to care about which integer library *will* be used---this is purely a crutch so the build system doesn't need to pass flags later when using that library. 4. Experience with cross compilation in Nixpkgs has shown things work nicer when compiler's can *optionally* delegate the bootstrapping the package manager. The package manager knows the entire end-goal build plan, and thus can make top-down decisions on bootstrapping. GHC can just worry about GHC, not even core library like base and ghc-prim! - - - - - 5cf8032e by Oleg Grenrus at 2019-05-14T16:41:19-04:00 Update terminal title while running test-suite Useful progress indicator even when `make test VERBOSE=1`, and when you do something else, but have terminal title visible. - - - - - c72c369b by Vladislav Zavialov at 2019-05-14T16:41:19-04:00 Add a minimized regression test for #12928 - - - - - a5fdd185 by Vladislav Zavialov at 2019-05-14T16:41:19-04:00 Guard CUSKs behind a language pragma GHC Proposal #36 describes a transition plan away from CUSKs and to top-level kind signatures: 1. Introduce a new extension, -XCUSKs, on by default, that detects CUSKs as they currently exist. 2. We turn off the -XCUSKs extension in a few releases and remove it sometime thereafter. This patch implements phase 1 of this plan, introducing a new language extension to control whether CUSKs are enabled. When top-level kind signatures are implemented, we can transition to phase 2. - - - - - 684dc290 by Vladislav Zavialov at 2019-05-14T16:41:19-04:00 Restore the --coerce option in 'happy' configuration happy-1.19.10 has been released with a fix for --coerce in the presence of higher rank types. This should result in about 10% performance improvement in the parser. - - - - - a416ae26 by Alp Mestanogullari at 2019-05-14T16:41:20-04:00 Hadrian: 'need' source files for various docs in Rules.Documentation Previously, changing one of the .rst files from the user guide would not cause the user guide to be rebuilt. This patch take a first stab at declaring the documentation source files that our documentation rules depend on, focusing on the .rst files only for now. We eventually might want to rebuild docs when we, say, change the haddock style file, but this level of tracking isn't really necessary for now. This fixes #16645. - - - - - 7105fb66 by Ben Gamari at 2019-05-16T12:47:59-04:00 rts: Explicit state that CONSTR tag field is zero-based This was a bit unclear as we use both one-based and zero-based tags in GHC. [skip ci] - - - - - 5bb80cf2 by David Eichmann at 2019-05-20T15:41:55+01:00 Improve test runner logging when calculating performance metric baseline #16662 We attempt to get 75 commit hashes via `git log`, but this only gave 10 hashes in a CI run (see #16662). Better logging may help solve this error if it occurs again in the future. - - - - - b46efa2b by David Eichmann at 2019-05-20T19:45:56+01:00 Recalculate Performance Test Baseline T9630 #16680 Metric Decrease: T9630 - - - - - 54095bbd by Takenobu Tani at 2019-05-21T16:54:00-04:00 users-guide: Fix directive errors on 8.10 The following sections are not displayed due to a directive error: * -Wunused-record-wildcards * -Wredundant-record-wildcards I changed the location of the `since` directive. [skip ci] - - - - - 8fc654c3 by David Eichmann at 2019-05-21T16:57:37-04:00 Include CPP preprocessor dependencies in -M output Issue #16521 - - - - - 0af519ac by David Eichmann at 2019-05-21T17:01:16-04:00 Refactor Libffi and RTS rules This removes a hack that copies libffi files to the rts build directory. This was done in a libffi rule, but now an rts rule correctly needs and copies the relevant files from the libffi build dir to the rts build dir. Issues: #16272 #16304 - - - - - 9342b1fa by Kirill Elagin at 2019-05-21T17:04:54-04:00 users-guide: Fix -rtsopts default - - - - - d0142f21 by Javran Cheng at 2019-05-21T17:08:29-04:00 Fix doc for Data.Function.fix. Doc-only change. - - - - - ddd905b4 by Shayne Fletcher at 2019-05-21T17:12:07-04:00 Update resolver for for happy 1.19.10 - - - - - e32c30ca by Alp Mestanogullari at 2019-05-21T17:15:45-04:00 distrib/configure.ac.in: remove mention to 'settings', since settings.in is gone Otherwise, when `./configure`ing a GHC bindist, produced by either Make or Hadrian, we would try to generate the `settings` file from the `settings.in` template that we used to have around but which has been gone since d37d91e9. That commit generates the settings file using the build systems instead, but forgot to remove this mention to the `settings` file. - - - - - 4a6c8436 by Ryan Scott at 2019-05-21T17:19:22-04:00 Fix #16666 by parenthesizing contexts in Convert Most places where we convert contexts in `Convert` are actually in positions that are to the left of some `=>`, such as in superclasses and instance contexts. Accordingly, these contexts need to be parenthesized at `funPrec`. To accomplish this, this patch changes `cvtContext` to require a precedence argument for the purposes of calling `parenthesizeHsContext` and adjusts all `cvtContext` call sites accordingly. - - - - - c32f64e5 by Ben Gamari at 2019-05-21T17:23:01-04:00 gitlab-ci: Allow Windows Hadrian build to fail Due to #16574. - - - - - 412a1f39 by Ben Gamari at 2019-05-21T17:23:01-04:00 Update .gitlab-ci.yml - - - - - 0dc79856 by Julian Leviston at 2019-05-21T20:55:44-04:00 Allow for multiple linker instances. Fixes Haskell portion of #3372. - - - - - 21272670 by Michael Sloan at 2019-05-22T16:37:57-04:00 Have GHCi use object code for UnboxedTuples modules #15454 The idea is to automatically enable -fobject-code for modules that use UnboxedTuples, along with all the modules they depend on. When looking into how to solve this, I was pleased to find that there was already highly similar logic for enabling code generation when -fno-code is specified but TemplateHaskell is used. The state before this patch was that if you used unboxed tuples then you had to enable `-fobject-code` globally rather than on a per module basis. - - - - - ddae344e by Michael Sloan at 2019-05-22T16:41:31-04:00 Use datatype for unboxed returns when loading ghc into ghci See #13101 and #15454 - - - - - 78c3f330 by Kevin Buhr at 2019-05-22T16:45:08-04:00 Add regression test for old Word32 arithmetic issue (#497) - - - - - ecc9366a by Alec Theriault at 2019-05-22T16:48:45-04:00 RTS: Fix restrictive cast Commit e75a9afd2989e0460f9b49fa07c1667299d93ee9 added an `unsigned` cast to account for OSes that have signed `rlim_t` signed. Unfortunately, the `unsigned` cast has the unintended effect of narrowing `rlim_t` to only 4 bytes. This leads to some spurious out of memory crashes (in particular: Haddock crashes with OOM whenn building docs of `ghc`-the-library). In this case, `W_` is a better type to cast to: we know it will be unsigned too and it has the same type as `*len` (so we don't suffer from accidental narrowing). - - - - - 2c15b85e by Alp Mestanogullari at 2019-05-22T16:52:22-04:00 Hadrian: add --test-root-dirs, to only run specific directories of tests We can specify several of those, by using the flag multiple times or just once but combining the directories with ':'. Along the way, this patch also fixes the testsuite-related --only flag, so that we can use it many times instead of being force to specify a space-separated list of test in a single --only flag. - - - - - 6efe04de by Ryan Scott at 2019-05-22T16:56:01-04:00 Use HsTyPats in associated type family defaults Associated type family default declarations behave strangely in a couple of ways: 1. If one tries to bind the type variables with an explicit `forall`, the `forall`'d part will simply be ignored. (#16110) 2. One cannot use visible kind application syntax on the left-hand sides of associated default equations, unlike every other form of type family equation. (#16356) Both of these issues have a common solution. Instead of using `LHsQTyVars` to represent the left-hand side arguments of an associated default equation, we instead use `HsTyPats`, which is what other forms of type family equations use. In particular, here are some highlights of this patch: * `FamEqn` is no longer parameterized by a `pats` type variable, as the `feqn_pats` field is now always `HsTyPats`. * The new design for `FamEqn` in chronicled in `Note [Type family instance declarations in HsSyn]`. * `TyFamDefltEqn` now becomes the same thing as `TyFamInstEqn`. This means that many of `TyFamDefltEqn`'s code paths can now reuse the code paths for `TyFamInstEqn`, resulting in substantial simplifications to various parts of the code dealing with associated type family defaults. Fixes #16110 and #16356. - - - - - 4ba73e00 by Luite Stegeman at 2019-05-22T16:59:39-04:00 fix Template Haskell cross compilation on 64 bit compiler with 32 bit target - - - - - 535a26c9 by David Eichmann at 2019-05-23T18:26:37+01:00 Revert "Add Generic tuple instances up to 15-tuple" #16688 This reverts commit 5eb9445444c4099fc9ee0803ba45db390900a80f. It has caused an increase in variance of performance test T9630, causing CI to fail. - - - - - 04b4b984 by Alp Mestanogullari at 2019-05-23T22:32:15-04:00 add an --hadrian mode to ./validate When the '--hadrian' flag is passed to the validate script, we use hadrian to build GHC, package it up in a binary distribution and later on run GHC's testsuite against the said bindist, which gets installed locally in the process. Along the way, this commit fixes a typo, an omission (build iserv binaries before producing the bindist archive) and moves the Makefile that enables 'make install' on those bindists from being a list of strings in the code to an actual file (it was becoming increasingly annoying to work with). Finally, the Settings.Builders.Ghc part of this patch is necessary for being able to use the installed binary distribution, in 'validate'. - - - - - 0b449d34 by Ömer Sinan Ağacan at 2019-05-23T22:35:54-04:00 Add a test for #16597 - - - - - 59f4cb6f by Iavor Diatchki at 2019-05-23T22:39:35-04:00 Add a `NOINLINE` pragma on `someNatVal` (#16586) This fixes #16586, see `Note [NOINLINE someNatVal]` for details. - - - - - 6eedbd83 by Ryan Scott at 2019-05-23T22:43:12-04:00 Some forall-related cleanup in deriving code * Tweak the parser to allow `deriving` clauses to mention explicit `forall`s or kind signatures without gratuitous parentheses. (This fixes #14332 as a consequence.) * Allow Haddock comments on `deriving` clauses with explicit `forall`s. This requires corresponding changes in Haddock. - - - - - c931f256 by David Eichmann at 2019-05-24T11:22:29+01:00 Allow metric change after reverting "Add Generic tuple instances up to 15-tuple" #16688 Metrics increased on commit 5eb9445444c4099fc9ee0803ba45db390900a80f and decreased on revert commit 535a26c90f458801aeb1e941a3f541200d171e8f. Metric Decrease: T9630 haddock.base - - - - - d9dfbde3 by Michael Sloan at 2019-05-24T16:55:07+01:00 Add PlainPanic for throwing exceptions without depending on pprint This commit splits out a subset of GhcException which do not depend on pretty printing (SDoc), as a new datatype called PlainGhcException. These exceptions can be caught as GhcException, because 'fromException' will convert them. The motivation for this change is that that the Panic module transitively depends on many modules, primarily due to pretty printing code. It's on the order of about 130 modules. This large set of dependencies has a few implications: 1. To avoid cycles / use of boot files, these dependencies cannot throw GhcException. 2. There are some utility modules that use UnboxedTuples and also use `panic`. This means that when loading GHC into GHCi, about 130 additional modules would need to be compiled instead of interpreted. Splitting the non-pprint exception throwing into a new module resolves this issue. See #13101 - - - - - 70c24471 by Moritz Angermann at 2019-05-25T17:51:30-04:00 Add `keepCAFs` to RtsSymbols - - - - - 9be1749d by David Eichmann at 2019-05-25T17:55:05-04:00 Hadrian: Add Mising Libffi Dependencies #16653 Libffi is ultimately built from a single archive file (e.g. libffi-tarballs/libffi-3.99999+git20171002+77e130c.tar.gz). The file can be seen as the shallow dependency for the whole libffi build. Hence, in all libffi rules, the archive is `need`ed and the build directory is `trackAllow`ed. - - - - - 2d0cf625 by Sandy Maguire at 2019-05-26T08:57:20-04:00 Let the specialiser work on dicts under lambdas Following the discussion under #16473, this change allows the specializer to work on any dicts in a lambda, not just those that occur at the beginning. For example, if you use data types which contain dictionaries and higher-rank functions then once these are erased by the optimiser you end up with functions such as: ``` go_s4K9 Int# -> forall (m :: * -> *). Monad m => (forall x. Union '[State (Sum Int)] x -> m x) -> m () ``` The dictionary argument is after the Int# value argument, this patch allows `go` to be specialised. - - - - - 4b228768 by Moritz Angermann at 2019-05-27T01:19:49-04:00 Lowercase windows imports While windows and macOS are currently on case-insensitive file systems, this poses no issue on those. When cross compiling from linux with a case sensitive file system and mingw providing only lowercase headers, this in fact produces an issue. As such we just lowercase the import headers, which should still work fine on a case insensitive file system and also enable mingw's headers to be usable porperly. - - - - - 01f8e390 by Alp Mestanogullari at 2019-05-27T10:06:26-04:00 Hadrian: Fix problem with unlit path in settings file e529c65e introduced a problem in the logic for generating the path to the unlit command in the settings file, and this patches fixes it. This fixes many tests, the simplest of which is: > _build/stage1/bin/ghc testsuite/tests/parser/should_fail/T8430.lhs which failed because of a wrong path for unlit, and now fails for the right reason, with the error message expected for this test. This addresses #16659. - - - - - dcd843ac by mizunashi_mana at 2019-05-27T10:06:27-04:00 Fix typo of primop format - - - - - 3f6e5b97 by Joshua Price at 2019-05-27T10:06:28-04:00 Correct the large tuples section in user's guide Fixes #16644. - - - - - 1f51aad6 by Krzysztof Gogolewski at 2019-05-27T10:06:28-04:00 Fix tcfail158 (#15899) As described in #15899, this test was broken, but now it's back to normal. - - - - - 723216e3 by Sebastian Graf at 2019-05-27T10:06:29-04:00 Add a pprTraceWith function - - - - - 6d188dd5 by Simon Jakobi at 2019-05-27T10:06:31-04:00 base: Include (<$) in all exports of Functor Previously the haddocks for Control.Monad and Data.Functor gave the impression that `fmap` was the only Functor method. Fixes #16681. - - - - - 95b79173 by Jasper Van der Jeugt at 2019-05-27T10:06:32-04:00 Fix padding of entries in .prof files When the number of entries of a cost centre reaches 11 digits, it takes up the whole space reserved for it and the prof file ends up looking like: ... no. entries %time %alloc %time %alloc ... ... 120918 978250 0.0 0.0 0.0 0.0 ... 118891 0 0.0 0.0 73.3 80.8 ... 11890229702412351 8.9 13.5 73.3 80.8 ... 118903 153799689 0.0 0.1 0.0 0.1 ... This results in tooling not being able to parse the .prof file. I realise we have the JSON output as well now, but still it'd be good to fix this little weirdness. Original bug report and full prof file can be seen here: <https://github.com/jaspervdj/profiteur/issues/28>. - - - - - f80d3afd by John Ericson at 2019-05-27T10:06:33-04:00 hadrian: Fix generation of settings I jumbled some lines in e529c65eacf595006dd5358491d28c202d673732, messing up the leading underscores and rts ways settings. This broke at least stage1 linking on macOS, but probably loads of other things too. Should fix #16685 and #16658. - - - - - db8e3275 by Ömer Sinan Ağacan at 2019-05-27T10:06:37-04:00 Add missing opening braces in Cmm dumps Previously -ddump-cmm was generating code with unbalanced curly braces: stg_atomically_entry() // [R1] { info_tbls: [(cfl, label: stg_atomically_info rep: tag:16 HeapRep 1 ptrs { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset cfl: // cfk unwind Sp = Just Sp + 0; _cfk::P64 = R1; //tick src<rts/PrimOps.cmm:(1243,1)-(1245,1)> R1 = I64[_cfk::P64 + 8 + 8 + 0 * 8]; call stg_atomicallyzh(R1) args: 8, res: 0, upd: 8; } }, <---- OPENING BRACE MISSING After this patch: stg_atomically_entry() { // [R1] <---- MISSING OPENING BRACE HERE { info_tbls: [(cfl, label: stg_atomically_info rep: tag:16 HeapRep 1 ptrs { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset cfl: // cfk unwind Sp = Just Sp + 0; _cfk::P64 = R1; //tick src<rts/PrimOps.cmm:(1243,1)-(1245,1)> R1 = I64[_cfk::P64 + 8 + 8 + 0 * 8]; call stg_atomicallyzh(R1) args: 8, res: 0, upd: 8; } }, - - - - - 9334467f by Richard Eisenberg at 2019-05-28T00:24:50-04:00 Improve comments around injectivity checks - - - - - c8380a4a by Krzysztof Gogolewski at 2019-05-29T10:35:50-04:00 Handle hs-boot files in -Wmissing-home-modules (#16551) - - - - - 7a75a094 by Alp Mestanogullari at 2019-05-29T10:36:35-04:00 testsuite: introduce 'static_stats' tests They are a particular type of perf tests. This patch introduces a 'stats_files_dir' configuration field in the testsuite driver where all haddock timing files (and possibly others in the future) are assumed to live. We also change both the Make and Hadrian build systems to pass respectively $(TOP)/testsuite/tests/perf/haddock/ and <build root>/stage1/haddock-timing-files/ as the value of that new configuration field, and to generate the timing files in those directories in the first place while generating documentation with haddock. This new test type can be seen as one dedicated to examining stats files that are generated while building a GHC distribution. This also lets us get rid of the 'extra_files' directives in the all.T entries for haddock.base, haddock.Cabal and haddock.compiler. - - - - - 32acecc2 by P.C. Shyamshankar at 2019-05-29T10:37:16-04:00 Minor spelling fixes to users guide. - - - - - b58b389b by Oleg Grenrus at 2019-05-29T10:37:54-04:00 Remove stale 8.2.1-notes - - - - - 5bfd28f5 by Oleg Grenrus at 2019-05-29T10:37:54-04:00 Fix some warnings in users_guide (incl #16640) - short underline - :ghc-flag:, not :ghc-flags: - :since: have to be separate - newline before code block - workaround anchor generation so - pragma:SPECIALISE - pragma:SPECIALIZE-INLINE - pragma:SPECIALIZE-inline are different anchors, not all the same `pragma:SPECIALIZE` - - - - - a5b14ad4 by Kevin Buhr at 2019-05-29T10:38:30-04:00 Add test for old issue displaying unboxed tuples in error messages (#502) - - - - - f9d61ebb by Krzysztof Gogolewski at 2019-05-29T10:39:05-04:00 In hole fits, don't show VTA for inferred variables (#16456) We fetch the ArgFlag for every argument by using splitForAllVarBndrs instead of splitForAllTys in unwrapTypeVars. - - - - - 69b16331 by Krzysztof Gogolewski at 2019-05-29T10:39:43-04:00 Fix missing unboxed tuple RuntimeReps (#16565) Unboxed tuples and sums take extra RuntimeRep arguments, which must be manually passed in a few places. This was not done in deSugar/Check. This error was hidden because zipping functions in TyCoRep ignored lists with mismatching length. This is now fixed; the lengths are now checked by calling zipEqual. As suggested in #16565, I moved checking for isTyVar and isCoVar to zipTyEnv and zipCoEnv. - - - - - 9062b625 by Nathan Collins at 2019-05-29T10:40:21-04:00 Don't lose parentheses in show SomeAsyncException - - - - - cc0d05a7 by Daniel Gröber at 2019-05-29T10:41:02-04:00 Add hPutStringBuffer utility - - - - - 5b90e0a1 by Daniel Gröber at 2019-05-29T10:41:02-04:00 Allow using tagetContents for modules needing preprocessing This allows GHC API clients, most notably tooling such as Haskell-IDE-Engine, to pass unsaved files to GHC more easily. Currently when targetContents is used but the module requires preprocessing 'preprocessFile' simply throws an error because the pipeline does not support passing a buffer. This change extends `runPipeline` to allow passing the input buffer into the pipeline. Before proceeding with the actual pipeline loop the input buffer is immediately written out to a new tempfile. I briefly considered refactoring the pipeline at large to pass around in-memory buffers instead of files, but this seems needlessly complicated since no pipeline stages other than Hsc could really support this at the moment. - - - - - fb26d467 by Daniel Gröber at 2019-05-29T10:41:02-04:00 downsweep: Allow TargetFile not to exist when a buffer is given Currently 'getRootSummary' will fail with an exception if a 'TargetFile' is given but it does not exist even if an input buffer is passed along for this target. In this case it is not necessary for the file to exist since the buffer will be used as input for the compilation pipeline instead of the file anyways. - - - - - 4d51e0d8 by Ömer Sinan Ağacan at 2019-05-29T10:41:44-04:00 CNF.c: Move debug functions behind ifdef - - - - - ae968d41 by Vladislav Zavialov at 2019-05-29T10:42:20-04:00 tcMatchesFun s/rho/sigma #16692 - - - - - 2d2aa203 by Josh Meredith at 2019-05-29T10:43:03-04:00 Provide details in `plusSimplCount` errors - - - - - ace2e335 by John Ericson at 2019-05-29T16:06:45-04:00 Break up `Settings` into smaller structs As far as I can tell, the fields within `Settings` aren't *intrinsicly* related. They just happen to be initialized the same way (in particular prior to the rest of `DynFlags`), and that is why they are grouped together. Within `Settings`, however, there are groups of settings that clearly do share something in common, regardless of how they anything is initialized. In the spirit of GHC being a library, where the end cosumer may choose to initialize this configuration in arbitrary ways, I made some new data types for thoses groups internal to `Settings`, and used them to define `Settings` instead. Hopefully this is a baby step towards a general decoupling of the stateful and stateless parts of GHC. - - - - - bfccd832 by John Ericson at 2019-05-29T16:06:45-04:00 Inline `Settings` into `DynFlags` After the previous commit, `Settings` is just a thin wrapper around other groups of settings. While `Settings` is used by GHC-the-executable to initalize `DynFlags`, in principle another consumer of GHC-the-library could initialize `DynFlags` a different way. It therefore doesn't make sense for `DynFlags` itself (library code) to separate the settings that typically come from `Settings` from the settings that typically don't. - - - - - a1bf3413 by David Eichmann at 2019-05-29T16:07:24-04:00 Hadrian: Add note about Libffi's Indicating Inputs #16653 [skip ci] - - - - - 3aa71a22 by Alp Mestanogullari at 2019-05-30T07:28:32-04:00 Hadrian: always generate the libffi dynlibs manifest with globbing Instead of trying to deduce which dynlibs are expected to be found (and then copied to the RTS's build dir) in libffi's build directory, with some OS specific logic, we now always just use `getDirectoryFilesIO` to look for those dynlibs and record their names in the manifest. The previous logic ended up causing problems on Windows, where we don't build dynlibs at all for now but the manifest file's logic didn't take that into account because it was only partially reproducing the criterions that determine whether or not we will be building shared libraries. This patch also re-enables the Hadrian/Windows CI job, which was failing to build GHC precisely because of libffi shared libraries and the aforementionned duplicated logic. - - - - - ade53ce2 by Ben Gamari at 2019-05-30T07:29:10-04:00 CODEOWNERS: Use correct username for Richard Eisenberg In !980 Richard noted that he could not approve the MR. This mis-spelling was the reason. [skip ci] - - - - - 4ad37a32 by Ben Gamari at 2019-05-30T07:29:47-04:00 rts: Handle zero-sized mappings in MachO linker As noted in #16701, it is possible that we will find that an object has no segments needing to be mapped. Previously this would result in mmap being called for a zero-length mapping, which would fail. We now simply skip the mmap call in this case; the rest of the logic just works. - - - - - f81f3964 by Phuong Trinh at 2019-05-30T16:43:31-04:00 Use binary search to speedup checkUnload We are iterating through all object code for each heap objects when checking whether object code can be unloaded. For large projects in GHCi, this can be very expensive due to the large number of object code that needs to be loaded/unloaded. To speed it up, this arrangess all mapped sections of unloaded object code in a sorted array and use binary search to check if an address location fall on them. - - - - - 42129180 by Trịnh Tuấn Phương at 2019-05-30T16:43:31-04:00 Apply suggestion to rts/CheckUnload.c - - - - - 8e42e98e by Trịnh Tuấn Phương at 2019-05-30T16:43:31-04:00 Apply suggestion to rts/CheckUnload.c - - - - - 70afa539 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Export GhcMake.downsweep This is to enable #10887 as well as to make it possible to test downsweep on its own in the testsuite. - - - - - a8de5c5a by Daniel Gröber at 2019-05-30T16:44:08-04:00 Add failing test for #10887 - - - - - 8906bd66 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Refactor downsweep to allow returning multiple errors per module - - - - - 8e85ebf7 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Refactor summarise{File,Module} to reduce code duplication - - - - - 76c86fca by Daniel Gröber at 2019-05-30T16:44:08-04:00 Refactor summarise{File,Module} to extract checkSummaryTimestamp This introduces a slight change of behaviour in the interrest of keeping the code simple: Previously summariseModule would not call addHomeModuleToFinder for summaries that are being re-used but now we do. We're forced to to do this in summariseFile because the file being summarised might not even be on the regular search path! So if GHC is to find it at all we have to pre-populate the cache with its location. For modules however the finder cache is really just a cache so we don't have to pre-populate it with the module's location. As straightforward as that seems I did almost manage to introduce a bug (or so I thought) because the call to addHomeModuleToFinder I copied from summariseFile used to use `ms_location old_summary` instead of the `location` argument to checkSummaryTimestamp. If this call were to overwrite the existing entry in the cache that would have resulted in us using the old location of any module even if it was, say, moved to a different directory between calls to 'depanal'. However it turns out the cache just ignores the location if the module is already in the cache. Since summariseModule has to search for the module, which has the side effect of populating the cache, everything would have been fine either way. Well I'm adding a test for this anyways: tests/depanal/OldModLocation.hs. - - - - - 18d3f01d by Daniel Gröber at 2019-05-30T16:44:08-04:00 Make downsweep return all errors per-module instead of throwing some This enables API clients to handle such errors instead of immideately crashing in the face of some kinds of user errors, which is arguably quite bad UX. Fixes #10887 - - - - - 99e72769 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Catch preprocessor errors in downsweep This changes the way preprocessor failures are presented to the user. Previously the user would simply get an unlocated message on stderr such as: `gcc' failed in phase `C pre-processor'. (Exit code: 1) Now at the problematic source file is mentioned: A.hs:1:1: error: `gcc' failed in phase `C pre-processor'. (Exit code: 1) This also makes live easier for GHC API clients as the preprocessor error is now thrown as a SourceError exception. - - - - - b7ca94fd by Daniel Gröber at 2019-05-30T16:44:08-04:00 PartialDownsweep: Add test for import errors - - - - - 98e39818 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Add depanalPartial to make getting a partial modgraph easier As per @mpickering's suggestion on IRC this is to make the partial module-graph more easily accessible for API clients which don't intend to re-implementing depanal. - - - - - d2784771 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Improve targetContents code docs - - - - - 424e85b2 by Ben Gamari at 2019-05-30T16:44:43-04:00 testsuite: Compile T9630 with +RTS -G1 For the reasons described in Note [residency] we run programs with -G1 when we care about the max_bytes_used metric. - - - - - 4879d7af by Matthew Pickering at 2019-05-31T01:56:16-04:00 Eventlog: Document the fact timestamps are nanoseconds [skip ci] - - - - - 0b01a354 by Takenobu Tani at 2019-05-31T01:56:54-04:00 Update `$(TOP)/*.md` documents I updated the top documents to the latest status: - HACKING.md: - Modify Phabricator to GitLab infomation - Remove old Trac information - Add link to GitLab activity - MAKEHELP.md: - Add link to hadrian wiki - Fix markdown format - INSTALL.md: - Modify boot command to remove python3 - Fix markdown format - README.md: - Modify tarball file suffix - Fix markdown format I checked the page display on the GitHub and GitLab web. [skip ci] - - - - - 973077ac by Sergei Trofimovich at 2019-05-31T01:57:31-04:00 powerpc32: fix 64-bit comparison (#16465) On powerpc32 64-bit comparison code generated dangling target labels. This caused ghc build failure as: $ ./configure --target=powerpc-unknown-linux-gnu && make ... SCCs aren't in reverse dependent order bad blockId n3U This happened because condIntCode' in PPC codegen generated label name but did not place the label into `cmp_lo` code block. The change adds the `cmp_lo` label into the case of negative comparison. Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - bb2ee86a by Sergei Trofimovich at 2019-05-31T01:57:31-04:00 powerpc32: fix stack allocation code generation When ghc was built for powerpc32 built failed as: It's a fallout of commit 3f46cffcc2850e68405a1 ("PPC NCG: Refactor stack allocation code") where word size used to be II32/II64 and changed to II8/panic "no width for given number of bytes" widthFromBytes ((platformWordSize platform) `quot` 8) The change restores initial behaviour by removing extra division. Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 08b4c813 by Matthew Pickering at 2019-05-31T01:58:08-04:00 Use types already in AST when making .hie file These were meant to be added in !214 but for some reason wasn't included in the patch. Update Haddock submodule for new Types.hs hyperlinker output - - - - - 284cca51 by David Hewson at 2019-05-31T01:58:47-04:00 support small arrays and CONSTR_NOCAF in ghc-heap - - - - - f071576c by Neil Mitchell at 2019-05-31T01:59:24-04:00 Expose doCpp - - - - - c70d039e by Ömer Sinan Ağacan at 2019-05-31T02:00:02-04:00 Remove unused RTS function 'unmark' - - - - - bb929009 by Ömer Sinan Ağacan at 2019-05-31T02:00:40-04:00 Fix arity type of coerced types in CoreArity Previously if we had f |> co where `f` had arity type `ABot N` and `co` had arity M and M < N, `arityType` would return `ABot M` which is wrong, because `f` is only known to diverge when applied to `N` args, as described in Note [ArityType]: If at = ABot n, then (f x1..xn) definitely diverges. Partial applications to fewer than n args may *or may not* diverge. This caused incorrect eta expansion in the simplifier, causing #16066. We now return `ATop M` for the same expression so the simplifier can't assume partial applications of `f |> co` is divergent. A regression test T16066 is also added. - - - - - e32786df by Ryan Scott at 2019-05-31T02:01:18-04:00 Put COMPLETE sigs into ModDetails with -fno-code (#16682) `mkBootModDetailsTc`, which creates a special `ModDetails` when `-fno-code` is enabled, was not properly filling in the `COMPLETE` signatures from the `TcGblEnv`, resulting in incorrect pattern-match coverage warnings. Easily fixed. Fixes #16682. - - - - - 0c6f7f7e by Simon Jakobi at 2019-05-31T02:01:55-04:00 Implement (Functor.<$) for Array - - - - - 495a65cb by Simon Jakobi at 2019-05-31T02:02:33-04:00 Implement (Functor.<$) for Data.Functor.{Compose,Product,Sum} This allows us to make use of the (<$) implementations of the underlying functors. - - - - - 0e0d87da by Zubin Duggal at 2019-05-31T07:34:57+01:00 Fix and enforce validation of header for .hie files Implements #16686 The files version is automatically generated from the current GHC version in the same manner as normal interface files. This means that clients can first read the version and then decide how to read the rest of the file. - - - - - 1d43d4a3 by Nathan Collins at 2019-05-31T23:55:49-04:00 Improve ThreadId Show instance By making it include parens when a derived instance would. For example, this changes the (hypothetical) code `show (Just (ThreadId 3))` to produce `"Just (ThreadId 3)"` instead of the current `"Just ThreadId 3"`. - - - - - 45f88494 by Ryan Scott at 2019-05-31T23:56:27-04:00 Reject nested foralls in foreign imports (#16702) This replaces a panic observed in #16702 with a simple error message stating that nested `forall`s simply aren't allowed in the type signature of a `foreign import` (at least, not at present). Fixes #16702. - - - - - 76e58890 by Ryan Scott at 2019-05-31T23:57:05-04:00 Fix space leaks in dynLoadObjs (#16708) When running the test suite on a GHC built with the `quick` build flavour, `-fghci-leak-check` noticed some space leaks. Careful investigation led to `Linker.dynLoadObjs` being the culprit. Pattern-matching on `PeristentLinkerState` and a dash of `$!` were sufficient to fix the issue. (ht to mpickering for his suggestions, which were crucial to discovering a fix) Fixes #16708. - - - - - 1503da32 by Ömer Sinan Ağacan at 2019-06-01T11:18:57-04:00 Fix rewriting invalid shifts to errors Fixes #16449. 5341edf3 removed a code in rewrite rules for bit shifts, which broke the "silly shift guard", causing generating invalid bit shifts or heap overflow in compile time while trying to evaluate those invalid bit shifts. The "guard" is explained in Note [Guarding against silly shifts] in PrelRules.hs. More specifically, this was the breaking change: --- a/compiler/prelude/PrelRules.hs +++ b/compiler/prelude/PrelRules.hs @@ -474,12 +474,11 @@ shiftRule shift_op ; case e1 of _ | shift_len == 0 -> return e1 - | shift_len < 0 || wordSizeInBits dflags < shift_len - -> return (mkRuntimeErrorApp rUNTIME_ERROR_ID wordPrimTy - ("Bad shift length" ++ show shift_len)) This patch reverts this change. Two new tests added: - T16449_1: The original reproducer in #16449. This was previously casing a heap overflow in compile time when CmmOpt tries to evaluate the large (invalid) bit shift in compile time, using `Integer` as the result type. Now it builds as expected. We now generate an error for the shift as expected. - T16449_2: Tests code generator for large (invalid) bit shifts. - - - - - 2e297b36 by Ömer Sinan Ağacan at 2019-06-01T11:19:35-04:00 rts: Remove unused decls from CNF.h - - - - - 33e37d06 by Takenobu Tani at 2019-06-02T22:54:43-04:00 Add `-haddock` option under ci condition to fix #16415 In order to use the `:doc` command in ghci, it is necessary to compile for core libraries with `-haddock` option. Especially, the `-haddock` option is essential for release building. Note: * The `-haddock` option may affect compile time and binary size. * But hadrian has already set `-haddock` as the default. * This patch affects the make-based building. This patch has been split from !532. - - - - - 43a39c3c by Takenobu Tani at 2019-06-02T22:54:43-04:00 Add `-haddock` to perf.mk rather than prepare-system.sh To cover ci conditions from ghc8.6 to 8.9, I add `-haddock` option to `mk/flavours/perf.mk` rather than `.circleci/prepare-system.sh`. Because in windows condition of ghc-8.9, `mk/flavours/*` is included after `prepare-system.sh`. In addition, in linux condition of ghc-8.6, `mk/flavors/perf.mk` is used. - - - - - c4f94320 by Takenobu Tani at 2019-06-02T22:54:43-04:00 Add `-haddock` to prepare-system.sh and .gitlab-ci.yml To cover ci conditions from ghc8.6 to 8.9, I add `-haddock` option to `.circleci/prepare-system.sh` and .gitlab-ci.yml. after including `mk/flavours/*`. - - - - - 799b1d26 by Ben Gamari at 2019-06-02T22:55:18-04:00 gitlab-ci: Use GHC 8.6.5 for Windows CI builds - - - - - 286827be by David Eichmann at 2019-06-04T01:09:05-04:00 TestRunner: Added --chart to display a chart of performance tests This uses the Chart.js javascript library. Everything is put into a standalone .html file and opened with the default browser. I also simplified the text output to use the same data as the chart. You can now use a commit range with git's ".." syntax. The --ci option will use results from CI (you'll need to fetch them first): $ git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/ci/perf $ python3 testsuite/driver/perf_notes.py --ci --chart --test-env x86_64-darwin --test-name T9630 master~500..master - - - - - db78ac6f by Andrew Martin at 2019-06-04T01:09:43-04:00 Use a better strategy for determining the offset applied to foreign function arguments that have an unlifted boxed type. We used to use the type of the argument. We now use the type of the foreign function. Add a test to confirm that the roundtrip conversion between an unlifted boxed type and Any is sound in the presence of a foreign function call. - - - - - 114b014f by Alp Mestanogullari at 2019-06-04T01:10:20-04:00 Hadrian: fix OSX build failure and add an OSX/Hadrian CI job The OSX build failure introduced in 3aa71a22 was due to a change in the glob we use to collect libffi shared libraries in hadrian/src/Rules/Libffi.hs. This commit fixes the problem and adds an OSX CI job that builds GHC with Hadrian, to make sure we don't break it again. - - - - - 002594b7 by Xavier Denis at 2019-06-04T14:41:29-04:00 Add GHCi :instances command This commit adds the `:instances` command to ghci following proosal number 41. This makes it possible to query which instances are available to a given type. The output of this command is all the possible instances with type variables and constraints instantiated. - - - - - 3ecc03df by Ben Gamari at 2019-06-04T14:42:04-04:00 gitlab-ci: Run bindisttest during CI - - - - - c16f3297 by Ben Gamari at 2019-06-04T14:42:04-04:00 make: Fix bindist installation This fixes a few vestigial references to `settings` left over from !655. Fixes #16715. - - - - - ba4e3934 by Alp Mestanogullari at 2019-06-04T14:43:17-04:00 Hadrian: profiling and debug enabled ways support -eventlog too - - - - - 567894b4 by Matthew Pickering at 2019-06-07T09:36:32+01:00 gitlab-ci: Disable darwin hadrian job See #16771 We don't have enough capacity for the two jobs currently. [skip ci] - - - - - d3915b30 by Andrew Martin at 2019-06-07T10:20:42-04:00 [skip ci] Improve the documentation of the CNF primops. In this context, the term "size" is ambiguous and is now avoided. Additionally, the distinction between a CNF and the blocks that comprise it has been emphasize. The vocabulary has been made more consistent with the vocabulary in the C source for CNF. - - - - - e963beb5 by Sebastian Graf at 2019-06-07T10:21:21-04:00 TmOracle: Replace negative term equalities by refutable PmAltCons The `PmExprEq` business was a huge hack and was at the same time vastly too powerful and not powerful enough to encode negative term equalities, i.e. facts of the form "forall y. x ≁ Just y". This patch introduces the concept of 'refutable shapes': What matters for the pattern match checker is being able to encode knowledge of the kind "x can no longer be the literal 5". We encode this knowledge in a `PmRefutEnv`, mapping a set of newly introduced `PmAltCon`s (which are just `PmLit`s at the moment) to each variable denoting above inequalities. So, say we have `x ≁ 42 ∈ refuts` in the term oracle context and try to solve an equality like `x ~ 42`. The entry in the refutable environment will immediately lead to a contradiction. This machinery renders the whole `PmExprEq` and `ComplexEq` business unnecessary, getting rid of a lot of (mostly dead) code. See the Note [Refutable shapes] in TmOracle for a place to start. Metric Decrease: T11195 - - - - - 0b7372f6 by Matthew Pickering at 2019-06-07T10:21:57-04:00 Add HEAP_PROF_SAMPLE_END event to mark end of samples This allows a user to observe how long a sampling period lasts so that the time taken can be removed from the profiling output. Fixes #16697 - - - - - d1dc0ed7 by Roland Senn at 2019-06-07T10:22:47-04:00 Fix #16700: Tiny errors in output of GHCi commands :forward and :info `:info Coercible` now outputs the correct section number of the GHCi User's guide together with the secion title. `:forward x` gives the correct syntax hint. - - - - - 387050d0 by John Ericson at 2019-06-07T10:23:23-04:00 Factor out 'getLibDir' / 'getBaseDir' into a new GHC.BaseDir ghc-boot module ghc-pkg and ghc already both needed this. I figure it is better to deduplicate, especially seeing that changes to one (FreeBSD CPP) didn't make it to the other. Additionally in !1090 I make ghc-pkg look up the settings file, which makes it use the top dir a bit more widely. If that lands, any difference in the way they find the top dir would be more noticable. That change also means sharing more code between ghc and ghc-package (namely the settings file parsing code), so I'd think it better to get off the slipperly slope of duplicating code now. - - - - - da26ffe7 by Simon Peyton Jones at 2019-06-07T10:24:00-04:00 Preserve ShadowInfo when rewriting evidence When the canonicaliser rewrites evidence of a Wanted, it should preserve the ShadowInfo (ctev_nosh) field. That is, a WDerive should rewrite to WDerive, and WOnly to WOnly. Previously we were unconditionally making a WDeriv, thereby rewriting WOnly to WDeriv. This bit Nick Frisby (issue #16735) in the context of his plugin, but we don't have a compact test case. The fix is simple, but does involve a bit more plumbing, to pass the old ShadowInfo around, to use when building the new Wanted. - - - - - 9bb58799 by Ben Gamari at 2019-06-07T10:24:38-04:00 Hadrian: Delete target symlink in createFileLinkUntracked Previously createFileLinkUntracked would fail if the symlink already existed. - - - - - be63d299 by Simon Jakobi at 2019-06-07T10:25:16-04:00 Fix isValidNatural: The BigNat in NatJ# must have at least 2 limbs Previously the `integer-gmp` variant of `isValidNatural` would fail to detect values `<= maxBound::Word` that were incorrectly encoded using the `NatJ#` constructor. - - - - - e87b9f87 by Moritz Angermann at 2019-06-07T10:26:04-04:00 llvm-targets: Add x86_64 android layout - - - - - 60db142b by code5hot at 2019-06-07T10:26:46-04:00 Update Traversable.hs with a note about an intuitive law - - - - - f11aca52 by code5hot at 2019-06-07T10:26:46-04:00 Used terminology from a paper. Added it as a reference. - - - - - 13b3d45d by code5hot at 2019-06-07T10:26:46-04:00 remove backticks from markup - it doesn't mean what I think it means - - - - - cfd3e0f1 by Zejun Wu at 2019-06-07T10:27:34-04:00 Pass preprocessor options to C compiler when building foreign C files (#16737) - - - - - 5991d877 by Ben Gamari at 2019-06-07T10:28:09-04:00 base: Export Finalizers As requested in #16750. - - - - - 3d97bad6 by Alp Mestanogullari at 2019-06-07T10:28:47-04:00 Hadrian: use deb9 Docker images instead of deb8 for CI jobs This should fix #16739, where we seem to be getting extra carets in a test's output because of the gcc that ships with the deb8 image, whule we're not observing those extra carets in the deb9-based (Make) jobs. - - - - - 1afb4995 by Ben Gamari at 2019-06-07T10:29:23-04:00 gitlab-ci: Create index.html in documentation deployment Otherwise navigating to https://ghc.gitlab.haskell.org/ghc will result in a 404. - - - - - 07dc79c3 by Matthew Pickering at 2019-06-08T13:34:18-04:00 gitlab-ci: Linters, don't allow to fail Ben disabled them in cd85f8a71bb56cff332560e1d571b3406789fb71 but didn't say how or why they were broken. - - - - - fd840b64 by Matthew Pickering at 2019-06-08T13:34:18-04:00 gitlab-ci: Don't run two submodule checking jobs on Marge jobs - - - - - 310d0c4c by Matthew Pickering at 2019-06-08T13:34:18-04:00 Fix two lint failures in rts/linker/MachO.c - - - - - fe965316 by Ben Gamari at 2019-06-08T13:34:18-04:00 gitlab-ci: Use --unshallow when fetching for linters GitLab creates a shallow clone. However, this means that we may not have the base commit of an MR when linting, causing `git merge-base` to fail. Fix this by passing `--unshallow` to `git fetch`, ensuring that we have the entire history. - - - - - f58234ea by Ben Gamari at 2019-06-08T13:34:18-04:00 gitlab-ci: Fix submodule linter The job script didn't even try to compute the base commit to lint with respect to. - - - - - c392f987 by Ben Gamari at 2019-06-08T13:34:18-04:00 gitlab-ci: A few clarifying comments - - - - - 709290b0 by Matthew Pickering at 2019-06-08T13:38:15-04:00 Remove trailing whitespace [skip ci] This should really be caught by the linters! (#16711) - - - - - b2f106f5 by Ben Gamari at 2019-06-08T14:02:02-04:00 gitlab-ci: Disable shallow clones Previously we were passing `--unshallow` to `git fetch` in the linting rules to ensure that the base commit which we were linting with respect to was available. However, this breaks due to GitLab's re-use of working directories since `git fetch --unshallow` fails on a repository which is not currently shallow. Given that `git fetch --unshallow` circumvents the efficiencies provided by shallow clones anyways, let's just disable them entirely. There is no documented way to do disable shallow clones but on checking the GitLab implementation it seems that setting `GIT_DEPTH=0` should do the trick. - - - - - 4a72259d by Ben Gamari at 2019-06-08T14:40:55-04:00 gitlab-ci: Fix submodule linting of commits There is no notion of a base commit when we aren't checking a merge request. Just check the HEAD commit. - - - - - 87540029 by Ben Gamari at 2019-06-08T16:44:55-04:00 gitlab-ci: Ensure that all commits on a branch are submodule-linted The previous commit reworked things such that the submodule linter would only run on the head commit. However, the linter only checks the submodules which are touched by the commits it is asked to lint. Consequently it would be possible for a bad submodule to sneak through. Thankfully, we can use the handy CI_COMMIT_BEFORE_SHA attribute to find the base commit of the push. - - - - - 0462b0e0 by Alexandre Baldé at 2019-06-09T11:48:34-04:00 Explain that 'mappend' and '(<>)' should be the same [skip ci] - - - - - 970e4802 by Matthew Pickering at 2019-06-09T11:49:09-04:00 hadrian: Properly partition options in sourceArgs Previously if you build the `ghc` package then it would has the default opts and the library opts. This is different behaviour to make where the library opts are only reserved for things in the `libraries` subdirectory (I believe) Fixes #16716 - - - - - a018c3a8 by Ben Gamari at 2019-06-09T11:49:44-04:00 testsuite: Suppress ticks in T4918 output As noted in #16741, this test otherwise breaks when `base` is compiled with `-g`. - - - - - f7370333 by chessai at 2019-06-09T18:41:02-04:00 Introduce log1p and expm1 primops Previously log and exp were primitives yet log1p and expm1 were FFI calls. Fix this non-uniformity. - - - - - 41bf4045 by Ben Gamari at 2019-06-09T18:41:38-04:00 testsuite: Add test for #16514 - - - - - b9fe91fc by Simon Jakobi at 2019-06-09T18:42:21-04:00 Small refactorings in ExtractDocs - - - - - 9d238791 by Kevin Buhr at 2019-06-09T18:42:57-04:00 Handle trailing path separator in package DB names (#16360) Package DB directories with trailing separator (provided via GHC_PACKAGE_PATH or via -package-db) resulted in incorrect calculation of ${pkgroot} substitution variable. Keep the trailing separator while resolving as directory or file, but remove it before dropping the last path component with takeDirectory. Closes #16360. - - - - - a22e51ea by Richard Eisenberg at 2019-06-09T18:43:38-04:00 Fix #16517 by bumping the TcLevel for method sigs There were actually two bugs fixed here: 1. candidateQTyVarsOfType needs to be careful that it does not try to zap metavariables from an outer scope as "naughty" quantification candidates. This commit adds a simple check to avoid doing so. 2. We weren't bumping the TcLevel in kcHsKindSig, which was used only for class method sigs. This mistake led to the acceptance of class C a where meth :: forall k. Proxy (a :: k) -> () Note that k is *locally* quantified. This patch fixes the problem by using tcClassSigType, which correctly bumps the level. It's a bit inefficient because tcClassSigType does other work, too, but it would be tedious to repeat much of the code there with only a few changes. This version works well and is simple. And, while updating comments, etc., I noticed that tcRnType was missing a pushTcLevel, leading to #16767, which this patch also fixes, by bumping the level. In the refactoring here, I also use solveEqualities. This initially failed ghci/scripts/T15415, but that was fixed by teaching solveEqualities to respect -XPartialTypeSignatures. This patch also cleans up some Notes around error generation that came up in conversation. Test case: typecheck/should_fail/T16517, ghci/scripts/T16767 - - - - - 10452959 by Roland Senn at 2019-06-09T18:44:18-04:00 Add disable/enable commands to ghci debugger #2215 This patch adds two new commands `:enable` and `:disable` to the GHCi debugger. Opposite to `:set stop <n> :continue` a breakpoint disabled with `:disable` will not loose its previously set stop command. A new field breakEnabled is added to the BreakLocation data structure to track the enable/disable state. When a breakpoint is disabled with a `:disable` command, the following happens: The corresponding BreakLocation data element is searched dictionary of the `breaks` field of the GHCiStateMonad. If the break point is found and not already in the disabled state, the breakpoint is removed from bytecode. The BreakLocation data structure is kept in the breaks list and the new breakEnabled field is set to false. The `:enable` command works similar. The breaks field in the GHCiStateMonad was changed from an association list to int `IntMap`. - - - - - 13572480 by Ben Gamari at 2019-06-09T18:44:54-04:00 rts: Separate population of eventTypes from initial event generation Previously these two orthogonal concerns were both implemented in postHeaderEvents which made it difficult to send header events after RTS initialization. - - - - - ed20412a by nineonine at 2019-06-09T18:45:31-04:00 Do not report error if Name in pragma is unbound - - - - - 8a48a8a4 by Ben Gamari at 2019-06-09T18:46:08-04:00 testsuite: Add test for #16509 - - - - - 69c58f8a by David Eichmann at 2019-06-09T18:46:46-04:00 Hadrian: need CPP preprocessor dependencies #16660 Use the new -include-cpp-deps ghc option (#16521) when generating .dependencies files in hadrian. This is version gated as -include-cpp-deps is a relatively new option. - - - - - 1c7bb03d by Richard Eisenberg at 2019-06-09T18:47:24-04:00 Comments only: document tcdDataCusk better. - - - - - 5023adce by John Ericson at 2019-06-09T18:47:59-04:00 Remove CPP ensuring word size is 32 or 64 bits around Addr# <-> int# primops It shouldn't be needed these days, and those primops are "highly deprecated" anyways. This fits with my plans because it removes one bit of target-dependence of the builtin primops, and this is the hardest part of GHC to make multi-target. CC @carter - - - - - 8e60e3f0 by Daniel Gröber at 2019-06-09T18:48:38-04:00 rts: Fix RetainerProfile early return with TREC_CHUNK When pop() returns with `*c == NULL` retainerProfile will immediately return. All other code paths is pop() continue with the next stackElement when this happens so it seems weird to me that TREC_CHUNK we would suddenly abort everything even though the stack might still have elements left to process. - - - - - 1a3420ca by Ben Gamari at 2019-06-10T07:59:41-04:00 base: Mark CPUTime001 as fragile As noted in #16224, CPUTime001 has been quite problematic, reporting non-monotonic timestamps in CI. Unfortunately I've been unable to reproduce this locally. - - - - - 9bc10993 by Vladislav Zavialov at 2019-06-10T08:00:16-04:00 Print role annotations in TemplateHaskell brackets (#16718) - - - - - 0345b1b0 by Richard Eisenberg at 2019-06-10T23:52:10-04:00 Comments only: document newtypes' DataConWrapId - - - - - 58a5d728 by David Eichmann at 2019-06-10T23:52:50-04:00 Refactor the rules for .hi and .o into a single rule using `&%>` #16764 Currently the rule for .hi files just triggers (via need) the rule for the .o file, and .o rule generates both the .o and .hi file. Likewise for .o-boot and .hi-boot files. This is a bit of an abuse of Shake, and in fact shake supports rules with multiple output with the &%> function. This exact use case appears in Neil Mitchell's paper *Shake Before Building* section 6.3. - - - - - 2f945086 by Ben Gamari at 2019-06-10T23:53:25-04:00 testsuite: Fix and extend closure_size test This was previously broken in several ways. This is fixed and it also now tests arrays. Unfortunately I was unable to find a way to continue testing PAP and FUN sizes; these simply depend too much upon the behavior of the simplifier. I also tried to extend this to test non-empty arrays as well but unfortunately this was non-trivial as the array card size constant isn't readily available from haskell. Fixes #16531. - - - - - e5d275f4 by Ben Gamari at 2019-06-10T23:53:25-04:00 ghc-heap: Add closure_size_noopt test This adds a new test, only run in the `normal` way, to verify the size of FUNs and PAPs. - - - - - fe7e7e4a by Yuras Shumovich at 2019-06-11T18:39:58-04:00 Warn about unused packages Reviewers: bgamari, simonpj Reviewed By: simonpj Subscribers: hvr, simonpj, mpickering, rwbarton, carter GHC Trac Issues: #15838 Differential Revision: https://phabricator.haskell.org/D5285 - - - - - 39f50bff by Alp Mestanogullari at 2019-06-11T18:40:37-04:00 Refine the GHCI macro into HAVE[_{INTERNAL, EXTERNAL}]_INTERPRETER As discussed in #16331, the GHCI macro, defined through 'ghci' flags in ghc.cabal.in, ghc-bin.cabal.in and ghci.cabal.in, is supposed to indicate whether GHC is built with support for an internal interpreter, that runs in the same process. It is however overloaded in a few places to mean "there is an interpreter available", regardless of whether it's an internal or external interpreter. For the sake of clarity and with the hope of more easily being able to build stage 1 GHCs with external interpreter support, this patch splits the previous GHCI macro into 3 different ones: - HAVE_INTERNAL_INTERPRETER: GHC is built with an internal interpreter - HAVE_EXTERNAL_INTERPRETER: GHC is built with support for external interpreters - HAVE_INTERPRETER: HAVE_INTERNAL_INTERPRETER || HAVE_EXTERNAL_INTERPRETER - - - - - 45616133 by Alec Theriault at 2019-06-11T18:41:14-04:00 Make `haddock_testsuite` respect `--test-accept` Suppose you've made changes that affect the output of `haddockHtmlTest` so that the following is failing: ./hadrian/build.sh -c --only=haddockHtmlTest test Then, the following will accept new output for Haddock's test cases. ./hadrian/build.sh -c --only=haddockHtmlTest test --test-accept You still do need to make sure those new changes (which show up in Haddock's tree) get committed though. Fixes #16694 - - - - - 762098bf by Alp Mestanogullari at 2019-06-11T18:41:52-04:00 rts/RtsFlags.c: mention that -prof too enables support for +RTS -l - - - - - 457fe789 by Alp Mestanogullari at 2019-06-11T18:42:30-04:00 Hadrian: teach the RTS that PROFILING implies TRACING As discussed in #16744, both the Make and Hadrian build systems have special code to always pass -eventlog whenever -prof or -debug are passed. However, there is some similar logic in the RTS itself only for defining TRACING when the DEBUG macro is defined, but no such logic is implemented to define TRACING when the PROFILING macro is defined. This patch adds such a logic and therefore fixes #16744. - - - - - cf7f36ae by Ben Gamari at 2019-06-11T18:43:05-04:00 rts/linker: Mmap into low memory on AArch64 This extends mmapForLinker to use the same low-memory mapping strategy used on x86_64 on AArch64. See #16784. - - - - - 0b7f81f5 by Ben Gamari at 2019-06-11T18:43:05-04:00 rts/linker: Use mmapForLinker to map PLT The PLT needs to be located within a close distance of the code calling it under the small memory model. Fixes #16784. - - - - - 1389b2cc by Ömer Sinan Ağacan at 2019-06-11T18:43:43-04:00 Fix an error message in CheckUnload.c:searchHeapBlocks - - - - - aad6115a by Alp Mestanogullari at 2019-06-11T18:44:20-04:00 testsuite/mk/boilerplate.mk: rename 'ghc-config-mk' to 'ghc_config_mk' Make/shell variable names which contain dashes can cause problems under some conditions. The 'ghc-config-mk' variable from testsuite/mk/boilerplate.mk that I made overridable (by Hadrian) in ba0aed2e was working as expected when our Hadrian/Linux job was based off the deb8 Docker image, but broke when I switched the job to use our deb9-based image, in 3d97bad6. The exact circumstances/tool versions that trigger this problem are unknown, but changing the variable's name to 'ghc_config_mk' lets us work around the issue. This fixes the annth_compunits and annth_make test failures that showed up when we switched the Hadrian/Linux job to use the deb9 environment. - - - - - 9b4ff57d by Ben Gamari at 2019-06-12T07:35:25-04:00 llvm-targets: Add armv7l-unknown-linux-gnueabi Fixes #15208. [skip ci] - - - - - c05ca251 by Ben Gamari at 2019-06-12T07:36:01-04:00 testsuite: Add haddock perf test output to gitignore [skip ci] - - - - - bbc752c5 by Ben Gamari at 2019-06-12T07:36:36-04:00 rts/linker: Make elf_got.c a bit more legible - - - - - 217e6db4 by Ben Gamari at 2019-06-12T07:36:36-04:00 rts/linker: Only mprotect GOT after it is filled This fixes a regression, introduced by 67c422ca, where we mprotect'd the global offset table (GOT) region to PROT_READ before we had finished filling it, resulting in a linker crash. Fixes #16779. - - - - - 1219f8e8 by Krzysztof Gogolewski at 2019-06-12T07:37:12-04:00 Use DeriveFunctor throughout the codebase (#15654) - - - - - bd2d13ff by Ben Gamari at 2019-06-12T08:19:59-04:00 Bump binary to 0.8.7.0 (cherry picked from commit 983ada70a013c7642a751f6e41587ff95b57d0f8) - - - - - 381c3ae3 by Ben Gamari at 2019-06-12T08:19:59-04:00 Bump Cabal submodule (cherry picked from commit ff438786613f07df9b2d43eaeac49b13815d849d) Metric Increase: haddock.Cabal - - - - - 0354c7de by Ben Gamari at 2019-06-12T08:19:59-04:00 Bump time submodule to 1.9.3 (cherry picked from commit fdb07571036b1498800589d45b61781e6acdd368) - - - - - e0b16eaa by Ben Gamari at 2019-06-12T08:19:59-04:00 Bump terminfo to 0.4.1.4 (cherry picked from commit 1134488b4c9cef904ea82f22f1978646eea612df) - - - - - 2ce320b0 by Ben Gamari at 2019-06-12T08:19:59-04:00 gitlab-ci: Test using slowtest in deb9-debug job - - - - - 90e7c450 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Mark hWaitForInput-accurate-stdin as broken in threaded ways As noted in #16535. - - - - - 488187f8 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Mark T13167 as fragile in threaded2 As noted in #16536. - - - - - 9b583320 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Mark T13910 as broken in optasm Due to #16537. - - - - - eb644865 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Mark T14761c as broken in hpc, profasm, and optasm ways As noted in #16540. - - - - - 1a204e07 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Mark T16180 as broken in ghci and ext-interp ways As noted in #16541. - - - - - 8d482e45 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Omit tcrun022 in hpc way As noted in #16542, the expected rule doesn't fire. However, this doesn't seem terribly surpring given the circumstances. - - - - - 68cfdfdb by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Mark Overflow as broken in hpc way As noted in #16543. - - - - - a3929a4f by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Mark T2783 as fragile in threaded1 It was previously marked as broken but it passes non-deterministically. See #2783. - - - - - bb7ed32f by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Skip T7919 in ghci way It times out pretty reliably. It's not clear that much is gained by running this test in the ghci way anyways. - - - - - 329dcd7a by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Fix fragile_for test modifier - - - - - 55b5bb14 by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Fix omit_ways usage omit_ways expects a list but this was broken in several cases. - - - - - 264ad286 by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Mark threadstatus-T9333 as fragile in ghci way As noted in #16555. - - - - - 587bef66 by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Omit profasm way for cc017 cc017 requires TH but we can't load dynamic profiled objects. - - - - - dc5a37fd by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Skip T493 in ghci way. T493 tests #493, which is an FFI test. FFI tests should be skipped in ghci way. - - - - - e3f71d0e by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Mark T16449_2 as broken due to #16742 - - - - - b5a13a1e by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Mark T16737 as broken in ghci way due to #16541 - - - - - b09374a4 by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Note intentional typo in T7130 I earlier accidentally corrected it breaking the test. - - - - - a798c130 by Ben Gamari at 2019-06-12T08:20:25-04:00 linters/check-makefiles: Limit lint to Makefiles Previously we would apply this rule, which is only intended for testsuite Makefiles, to all files. This lead to a number of false-positives in all.T files. - - - - - 0782141e by Ben Gamari at 2019-06-12T08:20:25-04:00 gitlab-ci: Fetch submodules before running submodule linter - - - - - 898f7e92 by Ben Gamari at 2019-06-12T08:20:25-04:00 Fix uses of #ifdef/#ifndef The linter now enforces our preference for `#if defined()` and `#if !defined()`. - - - - - 0a13a04c by Ben Gamari at 2019-06-12T08:20:25-04:00 Bump unix submodule Marks posix002 as fragile in threaded2 way due to #16550. - - - - - a8579e5b by Ben Gamari at 2019-06-12T08:27:25-04:00 process: Bump submodule * Skip process005 in ghci way * Mark process002 as fragile in threaded2 - - - - - 3f1022c5 by Ben Gamari at 2019-06-12T08:27:25-04:00 testsuite: Skip cgrun078 in ghci way This test requires FFI usage. - - - - - 1cbfef47 by Ben Gamari at 2019-06-12T08:27:25-04:00 testsuite: Unbreak galois_raytrace on i386 galois_raytrace was previously broken on i386 due to use of x87 arithmethic on that platform. However, 42504f4a575395a35eec5c3fd7c9ef6e2b54e68e removes x87 support; this resulted in an unexpected pass. Unmark this test as broken. - - - - - 20160f1a by Ben Gamari at 2019-06-12T08:27:25-04:00 testsuite: Don't run tests requiring TH in profasm way when GhcDynamic Since we can't load profiled objects when GhcDynamic==YES. Affects: * T16737 * T16384 * T16718 * T16619 * T16190 - - - - - 7b751ed8 by Ben Gamari at 2019-06-12T17:52:35-04:00 gitlab-ci: Bump Docker image Fixes linters. - - - - - 5ffc266e by Ben Gamari at 2019-06-13T02:48:13-04:00 Add a few missing llvm-targets This should finally fix #14261. [skip ci] - - - - - fc6b23be by Phuong Trinh at 2019-06-13T02:48:50-04:00 Fix #16525: ObjectCode freed wrongly because of lack of info header check `checkUnload` currently doesn't check the info header of static objects. Thus, it may free an `ObjectCode` struct wrongly even if there's still a live static object whose info header lies in a mapped section of that `ObjectCode`. This fixes the issue by adding an appropriate check. - - - - - a657543c by Ben Gamari at 2019-06-13T02:49:25-04:00 PrelRules: Ensure that string unpack/append rule fires with source notes Previously the presence of source notes could hide nested applications of `unpackFoldrCString#` from our constant folding logic. For instance, consider the expression: ```haskell unpackFoldrCString# "foo" c (unpackFoldrCString# "baz" c n) ``` Specifically, ticks appearing in two places can defeat the rule: a. Surrounding the inner application of `unpackFoldrCString#` b. Surrounding the fold function, `c` The latter caused the `str_rules` testcase to fail when `base` was built with `-g3`. Fixes #16740. - - - - - e98d32a6 by David Eichmann at 2019-06-13T02:50:00-04:00 Hadrian: Track RTS library symlink targets This requires creating RTS library symlinks when registering, outside of the rule for the registered library file. - - - - - 35113117 by Alp Mestanogullari at 2019-06-13T02:50:37-04:00 Hadrian: Do not allow the Linux jobs to fail anymore MR !1151 makes the Hadrian/Linux job pass by fixing the last two test failures, so we can now be stricter and not allow those jobs to fail anymore, easily letting us see when patches introduce test failures. - - - - - 70b5eefe by Ben Gamari at 2019-06-13T02:51:13-04:00 users-guide: Fix a few markup issues Strangely these were only causing the build to fail in the aarch64-linux job, despite Sphinx throwing errors in all jobs I checked. Also changes some `#ifdef`s to `#if defined` to satisfy the linter. - - - - - 9721b40d by Ben Gamari at 2019-06-13T02:51:13-04:00 gitlab-ci: Don't build PDF user's guide on AArch64 For reasons I don't understand sphinx seems to fail to produce a .idx file for makeindex. - - - - - d550b771 by Ben Gamari at 2019-06-13T02:51:50-04:00 Clean up .circleci Move prepare-system.sh to .gitlab and remove everything else. - - - - - c53dfb3b by Ben Gamari at 2019-06-13T11:52:47-04:00 testsuite: A more portable solution to #9399 Previously we used an awful hybrid batch script/Bourne shell script to allow this test to run both on Windows and Linux (fixing #9399). However, this breaks on some libc implementations (e.g. musl). Fix this. Fixes #16798. - - - - - 74b5d049 by Ben Gamari at 2019-06-13T11:53:22-04:00 gitlab-ci: Disable deb9-llvm job, introduce nightly LLVM job This should help alleviate queue times as the LLVM job is one of the longest that we have. - - - - - 5ce63d52 by Ben Gamari at 2019-06-13T11:53:22-04:00 gitlab-ci: Disable validate-x86_64-linux-deb9 job to reduce load Enable artifacts on to ensure we have bindist coverage. - - - - - 7bc5d6c6 by Ben Gamari at 2019-06-13T23:34:41-04:00 Maintain separate flags for C++ compiler invocations Previously we would pass flags intended for the C compiler to the C++ compiler (see #16738). This would cause, for instance, `-std=gnu99` to be passed to the C++ compiler, causing spurious test failures. Fix this by maintaining a separate set of flags for C++ compilation invocations. - - - - - 71e75ba6 by Ömer Sinan Ağacan at 2019-06-13T23:35:19-04:00 Remove unused Unique field from StgFCallOp Fixes #16696 - - - - - ec25fe59 by Alp Mestanogullari at 2019-06-13T23:35:56-04:00 Hadrian: remove superfluous dependencies in Rules.Compile Each package's object files were 'need'ing the library files of all transitive dependencies of the current package, whichi is pointless since the said libraries are not needed until we link those object files together. This fixes #16759. - - - - - 3bc6df32 by Andreas Klebinger at 2019-06-13T23:36:34-04:00 Add Outputable instances for Float, Double. - - - - - effdd948 by Andrew Martin at 2019-06-14T10:48:13-04:00 Implement the -XUnliftedNewtypes extension. GHC Proposal: 0013-unlifted-newtypes.rst Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/98 Issues: #15219, #1311, #13595, #15883 Implementation Details: Note [Implementation of UnliftedNewtypes] Note [Unifying data family kinds] Note [Compulsory newtype unfolding] This patch introduces the -XUnliftedNewtypes extension. When this extension is enabled, GHC drops the restriction that the field in a newtype must be of kind (TYPE 'LiftedRep). This allows types like Int# and ByteArray# to be used in a newtype. Additionally, coerce is made levity-polymorphic so that it can be used with newtypes over unlifted types. The bulk of the changes are in TcTyClsDecls.hs. With -XUnliftedNewtypes, getInitialKind is more liberal, introducing a unification variable to return the kind (TYPE r0) rather than just returning (TYPE 'LiftedRep). When kind-checking a data constructor with kcConDecl, we attempt to unify the kind of a newtype with the kind of its field's type. When typechecking a data declaration with tcTyClDecl, we again perform a unification. See the implementation note for more on this. Co-authored-by: Richard Eisenberg <rae at richarde.dev> - - - - - 5279dda8 by Ben Gamari at 2019-06-14T10:48:51-04:00 PrelRules: Don't break let/app invariant in shiftRule Previously shiftRule would rewrite as invalid shift like ``` let x = I# (uncheckedIShiftL# n 80) in ... ``` to ``` let x = I# (error "invalid shift") in ... ``` However, this breaks the let/app invariant as `error` is not okay-for-speculation. There isn't an easy way to avoid this so let's not try. Instead we just take advantage of the undefined nature of invalid shifts and return zero. Fixes #16742. - - - - - 503e830c by Ben Gamari at 2019-06-14T23:10:08-04:00 gitlab-ci: Lint testsuite for framework failures This introduces a new lint job checking for framework failures and listing broken tests. - - - - - b5ea9323 by Ben Gamari at 2019-06-14T23:10:08-04:00 lint: Only apply --interactive lint to testsuite .T files - - - - - 5c97211c by Ben Gamari at 2019-06-14T23:10:08-04:00 gitlab-ci: Lint the linters - - - - - 257165b4 by Alp Mestanogullari at 2019-06-14T23:10:46-04:00 Remove duplicates from 'ghc --info' output - - - - - 5da6c86f by Ben Gamari at 2019-06-15T15:14:01-04:00 Bump unix submodule Skips `executeFile001` test in `threaded2` way. Fixes #16814. - - - - - 20b4d5ec by Ben Gamari at 2019-06-15T23:32:38-04:00 Disable optimisation when building Cabal lib for stage0 This disables optimisation when building Cabal for Hadrian and stage0 `ghc-cabal`. Cabal is performance critical in neither case nor will any performance difference here be visible to the end-user. See #16817. - - - - - 76b7f619 by Ben Gamari at 2019-06-15T23:32:38-04:00 Disable optimisation when building Cabal in development flavours This updates the make and Hadrian build flavours targetting developers to disable optimisation when building the Cabal library. Cabal tends to tickle some very bad compiler performance cases (e.g. #16577) so disabling optimisation here makes a sizeable impact on overall build time. See #16817. - - - - - 0d2a4258 by Ben Gamari at 2019-06-15T23:33:13-04:00 testsuite: Introduce concurrent_ways set Previously we just tested for the threaded2 when determining whether to skip tests which are fragile under concurrent execution. However, this isn't the only way which is concurrent. - - - - - beacb6fd by Ben Gamari at 2019-06-15T23:33:13-04:00 testsuite: Skip hDuplicateTo001 in concurrent ways As noted in #16819, this operation is racy under concurrent execution. - - - - - ca721193 by Aiken Cairncross at 2019-06-15T23:33:50-04:00 Fix typo in error message - - - - - 57b71848 by Ben Gamari at 2019-06-15T23:34:25-04:00 testsuite: Add assertions that way lists are in fact lists Previously there were a few cases where operations like `omit_ways` were incorrectly passed a single way (e.g. `omit_ways('threaded2')`). This won't work as the author expected. - - - - - 25ee60cd by Ryan Scott at 2019-06-15T23:35:03-04:00 Synchronize ClsInst.doTyConApp with TcTypeable validity checks (#15862) Issue #15862 demonstrated examples of type constructors on which `TcTypeable.tyConIsTypeable` would return `False`, but the `Typeable` constraint solver in `ClsInst` (in particular, `doTyConApp`) would try to generate `Typeable` evidence for anyway, resulting in disaster. This incongruity was caused by the fact that `doTyConApp` was using a weaker validity check than `tyConIsTypeable` to determine if a type constructor warrants `Typeable` evidence or not. The solution, perhaps unsurprisingly, is to use `tyConIsTypeable` in `doTyConApp` instead. To avoid import cycles between `ClsInst` and `TcTypeable`, I factored out `tyConIsTypeable` into its own module, `TcTypeableValidity`. Fixes #15862. - - - - - 4138bf86 by Krzysztof Gogolewski at 2019-06-15T23:35:38-04:00 Remove dead code - - - - - db313f98 by Ben Gamari at 2019-06-16T06:26:38-04:00 base/Event/Poll: Drop POLLRDHUP enum item Previously the Event enumeration produced by hsc2hs would sometimes include a currently-unused POLLRDHUP item. This unused binding would result in a build failure. Drop it. - - - - - 81608e82 by Ben Gamari at 2019-06-16T06:26:38-04:00 testsuite: Fix T8602 on musl Musl wants hash-bangs on all executables. - - - - - a0f68379 by Ben Gamari at 2019-06-16T06:26:38-04:00 testsuite: Ensure T5423 flushes C output buffer Previously T5423 would fail to flush the printf output buffer. Consequently it was platform-dependent whether the C or Haskell print output would be emitted first. - - - - - 543dfaab by Ben Gamari at 2019-06-16T06:26:38-04:00 testsuite: Flush conc059's printf buffer Otherwise it the order out the Haskell and C output will be system-dependent. - - - - - e647752e by Ben Gamari at 2019-06-16T06:26:38-04:00 testsuite: Ensure that ffi005 output order is predictable The libc output buffer wasn't being flushed, making the order system-depedent. - - - - - 338336d3 by Ben Gamari at 2019-06-16T06:26:38-04:00 gitlab-ci: Build alpine release bindists - - - - - 75c6ccf7 by Alp Mestanogullari at 2019-06-16T06:27:17-04:00 fix runghc's GHC detection logic to cover the "in-tree Hadrian build" scenario Before this patch, runghc would only run the GHC detection logic on Windows and assume that it was invoked through a wrapper script on all other platforms. This patch lifts this limitation and makes that logic work for the scenario where someone is calling the runghc executable directly, without passing an explicit path to GHC. - - - - - 3c35e140 by Ben Gamari at 2019-06-16T19:38:51-04:00 testsuite: Really fix #16741 The previous fix, !1095, didn't work as `--show-iface` ignores `-dsuppress-ticks`. Rework the test instead. - - - - - b3bb1b06 by Ben Gamari at 2019-06-16T19:38:51-04:00 gitlab-ci: Don't allow failure of deb9-dwarf job This #16741 out of the way this should now pass. - - - - - b965de1e by Ömer Sinan Ağacan at 2019-06-16T19:39:29-04:00 Use TupleSections in CmmParse.y, simplify a few exprs - - - - - 63965ae3 by Ben Gamari at 2019-06-17T01:20:21-04:00 make: Clean includes/settings file Now since this is generated by the build system we should ensure that it is properly cleaned. [skip ci] - - - - - bb141114 by Siddharth Bhat at 2019-06-17T01:20:57-04:00 Add link to mfix.github.io/ghc in HACKING.md - - - - - 24afbfe9 by Ben Gamari at 2019-06-17T10:20:32-04:00 gitlab-ci: Run nofib on binary distributions Updates docker images to ensure that the `time` utility is available. - - - - - 62f0213d by Fumiaki Kinoshita at 2019-06-18T16:00:20-04:00 Data.Ord: give a field name getDown to Down - - - - - da33f2bb by Fumiaki Kinoshita at 2019-06-18T16:00:20-04:00 Add more newtype-derived instances to Data.Ord.Down Metric Increase: haddock.base - - - - - dbf9ca20 by Ben Gamari at 2019-06-18T16:00:56-04:00 testsuite: Add testcase for #16689 - - - - - 29ec33cd by Ben Gamari at 2019-06-18T16:00:56-04:00 SafeHaskell: Don't throw -Wsafe warning if module is declared Safe Fixes #16689. - - - - - a491e40c by Ben Gamari at 2019-06-18T16:01:31-04:00 hadrian: Compile UserSettings with -O0 This guarantees that the interface file for `UserSettings` doesn't contain any unfoldings, ensuring that a change in it requires minimal rebuilds. - - - - - 74bd6b22 by Ben Gamari at 2019-06-18T16:02:07-04:00 testsuite: Add test for #16832 - - - - - 6a92f59d by Ben Gamari at 2019-06-18T16:02:42-04:00 gitlab-ci: Run alpine builds during nightly job - - - - - 4549cadf by Andreas Klebinger at 2019-06-18T16:03:19-04:00 Make sure mkSplitUniqSupply stores the precomputed mask only. mkSplitUniqSupply was lazy on the boxed char. This caused a bunch of issues: * The closure captured the boxed Char * The mask was recomputed on every split of the supply. * It also caused the allocation of MkSplitSupply to happen in it's own (allocated) closure. The reason of which I did not further investigate. We know force the computation of the mask inside mkSplitUniqSupply. * This way the mask is computed at most once per UniqSupply creation. * It allows ww to kick in, causing the closure to retain the unboxed value. Requesting Uniques in a loop is now faster by about 20%. I did not check the impact on the overall compiler, but I added a test to avoid regressions. - - - - - 8584430e by Ömer Sinan Ağacan at 2019-06-19T15:00:11+03:00 Fix a Note name in CmmNode ("Continuation BlockIds" is referenced in CmmProcPoint) [skip ci] - - - - - 9d58554f by Ömer Sinan Ağacan at 2019-06-19T22:14:26-04:00 Properly trim IdInfos of DFunIds and PatSyns in TidyPgm Not doing this right caused #16608. We now properly trim IdInfos of DFunIds and PatSyns. Some further refactoring done by SPJ. Two regression tests T16608_1 and T16608_2 added. Fixes #16608 - - - - - 39c758e1 by Roland Senn at 2019-06-19T22:15:04-04:00 Fix #1620: ModBreaks.modBreaks_array not initialised After a :cd command and after setting some package flags, GHCi unloads all loaded modules by resetting the list of targets. This patch deletes eventually defined debugger breakpoints, before GHCi resets the target list. The common code is factored out into the new function clearAllTargets. - - - - - 3c9b57b0 by Simon Peyton Jones at 2019-06-19T22:15:39-04:00 Fix two places that failed the substitution invariant The substition invariant relies on keeping the in-scope set in sync, and we weren't always doing so, which means that a DEBUG compiler crashes sometimes with an assertion failure This patch fixes a couple more cases. Still not validate clean (with -DEEBUG) but closer! - - - - - 48fb3482 by Simon Peyton Jones at 2019-06-19T22:15:39-04:00 Fix typechecking of partial type signatures Partial type sigs had grown hair. tcHsParialSigType was doing lots of unnecessary work, and tcInstSig was cloning it unnecessarily -- and the result didn't even work: #16728. This patch cleans it all up, described by TcHsType Note [Checking parital type signatures] I basically just deleted code... but very carefully! Some refactoring along the way * Distinguish more explicintly between "anonymous" wildcards "_" and "named" wildcards "_a". I changed the names of a number of functions to make this distinction much more apparent. The patch also revealed that the code in `TcExpr` that implements the special typing rule for `($)` was wrong. It called `getRuntimeRep` in a situation where where was no particular reason to suppose that the thing had kind `TYPE r`. This caused a crash in typecheck/should_run/T10846. The fix was easy, and actually simplifies the code in `TcExpr` quite a bit. Hooray. - - - - - 3ae23992 by Simon Peyton Jones at 2019-06-19T22:15:39-04:00 Comments and tiny refactor * Added Note [Quantified varaibles in partial type signatures] in TcRnTypes * Kill dVarSetElemsWellScoped; it was only called in one function, quantifyTyVars. I inlined it because it was only scopedSort . dVarSetElems * Kill Type.tyCoVarsOfBindersWellScoped, never called. - - - - - bff2f24b by John Ericson at 2019-06-19T22:16:16-04:00 Move 'Platform' to ghc-boot ghc-pkg needs to be aware of platforms so it can figure out which subdire within the user package db to use. This is admittedly roundabout, but maybe Cabal could use the same notion of a platform as GHC to good affect too. - - - - - a298b96e by John Ericson at 2019-06-19T22:16:16-04:00 Add 'stringEncodeArch' and 'stringEncodeOS' to GHC.Platform - - - - - d406a16a by John Ericson at 2019-06-19T22:16:16-04:00 ghc-pkg needs settings file to un-hardcode target platform This matches GHC itself getting the target platform from there. - - - - - aa4891a7 by Ben Gamari at 2019-06-19T22:16:51-04:00 users-guide: Fix a variety of broken links and syntax - - - - - fe819dd6 by Ben Gamari at 2019-06-19T22:16:51-04:00 users-guide: Update -Wsafe description for #16689 We no longer emit a warning when a safe module is explicitly declared as such. - - - - - c311277b by Matthías Páll Gissurarson at 2019-06-21T03:21:21+02:00 Add HoleFitPlugins and RawHoleFits This patch adds a new kind of plugin, Hole fit plugins. These plugins can change what candidates are considered when looking for valid hole fits, and add hole fits of their own. The type of a plugin is relatively simple, ``` type FitPlugin = TypedHole -> [HoleFit] -> TcM [HoleFit] type CandPlugin = TypedHole -> [HoleFitCandidate] -> TcM [HoleFitCandidate] data HoleFitPlugin = HoleFitPlugin { candPlugin :: CandPlugin , fitPlugin :: FitPlugin } data TypedHole = TyH { tyHRelevantCts :: Cts -- ^ Any relevant Cts to the hole , tyHImplics :: [Implication] -- ^ The nested implications of the hole with the -- innermost implication first. , tyHCt :: Maybe Ct -- ^ The hole constraint itself, if available. } This allows users and plugin writers to interact with the candidates and fits as they wish, even going as far as to allow them to reimplement the current functionality (since `TypedHole` contains all the relevant information). As an example, consider the following plugin: ``` module HolePlugin where import GhcPlugins import TcHoleErrors import Data.List (intersect, stripPrefix) import RdrName (importSpecModule) import TcRnTypes import System.Process plugin :: Plugin plugin = defaultPlugin { holeFitPlugin = hfp, pluginRecompile = purePlugin } hfp :: [CommandLineOption] -> Maybe HoleFitPluginR hfp opts = Just (fromPureHFPlugin $ HoleFitPlugin (candP opts) (fp opts)) toFilter :: Maybe String -> Maybe String toFilter = flip (>>=) (stripPrefix "_module_") replace :: Eq a => a -> a -> [a] -> [a] replace match repl str = replace' [] str where replace' sofar (x:xs) | x == match = replace' (repl:sofar) xs replace' sofar (x:xs) = replace' (x:sofar) xs replace' sofar [] = reverse sofar -- | This candidate plugin filters the candidates by module, -- using the name of the hole as module to search in candP :: [CommandLineOption] -> CandPlugin candP _ hole cands = do let he = case tyHCt hole of Just (CHoleCan _ h) -> Just (occNameString $ holeOcc h) _ -> Nothing case toFilter he of Just undscModName -> do let replaced = replace '_' '.' undscModName let res = filter (greNotInOpts [replaced]) cands return $ res _ -> return cands where greNotInOpts opts (GreHFCand gre) = not $ null $ intersect (inScopeVia gre) opts greNotInOpts _ _ = True inScopeVia = map (moduleNameString . importSpecModule) . gre_imp -- Yes, it's pretty hacky, but it is just an example :) searchHoogle :: String -> IO [String] searchHoogle ty = lines <$> (readProcess "hoogle" [(show ty)] []) fp :: [CommandLineOption] -> FitPlugin fp ("hoogle":[]) hole hfs = do dflags <- getDynFlags let tyString = showSDoc dflags . ppr . ctPred <$> tyHCt hole res <- case tyString of Just ty -> liftIO $ searchHoogle ty _ -> return [] return $ (take 2 $ map (RawHoleFit . text . ("Hoogle says: " ++)) res) ++ hfs fp _ _ hfs = return hfs ``` with this plugin available, you can compile the following file ``` {-# OPTIONS -fplugin=HolePlugin -fplugin-opt=HolePlugin:hoogle #-} module Main where import Prelude hiding (head, last) import Data.List (head, last) t :: [Int] -> Int t = _module_Prelude g :: [Int] -> Int g = _module_Data_List main :: IO () main = print $ t [1,2,3] ``` and get the following output: ``` Main.hs:14:5: error: • Found hole: _module_Prelude :: [Int] -> Int Or perhaps ‘_module_Prelude’ is mis-spelled, or not in scope • In the expression: _module_Prelude In an equation for ‘t’: t = _module_Prelude • Relevant bindings include t :: [Int] -> Int (bound at Main.hs:14:1) Valid hole fits include Hoogle says: GHC.List length :: [a] -> Int Hoogle says: GHC.OldList length :: [a] -> Int t :: [Int] -> Int (bound at Main.hs:14:1) g :: [Int] -> Int (bound at Main.hs:17:1) length :: forall (t :: * -> *) a. Foldable t => t a -> Int with length @[] @Int (imported from ‘Prelude’ at Main.hs:5:1-34 (and originally defined in ‘Data.Foldable’)) maximum :: forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a with maximum @[] @Int (imported from ‘Prelude’ at Main.hs:5:1-34 (and originally defined in ‘Data.Foldable’)) (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits) | 14 | t = _module_Prelude | ^^^^^^^^^^^^^^^ Main.hs:17:5: error: • Found hole: _module_Data_List :: [Int] -> Int Or perhaps ‘_module_Data_List’ is mis-spelled, or not in scope • In the expression: _module_Data_List In an equation for ‘g’: g = _module_Data_List • Relevant bindings include g :: [Int] -> Int (bound at Main.hs:17:1) Valid hole fits include Hoogle says: GHC.List length :: [a] -> Int Hoogle says: GHC.OldList length :: [a] -> Int g :: [Int] -> Int (bound at Main.hs:17:1) head :: forall a. [a] -> a with head @Int (imported from ‘Data.List’ at Main.hs:7:19-22 (and originally defined in ‘GHC.List’)) last :: forall a. [a] -> a with last @Int (imported from ‘Data.List’ at Main.hs:7:25-28 (and originally defined in ‘GHC.List’)) | 17 | g = _module_Data_List ``` This relatively simple plugin has two functions, as an example of what is possible to do with hole fit plugins. The candidate plugin starts by filtering the candidates considered by module, indicated by the name of the hole (`_module_Data_List`). The second function is in the fit plugin, where the plugin invokes a local hoogle instance to search by the type of the hole. By adding the `RawHoleFit` type, we can also allow these completely free suggestions, used in the plugin above to display fits found by Hoogle. Additionally, the `HoleFitPluginR` wrapper can be used for plugins to maintain state between invocations, which can be used to speed up invocation of plugins that have expensive initialization. ``` -- | HoleFitPluginR adds a TcRef to hole fit plugins so that plugins can -- track internal state. Note the existential quantification, ensuring that -- the state cannot be modified from outside the plugin. data HoleFitPluginR = forall s. HoleFitPluginR { hfPluginInit :: TcM (TcRef s) -- ^ Initializes the TcRef to be passed to the plugin , hfPluginRun :: TcRef s -> HoleFitPlugin -- ^ The function defining the plugin itself , hfPluginStop :: TcRef s -> TcM () -- ^ Cleanup of state, guaranteed to be called even on error } ``` Of course, the syntax here is up for debate, but hole fit plugins allow us to experiment relatively easily with ways to interact with typed-holes without having to dig deep into GHC. Reviewers: bgamari Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5373 - - - - - 2485c08a by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Skip dynamicToo006 when dynamic linking is not available This was previously failling on Windows. - - - - - aa516431 by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Mark T3372 as fragile on Windows On Windows we must lock package databases even when opening for read-only access. This means that concurrent GHC sessions are very likely to fail with file lock contention. See #16773. - - - - - 2eedb120 by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Add stderr output for UnsafeInfered02 on Windows This test uses TemplateHaskell causing GHC to build dynamic objects on platforms where dynamic linking is available. However, Windows doesn't support dynamic linking. Consequently the test would fail on Windows with: ```patch --- safeHaskell/safeInfered/UnsafeInfered02.run/UnsafeInfered02.stderr.normalised 2019-06-04 15:10:10.521594200 +0000 +++ safeHaskell/safeInfered/UnsafeInfered02.run/UnsafeInfered02.comp.stderr.normalised 2019-06-04 15:10:10.523546200 +0000 @@ -1,5 +1,5 @@ -[1 of 2] Compiling UnsafeInfered02_A ( UnsafeInfered02_A.hs, UnsafeInfered02_A.o, UnsafeInfered02_A.dyn_o ) -[2 of 2] Compiling UnsafeInfered02 ( UnsafeInfered02.hs, UnsafeInfered02.o, UnsafeInfered02.dyn_o ) +[1 of 2] Compiling UnsafeInfered02_A ( UnsafeInfered02_A.hs, UnsafeInfered02_A.o ) +[2 of 2] Compiling UnsafeInfered02 ( UnsafeInfered02.hs, UnsafeInfered02.o ) UnsafeInfered02.hs:4:1: UnsafeInfered02_A: Can't be safely imported! ``` The other approach I considered for this issue is to pass `-v0` to GHC. However, I felt we should probably do this consistently for all of the tests in this directory and this would take more time than I currently have. - - - - - 3967d13a by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Mark OldModLocation as broken on Windows Strangely the path it emits contains duplicate path delimiters (#16772), ```patch --- ghc-api/downsweep/OldModLocation.run/OldModLocation.stderr.normalised 2019-06-04 14:40:26.326075000 +0000 +++ ghc-api/downsweep/OldModLocation.run/OldModLocation.run.stderr.normalised 2019-06-04 14:40:26.328029200 +0000 @@ -1 +1 @@ -[Just "A.hs",Just "mydir/B.hs"] +[Just "A.hs",Just "mydir//B.hs"] ``` - - - - - 31f2ea68 by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Mark T7170 as broken on Windows Due to #16801. - - - - - 7bd1c3e1 by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Mark T7702 as broken on Windows Due to #16799. - - - - - 84900724 by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Mark T15633a and T15633b as fragile on Windows As noted in #16813, these tests seem to be fragile on Windows. - - - - - 49fff41d by Ben Gamari at 2019-06-21T13:32:34-04:00 linker: Disable code unloading As noted in #16841, there are currently a variety of bugs in the unloading logic. These only affect Windows since code unloading is disabled on Linux, where we build with `GhcDynamic=YES` by default. In the interest of getting the tree green on Windows disable code unloading until the issues are resolved. - - - - - e0595d22 by Ben Gamari at 2019-06-22T09:36:53-04:00 testsuite: Mark T16608_* as fragile on Darwin As noted in #16855. - - - - - 655c6e26 by Ben Gamari at 2019-06-22T10:06:05-04:00 ghci: Don't rely on resolution of System.IO to base module Previously we would hackily evaluate a textual code snippet to compute actions to disable I/O buffering and flush the stdout/stderr handles. This broke in a number of ways (#15336, #16563). Instead we now ship a module (`GHC.GHCi.Helpers`) with `base` containing the needed actions. We can then easily refer to these via `Orig` names. - - - - - 8f8fc31b by Ben Gamari at 2019-06-22T10:06:05-04:00 testsuite: Add test for #16563 - - - - - 22e721c1 by Ben Gamari at 2019-06-22T10:06:05-04:00 testsuite: Mark T5611 as broken in ghci way As described in #16845. - - - - - b0d6bf2a by Ben Gamari at 2019-06-22T10:06:05-04:00 rts: Reset STATIC_LINK field of reverted CAFs When we revert a CAF we must reset the STATIC_LINK field lest the GC might ignore the CAF (e.g. as it carries the STATIC_FLAG_LIST flag) and will consequently overlook references to object code that we are trying to unload. This would result in the reachable object code being unloaded. See Note [CAF lists] and Note [STATIC_LINK fields]. This fixes #16842. Idea-due-to: Phuong Trinh <lolotp at fb.com> - - - - - 1f2fff89 by Ben Gamari at 2019-06-22T10:06:05-04:00 testsuite: Add caf_crash testcase - - - - - ade3db53 by Ben Gamari at 2019-06-23T17:19:48-04:00 testsuite: Test for #13786 - - - - - 5a502cd1 by Ben Gamari at 2019-06-23T17:19:48-04:00 ghci: Load static objects in batches Previously in the case where GHC was dynamically linked we would load static objects one-by-one by linking each into its own shared object and dlopen'ing each in order. However, this meant that the link would fail in the event that the objects had cyclic symbol dependencies. Here we fix this by merging each "run" of static objects into a single shared object and loading this. Fixes #13786 for the case where GHC is dynamically linked. - - - - - 9bbcc3be by Ryan Scott at 2019-06-23T17:20:41-04:00 Refactor UnliftedNewtypes-relation kind signature validity checks This fixes three infelicities related to the programs that are (and aren't) accepted with `UnliftedNewtypes`: * Enabling `UnliftedNewtypes` would permit newtypes to have return kind `Id Type`, which had disastrous results (i.e., GHC panics). * Data family declarations ending in kind `TYPE r` (for some `r`) weren't being accepted if `UnliftedNewtypes` wasn't enabled, despite the GHC proposal specifying otherwise. * GHC wasn't warning about programs that _would_ typecheck if `UnliftedNewtypes` were enabled in certain common cases. As part of fixing these issues, I factored out the logic for checking all of the various properties about data type/data family return kinds into a single `checkDataKindSig` function. I also cleaned up some of the formatting in the existing error message that gets thrown. Fixes #16821, fixes #16827, and fixes #16829. - - - - - 71aca77c by Erik de Castro Lopo at 2019-06-24T01:11:46-04:00 Fixes for LLVM 7 LLVM version numberinf changed recently. Previously, releases were numbered 4.0, 5.0 and 6.0 but with version 7, they dropped the redundant ".0". Fix requires for Llvm detection and some code. - - - - - 581cbc28 by Erik de Castro Lopo at 2019-06-24T01:12:22-04:00 Add MonadFail instance for ParserM - - - - - 15b26223 by Andrey Mokhov at 2019-06-25T01:36:10-04:00 Fix cyclic dependencies when using --configure This resolves #16809 (https://gitlab.haskell.org/ghc/ghc/issues/16809). This patch removes the unnecessary dependency on configure-generated flags `windowsHost`, `osxHost` and `iosHost`, using the information provided by the module `System.Info` instead. We also take care to use the `CrossCompiling` flag generated by the configure script only after the latter had a chance to run. - - - - - ebd63e8d by Ömer Sinan Ağacan at 2019-06-25T01:36:50-04:00 Simplify link_caf and mkForeignLabel functions - - - - - c346585b by Ben Gamari at 2019-06-25T08:37:46-04:00 testsuite: A major revamp of the driver This tries to put the testsuite driver into a slightly more maintainable condition: * Add type annotations where easily done * Use pathlib.Path instead of str paths * Make it pass the mypy typechecker - - - - - bb40bd37 by Ben Gamari at 2019-06-25T08:37:46-04:00 testsuite: Fix a few issues in JUnit output * Make it pass mypy * Fix a typo in test name field * Report more stderr output * Report stdout output - - - - - 95f56853 by Ben Gamari at 2019-06-25T08:37:46-04:00 gitlab-ci: Add testsuite typechecking lint - - - - - 9542ab06 by Ben Gamari at 2019-06-25T08:38:22-04:00 testsuite: Don't run T16525a with -DS unless compiler_debugged Originally I was thinking of just skipping the test unless compiled_debugged==True. However, the test will likely be useful even without -DS, so let's run it either way. - - - - - d0993a29 by Ben Gamari at 2019-06-25T08:38:22-04:00 testsuite: Fix expected output for caf_crash - - - - - 757b71d9 by Ben Gamari at 2019-06-25T08:38:22-04:00 testsuite: Mark ghci058 as broken on Windows Due to #16858. - - - - - 38ded743 by Siddharth Bhat at 2019-06-25T15:15:16+02:00 [skip ci] Typo fix: b*ar*nches -> b*ra*nches - - - - - 8a03d5a1 by Ben Gamari at 2019-06-25T22:20:24-04:00 testsuite: Add test for #16846 - - - - - 5ff0a171 by Ben Gamari at 2019-06-25T22:20:24-04:00 CoreToStg: Enable CAFfyness checking with -dstg-lint The debugging involved in finding #16846 wouldn't have been necessary had the consistentCafInfo check been enabled. However, :wq - - - - - cac8dc9f by Ben Gamari at 2019-06-25T22:20:24-04:00 Don't eta-expand unsaturated primops Previously, as described in Note [Primop wrappers], `hasNoBinding` would return False in the case of `PrimOpId`s. This would result in eta expansion of unsaturated primop applications during CorePrep. Not only did this expansion result in unnecessary allocations, but it also meant lead to rather nasty inconsistencies between the CAFfy-ness determinations made by TidyPgm and CorePrep. This fixes #16846. - - - - - b90437d8 by Ben Gamari at 2019-06-25T22:20:59-04:00 testsuite: Unbreak T16608 tests Sleep to avoid non-determinism due to Darwin's poor mtime resolution. Fixes #16855. - - - - - ff2b99e1 by Ömer Sinan Ağacan at 2019-06-25T22:21:38-04:00 Remove unused UniqSupply functions - - - - - 4c2127c4 by Ben Gamari at 2019-06-25T22:52:26-04:00 Bump containers submodule to v0.6.2.1 - - - - - 5c3f2080 by Ben Gamari at 2019-06-25T22:52:26-04:00 Bump Cabal submodule to what will become 3.0.0.0 Metric Increase: haddock.Cabal - - - - - a863c44f by Oleg Grenrus at 2019-06-25T23:25:08-04:00 Add -Winferred-safe-imports warning This commit partly reverts e69619e923e84ae61a6bb4357f06862264daa94b commit by reintroducing Sf_SafeInferred SafeHaskellMode. We preserve whether module was declared or inferred Safe. When declared-Safe module imports inferred-Safe, we warn. This inferred status is volatile, often enough it's a happy coincidence, something which cannot be relied upon. However, explicitly Safe or Trustworthy packages won't accidentally become Unsafe. Updates haddock submodule. - - - - - 8ec5ceb0 by Oleg Grenrus at 2019-06-25T23:25:08-04:00 Add -Wmissing-safe-haskell-mode warning - - - - - c99d9aab by Ben Gamari at 2019-06-26T08:15:02-04:00 testsuite: Fix T16832 The test seems to have been missing the name of its script and didn't build with HEAD. How it made it through CI is beyond me. - - - - - e0899925 by Siddharth Bhat at 2019-06-26T08:16:30-04:00 [skip ci] add a blurb about the purpose of Printer.c - - - - - 58e84b30 by Ben Gamari at 2019-06-26T08:18:25-04:00 testsuite: Use safe FFI call in T5611 The original issue, #5611, was concerned with safe calls. However, the test inexplicably used an unsafe call. Fix this. - - - - - 12752342 by Ben Gamari at 2019-06-26T08:18:25-04:00 testsuite: Add T5611a This is the same as T5611 but with an unsafe call to sleep. - - - - - 551b79e4 by Ben Gamari at 2019-06-26T08:18:25-04:00 testsuite: Mark T5611 and T5611a as fragile - - - - - 44d08c32 by Ben Gamari at 2019-06-26T08:20:54-04:00 testsuite: Run and report on fragile tests This allows us to run (but ignore the result of) fragile testcases. Hopefully this should allow us to more easily spot when a fragile test becomes un-fragile. - - - - - 1c4f18d0 by Ben Gamari at 2019-06-26T08:20:54-04:00 testsuite: More type signatures - - - - - a586b33f by Matthew Pickering at 2019-06-27T10:42:29-04:00 rts: Correct handling of LARGE ARR_WORDS in LDV profiler This implements the correct fix for #11627 by skipping over the slop (which is zeroed) rather than adding special case logic for LARGE ARR_WORDS which runs the risk of not performing a correct census by ignoring any subsequent blocks. This approach implements similar logic to that in Sanity.c - - - - - ed4cbd93 by Matthew Pickering at 2019-06-27T10:42:29-04:00 rts: Correct assertion in LDV_recordDead It is possible that void_total is exactly equal to not_used and the other assertions for this check for <= rather than <. - - - - - 07cffc49 by Matthew Pickering at 2019-06-27T10:42:29-04:00 rts: Do not traverse nursery for dead closures in LDV profile It is important that `heapCensus` and `LdvCensusForDead` traverse the same areas. `heapCensus` increases the `not_used` counter which tracks how many closures are live but haven't been used yet. `LdvCensusForDead` increases the `void_total` counter which tracks how many dead closures there are. The `LAG` is then calculated by substracting the `void_total` from `not_used` and so it is essential that `not_used >= void_total`. This fact is checked by quite a few assertions. However, if a program has low maximum residency but allocates a lot in the nursery then these assertions were failing (see #16753 and #15903) because `LdvCensusForDead` was observing dead closures from the nursery which totalled more than the `not_used`. The same closures were not counted by `heapCensus`. Therefore, it seems that the correct fix is to make `LdvCensusForDead` agree with `heapCensus` and not traverse the nursery for dead closures. Fixes #16100 #16753 #15903 #8982 - - - - - c1f67887 by Roland Senn at 2019-06-27T10:43:10-04:00 Improve doc for :type-at. (#14780) - - - - - 52f10216 by Roland Zumkeller at 2019-06-27T10:43:47-04:00 configure: prefer cc over gcc Fixes #16857. - - - - - 90e0ab7d by Sylvain Henry at 2019-06-27T10:44:25-04:00 Fix Happy deps for Stack (#16825) - - - - - d35cec7a by Fraser Tweedale at 2019-06-27T10:45:01-04:00 getExecutablePath: get path from sysctl on FreeBSD - - - - - 2a68b8b7 by nineonine at 2019-06-27T10:45:39-04:00 Fix #16805 by formatting warning message - - - - - 217258d0 by Ben Gamari at 2019-06-27T10:46:18-04:00 testsuite: Add more type annotations to perf_notes - - - - - 4ec233ec by Sylvain Henry at 2019-06-27T23:58:37-04:00 Fix GCC warnings with __clear_cache builtin (#16867) - - - - - ef6d9a50 by Artem Pelenitsyn at 2019-06-27T23:59:15-04:00 typo in the docs for DynFlags.hs - - - - - 11bac115 by Travis Whitaker at 2019-06-28T15:25:05-04:00 Correct closure observation, construction, and mutation on weak memory machines. Here the following changes are introduced: - A read barrier machine op is added to Cmm. - The order in which a closure's fields are read and written is changed. - Memory barriers are added to RTS code to ensure correctness on out-or-order machines with weak memory ordering. Cmm has a new CallishMachOp called MO_ReadBarrier. On weak memory machines, this is lowered to an instruction that ensures memory reads that occur after said instruction in program order are not performed before reads coming before said instruction in program order. On machines with strong memory ordering properties (e.g. X86, SPARC in TSO mode) no such instruction is necessary, so MO_ReadBarrier is simply erased. However, such an instruction is necessary on weakly ordered machines, e.g. ARM and PowerPC. Weam memory ordering has consequences for how closures are observed and mutated. For example, consider a closure that needs to be updated to an indirection. In order for the indirection to be safe for concurrent observers to enter, said observers must read the indirection's info table before they read the indirectee. Furthermore, the entering observer makes assumptions about the closure based on its info table contents, e.g. an INFO_TYPE of IND imples the closure has an indirectee pointer that is safe to follow. When a closure is updated with an indirection, both its info table and its indirectee must be written. With weak memory ordering, these two writes can be arbitrarily reordered, and perhaps even interleaved with other threads' reads and writes (in the absence of memory barrier instructions). Consider this example of a bad reordering: - An updater writes to a closure's info table (INFO_TYPE is now IND). - A concurrent observer branches upon reading the closure's INFO_TYPE as IND. - A concurrent observer reads the closure's indirectee and enters it. (!!!) - An updater writes the closure's indirectee. Here the update to the indirectee comes too late and the concurrent observer has jumped off into the abyss. Speculative execution can also cause us issues, consider: - An observer is about to case on a value in closure's info table. - The observer speculatively reads one or more of closure's fields. - An updater writes to closure's info table. - The observer takes a branch based on the new info table value, but with the old closure fields! - The updater writes to the closure's other fields, but its too late. Because of these effects, reads and writes to a closure's info table must be ordered carefully with respect to reads and writes to the closure's other fields, and memory barriers must be placed to ensure that reads and writes occur in program order. Specifically, updates to a closure must follow the following pattern: - Update the closure's (non-info table) fields. - Write barrier. - Update the closure's info table. Observing a closure's fields must follow the following pattern: - Read the closure's info pointer. - Read barrier. - Read the closure's (non-info table) fields. This patch updates RTS code to obey this pattern. This should fix long-standing SMP bugs on ARM (specifically newer aarch64 microarchitectures supporting out-of-order execution) and PowerPC. This fixes issue #15449. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - bd660ede by Ben Gamari at 2019-06-28T15:25:30-04:00 rts: Assert that LDV profiling isn't used with parallel GC I'm not entirely sure we are careful about ensuring this; this is a last-ditch check. - - - - - 82693938 by Moritz Angermann at 2019-07-02T16:18:05-04:00 Add _GLOBAL_OFFSET_TABLE_ support This adds lookup logic for _GLOBAL_OFFSET_TABLE_ as well as relocation logic for R_ARM_BASE_PREL and R_ARM_GOT_BREL which the gnu toolchain (gas, gcc, ...) prefers to produce. Apparently recent llvm toolchains will produce those as well. - - - - - 348e3f8e by Edward Amsden at 2019-07-02T16:18:05-04:00 Lookup _GLOBAL_OFFSET_TABLE by symbol->addr when doing relocations - - - - - e9abcad4 by Moritz Angermann at 2019-07-02T16:18:05-04:00 No atomics on arm32; this will just yield stubs. As such the internal linker will fail for them. The alternative would be to implement them as stubs in the linker and have them barf when called. > Not all operations are supported by all target processors. If a particular operation cannot be implemented on the target processor, a warning is generated and a call an external function is generated. The external function carries the same name as the built-in version, with an additional suffix ‘_n’ where n is the size of the data type. (https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html) - - - - - 023a2bc7 by Ben Gamari at 2019-07-02T16:18:05-04:00 Apply suggestion to rts/linker/elf_got.c - - - - - 0bed9647 by Ben Gamari at 2019-07-02T16:18:05-04:00 Apply suggestion to rts/linker/Elf.c - - - - - cef80c0b by nineonine at 2019-07-02T16:18:44-04:00 Fix #15843 by extending Template Haskell AST for tuples to support sections - - - - - 294b55dc by Eric Wolf at 2019-07-02T16:19:21-04:00 Add test for #16575 just use the test to show the defective behaviour, so we can see the difference, when it gets fixed - - - - - 60b9eab9 by Ömer Sinan Ağacan at 2019-07-02T16:19:59-04:00 Fix stage 1 warnings - - - - - df3e5b74 by David Eichmann at 2019-07-02T16:20:36-04:00 Hadrian: disable cloud build cache for symlinks #16800 This is a temporary workaround shake not supporting symlinks when using cloud/cached builds. - - - - - acd79558 by Abhiroop Sarkar at 2019-07-03T09:33:39-04:00 Add support for SIMD operations in the NCG This adds support for constructing vector types from Float#, Double# etc and performing arithmetic operations on them Cleaned-Up-By: Ben Gamari <ben at well-typed.com> - - - - - 973c61b5 by Ben Gamari at 2019-07-03T09:34:16-04:00 gitlab-ci: Fix doc-tarball job Previously we used the deb9-debug job which used the `validate` build flavour which disabled `BUILD_SPHINX_PDF`. Fix this. Fixes #16890. - - - - - a25f6f55 by Ryan Scott at 2019-07-03T09:34:54-04:00 Bump template-haskell version to 2.16.0.0 Commit cef80c0b9edca3d21b5c762f51dfbab4c5857d8a debuted a breaking change to `template-haskell`, so in order to guard against it properly with CPP, we need to bump the `template-haskell` version number accordingly. - - - - - f7a2e709 by Ben Gamari at 2019-07-04T15:29:49-04:00 Bump parsec submodule to 3.1.14.0 - - - - - d7f7e1ed by Siddharth Bhat at 2019-07-04T21:22:00-04:00 Make printer untag when chasing a pointer in a RET_FUN frame This is to mimic what `Scav.c` does. This should fix a crash in the printer. - - - - - 675d27fc by Ben Gamari at 2019-07-04T21:22:35-04:00 gitlab: Reduce size of template headings - - - - - 679427f8 by Vladislav Zavialov at 2019-07-04T21:23:10-04:00 Produce all DerivInfo in tcTyAndClassDecls Before this refactoring: * DerivInfo for data family instances was returned from tcTyAndClassDecls * DerivInfo for data declarations was generated with mkDerivInfos and added at a later stage of the pipeline in tcInstDeclsDeriv After this refactoring: * DerivInfo for both data family instances and data declarations is returned from tcTyAndClassDecls in a single list. This uniform treatment results in a more convenient arrangement to fix #16731. - - - - - 53aa59f3 by Simon Peyton Jones at 2019-07-04T21:23:49-04:00 Add a missing zonk (fixes #16902) In the eager unifier, when unifying (tv1 ~ tv2), when we decide to swap them over, to unify (tv2 ~ tv1), I'd forgotten to ensure that tv1's kind was fully zonked, which is an invariant of uUnfilledTyVar2. That could lead us to build an infinite kind, or (in the case of #16902) update the same unification variable twice. Yikes. Now we get an error message rather than non-termination, which is much better. The error message is not great, but it's a very strange program, and I can't see an easy way to improve it, so for now I'm just committing this fix. Here's the decl data F (a :: k) :: (a ~~ k) => Type where MkF :: F a and the rather error message of which I am not proud T16902.hs:11:10: error: • Expected a type, but found something with kind ‘a1’ • In the type ‘F a’ - - - - - ed662901 by Daniel Gröber at 2019-07-04T21:24:26-04:00 rts: Fix -hT option with profiling rts In dumpCensus we switch/case on doHeapProfile twice. The second switch tries to barf on unknown doHeapProfile modes but HEAP_BY_CLOSURE_TYPE is checked by the first switch and not included in the second. So when trying to pass -hT to the profiling rts it barfs. This commit simply merges the two switches into one which fixes this problem. - - - - - 80afdf6b by Simon Peyton Jones at 2019-07-04T21:25:05-04:00 Fix over-eager implication constraint discard Ticket #16247 showed that we were discarding an implication constraint that had empty ic_wanted, when we still needed to keep it so we could check whether it had a bad telescope. Happily it's a one line fix. All the rest is comments! - - - - - f002250a by Andreas Klebinger at 2019-07-04T21:25:43-04:00 Dont gather ticks when only striping them in STG. Adds stripStgTicksTopE which only returns the stripped expression. So far we also allocated a list for the stripped ticks which was never used. Allocation difference is as expected very small but present. About 0.02% difference when compiling with -O. - - - - - a76b233d by Artem Pelenitsyn at 2019-07-05T07:06:55-04:00 Make all submodules have absolute URLs The relative URLs were a workaround to let most contributors fork from Github due to a weakness in the haskell.org server. This workaround is no longer needed. And relative submodule URLs are an impediment to forking which makes contributions harder than they should be. The URLs are chosen to clone from https, because this makes sure that anybody, even not a registered Gitlab user, can clone a fork recursively. - - - - - 62b82135 by Ryan Scott at 2019-07-05T07:07:38-04:00 More sensible SrcSpans for recursive pattern synonym errors (#16900) Attach the `SrcSpan` of the first pattern synonym binding involved in the recursive group when throwing the corresponding error message, similarly to how it is done for type synonyms. Fixes #16900. - - - - - 2fd1ed54 by nineonine at 2019-07-05T07:08:17-04:00 Fix #16895 by checking whether infix expression operator is a variable - - - - - 03f5adcd by David Eichmann at 2019-07-08T07:07:10-04:00 Bump Shake and copy instead of hard link from cloud cache This is important as in hard link mode shake makes all such files read only to avoid accidentally modifying cache files via the hard link. It turns out, many Hadrian rules attempt read access to such files and hence fail in the hard link mode. These rules could be refactored to avoid write access, but using copy instead of hard link a much simpler solution. - - - - - 5af815f2 by Kevin Buhr at 2019-07-08T07:07:11-04:00 Add test for old issue w/ bad source locations for warnings in .lhs files (#515) - - - - - 6a03d77b by Ryan Scott at 2019-07-09T11:52:45-04:00 Use an empty data type in TTG extension constructors (#15247) To avoid having to `panic` any time a TTG extension constructor is consumed, this MR introduces an uninhabited 'NoExtCon' type and uses that in every extension constructor's type family instance where it is appropriate. This also introduces a 'noExtCon' function which eliminates a 'NoExtCon', much like 'Data.Void.absurd' eliminates a 'Void'. I also renamed the existing `NoExt` type to `NoExtField` to better distinguish it from `NoExtCon`. Unsurprisingly, there is a lot of code churn resulting from this. Bumps the Haddock submodule. Fixes #15247. - - - - - b05c8423 by Phuong Trinh at 2019-07-09T22:55:41-04:00 Fix #16511: changes in interface dependencies should trigger recompilation If the union of dependencies of imported modules change, the `mi_deps` field of the interface files should change as well. Because of that, we need to check for changes in this in recompilation checker which we are not doing right now. This adds a checks for that. - - - - - fb43bddc by John Ericson at 2019-07-09T22:56:18-04:00 Fix two more `#ifndef` for the linter - - - - - 0472f0f6 by John Ericson at 2019-07-09T22:56:18-04:00 Remove most uses of TARGET platform macros These prevent multi-target builds. They were gotten rid of in 3 ways: 1. In the compiler itself, replacing `#if` with runtime `if`. In these cases, we care about the target platform still, but the target platform is dynamic so we must delay the elimination to run time. 2. In the compiler itself, replacing `TARGET` with `HOST`. There was just one bit of this, in some code splitting strings representing lists of paths. These paths are used by GHC itself, and not by the compiled binary. (They are compiler lookup paths, rather than RPATHS or something that does matter to the compiled binary, and thus would legitamentally be target-sensative.) As such, the path-splitting method only depends on where GHC runs and not where code it produces runs. This should have been `HOST` all along. 3. Changing the RTS. The RTS doesn't care about the target platform, full stop. 4. `includes/stg/HaskellMachRegs.h` This file is also included in the genapply executable. This is tricky because the RTS's host platform really is that utility's target platform. so that utility really really isn't multi-target either. But at least it isn't an installed part of GHC, but just a one-off tool when building the RTS. Lying with the `HOST` to a one-off program (genapply) that isn't installed doesn't seem so bad. It's certainly better than the other way around of lying to the RTS though not to genapply. The RTS is more important, and it is installed, *and* this header is installed as part of the RTS. - - - - - 24782b89 by John Ericson at 2019-07-09T22:56:18-04:00 Deduplicate "unique subdir" code between GHC and Cabal The code, including the generated module with the version, is now in ghc-boot. Config.hs reexports stuff as needed, ghc-pkg doesn't need any tricks at all. - - - - - 42ff8653 by Ben Gamari at 2019-07-09T22:56:53-04:00 testsuite: Fix #16818 Renames performance metrics to include whether they are compile-time or runtime metrics. - - - - - 18ac9ad4 by Alp Mestanogullari at 2019-07-09T22:57:31-04:00 Hadrian: implement key-value settings for builder options They take the general form `foo.bar.baz [+]= some values`, where `=` completely overrides the arguments for a builder and `+=` extends them. We currenly only support settings for updating the GHC and C compiler options, of the form: ``` {stage0, ..., stage3 or *}.{package name or *} .ghc.{c, hs, link, deps, toolargs or *}.opts {stage0, ..., stage3 or *}.{package name or *} .cc.{c, deps or *}.opts ``` The supported settings and their use is covered in the new section of `hadrian/doc/user-settings.md`, while the implementation is explained in a new Note [Hadrian settings]. Most of the logic is implemented in a new module, `Settings.Parser`, which contains key-value assignment/extension parsers as well as utilities for specifying allowed settings at a high-level, generating a `Predicate` from such a description or generating the list of possible completions for a given string. The additions to the `Settings` module make use of this to describe the settings that Hadrian currently supports, and apply all such key-value settings (from the command line and `<root>/hadrian.settings`) to the flavour that Hadrian is going to proceed with. This new setting system comes with support for generating Bash completions, implemented in `hadrian/completion.sh` and Hadrian's `autocomplete` target: > source hadrian/completion.sh > hadrian/build.sh stage1.base.ghc.<TAB> stage1.base.ghc.c.opts stage1.base.ghc.hs.opts stage1.base.ghc.*.opts stage1.base.ghc.deps.opts stage1.base.ghc.link.opts stage1.base.ghc.toolargs.opts - - - - - 7f8bf98e by Alp Mestanogullari at 2019-07-09T22:58:09-04:00 Hadrian: fix source-dist rule The first problem was that the list of files/dirs to embed or ignore was not up-to-date. The second problem was that the 'Cwd' option used when running the Tar builder in the source-dist rule didn't actually change the current directory and was therefore failing. Finally, the source-dist rule did not pre-generate Haskell modules derived from .x (alex) and .y (happy) files, like the Make build system does -- this is now fixed. We might be doing too much work for that last step (we seem to be building many things until we get to generating the source distribution), but extracting the distribution and running ./configure && hadrian/build.sh --flavour=quickest -j from there does work for me now. - - - - - d7423f10 by Ömer Sinan Ağacan at 2019-07-09T22:58:48-04:00 Testsuite tweaks and refactoring - Rename requires_th to req_th for consistency with other req functions (e.g. req_interp, req_profiling etc.) - req_th (previously requires_th) now checks for interpreter (via req_interp). With this running TH tests are skipped when running the test suite with stage=1. - Test tweaks: - T9360a, T9360b: Use req_interp - recomp009, T13938, RAE_T32a: Use req_th - Fix check-makefiles linter: it now looks for Makefiles instead of .T files (which are actually Python files) - - - - - 897a59a5 by Ömer Sinan Ağacan at 2019-07-09T22:59:26-04:00 Minor refactoring in CoreSimpl When `join_ids` is empty `extendVarSetList existing_joins join_ids` is already no-op, so no need to check whether `join_ids` is empty or not before extending the joins set. - - - - - 85da17e5 by Eric Wolf at 2019-07-09T23:00:03-04:00 Add testcase T16804 for #16804 slightly larger testcase for :type-at and :uses so we can see changes, if #16804 is done. - - - - - 8fcc931c by Eric Wolf at 2019-07-09T23:00:03-04:00 T16804: adjust src spans - - - - - a35e0916 by Ben Gamari at 2019-07-09T23:00:42-04:00 hadrian/doc: Add some discussion of compilation stages This documents some of the lore surrounding the nature and naming of GHC's stage numbers. - - - - - d2e290d3 by Simon Peyton Jones at 2019-07-09T23:01:24-04:00 Fix erroneous float in CoreOpt The simple optimiser was making an invalid transformation to join points -- yikes. The fix is easy. I also added some documentation about the fact that GHC uses a slightly more restrictive version of join points than does the paper. Fix #16918 - - - - - cb5271ac by Kevin Buhr at 2019-07-11T17:46:19-04:00 Add regression test for old panic on inlining undeclared identifier (#495) - - - - - 01ec8549 by Andreas Klebinger at 2019-07-11T17:46:57-04:00 Special case a few common patterns in unionLists. In particular we very often pass one empty list and in these cases we want to avoid the overhead of computing `xs ++ []`. This should fix #14759 and #16911. - - - - - b507aceb by Ryan Scott at 2019-07-11T17:47:41-04:00 Don't typecheck too much (or too little) in DerivingVia (#16923) Previously, GHC would typecheck the `via` type once per class in a `deriving` clause, which caused the problems observed in #16923. This patch restructures some of the functionality in `TcDeriv` and `TcHsType` to avoid this problem. We now typecheck the `via` type exactly once per `deriving` clause and *then* typecheck all of the classes in the clause. See `Note [Don't typecheck too much in DerivingVia]` in `TcDeriv` for the full details. - - - - - 8449c5b6 by nineonine at 2019-07-11T17:48:18-04:00 Allow reusing temporary object files generated by GHCi by writing to -odir in case -fwrite-interface was specified (#16670) - - - - - d5c899d1 by Ben Gamari at 2019-07-11T17:48:54-04:00 head.hackage: Run build on head.hackage's master branch The GitLab CI infrastructure is now in the master branch. - - - - - 8a209384 by Ben Gamari at 2019-07-11T17:48:54-04:00 head.hackage: Run builds with -dcore-lint - - - - - e4c73514 by Simon Peyton Jones at 2019-07-12T02:20:01-04:00 Fix kind-checking for data/newtypes In one spot in kcConDecl we were passing in the return kind signature rether than the return kind. e.g. #16828 newtype instance Foo :: Type -> Type where MkFoo :: a -> Foo a We were giving kcConDecl the kind (Type -> Type), whereas it was expecting the ultimate return kind, namely Type. This "looking past arrows" was being done, independently, in several places, but we'd missed one. This patch moves it all to one place -- the new function kcConDecls (note the plural). I also took the opportunity to rename tcDataFamHeader to tcDataFamInstHeader (The previous name was consistently a source of confusion.) - - - - - de3935a6 by Shayne Fletcher at 2019-07-12T02:20:43-04:00 Add shake 0.18.3 to extra deps - - - - - a31b24a5 by Ashley Yakeley at 2019-07-13T16:35:41-04:00 base: Data.Fixed: make HasResolution poly-kinded (#10055, #15622) - - - - - 688a1b89 by Alp Mestanogullari at 2019-07-13T16:36:18-04:00 compiler: trace SysTools commands to emit start/stop eventlog markers This patch was motivated by some performance characterization work done for #16822, where we suspected that GHC was spending a lot of time waiting on the linker to be done. (That turned out to be true.) The tracing is taken care of by ErrUtils.withTiming, so this patch just defines and uses a little wrapper around that function in all the helpers for calling the various systools (C compiler, linker, unlit, ...). With this patch, assuming a GHC executable linked against an eventlog-capable RTS (RTS ways that contain the debug, profiling or eventlog way units), we can measure how much time is spent in each of the SysTools when building hello.hs by simply doing: ghc hello.hs -ddump-timings +RTS -l The event names are "systool:{cc, linker, as, unlit, ...}". - - - - - 348cc8eb by Andreas Klebinger at 2019-07-13T16:36:57-04:00 Add two CmmSwitch optimizations. Move switch expressions into a local variable when generating switches. This avoids duplicating the expression if we translate the switch to a tree search. This fixes #16933. Further we now check if all branches of a switch have the same destination, replacing the switch with a direct branch if that is the case. Both of these patterns appear in the ENTER macro used by the RTS but are unlikely to occur in intermediate Cmm generated by GHC. Nofib result summary: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- Min -0.0% -0.0% -15.7% -15.6% 0.0% Max -0.0% 0.0% +5.4% +5.5% 0.0% Geometric Mean -0.0% -0.0% -1.0% -1.0% -0.0% Compiler allocations go up slightly: +0.2% Example output before and after the change taken from RTS code below. All but one of the memory loads `I32[_c3::I64 - 8]` are eliminated. Instead the data is loaded once from memory in block c6. Also the switch in block `ud` in the original code has been eliminated completely. Cmm without this commit: ``` stg_ap_0_fast() { // [R1] { [] } {offset ca: _c1::P64 = R1; // CmmAssign goto c2; // CmmBranch c2: if (_c1::P64 & 7 != 0) goto c4; else goto c6; c6: _c3::I64 = I64[_c1::P64]; if (I32[_c3::I64 - 8] < 26 :: W32) goto ub; else goto ug; ub: if (I32[_c3::I64 - 8] < 15 :: W32) goto uc; else goto ue; uc: if (I32[_c3::I64 - 8] < 8 :: W32) goto c7; else goto ud; ud: switch [8 .. 14] (%MO_SS_Conv_W32_W64(I32[_c3::I64 - 8])) { case 8, 9, 10, 11, 12, 13, 14 : goto c4; } ue: if (I32[_c3::I64 - 8] >= 25 :: W32) goto c4; else goto uf; uf: if (%MO_SS_Conv_W32_W64(I32[_c3::I64 - 8]) != 23) goto c7; else goto c4; c4: R1 = _c1::P64; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; ug: if (I32[_c3::I64 - 8] < 28 :: W32) goto uh; else goto ui; uh: if (I32[_c3::I64 - 8] < 27 :: W32) goto c7; else goto c8; ui: if (I32[_c3::I64 - 8] < 29 :: W32) goto c8; else goto c7; c8: _c1::P64 = P64[_c1::P64 + 8]; goto c2; c7: R1 = _c1::P64; call (_c3::I64)(R1) args: 8, res: 0, upd: 8; } } ``` Cmm with this commit: ``` stg_ap_0_fast() { // [R1] { [] } {offset ca: _c1::P64 = R1; goto c2; c2: if (_c1::P64 & 7 != 0) goto c4; else goto c6; c6: _c3::I64 = I64[_c1::P64]; _ub::I64 = %MO_SS_Conv_W32_W64(I32[_c3::I64 - 8]); if (_ub::I64 < 26) goto uc; else goto uh; uc: if (_ub::I64 < 15) goto ud; else goto uf; ud: if (_ub::I64 < 8) goto c7; else goto c4; uf: if (_ub::I64 >= 25) goto c4; else goto ug; ug: if (_ub::I64 != 23) goto c7; else goto c4; c4: R1 = _c1::P64; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; uh: if (_ub::I64 < 28) goto ui; else goto uj; ui: if (_ub::I64 < 27) goto c7; else goto c8; uj: if (_ub::I64 < 29) goto c8; else goto c7; c8: _c1::P64 = P64[_c1::P64 + 8]; goto c2; c7: R1 = _c1::P64; call (_c3::I64)(R1) args: 8, res: 0, upd: 8; } } ``` - - - - - 232002c4 by James Foster at 2019-07-13T16:37:34-04:00 Make HsInstances and DynFlags compile with -O0 for Stage0 to speed up Hadrian builds (fixes #16936) - - - - - a7176fa1 by Ömer Sinan Ağacan at 2019-07-13T16:38:13-04:00 Minor refactoring in CmmBuildInfoTables - Replace `catMaybes (map ...)` with `mapMaybe ...` - Remove a list->set->list conversion - - - - - ff04eb59 by John Ericson at 2019-07-14T01:19:22-04:00 Remove purely external primops The compiler doesn't create uses nor compiles the uses that exist specially. These are just plain C-- FFI. These `await*` ones are especially important to so convert because "true" primops are hard to make platform-specific currently. The other exports are part of this commit so this module always exports something, which avoids silly CPP elsewhere. More will be added later once `foreign import prim` is extended. - - - - - f9b00038 by Matthew Pickering at 2019-07-14T01:19:58-04:00 hadrian: Build debug rts with -O0 -g3 and disable rts stripping Fixes #16920 - - - - - f508b7ce by Ben Gamari at 2019-07-14T01:20:34-04:00 Don't package settings in bindist Since !712 the `settings` file is produced by the build system instead of autoconf. However, this introduced a subtle bug where we would fail to rebuild the `settings` file with what we have learned from the install-time `configure` invocation. Fix this by not packaging `settings` in the bindist tarball. The build system will take care of the rest. Also fix a bug where the value of `UseLibdw` was not being persisted to the install time `configure`. - - - - - e7ed53c9 by John Ericson at 2019-07-14T01:21:11-04:00 Remove LLVM_TARGET platform macros Instead following @angerman's suggestion put them in the config file. Maybe we could re-key llvm-targets someday, but this is good for now. - - - - - bd9fc1b2 by John Ericson at 2019-07-14T01:21:48-04:00 Make CPP linter skip certain files - docs which document the lint and need to contain the unutterable - vendored code which is outside our purview - - - - - d7c6c471 by John Ericson at 2019-07-14T01:21:48-04:00 Expunge #ifdef and #ifndef from the codebase These are unexploded minds as far as the linter is concerned. I don't want to hit in my MRs by mistake! I did this with `sed`, and then rolled back some changes in the docs, config.guess, and the linter itself. - - - - - fce8f240 by xplorld at 2019-07-14T08:32:48-04:00 rename type parameter in `instance Applicative ((->) a)`, fixing #16928 - - - - - 78ed46f3 by Niklas Hambüchen at 2019-07-14T08:33:26-04:00 primops: haddock: Fix typo in referenced function. Found by @lehins. - - - - - a39a3cd6 by Ben Gamari at 2019-07-15T00:14:40-04:00 gitlab-ci: Disable submodule linter for now - - - - - 0670f98a by Arnaud Spiwack at 2019-07-15T09:23:15+02:00 Add a note in the simplifier about in-scope set as a substitution See also the discussion at #16592 - - - - - 284a2f44 by Vladislav Zavialov at 2019-07-15T18:29:05-04:00 Decouple AddAnn from P - - - - - 1befd2c0 by Vladislav Zavialov at 2019-07-15T18:29:05-04:00 PV is not P (#16611) - - - - - 5728d9fa by Artem Pelenitsyn at 2019-07-16T02:40:08-04:00 Sort out Hadrian colored output flags (fix #16397) Hadrian used to have a separate flag --progress-colour to control colored output during the build. After introduction of a Shake flag with similar purpose Hadrian's flag became redundant. The commit removes --progress-colour and switches to Shake's flag. The only difference between the two is that Hadrian has special default mode when it tries to determine if the terminal support colored output. The user can override it using (Shake's) `--[no-]color`. - - - - - db948dae by Ben Gamari at 2019-07-16T02:40:43-04:00 Revert "Add support for SIMD operations in the NCG" Unfortunately this will require more work; register allocation is quite broken. This reverts commit acd795583625401c5554f8e04ec7efca18814011. - - - - - 373c9cb3 by Daniel Gröber at 2019-07-16T02:41:23-04:00 rts: Divorce init of Heap profiler from CCS profiler Currently initProfiling gets defined by Profiling.c only if PROFILING is defined. Otherwise the ProfHeap.c defines it. This is just needlessly complicated so in this commit I make Profiling and ProfHeap into properly seperate modules and call their respective init functions from RtsStartup.c. - - - - - 52f755aa by Daniel Gröber at 2019-07-16T02:41:23-04:00 rts: Rename the nondescript initProfiling2 to refreshProfilingCCSs - - - - - 0a9b77b8 by John Ericson at 2019-07-17T12:20:26-04:00 Create {Int,Word}32Rep This prepares the way for making Int32# and Word32# the actual size they claim to be. Updates binary submodule for (de)serializing the new runtime reps. - - - - - 8add024f by Sebastian Graf at 2019-07-17T12:20:27-04:00 Make GHC-in-GHCi work on Windows By not building anything in the dynamic way on Windows, where we don't have a working story for DLLs yet. Also the ghcid command needs to call bash on the hadrian/ghci.sh script explicitly as the path gets interpreted differently otherwise. - - - - - d48da6ff by Ben Gamari at 2019-07-18T20:55:11-04:00 gitlab-ci: Run slow validate in -debug job Otherwise we don't compile the stage2 compiler with DEBUG, meaning the testsuite isn't checked with assertions. Metric Increase: haddock.Cabal - - - - - 272246bf by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: More type checking fixes - - - - - c7bcd017 by Ben Gamari at 2019-07-18T20:55:11-04:00 Add HasDebugCallStack to unionLists This should help identify a few cases where this is throwing warnings - - - - - 3cec2af6 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Mark static-plugins as broken in profiled ways See #16803. - - - - - e8adffb5 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Set -dinitial-unique when reversing uniques Otherwise the unique counter starts at 0, causing us to immediately underflow. - - - - - b9e9d8c9 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Fix req_th - - - - - d238d306 by Ben Gamari at 2019-07-18T20:55:11-04:00 Fix formatting of --info's "Debug on" field As noted in #16914, the value `True` was used instead of `YES` here, in contrast to the other boolean fields emitted by `--info`. This confused the testsuite driver and broke the `ghc_debugged` testsuite predicate. - - - - - eb8c40e3 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Mark hWaitForInput-accurate-stdin as broken in all threaded ways Previously it was not marked as broken in profthreaded - - - - - b16cabc1 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Print output from hp2ps - - - - - b62a2dfb by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Fix some ints used as bools - - - - - b3df1efb by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Skip forking tests in profiled ways As noted in #11645 and #8862, forking and profiling don't go well together. Bumps hpc and unix submodules. - - - - - 49dcbf86 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Mark test-hole-plugin as req_th This requires code loading and therefore can't be run in the profiled ways when GHC is dynamically linked. - - - - - ce8ffd80 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Unmark recomp007 as broken Fixed in #14759. - - - - - 82abc479 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Mark T4808 as broken in threaded2 way As noted in #16909. - - - - - 73703d9b by Artem Pelenitsyn at 2019-07-19T18:06:22-04:00 Hide "Loading package environment" message with -v0 (fix #16879) - - - - - 9372ff92 by Vladislav Zavialov at 2019-07-19T18:06:57-04:00 Drop the orphan roles check (#16941) 9366e019 introduced a check for orphan roles to fix #8485 6ab5da99 changed the lookup code and made the check redundant. Now it is removed. - - - - - 69adb253 by Richard Eisenberg at 2019-07-19T18:07:37-04:00 Fix #16870 by improving documentation (only) - - - - - f1980a1e by Sebastian Graf at 2019-07-19T18:08:15-04:00 Make generated ghc-stage<n> scripts executable - - - - - bec17997 by James Foster at 2019-07-19T18:08:51-04:00 users-guide: corrected -fmax-relevant-binds reverse to be -fno-max-relevant-binds - - - - - 257d1fd8 by Ryan Scott at 2019-07-19T18:09:28-04:00 Don't maintainer-clean libraries/ghc-boot/ghc.mk (#16953) This makes the `maintainer-clean` rule in `ghc.mk` slightly more sophisticated so that it does not remove the version-controlled file `libraries/ghc-boot/ghc.mk`, which was checked into version control in commit 24782b89907ab36fb5aef3a17584f4c10f1e2690. Fixes #16953. - - - - - ff996555 by Richard Eisenberg at 2019-07-19T18:10:06-04:00 Add module doc for Plugins. This was requested in #15650. - - - - - 08ad7ef4 by Baldur Blöndal at 2019-07-20T07:51:22-04:00 Added do-notation examples for Functor, Applicative and Monad combinators. - - - - - 7b42ece5 by Alfredo Di Napoli at 2019-07-20T07:52:01-04:00 Line wrap when pp long expressions (fixes #16874) This commit fixes #16874 by using `fsep` rather than `sep` when pretty printing long patterns and expressions. - - - - - 3676375f by Andreas Klebinger at 2019-07-20T07:52:39-04:00 Bump nofib submodule. - - - - - 4dfd6a5f by Matthew Pickering at 2019-07-20T07:53:15-04:00 hadrian: Remove RTS -Waggregate-return warning This was removed from make in 077b92fa39839a8e83cd87398435424403cf6486 - - - - - 5042ba9d by Andreas Klebinger at 2019-07-21T05:03:04-04:00 Expose the GhcPrelude module. This makes it simpler to load Modules importing it when using ghc-the-package. ------------------------- Metric Decrease: haddock.compiler ------------------------- - - - - - 67ee741b by Ivan Kasatenko at 2019-07-21T05:03:40-04:00 Do not ignore events deletion when events to be added are provided (#16916) Kqueue/kevent implementation used to ignore events to be unsubscribed from when events to be subscribed to were provided. This resulted in a lost notification subscription, when GHC runtime didn't listen for any events, yet the kernel considered otherwise and kept waking up the IO manager thread. This commit fixes this issue by always adding and removing all of the provided subscriptions. - - - - - 32be4461 by Roland Senn at 2019-07-21T05:04:17-04:00 Fix #8487: Debugger confuses variables To display the free variables for a single breakpoint, GHCi pulls out the information from the fields `modBreaks_breakInfo` and `modBreaks_vars` of the `ModBreaks` data structure. For a specific breakpoint this gives 2 lists of types 'Id` (`Var`) and `OccName`. They are used to create the Id's for the free variables and must be kept in sync: If we remove an element from the Names list, then we also must remove the corresponding element from the OccNames list. - - - - - 4854a349 by Ben Gamari at 2019-07-21T05:04:53-04:00 ghc-cabal: Use fromFlagOrDefault instead of fromFlag As fromFlag is partial. The only case where we used fromFlag is when determining whether to strip libraries; we now assume that we shouldn't. - - - - - 4c7a8462 by Xavier Denis at 2019-07-23T11:43:59-04:00 Make sure to load interfaces when running :instances - - - - - f9af30f8 by Ömer Sinan Ağacan at 2019-07-23T11:44:38-04:00 Remove fix-submodules.py Now that we have absolute paths for submodules (since a76b233d) we no longer need this script. - - - - - 6ade71fb by Alp Mestanogullari at 2019-07-23T23:06:36-04:00 Hadrian: run the testsuite in Windows CI job Since MR !1025 fixed the Windows build, allowing us to build a binary distribution, we can now run the testsuite in that CI job. This required fixing 'createFileLink': it should not try to create symlinks on Windows (that requires admin priviledges, which Hadrian can't assume). We now instead fall back to copying. This patch also removes some duplicated logic for iserv in the test rules, where we handle our dependency on the iserv binaries in a special way. - - - - - 3dbcc368 by Richard Eisenberg at 2019-07-23T23:07:13-04:00 Simon and I like to work in hsSyn, too. - - - - - b95b6380 by John Ericson at 2019-07-24T16:49:53-04:00 Make stage 1 GHC target independent Now that the target macros are not being used, we remove them. This prevents target hardcoding regressions. - - - - - d0f8ed20 by Ben Gamari at 2019-07-24T16:50:28-04:00 gitlab-ci: Fix source tarball job * Use show! in source tarball job. Since we aren't actually building anything in this job `show` won't work. * Fix Docker image name * Make `version` file contain only version string - - - - - 90dd2ea0 by Vladislav Zavialov at 2019-07-24T23:11:22-04:00 ASSERT(vis_flag==ForallInvis) in hsScopedTvs - - - - - e07f0e2b by Vladislav Zavialov at 2019-07-24T23:11:57-04:00 Drop unused helpers 'mkTyClGroup' and 'emptyTyClGroup' - - - - - cb495b3c by Ryan Scott at 2019-07-25T17:25:26-04:00 Make DefUses = OrdList DefUse Before, `type DefUses = [DefUse]`. But lists are a terrible choice of data structure here, as we frequently append to the right of a `DefUses`, which yields some displeasing asymptotics. Let's instead use `OrdList`, which has constant-time appending to the right. This is one step on the way to #10347. - - - - - b9c99df1 by Ömer Sinan Ağacan at 2019-07-25T17:26:03-04:00 Printer: add an empty line between bindings in Rec STG binding groups Before: Rec { x2_r10T :: Lib.Bar [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Bar! [x3_r10U]; x3_r10U :: Lib.Foo [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Foo! [x1_r10p x2_r10T]; end Rec } After: Rec { x2_r10T :: Lib.Bar [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Bar! [x3_r10U]; x3_r10U :: Lib.Foo [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Foo! [x1_r10p x2_r10T]; end Rec } - - - - - 30b6f391 by Ryan Scott at 2019-07-26T00:57:02-04:00 Banish reportFloatingViaTvs to the shadow realm (#15831, #16181) GHC used to reject programs of this form: ``` newtype Age = MkAge Int deriving Eq via Const Int a ``` That's because an earlier implementation of `DerivingVia` would generate the following instance: ``` instance Eq Age where (==) = coerce @(Const Int a -> Const Int a -> Bool) @(Age -> Age -> Bool) (==) ``` Note that the `a` in `Const Int a` is not bound anywhere, which causes all sorts of issues. I figured that no one would ever want to write code like this anyway, so I simply banned "floating" `via` type variables like `a`, checking for their presence in the aptly named `reportFloatingViaTvs` function. `reportFloatingViaTvs` ended up being implemented in a subtly incorrect way, as #15831 demonstrates. Following counsel with the sage of gold fire, I decided to abandon `reportFloatingViaTvs` entirely and opt for a different approach that would _accept_ the instance above. This is because GHC now generates this instance instead: ``` instance forall a. Eq Age where (==) = coerce @(Const Int a -> Const Int a -> Bool) @(Age -> Age -> Bool) (==) ``` Notice that we now explicitly quantify the `a` in `instance forall a. Eq Age`, so everything is peachy scoping-wise. See `Note [Floating `via` type variables]` in `TcDeriv` for the full scoop. A pleasant benefit of this refactoring is that it made it much easier to catch the problem observed in #16181, so this patch fixes that issue too. Fixes #15831. Fixes #16181. - - - - - aae0457f by nineonine at 2019-07-26T00:57:39-04:00 Change behaviour of -ddump-cmm-verbose to dump each Cmm pass output to a separate file and add -ddump-cmm-verbose-by-proc to keep old behaviour (#16930) - - - - - 00d9d284 by Vladislav Zavialov at 2019-07-26T00:58:15-04:00 TemplateHaskell: reifyType (#16976) - - - - - ea08fa37 by Vladislav Zavialov at 2019-07-26T00:58:15-04:00 reifyTypeOfThing: panic on impossible cases - - - - - 7c9fb2f0 by Adam Sandberg Eriksson at 2019-07-26T09:49:14-04:00 ghc-heap: implement WEAK closure type #16974 - - - - - 26314386 by nineonine at 2019-07-26T09:49:51-04:00 Add regression test for #16946 - - - - - cd11f81f by Fumiaki Kinoshita at 2019-07-28T19:47:50-04:00 base: add Functor, Applicative, Monad, Alternative, MonadPlus, Generic and Generic1 instances to Kleisli - - - - - c1a06d49 by Dale Wijnand at 2019-07-28T19:48:27-04:00 hadrian: relink to the flavours doc in the ghc repo - - - - - 9f8cdb35 by Richard Eisenberg at 2019-07-29T19:32:16-04:00 Add Note [RuntimeRep and PrimRep] in RepType Also adds Note [Getting from RuntimeRep to PrimRep], which deocuments a related thorny process. This Note addresses #16964, which correctly observes that documentation for this thorny design is lacking. Documentation only. - - - - - 86f47b8e by Dale Wijnand at 2019-07-29T19:32:52-04:00 hadrian: Drop a stale limitation tracking issue https://github.com/snowleopard/hadrian/issues/187 was superseded by https://github.com/snowleopard/hadrian/issues/669, which has also been closed. So, optimistically, dropping this as a limitation issue. - - - - - 9c8a211a by Andreas Klebinger at 2019-07-30T01:33:50-04:00 Expand the preallocated Int range to [-16,255] Effects as I measured them: RTS Size: +0.1% Compile times: -0.5% Runtine nofib: -1.1% Nofib runtime result seems to mostly come from the `CS` benchmark which is very sensible to alignment changes so this is likely over represented. However the compile time changes are realistic. This is related to #16961. - - - - - 2829f6da by Simon Peyton Jones at 2019-07-30T01:34:27-04:00 Apply a missing substitution in mkEtaWW (#16979) The `mkEtaWW` case for newtypes forgot to apply the substitution to the newtype coercion, resulting in the Core Lint errors observed in #16979. Easily fixed. Fixes #16979. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - 371dadfb by Ben Gamari at 2019-07-31T04:27:59-04:00 Break up TyCoRep This breaks up the monstrous TyCoReps module into several new modules by topic: * TyCoRep: Contains the `Coercion`, `Type`, and related type definitions and a few simple predicates but nothing further * TyCoPpr: Contains the the pretty-printer logic * TyCoFVs: Contains the free variable computations (and `tyConAppNeedsKindSig`, although I suspect this should change) * TyCoSubst: Contains the substitution logic for types and coercions * TyCoTidy: Contains the tidying logic for types While we are able to eliminate a good number of `SOURCE` imports (and make a few others smaller) with this change, we must introduce one new `hs-boot` file for `TyCoPpr` so that `TyCoRep` can define `Outputable` instances for the types it defines. Metric Increase: haddock.Cabal haddock.compiler - - - - - b6fa7fe3 by Ben Gamari at 2019-07-31T04:27:59-04:00 gitignore: Add .mypy_cache - - - - - 88410e77 by Ben Gamari at 2019-07-31T04:27:59-04:00 Move tyConAppNeedsKindSig to Type Previously it was awkwardly in TyCoFVs (and before that in TyCoRep). Type seems like a sensible place for it to live. - - - - - 787fab43 by Ben Gamari at 2019-07-31T04:27:59-04:00 Work around redundant import issue As mentioned in #16997, GHC currently complains about this import. In general I'm reluctant to paper over things like this but in the case of an hs-boot file I think adding an import list is the right thing to do regardless of the bug. - - - - - 5e04841c by Ben Gamari at 2019-07-31T13:53:58-04:00 gitlab-ci: Fix it after upgrade It seems that the regular expression parser changed in GitLab 12.1 and now does now support forward slashes in the RE, even when escaped. - - - - - 986643cb by Ivan Kasatenko at 2019-08-01T13:49:50-04:00 Fix T16916 CI failures (#16966) 1. Slightly increased the waiting time for the tested effect to be more profound. 2. Introduced measuring of the actual time spent waiting and adjusing CPU time by it to compensate for threadDelay waiting time inconsistencies. - - - - - 95521140 by Andreas Klebinger at 2019-08-02T08:14:10-04:00 Add StandaloneDeriving example for DerivingVia. [skip-ci] - - - - - 1b9d32b8 by Ryan Scott at 2019-08-02T08:14:47-04:00 Rip out 9-year-old pattern variable hack (#17007) GHC had an ad hoc validity check in place to rule out pattern variables bound by type synonyms, such as in the following example: ```hs type ItemColID a b = Int -- Discards a,b get :: ItemColID a b -> ItemColID a b get (x :: ItemColID a b) = x :: ItemColID a b ``` This hack is wholly unnecessary nowadays, since OutsideIn(X) is more than capable of instantiating `a` and `b` to `Any`. In light of this, let's rip out this validity check. Fixes #17007. - - - - - 93bed40a by Ryan Scott at 2019-08-02T08:15:25-04:00 Use injectiveVarsOfType to catch dodgy type family instance binders (#17008) Previously, we detected dodgy type family instances binders by expanding type synonyms (via `exactTyCoVarsOfType`) and looking for type variables on the RHS that weren't mentioned on the (expanded) LHS. But this doesn't account for type families (like the example in #17008), so we instead use `injectiveVarsOfType` to only count LHS type variables that are in injective positions. That way, the `a` in `type instance F (x :: T a) = a` will not count if `T` is a type synonym _or_ a type family. Along the way, I moved `exactTyCoVarsOfType` to `TyCoFVs` to live alongside its sibling functions that also compute free variables. Fixes #17008. - - - - - c902f56b by Krzysztof Gogolewski at 2019-08-02T08:16:03-04:00 Remove build.nix.sh This file refers to shell.nix, which was removed in 430e6fedfda and c00d2f59d. - - - - - 5e960287 by Adam Sandberg Eriksson at 2019-08-02T08:16:45-04:00 docs: fixs -prof links in rts-flags section - - - - - 0c5cd771 by Alp Mestanogullari at 2019-08-02T22:20:14-04:00 compiler: emit finer grained codegen events to eventlog - - - - - 0ecacb1e by Alp Mestanogullari at 2019-08-02T22:20:14-04:00 Add Note [withTiming] in compiler/main/ErrUtils.hs - - - - - 4664bafc by Ben Gamari at 2019-08-02T22:20:50-04:00 rts: Always truncate output files Previously there were numerous places in the RTS where we would fopen with the "w" flag string. This is wrong as it will not truncate the file. Consequently if we write less data than the previous length of the file we will leave garbage at its end. Fixes #16993. - - - - - e3cbe319 by Ben Gamari at 2019-08-02T22:21:26-04:00 Packages: Add timing for package database initialization - - - - - a5227080 by Alp Mestanogullari at 2019-08-02T22:22:06-04:00 Hadrian: make settings, platformConstants, etc dependencies of lib:ghc This fixes #17003, where a user directly asked for the 'docs-haddock' target without building a complete stage 2 GHC first. Since haddock only depends on lib:ghc, the stage 2 GHC executable wasn't built, and neither were the settings, platformConstants, llvm-passes and llvm-targets files, since they are declared to be dependencies of exe:ghc. This makes sense in general since all GHC API users (haddock is one) will likely want those files to be there. - - - - - 7e404afd by Ben Gamari at 2019-08-04T18:16:51-04:00 gitlab-ci: Manually set SPHINXBUILD on Windows For some reason configure seems unable to find it on its own. Let's try giving it a hint. Addresses #16398. - - - - - 8a061d18 by Matthew Pickering at 2019-08-04T18:17:28-04:00 Update .gitignore Add some files generated by hadrian and some tooling files - - - - - 7d8d0012 by Simon Peyton Jones at 2019-08-04T18:18:08-04:00 Don't float unlifted join points to top level Ticket #16978 showed that we were floating a recursive, unlifted join point to top level. It's very much a corner case: joinrec j :: Int# j = jump j in ... But somehow it showed up in a real program. For non-recursive bindings in SetLevels.lvlBind we were already (correctly) checking for unlifted bindings, but when I wrote that code I didn't think that a /recursive/ binding could be unlifted but /join-points/ can be! Actually I don't think that SetLevels should be floating join points at all. SetLevels really floats things to move stuff out of loops and save allocation; but none of that applies to join points. The only reason to float join points is in cases like join j1 x = join j2 y = ... in ... which we might want to swizzle to join j2 x y = ... in join j1 x = ... in ... because now j1 looks small and might be inlined away altogether. But this is a very local float perhaps better done in the simplifier. Still: this patch fixes the crash, and does so in a way that is harmless if/when we change our strategy for floating join points. - - - - - 3b31a94d by Ben Gamari at 2019-08-04T18:18:08-04:00 testsuite: Add testsuite for #16978 - - - - - 2e031806 by Ben Gamari at 2019-08-04T18:18:45-04:00 configure: Search for LLVM executables with two-number versions Fedora uses the naming llc-7.0 while Debian uses llc-7. Ensure that both are found. Fixes #16990. - - - - - 6e5dfcd2 by Ben Gamari at 2019-08-04T18:19:21-04:00 testsuite: Rework tracking of fragile tests Breaks fragile tests into two groups, allowing us to easily preserve stdout/stderr of failing fragile tests. - - - - - ea16f6cb by Simon Peyton Jones at 2019-08-06T20:24:41-04:00 Remove dead parameter from coreToStgApp - - - - - 0c1ccf3c by James Foster at 2019-08-06T20:25:18-04:00 hadrian: Refactor file patterns for future Shake changes (fixes #17005) Shake will be moving from its current implementation of ?== to one from System.FilePattern. Support for `//` is being dropped, leaving only `*` and `**` as special forms. This commit converts the existing file patterns in Hadrian to the new format. It also removes all occurances of <//> and changes the user-settings docs to remove references to // and add **. The conversion is as follows: - //a ==> **/a - a// ==> a/** - a//b ==> a/**/b - - - - - c83e39bf by Matthew Pickering at 2019-08-06T20:25:54-04:00 Remove old/broken(?) .ghci script I was attempting to load hadrian into ghci by using `cabal new-repl exe:hadrian` but it failed because it tried to use this `.ghci` configuration. I'm not sure who used this script but you should really use the new-repl method. - - - - - 6f116005 by Ömer Sinan Ağacan at 2019-08-06T20:26:32-04:00 Introduce a type for "platform word size", use it instead of Int We introduce a PlatformWordSize type and use it in platformWordSize field. This removes to panic/error calls called when platform word size is not 32 or 64. We now check for this when reading the platform config. - - - - - 2073745c by mniip at 2019-08-07T10:18:07-04:00 Add a -fprint-axiom-incomps option (#15546) Supply branch incomps when building an IfaceClosedSynFamilyTyCon `pprTyThing` now has access to incomps. This also causes them to be written out to .hi files, but that doesn't pose an issue other than a more faithful bijection between `tyThingToIfaceDecl` and `tcIfaceDecl`. The machinery for displaying axiom incomps was already present but not in use. Since this is now a thing that pops up in ghci's :info the format was modified to look like a haskell comment. Documentation and a test for the new feature included. Test Plan: T15546 Reviewers: simonpj, bgamari, goldfire Reviewed By: simonpj Subscribers: rwbarton, carter GHC Trac Issues: #15546 Differential Revision: https://phabricator.haskell.org/D5097 - - - - - bca79345 by mniip at 2019-08-07T10:18:07-04:00 Fix test - - - - - 3d32286d by mniip at 2019-08-07T10:18:07-04:00 Explicitly number equations when printing axiom incompatibilities - - - - - ca8efc49 by mniip at 2019-08-07T10:18:07-04:00 Fix documentation - - - - - 2c1b1ad7 by mniip at 2019-08-07T10:18:07-04:00 Fix test - - - - - 8e2fe575 by Zubin Duggal at 2019-08-07T10:18:44-04:00 Fix bug preventing information about patterns from being serialized in .hie files - - - - - f1d0e49f by Ben Gamari at 2019-08-07T10:19:21-04:00 testsuite: Add tests for #16943 - - - - - 83ca42de by Ben Gamari at 2019-08-07T10:19:21-04:00 Revert "Make scanr a good producer and consumer" This reverts commit 4e1dfc3767167dddd0e151a2df8305b12aa0f49c. Due to #16943. - - - - - 81860281 by Joachim Breitner at 2019-08-10T14:39:27-04:00 Consolidate `TablesNextToCode` and `GhcUnreigsterised` in configure (#15548) `TablesNextToCode` is now a substituted by configure, where it has the correct defaults and error handling. Nowhere else needs to duplicate that, though we may want the compiler to to guard against bogus settings files. I renamed it from `GhcEnableTablesNextToCode` to `TablesNextToCode` to: - Help me guard against any unfixed usages - Remove any lingering connotation that this flag needs to be combined with `GhcUnreigsterised`. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082 - - - - - 422ffce0 by Ben Gamari at 2019-08-10T14:40:03-04:00 Add timing on loadInterface AndreasK recently mentioned that he thought that interface file loading may be a non-trivial cost. Let's measure. - - - - - 0424de2d by Ömer Sinan Ağacan at 2019-08-10T14:40:46-04:00 Add test for #16893 - - - - - 672cbab2 by Ömer Sinan Ağacan at 2019-08-10T14:41:26-04:00 Reformat comments in StgSyn This does not make any changes in the contents -- formatting only. Previously the comments were too noisy and I've always found it very hard to read. Hopefully it's easier to read now. - - - - - 328a0efa by Sebastian Graf at 2019-08-13T17:30:15-04:00 Add Foldable, Traversable instances for Uniq(D)FM The `UniqDFM` is deterministic, of course, while we provide an unsafe `NonDetUniqFM` wrapper for `UniqFM` to opt into nondeterministic instances. - - - - - b1d29c67 by Tamar Christina at 2019-08-13T17:30:50-04:00 Fix binary distribution - - - - - a38104b4 by Andreas Klebinger at 2019-08-14T16:55:42-04:00 Rework the Binary Integer instance. We used to serialise large integers as strings. Now they are serialized as a list of Bytes. This changes the size for a Integer in the higher 64bit range from 77 to 9 bytes when written to disk. The impact on the general case is small (<1% for interface files) as we don't use many Integers. But for code that uses many this should be a nice benefit. - - - - - aa4d8b07 by Andreas Klebinger at 2019-08-14T16:56:20-04:00 Use os.devnull instead of '/dev/null' in the testsuite driver. The later caused issues on windows by being translated into "\\dev\\null" and python then trying to open this non-existant file. So we now use os.devnull inside python and convert it to "/dev/null" when calling out to the shell, which is bound to run in a unix like environment. This fixes an issue a test producing unexpected stderr output failed with a framework failure instead of showing a diff of the output. - - - - - 6329c70a by Richard Eisenberg at 2019-08-14T17:47:25-04:00 GHCi supports not-necessarily-lifted join points Fixes #16509. See Note [Not-necessarily-lifted join points] in ByteCodeGen, which tells the full story. This commit also adds some comments and cleans some code in the byte-code generator, as I was exploring around trying to understand it. (This commit removes an old test -- this is really a GHCi problem, not a pattern-synonym problem.) test case: ghci/scripts/T16509 - - - - - ca71d551 by James Foster at 2019-08-15T12:01:43-04:00 Remove unused imports of the form 'import foo ()' (Fixes #17065) These kinds of imports are necessary in some cases such as importing instances of typeclasses or intentionally creating dependencies in the build system, but '-Wunused-imports' can't detect when they are no longer needed. This commit removes the unused ones currently in the code base (not including test files or submodules), with the hope that doing so may increase parallelism in the build system by removing unnecessary dependencies. - - - - - 95837c0f by Tobias Dammers at 2019-08-15T22:13:13-04:00 Add test cases for #16615 - - - - - 8d076841 by Tobias Dammers at 2019-08-15T22:13:13-04:00 Make add_info attach unfoldings (#16615) - - - - - 14208853 by Sylvain Henry at 2019-08-15T22:13:52-04:00 Cmm: constant folding `quotRem x 2^N` `quot` and `rem` are implemented efficiently when the second argument is a constant power of 2. This patch uses the same implementations for `quotRem` primop. - - - - - 47e16237 by Ömer Sinan Ağacan at 2019-08-15T22:14:31-04:00 Document types of LitNumbers, minor refactoring in Literal.hs - - - - - ac73c1b1 by Sylvain Henry at 2019-08-18T05:16:40-04:00 Faster exactLog2 Make `exactLog2` faster (use `countLeadingZeros` and Int32 bit-ops). On my Core i7-9700k Criterion reports ~50% speedup (from 16 to 8ns). - - - - - 1230d6f9 by Ömer Sinan Ağacan at 2019-08-18T05:17:20-04:00 Typo fix in CoreToStg - - - - - d0716279 by Ryan Scott at 2019-08-18T05:18:01-04:00 Fix #17067 by making data family type constructors actually injective `TcTyClsDecls.tcFamDecl1` was using `NotInjective` when creating data family type constructors, which is just plain wrong. This tweaks it to use `Injective` instead. Fixes #17067. - - - - - 993804bf by Sam Halliday at 2019-08-18T16:39:21-04:00 expose ModuleInfo.minf_rdr_env for tooling authors - - - - - 5b713aa3 by Ömer Sinan Ağacan at 2019-08-18T16:40:03-04:00 Fix COMPACT_NFDATA closure size, more CNF sanity checking We now do a shallow closure check on objects in compact regions. See the new comment on why we can't do a "normal" closure check. - - - - - ac7c738b by Richard Lupton at 2019-08-19T02:11:59-04:00 Generalized MonadUtils folds to Foldable (#16969) - - - - - 3a1efe1a by Richard Lupton at 2019-08-19T02:12:00-04:00 Re-export foldlM and foldrM from Data.Foldable in MonadUtils (#16969) - - - - - 2a394246 by Richard Lupton at 2019-08-19T02:12:00-04:00 Use Foldable instance of Bag for specialised Bag folds (#16969) - - - - - ac79dfe9 by Richard Lupton at 2019-08-19T02:12:00-04:00 Remove Bag fold specialisations (#16969) - - - - - 5e40356f by Ben Gamari at 2019-08-19T02:12:36-04:00 gitlab-ci: Update bootstrap compiled used for Darwin builds - - - - - d5055248 by Ben Gamari at 2019-08-22T09:25:08-04:00 gitlab-ci: Add Windows full build during the nightly pipeline - - - - - a33bad2d by Sylvain Henry at 2019-08-22T09:25:47-04:00 Doc: add Haddocks for quotRemWord2 primop - - - - - 605bce26 by James Foster at 2019-08-22T18:47:20-04:00 Add documentation for Hadrian expressions This commit adds documentation on Hadrian's 'Expr' type and references the documentation in hadrian/README.md - - - - - 8f32d2bc by TDecki at 2019-08-22T18:47:57-04:00 base: Reintroduce fusion for scanr While avoiding #16943. - - - - - c3e26ab3 by Ömer Sinan Ağacan at 2019-08-22T22:19:26-04:00 Remove special case in SRT generation with -split-sections Previously we were using an empty ModuleSRTInfo for each Cmm group with -split-section. As far as I can see this has no benefits, and simplifying this makes another patch simpler (!1304). We also remove some outdated comments: we no longer generate one module-level SRT. - - - - - a8300520 by Ömer Sinan Ağacan at 2019-08-23T12:04:15+03:00 Make non-streaming LLVM and C backends streaming This adds a Stream.consume function, uses it in LLVM and C code generators, and removes the use of Stream.collect function which was used to collect streaming Cmm generation results into a list. LLVM and C backends now properly use streamed Cmm generation, instead of collecting Cmm groups into a list before generating LLVM/C code. - - - - - 47070144 by Andreas Klebinger at 2019-08-23T19:26:42-04:00 Use variable length encoding for Binary instances. Use LEB128 encoding for Int/Word variants. This reduces the size of interface files significantly. (~19%). Also includes a few small optimizations to make unboxing work better that I have noticed while looking at the core. - - - - - cff44d86 by Sergei Trofimovich at 2019-08-23T19:27:21-04:00 configure.ac: fix '--disable-dwarf-debug' Before the change ./configure --disable-dwarf-debug enabled DWARF debugging unconditionally. This happened due to use of 5-argument form of `AC_ARG_ENABLE` without actually checking the passed `$enableval` parameter: ``` AC_ARG_ENABLE(dwarf-unwind, [AC_HELP_STRING([--enable-dwarf-unwind], [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])], [AC_CHECK_LIB(dw, dwfl_attach_state, [UseLibdw=YES], [AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)])])] [UseLibdw=NO] ) ``` Note: - `[UseLibdw=NO]` is called when `--{enable,disable}-dwarf-unwind` is not passed at all as a parameter (ok). - `[AC_CHECK_LIB(dw, dwfl_attach_state, [UseLibdw=YES],` is called for both: * `--enable-dwarf-unwind` being passed: `$enableval = "yes"` (ok). * --disable-dwarf-unwind` being passed: `$enableval = "no"` (bad). The change is to use 3-argument `AC_ARG_ENABLE` and check for passed value as `"$enable_dwarf_unwind" = "yes"`. Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 10763ce0 by Ömer Sinan Ağacan at 2019-08-27T10:45:02+03:00 Some more documentation for typePrimRep1 stuff [skip ci] - - - - - 89487be2 by Ömer Sinan Ağacan at 2019-08-27T15:21:50-04:00 Some tweaks in GHC.Compact haddocks - - - - - ee2fad9e by Andreas Klebinger at 2019-08-27T15:22:28-04:00 Remove redundant OPTIONS_GHC in BlockLayout.hs - - - - - 1c7ec449 by Ömer Sinan Ağacan at 2019-08-28T12:51:12+03:00 Return results of Cmm streams in backends This generalizes code generators (outputAsm, outputLlvm, outputC, and the call site codeOutput) so that they'll return the return values of the passed Cmm streams. This allows accumulating data during Cmm generation and returning it to the call site in HscMain. Previously the Cmm streams were assumed to return (), so the code generators returned () as well. This change is required by !1304 and !1530. Skipping CI as this was tested before and I only updated the commit message. [skip ci] - - - - - a308b435 by Sebastian Graf at 2019-08-28T11:33:49-04:00 Fix #17112 The `mkOneConFull` function of the pattern match checker used to try to guess the type arguments of the data type's type constructor by looking at the ambient type of the match. This doesn't work well for Pattern Synonyms, where the result type isn't even necessarily a TyCon application, and it shows in #11336 and #17112. Also the effort seems futile; why try to try hard when the type checker has already done the hard lifting? After this patch, we instead supply the type constructors arguments as an argument to the function and lean on the type-annotated AST. - - - - - 137c24e1 by Ryan Scott at 2019-08-28T22:36:40-04:00 Balance parentheses in GHC 8.10.1 release notes [ci skip] - - - - - 66282ba5 by luca at 2019-08-28T22:37:19-04:00 Remove Unused flag -ddump-shape [skip ci] - - - - - bf9dfe1c by Ömer Sinan Ağacan at 2019-08-29T04:28:35-04:00 Fix LLVM version check yet again There were two problems with LLVM version checking: - The parser would only parse x and x.y formatted versions. E.g. 1.2.3 would be rejected. - The version check was too strict and would reject x.y formatted versions. E.g. when we support version 7 it'd reject 7.0 ("LLVM version 7.0") and only accept 7 ("LLVM version 7"). We now parse versions with arbitrarily deep minor numbering (x.y.z.t...) and accept versions as long as the major version matches the supported version (e.g. 7.1, 7.1.2, 7.1.2.3 ...). - - - - - fc746e98 by Ben Gamari at 2019-08-29T04:29:13-04:00 gitlab-ci: Fix URL of Darwin's cabal-install tarball This was inadvertently referring to the cabal-install-latest/ directory which is volatile. - - - - - 304067a0 by Ömer Sinan Ağacan at 2019-08-29T09:38:25-04:00 Small optimization in the SRT algorithm Noticed by @simonmar in !1362: If the srtEntry is Nothing, then it should be safe to omit references to this SRT from other SRTs, even if it is a static function. When updating SRT map we don't omit references to static functions (see Note [Invalid optimisation: shortcutting]), but there's no reason to add an SRT entry for a static function if the function is not CAFFY. (Previously we'd add SRT entries for static functions even when they're not CAFFY) Using 9151b99e I checked sizes of all SRTs when building GHC and containers: - GHC: 583736 (HEAD), 581695 (this patch). 2041 less SRT entries. - containers: 2457 (HEAD), 2381 (this patch). 76 less SRT entries. - - - - - 78afc2c9 by Sergei Trofimovich at 2019-08-30T06:14:44-04:00 configure.ac: add --enable-numa switch Before the change ./configure detected numa support automatically withoun a nice way to disable autodetection. The change adds `--enable-numa` / `--disable-numa` switch to override the default. If `--enable-numa` is passed and `libnuma` is not present then configure will fail. Reported-by: Sergey Alirzaev Bug: https://github.com/gentoo-haskell/gentoo-haskell/issues/955 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c0956c14 by Vladislav Zavialov at 2019-08-30T06:15:21-04:00 Remove HsUtils/userHsLTyVarBndrs This patch removes 'userHsLTyVarBndrs' and 'userHsTyVarBndrs' from HsUtils. These helper functions were not used anywhere. - - - - - 7e6aeb13 by Eric Wolf at 2019-08-31T10:25:39+02:00 Add additional step to T16804 Add another small test step Use the same identifier name in different scopes and see, if ':uses' handles that. Add another test step to check wether local bindings with the same identifier name might get confused Add easier to understand test output Fix annotated lines from file correctly - - - - - e56251f6 by Ömer Sinan Ağacan at 2019-08-31T17:55:13-04:00 Remove redundant special case in STG pretty-printer This special case existed for no reason, and made things inconsistent. Before Boolean.$bT :: Boolean.Boolean [GblId, Str=m, Unf=OtherCon []] = CAF_ccs \ u [] Boolean.$bT1; After Boolean.$bF :: Boolean.Boolean [GblId, Str=m, Unf=OtherCon []] = \u [] Boolean.$bF1; The cost-centre is now hidden when not profiling, as is the case with other types of closures. - - - - - cfab4abe by Gershom Bazerman at 2019-09-01T00:34:05-04:00 cap max stack size at 32 bit limit (#17019) - - - - - 9acba780 by John Ericson at 2019-09-01T22:44:45-04:00 Use C99 Fixed width types to avoid hack in base's configure Define MD5Context in terms of `uint*_t` and don't use `HsFFI.h`. - - - - - 11679e5b by Ömer Sinan Ağacan at 2019-09-02T13:17:49+03:00 Few tweaks in -ddump-debug output, minor refactoring - Fixes crazy indentation in -ddump-debug output - We no longer dump empty sections in -ddump-debug when a code block does not have any generated debug info - Minor refactoring in Debug.hs and AsmCodeGen.hs - - - - - f96d57b8 by John Ericson at 2019-09-05T18:50:19-04:00 Make the C-- O and C types constructors with DataKinds The tightens up the kinds a bit. I use type synnonyms to avoid adding promotion ticks everywhere. - - - - - b55ee979 by John Ericson at 2019-09-05T18:50:56-04:00 Make sure all boolean settings entries use `YES` / `NO` Some where using `True` / `False`, a legacy of when they were in `Config.hs`. See #16914 / d238d3062a9858 for a similar problem. Also clean up the configure variables names for consistency and clarity while we're at it. "Target" makes clear we are talking about outputted code, not where GHC itself runs. - - - - - 821bece9 by Ömer Sinan Ağacan at 2019-09-07T04:50:21-04:00 Minor refactoring in deriveConstants Mainly we now generate this data PlatformConstants = PlatformConstants { pc_CONTROL_GROUP_CONST_291 :: Int, pc_STD_HDR_SIZE :: Int, pc_PROF_HDR_SIZE :: Int, pc_BLOCK_SIZE :: Int, } instead of data PlatformConstants = PlatformConstants { pc_platformConstants :: () , pc_CONTROL_GROUP_CONST_291 :: Int , pc_STD_HDR_SIZE :: Int , pc_PROF_HDR_SIZE :: Int , pc_BLOCK_SIZE :: Int ... } The first field has no use and according to (removed) comments it was to make code generator's work easier.. if anything this version is simpler because it has less repetition (the commas in strings are gone). - - - - - b0fdd7fe by Alp Mestanogullari at 2019-09-07T04:50:59-04:00 hadrian: fix _build/ghc-stage1 to make it callable from any directory - - - - - 51379b89 by Ömer Sinan Ağacan at 2019-09-08T21:40:32-04:00 Add a new flag -dno-typeable-binds for debugging See the user manual entry -- this helps when debugging as generated Core gets smaller without these bindings. - - - - - d0b45ac6 by Moritz Kiefer at 2019-09-08T21:41:12-04:00 Fix GHC version guard for Int32Rep/Word32Rep Those constructors have been added after GHC 8.8. The version guards in `binary` are correct, see https://github.com/kolmodin/binary/pull/167/files. - - - - - 4cf91d1a by Daniel Gröber at 2019-09-09T05:42:33-04:00 Use lazyness for FastString's z-encoding memoization Having an IORef in FastString to memoize the z-encoded version is unecessary because there is this amazing thing Haskell can do natively, it's called "lazyness" :) We simply remove the UNPACK and strictness annotations from the constructor field corresponding to the z-encoding, making it lazy, and store the (pure) z-encoded string there. The only complication here is 'hasZEncoding' which allows cheking if a z-encoding was computed for a given string. Since this is only used for compiler performance statistics though it's not actually necessary to have the current per-string granularity. Instead I add a global IORef counter to the FastStringTable and use unsafePerformIO to increment the counter whenever a lazy z-encoding is forced. - - - - - f5e2fde4 by Daniel Gröber at 2019-09-09T05:42:33-04:00 Update FastString docstrings 1) FastStrings are always UTF-8 encoded now. 2) Clarify what is meant by "hashed" 3) Add mention of lazy z-enc - - - - - 270fbe85 by Ryan Scott at 2019-09-09T05:43:12-04:00 Replace queryCygwinTerminal with Win32's isMinTTYHandle `SysTools.Terminal.queryCygwinTerminal` now exists in the `Win32` library under the name `isMinTTYHandle` since `Win32-2.5.0.0`. (GHC 8.4.4 ships with `Win32-2.6.1.0`, so this is well within GHC's support window.) We can therefore get replace `queryCygwinTerminal` with `isMinTTYHandle` and delete quite a bit of code from `SysTools.Terminal` in the process. Along the way I needed to replace some uses of `#if defined x` with `#if defined(x)` to please the CI linters. - - - - - 447864a9 by Sylvain Henry at 2019-09-10T00:04:50+02:00 Module hierarchy: StgToCmm (#13009) Add StgToCmm module hierarchy. Platform modules that are used in several other places (NCG, LLVM codegen, Cmm transformations) are put into GHC.Platform. - - - - - 60c26403 by Niklas Hambüchen at 2019-09-11T09:44:23-04:00 linker: Move -optl flags to end of linker invocation. Until now, giving `-optl` linker flags to `ghc` on the command line placed them in the wrong place in the `ld` command line: They were given before all the Haskell libararies, when they should appear after. Background: Most linkers like `ld.bfd` and `ld.gold`, but not the newer LLVM `lld`, work in a way where the order of `-l` flags given matters; earlier `-lmylib1` flags are supposed to create "holes" for linker symbols that are to be filled with later `lmylib2` flags that "fill the holes" for these symbols. As discovered in https://github.com/haskell/cabal/pull/5451#issuecomment-518001240, the `-optl` flags appeared before e.g. the -lHStext-1.2.3.1 -lHSbinary-0.8.6.0 -lHScontainers-0.6.0.1 flags that GHC added at the very end. Haskell libraries typically depend on C libraries, so `-lHS*` flags will create holes for the C libraries to fill in, but that only works when those libraries' `-l` flags are given **after** the `-lHS*` flags; until now they were given before, which was wrong. This meant that Cabal's `--ld-options` flag and `ld-options` `.cabal` file field were pretty ineffective, unless you used the `--ld-option=--start-group` hack as (https://github.com/haskell/cabal/pull/5451#issuecomment-406761676) that convinces the classical linkers to not be dependent on the order of linker flags given. This commit fixes the problem by simply flipping the order, putting `-optl` flags at the end, after Haskell libraries. The code change is effectively only `args1 ++ args` -> `args ++ args1` but the commit also renames the variables for improved clarity. Simple way to test it: ghc --make Main.hs -fforce-recomp -v -optl-s on a `Main.hs` like: import qualified Data.Set as Set main = print $ Set.fromList "hello" - - - - - 7032a913 by John Ericson at 2019-09-11T09:45:02-04:00 Remove COMPILING_GHC It is no longer used. I guess we are sharing fewer headers with the RTS than the comment claims. That's a relief! - - - - - 58569a5b by Peter Trommler at 2019-09-11T09:45:47-04:00 testsuite: check for RTS linker Fixes #16833 - - - - - df6fbe03 by Luke Lau at 2019-09-11T09:46:36-04:00 Bump Hadrian's QuickCheck dependency - - - - - d9e637df by John Ericson at 2019-09-11T09:47:26-04:00 Remove dead `ncgDebugIsOn` and `NCG_DEBUG` Haven't been used since 16206a6603e87e15d61c57456267c5f7ba68050e. - - - - - 7ef6fe8f by Ben Gamari at 2019-09-11T09:48:03-04:00 SetLevels: Fix potential panic in lvlBind 3b31a94d introduced a use of isUnliftedType which can panic in the case of levity-polymorphic types. Fix this by introducing mightBeUnliftedType which returns whether the type is *guaranteed* to be lifted. - - - - - c76cc0c6 by Ömer Sinan Ağacan at 2019-09-11T19:40:06-04:00 Refactor bad coercion checking in a few places We do bad coercion checking in a few places in the compiler, but they all checked it differently: - CoreToStg.coreToStgArgs: Disallowed lifted-to-unlifted, disallowed changing prim reps even when the sizes are the same. - StgCmmExpr.cgCase: Checked primRepSlot equality. This disallowed Int to Int64 coercions on 64-bit systems (and Int to Int32 on 32-bit) even though those are fine. - CoreLint: Only place where we do this right. Full rules are explained in Note [Bad unsafe coercion]. This patch implements the check explained in Note [Bad unsafe coercion] in CoreLint and uses it in CoreToStg.coreToStgArgs and StgCmmExpr.cgCase. This fixes #16952 and unblocks !1381 (which fixes #16893). This is the most conservative and correct change I came up with that fixes #16952. One remaining problem with coercion checking is that it's currently done in seemingly random places. What's special about CoreToStg.coreToStgArgs and StgCmmExpr.cgCase? My guess is that adding assertions to those places caught bugs before so we left assertions in those places. I think we should remove these assertions and do coercion checking in CoreLint and StgLint only (#17041). - - - - - 3a7d3923 by Tamar Christina at 2019-09-11T19:40:53-04:00 Windows: make openTempFile fully atomic. - - - - - 98b0d6ee by Pranay Sashank at 2019-09-12T04:52:33-04:00 Print the correct system memory in use with +RTS -s (#17158) Use `stats.max_mem_in_use_bytes` to print the memory usage instead of `stats.max_live_bytes` which prints maximum residency. Fixes (#17158). - - - - - a06629b4 by John Ericson at 2019-09-12T04:53:13-04:00 Do not throw away backpack instantiations for module lookup cache Currently, there is only one home package so this probably doesn't matter. But if we support multiple home packages, they could differ only in arguments (same indef component being applied). It looks like it used to be this way before 4e8a0607140b23561248a41aeaf837224aa6315b, but that commit doesn't seem to comment on this change in the particular. (It's main purpose is creating the InstalledUnitId and recategorizing the UnitId expressions accordingly.) Trying this as a separate commit for testing purposes. I leave it to others to decide whether this is a good change on its own. - - - - - 09fa5654 by John Ericson at 2019-09-12T04:53:51-04:00 Remove unused `#include`s from parser/cutils.c Looks like these have been unused since 7c665f9ce0980ee7c81a44c8f861686395637453. - - - - - 2b37a79d by Sebastian Graf at 2019-09-12T14:05:29-04:00 Bump Cabal submodule to 3.1 ------------------------- Metric Increase: haddock.Cabal T4029 ------------------------- - - - - - 86753475 by Ningning Xie at 2019-09-12T14:06:07-04:00 Fix StandaloneDeriving If I understand correctly, `deriving instance _ => Eq (Foo a)` is equivalent to `data Foo a deriving Eq`, rather than `data Foo a deriving Foo`. - - - - - a733002a by Ben Gamari at 2019-09-13T03:09:47-04:00 Update mailmap - - - - - 5b64aee2 by Simon Peyton Jones at 2019-09-13T03:10:26-04:00 Fix scoping of implicit parameters There was an outright bug in TcInteract.solveOneFromTheOther which meant that we did not always pick the innermost implicit parameter binding, causing #17104. The fix is easy, just a rearrangement of conditional tests - - - - - 47b12660 by Tamar Christina at 2019-09-13T03:11:06-04:00 Windows: Fix hsc2hs non-deterministic failures. - - - - - e3a7592b by Alp Mestanogullari at 2019-09-13T03:11:50-04:00 Add a test to make sure we don't regress on #17140 in the future - - - - - 6f3cd50e by Zubin Duggal at 2019-09-13T11:24:51-04:00 Explain how to update HieAst [skip ci] - - - - - 71428a43 by Zubin Duggal at 2019-09-13T11:24:51-04:00 Address review comments [skip CI] - - - - - ccb4e646 by John Ericson at 2019-09-13T11:25:29-04:00 Compiler should always get fingerprinting impl from base 07ee15915d5a0d6d1aeee137541eec6e9c153e65 started the transition, but the job was never finished. - - - - - c45c89d6 by Ben Gamari at 2019-09-13T11:26:05-04:00 gitlab: Add issue template for documentation issues Fixes #17180. - - - - - a0e220b7 by John Ericson at 2019-09-13T11:26:43-04:00 Remove empty NCG.h - - - - - 046ca133 by Andrew Martin at 2019-09-13T15:43:16-04:00 Add predicates for testing if IOError is ResourceVanished. This adds isResourceVanished, resourceVanishedErrorType, and isResourceVanishedErrorType to System.IO.Error, resolving #14730. - - - - - bd079345 by taylorfausak at 2019-09-14T06:25:27-04:00 Fix CONLIKE typo - - - - - cf7e78a3 by Ben Gamari at 2019-09-15T23:46:36-04:00 Rename GHC.StgToCmm.Con -> GHC.StgToCmm.DataCon Incredibly, Windows disallows the manipulation of any file matching Con(\..*)?. The `GHC.StgToCmm.Con` was introduced in the renamings in 447864a9, breaking the Windows build. Work around this by renaming it to `GHC.StgToCmm.DataCon` Fixes #17187. - - - - - 7208160d by Sylvain Henry at 2019-09-15T23:47:22-04:00 Fix Hadrian build with Stack (#17189) Broken by 2b37a79d61e9b3787873dc9f7458ef2bde4809b0 - - - - - b5ae3868 by Sylvain Henry at 2019-09-16T13:32:22-04:00 Allow validation with Hadrian built with Stack [skip ci] - - - - - 7915afc6 by Sebastian Graf at 2019-09-16T13:33:05-04:00 Encode shape information in `PmOracle` Previously, we had an elaborate mechanism for selecting the warnings to generate in the presence of different `COMPLETE` matching groups that, albeit finely-tuned, produced wrong results from an end user's perspective in some cases (#13363). The underlying issue is that at the point where the `ConVar` case has to commit to a particular `COMPLETE` group, there's not enough information to do so and the status quo was to just enumerate all possible complete sets nondeterministically. The `getResult` function would then pick the outcome according to metrics defined in accordance to the user's guide. But crucially, it lacked knowledge about the order in which affected clauses appear, leading to the surprising behavior in #13363. In !1010 we taught the term oracle to reason about literal values a variable can certainly not take on. This MR extends that idea to `ConLike`s and thereby fixes #13363: Instead of committing to a particular `COMPLETE` group in the `ConVar` case, we now split off the matching constructor incrementally and record the newly covered case as a refutable shape in the oracle. Whenever the set of refutable shapes covers any `COMPLETE` set, the oracle recognises vacuosity of the uncovered set. This patch goes a step further: Since at this point the information in value abstractions is merely a cut down representation of what the oracle knows, value abstractions degenerate to a single `Id`, the semantics of which is determined by the oracle state `Delta`. Value vectors become lists of `[Id]` given meaning to by a single `Delta`, value set abstractions (of which the uncovered set is an instance) correspond to a union of `Delta`s which instantiate the same `[Id]` (akin to models of formula). Fixes #11528 #13021, #13363, #13965, #14059, #14253, #14851, #15753, #17096, #17149 ------------------------- Metric Decrease: ManyAlternatives T11195 ------------------------- - - - - - ae4415b9 by Matthew Pickering at 2019-09-17T19:21:10-04:00 eventlog: Add biographical and retainer profiling traces This patch adds a new eventlog event which indicates the start of a biographical profiler sample. These are different to normal events as they also include the timestamp of when the census took place. This is because the LDV profiler only emits samples at the end of the run. Now all the different profiling modes emit consumable events to the eventlog. - - - - - 9c21b2fd by Richard Eisenberg at 2019-09-17T19:22:00-04:00 Fix #13571 by adding an extension flag check Test case: indexed-types/should_fail/T13571 - - - - - 8039b125 by Simon Peyton Jones at 2019-09-17T19:22:50-04:00 Comments only - - - - - 1c3af277 by Simon Peyton Jones at 2019-09-17T19:23:37-04:00 Improve error message for out-of-scope variables + VTA As #13834 and #17150 report, we get a TERRIBLE error message when you have an out of scope variable applied in a visible type application: (outOfScope @Int True) This very simple patch improves matters. See TcExpr Note [VTA for out-of-scope functions] - - - - - c77fc3b2 by John Ericson at 2019-09-17T19:24:20-04:00 Deduplicate `HaskellMachRegs.h` and `RtsMachRegs.h` headers Until 0472f0f6a92395d478e9644c0dbd12948518099f there was a meaningful host vs target distinction (though it wasn't used right, in genapply). After that, they did not differ in meaningful ways, so it's best to just only keep one. - - - - - c3eaaca6 by Simon Peyton Jones at 2019-09-19T09:03:19-04:00 Add a missing update of sc_hole_ty (#16312) In simplCast I totally failed to keep the sc_hole_ty field of ApplyToTy (see Note [The hole type in ApplyToTy]) up to date. When a cast goes by, of course the hole type changes. Amazingly this has not bitten us before, but #16312 finally triggered it. Fortunately the fix is simple. Fixes #16312. - - - - - de1723b2 by Ben Gamari at 2019-09-19T09:03:19-04:00 Simplify: Lazy pattern match - - - - - d9c6b86e by Richard Eisenberg at 2019-09-19T09:04:03-04:00 Refactor kindGeneralize and friends This commit should have no change in behavior.(*) The observation was that Note [Recipe for checking a signature] says that every metavariable in a type-checked type must either (A) be generalized (B) be promoted (C) be zapped. Yet the code paths for doing these were all somewhat separate. This led to some steps being skipped. This commit shores this all up. The key innovation is TcHsType.kindGeneralizeSome, with appropriate commentary. This commit also sets the stage for #15809, by turning the WARNing about bad level-numbers in generalisation into an ASSERTion. The actual fix for #15809 will be in a separate commit. Other changes: * zonkPromoteType is now replaced by kindGeneralizeNone. This might have a small performance degradation, because zonkPromoteType zonked and promoted all at once. The new code path promotes first, and then zonks. * A call to kindGeneralizeNone was added in tcHsPartialSigType. I think this was a lurking bug, because it did not follow Note [Recipe for checking a signature]. I did not try to come up with an example showing the bug. This is the (*) above. Because of this change, there is an error message regression in partial-sigs/should_fail/T14040a. This problem isn't really a direct result of this refactoring, but is a symptom of something deeper. See #16775, which addresses the deeper problem. * I added a short-cut to quantifyTyVars, in case there's nothing to quantify. * There was a horribly-outdated Note that wasn't referred to. Gone now. * While poking around with T14040a, I discovered a small mistake in the Coercion.simplifyArgsWorker. Easy to fix, happily. * See new Note [Free vars in coercion hole] in TcMType. Previously, we were doing the wrong thing when looking at a coercion hole in the gather-candidates algorithm. Fixed now, with lengthy explanation. Metric Decrease: T14683 - - - - - f594a68a by Richard Eisenberg at 2019-09-19T09:04:03-04:00 Use level numbers for generalisation This fixes #15809, and is covered in Note [Use level numbers for quantification] in TcMType. This patch removes the "global tyvars" from the environment, a nice little win. - - - - - c675d08f by Richard Eisenberg at 2019-09-19T09:04:03-04:00 Test #17077. - - - - - 912afaf4 by Ben Gamari at 2019-09-19T09:04:39-04:00 CoreUtils: Use mightBeUnliftedType in exprIsTopLevelBindable Also add reference from isUnliftedType to mightBeUnliftedType. - - - - - baf47661 by Sebastian Graf at 2019-09-19T09:05:20-04:00 Extract PmTypes module from PmExpr and PmOracle Apparently ghc-lib-parser's API blew up because the newly induced cyclic dependency between TcRnTypes and PmOracle pulled in the other half of GHC into the relevant strongly-connected component. This patch arranges it so that PmTypes exposes mostly data type definitions and type class instances to be used within PmOracle, without importing the any of the possibly offending modules DsMonad, TcSimplify and FamInst. - - - - - 2a8867cf by Sebastian Graf at 2019-09-19T09:05:58-04:00 Add a regression test for #11822 The particular test is already fixed, but the issue seems to have multiple different test cases lumped together. - - - - - 52173990 by Ben Gamari at 2019-09-19T09:06:36-04:00 testsuite: Add testcase for #17206 - - - - - b3e5c731 by Alp Mestanogullari at 2019-09-19T21:42:17-04:00 ErrUtils: split withTiming into withTiming and withTimingSilent 'withTiming' becomes a function that, when passed '-vN' (N >= 2) or '-ddump-timings', will print timing (and possibly allocations) related information. When additionally built with '-eventlog' and executed with '+RTS -l', 'withTiming' will also emit both 'traceMarker' and 'traceEvent' events to the eventlog. 'withTimingSilent' on the other hand will never print any timing information, under any circumstance, and will only emit 'traceEvent' events to the eventlog. As pointed out in !1672, 'traceMarker' is better suited for things that we might want to visualize in tools like eventlog2html, while 'traceEvent' is better suited for internal events that occur a lot more often and that we don't necessarily want to visualize. This addresses #17138 by using 'withTimingSilent' for all the codegen bits that are expressed as a bunch of small computations over streams of codegen ASTs. - - - - - 4853d962 by Ben Gamari at 2019-09-19T21:42:55-04:00 users guide: Fix link to let generalization blog post Fixes #17200. - - - - - 51192964 by Sylvain Henry at 2019-09-20T05:14:34-04:00 Module hierarchy: Hs (#13009) Add GHC.Hs module hierarchy replacing hsSyn. Metric Increase: haddock.compiler - - - - - 2f8ce45a by Ben Gamari at 2019-09-20T05:15:11-04:00 testsuite: Add test for #17202 - - - - - f257bf73 by Matthew Pickering at 2019-09-20T05:15:52-04:00 hadrian/ghci.sh: Enable building in parallel - - - - - 070f7b85 by Matthew Pickering at 2019-09-20T05:15:52-04:00 Remove trailing whitespace - - - - - 5390b553 by Matthew Pickering at 2019-09-20T05:15:52-04:00 Pass -j to ghc-in-ghci CI job - - - - - 1b7e1d31 by John Ericson at 2019-09-20T05:16:36-04:00 Remove pointless partiality in `Parser.ajs` - - - - - 17554248 by Simon Peyton Jones at 2019-09-20T10:50:21+01:00 Fix PmOracle.addVarCoreCt in-scope set PmOracle.addVarCoreCt was giving a bogus (empty) in-scope set to exprIsConApp_maybe, which resulted in a substitution-invariant failure (see MR !1647 discussion). This patch fixes it, by taking the free vars of the expression. - - - - - 0dad81ca by Simon Peyton Jones at 2019-09-20T10:50:21+01:00 Fix bogus type of case expression Issue #17056 revealed that we were sometimes building a case expression whose type field (in the Case constructor) was bogus. Consider a phantom type synonym type S a = Int and we want to form the case expression case x of K (a::*) -> (e :: S a) We must not make the type field of the Case constructor be (S a) because 'a' isn't in scope. We must instead expand the synonym. Changes in this patch: * Expand synonyms in the new function CoreUtils.mkSingleAltCase. * Use mkSingleAltCase in MkCore.wrapFloat, which was the proximate source of the bug (when called by exprIsConApp_maybe) * Use mkSingleAltCase elsewhere * Documentation CoreSyn new invariant (6) in Note [Case expression invariants] CoreSyn Note [Why does Case have a 'Type' field?] CoreUtils Note [Care with the type of a case expression] * I improved Core Lint's error reporting, which was pretty confusing in this case, because it didn't mention that the offending type was the return type of a case expression. * A little bit of cosmetic refactoring in CoreUtils - - - - - 1ea8c451 by Sebastian Graf at 2019-09-21T09:52:34-04:00 PredType for type constraints in the pattern match checker instead of EvVar Using EvVars for capturing type constraints implied side-effects in DsM when we just wanted to *construct* type constraints. But giving names to type constraints is only necessary when passing Givens to the type checker, of which the majority of the pattern match checker should be unaware. Thus, we simply generate `newtype TyCt = TyCt PredType`, which are nicely stateless. But at the same time this means we have to allocate EvVars when we want to query the type oracle! So we keep the type oracle state as `newtype TyState = TySt (Bag EvVar)`, which nicely makes a distinction between new, unchecked `TyCt`s and the inert set in `TyState`. - - - - - ded96fb3 by Ömer Sinan Ağacan at 2019-09-21T09:53:29-04:00 Document MIN_PAYLOAD_SIZE and mark-compact GC mark bits This updates the documentation of the MIN_PAYLOAD_SIZE constant and adds a new Note [Mark bits in mark-compact collector] explaning why the mark-compact collector uses two bits per objet and why we need MIN_PAYLOAD_SIZE. - - - - - a7867c79 by Sebastian Graf at 2019-09-21T14:56:58+01:00 Get rid of PmFake The pattern match oracle can now cope with the abundance of information that ViewPatterns, NPlusKPats, overloaded lists, etc. provide. No need to have PmFake anymore! Also got rid of a spurious call to `allCompleteMatches`, which we used to call *for every constructor* match. Naturally this blows up quadratically for programs like `ManyAlternatives`. ------------------------- Metric Decrease: ManyAlternatives Metric Increase: T11822 ------------------------- - - - - - fa66e3e5 by Alp Mestanogullari at 2019-09-21T23:31:08-04:00 Fix haddocks for marker events in Debug.Trace - - - - - da12da79 by Daniel Gröber at 2019-09-22T14:34:56+02:00 rts: retainer: Remove cStackSize debug counter This can only ever be one since 5f1d949ab9 ("Remove explicit recursion in retainer profiling"), so it's pointless. - - - - - 3ebaa4b5 by Daniel Gröber at 2019-09-22T15:17:53+02:00 rts: Remove bitrotten retainer debug code The `defined(DEBUG_RETAINER) == true` branch doesn't even compile anymore because 1) retainerSet was renamed to RetainerSet and 2) even if I fix that the context in Rts.h seems to have changed such that it's not in scope. If 3) I fix that 'flip' is still not in scope :) At that point I just gave up. - - - - - 63023dc2 by Daniel Gröber at 2019-09-22T15:18:09+02:00 rts: Fix outdated references to 'ldvTime' This got renamed to 'era' in dbef766ce7 ("[project @ 2001-11-26 16:54:21 by simonmar] Profiling cleanup"). - - - - - ead05f80 by Daniel Gröber at 2019-09-22T15:18:09+02:00 rts: retainer: Turn global traversal state into a struct Global state is ugly and hard to test. Since the profiling code isn't quite as performance critical as, say, GC we should prefer better code here. I would like to move the 'flip' bit into the struct too but that's complicated by the fact that the defines which use it directly are also called from ProfHeap where the traversalState is not easily available. Maybe in a future commit. - - - - - 94ecdb4f by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move info.next.parent to stackElement I don't see a point in having this live in 'info', just seems to make the code more complicated. - - - - - f79ac2ef by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Generalise per-stackElement data This essentially ammounts to s/retainer/stackData/, s/c_child_r/data/ and some temporary casting of c_child_r to stackData until refactoring of this module is completed by a subsequent commit. We also introduce a new union 'stackData' which will contain the actual extra data to be stored on the stack. The idea is to make the heap traversal logic of the retainer profiler ready for extraction into it's own module. So talking about "retainers" there doesn't really make sense anymore. Essentially the "retainers" we store in the stack are just data associated with the push()ed closures which we return when pop()ing it. - - - - - f083358b by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Fix comment typo s/keeps/keep/ - - - - - 2f2f6dd5 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: Generalise profiling heap traversal flip bit handling This commit starts renaming some flip bit related functions for the generalised heap traversal code and adds provitions for sharing the per-closure profiling header field currently used exclusively for retainer profiling with other heap traversal profiling modes. - - - - - e40b3c23 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: GC: Remove redundant #include "RetainerProfiler.h" - - - - - b03db9da by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Pull retainer specific code into a callback This essentially turns the heap traversal code into a visitor. You add a bunch of roots to the work-stack and then the callback you give to traverseWorkStack() will be called with every reachable closure at least once. - - - - - 48e816f0 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: simplify pop() control flow Instead of breaking out of the switch-in-while construct using `return` this uses `goto out` which makes it possible to share a lot of the out-variable assignment code in all the cases. I also replaced the nasty `while(true)` business by the real loop condition: `while(*c == NULL)`. All `break` calls inside the switch aready have either a check for NULL or an assignment of `c` to NULL so this should not change any behaviour. Using `goto out` also allowed me to remove another minor wart: In the MVAR_*/WEAK cases the popOff() call used to happen before reading the stackElement. This looked like a use-after-free hazard to me as the stack is allocated in blocks and depletion of a block could mean it getting freed and possibly overwritten by zero or garbage, depending on the block allocator's behaviour. - - - - - b92ed68a by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: Add note reference to SET_PROF_HDR for profiling 'flip' bit - - - - - f3bb7397 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerSet: Remove obsolete fist/second-approach choice In the old code when DEBUG_RETAINER was set, FIRST_APPROACH is implied. However ProfHeap.c now depends on printRetainerSetShort which is only available with SECOND_APPROACH. This is because with FIRST_APPROACH retainerProfile() will free all retainer sets before returning so by the time ProfHeap calls dumpCensus the retainer set pointers are segfaulty. Since all of this debugging code obviously hasn't been compiled in ages anyways I'm taking the liberty of just removing it. Remember guys: Dead code is a liability not an asset :) - - - - - ec1d76e2 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Remove obsolete debug code Commit dbef766ce7 ("Profiling cleanup.") made this debug code obsolete by removing the 'cost' function without a replacement. As best I can tell the retainer profiler used to do some heap census too and this debug code was mainly concerned with that. - - - - - b7e15d17 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Rename heap traversal functions for extraction This gets all remaining functions in-line with the new 'traverse' prefix and module name. - - - - - 64ec45a7 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Reduce DEBUG_RETAINER ifdef noise Keeping track of the maximum stack seems like a good idea in all configurations. The associated ASSERTs only materialize in debug mode but having the statistic is nice. To make the debug code less prone to bitrotting I introduce a function 'debug()' which doesn't actually print by default and is #define'd away only when the standard DEBUG define is off. - - - - - bd78b696 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Cleanup comments and strings for traversal extraction A lot of comments and strings are still talking about old names, fix that. - - - - - cb7220b3 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Remove outdated invariants on traversePushStack These invariants don't seem to make any sense in the current code. The text talks about c_child_r as if it were an StgClosure, for which RSET() would make sense, but it's a retainer aka 'CostCentreStack*'. - - - - - bb92660c by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Use global STATIC_INLINE macro STATIC_INLINE already does what the code wanted here, no need to duplicate the functionality here. - - - - - 2b76cf9e by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move heap traversal declarations to new header - - - - - 44d5cc0d by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Abstract maxStackSize for generic traversal - - - - - fd213d17 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Update obsolete docs for traverseMaybeInitClosureData - - - - - 39f2878c by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move actual 'flip' bit flip to generic traversal code - - - - - f9b4c4f2 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Remove traverse-stack chunk support There's simply no need anymore for this whole business. Instead of individually traversing roots in retainRoot() we just push them all onto the stack and traverse everything in one go. This feature was not really used anyways. There is an `ASSERT(isEmptyWorkStack(ts))` at the top of retainRoot() which means there really can't ever have been any chunks at the toplevel. The only place where this was probably used is in traversePushStack but only way back when we were still using explicit recursion on the C callstack. Since the code was changed to use an explicit traversal-stack these stack-chunks can never escape one call to traversePushStack anymore. See commit 5f1d949ab9 ("Remove explicit recursion in retainer profiling") - - - - - c7def600 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move mut_list reset to generic traversal code - - - - - 9bf27060 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Make visit callback easier to implement Currently it is necessary for user code to expend at least one extra bit in the closure header just to know whether visit() should return true or false, to indicate if children should be traversed. The generic traversal code already has this information in the visited bit so simply pass it to the visit callback. - - - - - 96adf179 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Improve Note [Profiling heap traversal visited bit] - - - - - 187192a6 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerProfile.c: Re-enable and fix warnings Turns out some genius disabled warnings for RetainerProfile.c in the build system. That would have been good to know about five silent type mismatch crashes ago.. :) - - - - - eb29735e by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerProfile.c: Minimize #includes A lot of these includes are presumably leftovers from when the retainer profiler still did it's own heap profiling. - - - - - 383f9089 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: Split heap traversal from retainer profiler This finally moves the newly generalised heap traversal code from the retainer profiler into it's own file. - - - - - 52c5ea71 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: TraverseHeap: Make comment style consistent - - - - - 75355228 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: TraverseHeap: Make pushStackElement argument const - - - - - a8137780 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: TraverseHeap: Move stackElement.cp back into nextPos union The 'cp' field really is only used when type==posTypeFresh so it's more space efficient to have it in the nextPos union. - - - - - 7f10cc2d by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerProfile: Explain retainVisitClosure return values [ci skip] - - - - - 111f2761 by Daniel Gröber at 2019-09-22T15:33:41+02:00 rts: TraverseHeap: Add doc comment for getTraverseStackMaxSize - - - - - 68ddb43c by Ben Gamari at 2019-09-23T00:34:00-04:00 gitlab-ci: Fix URL of Windows cabal-install tarball - - - - - 0e478407 by Takenobu Tani at 2019-09-23T17:51:37-04:00 users-guide: Fix links and formats for GHC 8.10 This commit only fixes links and markdown syntax. [skip ci] - - - - - 74631bbc by Adam Sandberg Eriksson at 2019-09-23T17:52:32-04:00 base: add newtypes for socklen_t and ndfs_t to System.Posix.Types #16568 Metric Increase: haddock.base T4029 - - - - - 4470a144 by Björn Gohla at 2019-09-23T17:53:23-04:00 add Hadrian rule to build user guide as Info book - - - - - dbbea5a8 by Björn Gohla at 2019-09-23T17:53:23-04:00 use the Make builder instead of raw cmd_ - - - - - b0e3b173 by Björn Gohla at 2019-09-23T17:53:23-04:00 detect makeinfo in configure(.ac) - - - - - 9fe4d2df by Björn Gohla at 2019-09-23T17:53:23-04:00 explicit dependence on makeinfo - - - - - b650c2b6 by Björn Gohla at 2019-09-23T17:53:23-04:00 alphabetical ordering - - - - - 27789294 by Björn Gohla at 2019-09-23T17:53:23-04:00 sort-paragraphs in runBuilderWith - - - - - d0c2f3a2 by Artem Pyanykh at 2019-09-23T17:54:04-04:00 [hadrian] Rebuild programs on dynamicGhcPrograms/ghcProfiled change Currently, if you change these ^ flavour parameters, rebuilding is not triggered, since `programContext` doesn't set up a dependency on those values. Exposing these values via an oracle does set the dependency and properly triggers a rebuild of binaries. Several attempts to factor out these actions ended up in cyclic dependency here or there. I'm not absolutely happy with this variant either, but at least it works. ==== Issue repro: In UserSettings.hs: ``` dbgDynamic = defaultFlavour { name = "dbg-dynamic" , dynamicGhcPrograms = pure True, ... } dbgStatic = defaultFlavour { name = "dbg-static" , dynamicGhcPrograms = pure False ... } ``` Then in console: ``` $ hadrian/build.sh -j --flavour=dbg-dynamic ... does the build $ hadrian/build.sh -j --flavour=dbg-static ... does nothing, considers binaries up to date ``` - - - - - 238b58e4 by Kari Pahula at 2019-09-23T17:54:42-04:00 Add -fkeep-going to make compiler continue despite errors (#15424) Add a new optional failure handling for upsweep which continues the compilation on other modules if any of them has errors. - - - - - 146f26cc by Sebastian Graf at 2019-09-24T01:06:40-04:00 Some leftovers from !1732. Comments only [skip ci] - - - - - b5f24fb4 by Takenobu Tani at 2019-09-24T01:07:19-04:00 Hadrian: Add -haddock option for GHCi's :doc command This commit adds -haddock option to Hadrian-based build system. To enable :doc command on GHCi, core libraries must be compiled with -haddock option. Especially, the `-haddock` option is essential for a release build. Assuming current GitLab CI condition (.gitlab-ci.yml), I add -haddock option to the default flavour only. This has already been done for Make-based build system. Please see #16415. - - - - - f97a7aac by Sebastian Graf at 2019-09-24T01:07:57-04:00 Fix some duplication in the parser D3673 experienced reduce/reduce conflicts when trying to use opt_instance for associated data families. That was probably because the author tried to use it for Haskell98-syntax without also applying it to GADT-syntax, which actually leads to a reduce/reduce conflict. Consider the following state: ``` data . T = T data . T where T :: T ``` The parser must decide at this point whether or not to reduce an empty `opt_instance`. But doing so would also commit to either Haskell98 or GADT syntax! Good thing we also accept an optional "instance" for GADT syntax, so the `opt_instance` is there in both productions and there's no reduce/reduce conflict anymore. Also no need to inline `opt_instance`, how it used to be. - - - - - b23f01fd by Ben Gamari at 2019-09-24T08:49:43-04:00 base: Add link to "A reflection on types" Fixes #17181. - - - - - 4bbe0dba by Ben Gamari at 2019-09-24T08:50:20-04:00 gitlab-ci: Bump ci-images This bumps the CI Docker images to ghc/ci-images at 990c5217d1d0e03aea415f951afbc3b1a89240c6. - - - - - 6bca867c by Ben Gamari at 2019-09-24T08:50:59-04:00 hadrian: Update source-repository - - - - - b2d47536 by Ben Gamari at 2019-09-24T08:51:45-04:00 testsuite: Mark threadstatus-9333 as fragile in profthreaded Due to #16555. - - - - - ed520678 by Andreas Klebinger at 2019-09-24T21:08:42-04:00 Fix bounds check in ocResolve_PEi386 for relocation values. The old test was wrong at least for gcc and the value -2287728808L. It also relied on implementation defined behaviour (right shift on a negative value), which might or might not be ok. Either way it's now a simple comparison which will always work. - - - - - 218c5dbf by Matthew Pickering at 2019-09-24T21:09:23-04:00 Add ghcide configuration files This commit adds three new files 1. A hie.yaml file to the project root which specifies to IDEs how to set up the correct environment for loading GHC. This currently specifies to call the `./hadrian/hie-bios` script. 2. A `hie.yaml` file for the hadrian subcomponent, which uses the `cabal` cradle type. 2. The `./hadrian/hie-bios` script which supplies the correct arguments for an IDE to start a session. With these two files it is possible to run ``` ghcide compiler/ ``` and successfully load all the modules for use in the IDE. or ``` ghcide --cwd hadrian/ src/ ``` to test loading all of Hadrian's modules. Closes #17194 - - - - - 2970dc7a by Kari Pahula at 2019-09-25T13:52:48-04:00 Add -Wderiving-defaults (#15839) Enabling both DeriveAnyClass and GeneralizedNewtypeDeriving can cause a warning when no explicit deriving strategy is in use. This change adds an enable/suppress flag for it. - - - - - 4540bbe2 by John Ericson at 2019-09-25T13:53:42-04:00 includes/CodeGen.Platform.hs don't include ghcautoconf.h It doesn't need it, and it shouldn't need it or else multi-target will break. - - - - - ebc65025 by Sebastian Graf at 2019-09-25T13:54:22-04:00 PmCheck: Only ever check constantly many models against a single pattern Introduces a new flag `-fmax-pmcheck-deltas` to achieve that. Deprecates the old `-fmax-pmcheck-iter` mechanism in favor of this new flag. >From the user's guide: Pattern match checking can be exponential in some cases. This limit makes sure we scale polynomially in the number of patterns, by forgetting refined information gained from a partially successful match. For example, when matching `x` against `Just 4`, we split each incoming matching model into two sub-models: One where `x` is not `Nothing` and one where `x` is `Just y` but `y` is not `4`. When the number of incoming models exceeds the limit, we continue checking the next clause with the original, unrefined model. This also retires the incredibly hard to understand "maximum number of refinements" mechanism, because the current mechanism is more general and should catch the same exponential cases like PrelRules at the same time. ------------------------- Metric Decrease: T11822 ------------------------- - - - - - d90d0bad by Ben Gamari at 2019-09-25T13:55:09-04:00 base: Move Ix typeclass to GHC.Ix The `Ix` class seems rather orthogonal to its original home in `GHC.Arr`. - - - - - 795986aa by Ryan Scott at 2019-09-25T13:56:07-04:00 Remove unneeded CPP now that GHC 8.6 is the minimum The minimum required GHC version for bootstrapping is 8.6, so we can get rid of some unneeded `#if `__GLASGOW_HASKELL__` CPP guards, as well as one `MIN_VERSION_ghc_prim(0,5,3)` guard (since GHC 8.6 bundles `ghc-prim-0.5.3`). - - - - - 0b5eede9 by Vladislav Zavialov at 2019-09-25T21:06:04+03:00 Standalone kind signatures (#16794) Implements GHC Proposal #54: .../ghc-proposals/blob/master/proposals/0054-kind-signatures.rst With this patch, a type constructor can now be given an explicit standalone kind signature: {-# LANGUAGE StandaloneKindSignatures #-} type Functor :: (Type -> Type) -> Constraint class Functor f where fmap :: (a -> b) -> f a -> f b This is a replacement for CUSKs (complete user-specified kind signatures), which are now scheduled for deprecation. User-facing changes ------------------- * A new extension flag has been added, -XStandaloneKindSignatures, which implies -XNoCUSKs. * There is a new syntactic construct, a standalone kind signature: type <name> :: <kind> Declarations of data types, classes, data families, type families, and type synonyms may be accompanied by a standalone kind signature. * A standalone kind signature enables polymorphic recursion in types, just like a function type signature enables polymorphic recursion in terms. This obviates the need for CUSKs. * TemplateHaskell AST has been extended with 'KiSigD' to represent standalone kind signatures. * GHCi :info command now prints the kind signature of type constructors: ghci> :info Functor type Functor :: (Type -> Type) -> Constraint ... Limitations ----------- * 'forall'-bound type variables of a standalone kind signature do not scope over the declaration body, even if the -XScopedTypeVariables is enabled. See #16635 and #16734. * Wildcards are not allowed in standalone kind signatures, as partial signatures do not allow for polymorphic recursion. * Associated types may not be given an explicit standalone kind signature. Instead, they are assumed to have a CUSK if the parent class has a standalone kind signature and regardless of the -XCUSKs flag. * Standalone kind signatures do not support multiple names at the moment: type T1, T2 :: Type -> Type -- rejected type T1 = Maybe type T2 = Either String See #16754. * Creative use of equality constraints in standalone kind signatures may lead to GHC panics: type C :: forall (a :: Type) -> a ~ Int => Constraint class C a where f :: C a => a -> Int See #16758. Implementation notes -------------------- * The heart of this patch is the 'kcDeclHeader' function, which is used to kind-check a declaration header against its standalone kind signature. It does so in two rounds: 1. check user-written binders 2. instantiate invisible binders a la 'checkExpectedKind' * 'kcTyClGroup' now partitions declarations into declarations with a standalone kind signature or a CUSK (kinded_decls) and declarations without either (kindless_decls): * 'kinded_decls' are kind-checked with 'checkInitialKinds' * 'kindless_decls' are kind-checked with 'getInitialKinds' * DerivInfo has been extended with a new field: di_scoped_tvs :: ![(Name,TyVar)] These variables must be added to the context in case the deriving clause references tcTyConScopedTyVars. See #16731. - - - - - 4f81fab0 by Ryan Scott at 2019-09-26T14:04:38-04:00 Make -fbyte-code prevent unboxed tuples/sums from implying object code (#16876) This resolves #16876 by making the explicit use of `-fbyte-code` prevent code that enables `UnboxedTuples` or `UnboxedSums` from automatically compiling to object code. This allows for a nice middle ground where most code that enables `UnboxedTuples`/-`Sums` will still benefit from automatically enabling `-fobject-code`, but allows power users who wish to avoid this behavior in certain corner cases (such as `lens`, whose use case is documented in #16876) to do so. Along the way, I did a little cleanup of the relevant code and documentation: * `enableCodeGenForUnboxedTuples` was only checking for the presence of `UnboxedTuples`, but `UnboxedSums` has the same complications. I fixed this and renamed the function to `enableCodeGenForUnboxedTuplesOrSums`. * I amended the users' guide with a discussion of these issues. - - - - - 289fc8da by Sebastian Graf at 2019-09-27T22:10:17-04:00 PmCheck: Elaborate what 'model' means in the user guide [skip ci] - - - - - 9c02a793 by Ron Mordechai at 2019-09-27T22:11:06-04:00 Allow users to disable Unicode with an env var Unicode renders funny on my terminal and I like to avoid it where possible. Most applications which print out non-ascii characters allow users to disable such prints with an environment variable (e.g. Homebrew). This diff disables Unicode usage when the environment variable `GHC_NO_UNICODE` is set. To test, set the env var and compile a bad program. Note that GHC does not print Unicode bullets but instead prints out asterisks: ``` $ GHC_NO_UNICODE= _build/stage1/bin/ghc ../Temp.hs [1 of 1] Compiling Temp ( ../Temp.hs, ../Temp.o ) ../Temp.hs:4:23: error: * Couldn't match type `Bool' with `a -> Bool' Expected type: Bool -> a -> Bool Actual type: Bool -> Bool * In the first argument of `foldl', namely `(&& (flip $ elem u))' In the expression: foldl (&& (flip $ elem u)) True v In an equation for `isPermut': isPermut u v = foldl (&& (flip $ elem u)) True v * Relevant bindings include v :: [a] (bound at ../Temp.hs:4:12) u :: [a] (bound at ../Temp.hs:4:10) isPermut :: [a] -> [a] -> Bool (bound at ../Temp.hs:4:1) | 4 | isPermut u v = foldl (&& (flip $ elem u)) True v | ^^^^^^^^^^^^^^^^^^ ``` (Broken code taken from Stack Overflow) - - - - - 144abba3 by Ben Gamari at 2019-09-27T22:11:53-04:00 configure: Don't depend upon alex in source dist build This fixes #16860 by verifying that the generated sources don't already exist before asserting that the `alex` executable was found. This replicates the logic already used for `happy` in the case of `alex`. - - - - - c6fb913c by John Ericson at 2019-09-27T22:12:35-04:00 Just get RTS libs from its package conf `rts.conf` already contains this exact information in its `extra-libraries` stanza. - - - - - f07862b4 by Ben Gamari at 2019-09-27T22:13:16-04:00 ghc-prim: Fix documentation of Type As pointed out in #17243, `Type` is not the only kind having values. - - - - - 0201d0bf by chris-martin at 2019-09-27T22:14:00-04:00 Clarify the purpose and status of the GHC.TypeLits module - - - - - 444e554f by chris-martin at 2019-09-27T22:14:00-04:00 Expand description of DataKinds to mention data constructors, and include mention of TypeError - - - - - 1582dafa by Sebastian Graf at 2019-09-27T22:14:44-04:00 PmCheck: Look at precendence to give type signatures to some wildcards Basically do what we currently only do for -XEmptyCase in other cases where adding the type signature won't distract from pattern matches in other positions. We use the precedence to guide us, equating "need to parenthesise" with "too much noise". - - - - - ad0c4390 by Shayne Fletcher at 2019-09-27T22:15:27-04:00 Add test for expected dependencies of 'Parser' - - - - - 0b1fa64d by Ben Gamari at 2019-09-27T22:16:04-04:00 testsuite: Mark cgrun071 as broken on i386 As described in #17247. - - - - - 24620182 by Daniel Gröber at 2019-09-27T22:17:04-04:00 Raise minimum GHC version to 8.6 commit 795986aaf33e ("Remove unneeded CPP now that GHC 8.6 is the minimum") broke the 8.4 build. - - - - - e0bbb961 by Ben Gamari at 2019-09-27T22:17:44-04:00 testsuite: Mark compact_gc as fragile in the ghci way As noted in #17253. - - - - - bb984ac6 by Ben Gamari at 2019-09-27T22:18:42-04:00 testsuite: Mark hs_try_putmvar003 as fragile in threaded1 Due to #16361. Note that I'm leaving out threaded2 since it's not clear whether the single crash in that way was due to other causes. - - - - - ad2a1f99 by Ben Gamari at 2019-09-27T22:19:26-04:00 testsuite: Mark T3389 as broken in profiled ways on i386 As noted in #17256. - - - - - 6f9fa0be by Ben Gamari at 2019-09-27T22:20:04-04:00 testsuite: Mark TH tests as fragile in LLVM built external-interpreter Due to #16087. This drops the previous explicit list of broken tests and rather encompasses the entire set of tests since they all appear to be broken. - - - - - c5d888d4 by Sebastian Graf at 2019-09-28T17:11:41-04:00 PmCheck: No ConLike instantiation in pmcheck `pmcheck` used to call `refineToAltCon` which would refine the knowledge we had about a variable by equating it to a `ConLike` application. Since we weren't particularly smart about this in the Check module, we simply freshened the constructors existential and term binders utimately through a call to `mkOneConFull`. But that instantiation is unnecessary for when we match against a concrete pattern! The pattern will already have fresh binders and field types. So we don't call `refineToAltCon` from `Check` anymore. Subsequently, we can simplify a couple of call sites and functions in `PmOracle`. Also implementing `computeCovered` becomes viable and we don't have to live with the hack that was `addVarPatVecCt` anymore. A side-effect of not indirectly calling `mkOneConFull` anymore is that we don't generate the proper strict argument field constraints anymore. Instead we now desugar ConPatOuts as if they had bangs on their strict fields. This implies that `PmVar` now carries a `HsImplBang` that we need to respect by a (somewhat ephemeral) non-void check. We fix #17234 in doing so. - - - - - ce64b397 by Sebastian Graf at 2019-09-28T17:12:26-04:00 `exprOkForSpeculation` for Note [IO hack in the demand analyser] In #14998 I realised that the notion of speculative execution *exactly matches* eager evaluation of expressions in a case alternative where the scrutinee is an IO action. Normally we have to `deferIO` any result from that single case alternative to prevent this speculative execution, so we had a special case in place in the demand analyser that would check if the scrutinee was a prim-op, in which case we assumed that it would be ok to do the eager evaluation. Now we just check if the scrutinee is `exprOkForSpeculation`, corresponding to the notion that we want to push evaluation of the scrutinee *after* eagerly evaluating stuff from the case alternative. This fixes #14988, because it resolves the last open Item 4 there. - - - - - f3cb8c7c by Ömer Sinan Ağacan at 2019-09-30T22:39:53-04:00 Refactor iface file generation: This commit refactors interface file generation to allow information from the later passed (NCG, STG) to be stored in interface files. We achieve this by splitting interface file generation into two parts: * Partial interfaces, built based on the result of the core pipeline * A fully instantiated interface, which also contains the final fingerprints and can optionally contain information produced by the backend. This change is required by !1304 and !1530. -dynamic-too handling is refactored too: previously when generating code we'd branch on -dynamic-too *before* code generation, but now we do it after. (Original code written by @AndreasK in !1530) Performance ~~~~~~~~~~~ Before this patch interface files where created and immediately flushed to disk which made space leaks impossible. With this change we instead use NFData to force all iface related data structures to avoid space leaks. In the process of refactoring it was discovered that the code in the ToIface Module allocated a lot of thunks which were immediately forced when writing/forcing the interface file. So we made this module more strict to avoid creating many of those thunks. Bottom line is that allocations go down by about ~0.1% compared to master. Residency is not meaningfully different after this patch. Runtime was not benchmarked. Co-Authored-By: Andreas Klebinger <klebinger.andreas at gmx.at> Co-Authored-By: Ömer Sinan Ağacan <omer at well-typed.com> - - - - - 6a1700aa by Simon Peyton Jones at 2019-09-30T22:40:30-04:00 Fix arguments for unbound binders in RULE application We were failing to correctly implement Note [Unbound RULE binders] in Rules.hs. In particular, when cooking up a fake Refl, were were failing to apply the substitition. This patch fixes that problem, and simultaneously tidies up the impedence mis-match between RuleSubst and TCvSubst. Thanks to Sebastian! - - - - - 97811ef5 by Takenobu Tani at 2019-09-30T22:41:35-04:00 Add help message for GHCi :instances command This commit updates GHCi's help message for GHC 8.10. - - - - - 6f8550a3 by Sebastian Graf at 2019-09-30T22:42:14-04:00 Move pattern match checker modules to GHC.HsToCore.PmCheck - - - - - b36dd49b by Takenobu Tani at 2019-09-30T22:42:53-04:00 testsuite: Add minimal test for :doc command Currently, there are no testcases for GHCi `:doc` command. Perhaps because it was experimental. And it could be changed in the future. But `:doc` command is already useful, so I add a minimal regression test to keep current behavior. See also 85309a3cda for implementation of `:doc` command. - - - - - bdba6ac2 by Vladislav Zavialov at 2019-09-30T22:43:31-04:00 Do not rely on CUSKs in 'base' Use standalone kind signatures instead of complete user-specified kinds in Data.Type.Equality and Data.Typeable - - - - - dbdf6a3d by Ben Gamari at 2019-09-30T22:44:07-04:00 testsuite: Mark T3389 as broken in hpc way on i386 See #17256. - - - - - 822481d5 by Ben Gamari at 2019-09-30T22:44:44-04:00 Bump process submodule Marks process003 as fragile, as noted in #17245. - - - - - 6548b7b0 by Sebastian Graf at 2019-10-01T09:22:10+00:00 Add a bunch of testcases for the pattern match checker Adds regression tests for tickets #17207, #17208, #17215, #17216, #17218, #17219, #17248 - - - - - 58013220 by Sebastian Graf at 2019-10-01T09:22:18+00:00 Add testcases inspired by Luke Maranget's pattern match series In his paper "Warnings for Pattern Matching", Luke Maranget describes three series in his appendix for which GHC's pattern match checker scaled very badly. We mostly avoid this now with !1752. This commit adds regression tests for each of the series. Fixes #17264. - - - - - 9c002177 by Ryan Scott at 2019-10-01T16:24:12-04:00 Refactor some cruft in TcDeriv * `mk_eqn_stock`, `mk_eqn_anyclass`, and `mk_eqn_no_mechanism` all took a continuation of type `DerivSpecMechanism -> DerivM EarlyDerivSpec` to represent its primary control flow. However, in practice this continuation was always instantiated with the `mk_originative_eqn` function, so there's not much point in making this be a continuation in the first place. This patch removes these continuations in favor of invoking `mk_originative_eqn` directly, which is simpler. * There were several parts of `TcDeriv` that took different code paths if compiling an `.hs-boot` file. But this is silly, because ever since 101a8c770b9d3abd57ff289bffea3d838cf25c80 we simply error eagerly whenever attempting to derive any instances in an `.hs-boot` file. This patch removes all of the unnecessary `.hs-boot` code paths, leaving only one (which errors out). * Remove various error continuation arguments from `mk_eqn_stock` and related functions. - - - - - 9a27a063 by David Eichmann at 2019-10-01T16:55:33-04:00 Hadrian: Libffi rule now `produces` dynamic library files. - - - - - 0956c194 by David Eichmann at 2019-10-01T16:55:33-04:00 Hadrian: do not cache GHC configure rule - - - - - 8924224e by Ömer Sinan Ağacan at 2019-10-01T16:55:37-04:00 Make small INLINE functions behave properly Simon writes: Currently we check for a type arg rather than isTyCoArg. This in turn makes INLINE things look bigger than they should be, and stops them being inlined into boring contexts when they perfectly well could be. E.g. f x = g <refl> x {-# INLINE g #-} ... (map (f x) xs) ... The context is boring, so don't inline unconditionally. But f's RHS is no bigger than its call, provided you realise that the coercion argument is ultimately cost-free. This happens in practice for $WHRefl. It's not a big deal: at most it means we have an extra function call overhead. But it's untidy, and actually worse than what happens without an INLINE pragma. Fixes #17182 This makes 0.0% change in nofib binary sizes. - - - - - 53b0c6e0 by Gabor Greif at 2019-10-03T08:15:50-04:00 Typo in comment [ci skip] - - - - - 60229e9e by Ryan Scott at 2019-10-03T12:17:10-04:00 Merge TcTypeableValidity into TcTypeable, document treatment of casts This patch: * Implements a refactoring (suggested in https://gitlab.haskell.org/ghc/ghc/merge_requests/1199#note_207345) that moves all functions from `TcTypeableValidity` back to `TcTypeable`, as the former module doesn't really need to live on its own. * Adds `Note [Typeable instances for casted types]` to `TcTypeable` explaining why the `Typeable` solver currently does not support types containing casts. Resolves #16835. - - - - - 3b9d4907 by Richard Eisenberg at 2019-10-03T12:17:13-04:00 Note [Don't flatten tuples from HsSyn] in MkCore Previously, we would sometimes flatten 1-tuples and sometimes not. This didn't cause damage because there is no way to generate HsSyn with 1-tuples. But, with the upcoming fix to #16881, there will be. Without this patch, obscure lint errors would have resulted. No test case, as there is not yet a way to tickle this. - - - - - 8a254d6b by Ömer Sinan Ağacan at 2019-10-03T12:17:19-04:00 Fix new compact block allocation in allocateForCompact allocateForCompact() is called when nursery of a compact region is full, to add new blocks to the compact. New blocks added to an existing region needs a StgCompactNFDataBlock header, not a StgCompactNFData. This fixes allocateForCompact() so that it now correctly allocates space for StgCompactNFDataBlock instead of StgCompactNFData as before. Fixes #17044. A regression test T17044 added. - - - - - 3c7b172b by James Brock at 2019-10-03T12:17:24-04:00 docs String, hyperlink to Data.List Add a reference to the documentation for Data.List in the description for String. On the generated Haddock for Data.String, http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-String.html there is curently no hyperlink to Data.List, which is where a reader will find most of the useful functions which can operate on Strings. I imagine this has confused beginners who came to this page looking for String operations. - - - - - 67bf734c by John Ericson at 2019-10-03T12:17:28-04:00 Add `module {-# SOURCE #-} Foo` syntax for hs-boot in bkp This is a good convenience for testing. - - - - - 6655ec73 by Richard Eisenberg at 2019-10-03T12:17:30-04:00 Improve documentation around empty tuples/lists This patch also changes the way we handle empty lists, simplifying them somewhat. See Note [Empty lists]. Previously, we had to special-case empty lists in the type-checker. Now no more! Finally, this patch improves some documentation around the ir_inst field used in the type-checker. This breaks a test case, but I really think the problem is #17251, not really related to this patch. Test case: typecheck/should_compile/T13680 - - - - - 9a4ff210 by John Ericson at 2019-10-03T12:17:31-04:00 Make Haddock submodule remote point to gitlab mirror This makes it match the others - - - - - cb364bc2 by Ben Gamari at 2019-10-03T12:17:32-04:00 testsuite: Mark print037 as fragile, not broken See #16205. - - - - - 259f4dff by Ben Gamari at 2019-10-03T12:17:32-04:00 Exclude rts.cabal from source distributions This modifies both the Hadrian and make build systems to avoid included the rts.cabal generated by autoconf in the source distribution. Fixes #17265. - - - - - e4c93896 by Ben Gamari at 2019-10-03T12:17:32-04:00 DynFlags: Only warn when split-sections is ignored Previously we would throw an error which seems a bit harsh. As reported in #17283. - - - - - ee6324ad by Tobias Guggenmos at 2019-10-03T12:17:33-04:00 Improve documentation for runtime debugging flags - - - - - 47386fe8 by Tobias Guggenmos at 2019-10-03T12:17:33-04:00 Add new debug flag -DZ Zeros heap memory after gc freed it. - - - - - d0924b15 by Stefan Schulze Frielinghaus at 2019-10-03T12:17:34-04:00 Extend argument of createIOThread to word size Function createIOThread expects its second argument to be of size word. The natural size of the second parameter is 32bits. Thus for some 64bit architectures, where a write of the lower half of a register does not clear the upper half, the value must be zero extended. - - - - - 1357d023 by Ben Gamari at 2019-10-03T12:17:34-04:00 rules/haddock: Ensure that RTS stats directory exists It may not exist if the source tarball was extracted yet not the testsuite tarball. - - - - - ec93d2a9 by Fumiaki Kinoshita at 2019-10-04T21:43:49-04:00 Add Monad instances to `(,,) a b` and `(,,,) a b c` - - - - - 05419e55 by John Ericson at 2019-10-04T21:44:29-04:00 Per stage headers, ghc_boot_platform.h -> stage 0 ghcplatform.h The generated headers are now generated per stage, which means we can skip hacks like `ghc_boot_platform.h` and just have that be the stage 0 header as proper. In general, stages are to be embraced: freely generate everything in each stage but then just build what you depend on, and everything is symmetrical and efficient. Trying to avoid stages because bootstrapping is a mind bender just creates tons of bespoke mini-mind-benders that add up to something far crazier. Hadrian was pretty close to this "stage-major" approach already, and so was fairly easy to fix. Make needed more work, however: it did know about stages so at least there was a scaffold, but few packages except for the compiler cared, and the compiler used its own counting system. That said, make and Hadrian now work more similarly, which is good for the transition to Hadrian. The merits of embracing stage aside, the change may be worthy for easing that transition alone. - - - - - 75a5dd8e by John Ericson at 2019-10-04T21:44:29-04:00 Remove {Build,Host}Platform_NAME from header They are only used in a file we construct directly, so just skip CPP. - - - - - b538476b by Daroc Alden at 2019-10-04T21:45:09-04:00 Deprecate -fwarn-hi-shadowing, because it was never implemented and is not used. This fixes #10913. - - - - - dd8f76b2 by John Ericson at 2019-10-04T21:45:48-04:00 Factor out a smaller part of Platform for host fallback - - - - - d15b44d6 by John Ericson at 2019-10-04T21:45:49-04:00 Pull out the settings file parsing code into it's own module. This has two benefits: 1. One less hunk of code dependent on DynFlags 2. Add a little bit of error granularity to distrinugish between missing data and bad data. This could someday be shared with ghc-pkg which aims to work even with a missing file. I also am about to to make --supported-extensions use this too. - - - - - eb892b28 by John Ericson at 2019-10-04T21:45:49-04:00 Add tryFindTopDir to look for the top dir without blowing up if it is not found. - - - - - 0dded5ec by John Ericson at 2019-10-04T21:45:49-04:00 Always enable the external interpreter You can always just not use or even build `iserv`. I don't think the maintenance cost of the CPP is worth...I can't even tell what the benefit is. - - - - - 0d31ccdd by Artem Pyanykh at 2019-10-04T21:46:28-04:00 [linker, macho] Don't map/allocate zero size sections and segments Zero size sections are common even during regular build on MacOS. For instance: ``` $ ar -xv libHSghc-prim-0.6.1.a longlong.o $ otool -l longlong.o longlong.o: Mach header magic cputype cpusubtype caps filetype ncmds sizeofcmds flags 0xfeedfacf 16777223 3 0x00 1 2 176 0x00002000 Load command 0 cmd LC_SEGMENT_64 cmdsize 152 segname vmaddr 0x0000000000000000 vmsize 0x0000000000000000 <-- segment size = 0 fileoff 208 filesize 0 maxprot 0x00000007 initprot 0x00000007 nsects 1 flags 0x0 Section sectname __text segname __TEXT addr 0x0000000000000000 size 0x0000000000000000 <-- section size = 0 offset 208 align 2^0 (1) reloff 0 nreloc 0 flags 0x80000000 reserved1 0 reserved2 0 cmd LC_BUILD_VERSION cmdsize 24 platform macos sdk 10.14 minos 10.14 ntools 0 ``` The issue of `mmap`ing 0 bytes was resolved in !1050, but the problem remained. These 0 size segments and sections were still allocated in object code, which lead to failed `ASSERT(size > 0)` in `addProddableBlock` further down the road. With this change zero size segments **and** sections are not mapped/allocated at all. Test plan: 1. Build statically linked GHC. 2. Run `ghc --interactive`. Observe that REPL loads successfully (which was not the case before). 3. Load several more compiled hs files into repl. No failures. - - - - - 93f02b62 by Roland Senn at 2019-10-04T21:47:07-04:00 New fix for #11647. Avoid side effects like #17171 If a main module doesn't contain a header, we omit the check whether the main module is exported. With this patch GHC, GHCi and runghc use the same code. - - - - - 8039b625 by Matthew Bauer at 2019-10-04T21:47:47-04:00 Add musl systems to llvm-targets This was done in Nixpkgs, but never upstreamed. Musl is pretty much the same as gnu, but with a different libc. I’ve used the same values for everything. - - - - - ee8118ca by John Ericson at 2019-10-05T00:11:58-04:00 Clean up `#include`s in the compiler - Remove unneeded ones - Use <..> for inter-package. Besides general clean up, helps distinguish between the RTS we link against vs the RTS we compile for. - - - - - 241921a0 by Ben Gamari at 2019-10-05T19:18:40-04:00 rts: Fix CNF dirtying logic Previously due to a silly implementation bug CNFs would never have their dirty flag set, resulting in their being added again and again to the `mut_list`. Fix this. Fixes #17297. - - - - - 825c108b by Ryan Scott at 2019-10-07T12:00:59-04:00 Only flatten up to type family arity in coreFlattenTyFamApp (#16995) Among other uses, `coreFlattenTyFamApp` is used by Core Lint as a part of its check to ensure that each type family axiom reduces according to the way it is defined in the source code. Unfortunately, the logic that `coreFlattenTyFamApp` uses to flatten type family applications disagreed with the logic in `TcFlatten`, which caused it to spuriously complain this program: ```hs type family Param :: Type -> Type type family LookupParam (a :: Type) :: Type where LookupParam (f Char) = Bool LookupParam x = Int foo :: LookupParam (Param ()) foo = 42 ``` This is because `coreFlattenTyFamApp` tries to flatten the `Param ()` in `LookupParam (Param ())` to `alpha` (where `alpha` is a flattening skolem), and GHC is unable to conclude that `alpha` is apart from `f Char`. This patch spruces up `coreFlattenTyFamApp` so that it instead flattens `Param ()` to `alpha ()`, which GHC _can_ know for sure is apart from `f Char`. See `Note [Flatten], wrinkle 3` in `FamInstEnv`. - - - - - b2577081 by Ben Gamari at 2019-10-07T12:01:46-04:00 Refactor, document, and optimize LLVM configuration loading As described in the new Note [LLVM Configuration] in SysTools, we now load llvm-targets and llvm-passes lazily to avoid the overhead of doing so when -fllvm isn't used (also known as "the common case"). Noticed in #17003. Metric Decrease: T12234 T12150 - - - - - 93c71ae6 by Ben Gamari at 2019-10-07T12:02:23-04:00 configure: Determine library versions of template-haskell, et al. These are needed by the user guide documentation. Fixes #17260. - - - - - b7890611 by Andrey Mokhov at 2019-10-07T12:03:13-04:00 Hadrian: Stop using in-tree Cabal - - - - - 0ceb98f6 by Andrey Mokhov at 2019-10-07T12:03:13-04:00 Switch to cabal-version=3.0 in ghc-heap.cabal - - - - - e3418e96 by Andrey Mokhov at 2019-10-07T12:03:13-04:00 Switch to cabal-version=3.0 in base.cabal and rts.cabal - - - - - 805653f6 by John Ericson at 2019-10-07T12:04:19-04:00 Get rid of wildcard patterns in prim Cmm emitting code This way, we can be sure we don't miss a case. - - - - - ab945819 by Ryan Scott at 2019-10-07T12:05:09-04:00 Refactor some cruft in TcGenGenerics * `foldBal` contains needless partiality that can easily be avoided. * `mkProd_E` and `mkProd_P` both contain unique supply arguments that are completely unused, which can be removed. - - - - - d0edba3a by John Ericson at 2019-10-07T12:05:47-04:00 Remove CONFIGURE_ARGS from configure.ac It looks like it's been unused since at least 34cc75e1a62638f2833815746ebce0a9114dc26b. - - - - - 9a6bfb0a by John Ericson at 2019-10-07T12:06:26-04:00 Keep OSTYPE local to configure.ac Unused outside it since b6be81b841e34ca45b3549c4c79e886a8761e59a. - - - - - 4df39fd0 by John Ericson at 2019-10-07T12:07:08-04:00 Get rid of GHC_PACKAGE_DB_FLAG We no longer support booting from older GHC since 527bcc41630918977c73584d99125ff164400695. - - - - - 31a29a7a by John Ericson at 2019-10-07T12:07:46-04:00 Remove GhcLibsWithUnix d679ca43e7477284d733b94ff542be5363be3353 meant to remove it but did not finish the job. - - - - - 77ca39e3 by Ben Gamari at 2019-10-08T05:11:03-04:00 gitlab-ci: Add missing TEST_ENV variables This should fix #16985. - - - - - 9a2798e1 by Ben Gamari at 2019-10-08T05:11:03-04:00 hadrian: Add `validate` and `slow validate` flavours - - - - - ab311696 by Ben Gamari at 2019-10-08T05:11:03-04:00 validate: Use Hadrian's validate flavour - - - - - 98179a77 by Ben Gamari at 2019-10-08T05:11:03-04:00 gitlab-ci: Use validate flavour in hadrian builds - - - - - 8af9eba8 by Ben Gamari at 2019-10-08T05:11:40-04:00 base: Document the fact that Typeable is automatically "derived" This fixes #17060. - - - - - 397c6ed5 by Sebastian Graf at 2019-10-08T05:12:15-04:00 PmCheck: Identify some semantically equivalent expressions By introducing a `CoreMap Id` to the term oracle, we can represent syntactically equivalent expressions by the same `Id`. Combine that with `CoreOpt.simpleCoreExpr` and it might even catch non-trivial semantic equalities. Unfortunately due to scoping issues, this will not solve #17208 for view patterns yet. - - - - - 8a2e8408 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Refer to language extension flags via :extension: Previously several were referred to via :ghc-flag:`-X...`. - - - - - 7cd54538 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Make reverse flags addressable via :ghc-flag: Previously one could not easily link to the :reverse: flag of a ghc-flag. - - - - - e9813afc by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Document -XHaskell98 and -XHaskell2010 - - - - - eaeb28a1 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Fix various warnings - - - - - 180cf177 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Document NondecreasingIndentation - - - - - 0a26f9e8 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Document -fworker-wrapper - - - - - ca4791db by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Rework pragma key generation Previously we had a hack to handle the case of multi-token SPECIALISE pragmas. Now we use a slightly more general rule of using a prefix of tokens containing only alphabetical characters. - - - - - 98c09422 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Run sphinx in nit-picky mode This ensure that it blurts an error on missing references. - - - - - a95f7185 by Ben Gamari at 2019-10-08T05:12:58-04:00 doc: Write out documented flag list - - - - - 9402608e by Ben Gamari at 2019-10-08T05:12:58-04:00 gitlab-ci: Check coverage of GHC flags in users guide This ensures that all GHC flags are documented during the documentation build. Fixes #17315. - - - - - 9ac3bcbb by Andrew Martin at 2019-10-08T13:24:52-04:00 Document the UnliftedFFITypes extension. - - - - - 77f3ba23 by Andrew Martin at 2019-10-08T13:24:52-04:00 Rephrase a bunch of things in the unlifted ffi types documentation. Add a section on pinned byte arrays. - - - - - a70db7bf by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] link to foreign cmm call - - - - - 0d413259 by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] make the table better - - - - - 0c7a5bcd by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] can not -> may not - - - - - 6a5c249d by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] clarify what unsound means - - - - - bf02c264 by Ryan Scott at 2019-10-08T13:25:37-04:00 Mark newtype constructors as used in the Coercible solver (#10347) Currently, newtype constructors are not marked as used when they are accessed under the hood by uses of `coerce`, as described in #10347. This fixes #10347 by co-opting the `tcg_keep` field of `TcGblEnv` to track uses of newtype constructors in the `Coercible` solver. See `Note [Tracking unused binding and imports]` in `TcRnTypes`. Since #10347 is fixed, I was able to simplify the code in `TcDeriv` slightly, as the hack described in `Note [Newtype deriving and unused constructors]` is no longer necessary. - - - - - 9612e91c by Richard Eisenberg at 2019-10-08T13:26:20-04:00 Solve constraints from top-level groups sooner Previously, all constraints from all top-level groups (as separated by top-level splices) were lumped together and solved at the end. This could leak metavariables to TH, though, and that's bad. This patch solves each group's constraints before running the next group's splice. Naturally, we now report fewer errors in some cases. One nice benefit is that this also fixes #11680, but in a much simpler way than the original fix for that ticket. Admittedly, the error messages degrade just a bit from the fix from #11680 (previously, we informed users about variables that will be brought into scope below a top-level splice, and now we just report an out-of-scope error), but the amount of complexity required throughout GHC to get that error was just not worth it. This patch thus reverts much of f93c9517a2c6e158e4a5c5bc7a3d3f88cb4ed119. Fixes #16980 Test cases: th/T16980{,a} - - - - - c2d4011c by Vladislav Zavialov at 2019-10-08T13:27:12-04:00 Bump array and haddock submodules - - - - - f691f0c2 by Sebastian Graf at 2019-10-08T13:27:49-04:00 PmCheck: Look up parent data family TyCon when populating `PossibleMatches` The vanilla COMPLETE set is attached to the representation TyCon of a data family instance, whereas the user-defined COMPLETE sets are attached to the parent data family TyCon itself. Previously, we weren't trying particularly hard to get back to the representation TyCon to the parent data family TyCon, resulting in bugs like #17207. Now we should do much better. Fixes the original issue in #17207, but I found another related bug that isn't so easy to fix. - - - - - 0c0a15a8 by Ben Gamari at 2019-10-09T16:21:14-04:00 Rename STAGE macro to GHC_STAGE To avoid polluting the macro namespace - - - - - 63a5371d by Ben Gamari at 2019-10-09T16:21:14-04:00 Relayout generated header body - - - - - 817c1a94 by Ben Gamari at 2019-10-09T16:21:14-04:00 Define GHC_STAGE in headers instead of command-line - - - - - 5f2c49d8 by Ben Gamari at 2019-10-09T16:21:14-04:00 Remove GHC_STAGE guards from MachDeps This allows the stage1 compiler (which needs to run on the build platform and produce code for the host) to depend upon properties of the target. This is wrong. However, it's no more wrong than it was previously and @Erichson2314 is working on fixing this so I'm going to remove the guard so we can finally bootstrap HEAD with ghc-8.8 (see issue #17146). - - - - - 35cc5eff by Ben Gamari at 2019-10-09T16:21:15-04:00 Test - - - - - d584e3f0 by Ryan Scott at 2019-10-09T16:21:50-04:00 Use addUsedDataCons more judiciously in TcDeriv (#17324) If you derive an instance like this: ```hs deriving <...> instance Foo C ``` And the data constructors for `C` aren't in scope, then `doDerivInstErrorChecks1` throws an error. Moreover, it will _only_ throw an error if `<...>` is either `stock` or `newtype`. This is because the code that the `anyclass` or `via` strategies would generate would not require the use of the data constructors for `C`. However, `doDerivInstErrorChecks1` has another purpose. If you write this: ```hs import M (C(MkC1, ..., MkCn)) deriving <...> instance Foo C ``` Then `doDerivInstErrorChecks1` will call `addUsedDataCons` on `MkC1` through `MkCn` to ensure that `-Wunused-imports` does not complain about them. However, `doDerivInstErrorChecks1` was doing this for _every_ deriving strategy, which mean that if `<...>` were `anyclass` or `via`, then the warning about `MkC1` through `MkCn` being unused would be suppressed! The fix is simple enough: only call `addUsedDataCons` when the strategy is `stock` or `newtype`, just like the other code paths in `doDerivInstErrorChecks1`. Fixes #17324. - - - - - 30f5ac07 by Sebastian Graf at 2019-10-11T22:10:12-04:00 Much simpler language for PmCheck Simon realised that the simple language composed of let bindings, bang patterns and flat constructor patterns is enough to capture the semantics of the source pattern language that are important for pattern-match checking. Well, given that the Oracle is smart enough to connect the dots in this less informationally dense form, which it is now. So we transform `translatePat` to return a list of `PmGrd`s relative to an incoming match variable. `pmCheck` then trivially translates each of the `PmGrd`s into constraints that the oracle understands. Since we pass in the match variable, we incidentally fix #15884 (coverage checks for view patterns) through an interaction with !1746. - - - - - 166e1c2a by Stefan Schulze Frielinghaus at 2019-10-11T22:10:51-04:00 Hadrian: Take care of assembler source files Fixes #17286. - - - - - c2290596 by John Ericson at 2019-10-12T06:32:18-04:00 Simplify Configure in a few ways - No need to distinguish between gcc-llvm and clang. First of all, gcc-llvm is quite old and surely unmaintained by now. Second of all, none of the code actually care about that distinction! Now, it does make sense to consider C multiple frontends for LLVMs in the form of clang vs clang-cl (same clang, yes, but tweaked interface). But this is better handled in terms of "gccish vs mvscish" and "is LLVM", yielding 4 combinations. Therefore, I don't think it is useful saving the existing code for that. - Get the remaining CC_LLVM_BACKEND, and also TABLES_NEXT_TO_CODE in mk/config.h the normal way, rather than hacking it post-hoc. No point keeping these special cases around for now reason. - Get rid of hand-rolled `die` function and just use `AC_MSG_ERROR`. - Abstract check + flag override for unregisterised and tables next to code. Oh, and as part of the above I also renamed/combined some variables where it felt appropriate. - GccIsClang -> CcLlvmBackend. This is for `AC_SUBST`, like the other Camal case ones. It was never about gcc-llvm, or Apple's renamed clang, to be clear. - llvm_CC_FLAVOR -> CC_LLVM_BACKEND. This is for `AC_DEFINE`, like the other all-caps snake case ones. llvm_CC_FLAVOR was just silly indirection *and* an odd name to boot. - - - - - f1ce3535 by Vladislav Zavialov at 2019-10-12T06:33:05-04:00 Escape stats file command (#13676) - - - - - cd1a8808 by Vladislav Zavialov at 2019-10-12T06:33:05-04:00 Skip T13767 on Darwin The CI job fails with: +++ rts/T13676.run/T13676.run.stderr.normalised 2019-10-09 12:27:56.000000000 -0700 @@ -0,0 +1,4 @@ +dyld: Library not loaded: @rpath/libHShaskeline-0.7.5.0-ghc8.9.0.20191009.dylib + Referenced from: /Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib/bin/ghc + Reason: image not found +*** Exception: readCreateProcess: '/Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib/bin/ghc' '-B/Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib' '-e' ''/''$'/'' == '/''/x0024'/''' +RTS '-tT13676.t' (exit -6): failed Unable to reproduce locally. - - - - - 0a338264 by Ryan Scott at 2019-10-12T06:33:42-04:00 Use newDFunName for both manual and derived instances (#17339) Issue #17339 was caused by using a slightly different version of `newDFunName` for derived instances that, confusingly enough, did not take all arguments to the class into account when generating the `DFun` name. I cannot think of any good reason for doing this, so this patch uses `newDFunName` uniformly for both derived instances and manually written instances alike. Fixes #17339. - - - - - c50e4c92 by Simon Peyton Jones at 2019-10-12T13:35:24-04:00 Fix validity checking for inferred types GHC is suposed to uphold the principle that an /inferred/ type for a let-binding should obey the rules for that module. E.g. we should only accept an inferred higher rank type if we have RankNTypes on. But we were failing to check this: TcValidity.checkValidType allowed arbitrary rank for inferred types. This patch fixes the bug. It might in principle cause some breakage, but if so that's good: the user should add RankNTypes and/or a manual signature. (And almost every package has explicit user signatures for all top-level things anyway.) Let's see. Fixes #17213. Metric Decrease: T10370 - - - - - 226d86d2 by Simon Peyton Jones at 2019-10-12T13:36:02-04:00 Do not add a 'solved dict' for quantified constraints GHC has a wonderful-but-delicate mechanism for building recursive dictionaries by adding a goal to the "solved dictionaries" before solving the sub-goals. See Note [Solved dictionaries] in TcSMonad Ticket #17267 showed that if you use this mechanism for local /quantified/ constraints you can get a loop -- or even unsafe coerce. This patch fixes the bug. Specifically * Make TcSMonad.addSolvedDict be conditional on using a /top level/ instance, not a quantified one. * Moreover, we /also/ don't want to add a solved dict for equalities (a~b). * Add lots more comments to Note [Solved dictionaries] to explain the above cryptic stuff. * Extend InstanceWhat to identify those strange built-in equality instances. A couple of other things along the way * Delete the unused Type.isIPPred_maybe. * Stop making addSolvedDict conditional on not being an impolicit parameter. This comes from way back. But it's irrelevant now because IP dicts are never solved via an instance. - - - - - 5ab1a28d by nineonine at 2019-10-13T06:31:40-04:00 Template Haskell: make unary tuples legal (#16881) - - - - - c1bd07cd by Andreas Klebinger at 2019-10-13T06:32:19-04:00 Fix #17334 where NCG did not properly update the CFG. Statements can change the basic block in which instructions are placed during instruction selection. We have to keep track of this switch of the current basic block as we need this information in order to properly update the CFG. This commit implements this change and fixes #17334. We do so by having stmtToInstr return the new block id if a statement changed the basic block. - - - - - 1eda9f28 by Takenobu Tani at 2019-10-13T19:06:02-04:00 users-guide: Add GHCi's ::<builtin-command> form This commit explicitly adds description about double colon command of GHCi. [skip ci] - - - - - 27145351 by Takenobu Tani at 2019-10-13T19:06:40-04:00 Add GHCi help message for :def! and :: commands - - - - - 78463fc5 by Ryan Scott at 2019-10-14T08:38:36-04:00 Add docs/users_guide/.log to .gitignore When the users guide fails to build (as in #17346), a `docs/users_guide/.log` file will be generated with contents that look something like this: ``` WARNING: unknown config value 'latex_paper_size' in override, ignoring /home/rgscott/Software/ghc5/docs/users_guide/ghci.rst:3410: WARNING: u'ghc-flag' reference target not found: -pgmo ?option? /home/rgscott/Software/ghc5/docs/users_guide/ghci.rst:3410: WARNING: u'ghc-flag' reference target not found: -pgmo ?port? Encoding error: 'ascii' codec can't encode character u'\u27e8' in position 132: ordinal not in range(128) The full traceback has been saved in /tmp/sphinx-err-rDF2LX.log, if you want to report the issue to the developers. ``` This definitely should not be checked in to version control, so let's add this to `.gitignore`. - - - - - 4aba72d6 by Ryan Scott at 2019-10-14T08:39:12-04:00 Mention changes from #16980, #17213 in 8.10.1 release notes The fixes for these issues both have user-facing consequences, so it would be good to mention them in the release notes for GHC 8.10.1. While I'm in town, also mention `UnboxedSums` in the release notes entry related to `-fobject-code`. - - - - - 0ca044fd by Ben Gamari at 2019-10-14T08:39:48-04:00 gitlab-ci: Move hadrian-ghc-in-ghci job first This is a very cheap job and can catch a number of "easy" failure modes (e.g. missing imports in the compiler). Let's run it first. - - - - - a2d3594c by Ryan Scott at 2019-10-15T01:35:34-04:00 Refactor some cruft in TcDerivInfer.inferConstraints The latest installment in my quest to clean up the code in `TcDeriv*`. This time, my sights are set on `TcDerivInfer.inferConstraints`, which infers the context for derived instances. This function is a wee bit awkward at the moment: * It's not terribly obvious from a quick glance, but `inferConstraints` is only ever invoked when using the `stock` or `anyclass` deriving strategies, as the code for inferring the context for `newtype`- or `via`-derived instances is located separately in `mk_coerce_based_eqn`. But there's no good reason for things to be this way, so I moved this code from `mk_coerce_based_eqn` to `inferConstraints` so that everything related to inferring instance contexts is located in one place. * In this process, I discovered that the Haddocks for the auxiliary function `inferConstraintsDataConArgs` are completely wrong. It claims that it handles both `stock` and `newtype` deriving, but this is completely wrong, as discussed above—it only handles `stock`. To rectify this, I renamed this function to `inferConstraintsStock` to reflect its actual purpose and created a new `inferConstraintsCoerceBased` function to specifically handle `newtype` (and `via`) deriving. Doing this revealed some opportunities for further simplification: * Removing the context-inference–related code from `mk_coerce_based_eqn` made me realize that the overall structure of the function is basically identical to `mk_originative_eqn`. In fact, I was easily able to combine the two functions into a single `mk_eqn_from_mechanism` function. As part of this merger, I now invoke `atf_coerce_based_error_checks` from `doDerivInstErrorChecks1`. * I discovered that GHC defined this function: ```hs typeToTypeKind = liftedTypeKind `mkVisFunTy` liftedTypeKind ``` No fewer than four times in different modules. I consolidated all of these definitions in a single location in `TysWiredIn`. - - - - - 426b0ddc by Ryan Scott at 2019-10-15T01:36:14-04:00 Don't skip validity checks for built-in classes (#17355) Issue #17355 occurred because the control flow for `TcValidity.check_valid_inst_head` was structured in such a way that whenever it checked a special, built-in class (like `Generic` or `HasField`), it would skip the most important check of all: `checkValidTypePats`, which rejects nonsense like this: ```hs instance Generic (forall a. a) ``` This fixes the issue by carving out `checkValidTypePats` from `check_valid_inst_head` so that `checkValidTypePats` is always invoked. `check_valid_inst_head` has also been renamed to `check_special_inst_head` to reflect its new purpose of _only_ checking for instances headed by special classes. Fixes #17355. - - - - - a55b8a65 by Alp Mestanogullari at 2019-10-15T18:41:18-04:00 iface: export a few more functions from BinIface - - - - - 9c11f817 by Ben Gamari at 2019-10-15T18:41:54-04:00 hadrian: Add support for bindist compressors other than Xz Fixes #17351. - - - - - 535a88e1 by klebinger.andreas at gmx.at at 2019-10-16T07:04:21-04:00 Add loop level analysis to the NCG backend. For backends maintaining the CFG during codegen we can now find loops and their nesting level. This is based on the Cmm CFG and dominator analysis. As a result we can estimate edge frequencies a lot better for methods, resulting in far better code layout. Speedup on nofib: ~1.5% Increase in compile times: ~1.9% To make this feasible this commit adds: * Dominator analysis based on the Lengauer-Tarjan Algorithm. * An algorithm estimating global edge frequences from branch probabilities - In CFG.hs A few static branch prediction heuristics: * Expect to take the backedge in loops. * Expect to take the branch NOT exiting a loop. * Expect integer vs constant comparisons to be false. We also treat heap/stack checks special for branch prediction to avoid them being treated as loops. - - - - - cc2bda50 by adithyaov at 2019-10-16T07:05:01-04:00 Compiling with -S and -fno-code no longer panics (fixes #17143) - - - - - 19641957 by Takenobu Tani at 2019-10-16T07:05:41-04:00 testsuite: Add test for #8305 This is a test for the current algorithm of GHCi command name resolution. I add this test in preparation for updating GHCi command name resolution. For the current algorithm, see https://downloads.haskell.org/ghc/latest/docs/html/users_guide/ghci.html#the-ghci-files - - - - - 6ede3554 by Sebastian Graf at 2019-10-16T07:06:20-04:00 Infer rho-types instead of sigma-types in guard BindStmts and TransStmts In #17343 we saw that we didn't handle the pattern guard `!_ <- undefined` correctly: The `undefined` was never evaluated. Indeed, elaboration failed to insert the invisible type aruments to `undefined`. So `undefined` was trivially a normal-form and in turn never entered. The problem is that we used to infer a sigma-type for the RHS of the guard, the leading qualifiers of which will never be useful in a pattern match situation. Hence we infer a rho-type now. Fixes #17343. - - - - - 798037a1 by John Ericson at 2019-10-16T07:06:58-04:00 Delete ghctags cabal file It came back to life in 381c3ae31b68019177f1cd20cb4da2f9d3b7d6c6 by mistake. - - - - - 51fad9e6 by Richard Eisenberg at 2019-10-16T15:58:58-04:00 Break up TcRnTypes, among other modules. This introduces three new modules: - basicTypes/Predicate.hs describes predicates, moving this logic out of Type. Predicates don't really exist in Core, and so don't belong in Type. - typecheck/TcOrigin.hs describes the origin of constraints and types. It was easy to remove from other modules and can often be imported instead of other, scarier modules. - typecheck/Constraint.hs describes constraints as used in the solver. It is taken from TcRnTypes. No work other than module splitting is in this patch. This is the first step toward homogeneous equality, which will rely more strongly on predicates. And homogeneous equality is the next step toward a dependently typed core language. - - - - - 11d4fc50 by Ben Gamari at 2019-10-16T15:59:52-04:00 hadrian: Introduce enableDebugInfo flavour transformer Also refactor things a bit to eliminate repetition. - - - - - deb96399 by Ryan Scott at 2019-10-16T16:00:29-04:00 Make Coverage.TM a newtype - - - - - 42ebc3f6 by Brian Wignall at 2019-10-16T16:01:06-04:00 Add hyperlinks to PDF/HTML documentation; closes #17342 - - - - - b15a7fb8 by Ben Gamari at 2019-10-17T01:03:11-04:00 testsuite: Ensure that makefile tests get run Previously `makefile_test` and `run_command` tests could easily end up in a situation where they wouldn't be run if the user used the `only_ways` modifier. The reason is to build the set of a ways to run the test in we first start with a candidate set determined by the test type (e.g. `makefile_test`, `compile_run`, etc.) and then filter that set with the constraints given by the test's modifiers. `makefile_test` and `run_command` tests' candidate sets were simply `{normal}`, and consequently most uses of `only_ways` would result in the test being never run. To avoid this we rather use all ways as the candidate sets for these test types. This may result in a few more testcases than we would like (given that some `run_command` tests are insensitive to way) but this can be fixed by adding modifiers and we would much rather run too many tests than too few. This fixes #16042 and a number of other tests afflicted by the same issue. However, there were a few cases that required special attention: * `T14028` is currently failing and is therefore marked as broken due to #17300 * `T-signals-child` is fragile in the `threaded1` and `threaded2` ways (tracked in #17307) - - - - - 4efdda90 by Richard Eisenberg at 2019-10-17T01:03:51-04:00 Tiny fixes to comments around flattening. - - - - - c4c9904b by Ben Gamari at 2019-10-17T01:04:26-04:00 testsuite: Assert that testsuite ways are known This ensures that all testsuite way names given to `omit_ways`, `only_ways`, etc. are known ways. - - - - - 697be2b6 by Ömer Sinan Ağacan at 2019-10-18T15:26:53-04:00 rts/GC: Add an obvious assertion during block initialization Namely ensure that block descriptors are initialized with valid generation numbers. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 61d2ed42 by Ben Gamari at 2019-10-18T15:26:53-04:00 rts: Add Note explaining applicability of selector optimisation depth limit This was slightly non-obvious so a note seems deserved. - - - - - 11395037 by Ben Gamari at 2019-10-18T15:26:53-04:00 rts/Capability: A few documentation comments - - - - - 206f782a by Ben Gamari at 2019-10-18T15:26:53-04:00 rts: Give stack flags proper macros This were previously quite unclear and will change a bit under the non-moving collector so let's clear this up now. - - - - - 81d4675e by Ben Gamari at 2019-10-18T15:26:53-04:00 rts/GC: Refactor gcCAFs - - - - - 4d674c4e by Ben Gamari at 2019-10-18T15:26:53-04:00 rts: Fix macro parenthesisation - - - - - bfcafd39 by Ben Gamari at 2019-10-18T15:27:42-04:00 rts/Schedule: Allow synchronization without holding a capability The concurrent mark-and-sweep will be performed by a GHC task which will not hold a capability. This is necessary to avoid a concurrent mark from interfering with minor generation collections. However, the major collector must synchronize with the mutators at the end of marking to flush their update remembered sets. This patch extends the `requestSync` mechanism used to synchronize garbage collectors to allow synchronization without holding a capability. This change is fairly straightforward as the capability was previously only required for two reasons: 1. to ensure that we don't try to re-acquire a capability that we the sync requestor already holds. 2. to provide a way to suspend and later resume the sync request if there is already a sync pending. When synchronizing without holding a capability we needn't worry about consideration (1) at all. (2) is slightly trickier and may happen, for instance, when a capability requests a minor collection and shortly thereafter the non-moving mark thread requests a post-mark synchronization. In this case we need to ensure that the non-moving mark thread suspends his request until after the minor GC has concluded to avoid dead-locking. For this we introduce a condition variable, `sync_finished_cond`, which a non-capability-bearing requestor will wait on and which is signalled after a synchronization or GC has finished. - - - - - 921e4e36 by Ömer Sinan Ağacan at 2019-10-18T15:27:56-04:00 rts/BlockAlloc: Allow aligned allocation requests This implements support for block group allocations which are aligned to an integral number of blocks. This will be used by the nonmoving garbage collector, which uses the block allocator to allocate the segments which back its heap. These segments are a fixed number of blocks in size, with each segment being aligned to the segment size boundary. This allows us to easily find the segment metadata stored at the beginning of the segment. - - - - - 4b431f33 by Tamar Christina at 2019-10-20T16:21:10+01:00 Windows: Update tarballs to GCC 9.2 and remove MAX_PATH limit. - - - - - 8057ac96 by Ben Gamari at 2019-10-20T21:15:14-04:00 Merge branches 'wip/gc/sync-without-capability' and 'wip/gc/aligned-block-allocation' into wip/gc/preparation - - - - - 32500f64 by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00 rts/StableName: Expose FOR_EACH_STABLE_NAME, freeSnEntry, SNT_size These will be needed when we implement sweeping in the nonmoving collector. - - - - - 4be5152a by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Disable aggregate-return warnings from gcc This warning is a bit of a relic; there is little reason to avoid aggregate return values in 2019. - - - - - 04471c4f by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00 rts/Scav: Expose scavenging functions To keep the non-moving collector nicely separated from the moving collector its scavenging phase will live in another file, `NonMovingScav.c`. However, it will need to use these functions so let's expose them. - - - - - 6ff29c06 by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Introduce flag to enable the nonmoving old generation This flag will enable the use of a non-moving oldest generation. - - - - - b3ef2d1a by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Introduce debug flag for non-moving GC - - - - - 68e0647f by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00 rts: Non-concurrent mark and sweep This implements the core heap structure and a serial mark/sweep collector which can be used to manage the oldest-generation heap. This is the first step towards a concurrent mark-and-sweep collector aimed at low-latency applications. The full design of the collector implemented here is described in detail in a technical note B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell Compiler" (2018) The basic heap structure used in this design is heavily inspired by K. Ueno & A. Ohori. "A fully concurrent garbage collector for functional programs on multicore processors." /ACM SIGPLAN Notices/ Vol. 51. No. 9 (presented by ICFP 2016) This design is intended to allow both marking and sweeping concurrent to execution of a multi-core mutator. Unlike the Ueno design, which requires no global synchronization pauses, the collector introduced here requires a stop-the-world pause at the beginning and end of the mark phase. To avoid heap fragmentation, the allocator consists of a number of fixed-size /sub-allocators/. Each of these sub-allocators allocators into its own set of /segments/, themselves allocated from the block allocator. Each segment is broken into a set of fixed-size allocation blocks (which back allocations) in addition to a bitmap (used to track the liveness of blocks) and some additional metadata (used also used to track liveness). This heap structure enables collection via mark-and-sweep, which can be performed concurrently via a snapshot-at-the-beginning scheme (although concurrent collection is not implemented in this patch). The mark queue is a fairly straightforward chunked-array structure. The representation is a bit more verbose than a typical mark queue to accomodate a combination of two features: * a mark FIFO, which improves the locality of marking, reducing one of the major overheads seen in mark/sweep allocators (see [1] for details) * the selector optimization and indirection shortcutting, which requires that we track where we found each reference to an object in case we need to update the reference at a later point (e.g. when we find that it is an indirection). See Note [Origin references in the nonmoving collector] (in `NonMovingMark.h`) for details. Beyond this the mark/sweep is fairly run-of-the-mill. [1] R. Garner, S.M. Blackburn, D. Frampton. "Effective Prefetch for Mark-Sweep Garbage Collection." ISMM 2007. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - c7e73d12 by Ben Gamari at 2019-10-20T21:15:37-04:00 testsuite: Add nonmoving WAY This simply runs the compile_and_run tests with `-xn`, enabling the nonmoving oldest generation. - - - - - f8f77a07 by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Mark binder as const - - - - - bd8e3ff4 by Ben Gamari at 2019-10-20T21:15:52-04:00 rts: Implement concurrent collection in the nonmoving collector This extends the non-moving collector to allow concurrent collection. The full design of the collector implemented here is described in detail in a technical note B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell Compiler" (2018) This extension involves the introduction of a capability-local remembered set, known as the /update remembered set/, which tracks objects which may no longer be visible to the collector due to mutation. To maintain this remembered set we introduce a write barrier on mutations which is enabled while a concurrent mark is underway. The update remembered set representation is similar to that of the nonmoving mark queue, being a chunked array of `MarkEntry`s. Each `Capability` maintains a single accumulator chunk, which it flushed when it (a) is filled, or (b) when the nonmoving collector enters its post-mark synchronization phase. While the write barrier touches a significant amount of code it is conceptually straightforward: the mutator must ensure that the referee of any pointer it overwrites is added to the update remembered set. However, there are a few details: * In the case of objects with a dirty flag (e.g. `MVar`s) we can exploit the fact that only the *first* mutation requires a write barrier. * Weak references, as usual, complicate things. In particular, we must ensure that the referee of a weak object is marked if dereferenced by the mutator. For this we (unfortunately) must introduce a read barrier, as described in Note [Concurrent read barrier on deRefWeak#] (in `NonMovingMark.c`). * Stable names are also a bit tricky as described in Note [Sweeping stable names in the concurrent collector] (`NonMovingSweep.c`). We take quite some pains to ensure that the high thread count often seen in parallel Haskell applications doesn't affect pause times. To this end we allow thread stacks to be marked either by the thread itself (when it is executed or stack-underflows) or the concurrent mark thread (if the thread owning the stack is never scheduled). There is a non-trivial handshake to ensure that this happens without racing which is described in Note [StgStack dirtiness flags and concurrent marking]. Co-Authored-by: Ömer Sinan Ağacan <omer at well-typed.com> - - - - - dd1b4fdd by Ben Gamari at 2019-10-20T21:15:52-04:00 Nonmoving: Disable memory inventory with concurrent collection - - - - - 4a44ab33 by Ben Gamari at 2019-10-20T21:15:52-04:00 rts: Shrink size of STACK's dirty and marking fields - - - - - 10373416 by Ben Gamari at 2019-10-20T21:15:52-04:00 Don't cleanup until we've stopped the collector This requires that we break nonmovingExit into two pieces since we need to first stop the collector to relinquish any capabilities, then we need to shutdown the scheduler, then we need to free the nonmoving allocators. - - - - - 26c3827f by Ben Gamari at 2019-10-21T11:43:54-04:00 Nonmoving: Ensure write barrier vanishes in non-threaded RTS - - - - - 17e5a032 by Ben Gamari at 2019-10-21T11:43:54-04:00 ThreadPaused: Add barrer on updated thunk - - - - - 8ea316da by David Eichmann at 2019-10-22T02:07:48-04:00 CI: Always dump performance metrics. - - - - - aa31ceaf by Matthew Bauer at 2019-10-22T02:39:01-04:00 Replace freebsd-gnueabihf with freebsd FreeBSD does not support GNU libc, so it makes no sense to use this triple. Most likely previous builds were just using the FreeBSD libc instead of gnueabihf. To fix this, we should just use armv6-unknown-freebsd and armv7-unknown-freebsd triples. Note that both of these are actually "soft-float", not "hard-float". FreeBSD has never officially released hard-float arm32: https://wiki.freebsd.org/ARMTier1 - - - - - fd8b666a by Stefan Schulze Frielinghaus at 2019-10-22T02:39:03-04:00 Implement s390x LLVM backend. This patch adds support for the s390x architecture for the LLVM code generator. The patch includes a register mapping of STG registers onto s390x machine registers which enables a registerised build. - - - - - 2d2cc76f by Tilman Blumhagen at 2019-10-22T02:39:04-04:00 Documentation for (&&) and (&&) states that they are lazy in their second argument (fixes #17354) - - - - - 06d51c4e by Ben Gamari at 2019-10-22T12:13:36-04:00 Fix unregisterised build This required some fiddling around with the location of forward declarations since the C sources generated by GHC's C backend only includes Stg.h. - - - - - 912e440e by Ben Gamari at 2019-10-22T12:17:00-04:00 rts: Tracing support for nonmoving collection events This introduces a few events to mark key points in the nonmoving garbage collection cycle. These include: * `EVENT_CONC_MARK_BEGIN`, denoting the beginning of a round of marking. This may happen more than once in a single major collection since we the major collector iterates until it hits a fixed point. * `EVENT_CONC_MARK_END`, denoting the end of a round of marking. * `EVENT_CONC_SYNC_BEGIN`, denoting the beginning of the post-mark synchronization phase * `EVENT_CONC_UPD_REM_SET_FLUSH`, indicating that a capability has flushed its update remembered set. * `EVENT_CONC_SYNC_END`, denoting that all mutators have flushed their update remembered sets. * `EVENT_CONC_SWEEP_BEGIN`, denoting the beginning of the sweep portion of the major collection. * `EVENT_CONC_SWEEP_END`, denoting the end of the sweep portion of the major collection. - - - - - 9f42cd81 by Ben Gamari at 2019-10-22T12:17:00-04:00 rts: Introduce non-moving heap census This introduces a simple census of the non-moving heap (not to be confused with the heap census used by the heap profiler). This collects basic heap usage information (number of allocated and free blocks) which is useful when characterising fragmentation of the nonmoving heap. - - - - - 711837cc by Ben Gamari at 2019-10-22T12:17:00-04:00 rts/Eventlog: More descriptive error message - - - - - 0d31819e by Ben Gamari at 2019-10-22T12:17:00-04:00 Allow census without live word count Otherwise the census is unsafe when mutators are running due to concurrent mutation. - - - - - 6f173181 by Ben Gamari at 2019-10-22T12:17:00-04:00 NonmovingCensus: Emit samples to eventlog - - - - - 13dd78dd by Ben Gamari at 2019-10-22T12:18:33-04:00 Nonmoving: Allow aging and refactor static objects logic This commit does two things: * Allow aging of objects during the preparatory minor GC * Refactor handling of static objects to avoid the use of a hashtable - - - - - 7b79e8b4 by Ben Gamari at 2019-10-22T12:18:33-04:00 Disable aging when doing deadlock detection GC - - - - - 8fffe12b by Ben Gamari at 2019-10-22T12:18:33-04:00 More comments for aging - - - - - 039d2906 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Eliminate integer division in nonmovingBlockCount Perf showed that the this single div was capturing up to 10% of samples in nonmovingMark. However, the overwhelming majority of cases is looking at small block sizes. These cases we can easily compute explicitly, allowing the compiler to turn the division into a significantly more efficient division-by-constant. While the increase in source code looks scary, this all optimises down to very nice looking assembler. At this point the only remaining hotspots in nonmovingBlockCount are due to memory access. - - - - - d15ac82d by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Allocate mark queues in larger block groups - - - - - 26d2d331 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMovingMark: Optimize representation of mark queue This shortens MarkQueueEntry by 30% (one word) - - - - - e5eda61e by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Optimize bitmap search during allocation Use memchr instead of a open-coded loop. This is nearly twice as fast in a synthetic benchmark. - - - - - dacf4cae by Ben Gamari at 2019-10-22T12:18:39-04:00 rts: Add prefetch macros - - - - - 786c52d2 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Prefetch when clearing bitmaps Ensure that the bitmap of the segmentt that we will clear next is in cache by the time we reach it. - - - - - 0387df5b by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Inline nonmovingClearAllBitmaps - - - - - e893877e by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Fuse sweep preparation into mark prep - - - - - e6f6823f by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Pre-fetch during mark This improved overall runtime on nofib's constraints test by nearly 10%. - - - - - 56c5ebdc by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Prefetch segment header - - - - - 19bfe460 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Optimise allocator cache behavior Previously we would look at the segment header to determine the block size despite the fact that we already had the block size at hand. - - - - - 53a1a27e by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMovingMark: Eliminate redundant check_in_nonmoving_heaps - - - - - b967e470 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Don't do major GC if one is already running Previously we would perform a preparatory moving collection, resulting in many things being added to the mark queue. When we finished with this we would realize in nonmovingCollect that there was already a collection running, in which case we would simply not run the nonmoving collector. However, it was very easy to end up in a "treadmilling" situation: all subsequent GC following the first failed major GC would be scheduled as major GCs. Consequently we would continuously feed the concurrent collector with more mark queue entries and it would never finish. This patch aborts the major collection far earlier, meaning that we avoid adding nonmoving objects to the mark queue and allowing the concurrent collector to finish. - - - - - 3bc172a4 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Clean mut_list - - - - - 8e79e2a9 by Ben Gamari at 2019-10-22T12:18:39-04:00 Unconditionally flush update remembered set during minor GC Flush the update remembered set. The goal here is to flush periodically to ensure that we don't end up with a thread who marks their stack on their local update remembered set and doesn't flush until the nonmoving sync period as this would result in a large fraction of the heap being marked during the sync pause. - - - - - b281e80b by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Add nonmoving_thr way - - - - - 07987957 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Add nonmoving_thr_ghc way This uses the nonmoving collector when compiling the testcases. - - - - - 01fd0242 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Don't run T15892 in nonmoving ways The nonmoving GC doesn't support `+RTS -G1`, which this test insists on. - - - - - 097f4fd0 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Nonmoving collector doesn't support -G1 - - - - - 4b91dd25 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Ensure that threaded tests are run in nonmoving_thr - - - - - 78ce35b9 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: bug1010 requires -c, which isn't supported by nonmoving - - - - - 6e97cc47 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Skip T15892 in nonmoving_thr_ghc - - - - - 5ce853c8 by Ben Gamari at 2019-10-22T12:18:44-04:00 ghc-heap: Skip heap_all test with debugged RTS The debugged RTS initializes the heap with 0xaa, which breaks the (admittedly rather fragile) assumption that uninitialized fields are set to 0x00: ``` Wrong exit code for heap_all(nonmoving)(expected 0 , actual 1 ) Stderr ( heap_all ): heap_all: user error (assertClosuresEq: Closures do not match Expected: FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 0, code = Nothing}, ptrArgs = [], dataArgs = [0]} Actual: FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 1032832, code = Nothing}, ptrArgs = [], dataArgs = [12297829382473034410]} CallStack (from HasCallStack): assertClosuresEq, called at heap_all.hs:230:9 in main:Main ) ``` - - - - - 6abefce7 by Ben Gamari at 2019-10-22T12:18:44-04:00 Skip ghc_heap_all test in nonmoving ways - - - - - 99baff8c by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Don't run T9630 in nonmoving ways The nonmoving collector doesn't support -G1 - - - - - 25ae8f7d by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Don't run T7160 in nonmoving_thr ways The nonmoving way finalizes things in a different order. - - - - - 8cab149b by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Mark length001 as failing under nonmoving ways This is consistent with the other unoptimized ways. - - - - - 5b130b3d by Ben Gamari at 2019-10-22T12:18:46-04:00 Merge branches 'wip/gc/optimize' and 'wip/gc/test' into wip/gc/everything - - - - - 246ce2af by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00 NonMoving: Implement indirection shortcutting This allows indirection chains residing in the non-moving heap to be shorted-out. - - - - - 875861ef by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00 NonMoving: Implement selector optimisation - - - - - c72e84c6 by Ben Gamari at 2019-10-22T12:20:15-04:00 NonMovingMark: Handle INDs left by shortcutting - - - - - 0f8fd3c6 by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00 NonMoving: Implement -xns to disable selector optimization - - - - - c936a245 by Ben Gamari at 2019-10-22T12:20:37-04:00 NonMoving: Introduce nonmovingSegmentLogBlockSize acccessor This will allow us to easily move the block size elsewhere. - - - - - 6dcef5ee by Ben Gamari at 2019-10-22T12:20:37-04:00 NonMoving: Move block size to block descriptor - - - - - dd8d1b49 by Ben Gamari at 2019-10-22T12:20:37-04:00 NonMoving: Move next_free_snap to block descriptor - - - - - 116e4646 by Ben Gamari at 2019-10-22T12:20:46-04:00 NonMoving: Add summarizing Note - - - - - 22eee2bc by Ben Gamari at 2019-10-22T12:20:48-04:00 Merge branches 'wip/gc/segment-header-to-bdescr' and 'wip/gc/docs' into wip/gc/everything2 - - - - - 3a862703 by Ömer Sinan Ağacan at 2019-10-22T18:56:32-04:00 rts: COMPACT_NFDATA support for the nonmoving collector This largely follows the model used for large objects, with appropriate adjustments made to account for references in the sharing deduplication hashtable. - - - - - 7c35d39b by Ben Gamari at 2019-10-22T18:56:32-04:00 rts: Mark nonmoving GC paths in moving collector as unlikely The expectation here is that the nonmoving GC is latency-centric, whereas the moving GC emphasizes throughput. Therefore we give the latter the benefit of better static branch prediction. - - - - - 91109404 by Ben Gamari at 2019-10-22T18:57:27-04:00 nonmoving: Trace GC preparation steps - - - - - a69b28f4 by Ben Gamari at 2019-10-22T18:57:27-04:00 nonmoving: Don't do two passes over large and compact object lists Previously we would first move the new objects to their appropriate non-moving GC list, then do another pass over that list to clear their mark bits. This is needlessly expensive. First clear the mark bits of the existing objects, then add the newly evacuated objects and, at the same time, clear their mark bits. This cuts the preparatory GC time in half for the Pusher benchmark with a large queue size. - - - - - 984745b0 by Ben Gamari at 2019-10-22T18:57:27-04:00 nonmoving: Upper-bound time we hold SM_MUTEX for during sweep - - - - - 96c5411a by David Feuer at 2019-10-23T05:58:37-04:00 Use an IORef for QSemN Replace the outer `MVar` in `QSemN` with an `IORef`. This should probably be lighter, and it removes the need for `uninterruptibleMask`. Previously Differential Revision https://phabricator.haskell.org/D4896 - - - - - faa30dcb by Andreas Klebinger at 2019-10-23T05:58:43-04:00 Warn about missing profiled libs when using the Interpreter. When GHC itself, or it's interpreter is profiled we need to load profiled libraries as well. This requirement is not always obvious, especially when TH implicilty uses the interpreter. When the libs were not found we fall back to assuming the are in a DLL. This is usually not the case so now we warn users when we do so. This makes it more obvious what is happening and gives users a way to fix the issue. This fixes #17121. - - - - - 1cd3fa29 by Richard Eisenberg at 2019-10-23T05:58:46-04:00 Implement a coverage checker for injectivity This fixes #16512. There are lots of parts of this patch: * The main payload is in FamInst. See Note [Coverage condition for injective type families] there for the overview. But it doesn't fix the bug. * We now bump the reduction depth every time we discharge a CFunEqCan. See Note [Flatten when discharging CFunEqCan] in TcInteract. * Exploration of this revealed a new, easy to maintain invariant for CTyEqCans. See Note [Almost function-free] in TcRnTypes. * We also realized that type inference for injectivity was a bit incomplete. This means we exchanged lookupFlattenTyVar for rewriteTyVar. See Note [rewriteTyVar] in TcFlatten. The new function is monadic while the previous one was pure, necessitating some faff in TcInteract. Nothing too bad. * zonkCt did not maintain invariants on CTyEqCan. It's not worth the bother doing so, so we just transmute CTyEqCans to CNonCanonicals. * The pure unifier was finding the fixpoint of the returned substitution, even when doing one-way matching (in tcUnifyTysWithTFs). Fixed now. Test cases: typecheck/should_fail/T16512{a,b} - - - - - 900cf195 by Alp Mestanogullari at 2019-10-23T05:58:48-04:00 compiler: introduce DynFlags plugins They have type '[CommandLineOpts] -> Maybe (DynFlags -> IO DynFlags)'. All plugins that supply a non-Nothing 'dynflagsPlugin' will see their updates applied to the current DynFlags right after the plugins are loaded. One use case for this is to superseede !1580 for registering hooks from a plugin. Frontend/parser plugins were considered to achieve this but they respectively conflict with how this plugin is going to be used and don't allow overriding/modifying the DynFlags, which is how hooks have to be registered. This commit comes with a test, 'test-hook-plugin', that registers a "fake" meta hook that replaces TH expressions with the 0 integer literal. - - - - - a19c7d17 by Ryan Scott at 2019-10-23T05:58:49-04:00 Reify oversaturated data family instances correctly (#17296) `TcSplice` was not properly handling oversaturated data family instances, such as the example in #17296, as it dropped arguments due to carelessly zipping data family instance arguments with `tyConTyVars`. For data families, the number of `tyConTyVars` can sometimes be less than the number of arguments it can accept in a data family instance due to the fact that data family instances can be oversaturated. To account for this, `TcSplice.mkIsPolyTvs` has now been renamed to `tyConArgsPolyKinded` and now factors in `tyConResKind` in addition to `tyConTyVars`. I've also added `Note [Reified instances and explicit kind signatures]` which explains the various subtleties in play here. Fixes #17296. - - - - - 9b2a5008 by Ben Gamari at 2019-10-23T05:58:50-04:00 testsuite: Don't run T7653 in ghci and profiled ways Currently this routinely fails in the i386 job. See #7653. - - - - - b521e8b6 by Ömer Sinan Ağacan at 2019-10-23T05:58:57-04:00 Refactor Compact.c: - Remove forward declarations - Introduce UNTAG_PTR and GET_PTR_TAG for dealing with pointer tags without having to cast arguments to StgClosure* - Remove dead code - Use W_ instead of StgWord - Use P_ instead of StgPtr - - - - - 17987a4b by Matthew Pickering at 2019-10-23T05:58:58-04:00 eventlog: Dump cost centre stack on each sample With this change it is possible to reconstruct the timing portion of a `.prof` file after the fact. By logging the stacks at each time point a more precise executation trace of the program can be observed rather than all identical cost centres being identified in the report. There are two new events: 1. `EVENT_PROF_BEGIN` - emitted at the start of profiling to communicate the tick interval 2. `EVENT_PROF_SAMPLE_COST_CENTRE` - emitted on each tick to communicate the current call stack. Fixes #17322 - - - - - 4798f3b9 by Takenobu Tani at 2019-10-23T05:59:00-04:00 Allow command name resolution for GHCi commands with option `!` #17345 This commit allows command name resolution for GHCi commands with option `!` as follows: ghci> :k! Int Int :: * = Int This commit changes implementation as follows: Before: * Prefix match with full string including the option `!` (e.g. `k!`) After (this patch): * Prefix match without option suffix `!` (e.g. `k`) * in addition, suffix match with option `!` See also #8305 and #8113 - - - - - aa778152 by Andreas Klebinger at 2019-10-23T05:59:01-04:00 Fix bug in the x86 backend involving the CFG. This is part two of fixing #17334. There are two parts to this commit: - A bugfix for computing loop levels - A bugfix of basic block invariants in the NCG. ----------------------------------------------------------- In the first bug we ended up with a CFG of the sort: [A -> B -> C] This was represented via maps as fromList [(A,B),(B,C)] and later transformed into a adjacency array. However the transformation did not include block C in the array (since we only looked at the keys of the map). This was still fine until we tried to look up successors for C and tried to read outside of the array bounds when accessing C. In order to prevent this in the future I refactored to code to include all nodes as keys in the map representation. And make this a invariant which is checked in a few places. Overall I expect this to make the code more robust as now any failed lookup will represent an error, versus failed lookups sometimes being expected and sometimes not. In terms of performance this makes some things cheaper (getting a list of all nodes) and others more expensive (adding a new edge). Overall this adds up to no noteable performance difference. ----------------------------------------------------------- Part 2: When the NCG generated a new basic block, it did not always insert a NEWBLOCK meta instruction in the stream which caused a quite subtle bug. During instruction selection a statement `s` in a block B with control of the sort: B -> C will sometimes result in control flow of the sort: ┌ < ┐ v ^ B -> B1 ┴ -> C as is the case for some atomic operations. Now to keep the CFG in sync when introducing B1 we clearly want to insert it between B and C. However there is a catch when we have to deal with self loops. We might start with code and a CFG of these forms: loop: stmt1 ┌ < ┐ .... v ^ stmtX loop ┘ stmtY .... goto loop: Now we introduce B1: ┌ ─ ─ ─ ─ ─┐ loop: │ ┌ < ┐ │ instrs v │ │ ^ .... loop ┴ B1 ┴ ┘ instrsFromX stmtY goto loop: This is simple, all outgoing edges from loop now simply start from B1 instead and the code generator knows which new edges it introduced for the self loop of B1. Disaster strikes if the statement Y follows the same pattern. If we apply the same rule that all outgoing edges change then we end up with: loop ─> B1 ─> B2 ┬─┐ │ │ └─<┤ │ │ └───<───┘ │ └───────<────────┘ This is problematic. The edge B1->B1 is modified as expected. However the modification is wrong! The assembly in this case looked like this: _loop: <instrs> _B1: ... cmpxchgq ... jne _B1 <instrs> <end _B1> _B2: ... cmpxchgq ... jne _B2 <instrs> jmp loop There is no edge _B2 -> _B1 here. It's still a self loop onto _B1. The problem here is that really B1 should be two basic blocks. Otherwise we have control flow in the *middle* of a basic block. A contradiction! So to account for this we add yet another basic block marker: _B: <instrs> _B1: ... cmpxchgq ... jne _B1 jmp _B1' _B1': <instrs> <end _B1> _B2: ... Now when inserting B2 we will only look at the outgoing edges of B1' and everything will work out nicely. You might also wonder why we don't insert jumps at the end of _B1'. There is no way another block ends up jumping to the labels _B1 or _B2 since they are essentially invisible to other blocks. View them as control flow labels local to the basic block if you'd like. Not doing this ultimately caused (part 2 of) #17334. - - - - - 1f40e68a by Ryan Yates at 2019-10-23T05:59:03-04:00 Full abort on validate failure merging `orElse`. Previously partial roll back of a branch of an `orElse` was attempted if validation failure was observed. Validation here, however, does not account for what part of the transaction observed inconsistent state. This commit fixes this by fully aborting and restarting the transaction. - - - - - 9c1f0f7c by Ben Gamari at 2019-10-23T05:59:03-04:00 Bump stm submodule - - - - - 6beea836 by Andreas Klebinger at 2019-10-23T05:59:04-04:00 Make dynflag argument for withTiming pure. 19 times out of 20 we already have dynflags in scope. We could just always use `return dflags`. But this is in fact not free. When looking at some STG code I noticed that we always allocate a closure for this expression in the heap. Clearly a waste in these cases. For the other cases we can either just modify the callsite to get dynflags or use the _D variants of withTiming I added which will use getDynFlags under the hood. - - - - - 8dd480cc by Matthew Pickering at 2019-10-23T05:59:06-04:00 Performance tests: Reduce acceptance threshold for bytes allocated tests The "new" performance testing infrastructure resets the baseline after every test so it's easy to miss gradual performance regressions over time. We should at least make these numbers smaller to catch patches which affect performance earlier. - - - - - 4af20bbc by Ben Gamari at 2019-10-23T05:59:06-04:00 users-guide: Fix :since: for -Wunused-packages Fixes #17382. - - - - - 21663693 by Ben Gamari at 2019-10-23T05:59:07-04:00 Drop duplicate -optl's from GHC invocations Previously the make build system would pass things like `-optl-optl-Wl,-x -optl-optl-Wl,noexecstack` to GHC. This would naturally result in mass confusion as GHC would pass `-optl-Wl,-x` to GCC. GCC would in turn interpret this as `-o ptl-Wl,-x`, setting the output pass of the invocation. The problem that `-optl` was added to the command-line in two places in the build system. Fix this. Fixes #17385. - - - - - bb0dc5a5 by Andreas Klebinger at 2019-10-23T05:59:07-04:00 Hadrian: Invoke ghc0 via bash when running tests to fix #17362. cmd uses RawCommand which uses Windows semantics to find the executable which sometimes seems to fail for unclear reasons. If we invoke ghc via bash then bash will find the ghc executable and the issue goes away. - - - - - 266435a7 by Ömer Sinan Ağacan at 2019-10-23T05:59:09-04:00 Add new flag for unarised STG dumps Previously -ddump-stg would dump pre and post-unarise STGs. Now we have a new flag for post-unarise STG and -ddump-stg only dumps coreToStg output. STG dump flags after this commit: - -ddump-stg: Dumps CoreToStg output - -ddump-stg-unarised: Unarise output - -ddump-stg-final: STG right before code gen (includes CSE and lambda lifting) - - - - - 8abddac8 by Ben Gamari at 2019-10-23T05:59:10-04:00 base: Add @since on GHC.IO.Handle.Lock.hUnlock Unfortunately this was introduced in base-4.11.0 (GHC 8.4.1) whereas the other locking primitives were added in base-4.10.0 (GHC 8.2.1). - - - - - 7f72b540 by Ben Gamari at 2019-10-23T14:56:46-04:00 Merge non-moving garbage collector This introduces a concurrent mark & sweep garbage collector to manage the old generation. The concurrent nature of this collector typically results in significantly reduced maximum and mean pause times in applications with large working sets. Due to the large and intricate nature of the change I have opted to preserve the fully-buildable history, including merge commits, which is described in the "Branch overview" section below. Collector design ================ The full design of the collector implemented here is described in detail in a technical note > B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell > Compiler" (2018) This document can be requested from @bgamari. The basic heap structure used in this design is heavily inspired by > K. Ueno & A. Ohori. "A fully concurrent garbage collector for > functional programs on multicore processors." /ACM SIGPLAN Notices/ > Vol. 51. No. 9 (presented at ICFP 2016) This design is intended to allow both marking and sweeping concurrent to execution of a multi-core mutator. Unlike the Ueno design, which requires no global synchronization pauses, the collector introduced here requires a stop-the-world pause at the beginning and end of the mark phase. To avoid heap fragmentation, the allocator consists of a number of fixed-size /sub-allocators/. Each of these sub-allocators allocators into its own set of /segments/, themselves allocated from the block allocator. Each segment is broken into a set of fixed-size allocation blocks (which back allocations) in addition to a bitmap (used to track the liveness of blocks) and some additional metadata (used also used to track liveness). This heap structure enables collection via mark-and-sweep, which can be performed concurrently via a snapshot-at-the-beginning scheme (although concurrent collection is not implemented in this patch). Implementation structure ======================== The majority of the collector is implemented in a handful of files: * `rts/Nonmoving.c` is the heart of the beast. It implements the entry-point to the nonmoving collector (`nonmoving_collect`), as well as the allocator (`nonmoving_allocate`) and a number of utilities for manipulating the heap. * `rts/NonmovingMark.c` implements the mark queue functionality, update remembered set, and mark loop. * `rts/NonmovingSweep.c` implements the sweep loop. * `rts/NonmovingScav.c` implements the logic necessary to scavenge the nonmoving heap. Branch overview =============== ``` * wip/gc/opt-pause: | A variety of small optimisations to further reduce pause times. | * wip/gc/compact-nfdata: | Introduce support for compact regions into the non-moving |\ collector | \ | \ | | * wip/gc/segment-header-to-bdescr: | | | Another optimization that we are considering, pushing | | | some segment metadata into the segment descriptor for | | | the sake of locality during mark | | | | * | wip/gc/shortcutting: | | | Support for indirection shortcutting and the selector optimization | | | in the non-moving heap. | | | * | | wip/gc/docs: | |/ Work on implementation documentation. | / |/ * wip/gc/everything: | A roll-up of everything below. |\ | \ | |\ | | \ | | * wip/gc/optimize: | | | A variety of optimizations, primarily to the mark loop. | | | Some of these are microoptimizations but a few are quite | | | significant. In particular, the prefetch patches have | | | produced a nontrivial improvement in mark performance. | | | | | * wip/gc/aging: | | | Enable support for aging in major collections. | | | | * | wip/gc/test: | | | Fix up the testsuite to more or less pass. | | | * | | wip/gc/instrumentation: | | | A variety of runtime instrumentation including statistics | | / support, the nonmoving census, and eventlog support. | |/ | / |/ * wip/gc/nonmoving-concurrent: | The concurrent write barriers. | * wip/gc/nonmoving-nonconcurrent: | The nonmoving collector without the write barriers necessary | for concurrent collection. | * wip/gc/preparation: | A merge of the various preparatory patches that aren't directly | implementing the GC. | | * GHC HEAD . . . ``` - - - - - 83655b06 by Ben Gamari at 2019-10-24T08:45:41-04:00 hadrian: Warn user if hadrian build fails due to lack of threaded RTS See #16873. - - - - - 6824f29a by Ryan Scott at 2019-10-24T08:46:19-04:00 Parenthesize GADT return types in pprIfaceConDecl (#17384) We were using `pprIfaceAppArgs` instead of `pprParendIfaceAppArgs` in `pprIfaceConDecl`. Oops. Fixes #17384. - - - - - 9de3f8b1 by Ryan Scott at 2019-10-24T18:38:32-04:00 Make isTcLevPoly more conservative with newtypes (#17360) `isTcLevPoly` gives an approximate answer for when a type constructor is levity polymorphic when fully applied, where `True` means "possibly levity polymorphic" and `False` means "definitely not levity polymorphic". `isTcLevPoly` returned `False` for newtypes, which is incorrect in the presence of `UnliftedNewtypes`, leading to #17360. This patch tweaks `isTcLevPoly` to return `True` for newtypes instead. Fixes #17360. - - - - - 243c72eb by Ryan Scott at 2019-10-24T18:39:08-04:00 Mark promoted InfixT names as IsPromoted (#17394) We applied a similar fix for `ConT` in #15572 but forgot to apply the fix to `InfixT` as well. This patch fixes #17394 by doing just that. - - - - - 87175e78 by James Foster at 2019-10-25T09:01:08-04:00 Make Hadrian use -dynamic-too in the basic case This commit makes Hadrian use the `-dynamic-too` flag when the current Flavour's libraryWays contains both vanilla and dynamic, cutting down the amount of repeated work caused by separate compilation of dynamic and static files. It does this for the basic case where '.o' and '.dyn_o' files are built with one command, but does not generalise to cases like '.prof_o' and '.prof_dyn_o'. - - - - - ecd89062 by Alp Mestanogullari at 2019-10-25T09:01:47-04:00 hadrian/ci: run testsuite against a freshly produced and installed bindist - - - - - 2a16b555 by Ben Gamari at 2019-10-25T09:02:26-04:00 testsuite: Mark T13786 as fragile in unreg build Due to #17018. - - - - - 08298926 by Ben Gamari at 2019-10-25T09:02:26-04:00 testsuite: Use fragile modifier in TH_foreignInterruptible It looks like this use of `skip` snuck through my previous refactoring. - - - - - 4c7d45d1 by Brian Wignall at 2019-10-25T09:03:04-04:00 Make documentation for byteSwap16 consistent with byteSwap32 (impl is same, with s/16/32) - - - - - 02822d84 by Ben Gamari at 2019-10-25T09:03:40-04:00 aclocal: A bit of reformatting - - - - - 519f5162 by Ben Gamari at 2019-10-25T09:03:40-04:00 configure: Drop GccLT46 GCC 4.6 was released 7 years ago. I think we can finally assume that it's available. This is a simplification prompted by #15742. - - - - - acedfc8b by Ben Gamari at 2019-10-25T09:04:16-04:00 gitlab-ci: Run check-uniques during lint job - - - - - 8916e64e by Andrew Martin at 2019-10-26T05:19:38-04:00 Implement shrinkSmallMutableArray# and resizeSmallMutableArray#. This is a part of GHC Proposal #25: "Offer more array resizing primitives". Resources related to the proposal: - Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/121 - Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0025-resize-boxed.rst Only shrinkSmallMutableArray# is implemented as a primop since a library-space implementation of resizeSmallMutableArray# (in GHC.Exts) is no less efficient than a primop would be. This may be replaced by a primop in the future if someone devises a strategy for growing arrays in-place. The library-space implementation always copies the array when growing it. This commit also tweaks the documentation of the deprecated sizeofMutableByteArray#, removing the mention of concurrency. That primop is unsound even in single-threaded applications. Additionally, the non-negativity assertion on the existing shrinkMutableByteArray# primop has been removed since this predicate is trivially always true. - - - - - 1be9c35c by Roland Senn at 2019-10-26T05:20:14-04:00 Fix #14690 - :steplocal panics after break-on-error `:steplocal` enables only breakpoints in the current top-level binding. When a normal breakpoint is hit, then the module name and the break id from the `BRK_FUN` byte code allow us to access the corresponding entry in a ModBreak table. From this entry we then get the SrcSpan (see compiler/main/InteractiveEval.hs:bindLocalsAtBreakpoint). With this source-span we can then determine the current top-level binding, needed for the steplocal command. However, if we break at an exception or at an error, we don't have an BRK_FUN byte-code, so we don't have any source information. The function `bindLocalsAtBreakpoint` creates an `UnhelpfulSpan`, which doesn't allow us to determine the current top-level binding. To avoid a `panic`, we have to check for `UnhelpfulSpan` in the function `ghc/GHCi/UI.hs:stepLocalCmd`. Hence a :steplocal command after a break-on-exception or a break-on-error is not possible. - - - - - 4820af10 by Adam Sandberg Eriksson at 2019-10-26T19:53:01-04:00 hadrian: point link to ghc gitlab [skip ci] - - - - - 609c7ee6 by Ben Gamari at 2019-10-26T19:53:36-04:00 gitlab-ci: Produce ARMv7 binary distributions - - - - - 8ac49411 by Ben Gamari at 2019-10-26T19:53:36-04:00 testsuite: Skip regalloc_unit_tests unless have_ncg This is a unit test for the native code generator's register allocator; naturally. the NCG is required. - - - - - 60575596 by Ben Gamari at 2019-10-26T19:53:36-04:00 Enable PDF documentation - - - - - 417f59d4 by Ben Gamari at 2019-10-26T19:53:36-04:00 rts: Fix ARM linker includes * Prefer #pragma once over guard macros * Drop redundant #includes * Fix order to ensure that necessary macros are defined when we condition on them - - - - - 4054f0e5 by Ömer Sinan Ağacan at 2019-10-26T19:54:16-04:00 Remove redundant -fno-cse options These were probably added with some GLOBAL_VARs, but those GLOBAL_VARs are now gone. - - - - - c62817f2 by Luke Lau at 2019-10-27T11:35:40-04:00 Fix RankNTypes :ghc-flag: in users guide This fixes a hadrian `build docs` failure - - - - - fc3a5205 by Luke Lau at 2019-10-27T11:35:40-04:00 Remove unused import - - - - - d2520bef by Luke Lau at 2019-10-27T11:35:40-04:00 Fix path to ghc-flags in users guide Hadrian rules It should point to the _build directory, not the source - - - - - 896d470a by Luke Lau at 2019-10-27T11:35:40-04:00 Add back documentation for deprecated -Whi-shadowing This was removed in b538476be3706264620c072e6e436debf9e0d3e4, but without it the compare-flags.py script fails. This adds it back and marks it as deprecated, with a notice that it is slated for removal. - - - - - 7d80f8b5 by Luke Lau at 2019-10-27T11:35:40-04:00 Remove documented flags from expected-undocumented-flags.txt - - - - - fa0d4809 by Ryan Scott at 2019-10-27T11:36:17-04:00 Parenthesize nullary constraint tuples using sigPrec (#17403) We were using `appPrec`, not `sigPrec`, as the precedence when determining whether or not to parenthesize `() :: Constraint`, which lead to the parentheses being omitted in function contexts like `(() :: Constraint) => String`. Easily fixed. Fixes #17403. - - - - - 90d06fd0 by Ben Gamari at 2019-10-27T17:27:17-04:00 hadrian: Silence output from Support SMP check Previously we would allow the output from the check of SMP support introduced by 83655b06e6d3e93b2d15bb0fa250fbb113d7fe68 leak to stdout. Silence this. See #16873. - - - - - 6635a3f6 by Josef Svenningsson at 2019-10-28T09:20:34-04:00 Fix #15344: use fail when desugaring applicative-do Applicative-do has a bug where it fails to use the monadic fail method when desugaring patternmatches which can fail. See #15344. This patch fixes that problem. It required more rewiring than I had expected. Applicative-do happens mostly in the renamer; that's where decisions about scheduling are made. This schedule is then carried through the typechecker and into the desugarer which performs the actual translation. Fixing this bug required sending information about the fail method from the renamer, through the type checker and into the desugarer. Previously, the desugarer didn't have enough information to actually desugar pattern matches correctly. As a side effect, we also fix #16628, where GHC wouldn't catch missing MonadFail instances with -XApplicativeDo. - - - - - cd9b9459 by Ryan Scott at 2019-10-28T09:21:13-04:00 Refactor TcDeriv to validity-check less in anyclass/via deriving (#13154) Due to the way `DerivEnv` is currently structured, there is an invariant that every derived instance must consist of a class applied to a non-empty list of argument types, where the last argument *must* be an application of a type constructor to some arguments. This works for many cases, but there are also some design patterns in standalone `anyclass`/`via` deriving that are made impossible due to enforcing this invariant, as documented in #13154. This fixes #13154 by refactoring `TcDeriv` and friends to perform fewer validity checks when using the `anyclass` or `via` strategies. The highlights are as followed: * Five fields of `DerivEnv` have been factored out into a new `DerivInstTys` data type. These fields only make sense for instances that satisfy the invariant mentioned above, so `DerivInstTys` is now only used in `stock` and `newtype` deriving, but not in other deriving strategies. * There is now a `Note [DerivEnv and DerivSpecMechanism]` describing the bullet point above in more detail, as well as explaining the exact requirements that each deriving strategy imposes. * I've refactored `mkEqnHelp`'s call graph to be slightly less complicated. Instead of the previous `mkDataTypeEqn`/`mkNewTypeEqn` dichotomy, there is now a single entrypoint `mk_eqn`. * Various bits of code were tweaked so as not to use fields that are specific to `DerivInstTys` so that they may be used by all deriving strategies, since not all deriving strategies use `DerivInstTys`. - - - - - e0e04856 by Alan Zimmerman at 2019-10-28T09:21:58-04:00 Attach API Annotations for {-# SOURCE #-} import pragma Attach the API annotations for the start and end locations of the {-# SOURCE #-} pragma in an ImportDecl. Closes #17388 - - - - - e951f219 by Sebastian Graf at 2019-10-28T09:22:35-04:00 Use FlexibleInstances for `Outputable (* p)` instead of match-all instances with equality constraints In #17304, Richard and Simon dicovered that using `-XFlexibleInstances` for `Outputable` instances of AST data types means users can provide orphan `Outputable` instances for passes other than `GhcPass`. Type inference doesn't currently to suffer, and Richard gave an example in #17304 that shows how rare a case would be where the slightly worse type inference would matter. So I went ahead with the refactoring, attempting to fix #17304. - - - - - ad1fe274 by Simon Peyton Jones at 2019-10-28T09:23:14-04:00 Better arity for join points A join point was getting too large an arity, leading to #17294. I've tightened up the invariant: see CoreSyn, Note [Invariants on join points], invariant 2b - - - - - fb4f245c by Takenobu Tani at 2019-10-29T03:45:02-04:00 users-guide: Fix :since: for -xn flag [skip ci] - - - - - 35abbfee by Takenobu Tani at 2019-10-29T03:45:41-04:00 users-guide: Add some new features and fix warnings for GHC 8.10 This updates the following: * Add description for ImportQualifiedPost extension * Add description for ghci command name resolution * Fix markdown warnings [skip ci] - - - - - 57dc1565 by Sylvain Henry at 2019-10-29T03:46:22-04:00 Use `not#` primitive to implement Word's complement - - - - - 28e52732 by Ben Gamari at 2019-10-29T03:46:59-04:00 linters: Add mode to lint given set of files This makes testing much easier. - - - - - db43b3b3 by Ben Gamari at 2019-10-29T03:46:59-04:00 linters: Add linter to catch unquoted use of $(TEST_HC) This is a common bug that creeps into Makefiles (e.g. see T12674). - - - - - ebee0d6b by Ben Gamari at 2019-10-29T03:46:59-04:00 testsuite: Fix quoting of $(TEST_HC) in T12674 I have no idea how this went unnoticed until now. - - - - - 3bd3456f by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 Refactor HscRecomp constructors: Make it evident in the constructors that the final interface is only available when HscStatus is not HscRecomp. (When HscStatus == HscRecomp we need to finish the compilation to get the final interface) `Maybe ModIface` return value of hscIncrementalCompile and the partial `expectIface` function are removed. - - - - - bbdd54aa by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 Return ModIface in compilation pipeline, remove IORef hack for generating ModIfaces The compilation phases now optionally return ModIface (for phases that generate an interface, currently only HscOut when (re)compiling a file). The value is then used by compileOne' to return the generated interface with HomeModInfo (which is then used by the batch mode compiler when building rest of the tree). hscIncrementalMode also returns a DynFlags with plugin info, to be used in the rest of the pipeline. Unfortunately this introduces a (perhaps less bad) hack in place of the previous IORef: we now record the DynFlags used to generate the partial infterface in HscRecomp and use the same DynFlags when generating the full interface. I spent almost three days trying to understand what's changing in DynFlags that causes a backpack test to fail, but I couldn't figure it out. There's a FIXME added next to the field so hopefully someone who understands this better than I do will fix it leter. - - - - - a56433a9 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 Remove unused DynFlags arg of lookupIfaceByModule - - - - - dcd40c71 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 HscMain: Move a comment closer to the relevant site - - - - - 593f6543 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 MkIface: Remove redundant parameter and outdated comments from addFingerprints - - - - - f868e1fe by Ben Gamari at 2019-10-29T03:48:20-04:00 gitlab-ci: Use Hadrian for unregisterised job - - - - - 7b2ecbc0 by Ben Gamari at 2019-10-29T03:48:20-04:00 gitlab-ci: Factor out Linux Hadrian validation logic - - - - - 8e5de15d by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Define USE_LIBFFI_FOR_ADJUSTORS when necessary - - - - - 6a090270 by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Define NOSMP when building rts unregisterised It seems that NOSMP was previously only defined when compiling the compiler, not the RTS. Fix this. In addition do some spring-cleaning and make the logic match that of the Make build system. - - - - - b741d19d by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Shuffle around RTS build flags Some of these flags wanted to be passed to .cmm builds as well as C builds. - - - - - d7cedd9d by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Drop -Werror=unused-but-set-variable from GHC flags Previously `hadrian` would pass `-optc-Werror=unused-but-set-variable` to all GHC invocations. This was a difference from the make build system and cause the unregisterised build to fail as the C that GHC produces contains many unused functions. Drop it from the GHC flags. Note, however, that the flag is still present in `Settings.Builders.Common.cWarnings` and therefore will still be applied during compilation of C sources. - - - - - 7d3a15c7 by Ben Gamari at 2019-10-29T03:48:55-04:00 base: Fix open-file locking The OFD locking path introduced in 3b784d440d4b01b4c549df7c9a3ed2058edfc780 due to #13945 appears to have never actually worked but we never noticed due to an oversight in the autoconf check. Fix it. Thanks to Oleg Grenrus for noticing this. - - - - - 78b70e63 by Ben Gamari at 2019-10-29T03:48:55-04:00 base: Split up file locking implementation This makes the CPP significantly easier to follow. - - - - - 63977398 by Ben Gamari at 2019-10-29T03:49:31-04:00 Don't substitute GccVersion variable Not only is it now unused but we generally can't assume that we are compiling with GCC, so it really shouldn't be used. - - - - - 72f7ac9a by Ben Gamari at 2019-10-29T03:50:06-04:00 Revert "Replace freebsd-gnueabihf with freebsd" This reverts commit aa31ceaf7568802590f73a740ffbc8b800096342 as suggested in #17392. - - - - - 3c0372d6 by Ben Gamari at 2019-10-29T20:31:36-04:00 distrib: Fix binary distribution installation This had silently regressed due to 81860281 and the variable renaming performed in b55ee979, as noted in #17374. - - - - - a7f423ee by Ben Gamari at 2019-10-29T20:31:36-04:00 gitlab-ci: Use pxz to compress binary distributions - - - - - db602643 by Ben Gamari at 2019-10-29T20:31:36-04:00 Don't include settings file in binary distribution The configuration in the installation environment (as determined by `autoconf`) may differ from the build environment and therefore we need to be sure to rebuild the settings file. Fixes #17374. - - - - - 260e2379 by Ben Gamari at 2019-10-29T20:31:36-04:00 gitlab-ci: Fix binary distribution testing - - - - - 01ef3e1f by Ömer Sinan Ağacan at 2019-10-29T20:32:18-04:00 Interpreter: initialize arity fields of AP_NOUPDs AP_NOUPD entry code doesn't use the arity field, but not initializing this field confuses printers/debuggers, and also makes testing harder as the field's value changes randomly. - - - - - 93ff9197 by Ben Gamari at 2019-10-30T07:36:49-04:00 rts: More aarch64 header fixes - - - - - 3e7569bc by Vladislav Zavialov at 2019-10-30T07:36:50-04:00 Whitespace forward compatibility for proposal #229 GHC Proposal #229 changes the lexical rules of Haskell, which may require slight whitespace adjustments in certain cases. This patch changes formatting in a few places in GHC and its testsuite in a way that enables it to compile under the proposed rules. - - - - - 4898df1c by Ben Gamari at 2019-10-30T18:15:52-04:00 gitlab-ci: Fix the ARMv7 triple Previously we were configuring the ARMv7 builds with a host/target triple of arm-linux-gnueabihf, which caused us to target ARMv6 and consequently rely on the old CP15 memory barrier implementation. This barrier has to be emulated on ARMv8 machines which is glacially slow. Hopefully this should fix the ARMv7 builds which currently consistently time out. - - - - - 337e9b5a by Ömer Sinan Ağacan at 2019-10-31T19:01:54-04:00 Remove redundant 0s in ghc-heap pointer strings Before: 0x0000004200c86888 After: 0x42000224f8 This is more concise and consistent with the RTS's printer (which uses %p formatter, and at least on Linux gcc prints the short form) and gdb's pointer formatter. - - - - - 97b6f7a3 by Ben Gamari at 2019-10-31T19:02:32-04:00 base: Clamp IO operation size to 2GB on Darwin As reported in #17414, Darwin throws EINVAL in response to large writes. - - - - - a9743eb7 by Ben Gamari at 2019-10-31T19:02:32-04:00 testsuite: Add test for #17414 - - - - - 73d6e508 by Ben Gamari at 2019-10-31T19:03:10-04:00 base: Various haddock fixes Just a few things I found while looking at #17383. - - - - - dc487642 by taylorfausak at 2019-11-01T04:54:47-04:00 Implement `round` for `Ratio` that doesn't explode with `Natural`s - - - - - 3932fb97 by taylorfausak at 2019-11-01T04:54:47-04:00 Fix rounding around 0 - - - - - baf47ff8 by taylorfausak at 2019-11-01T04:54:47-04:00 Add tests for rounding ratios - - - - - 214d8122 by taylorfausak at 2019-11-01T04:54:47-04:00 Fix running of ratio test case - - - - - 70b62c97 by Ben Gamari at 2019-11-01T04:55:24-04:00 mmap: Factor out protection flags - - - - - c6759080 by Ben Gamari at 2019-11-01T04:55:24-04:00 rts: Make m32 allocator per-ObjectCode MacOS Catalina is finally going to force our hand in forbidden writable exeutable mappings. Unfortunately, this is quite incompatible with the current global m32 allocator, which mixes symbols from various objects in a single page. The problem here is that some of these symbols may not yet be resolved (e.g. had relocations performed) as this happens lazily (and therefore we can't yet make the section read-only and therefore executable). The easiest way around this is to simply create one m32 allocator per ObjectCode. This may slightly increase fragmentation for short-running programs but I suspect will actually improve fragmentation for programs doing lots of loading/unloading since we can always free all of the pages allocated to an object when it is unloaded (although this ability will only be implemented in a later patch). - - - - - 35c99e72 by Simon Peyton Jones at 2019-11-01T04:56:02-04:00 Makes Lint less chatty: I found in #17415 that Lint was printing out truly gigantic warnings, unmanageably huge, with repeated copies of the same thing. This patch makes Lint less chatty, especially for warnings: * For **warnings**, I don't print details of the location, unless you add `-dppr-debug`. * For **errors**, I still print all the info. They are fatal and stop exection, whereas warnings appear repeatedly. * I've made much less use of `AnExpr` in `LintLocInfo`; the expression can be gigantic. - - - - - d2471964 by Simon Peyton Jones at 2019-11-01T04:56:38-04:00 Add another test for #17267 This one came in a comment from James Payor - - - - - 1e2e82aa by Simon Peyton Jones at 2019-11-01T04:57:15-04:00 Fix a bad error in tcMatchTy This patch fixes #17395, a very subtle and hard-to-trigger bug in tcMatchTy. It's all explained in Note [Matching in the presence of casts (2)] I have not added a regression test because it is very hard to trigger it, until we have the upcoming mkAppTyM patch, after which lacking this patch means you can't even compile the libraries. - - - - - 51067194 by Ben Gamari at 2019-11-01T15:48:37-04:00 base: Ensure that failIO isn't SOURCE imported failIO has useful information in its demand signature (specifically that it bottoms) which is hidden if it is SOURCE imported, as noted in #16588. Rejigger things such that we don't SOURCE import it. Metric Increase: T13701 - - - - - c751082c by Ben Gamari at 2019-11-01T15:48:37-04:00 testsuite: Make ExplicitForAllRules1 more robust Previously the test relied on `id` not inlining. Fix this. - - - - - dab12c87 by Ben Gamari at 2019-11-01T15:48:37-04:00 Describe optimisation of demand analysis of noinline As described in #16588. - - - - - c9236384 by Adam Sandberg Eriksson at 2019-11-01T15:49:16-04:00 template-haskell: require at least 1 GADT constructor name (#17379) - - - - - a4ce26e0 by Ben Gamari at 2019-11-01T15:49:53-04:00 hadrian: Make runtest invocation consistency with Make Use True/False instead of 0/1. This shouldn't be a functional change but we should be consistent. - - - - - cabafe34 by Ben Gamari at 2019-11-01T15:50:29-04:00 testsuite: Add test for #17423 - - - - - 4a6d3d68 by Simon Peyton Jones at 2019-11-01T23:11:37-04:00 Make CSE delay inlining less CSE delays inlining a little bit, to avoid losing vital specialisations; see Note [Delay inlining after CSE] in CSE. But it was being over-enthusiastic. This patch makes the delay only apply to Ids with specialisation rules, which avoids unnecessary delay (#17409). - - - - - 01006bc7 by Niklas Hambüchen at 2019-11-01T23:12:17-04:00 doc: Fix backticks - - - - - 9980fb58 by Niklas Hambüchen at 2019-11-01T23:12:17-04:00 Add +RTS --disable-delayed-os-memory-return. Fixes #17411. Sets `MiscFlags.disableDelayedOsMemoryReturn`. See the added `Note [MADV_FREE and MADV_DONTNEED]` for details. - - - - - 182b1199 by Sebastian Graf at 2019-11-02T20:16:33-04:00 Separate `LPat` from `Pat` on the type-level Since the Trees That Grow effort started, we had `type LPat = Pat`. This is so that `SrcLoc`s would only be annotated in GHC's AST, which is the reason why all GHC passes use the extension constructor `XPat` to attach source locations. See #15495 for the design discussion behind that. But now suddenly there are `XPat`s everywhere! There are several functions which dont't cope with `XPat`s by either crashing (`hsPatType`) or simply returning incorrect results (`collectEvVarsPat`). This issue was raised in #17330. I also came up with a rather clean and type-safe solution to the problem: We define ```haskell type family XRec p (f :: * -> *) = r | r -> p f type instance XRec (GhcPass p) f = Located (f (GhcPass p)) type instance XRec TH f = f p type LPat p = XRec p Pat ``` This is a rather modular embedding of the old "ping-pong" style, while we only pay for the `Located` wrapper within GHC. No ping-ponging in a potential Template Haskell AST, for example. Yet, we miss no case where we should've handled a `SrcLoc`: `hsPatType` and `collectEvVarsPat` are not callable at an `LPat`. Also, this gets rid of one indirection in `Located` variants: Previously, we'd have to go through `XPat` and `Located` to get from `LPat` to the wrapped `Pat`. Now it's just `Located` again. Thus we fix #17330. - - - - - 3c916162 by Richard Eisenberg at 2019-11-02T20:17:13-04:00 Update Note references -- comments only Follow-on from !2041. - - - - - 3b65655c by Ben Gamari at 2019-11-04T03:40:31-05:00 SysTools: Only apply Windows-specific workaround on Windows Issue #1110 was apparently due to a bug in Vista which prevented GCC from finding its binaries unless we explicitly added it to PATH. However, this workaround was incorrectly applied on non-Windows platforms as well, resulting in ill-formed PATHs (#17266). Fixes #17266. - - - - - 5d4f16ee by Leif Metcalf at 2019-11-04T03:41:09-05:00 Rephrase note on full-laziness - - - - - 120f2e53 by Ben Gamari at 2019-11-04T03:41:44-05:00 rts/linker: Ensure that code isn't writable For many years the linker would simply map all of its memory with PROT_READ|PROT_WRITE|PROT_EXEC. However operating systems have been becoming increasingly reluctant to accept this practice (e.g. #17353 and #12657) and for good reason: writable code is ripe for exploitation. Consequently mmapForLinker now maps its memory with PROT_READ|PROT_WRITE. After the linker has finished filling/relocating the mapping it must then call mmapForLinkerMarkExecutable on the sections of the mapping which contain executable code. Moreover, to make all of this possible it was necessary to redesign the m32 allocator. First, we gave (in an earlier commit) each ObjectCode its own m32_allocator. This was necessary since code loading and symbol resolution/relocation are currently interleaved, meaning that it is not possible to enforce W^X when symbols from different objects reside in the same page. We then redesigned the m32 allocator to take advantage of the fact that all of the pages allocated with the allocator die at the same time (namely, when the owning ObjectCode is unloaded). This makes a number of things simpler (e.g. no more page reference counting; the interface provided by the allocator for freeing is simpler). See Note [M32 Allocator] for details. - - - - - 7c28087a by Takenobu Tani at 2019-11-05T02:45:31-05:00 users-guide: Improve documentaion of CPP extension Currently, the description of CPP extension is given in the section of command-line options. Therefore, it is a little difficult to understand that it is a language extension. This commit explicitly adds a description for it. [skip ci] - - - - - d57059f7 by Ben Gamari at 2019-11-05T02:46:10-05:00 rts: Add missing const in HEAP_ALLOCED_GC This was previously unnoticed as this code-path is hit on very few platforms (e.g. OpenBSD). - - - - - 487ede42 by Peter Trommler at 2019-11-05T02:46:48-05:00 testsuite: skip test requiring RTS linker on PowerPC The RTS linker is not available on 64-bit PowerPC. Instead of marking tests that require the RTS linker as broken on PowerPC 64-bit skip the respective tests on all platforms where the RTS linker or a statically linked external interpreter is not available. Fixes #11259 - - - - - 1593debf by Sebastian Graf at 2019-11-05T11:38:30-05:00 Check EmptyCase by simply adding a non-void constraint We can handle non-void constraints since !1733, so we can now express the strictness of `-XEmptyCase` just by adding a non-void constraint to the initial Uncovered set. For `case x of {}` we thus check that the Uncovered set `{ x | x /~ ⊥ }` is non-empty. This is conceptually simpler than the plan outlined in #17376, because it talks to the oracle directly. In order for this patch to pass the testsuite, I had to fix handling of newtypes in the pattern-match checker (#17248). Since we use a different code path (well, the main code path) for `-XEmptyCase` now, we apparently also handle #13717 correctly. There's also some dead code that we can get rid off now. `provideEvidence` has been updated to provide output more in line with the old logic, which used `inhabitationCandidates` under the hood. A consequence of the shift away from the `UncoveredPatterns` type is that we don't report reduced type families for empty case matches, because the pretty printer is pure and only knows the match variable's type. Fixes #13717, #17248, #17386 - - - - - e6ffe148 by Ömer Sinan Ağacan at 2019-11-05T11:39:13-05:00 TidyPgm: replace an explicit loop with mapAccumL - - - - - b7460492 by Ömer Sinan Ağacan at 2019-11-05T11:39:13-05:00 CoreTidy: hide tidyRule - - - - - f9978f53 by Stefan Schulze Frielinghaus at 2019-11-05T11:39:51-05:00 Hadrian: enable interpreter for s390x - - - - - 3ce18700 by Ben Gamari at 2019-11-06T08:05:57-05:00 rts: Drop redundant flags for libffi These are now handled in the cabal file's include-dirs field. - - - - - ce9e2a1a by Ben Gamari at 2019-11-06T08:05:57-05:00 configure: Add --with-libdw-{includes,libraries} flags Fixing #17255. - - - - - 97f9674b by Takenobu Tani at 2019-11-06T08:06:37-05:00 configure: Add checking python3-sphinx This checks the configuration about python3-sphinx. We need python3-sphinx instead of python2-sphinx to build documentation. The approach is as follows: * Check python3 version with custom `conf.py` invoked from sphinx-build` executable * Place custom `conf.py` into new `utils/check-sphinx` directory If sphinx is for python2 not python3, it's treated as config ERROR instead of WARN. See also #17346 and #17356. - - - - - b4fb2328 by Dan Brooks at 2019-11-06T08:07:15-05:00 Adding examples to Semigroup/monoid - - - - - 708c60aa by Ryan Scott at 2019-11-07T08:39:36-05:00 Clean up TH's treatment of unary tuples (or, #16881 part two) !1906 left some loose ends in regards to Template Haskell's treatment of unary tuples. This patch ends to tie up those loose ends: * In addition to having `TupleT 1` produce unary tuples, `TupE [exp]` and `TupP [pat]` also now produce unary tuples. * I have added various special cases in GHC's pretty-printers to ensure that explicit 1-tuples are printed using the `Unit` type. See `testsuite/tests/th/T17380`. * The GHC 8.10.1 release notes entry has been tidied up a little. Fixes #16881. Fixes #17371. Fixes #17380. - - - - - a424229d by Stefan Schulze Frielinghaus at 2019-11-07T08:40:13-05:00 For s390x issue a warning if LLVM 9 or older is used For s390x the GHC calling convention is only supported since LLVM version 10. Issue a warning in case an older version of LLVM is used. - - - - - 55bc3787 by Ben Gamari at 2019-11-07T08:40:50-05:00 FlagChecker: Add ticky flags to hashed flags These affect output and therefore should be part of the flag hash. - - - - - fa0b1b4b by Stefan Schulze Frielinghaus at 2019-11-07T08:41:33-05:00 Bump libffi-tarballs submodule - - - - - a9566632 by Takenobu Tani at 2019-11-07T08:42:15-05:00 configure: Modify ERROR to WARN for sphinx's python check If sphinx's python version check failed, many people prefer to build without documents instead of stopping on the error. So this commit fixes the following: * Modify AC_MSG_ERROR to AC_MSG_WARN * Add clearing of SPHINXBUILD variable when check fails See also !2016. - - - - - d0ef8312 by Alp Mestanogullari at 2019-11-07T21:24:59-05:00 hadrian: fix support for the recording of perf test results Before this patch, Hadrian didn't care about the TEST_ENV and METRICS_FILE environment variables, that the performance testing infrastructure uses to record perf tests results from CI jobs. It now looks them up right before running the testsuite driver, and passes suitable --test-env/--metrics-file arguments when these environment variables are set. - - - - - 601e554c by Ben Gamari at 2019-11-07T21:25:36-05:00 Bump the process submodule This should fix the #17108 and #17249 with the fix from https://github.com/haskell/process/pull/159. - - - - - 6b7d7e1c by Ben Gamari at 2019-11-07T21:25:36-05:00 Bump hsc2hs submodule - - - - - b1c158c9 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts: Fix m32 allocator build on Windows An inconsistency in the name of m32_allocator_flush caused the build to fail with a missing prototype error. - - - - - ae431cf4 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts: Ensure that Rts.h is always included first In general this is the convention that we use in the RTS. On Windows things actually fail if we break it. For instance, you see things like: includes\stg\Types.h:26:9: error: warning: #warning "Mismatch between __USE_MINGW_ANSI_STDIO definitions. If using Rts.h make sure it is the first header included." [-Wcpp] - - - - - 0d141d28 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts: Remove undesireable inline specifier I have no idea why I marked this as inline originally but clearly it shouldn't be inlined. - - - - - 870376f9 by Ben Gamari at 2019-11-07T21:25:36-05:00 base: Add missing imports in Windows locking implementation - - - - - 23994738 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts/NonMoving: Fix various Windows build issues The Windows build seems to be stricter about not providing threading primitives in the non-threaded RTS. - - - - - a3ce52fd by Ben Gamari at 2019-11-07T21:25:36-05:00 users_guide: Set flags list file encoding Otherwise this fails on Windows. - - - - - 9db2e905 by Stefan Schulze Frielinghaus at 2019-11-08T05:36:54-05:00 Testsuite: Introduce req_rts_linker Some tests depend on the RTS linker. Introduce a modifier to skip such tests, in case the RTS linker is not available. - - - - - a4631335 by Szymon Nowicki-Korgol at 2019-11-08T05:37:34-05:00 Set correct length of DWARF .debug_aranges section (fixes #17428) - - - - - 3db2ab30 by Ben Gamari at 2019-11-08T05:38:11-05:00 hadrian: Add enableTickyGhc helper This took a bit of trial-and-error to get working so it seems worth having in the tree. - - - - - 5c87ebd7 by Ben Gamari at 2019-11-08T12:09:22-05:00 SetLevels: Don't set context level when floating cases When floating a single-alternative case we previously would set the context level to the level where we were floating the case. However, this is wrong as we are only moving the case and its binders. This resulted in #16978, where the disrepancy caused us to unnecessarily abstract over some free variables of the case body, resulting in shadowing and consequently Core Lint failures. (cherry picked from commit a2a0e6f3bb2d02a9347dec4c7c4f6d4480bc2421) - - - - - 43623b09 by Ben Gamari at 2019-11-08T12:10:01-05:00 testsuite: Run tests in nonmoving_thr in speed==slow - - - - - 6e4656cc by Ben Gamari at 2019-11-08T12:10:01-05:00 rts/nonmoving: Catch failure of createOSThread - - - - - 2e4fc04b by Ben Gamari at 2019-11-08T12:10:01-05:00 Bump unix submodule Marks executeFile001 as broken in all concurrent ways. - - - - - 8a10f9fb by Ben Gamari at 2019-11-09T18:03:01-05:00 template-haskell: Document assembler foreign file support See #16180. - - - - - 5ad3cb53 by Ben Gamari at 2019-11-09T18:03:01-05:00 template-haskell: Fix TBAs in changelog - - - - - 4a75a832 by Ben Gamari at 2019-11-09T18:03:01-05:00 base: Fix TBA in changelog - - - - - d7de0d81 by Ryan Scott at 2019-11-09T18:03:02-05:00 template-haskell: Fix italics in changelog [ci-skip] - - - - - 0fb246c3 by Ben Gamari at 2019-11-09T18:03:37-05:00 testsuite: Fix Windows cleanup path This was a regression introduced with the Path refactoring. - - - - - 925fbdbb by Ben Gamari at 2019-11-09T18:03:37-05:00 testsuite: Skip T16916 on Windows The event manager is not supported on Windows. - - - - - 7c2ce0a0 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Skip T14931 on Windows This test uses -dynamic-too, which is not supported on Windows. - - - - - 7c63edb4 by Ben Gamari at 2019-11-09T18:03:38-05:00 gitlab-ci: Don't allow Windows make job to fail While linking is still slow (#16084) all of the correctness issues which were preventing us from being able to enforce testsuite-green on Windows are now resolved. - - - - - a50ecda6 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Fix header #include order on Windows <Rts.h> must always come first. - - - - - dcb23ec9 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T13676 as broken on Darwin and Windows Due to #17447. - - - - - 411ba7ba by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T11627b as fragile It was previously marked as broken due to #12236 however it passes for me locally while failing on CI. - - - - - c1f1f3f9 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T16219 as unbroken This was previously broken due to #16386 yet it passes for me locally. - - - - - 1f871e70 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Remove redundant cleaning logic from T16511 The GHCi script for T16511 had some `rm` commands to clean up output from previous runs. This should be harmless since stderr was redirected to /dev/null; however, it seems that this redirection doesn't work on Windows (perhaps because GHCi uses `cmd` to execute the command-line; I'm not sure). I tried to fix it but was unable to find a sensible solution. Regardless, the cleaning logic is quite redundant now that we run each test in a hermetic environment. Let's just remove it. - - - - - 4d523cb1 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T17414 as fragile on Windows This consistently times out on Windows as described in #17453. I have tried increasing the timeout multiplier to two yet it stills fails. Disabling until we have time to investigate. - - - - - f73fbd2d by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Ignore stderr in PartialDownsweep As described in #17449, PartialDownsweep is currently fragile due to its dependence on the error messages produced by the C preprocessor. To eliminate this dependence we simply ignore stderr output, instead relying on the fact that the test will exit with a non-zero exit code on failure. Fixes #17449. - - - - - a9b14790 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Fix putStrLn in saks028 Bizarrely, `saks028` previously failed reliably, but only on Windows (#17450). The test would exit with a zero exit code but simply didn't emit the expected text to stderr. I believe this was due to the fact that the test used `putStrLn`, resulting in the output ending up on stdout. This worked on other platforms since (apparently) we redirect stdout to stderr when evaluating splices. However, on Windows it seems that the redirected output wasn't flushed as it was on other platforms. Anyways, it seems like the right thing to do here is to be explicit about our desire for the output to end up on stderr. Closes #17450. - - - - - b62ca659 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Drop T7995 This test is quite sensitive to the build configuration as it requires that ghc have unfoldings, which isn't true in the quick build flavours. I considered various options to make the test more robust but none of them seemed particularly appealing. Moreover, Simon PJ was a bit skeptical of the value of the test to begin with and I strongly suspect that any regression in #7995 would be accompanied by failures in our other compiler performance tests. Closes #17399. - - - - - 011f3121 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T16219 as fragile on Windows As noted in #17452, this test produces very long file paths which exceed the Windows MAX_PATH limitation. Mark the test as fragile for not until we can come up with a better solution. - - - - - 1f98e47d by Simon Peyton Jones at 2019-11-09T18:04:14-05:00 Use the right type in :force A missing prime meant that we were considering the wrong type in the GHCi debugger, when doing :force on multiple arguments (issue #17431). The fix is trivial. - - - - - 1f911de4 by Brian Wignall at 2019-11-09T18:04:57-05:00 Add IsList instance for ZipList (closes #17433) - - - - - e3672f40 by Brian Wignall at 2019-11-09T18:04:57-05:00 Incorporate MR review suggestions; add change in changelog - - - - - 3957bdf2 by Brian Wignall at 2019-11-09T18:04:57-05:00 Fix incorrect plurals - - - - - 6f4c1250 by Alina Banerjee at 2019-11-10T01:06:12-05:00 Improve SPECIALIZE pragma error messages (Fixes #12126) - - - - - fa25c8c4 by Richard Eisenberg at 2019-11-10T01:06:48-05:00 Update release notes about #16512 / #17405. - - - - - 55ca1085 by Richard Eisenberg at 2019-11-10T01:06:48-05:00 Fix #17405 by not checking imported equations Previously, we checked all imported type family equations for injectivity. This is very silly. Now, we check only for conflicts. Before I could even imagine doing the fix, I needed to untangle several functions that were (in my opinion) overly complicated. It's still not quite as perfect as I'd like, but it's good enough for now. Test case: typecheck/should_compile/T17405 - - - - - a9467f4f by Ben Gamari at 2019-11-10T21:06:33-05:00 testsuite: Mark tests fragile in threaded2 as fragile in all concurrent ways - - - - - 3e07ea8d by Ben Gamari at 2019-11-10T21:10:30-05:00 testsuite: Use small allocation area when measuring residency As suggested in #17387; this helps reduce the variance in our residency sampling. Metric Increase: T10370 T3586 lazy-bs-alloc Metric Decrease 'compile_time/peak_megabytes_allocated': T1969 Metric Decrease 'runtime/bytes allocated': space_leak_001 Metric Increase 'compile_time/bytes allocated': T1969 Metric Increase 'runtime/peak_megabytes_allocated': space_leak_001 Metric Decrease: T3064 T9675 - - - - - 049d9ae0 by Ben Gamari at 2019-11-10T21:10:30-05:00 testsuite: Don't check_stats at runtime if not requested Previously we would call check_stats to check the runtime metrics even if the test definition hadn't requested it. This would result in an error since the .stats file doesn't exist. - - - - - 64433428 by Alp Mestanogullari at 2019-11-11T08:49:01-05:00 hadrian: export METRICS_FILE to make it accessible to perf notes script This addresses #17456 and also fixes the --metrics-file argument that Hadrian passes to the testsuite driver. - - - - - 06640394 by Ben Gamari at 2019-11-11T08:50:45-05:00 testsuite: Disable T4334 in nonmoving_thr way - - - - - f8ec32d7 by Alp Mestanogullari at 2019-11-11T11:36:44-05:00 ci: push perf test metrics even when the testsuite doesn't pass The corresponding commit might introduce a regression on a perf test, in which case we certainly want to record it. The testsuite might also fail because of a test unrelated to performance, in which case we want to record that the perf test results were good. Either way, we likely want to record them under all circumstances but we don't without this patch. Metric Decrease: T3586 Metric Increase: lazy-bs-alloc - - - - - 643d42fc by Alp Mestanogullari at 2019-11-12T18:40:19-05:00 testsuite: don't collect compiler stats in collect_runtime_residency We instead want to collect the runtime stats (with collect_stats, instead of collect_compiler_stats). This should fix a number of perf tests failures we have been seeing, where we suddenly started measuring metrics we didn't intend to measure, which tend to fall outside of the acceptance window. Metric Decrease: lazy-bs-alloc T3586 Metric Increase: space_leak_001 T4801 T5835 T12791 - - - - - 535d0edc by Ömer Sinan Ağacan at 2019-11-13T07:06:12-05:00 Document CmmTopInfo type [ci skip] - - - - - 2d4f9ad8 by Ben Gamari at 2019-11-13T07:06:49-05:00 Ensure that coreView/tcView are able to inline Previously an import cycle between Type and TyCoRep meant that several functions in TyCoRep ended up SOURCE import coreView. This is quite unfortunate as coreView is intended to be fused into a larger pattern match and not incur an extra call. Fix this with a bit of restructuring: * Move the functions in `TyCoRep` which depend upon things in `Type` into `Type` * Fold contents of `Kind` into `Type` and turn `Kind` into a simple wrapper re-exporting kind-ish things from `Type` * Clean up the redundant imports that popped up as a result Closes #17441. Metric Decrease: T4334 - - - - - b795637f by Alp Mestanogullari at 2019-11-13T07:07:28-05:00 hadrian: fix Windows CI script By only using 'export' from within bash commands. - - - - - 6885e22c by Ben Gamari at 2019-11-13T07:08:03-05:00 testsuite: Add test for #17458 As noted in #17458, QuantifiedConstraints and UndecideableInstances could previously be used to write programs which can loop at runtime. This was fixed in !1870. - - - - - b4b19d89 by Ben Gamari at 2019-11-13T07:08:03-05:00 users guide: Fix broken link - - - - - 9a939a6c by Ryan Scott at 2019-11-13T07:08:40-05:00 Print name prefixly in the Outputable instance for StandaloneKindSig Issue #17461 was occurring because the `Outputable` instance for standalone kind signatures was simply calling `ppr` on the name in the kind signature, which does not add parentheses to infix names. The solution is simple: use `pprPrefixOcc` instead. Fixes #17461. - - - - - a06cfb59 by Ömer Sinan Ağacan at 2019-11-13T07:09:18-05:00 Only pass mod_location with HscRecomp instead of the entire ModSummary HscRecomp users only need the ModLocation of the module being compiled, so only pass that to users instead of the entire ModSummary Metric Decrease: T4801 - - - - - dd49b3f0 by Ben Gamari at 2019-11-13T17:01:21-05:00 Bump Haskeline and add exceptions as boot library Haskeline now depends upon exceptions. See #16752. - - - - - b06b1858 by Ben Gamari at 2019-11-14T11:30:20-05:00 base: Bump version to 4.14.0.0 Metric Increase: T4801 - - - - - 6ab80439 by Ben Gamari at 2019-11-14T23:05:30-05:00 gitlab-ci: Allow Windows to fail again - - - - - 46afc380 by Ben Gamari at 2019-11-15T09:45:36-05:00 gitlab-ci: Install process to global pkgdb before starting build This is an attempt to mitigate #17480 by ensuring that a functional version of the process library is available before attempting the build. - - - - - 8c5cb806 by Ben Gamari at 2019-11-15T10:45:55-05:00 Bump supported LLVM version to 9.0 - - - - - 8e5851f0 by Ben Gamari at 2019-11-15T10:45:55-05:00 llvm-targets: Update with Clang 9 - - - - - f3ffec27 by Ben Gamari at 2019-11-15T11:54:26-05:00 testsuite: Increase acceptance window of T4801 This statistic is rather unstable. Hopefully fixes #17475. - - - - - c2991f16 by Ben Gamari at 2019-11-15T11:56:10-05:00 users-guide: Drop 8.6.1 release notes - - - - - e8da1354 by Ben Gamari at 2019-11-17T06:48:16-05:00 gitlab-ci: Fix submodule linter We ran it against the .git directory despite the fact that the linter wants to be run against the repository. - - - - - 13290f91 by Ben Gamari at 2019-11-17T06:48:16-05:00 Bump version to 8.10.0 Bumps haddock submodule. - - - - - fa98f823 by Ben Gamari at 2019-11-17T06:48:16-05:00 testsuite: Don't collect residency for T4801 I previously increased the size of the acceptance window from 2% to 5% but this still isn't enough. Regardless, measuring bytes allocated should be sufficient to catch any regressions. - - - - - 002b2842 by Ivan Kasatenko at 2019-11-17T06:49:22-05:00 Make test 16916 more stable across runs - - - - - ca89dd3b by Ben Gamari at 2019-11-17T06:58:17-05:00 users-guide: Address #17329 Adopts the language suggested by @JakobBruenker. - - - - - 2f5ed225 by Ben Gamari at 2019-11-17T07:16:32-05:00 exceptions: Bump submodule back to master The previous commit hasn't made it to master yet. - - - - - 34515e7c by nineonine at 2019-11-17T13:33:22-08:00 Fix random typos [skip ci] - - - - - 4a37a29b by Mario Blažević at 2019-11-17T17:26:24-05:00 Fixed issue #17435, missing Data instances - - - - - 97f1bcae by Andreas Klebinger at 2019-11-17T17:26:24-05:00 Turn some comments into GHC.Hs.Utils into haddocks - - - - - cf7f8e5b by Ben Gamari at 2019-11-17T17:26:26-05:00 testsuite: Skip T17414 on Linux It is typical for $TMP to be a small tmpfson Linux. This test will fail in such cases since we must create a file larger than the filesystem. See #17459. - - - - - 88013b78 by nineonine at 2019-11-19T11:53:16-05:00 Optimize MonadUnique instances based on IO (#16843) Metric Decrease: T14683 - - - - - a8adb5b4 by Ben Gamari at 2019-11-19T11:53:55-05:00 desugar: Drop stale Note [Matching seqId] The need for this note vanished in eae703aa60f41fd232be5478e196b661839ec3de. - - - - - 08d595c0 by Ben Gamari at 2019-11-19T11:53:55-05:00 Give seq a more precise type and remove magic `GHC.Prim.seq` previously had the rather plain type: seq :: forall a b. a -> b -> b However, it also had a special typing rule to applications where `b` is not of kind `Type`. Issue #17440 noted that levity polymorphism allows us to rather give it the more precise type: seq :: forall (r :: RuntimeRep) a (b :: TYPE r). a -> b -> b This allows us to remove the special typing rule that we previously required to allow applications on unlifted arguments. T9404 contains a non-Type application of `seq` which should verify that this works as expected. Closes #17440. - - - - - ec8a463d by Viktor Dukhovni at 2019-11-19T11:54:45-05:00 Enable USE_PTHREAD_FOR_ITIMER also on FreeBSD If using a pthread instead of a timer signal is more reliable, and has no known drawbacks, then FreeBSD is also capable of supporting this mode of operation (tested on FreeBSD 12 with GHC 8.8.1, but no reason why it would not also work on FreeBSD 11 or GHC 8.6). Proposed by Kevin Zhang in: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241849 - - - - - cd40e12a by Ömer Sinan Ağacan at 2019-11-19T11:55:36-05:00 Packages.hs: use O(n*log(n)) ordNub instead of O(n*n) nub As reported in #8173 in some environments package lists can get quite long, so we use more efficient ordNub instead of nub on package lists. - - - - - 2b27cc16 by Ben Gamari at 2019-11-19T11:56:21-05:00 Properly account for libdw paths in make build system Should finally fix #17255. - - - - - 0418c38d by Ben Gamari at 2019-11-19T11:56:58-05:00 rts: Add missing include of SymbolExtras.h This broke the Windows build. - - - - - c819c0e4 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Use correct info table pointer accessor Previously we used INFO_PTR_TO_STRUCT instead of THUNK_INFO_PTR_TO_STRUCT when looking at a thunk. These two happen to be equivalent on 64-bit architectures due to alignment considerations however they are different on 32-bit platforms. This lead to #17487. To fix this we also employ a small optimization: there is only one thunk of type WHITEHOLE (namely stg_WHITEHOLE_info). Consequently, we can just use a plain pointer comparison instead of testing against info->type. - - - - - deed8e31 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Fix incorrect masking in mark queue type test We were using TAG_BITS instead of TAG_MASK. This happened to work on 64-bit platforms where TAG_BITS==3 since we only use tag values 0 and 3. However, this broken on 32-bit platforms where TAG_BITS==2. - - - - - 097f8072 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Rework mark queue representation The previous representation needlessly limited the array length to 16-bits on 32-bit platforms. - - - - - eb7b233a by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Fix handling on large object marking on 32-bit Previously we would reset the pointer pointing to the object to be marked to the beginning of the block when marking a large object. This did no harm on 64-bit but on 32-bit it broke, e.g. `arr020`, since we align pinned ByteArray allocations such that the payload is 8 byte-aligned. This means that the object might not begin at the beginning of the block., - - - - - a7571a74 by Ben Gamari at 2019-11-19T11:57:36-05:00 testsuite: Increase width of stack003 test Previously the returned tuple seemed to fit in registers on amd64. This meant that non-moving collector bug would cause the test to fail on i386 yet not amd64. - - - - - 098d5017 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Drop redundant write barrier on stack underflow Previously we would push stack-carried return values to the new stack on a stack overflow. While the precise reasoning for this barrier is unfortunately lost to history, in hindsight I suspect it was prompted by a missing barrier elsewhere (that has been since fixed). Moreover, there the redundant barrier is actively harmful: the stack may contain non-pointer values; blindly pushing these to the mark queue will result in a crash. This is precisely what happened in the `stack003` test. However, because of a (now fixed) deficiency in the test this crash did not trigger on amd64. - - - - - e57b7cc6 by Roland Zumkeller at 2019-11-19T20:39:19-05:00 Changing Thread IDs from 32 bits to 64 bits. - - - - - d1f3c637 by Roland Zumkeller at 2019-11-19T20:39:19-05:00 Use pointer equality in Eq/Ord for ThreadId Changes (==) to use only pointer equality. This is safe because two threads are the same iff they have the same id. Changes `compare` to check pointer equality first and fall back on ids only in case of inequality. See discussion in #16761. - - - - - ef8a08e0 by Alexey Kuleshevich at 2019-11-19T20:39:20-05:00 hpc: Fix encoding issues. Add test for and fix #17073 * Make sure files are being read/written in UTF-8. Set encoding while writing HTML output. Also set encoding while writing and reading .tix files although we don't yet have a ticket complaining that this poses problems. * Set encoding in html header to utf8 * Upgrade to new version of 'hpc' library and reuse `readFileUtf8` and `writeFileUtf8` functions * Update git submodule for `hpc` * Bump up `hpc` executable version Co-authored-by: Ben Gamari <ben at smart-cactus.org> - - - - - b79e46d6 by Vladislav Zavialov at 2019-11-19T20:39:20-05:00 Strip parentheses in expressions contexts in error messages This makes error messages a tad less noisy. - - - - - 13bbde77 by Ben Gamari at 2019-11-21T13:56:56-05:00 Bump hsc2hs submodule Including Phyx's backport of the process changes fixing #17480. - - - - - d4d10501 by Ben Gamari at 2019-11-23T09:42:38-05:00 Bump hsc2hs submodule again This fixes the Darwin build. - - - - - 889d475b by nineonine at 2019-11-23T18:53:29-05:00 Fix typo in Note reference [skip ci] - - - - - 8a33abfc by Ryan Scott at 2019-11-23T18:54:05-05:00 Target the IsList instance for ZipList at base-4.14.0.0 (#17489) This moves the changelog entry about the instance from `base-4.15.0.0` to `base-4.14.0.0`. This accomplishes part (1) from #17489. [ci skip] - - - - - e43e6ece by Ben Gamari at 2019-11-23T18:54:41-05:00 rts: Expose interface for configuring EventLogWriters This exposes a set of interfaces from the GHC API for configuring EventLogWriters. These can be used by consumers like [ghc-eventlog-socket](https://github.com/bgamari/ghc-eventlog-socket). - - - - - de6bbdf2 by Matheus Magalhães de Alcantara at 2019-11-23T18:55:23-05:00 Take care to not eta-reduce jumps in CorePrep CorePrep already had a check to prevent it from eta-reducing Ids that respond true to hasNoBinding (foreign calls, constructors for unboxed sums and products, and Ids with compulsory unfoldings). It did not, however, consider join points as ids that 'must be saturated'. Checking whether the Id responds True to 'isJoinId' should prevent CorePrep from turning saturated jumps like the following (from #17429) into undersaturated ones: (\ eta_XP -> join { mapped_s1vo _ = lvl_s1vs } in jump mapped_s1vo eta_XP) - - - - - 4a1e7e47 by Matheus Magalhães de Alcantara at 2019-11-23T18:55:23-05:00 Make CorePrep.tryEtaReducePrep and CoreUtils.tryEtaReduce line up Simon PJ says he prefers this fix to #17429 over banning eta-reduction for jumps entirely. Sure enough, this also works. Test case: simplCore/should_compile/T17429.hs - - - - - 15f1dc33 by Ryan Scott at 2019-11-23T18:56:00-05:00 Prevent -optc arguments from being duplicated in reverse order (#17471) This reverts a part of commit 7bc5d6c6578ab9d60a83b81c7cc14819afef32ba that causes all arguments to `-optc` (and `-optcxx`) to be passed twice to the C/C++ compiler, once in reverse order and then again in the correct order. While passing duplicate arguments is usually harmless it can cause breakage in this pattern, which is employed by Hackage libraries in the wild: ``` ghc Foo.hs foo.c -optc-D -optcFOO ``` As `FOO -D -D FOO` will cause compilers to error. Fixes #17471. - - - - - e85c9b22 by Ben Gamari at 2019-11-23T18:56:36-05:00 Bump ghc version to 8.11 - - - - - 0e6c2045 by Ben Gamari at 2019-11-23T18:57:12-05:00 rts: Consolidate spinlock implementation Previously we had two distinct implementations: one with spinlock profiling and another without. This seems like needless duplication. - - - - - cb11fcb5 by Ben Gamari at 2019-11-23T18:57:49-05:00 Packages: Don't use expectJust Throw a slightly more informative error on failure. Motivated by the errors seen in !2160. - - - - - 5747ebe9 by Sebastian Graf at 2019-11-23T18:58:25-05:00 Stricten functions ins GHC.Natural This brings `Natural` on par with `Integer` and fixes #17499. Also does some manual CSE for 0 and 1 literals. - - - - - c14b723f by Ömer Sinan Ağacan at 2019-11-23T18:59:06-05:00 Bump exceptions submodule Adds a few files generated by GHC's configure script to .gitignore - - - - - 7b4c7b75 by Brian Wignall at 2019-11-23T19:04:52-05:00 Fix typos - - - - - 6008206a by Viktor Dukhovni at 2019-11-24T14:33:18-05:00 On FreeBSD 12 sys/sysctl.h requires sys/types.h Else build fails with: In file included from ExecutablePath.hsc:42: /usr/include/sys/sysctl.h:1062:25: error: unknown type name 'u_int'; did you mean 'int'? int sysctl(const int *, u_int, void *, size_t *, const void *, size_t); ^~~~~ int compiling libraries/base/dist-install/build/System/Environment/ExecutablePath_hsc_make.c failed (exit code 1) Perhaps also also other FreeBSD releases, but additional include will no harm even if not needed. - - - - - b694b566 by Ben Gamari at 2019-11-24T14:33:54-05:00 configure: Fix HAVE_C11_ATOMICS macro Previously we were using AC_DEFINE instead of AC_DEFINE_UNQUOTED, resulted in the variable not being interpolated. Fixes #17505. - - - - - 8b8dc366 by Krzysztof Gogolewski at 2019-11-25T14:37:38+01:00 Remove prefix arrow support for GADTs (#17211) This reverts the change in #9096. The specialcasing done for prefix (->) is brittle and does not support VTA, type families, type synonyms etc. - - - - - 5a08f7d4 by Sebastian Graf at 2019-11-27T00:14:59-05:00 Make warnings for TH splices opt-in In #17270 we have the pattern-match checker emit incorrect warnings. The reason for that behavior is ultimately an inconsistency in whether we treat TH splices as written by the user (`FromSource :: Origin`) or as generated code (`Generated`). This was first reported in #14838. The current solution is to TH splices as `Generated` by default and only treat them as `FromSource` when the user requests so (-fenable-th-splice-warnings). There are multiple reasons for opt-in rather than opt-out: * It's not clear that the user that compiles a splice is the author of the code that produces the warning. Think of the situation where she just splices in code from a third-party library that produces incomplete pattern matches. In this scenario, the user isn't even able to fix that warning. * Gathering information for producing the warnings (pattern-match check warnings in particular) is costly. There's no point in doing so if the user is not interested in those warnings. Fixes #17270, but not #14838, because the proper solution needs a GHC proposal extending the TH AST syntax. - - - - - 8168b42a by Vladislav Zavialov at 2019-11-27T11:32:18+03:00 Whitespace-sensitive bang patterns (#1087, #17162) This patch implements a part of GHC Proposal #229 that covers five operators: * the bang operator (!) * the tilde operator (~) * the at operator (@) * the dollar operator ($) * the double dollar operator ($$) Based on surrounding whitespace, these operators are disambiguated into bang patterns, lazy patterns, strictness annotations, type applications, splices, and typed splices. This patch doesn't cover the (-) operator or the -Woperator-whitespace warning, which are left as future work. - - - - - 9e5477c4 by Ryan Scott at 2019-11-27T20:01:50-05:00 Fix @since annotations for isResourceVanishedError and friends (#17488) - - - - - e122ba33 by Sergei Trofimovich at 2019-11-27T20:02:29-05:00 .gitmodules: tweak 'exception' URL to avoid redirection warnings Avoid initial close warning of form: ``` Cloning into 'exceptions'... warning: redirecting to https://gitlab.haskell.org/ghc/packages/exceptions.git/ ``` Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 5f84b52a by Philipp Krüger at 2019-11-28T02:54:05-05:00 Reduce boolean blindness in OccInfo(OneOcc) #17482 * Transformed the type aliases `InterestingCxt`, `InsideLam` and `OneBranch` into data types. * Added Semigroup and Monoid instances for use in orOccInfo in OccurAnal.hs * Simplified some usage sites by using pattern matching instead of boolean algebra. Metric Increase: T12150 This increase was on a Mac-build of exactly 1%. This commit does *not* re-intruduce the asymptotic memory usage described in T12150. - - - - - 3748ba3a by Brian Wignall at 2019-11-28T02:54:52-05:00 Fix typos, using Wikipedia list of common typos - - - - - 6c59cc71 by Stefan Schulze Frielinghaus at 2019-11-28T02:55:33-05:00 Fix endian handling of LLVM backend Get rid of CPP macro WORDS_BIGENDIAN which is not defined anymore, and replace it by DynFlag. This fixes partially #17337. - - - - - 6985e0fc by Vladislav Zavialov at 2019-11-28T15:47:53+03:00 Factor out HsSCC/HsCoreAnn/HsTickPragma into HsPragE This is a refactoring with no user-visible changes (except for GHC API users). Consider the HsExpr constructors that correspond to user-written pragmas: HsSCC representing {-# SCC ... #-} HsCoreAnn representing {-# CORE ... #-} HsTickPragma representing {-# GENERATED ... #-} We can factor them out into a separate datatype, HsPragE. It makes the code a bit tidier, especially in the parser. Before this patch: hpc_annot :: { Located ( (([AddAnn],SourceText),(StringLiteral,(Int,Int),(Int,Int))), ((SourceText,SourceText),(SourceText,SourceText)) ) } After this patch: prag_hpc :: { Located ([AddAnn], HsPragE GhcPs) } - - - - - 7f695a20 by Ömer Sinan Ağacan at 2019-11-29T08:25:28-05:00 Pass ModDetails with (partial) ModIface in HscStatus (Partial) ModIface and ModDetails are generated at the same time, but they're passed differently: ModIface is passed in HscStatus consturctors while ModDetails is returned in a tuple. This refactors ModDetails passing so that it's passed around with ModIface in HscStatus constructors. This makes the code more consistent and hopefully easier to understand: ModIface and ModDetails are really very closely related. It makes sense to treat them the same way. - - - - - e921c90f by Ömer Sinan Ağacan at 2019-11-29T08:26:07-05:00 Improve few Foreign.Marshal.Utils docs In copyBytes and moveBytes mention which argument is source and which is destination. Also fixes some of the crazy indentation in the module and cleans trailing whitespace. - - - - - 316f2431 by Sebastian Graf at 2019-11-30T02:57:58-05:00 Hadrian docs: Rename the second "validate" entry to "slow-validate" [ci skip] That would be in line with the implementation. - - - - - 5aba5d32 by Vladislav Zavialov at 2019-11-30T02:58:34-05:00 Remove HasSrcSpan (#17494) Metric Decrease: haddock.compiler - - - - - d1de5c22 by Sylvain Henry at 2019-11-30T02:59:13-05:00 Use Hadrian by default in validate script (#17527) - - - - - 3a96a0b6 by Sebastian Graf at 2019-11-30T02:59:55-05:00 Simpler Semigroup instance for InsideLam and InterestingCtxt This mirrors the definition of `(&&)` and `(||)` now, relieving the Simplifier of a marginal amount of pressure. - - - - - f8cfe81a by Roland Senn at 2019-11-30T20:33:49+01:00 Improve tests for #17171 While backporting MR !1806 to 8.8.2 (!1885) I learnt the following: * Tests with `expect_fail` do not compare `*.stderr` output files. So a test using `expect_fail` will not detect future regressions on the `stderr` output. * To compare the `*.stderr` output files, I have to use the `exit_code(n)` function. * When a release is made, tests with `makefile_test` are converted to use `run_command`. * For the test `T17171a` the return code is `1` when running `makefile_test`, however it's `2` when running `run_command`. Therefore I decided: * To improve my tests for #17171 * To change test T17171a from `expect_fail` to `exit_code(2)` * To change both tests from `makefile_test` to `run_command` - - - - - 2b113fc9 by Vladislav Zavialov at 2019-12-01T08:17:05-05:00 Update DisambECP-related comments - - - - - beed7c3e by Ben Gamari at 2019-12-02T03:41:37-05:00 testsuite: Fix location of typing_stubs module This should fix the build on Debian 8. - - - - - 53251413 by Ben Gamari at 2019-12-02T03:42:14-05:00 testsuite: Don't override LD_LIBRARY_PATH, only prepend NixOS development environments often require that LD_LIBRARY_PATH be set in order to find system libraries. T1407 was overriding LD_LIBRARY_PATH, dropping these directories. Now it merely prepends, its directory. - - - - - 65400314 by Krzysztof Gogolewski at 2019-12-02T03:42:57-05:00 Convert warnings into assertions Since the invariants always hold in the testsuite, we can convert them to asserts. - - - - - 18baed64 by Alan Zimmerman at 2019-12-02T03:43:37-05:00 API Annotations: Unicode '->' on HsForallTy The code fragment type family Proxy2' ∷ ∀ k → k → Type where Proxy2' = Proxy' Generates AnnRarrow instead of AnnRarrowU for the first →. Fixes #17519 - - - - - 717f3236 by Brian Wignall at 2019-12-02T03:44:16-05:00 Fix more typos - - - - - bde48f8e by Ben Gamari at 2019-12-02T11:55:34-05:00 More Haddock syntax in GHC.Hs.Utils As suggested by RyanGlScott in !2163. - - - - - 038bedbc by Ben Gamari at 2019-12-02T11:56:18-05:00 Simplify: Fix pretty-printing of strictness A colleague recently hit the panic in Simplify.addEvals and I noticed that the message is quite unreadable due to incorrect pretty-printing. Fix this. - - - - - c500f652 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Fix changelog linting logic - - - - - 8ead967d by Ben Gamari at 2019-12-02T11:56:54-05:00 win32-init: Drop workaround for #17480 The `process` changes have now been merged into `hsc2hs`. (cherry picked from commit fa029f53132ad59f847ed012d3b835452cf16615) - - - - - d402209a by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Disable Sphinx build on Debian 8 The docutils version available appears to be too old to support the `table` directive's `:widths:` options. (cherry picked from commit 75764487a96a7a026948b5af5022781872d12baa) - - - - - f1f68824 by Ben Gamari at 2019-12-02T11:56:54-05:00 base: Fix <unistd.h> #include Previously we were including <sys/unistd.h> which is available on glibc but not musl. (cherry picked from commit e44b695ca7cb5f3f99eecfba05c9672c6a22205e) - - - - - 37eb94b3 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Bump Docker images Installs pxz on Centos7 (cherry picked from commit 86960e691f7a600be247c32a7cf795bf9abf7cc4) - - - - - aec98a79 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: pxz is unavailable on CentOS 7 Fall back to xz - - - - - 6708b8e5 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Set LANG on CentOS 7 It otherwise seems to default to ascii - - - - - 470ef0e7 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Consolidate release build configuration - - - - - 38338757 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Add Debian 10 builds - - - - - 012f13b5 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Fix Windows bindist collection Apparently variable interpolation in the `artifacts.paths` key of `gitlab-ci.yml` doesn't work on Windows as it does on WIndows. (cherry picked from commit 100cc756faa4468ed6950116bae30609c1c3468b) - - - - - a0f09e23 by Ben Gamari at 2019-12-02T11:56:54-05:00 testsuite: Simplify Python <3.5 fallback for TextIO (cherry picked from commit d092d8598694c23bc07cdcc504dff52fa5f33be1) - - - - - 2b2370ec by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Add release-x86_64-linux-deb9 job (cherry picked from commit cbedb3c4a90649f474cb716842ba53afc5a642ca) - - - - - b1c206fd by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Always build source tarball (cherry picked from commit 67b5de88ef923971f1980335137e3c7193213abd) - - - - - 4cbd5b47 by Sergei Trofimovich at 2019-12-02T11:57:33-05:00 configure.ac: make cross-compiler detection stricter Be more precise at detecting cross-compilation case. Before the change configuration $ ./configure --host=x86_64-pc-linux-gnu --target=x86_64-gentoo-linux-musl was not considered a cross-target. Even though libcs are different (`glibc` vs. `musl`). Without this patch build fails as: ``` "inplace/bin/ghc-cabal" check libraries/integer-gmp "inplace/bin/ghc-cabal" configure libraries/integer-gmp dist-install \ --with-ghc="/home/slyfox/dev/git/ghc/inplace/bin/ghc-stage1" \ --with-ghc-pkg="/home/slyfox/dev/git/ghc/inplace/bin/ghc-pkg" \ --disable-library-for-ghci --enable-library-vanilla --enable-library-for-ghci \ --enable-library-profiling --enable-shared --with-hscolour="/usr/bin/HsColour" \ --configure-option=CFLAGS="-Wall \ -Werror=unused-but-set-variable -Wno-error=inline \ -iquote /home/slyfox/dev/git/ghc/libraries/integer-gmp" \ --configure-option=LDFLAGS=" " --configure-option=CPPFLAGS=" \ " --gcc-options="-Wall -Werror=unused-but-set-variable -Wno-error=inline -iquote /home/slyfox/dev/git/ghc/libraries/integer-gmp \ " --with-gcc="x86_64-gentoo-linux-musl-gcc" --with-ld="x86_64-gentoo-linux-musl-ld.gold" --with-ar="x86_64-gentoo-linux-musl-ar" \ --with-alex="/usr/bin/alex" --with-happy="/usr/bin/happy" Configuring integer-gmp-1.0.2.0... configure: WARNING: unrecognized options: --with-compiler checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu checking for gcc... /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... configure: error: in `/home/slyfox/dev/git/ghc/libraries/integer-gmp/dist-install/build': configure: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details make[1]: *** [libraries/integer-gmp/ghc.mk:5: libraries/integer-gmp/dist-install/package-data.mk] Error 1 make: *** [Makefile:126: all] Error 2 ``` Note: here `ghc-stage1` is assumed to target `musl` target but is passed `glibc` toolchain. It happens because initial ./configure phase did not detect host/target as different. Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 5f7cb423 by Sylvain Henry at 2019-12-02T23:59:29-05:00 Add `timesInt2#` primop - - - - - fbbe18a2 by Sylvain Henry at 2019-12-02T23:59:29-05:00 Use the new timesInt2# primop in integer-gmp (#9431) - - - - - 5a4b8d0c by Athas at 2019-12-03T00:00:09-05:00 Document RTS behaviour upon encountering '--'. - - - - - 705a16df by Ben Gamari at 2019-12-03T07:11:33-05:00 Make BCO# lifted In #17424 Simon PJ noted that there is a potentially unsafe occurrence of unsafeCoerce#, coercing from an unlifted to lifted type. However, nowhere in the compiler do we assume that a BCO# is not a thunk. Moreover, in the case of a CAF the result returned by `createBCO` *will* be a thunk (as noted in [Updatable CAF BCOs]). Consequently it seems better to rather make BCO# a lifted type and rename it to BCO. - - - - - 35afe4f3 by Sylvain Henry at 2019-12-03T07:12:13-05:00 Use Int# primops in `Bits Int{8,16,32,64}` instances - - - - - 7a51b587 by Sylvain Henry at 2019-12-03T07:12:13-05:00 Add constant folding rule (#16402) narrowN (x .&. m) m .&. (2^N-1) = 2^N-1 ==> narrowN x e.g. narrow16 (x .&. 0x12FFFF) ==> narrow16 x - - - - - 10caee7f by Ben Gamari at 2019-12-03T21:04:50-05:00 users-guide: Add 8.12.1 release notes - - - - - 25019d18 by Ben Gamari at 2019-12-03T21:04:50-05:00 Drop Uniquable constraint for AnnTarget This relied on deriveUnique, which was far too subtle to be safely applied. Thankfully the instance doesn't appear to be used so let's just drop it. - - - - - 78b67ad0 by Ben Gamari at 2019-12-03T21:04:50-05:00 Simplify uniqAway This does two things: * Eliminate all uses of Unique.deriveUnique, which was quite easy to mis-use and extremely subtle. * Rename the previous "derived unique" notion to "local unique". This is possible because the only places where `uniqAway` can be safely used are those where local uniqueness (with respect to some InScopeSet) is sufficient. * Rework the implementation of VarEnv.uniqAway, as discussed in #17462. This should make the operation significantly more efficient than its previous iterative implementation.. Metric Decrease: T9872c T12227 T9233 T14683 T5030 T12545 hie002 Metric Increase: T9961 - - - - - f03a41d4 by Ben Gamari at 2019-12-03T21:05:27-05:00 Elf: Fix link info note generation Previously we would use the `.int` assembler directive to generate 32-bit words in the note section. However, `.int` is note guaranteed to produce 4-bytes; in fact, on some platforms (e.g. AArch64) it produces 8-bytes. Use the `.4bytes` directive to avoid this. Moreover, we used the `.align` directive, which is quite platform dependent. On AArch64 it appears to not even be idempotent (despite what the documentation claims). `.balign` is consequentially preferred as it offers consistent behavior across platforms. - - - - - 84585e5e by Vladislav Zavialov at 2019-12-05T16:07:44-05:00 Meaning-preserving SCC annotations (#15730) This patch implements GHC Proposal #176: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0176-scc-parsing.rst Before the change: 1 / 2 / 2 = 0.25 1 / {-# SCC "name" #-} 2 / 2 = 1.0 After the change: 1 / 2 / 2 = 0.25 1 / {-# SCC "name" #-} 2 / 2 = parse error - - - - - e49e5470 by Vladislav Zavialov at 2019-12-05T16:07:44-05:00 Improve error messages for SCC pragmas - - - - - a2b535d9 by Ben Gamari at 2019-12-05T16:07:45-05:00 users guide: Try to silence underfull \hbox warnings We use two tricks, as suggested here [1]: * Use microtype to try to reduce the incidence of underfull boxes * Bump up \hbadness to eliminate the warnings - - - - - 4e47217f by Bodigrim at 2019-12-05T16:07:47-05:00 Make sameNat and sameSymbol proxy-polymorphic - - - - - 8324f0b7 by Bodigrim at 2019-12-05T16:07:47-05:00 Test proxy-polymorphic sameNat and sameSymbol - - - - - 69001f54 by Ben Gamari at 2019-12-05T16:07:48-05:00 nonmoving: Clear segment bitmaps during sweep Previously we would clear the bitmaps of segments which we are going to sweep during the preparatory pause. However, this is unnecessary: the existence of the mark epoch ensures that the sweep will correctly identify non-reachable objects, even if we do not clear the bitmap. We now defer clearing the bitmap to sweep, which happens concurrently with mutation. - - - - - 58a9c429 by Ben Gamari at 2019-12-05T16:07:48-05:00 testsuite: Disable divByZero on non-NCG targets The LLVM backend does not guarantee any particular semantics for division by zero, making this test unreliable across platforms. - - - - - 8280bd8a by Ben Gamari at 2019-12-05T16:07:49-05:00 testsuite: Factor out terminal coloring - - - - - 92a52aaa by Ben Gamari at 2019-12-05T16:07:49-05:00 testsuite: Make performance metric summary more readable Along with some refactoring. - - - - - c4ca29c7 by Ben Gamari at 2019-12-05T16:07:49-05:00 testsuite: Use colors more consistently - - - - - 3354c68e by Vladislav Zavialov at 2019-12-05T16:07:49-05:00 Pretty-printing of the * kind Before this patch, GHC always printed the * kind unparenthesized. This led to two issues: 1. Sometimes GHC printed invalid or incorrect code. For example, GHC would print: type F @* x = x when it meant to print: type F @(*) x = x In the former case, instead of a kind application we were getting a type operator (@*). 2. Sometimes GHC printed kinds that were correct but hard to read. Should Either * Int be read as Either (*) Int or as (*) Either Int ? This depends on whether -XStarIsType is enabled, but it would be easier if we didn't have to check for the flag when reading the code. We can solve both problems by assigning (*) a different precedence. Note that Haskell98 kinds are not affected: ((* -> *) -> *) -> * does NOT become (((*) -> (*)) -> (*)) -> (*) The parentheses are added when (*) is used in a function argument position: F * * * becomes F (*) (*) (*) F A * B becomes F A (*) B Proxy * becomes Proxy (*) a * -> * becomes a (*) -> * - - - - - 70dd0e4b by Vladislav Zavialov at 2019-12-05T16:07:49-05:00 Parenthesize the * kind in TH.Ppr - - - - - a7a4efbf by Ben Gamari at 2019-12-05T16:07:49-05:00 rts/NonMovingSweep: Fix locking of new mutable list allocation Previously we used allocBlockOnNode_sync in nonmovingSweepMutLists despite the fact that we aren't in the GC and therefore the allocation spinlock isn't in use. This meant that sweep would end up spinning until the next minor GC, when the SM lock was moved away from the SM_MUTEX to the spinlock. This isn't a correctness issue but it sure isn't good for performance. Found thanks for Ward. Fixes #17539. - - - - - f171b358 by Matthias Braun at 2019-12-05T16:07:51-05:00 Fix typo in documentation of Base.hs. - - - - - 9897e8c8 by Gabor Greif at 2019-12-06T21:20:38-05:00 Implement pointer tagging for big families (#14373) Formerly we punted on these and evaluated constructors always got a tag of 1. We now cascade switches because we have to check the tag first and when it is MAX_PTR_TAG then get the precise tag from the info table and switch on that. The only technically tricky part is that the default case needs (logical) duplication. To do this we emit an extra label for it and branch to that from the second switch. This avoids duplicated codegen. Here's a simple example of the new code gen: data D = D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 On a 64-bit system previously all constructors would be tagged 1. With the new code gen D7 and D8 are tagged 7: [Lib.D7_con_entry() { ... {offset c1eu: // global R1 = R1 + 7; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; } }] [Lib.D8_con_entry() { ... {offset c1ez: // global R1 = R1 + 7; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; } }] When switching we now look at the info table only when the tag is 7. For example, if we derive Enum for the type above, the Cmm looks like this: c2Le: _s2Js::P64 = R1; _c2Lq::P64 = _s2Js::P64 & 7; switch [1 .. 7] _c2Lq::P64 { case 1 : goto c2Lk; case 2 : goto c2Ll; case 3 : goto c2Lm; case 4 : goto c2Ln; case 5 : goto c2Lo; case 6 : goto c2Lp; case 7 : goto c2Lj; } // Read info table for tag c2Lj: _c2Lv::I64 = %MO_UU_Conv_W32_W64(I32[I64[_s2Js::P64 & (-8)] - 4]); if (_c2Lv::I64 != 6) goto c2Lu; else goto c2Lt; Generated Cmm sizes do not change too much, but binaries are very slightly larger, due to the fact that the new instructions are longer in encoded form. E.g. previously entry code for D8 above would be 00000000000001c0 <Lib_D8_con_info>: 1c0: 48 ff c3 inc %rbx 1c3: ff 65 00 jmpq *0x0(%rbp) With this patch 00000000000001d0 <Lib_D8_con_info>: 1d0: 48 83 c3 07 add $0x7,%rbx 1d4: ff 65 00 jmpq *0x0(%rbp) This is one byte longer. Secondly, reading info table directly and then switching is shorter _c1co: movq -1(%rbx),%rax movl -4(%rax),%eax // Switch on info table tag jmp *_n1d5(,%rax,8) than doing the same switch, and then for the tag 7 doing another switch: // When tag is 7 _c1ct: andq $-8,%rbx movq (%rbx),%rax movl -4(%rax),%eax // Switch on info table tag ... Some changes of binary sizes in actual programs: - In NoFib the worst case is 0.1% increase in benchmark "parser" (see NoFib results below). All programs get slightly larger. - Stage 2 compiler size does not change. - In "containers" (the library) size of all object files increases 0.0005%. Size of the test program "bitqueue-properties" increases 0.03%. nofib benchmarks kindly provided by Ömer (@osa1): NoFib Results ============= -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS +0.0% 0.0% -0.0% -0.0% -0.0% CSD +0.0% 0.0% 0.0% +0.0% +0.0% FS +0.0% 0.0% 0.0% +0.0% 0.0% S +0.0% 0.0% -0.0% 0.0% 0.0% VS +0.0% 0.0% -0.0% +0.0% +0.0% VSD +0.0% 0.0% -0.0% +0.0% -0.0% VSM +0.0% 0.0% 0.0% 0.0% 0.0% anna +0.0% 0.0% +0.1% -0.9% -0.0% ansi +0.0% 0.0% -0.0% +0.0% +0.0% atom +0.0% 0.0% 0.0% 0.0% 0.0% awards +0.0% 0.0% -0.0% +0.0% 0.0% banner +0.0% 0.0% -0.0% +0.0% 0.0% bernouilli +0.0% 0.0% +0.0% +0.0% +0.0% binary-trees +0.0% 0.0% -0.0% -0.0% -0.0% boyer +0.0% 0.0% +0.0% 0.0% -0.0% boyer2 +0.0% 0.0% +0.0% 0.0% -0.0% bspt +0.0% 0.0% +0.0% +0.0% 0.0% cacheprof +0.0% 0.0% +0.1% -0.8% 0.0% calendar +0.0% 0.0% -0.0% +0.0% -0.0% cichelli +0.0% 0.0% +0.0% 0.0% 0.0% circsim +0.0% 0.0% -0.0% -0.1% -0.0% clausify +0.0% 0.0% +0.0% +0.0% 0.0% comp_lab_zift +0.0% 0.0% +0.0% 0.0% -0.0% compress +0.0% 0.0% +0.0% +0.0% 0.0% compress2 +0.0% 0.0% 0.0% 0.0% 0.0% constraints +0.0% 0.0% -0.0% -0.0% -0.0% cryptarithm1 +0.0% 0.0% +0.0% 0.0% 0.0% cryptarithm2 +0.0% 0.0% +0.0% -0.0% 0.0% cse +0.0% 0.0% +0.0% +0.0% 0.0% digits-of-e1 +0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 +0.0% 0.0% +0.0% -0.0% -0.0% dom-lt +0.0% 0.0% +0.0% +0.0% 0.0% eliza +0.0% 0.0% -0.0% +0.0% 0.0% event +0.0% 0.0% -0.0% -0.0% -0.0% exact-reals +0.0% 0.0% +0.0% +0.0% +0.0% exp3_8 +0.0% 0.0% -0.0% -0.0% -0.0% expert +0.0% 0.0% +0.0% +0.0% +0.0% fannkuch-redux +0.0% 0.0% +0.0% 0.0% 0.0% fasta +0.0% 0.0% -0.0% -0.0% -0.0% fem +0.0% 0.0% +0.0% +0.0% +0.0% fft +0.0% 0.0% +0.0% -0.0% -0.0% fft2 +0.0% 0.0% +0.0% +0.0% +0.0% fibheaps +0.0% 0.0% +0.0% +0.0% 0.0% fish +0.0% 0.0% +0.0% +0.0% 0.0% fluid +0.0% 0.0% +0.0% +0.0% +0.0% fulsom +0.0% 0.0% +0.0% -0.0% +0.0% gamteb +0.0% 0.0% +0.0% -0.0% -0.0% gcd +0.0% 0.0% +0.0% +0.0% 0.0% gen_regexps +0.0% 0.0% +0.0% -0.0% -0.0% genfft +0.0% 0.0% -0.0% -0.0% -0.0% gg +0.0% 0.0% 0.0% -0.0% 0.0% grep +0.0% 0.0% +0.0% +0.0% +0.0% hidden +0.0% 0.0% +0.0% -0.0% -0.0% hpg +0.0% 0.0% +0.0% -0.1% -0.0% ida +0.0% 0.0% +0.0% -0.0% -0.0% infer +0.0% 0.0% -0.0% -0.0% -0.0% integer +0.0% 0.0% -0.0% -0.0% -0.0% integrate +0.0% 0.0% 0.0% +0.0% 0.0% k-nucleotide +0.0% 0.0% -0.0% -0.0% -0.0% kahan +0.0% 0.0% -0.0% -0.0% -0.0% knights +0.0% 0.0% +0.0% -0.0% -0.0% lambda +0.0% 0.0% +1.2% -6.1% -0.0% last-piece +0.0% 0.0% +0.0% -0.0% -0.0% lcss +0.0% 0.0% +0.0% -0.0% -0.0% life +0.0% 0.0% +0.0% -0.0% -0.0% lift +0.0% 0.0% +0.0% +0.0% 0.0% linear +0.0% 0.0% +0.0% +0.0% +0.0% listcompr +0.0% 0.0% -0.0% -0.0% -0.0% listcopy +0.0% 0.0% -0.0% -0.0% -0.0% maillist +0.0% 0.0% +0.0% -0.0% -0.0% mandel +0.0% 0.0% +0.0% +0.0% +0.0% mandel2 +0.0% 0.0% +0.0% +0.0% -0.0% mate +0.0% 0.0% +0.0% +0.0% +0.0% minimax +0.0% 0.0% -0.0% +0.0% -0.0% mkhprog +0.0% 0.0% +0.0% +0.0% +0.0% multiplier +0.0% 0.0% 0.0% +0.0% -0.0% n-body +0.0% 0.0% +0.0% -0.0% -0.0% nucleic2 +0.0% 0.0% +0.0% +0.0% -0.0% para +0.0% 0.0% +0.0% +0.0% +0.0% paraffins +0.0% 0.0% +0.0% +0.0% +0.0% parser +0.1% 0.0% +0.4% -1.7% -0.0% parstof +0.0% 0.0% -0.0% -0.0% -0.0% pic +0.0% 0.0% +0.0% 0.0% -0.0% pidigits +0.0% 0.0% -0.0% -0.0% -0.0% power +0.0% 0.0% +0.0% -0.0% -0.0% pretty +0.0% 0.0% +0.0% +0.0% +0.0% primes +0.0% 0.0% +0.0% 0.0% 0.0% primetest +0.0% 0.0% +0.0% +0.0% +0.0% prolog +0.0% 0.0% +0.0% +0.0% +0.0% puzzle +0.0% 0.0% +0.0% +0.0% +0.0% queens +0.0% 0.0% 0.0% +0.0% +0.0% reptile +0.0% 0.0% +0.0% +0.0% 0.0% reverse-complem +0.0% 0.0% -0.0% -0.0% -0.0% rewrite +0.0% 0.0% +0.0% 0.0% -0.0% rfib +0.0% 0.0% +0.0% +0.0% +0.0% rsa +0.0% 0.0% +0.0% +0.0% +0.0% scc +0.0% 0.0% +0.0% +0.0% +0.0% sched +0.0% 0.0% +0.0% +0.0% +0.0% scs +0.0% 0.0% +0.0% +0.0% 0.0% simple +0.0% 0.0% +0.0% +0.0% +0.0% solid +0.0% 0.0% +0.0% +0.0% 0.0% sorting +0.0% 0.0% +0.0% -0.0% 0.0% spectral-norm +0.0% 0.0% -0.0% -0.0% -0.0% sphere +0.0% 0.0% +0.0% -1.0% 0.0% symalg +0.0% 0.0% +0.0% +0.0% +0.0% tak +0.0% 0.0% +0.0% +0.0% +0.0% transform +0.0% 0.0% +0.4% -1.3% +0.0% treejoin +0.0% 0.0% +0.0% -0.0% 0.0% typecheck +0.0% 0.0% -0.0% +0.0% 0.0% veritas +0.0% 0.0% +0.0% -0.1% +0.0% wang +0.0% 0.0% +0.0% +0.0% +0.0% wave4main +0.0% 0.0% +0.0% 0.0% -0.0% wheel-sieve1 +0.0% 0.0% +0.0% +0.0% +0.0% wheel-sieve2 +0.0% 0.0% +0.0% +0.0% 0.0% x2n1 +0.0% 0.0% +0.0% +0.0% 0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -6.1% -0.0% Max +0.1% 0.0% +1.2% +0.0% +0.0% Geometric Mean +0.0% -0.0% +0.0% -0.1% -0.0% NoFib GC Results ================ -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- circsim +0.0% 0.0% -0.0% -0.0% -0.0% constraints +0.0% 0.0% -0.0% 0.0% -0.0% fibheaps +0.0% 0.0% 0.0% -0.0% -0.0% fulsom +0.0% 0.0% 0.0% -0.6% -0.0% gc_bench +0.0% 0.0% 0.0% 0.0% -0.0% hash +0.0% 0.0% -0.0% -0.0% -0.0% lcss +0.0% 0.0% 0.0% -0.0% 0.0% mutstore1 +0.0% 0.0% 0.0% -0.0% -0.0% mutstore2 +0.0% 0.0% +0.0% -0.0% -0.0% power +0.0% 0.0% -0.0% 0.0% -0.0% spellcheck +0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -0.6% -0.0% Max +0.0% 0.0% +0.0% 0.0% 0.0% Geometric Mean +0.0% +0.0% +0.0% -0.1% +0.0% Fixes #14373 These performance regressions appear to be a fluke in CI. See the discussion in !1742 for details. Metric Increase: T6048 T12234 T12425 Naperian T12150 T5837 T13035 - - - - - ee07421f by Simon Peyton Jones at 2019-12-06T21:21:14-05:00 Work in progress on coercionLKind, coercionRKind This is a preliminary patch for #17515 - - - - - 0a4ca9eb by Simon Peyton Jones at 2019-12-06T21:21:14-05:00 Split up coercionKind This patch implements the idea in #17515, splitting `coercionKind` into: * `coercion{Left,Right}Kind`, which computes the left/right side of the pair * `coercionKind`, which computes the pair of coercible types This is reduces allocation since we frequently only need only one side of the pair. Specifically, we see the following improvements on x86-64 Debian 9: | test | new | old | relative chg. | | :------- | ---------: | ------------: | ------------: | | T5030 | 695537752 | 747641152.0 | -6.97% | | T5321Fun | 449315744 | 474009040.0 | -5.21% | | T9872a | 2611071400 | 2645040952.0 | -1.28% | | T9872c | 2957097904 | 2994260264.0 | -1.24% | | T12227 | 773435072 | 812367768.0 | -4.79% | | T12545 | 3142687224 | 3215714752.0 | -2.27% | | T14683 | 9392407664 | 9824775000.0 | -4.40% | Metric Decrease: T12545 T9872a T14683 T5030 T12227 T9872c T5321Fun T9872b - - - - - d46a72e1 by Gabor Greif at 2019-12-09T12:05:15-05:00 Fix comment typos The below is only necessary to fix the CI perf fluke that happened in 9897e8c8ef0b19a9571ef97a1d9bb050c1ee9121: ------------------------- Metric Decrease: T5837 T6048 T9020 T12425 T12234 T13035 T12150 Naperian ------------------------- - - - - - e3bba7e4 by Micha Wiedenmann at 2019-12-10T19:52:44-05:00 users guide: Motivation of DefaultSignatures - - - - - 843ceb38 by Ben Gamari at 2019-12-10T19:53:54-05:00 rts: Add a long form flag to enable the non-moving GC The old flag, `-xn`, was quite cryptic. Here we add `--nonmoving-gc` in addition. - - - - - 921d3238 by Ryan Scott at 2019-12-10T19:54:34-05:00 Ignore unary constraint tuples during typechecking (#17511) We deliberately avoid defining a magical `Unit%` class, for reasons that I have expounded upon in the newly added `Note [Ignore unary constraint tuples]` in `TcHsType`. However, a sneaky user could try to insert `Unit%` into their program by way of Template Haskell, leading to the interface-file error observed in #17511. To avoid this, any time we encounter a unary constraint tuple during typechecking, we drop the surrounding constraint tuple application. This is safe to do since `Unit% a` and `a` would be semantically equivalent (unlike other forms of unary tuples). Fixes #17511. - - - - - 436ec9f3 by Ben Gamari at 2019-12-10T19:55:37-05:00 gitlab-ci: Move changelog linting logic to shell script Allowing it to be easily used locally. - - - - - 2f6b434f by Ben Gamari at 2019-12-10T19:55:37-05:00 gitlab-ci: Move changelog linting logic to shell script Allowing it to be easily used locally. - - - - - 7a5a6e07 by Ben Gamari at 2019-12-10T19:56:25-05:00 base: Fix incorrect @since in GHC.Natural Fixes #17547. - - - - - 2bbfaf8a by Ben Gamari at 2019-12-10T19:57:01-05:00 hadrian: AArch64 supports the GHCi interpreter and SMP I'm not sure how this was omitted from the list of supported architectures. - - - - - 8f1ceb67 by John Ericson at 2019-12-10T19:57:39-05:00 Move Int# section of primops.txt.pp This matches the organization of the fixed-sized ones, and keeps each Int* next to its corresponding Word*. - - - - - 7a823b0f by John Ericson at 2019-12-10T19:57:39-05:00 Move Int64# and Word64# sections of primops.txt.pp This way it is next to the other fixed-sized ones. - - - - - 8dd9929a by Ben Gamari at 2019-12-10T19:58:19-05:00 testsuite: Add (broken) test for #17510 - - - - - 6e47a76a by Ben Gamari at 2019-12-10T19:58:59-05:00 Re-layout validate script This script was previously a whitespace nightmare. - - - - - f80c4a66 by Crazycolorz5 at 2019-12-11T14:12:17-05:00 rts: Specialize hashing at call site rather than in struct. Separate word and string hash tables on the type level, and do not store the hashing function. Thus when a different hash function is desire it is provided upon accessing the table. This is worst case the same as before the change, and in the majority of cases is better. Also mark the functions for aggressive inlining to improve performance. {F1686506} Reviewers: bgamari, erikd, simonmar Subscribers: rwbarton, thomie, carter GHC Trac Issues: #13165 Differential Revision: https://phabricator.haskell.org/D4889 - - - - - 2d1b9619 by Richard Eisenberg at 2019-12-11T14:12:55-05:00 Warn on inferred polymorphic recursion Silly users sometimes try to use visible dependent quantification and polymorphic recursion without a CUSK or SAK. This causes unexpected errors. So we now adjust expectations with a bit of helpful messaging. Closes #17541 and closes #17131. test cases: dependent/should_fail/T{17541{,b},17131} - - - - - 4dde485e by Oleg Grenrus at 2019-12-12T02:24:46-05:00 Add --show-unit-ids flag to ghc-pkg I only added it into --simple-output and ghc-pkg check output; there are probably other places where it can be adopted. - - - - - e6e1ec08 by Ben Gamari at 2019-12-12T02:25:33-05:00 testsuite: Simplify and clarify performance test baseline search The previous implementation was extremely complicated, seemingly to allow the local and CI namespaces to be searched incrementally. However, it's quite unclear why this is needed and moreover the implementation seems to have had quadratic runtime cost in the search depth(!). - - - - - 29c4609c by Ben Gamari at 2019-12-12T02:26:19-05:00 testsuite: Add test for #17549 - - - - - 9f0ee253 by Ben Gamari at 2019-12-12T02:26:56-05:00 gitlab-ci: Move -dwarf and -debug jobs to full-build stage This sacrifices some precision in favor of improving parallelism. - - - - - 7179b968 by Ben Gamari at 2019-12-12T02:27:34-05:00 Revert "rts: Drop redundant flags for libffi" This seems to have regressed builds using `--with-system-libffi` (#17520). This reverts commit 3ce18700f80a12c48a029b49c6201ad2410071bb. - - - - - cc7d5650 by Oleg Grenrus at 2019-12-16T10:20:56+02:00 Having no shake upper bound is irresposible Given that shake is far from "done" API wise, and is central component to the build system. - - - - - 9431f905 by Oleg Grenrus at 2019-12-16T10:55:50+02:00 Add index-state to hadrian/cabal.project Then one is freer to omit upper bounds, as we won't pick any new entries on Hackage while building hadrian itself. - - - - - 3e17a866 by Krzysztof Gogolewski at 2019-12-16T19:31:44-05:00 Remove dataConSig As suggested in #17291 - - - - - 75355fde by Krzysztof Gogolewski at 2019-12-16T19:31:44-05:00 Use "OrCoVar" functions less As described in #17291, we'd like to separate coercions and expressions in a more robust fashion. This is a small step in this direction. - `mkLocalId` now panicks on a covar. Calls where this was not the case were changed to `mkLocalIdOrCoVar`. - Don't use "OrCoVar" functions in places where we know the type is not a coercion. - - - - - f9686e13 by Richard Eisenberg at 2019-12-16T19:32:21-05:00 Do more validity checks for quantified constraints Close #17583. Test case: typecheck/should_fail/T17563 - - - - - af763765 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Fix Windows artifact collection Variable interpolation in gitlab-ci.yml apparently doesn't work. Sigh. - - - - - e6d4b902 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Use xz --threads on Debian 10 - - - - - 8ba650e9 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Allow debian 8 build to fail The python release shipped with deb8 (3.3) is too old for our testsuite driver. - - - - - ac25a3f6 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Use xz --threads on Alpine - - - - - cc628088 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Another approach for xz detection - - - - - 37d788ab by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Re-add release-x86_64-deb9 job Also eliminate some redundancy. - - - - - f8279138 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Drop redundant release-x86_64-linux-deb9 job - - - - - 8148ff06 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark cgrun057 as broken on ARMv7 Due to #17554. It's very surprising that this only occurs on ARMv7 but this is the only place I've seen this failure thusfar. - - - - - 85e5696d by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark prog001 as fragile on ARMv7 Due to #17555. - - - - - a5f0aab0 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T10272 as broken on ARMv7 Due to #17556. - - - - - 1e6827c6 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T13825-debugger as broken on ARMv7 Due to #17557. - - - - - 7cef0b7d by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T14028 as broken on ARMv7 Due to #17558. - - - - - 6ea4eb4b by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Make ghc_built_by_llvm check more precise Previously it would hackily look at the flavour name to determine whether LLVM was used to build stage2 ghc. However, this didn't work at all with Hadrian and would miss cases like ARM where we use the LLVM backend by default. See #16087 for the motivation for why ghc_built_by_llvm is needed at all. This should catch one of the ARMv7 failures described in #17555. - - - - - c3e82bf7 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T5435_* tests as broken on ARM `T5435_v_asm_a`, `T5435_v_asm_b`, and `T5435_v_gcc` all fail on ARMv7. See #17559. - - - - - eb2aa851 by Ben Gamari at 2019-12-17T07:24:40-05:00 gitlab-ci: Don't allow armv7 jobs to fail - - - - - efc92216 by Ben Gamari at 2019-12-17T07:24:40-05:00 Revert "testsuite: Mark cgrun057 as broken on ARMv7" This reverts commit 6cfc47ec8a478e1751cb3e7338954da1853c3996. - - - - - 1d2bb9eb by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark print002 as fragile on ARM Due to #17557. Also accepting spurious performance change. Metric Decrease: T1969 - - - - - 41f4e4fb by Josh Meredith at 2019-12-17T07:25:17-05:00 Fix ambiguous occurence error when building Hadrian - - - - - 4374983a by Josh Meredith at 2019-12-17T07:25:17-05:00 Rename SphinxMode constructors - - - - - a8f7ecd5 by Josh Meredith at 2019-12-17T07:25:17-05:00 Use *Mode suffix instead of *M - - - - - 58655b9d by Sylvain Henry at 2019-12-18T13:43:37+01:00 Add GHC-API logging hooks * Add 'dumpAction' hook to DynFlags. It allows GHC API users to catch dumped intermediate codes and information. The format of the dump (Core, Stg, raw text, etc.) is now reported allowing easier automatic handling. * Add 'traceAction' hook to DynFlags. Some dumps go through the trace mechanism (for instance unfoldings that have been considered for inlining). This is problematic because: 1) dumps aren't written into files even with -ddump-to-file on 2) dumps are written on stdout even with GHC API 3) in this specific case, dumping depends on unsafe globally stored DynFlags which is bad for GHC API users We introduce 'traceAction' hook which allows GHC API to catch those traces and to avoid using globally stored DynFlags. * Avoid dumping empty logs via dumpAction/traceAction (but still write empty files to keep the existing behavior) - - - - - fad866e0 by Moritz Kiefer at 2019-12-19T11:15:39-05:00 Avoid race condition in hDuplicateTo In our codebase we have some code along the lines of ``` newStdout <- hDuplicate stdout stderr `hDuplicateTo` stdout ``` to avoid stray `putStrLn`s from corrupting a protocol (LSP) that is run over stdout. On CI we have seen a bunch of issues where `dup2` returned `EBUSY` so this fails with `ResourceExhausted` in Haskell. I’ve spent some time looking at the docs for `dup2` and the code in `base` and afaict the following race condition is being triggered here: 1. The user calls `hDuplicateTo stderr stdout`. 2. `hDuplicateTo` calls `hClose_help stdout_`, this closes the file handle for stdout. 3. The file handle for stdout is now free, so another thread allocating a file might get stdout. 4. If `dup2` is called while `stdout` (now pointing to something else) is half-open, it returns EBUSY. I think there might actually be an even worse case where `dup2` is run after FD 1 is fully open again. In that case, you will end up not just redirecting the original stdout to stderr but also the whatever resulted in that file handle being allocated. As far as I can tell, `dup2` takes care of closing the file handle itself so there is no reason to do this in `hDuplicateTo`. So this PR replaces the call to `hClose_help` by the only part of `hClose_help` that we actually care about, namely, `flushWriteBuffer`. I tested this on our codebase fairly extensively and haven’t been able to reproduce the issue with this patch. - - - - - 0c114c65 by Sylvain Henry at 2019-12-19T11:16:17-05:00 Handle large ARR_WORDS in heap census (fix #17572) We can do a heap census with a non-profiling RTS. With a non-profiling RTS we don't zero superfluous bytes of shrunk arrays hence a need to handle the case specifically to avoid a crash. Revert part of a586b33f8e8ad60b5c5ef3501c89e9b71794bbed - - - - - 1a0d1a65 by John Ericson at 2019-12-20T10:50:22-05:00 Deduplicate copied monad failure handler code - - - - - 70e56b27 by Ryan Scott at 2019-12-20T10:50:57-05:00 lookupBindGroupOcc: recommend names in the same namespace (#17593) Previously, `lookupBindGroupOcc`'s error message would recommend all similar names in scope, regardless of whether they were type constructors, data constructors, or functions, leading to the confusion witnessed in #17593. This is easily fixed by only recommending names in the same namespace, using the `nameSpacesRelated` function. Fixes #17593. - - - - - 3c12355e by Stefan Schulze Frielinghaus at 2019-12-24T01:03:44-05:00 Fix endian handling w.r.t. CPP macro WORDS_BIGENDIAN Include header file `ghcautoconf.h` where the CPP macro `WORDS_BIGENDIAN` is defined. This finally fixes #17337 (in conjunction with commit 6c59cc71dc). - - - - - 11f8eef5 by Stefan Schulze Frielinghaus at 2019-12-24T01:03:44-05:00 fixup! Fix endian handling w.r.t. CPP macro WORDS_BIGENDIAN - - - - - 40327b03 by Sylvain Henry at 2019-12-24T01:04:24-05:00 Remove outdated comment - - - - - aeea92ef by Sylvain Henry at 2019-12-25T19:23:54-05:00 Switch to ReadTheDocs theme for the user-guide - - - - - 26493eab by Gabor Greif at 2019-12-25T19:24:32-05:00 Fix copy-paste error in comment - - - - - 776df719 by Gabor Greif at 2019-12-25T19:24:32-05:00 Fix comment about minimal gcc version to be consistent what FP_GCC_VERSION requires - - - - - 3b17114d by Ömer Sinan Ağacan at 2019-12-26T14:09:11-05:00 Minor refactor in ghc.cabal.in: - Remove outdated comments - Move cutils.c from parser to cbits - Remove unused cutils.h - - - - - 334290b6 by Ryan Scott at 2019-12-26T14:09:48-05:00 Replace panic/notHandled with noExtCon in DsMeta There are many spots in `DsMeta` where `panic` or `notHandled` is used after pattern-matching on a TTG extension constructor. This is overkill, however, as using `noExtCon` would work just as well. This patch switches out these panics for `noExtCon`. - - - - - 68252aa3 by Ben Gamari at 2019-12-27T15:11:38-05:00 testsuite: Skip T17499 when built against integer-simple Since it routinely times out in CI. - - - - - 0c51aeeb by Gabor Greif at 2019-12-27T15:12:17-05:00 suppress popup dialog about missing Xcode at configure tested with `bash` and `zsh`. - - - - - 8d76bcc2 by Gabor Greif at 2019-12-27T15:12:17-05:00 while at it rename XCode to the official Xcode - - - - - 47a68205 by Ben Gamari at 2019-12-27T15:12:55-05:00 testsuite: Mark cgrun057 as fragile on ARM As reported in #17554. Only marking on ARM for now although there is evidence to suggest that the issue may occur on other platforms as well. - - - - - d03dec8f by Gabor Greif at 2019-12-27T15:13:32-05:00 use shell variable CcLlvmBackend for test Previously we used `AC_DEFINE`d variable `CC_LLVM_BACKEND` which has an empty shell expansion. - - - - - 2528e684 by Ben Gamari at 2019-12-30T06:51:32-05:00 driver: Include debug level in the recompilation check hash Fixes #17586. - - - - - f14bb50b by Ben Gamari at 2019-12-30T06:52:09-05:00 rts: Ensure that nonmoving gc isn't used with profiling - - - - - b426de37 by Ben Gamari at 2019-12-30T06:52:45-05:00 llvmGen: Ensure that entry labels don't have predecessors The LLVM IR forbids the entry label of a procedure from having any predecessors. In the case of a simple looping function the LLVM code generator broke this invariant, as noted in #17589. Fix this by moving the function prologue to its own basic block, as suggested by @kavon in #11649. Fixes #11649 and #17589. - - - - - 613f7265 by Ben Gamari at 2019-12-30T06:52:45-05:00 llvmGen: Drop old fix for #11649 This was a hack which is no longer necessary now since we introduce a dedicated entry block for each procedure. - - - - - fdeffa5e by Ben Gamari at 2019-12-30T06:53:23-05:00 rts: Error on invalid --numa flags Previously things like `+RTS --numa-debug` would enable NUMA support, despite being an invalid flag. - - - - - 9ce3ba68 by Ben Gamari at 2019-12-30T06:53:23-05:00 rts: Fix --debug-numa mode under Docker As noted in #17606, Docker disallows the get_mempolicy syscall by default. This caused numerous tests to fail under CI in the `debug_numa` way. Avoid this by disabling the NUMA probing logic when --debug-numa is in use, instead setting n_numa_nodes in RtsFlags.c. Fixes #17606. - - - - - 5baa2a43 by Ben Gamari at 2019-12-30T06:54:01-05:00 testsuite: Disable derefnull when built with LLVM LLVM does not guarantee any particular semantics when dereferencing null pointers. Consequently, this test actually passes when built with the LLVM backend. - - - - - bd544d3d by Ben Gamari at 2019-12-30T06:54:38-05:00 hadrian: Track hash of Cabal Setup builder arguments Lest we fail to rebuild when they change. Fixes #17611. - - - - - 6e2c495e by Ben Gamari at 2019-12-30T06:55:19-05:00 TcIface: Fix inverted logic in typechecking of source ticks Previously we would throw away source ticks when the debug level was non-zero. This is precisely the opposite of what was intended. Fixes #17616. Metric Decrease: T13056 T9020 T9961 T12425 - - - - - 7fad387d by Ben Gamari at 2019-12-30T06:55:55-05:00 perf_notes: Add --zero-y argument This makes it easier to see the true magnitude of fluctuations. Also do some house-keeping in the argument parsing department. - - - - - 0d42b287 by Ben Gamari at 2019-12-30T06:55:55-05:00 testsuite: Enlarge acceptance window for T1969 As noted in #17624, it's quite unstable, especially, for some reason, on i386 and armv7 (something about 32-bit platforms perhaps?). Metric Increase: T1969 - - - - - eb608235 by Sylvain Henry at 2019-12-31T14:22:32-05:00 Module hierarchy (#13009): Stg - - - - - d710fd66 by Vladislav Zavialov at 2019-12-31T14:23:10-05:00 Testsuite: update some Haddock tests Fixed tests: * haddockA039: added to all.T * haddockE004: replaced with T17561 (marked as expect_broken) New tests: * haddockA040: deriving clause for a data instance * haddockA041: haddock and CPP #include - - - - - 859ebdd4 by Kevin Buhr at 2019-12-31T23:44:39-05:00 Add "-Iw" RTS flag for minimum wait between idle GCs (#11134) - - - - - dd4b6551 by Kevin Buhr at 2019-12-31T23:44:39-05:00 Add additional Note explaining the -Iw flag - - - - - c4279ff1 by Kevin Buhr at 2019-12-31T23:44:39-05:00 Fix some sloppy indentation - - - - - b84c09d5 by Ömer Sinan Ağacan at 2019-12-31T23:45:19-05:00 Tweak Cmm dumps to avoid generating sections for empty groups When dumping Cmm groups check if the group is empty, to avoid generating empty sections in dump files like ==================== Output Cmm ==================== [] Also fixes a few bad indentation in the code around changes. - - - - - b2e0323f by Gabor Greif at 2020-01-03T21:22:36-05:00 Simplify mrStr - - - - - 3c9dc06b by Brian Wignall at 2020-01-04T15:55:06-05:00 Fix typos, via a Levenshtein-style corrector - - - - - d561c8f6 by Sylvain Henry at 2020-01-04T15:55:46-05:00 Add Cmm related hooks * stgToCmm hook * cmmToRawCmm hook These hooks are used by Asterius and could be useful to other clients of the GHC API. It increases the Parser dependencies (test CountParserDeps) to 184. It's still less than 200 which was the initial request (cf https://mail.haskell.org/pipermail/ghc-devs/2019-September/018122.html) so I think it's ok to merge this. - - - - - ae6b6276 by Oleg Grenrus at 2020-01-04T15:56:22-05:00 Update to Cabal submodule to v3.2.0.0-alpha3 Metric Increase: haddock.Cabal - - - - - 073f7cfd by Vladislav Zavialov at 2020-01-04T15:56:59-05:00 Add lexerDbg to dump the tokens fed to the parser This a small utility function that comes in handy when debugging the lexer and the parser. - - - - - 558d4d4a by Sylvain Henry at 2020-01-04T15:57:38-05:00 Split integerGmpInternals test in several parts This is to prepare for ghc-bignum which implements some but not all of gmp functions. - - - - - 4056b966 by Ben Gamari at 2020-01-04T15:58:15-05:00 testsuite: Mark cgrun057 as fragile on all platforms I have seen this fail both on x86-64/Debian 9 and armv7/Debian 9 See #17554. - - - - - 5ffea0c6 by Tamar Christina at 2020-01-06T18:38:37-05:00 Fix overflow. - - - - - 99a9f51b by Sylvain Henry at 2020-01-06T18:39:22-05:00 Module hierarchy: Iface (cf #13009) - - - - - 7aa4a061 by Ben Gamari at 2020-01-07T13:11:48-05:00 configure: Only check GCC version if CC is GCC Also refactor FP_GCC_EXTRA_FLAGS in a few ways: * We no longer support compilers which lack support for -fno-builtin and -fwrapv so remove the condition on GccVersion * These flags are only necessary when using the via-C backend so make them conditional on Unregisterised. Fixes #15742. - - - - - 0805ed7e by John Ericson at 2020-01-07T13:12:25-05:00 Use non-empty lists to remove partiality in matching code - - - - - 7844f3a8 by Ben Gamari at 2020-01-07T13:13:02-05:00 testsuite: Mark T17073 as broken on Windows Due to #17607. - - - - - acf40cae by Ben Gamari at 2020-01-07T13:13:02-05:00 gitlab-ci: Disallow Windows from failing - - - - - 34bc02c7 by Ben Gamari at 2020-01-07T13:13:02-05:00 configure: Find Python3 for testsuite In addition, we prefer the Mingw64 Python distribution on Windows due to #17483. - - - - - e35fe8d5 by Ben Gamari at 2020-01-07T13:13:02-05:00 testsuite: Fix Windows platform test Previously we used platform.system() and while this worked fine (e.g. returned `Windows`, as expected) locally under both msys and MingW64 Python distributions, it inexplicably returned `MINGW64_NT-10.0` under MingW64 Python on CI. It seems os.name is more reliable so we now use that instead.. - - - - - 48ef6217 by Ben Gamari at 2020-01-07T13:13:39-05:00 gitlab-ci: Rename push-test-metrics.sh to test-metrics.sh Refactoring to follow. - - - - - 2234fa92 by Ben Gamari at 2020-01-07T13:13:39-05:00 gitlab-ci: Pull test metrics before running testsuite Otherwise the testsuite driver may not have an up-to-date baseline. - - - - - 1ca9adbc by Sylvain Henry at 2020-01-07T13:14:18-05:00 Remove `parallel` check from configure.ac `parallel` is no longer a submodule since 3cb063c805ec841ca33b8371ef8aba9329221b6c - - - - - b69a3460 by Ryan Scott at 2020-01-07T13:14:57-05:00 Monomorphize HsModule to GhcPs (#17642) Analyzing the call sites for `HsModule` reveals that it is only ever used with parsed code (i.e., `GhcPs`). This simplifies `HsModule` by concretizing its `pass` parameter to always be `GhcPs`. Fixes #17642. - - - - - d491a679 by Sylvain Henry at 2020-01-08T06:16:31-05:00 Module hierarchy: Renamer (cf #13009) - - - - - d589410f by Ben Gamari at 2020-01-08T06:17:09-05:00 Bump haskeline submodule to 0.8.0.1 (cherry picked from commit feb3b955402d53c3875dd7a9a39f322827e5bd69) - - - - - 923a1272 by Ryan Scott at 2020-01-08T06:17:47-05:00 Print Core type applications with no whitespace after @ (#17643) This brings the pretty-printer for Core in line with how visible type applications are normally printed: namely, with no whitespace after the `@` character (i.e., `f @a` instead of `f @ a`). While I'm in town, I also give the same treatment to type abstractions (i.e., `\(@a)` instead of `\(@ a)`) and coercion applications (i.e., `f @~x` instead of `f @~ x`). Fixes #17643. - - - - - 49f83a0d by Adam Sandberg Eriksson at 2020-01-12T21:28:09-05:00 improve docs for HeaderInfo.getImports [skip ci] - - - - - 9129210f by Matthew Pickering at 2020-01-12T21:28:47-05:00 Overloaded Quotation Brackets (#246) This patch implements overloaded quotation brackets which generalise the desugaring of all quotation forms in terms of a new minimal interface. The main change is that a quotation, for example, [e| 5 |], will now have type `Quote m => m Exp` rather than `Q Exp`. The `Quote` typeclass contains a single method for generating new names which is used when desugaring binding structures. The return type of functions from the `Lift` type class, `lift` and `liftTyped` have been restricted to `forall m . Quote m => m Exp` rather than returning a result in a Q monad. More details about the feature can be read in the GHC proposal. https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0246-overloaded-bracket.rst - - - - - 350e2b78 by Richard Eisenberg at 2020-01-12T21:29:27-05:00 Don't zap to Any; error instead This changes GHC's treatment of so-called Naughty Quantification Candidates to issue errors, instead of zapping to Any. Close #16775. No new test cases, because existing ones cover this well. - - - - - 0b5ddc7f by Brian Wignall at 2020-01-12T21:30:08-05:00 Fix more typos, via an improved Levenshtein-style corrector - - - - - f732dbec by Ben Gamari at 2020-01-12T21:30:49-05:00 gitlab-ci: Retain bindists used by head.hackage for longer Previously we would keep them for two weeks. However, on the stable branches two weeks can easily elapse with no pushes. - - - - - c8636da5 by Sylvain Henry at 2020-01-12T21:31:30-05:00 Fix LANG=C for readelf invocation in T14999 The test fails when used with LANG=fr_FR.UTF-8 - - - - - 077a88de by Jean-Baptiste Mazon at 2020-01-12T21:32:08-05:00 users-guide/debug-info: typo “behivior” - - - - - 61916c5d by Simon Peyton Jones at 2020-01-12T21:32:44-05:00 Add comments about TH levels - - - - - 1fd766ca by Simon Peyton Jones at 2020-01-12T21:32:44-05:00 Comments about constraint floating - - - - - de01427e by Simon Peyton Jones at 2020-01-12T21:32:45-05:00 Minor refactor around quantified constraints This patch clarifies a dark corner of quantified constraints. * See Note [Yukky eq_sel for a HoleDest] in TcSMonad * Minor refactor, breaking out new function TcInteract.doTopReactEqPred - - - - - 30be3bf1 by Simon Peyton Jones at 2020-01-12T21:32:45-05:00 Comments in TcHsType - - - - - c5977d4d by Sebastian Graf at 2020-01-16T05:58:58-05:00 Better documentation for mkEtaWW [skip ci] So that hopefully I understand it faster next time. Also got rid of the confusing `orig_expr`, which makes the call site in `etaExpand` look out of sync with the passed `n` (which is not the original `n`). - - - - - 22c0bdc3 by John Ericson at 2020-01-16T05:59:37-05:00 Handle TagToEnum in the same big case as the other primops Before, it was a panic because it was handled above. But there must have been an error in my reasoning (another caller?) because #17442 reported the panic was hit. But, rather than figuring out what happened, I can just make it impossible by construction. By adding just a bit more bureaucracy in the return types, I can handle TagToEnum in the same case as all the others, so the big case is is now total, and the panic is removed. Fixes #17442 - - - - - ee5d63f4 by John Ericson at 2020-01-16T05:59:37-05:00 Get rid of OpDest `OpDest` was basically a defunctionalization. Just turn the code that cased on it into those functions, and call them directly. - - - - - 1ff55226 by John Ericson at 2020-01-16T06:00:16-05:00 Remove special case case of bool during STG -> C-- Allow removing the no longer needed cgPrimOp, getting rid of a small a small layer violation too. Change which made the special case no longer needed was #6135 / 6579a6c73082387f82b994305011f011d9d8382b, which dates back to 2013, making me feel better. - - - - - f416fe64 by Adam Wespiser at 2020-01-16T06:00:53-05:00 replace dead html link (fixes #17661) - - - - - f6bf2ce8 by Sebastian Graf at 2020-01-16T06:01:32-05:00 Revert "`exprOkForSpeculation` for Note [IO hack in the demand analyser]" This reverts commit ce64b397777408731c6dd3f5c55ea8415f9f565b on the grounds of the regression it would introduce in a couple of packages. Fixes #17653. Also undoes a slight metric increase in #13701 introduced by that commit that we didn't see prior to !1983. Metric Decrease: T13701 - - - - - a71323ff by Ben Gamari at 2020-01-17T08:43:16-05:00 gitlab-ci: Don't FORCE_SYMLINKS on Windows Not all runners have symlink permissions enabled. - - - - - 0499e3bc by Ömer Sinan Ağacan at 2020-01-20T15:31:33-05:00 Fix +RTS -Z flag documentation Stack squeezing is done on context switch, not on GC or stack overflow. Fix the documentation. Fixes #17685 [ci skip] - - - - - a661df91 by Ömer Sinan Ağacan at 2020-01-20T15:32:13-05:00 Document Stg.FVs module Fixes #17662 [ci skip] - - - - - db24e480 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Don't trash STG registers Fixes #13904. - - - - - f3d7fdb3 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Fix typo in readnone attribute - - - - - 442751c6 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Add lower-expect to the -O0 optimisation set @kavon says that this will improve block layout for stack checks. - - - - - e90ecc93 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Fix #14251 Fixes the calling convention for functions passing raw SSE-register values by adding padding as needed to get the values in the right registers. This problem cropped up when some args were unused an dropped from the live list. This folds together 2e23e1c7de01c92b038e55ce53d11bf9db993dd4 and 73273be476a8cc6c13368660b042b3b0614fd928 previously from @kavon. Metric Increase: T12707 ManyConstructors - - - - - 66e511a4 by Ben Gamari at 2020-01-20T15:33:28-05:00 testsuite: Preserve more information in framework failures Namely print the entire exception in hopes that this will help track down #17649. - - - - - b62b8cea by Ömer Sinan Ağacan at 2020-01-20T15:34:06-05:00 Remove deprecated -smp flag It was deprecated in 2012 with 46258b40 - - - - - 0c04a86a by Ben Gamari at 2020-01-20T15:34:43-05:00 gitlab-ci: Reenable submodule linter - - - - - 2bfabd22 by Ben Gamari at 2020-01-20T15:34:43-05:00 gitlab-ci: Allow submodule cleaning to fail on Windows Currently CI is inexplicably failing with ``` $ git submodule foreach git clean -xdf fatal: not a git repository: libffi-tarballs/../.git/modules/libffi-tarballs ``` I have no idea how this working tree got into such a state but we do need to fail more gracefully when it happens. Consequently, we allow the cleaning step to fail. - - - - - 14bced99 by Xavier Denis at 2020-01-20T15:35:21-05:00 Put the docs for :instances in alphabetical position - - - - - 7e0bb82b by Ben Gamari at 2020-01-20T15:35:57-05:00 Add missing Note [Improvement from Ground Wanteds] Closes #17659. - - - - - 17e43a7c by Ben Gamari at 2020-01-20T15:36:32-05:00 unregisterised: Fix declaration for stg_NO_FINALIZER Previously it had a redundant _entry suffix. We never noticed this previously presumably because we never generated references to it (however hard to believe this may be). However, it did start failing in !1304. - - - - - 3dae006f by PHO at 2020-01-20T15:37:08-05:00 Avoid ./configure failure on NetBSD - - - - - 738e2912 by Ben Gamari at 2020-01-24T13:42:56-05:00 testsuite: Widen acceptance window of T1969 I have seen >20% fluctuations in this number, leading to spurious failures. - - - - - ad4eb7a7 by Gabor Greif at 2020-01-25T05:19:07-05:00 Document the fact, that openFileBlocking can consume an OS thread indefinitely. Also state that a deadlock can happen with the non-threaded runtime. [ci skip] - - - - - be910728 by Sebastian Graf at 2020-01-25T05:19:46-05:00 `-ddump-str-signatures` dumps Text, not STG [skip ci] - - - - - 0e57d8a1 by Ömer Sinan Ağacan at 2020-01-25T05:20:27-05:00 Fix chaining tagged and untagged ptrs in compacting GC Currently compacting GC has the invariant that in a chain all fields are tagged the same. However this does not really hold: root pointers are not tagged, so when we thread a root we initialize a chain without a tag. When the pointed objects is evaluated and we have more pointers to it from the heap, we then add *tagged* fields to the chain (because pointers to it from the heap are tagged), ending up chaining fields with different tags (pointers from roots are NOT tagged, pointers from heap are). This breaks the invariant and as a result compacting GC turns tagged pointers into non-tagged. This later causes problem in the generated code where we do reads assuming that the pointer is aligned, e.g. 0x7(%rax) -- assumes that pointer is tagged 1 which causes misaligned reads. This caused #17088. We fix this using the "pointer tagging for large families" patch (#14373, !1742): - With the pointer tagging patch the GC can know what the tagged pointer to a CONSTR should be (previously we'd need to know the family size -- large families are always tagged 1, small families are tagged depending on the constructor). - Since we now know what the tags should be we no longer need to store the pointer tag in the info table pointers when forming chains in the compacting GC. As a result we no longer need to tag pointers in chains with 1/2 depending on whether the field points to an info table pointer, or to another field: an info table pointer is always tagged 0, everything else in the chain is tagged 1. The lost tags in pointers can be retrieved by looking at the info table. Finally, instead of using tag 1 for fields and tag 0 for info table pointers, we use two different tags for fields: - 1 for fields that have untagged pointers - 2 for fields that have tagged pointers When unchaining we then look at the pointer to a field, and depending on its tag we either leave a tagged pointer or an untagged pointer in the field. This allows chaining untagged and tagged fields together in compacting GC. Fixes #17088 Nofib results ------------- Binaries are smaller because of smaller `Compact.c` code. make mode=fast EXTRA_RUNTEST_OPTS="-cachegrind" EXTRA_HC_OPTS="-with-rtsopts=-c" NoFibRuns=1 -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.3% 0.0% +0.0% +0.0% +0.0% CSD -0.3% 0.0% +0.0% +0.0% +0.0% FS -0.3% 0.0% +0.0% -0.0% -0.0% S -0.3% 0.0% +5.4% +0.8% +3.9% VS -0.3% 0.0% +0.0% -0.0% -0.0% VSD -0.3% 0.0% -0.0% -0.0% -0.2% VSM -0.3% 0.0% +0.0% +0.0% +0.0% anna -0.1% 0.0% +0.0% +0.0% +0.0% ansi -0.3% 0.0% +0.1% +0.0% +0.0% atom -0.2% 0.0% +0.0% +0.0% +0.0% awards -0.2% 0.0% +0.0% 0.0% -0.0% banner -0.3% 0.0% +0.0% +0.0% +0.0% bernouilli -0.3% 0.0% +0.1% +0.0% +0.0% binary-trees -0.2% 0.0% +0.0% 0.0% +0.0% boyer -0.3% 0.0% +0.2% +0.0% +0.0% boyer2 -0.2% 0.0% +0.2% +0.1% +0.0% bspt -0.2% 0.0% +0.0% +0.0% +0.0% cacheprof -0.2% 0.0% +0.0% +0.0% +0.0% calendar -0.3% 0.0% +0.0% +0.0% +0.0% cichelli -0.3% 0.0% +1.1% +0.2% +0.5% circsim -0.2% 0.0% +0.0% -0.0% -0.0% clausify -0.3% 0.0% +0.0% -0.0% -0.0% comp_lab_zift -0.2% 0.0% +0.0% +0.0% +0.0% compress -0.3% 0.0% +0.0% +0.0% +0.0% compress2 -0.3% 0.0% +0.0% -0.0% -0.0% constraints -0.3% 0.0% +0.2% +0.1% +0.1% cryptarithm1 -0.3% 0.0% +0.0% -0.0% 0.0% cryptarithm2 -0.3% 0.0% +0.0% +0.0% +0.0% cse -0.3% 0.0% +0.0% +0.0% +0.0% digits-of-e1 -0.3% 0.0% +0.0% +0.0% +0.0% digits-of-e2 -0.3% 0.0% +0.0% +0.0% -0.0% dom-lt -0.2% 0.0% +0.0% +0.0% +0.0% eliza -0.2% 0.0% +0.0% +0.0% +0.0% event -0.3% 0.0% +0.1% +0.0% -0.0% exact-reals -0.2% 0.0% +0.0% +0.0% +0.0% exp3_8 -0.3% 0.0% +0.0% +0.0% +0.0% expert -0.2% 0.0% +0.0% +0.0% +0.0% fannkuch-redux -0.3% 0.0% -0.0% -0.0% -0.0% fasta -0.3% 0.0% +0.0% +0.0% +0.0% fem -0.2% 0.0% +0.1% +0.0% +0.0% fft -0.2% 0.0% +0.0% -0.0% -0.0% fft2 -0.2% 0.0% +0.0% -0.0% +0.0% fibheaps -0.3% 0.0% +0.0% -0.0% -0.0% fish -0.3% 0.0% +0.0% +0.0% +0.0% fluid -0.2% 0.0% +0.4% +0.1% +0.1% fulsom -0.2% 0.0% +0.0% +0.0% +0.0% gamteb -0.2% 0.0% +0.1% +0.0% +0.0% gcd -0.3% 0.0% +0.0% +0.0% +0.0% gen_regexps -0.3% 0.0% +0.0% -0.0% -0.0% genfft -0.3% 0.0% +0.0% +0.0% +0.0% gg -0.2% 0.0% +0.7% +0.3% +0.2% grep -0.2% 0.0% +0.0% +0.0% +0.0% hidden -0.2% 0.0% +0.0% +0.0% +0.0% hpg -0.2% 0.0% +0.1% +0.0% +0.0% ida -0.3% 0.0% +0.0% +0.0% +0.0% infer -0.2% 0.0% +0.0% -0.0% -0.0% integer -0.3% 0.0% +0.0% +0.0% +0.0% integrate -0.2% 0.0% +0.0% +0.0% +0.0% k-nucleotide -0.2% 0.0% +0.0% +0.0% -0.0% kahan -0.3% 0.0% -0.0% -0.0% -0.0% knights -0.3% 0.0% +0.0% -0.0% -0.0% lambda -0.3% 0.0% +0.0% -0.0% -0.0% last-piece -0.3% 0.0% +0.0% +0.0% +0.0% lcss -0.3% 0.0% +0.0% +0.0% 0.0% life -0.3% 0.0% +0.0% -0.0% -0.0% lift -0.2% 0.0% +0.0% +0.0% +0.0% linear -0.2% 0.0% +0.0% +0.0% +0.0% listcompr -0.3% 0.0% +0.0% +0.0% +0.0% listcopy -0.3% 0.0% +0.0% +0.0% +0.0% maillist -0.3% 0.0% +0.0% -0.0% -0.0% mandel -0.2% 0.0% +0.0% +0.0% +0.0% mandel2 -0.3% 0.0% +0.0% +0.0% +0.0% mate -0.2% 0.0% +0.0% +0.0% +0.0% minimax -0.3% 0.0% +0.0% +0.0% +0.0% mkhprog -0.2% 0.0% +0.0% +0.0% +0.0% multiplier -0.3% 0.0% +0.0% -0.0% -0.0% n-body -0.2% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.2% 0.0% +0.0% +0.0% +0.0% para -0.2% 0.0% +0.0% -0.0% -0.0% paraffins -0.3% 0.0% +0.0% -0.0% -0.0% parser -0.2% 0.0% +0.0% +0.0% +0.0% parstof -0.2% 0.0% +0.8% +0.2% +0.2% pic -0.2% 0.0% +0.1% -0.1% -0.1% pidigits -0.3% 0.0% +0.0% +0.0% +0.0% power -0.2% 0.0% +0.0% -0.0% -0.0% pretty -0.3% 0.0% -0.0% -0.0% -0.1% primes -0.3% 0.0% +0.0% +0.0% -0.0% primetest -0.2% 0.0% +0.0% -0.0% -0.0% prolog -0.3% 0.0% +0.0% -0.0% -0.0% puzzle -0.3% 0.0% +0.0% +0.0% +0.0% queens -0.3% 0.0% +0.0% +0.0% +0.0% reptile -0.2% 0.0% +0.2% +0.1% +0.0% reverse-complem -0.3% 0.0% +0.0% +0.0% +0.0% rewrite -0.3% 0.0% +0.0% -0.0% -0.0% rfib -0.2% 0.0% +0.0% +0.0% -0.0% rsa -0.2% 0.0% +0.0% +0.0% +0.0% scc -0.3% 0.0% -0.0% -0.0% -0.1% sched -0.3% 0.0% +0.0% +0.0% +0.0% scs -0.2% 0.0% +0.1% +0.0% +0.0% simple -0.2% 0.0% +3.4% +1.0% +1.8% solid -0.2% 0.0% +0.0% +0.0% +0.0% sorting -0.3% 0.0% +0.0% +0.0% +0.0% spectral-norm -0.2% 0.0% -0.0% -0.0% -0.0% sphere -0.2% 0.0% +0.0% +0.0% +0.0% symalg -0.2% 0.0% +0.0% +0.0% +0.0% tak -0.3% 0.0% +0.0% +0.0% -0.0% transform -0.2% 0.0% +0.2% +0.1% +0.1% treejoin -0.3% 0.0% +0.2% -0.0% -0.1% typecheck -0.3% 0.0% +0.0% +0.0% +0.0% veritas -0.1% 0.0% +0.0% +0.0% +0.0% wang -0.2% 0.0% +0.0% -0.0% -0.0% wave4main -0.3% 0.0% +0.0% -0.0% -0.0% wheel-sieve1 -0.3% 0.0% +0.0% -0.0% -0.0% wheel-sieve2 -0.3% 0.0% +0.0% -0.0% -0.0% x2n1 -0.3% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min -0.3% 0.0% -0.0% -0.1% -0.2% Max -0.1% 0.0% +5.4% +1.0% +3.9% Geometric Mean -0.3% -0.0% +0.1% +0.0% +0.1% -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- circsim -0.2% 0.0% +1.6% +0.4% +0.7% constraints -0.3% 0.0% +4.3% +1.5% +2.3% fibheaps -0.3% 0.0% +3.5% +1.2% +1.3% fulsom -0.2% 0.0% +3.6% +1.2% +1.8% gc_bench -0.3% 0.0% +4.1% +1.3% +2.3% hash -0.3% 0.0% +6.6% +2.2% +3.6% lcss -0.3% 0.0% +0.7% +0.2% +0.7% mutstore1 -0.3% 0.0% +4.8% +1.4% +2.8% mutstore2 -0.3% 0.0% +3.4% +1.0% +1.7% power -0.2% 0.0% +2.7% +0.6% +1.9% spellcheck -0.3% 0.0% +1.1% +0.4% +0.4% -------------------------------------------------------------------------------- Min -0.3% 0.0% +0.7% +0.2% +0.4% Max -0.2% 0.0% +6.6% +2.2% +3.6% Geometric Mean -0.3% +0.0% +3.3% +1.0% +1.8% Metric changes -------------- While it sounds ridiculous, this change causes increased allocations in the following tests. We concluded that this change can't cause a difference in allocations and decided to land this patch. Fluctuations in "bytes allocated" metric is tracked in #17686. Metric Increase: Naperian T10547 T12150 T12234 T12425 T13035 T5837 T6048 - - - - - 8038cbd9 by Sebastian Graf at 2020-01-25T05:21:05-05:00 PmCheck: Formulate as translation between Clause Trees We used to check `GrdVec`s arising from multiple clauses and guards in isolation. That resulted in a split between `pmCheck` and `pmCheckGuards`, the implementations of which were similar, but subtly different in detail. Also the throttling mechanism described in `Note [Countering exponential blowup]` ultimately got quite complicated because it had to cater for both checking functions. This patch realises that pattern match checking doesn't just consider single guarded RHSs, but that it's always a whole set of clauses, each of which can have multiple guarded RHSs in turn. We do so by translating a list of `Match`es to a `GrdTree`: ```haskell data GrdTree = Rhs !RhsInfo | Guard !PmGrd !GrdTree -- captures lef-to-right match semantics | Sequence !GrdTree !GrdTree -- captures top-to-bottom match semantics | Empty -- For -XEmptyCase, neutral element of Sequence ``` Then we have a function `checkGrdTree` that matches a given `GrdTree` against an incoming set of values, represented by `Deltas`: ```haskell checkGrdTree :: GrdTree -> Deltas -> CheckResult ... ``` Throttling is isolated to the `Sequence` case and becomes as easy as one would expect: When the union of uncovered values becomes too big, just return the original incoming `Deltas` instead (which is always a superset of the union, thus a sound approximation). The returned `CheckResult` contains two things: 1. The set of values that were not covered by any of the clauses, for exhaustivity warnings. 2. The `AnnotatedTree` that enriches the syntactic structure of the input program with divergence and inaccessibility information. This is `AnnotatedTree`: ```haskell data AnnotatedTree = AccessibleRhs !RhsInfo | InaccessibleRhs !RhsInfo | MayDiverge !AnnotatedTree | SequenceAnn !AnnotatedTree !AnnotatedTree | EmptyAnn ``` Crucially, `MayDiverge` asserts that the tree may force diverging values, so not all of its wrapped clauses can be redundant. While the set of uncovered values can be used to generate the missing equations for warning messages, redundant and proper inaccessible equations can be extracted from `AnnotatedTree` by `redundantAndInaccessibleRhss`. For this to work properly, the interface to the Oracle had to change. There's only `addPmCts` now, which takes a bag of `PmCt`s. There's a whole bunch of `PmCt` variants to replace the different oracle functions from before. The new `AnnotatedTree` structure allows for more accurate warning reporting (as evidenced by a number of changes spread throughout GHC's code base), thus we fix #17465. Fixes #17646 on the go. Metric Decrease: T11822 T9233 PmSeriesS haddock.compiler - - - - - 86966d48 by Sebastian Graf at 2020-01-25T05:21:05-05:00 PmCheck: Properly handle constructor-bound type variables In https://gitlab.haskell.org/ghc/ghc/merge_requests/2192#note_246551 Simon convinced me that ignoring type variables existentially bound by data constructors have to be the same way as value binders. Sadly I couldn't think of a regression test, but I'm confident that this change strictly improves on the status quo. - - - - - c3fde723 by Ryan Scott at 2020-01-25T05:21:40-05:00 Handle local fixity declarations in DsMeta properly `DsMeta.rep_sig` used to skip over `FixSig` entirely, which had the effect of causing local fixity declarations to be dropped when quoted in Template Haskell. But there is no good reason for this state of affairs, as the code in `DsMeta.repFixD` (which handles top-level fixity declarations) handles local fixity declarations just fine. This patch factors out the necessary parts of `repFixD` so that they can be used in `rep_sig` as well. There was one minor complication: the fixity signatures for class methods in each `HsGroup` were stored both in `FixSig`s _and_ the list of `LFixitySig`s for top-level fixity signatures, so I needed to take action to prevent fixity signatures for class methods being converted to `Dec`s twice. I tweaked `RnSource.add` to avoid putting these fixity signatures in two places and added `Note [Top-level fixity signatures in an HsGroup]` in `GHC.Hs.Decls` to explain the new design. Fixes #17608. Bumps the Haddock submodule. - - - - - 6e2d9ee2 by Sylvain Henry at 2020-01-25T05:22:20-05:00 Module hierarchy: Cmm (cf #13009) - - - - - 8b726534 by PHO at 2020-01-25T05:23:01-05:00 Fix rts allocateExec() on NetBSD Similar to SELinux, NetBSD "PaX mprotect" prohibits marking a page mapping both writable and executable at the same time. Use libffi which knows how to work around it. - - - - - 6eb566a0 by Xavier Denis at 2020-01-25T05:23:39-05:00 Add ghc-in-ghci for stack based builds - - - - - b1a32170 by Xavier Denis at 2020-01-25T05:23:39-05:00 Create ghci.cabal.sh - - - - - 0a5e4f5f by Sylvain Henry at 2020-01-25T05:24:19-05:00 Split glasgow_exts into several files (#17316) - - - - - b3e5c678 by Ben Gamari at 2020-01-25T05:24:57-05:00 hadrian: Throw error on duplicate-named flavours Throw an error if the user requests a flavour for which there is more than one match. Fixes #17156. - - - - - 0940b59a by Ryan Scott at 2020-01-25T08:15:05-05:00 Do not bring visible foralls into scope in hsScopedTvs Previously, `hsScopedTvs` (and its cousin `hsWcScopedTvs`) pretended that visible dependent quantification could not possibly happen at the term level, and cemented that assumption with an `ASSERT`: ```hs hsScopedTvs (HsForAllTy { hst_fvf = vis_flag, ... }) = ASSERT( vis_flag == ForallInvis ) ... ``` It turns out that this assumption is wrong. You can end up tripping this `ASSERT` if you stick it to the man and write a type for a term that uses visible dependent quantification anyway, like in this example: ```hs {-# LANGUAGE ScopedTypeVariables #-} x :: forall a -> a -> a x = x ``` That won't typecheck, but that's not the point. Before the typechecker has a chance to reject this, the renamer will try to use `hsScopedTvs` to bring `a` into scope over the body of `x`, since `a` is quantified by a `forall`. This, in turn, causes the `ASSERT` to fail. Bummer. Instead of walking on this dangerous ground, this patch makes GHC adopt a more hardline stance by pattern-matching directly on `ForallInvis` in `hsScopedTvs`: ```hs hsScopedTvs (HsForAllTy { hst_fvf = ForallInvis, ... }) = ... ``` Now `a` will not be brought over the body of `x` at all (which is how it should be), there's no chance of the `ASSERT` failing anymore (as it's gone), and best of all, the behavior of `hsScopedTvs` does not change. Everyone wins! Fixes #17687. - - - - - 1132602f by Ryan Scott at 2020-01-27T10:03:42-05:00 Use splitLHs{ForAll,Sigma}TyInvis throughout the codebase Richard points out in #17688 that we use `splitLHsForAllTy` and `splitLHsSigmaTy` in places that we ought to be using the corresponding `-Invis` variants instead, identifying two bugs that are caused by this oversight: * Certain TH-quoted type signatures, such as those that appear in quoted `SPECIALISE` pragmas, silently turn visible `forall`s into invisible `forall`s. * When quoted, the type `forall a -> (a ~ a) => a` will turn into `forall a -> a` due to a bug in `DsMeta.repForall` that drops contexts that follow visible `forall`s. These are both ultimately caused by the fact that `splitLHsForAllTy` and `splitLHsSigmaTy` split apart visible `forall`s in addition to invisible ones. This patch cleans things up: * We now use `splitLHsForAllTyInvis` and `splitLHsSigmaTyInvis` throughout the codebase. Relatedly, the `splitLHsForAllTy` and `splitLHsSigmaTy` have been removed, as they are easy to misuse. * `DsMeta.repForall` now only handles invisible `forall`s to reduce the chance for confusion with visible `forall`s, which need to be handled differently. I also renamed it from `repForall` to `repForallT` to emphasize that its distinguishing characteristic is the fact that it desugars down to `L.H.TH.Syntax.ForallT`. Fixes #17688. - - - - - 97d0b0a3 by Matthew Pickering at 2020-01-27T10:04:19-05:00 Make Block.h compile with c++ compilers - - - - - 4bada77d by Tom Ellis at 2020-01-27T12:30:46-05:00 Disable two warnings for files that trigger them incomplete-uni-patterns and incomplete-record-updates will be in -Wall at a future date, so prepare for that by disabling those warnings on files that trigger them. - - - - - 0188404a by Tom Ellis at 2020-01-27T12:30:46-05:00 Add two warnings to stage 2 build - - - - - acae02c1 by Tom Ellis at 2020-01-27T12:30:46-05:00 Add two warnings to Hadrian - - - - - bf38a20e by Sylvain Henry at 2020-01-31T02:46:15-05:00 Call `interpretPackageEnv` from `setSessionDynFlags` interpretPackageEnv modifies the flags by reading the dreaded package environments. It is much less surprising to call it from `setSessionDynFlags` instead of reading package environments as a side-effect of `initPackages`. - - - - - 29c701c1 by Sylvain Henry at 2020-01-31T02:46:15-05:00 Refactor package related code The package terminology is a bit of a mess. Cabal packages contain components. Instances of these components when built with some flags/options/dependencies are called units. Units are registered into package databases and their metadata are called PackageConfig. GHC only knows about package databases containing units. It is a sad mismatch not fixed by this patch (we would have to rename parameters such as `package-id <unit-id>` which would affect users). This patch however fixes the following internal names: - Renames PackageConfig into UnitInfo. - Rename systemPackageConfig into globalPackageDatabase[Path] - Rename PkgConfXX into PkgDbXX - Rename pkgIdMap into unitIdMap - Rename ModuleToPkgDbAll into ModuleNameProvidersMap - Rename lookupPackage into lookupUnit - Add comments on DynFlags package related fields It also introduces a new `PackageDatabase` datatype instead of explicitly passing the following tuple: `(FilePath,[PackageConfig])`. The `pkgDatabase` field in `DynFlags` now contains the unit info for each unit of each package database exactly as they have been read from disk. Previously the command-line flag `-distrust-all-packages` would modify these unit info. Now this flag only affects the "dynamic" consolidated package state found in `pkgState` field. It makes sense because `initPackages` could be called first with this `distrust-all-packages` flag set and then again (using ghc-api) without and it should work (package databases are not read again from disk when `initPackages` is called the second time). Bump haddock submodule - - - - - 942c7148 by Ben Gamari at 2020-01-31T02:46:54-05:00 rename: Eliminate usage of mkVarOccUnique Replacing it with `newSysName`. Fixes #17061. - - - - - 41117d71 by Ben Gamari at 2020-01-31T02:47:31-05:00 base: Use one-shot kqueue on macOS The underlying reason requiring that one-shot usage be disabled (#13903) has been fixed. Closes #15768. - - - - - 01b15b83 by Ben Gamari at 2020-01-31T02:48:08-05:00 testsuite: Don't crash on encoding failure in print If the user doesn't use a Unicode locale then the testsuite driver would previously throw framework failures due to encoding failures. We now rather use the `replace` error-handling strategy. - - - - - c846618a by Ömer Sinan Ağacan at 2020-01-31T12:21:10+03:00 Do CafInfo/SRT analysis in Cmm This patch removes all CafInfo predictions and various hacks to preserve predicted CafInfos from the compiler and assigns final CafInfos to interface Ids after code generation. SRT analysis is extended to support static data, and Cmm generator is modified to allow generating static_link fields after SRT analysis. This also fixes `-fcatch-bottoms`, which introduces error calls in case expressions in CorePrep, which runs *after* CoreTidy (which is where we decide on CafInfos) and turns previously non-CAFFY things into CAFFY. Fixes #17648 Fixes #9718 Evaluation ========== NoFib ----- Boot with: `make boot mode=fast` Run: `make mode=fast EXTRA_RUNTEST_OPTS="-cachegrind" NoFibRuns=1` -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.0% 0.0% -0.0% -0.0% -0.0% CSD -0.0% 0.0% -0.0% -0.0% -0.0% FS -0.0% 0.0% -0.0% -0.0% -0.0% S -0.0% 0.0% -0.0% -0.0% -0.0% VS -0.0% 0.0% -0.0% -0.0% -0.0% VSD -0.0% 0.0% -0.0% -0.0% -0.5% VSM -0.0% 0.0% -0.0% -0.0% -0.0% anna -0.1% 0.0% -0.0% -0.0% -0.0% ansi -0.0% 0.0% -0.0% -0.0% -0.0% atom -0.0% 0.0% -0.0% -0.0% -0.0% awards -0.0% 0.0% -0.0% -0.0% -0.0% banner -0.0% 0.0% -0.0% -0.0% -0.0% bernouilli -0.0% 0.0% -0.0% -0.0% -0.0% binary-trees -0.0% 0.0% -0.0% -0.0% -0.0% boyer -0.0% 0.0% -0.0% -0.0% -0.0% boyer2 -0.0% 0.0% -0.0% -0.0% -0.0% bspt -0.0% 0.0% -0.0% -0.0% -0.0% cacheprof -0.0% 0.0% -0.0% -0.0% -0.0% calendar -0.0% 0.0% -0.0% -0.0% -0.0% cichelli -0.0% 0.0% -0.0% -0.0% -0.0% circsim -0.0% 0.0% -0.0% -0.0% -0.0% clausify -0.0% 0.0% -0.0% -0.0% -0.0% comp_lab_zift -0.0% 0.0% -0.0% -0.0% -0.0% compress -0.0% 0.0% -0.0% -0.0% -0.0% compress2 -0.0% 0.0% -0.0% -0.0% -0.0% constraints -0.0% 0.0% -0.0% -0.0% -0.0% cryptarithm1 -0.0% 0.0% -0.0% -0.0% -0.0% cryptarithm2 -0.0% 0.0% -0.0% -0.0% -0.0% cse -0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 -0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 -0.0% 0.0% -0.0% -0.0% -0.0% dom-lt -0.0% 0.0% -0.0% -0.0% -0.0% eliza -0.0% 0.0% -0.0% -0.0% -0.0% event -0.0% 0.0% -0.0% -0.0% -0.0% exact-reals -0.0% 0.0% -0.0% -0.0% -0.0% exp3_8 -0.0% 0.0% -0.0% -0.0% -0.0% expert -0.0% 0.0% -0.0% -0.0% -0.0% fannkuch-redux -0.0% 0.0% -0.0% -0.0% -0.0% fasta -0.0% 0.0% -0.0% -0.0% -0.0% fem -0.0% 0.0% -0.0% -0.0% -0.0% fft -0.0% 0.0% -0.0% -0.0% -0.0% fft2 -0.0% 0.0% -0.0% -0.0% -0.0% fibheaps -0.0% 0.0% -0.0% -0.0% -0.0% fish -0.0% 0.0% -0.0% -0.0% -0.0% fluid -0.1% 0.0% -0.0% -0.0% -0.0% fulsom -0.0% 0.0% -0.0% -0.0% -0.0% gamteb -0.0% 0.0% -0.0% -0.0% -0.0% gcd -0.0% 0.0% -0.0% -0.0% -0.0% gen_regexps -0.0% 0.0% -0.0% -0.0% -0.0% genfft -0.0% 0.0% -0.0% -0.0% -0.0% gg -0.0% 0.0% -0.0% -0.0% -0.0% grep -0.0% 0.0% -0.0% -0.0% -0.0% hidden -0.0% 0.0% -0.0% -0.0% -0.0% hpg -0.1% 0.0% -0.0% -0.0% -0.0% ida -0.0% 0.0% -0.0% -0.0% -0.0% infer -0.0% 0.0% -0.0% -0.0% -0.0% integer -0.0% 0.0% -0.0% -0.0% -0.0% integrate -0.0% 0.0% -0.0% -0.0% -0.0% k-nucleotide -0.0% 0.0% -0.0% -0.0% -0.0% kahan -0.0% 0.0% -0.0% -0.0% -0.0% knights -0.0% 0.0% -0.0% -0.0% -0.0% lambda -0.0% 0.0% -0.0% -0.0% -0.0% last-piece -0.0% 0.0% -0.0% -0.0% -0.0% lcss -0.0% 0.0% -0.0% -0.0% -0.0% life -0.0% 0.0% -0.0% -0.0% -0.0% lift -0.0% 0.0% -0.0% -0.0% -0.0% linear -0.1% 0.0% -0.0% -0.0% -0.0% listcompr -0.0% 0.0% -0.0% -0.0% -0.0% listcopy -0.0% 0.0% -0.0% -0.0% -0.0% maillist -0.0% 0.0% -0.0% -0.0% -0.0% mandel -0.0% 0.0% -0.0% -0.0% -0.0% mandel2 -0.0% 0.0% -0.0% -0.0% -0.0% mate -0.0% 0.0% -0.0% -0.0% -0.0% minimax -0.0% 0.0% -0.0% -0.0% -0.0% mkhprog -0.0% 0.0% -0.0% -0.0% -0.0% multiplier -0.0% 0.0% -0.0% -0.0% -0.0% n-body -0.0% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.0% 0.0% -0.0% -0.0% -0.0% para -0.0% 0.0% -0.0% -0.0% -0.0% paraffins -0.0% 0.0% -0.0% -0.0% -0.0% parser -0.1% 0.0% -0.0% -0.0% -0.0% parstof -0.1% 0.0% -0.0% -0.0% -0.0% pic -0.0% 0.0% -0.0% -0.0% -0.0% pidigits -0.0% 0.0% -0.0% -0.0% -0.0% power -0.0% 0.0% -0.0% -0.0% -0.0% pretty -0.0% 0.0% -0.3% -0.4% -0.4% primes -0.0% 0.0% -0.0% -0.0% -0.0% primetest -0.0% 0.0% -0.0% -0.0% -0.0% prolog -0.0% 0.0% -0.0% -0.0% -0.0% puzzle -0.0% 0.0% -0.0% -0.0% -0.0% queens -0.0% 0.0% -0.0% -0.0% -0.0% reptile -0.0% 0.0% -0.0% -0.0% -0.0% reverse-complem -0.0% 0.0% -0.0% -0.0% -0.0% rewrite -0.0% 0.0% -0.0% -0.0% -0.0% rfib -0.0% 0.0% -0.0% -0.0% -0.0% rsa -0.0% 0.0% -0.0% -0.0% -0.0% scc -0.0% 0.0% -0.3% -0.5% -0.4% sched -0.0% 0.0% -0.0% -0.0% -0.0% scs -0.0% 0.0% -0.0% -0.0% -0.0% simple -0.1% 0.0% -0.0% -0.0% -0.0% solid -0.0% 0.0% -0.0% -0.0% -0.0% sorting -0.0% 0.0% -0.0% -0.0% -0.0% spectral-norm -0.0% 0.0% -0.0% -0.0% -0.0% sphere -0.0% 0.0% -0.0% -0.0% -0.0% symalg -0.0% 0.0% -0.0% -0.0% -0.0% tak -0.0% 0.0% -0.0% -0.0% -0.0% transform -0.0% 0.0% -0.0% -0.0% -0.0% treejoin -0.0% 0.0% -0.0% -0.0% -0.0% typecheck -0.0% 0.0% -0.0% -0.0% -0.0% veritas -0.0% 0.0% -0.0% -0.0% -0.0% wang -0.0% 0.0% -0.0% -0.0% -0.0% wave4main -0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 -0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 -0.0% 0.0% -0.0% -0.0% -0.0% x2n1 -0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.3% -0.5% -0.5% Max -0.0% 0.0% -0.0% -0.0% -0.0% Geometric Mean -0.0% -0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- circsim -0.1% 0.0% -0.0% -0.0% -0.0% constraints -0.0% 0.0% -0.0% -0.0% -0.0% fibheaps -0.0% 0.0% -0.0% -0.0% -0.0% gc_bench -0.0% 0.0% -0.0% -0.0% -0.0% hash -0.0% 0.0% -0.0% -0.0% -0.0% lcss -0.0% 0.0% -0.0% -0.0% -0.0% power -0.0% 0.0% -0.0% -0.0% -0.0% spellcheck -0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.0% -0.0% -0.0% Max -0.0% 0.0% -0.0% -0.0% -0.0% Geometric Mean -0.0% +0.0% -0.0% -0.0% -0.0% Manual inspection of programs in testsuite/tests/programs --------------------------------------------------------- I built these programs with a bunch of dump flags and `-O` and compared STG, Cmm, and Asm dumps and file sizes. (Below the numbers in parenthesis show number of modules in the program) These programs have identical compiler (same .hi and .o sizes, STG, and Cmm and Asm dumps): - Queens (1), andre_monad (1), cholewo-eval (2), cvh_unboxing (3), andy_cherry (7), fun_insts (1), hs-boot (4), fast2haskell (2), jl_defaults (1), jq_readsPrec (1), jules_xref (1), jtod_circint (4), jules_xref2 (1), lennart_range (1), lex (1), life_space_leak (1), bargon-mangler-bug (7), record_upd (1), rittri (1), sanders_array (1), strict_anns (1), thurston-module-arith (2), okeefe_neural (1), joao-circular (6), 10queens (1) Programs with different compiler outputs: - jl_defaults (1): For some reason GHC HEAD marks a lot of top-level `[Int]` closures as CAFFY for no reason. With this patch we no longer make them CAFFY and generate less SRT entries. For some reason Main.o is slightly larger with this patch (1.3%) and the executable sizes are the same. (I'd expect both to be smaller) - launchbury (1): Same as jl_defaults: top-level `[Int]` closures marked as CAFFY for no reason. Similarly `Main.o` is 1.4% larger but the executable sizes are the same. - galois_raytrace (13): Differences are in the Parse module. There are a lot, but some of the changes are caused by the fact that for some reason (I think a bug) GHC HEAD marks the dictionary for `Functor Identity` as CAFFY. Parse.o is 0.4% larger, the executable size is the same. - north_array: We now generate less SRT entries because some of array primops used in this program like `NewArrayOp` get eliminated during Stg-to-Cmm and turn some CAFFY things into non-CAFFY. Main.o gets 24% larger (9224 bytes from 9000 bytes), executable sizes are the same. - seward-space-leak: Difference in this program is better shown by this smaller example: module Lib where data CDS = Case [CDS] [(Int, CDS)] | Call CDS CDS instance Eq CDS where Case sels1 rets1 == Case sels2 rets2 = sels1 == sels2 && rets1 == rets2 Call a1 b1 == Call a2 b2 = a1 == a2 && b1 == b2 _ == _ = False In this program GHC HEAD builds a new SRT for the recursive group of `(==)`, `(/=)` and the dictionary closure. Then `/=` points to `==` in its SRT field, and `==` uses the SRT object as its SRT. With this patch we use the closure for `/=` as the SRT and add `==` there. Then `/=` gets an empty SRT field and `==` points to `/=` in its SRT field. This change looks fine to me. Main.o gets 0.07% larger, executable sizes are identical. head.hackage ------------ head.hackage's CI script builds 428 packages from Hackage using this patch with no failures. Compiler performance -------------------- The compiler perf tests report that the compiler allocates slightly more (worst case observed so far is 4%). However most programs in the test suite are small, single file programs. To benchmark compiler performance on something more realistic I build Cabal (the library, 236 modules) with different optimisation levels. For the "max residency" row I run GHC with `+RTS -s -A100k -i0 -h` for more accurate numbers. Other rows are generated with just `-s`. (This is because `-i0` causes running GC much more frequently and as a result "bytes copied" gets inflated by more than 25x in some cases) * -O0 | | GHC HEAD | This MR | Diff | | --------------- | -------------- | -------------- | ------ | | Bytes allocated | 54,413,350,872 | 54,701,099,464 | +0.52% | | Bytes copied | 4,926,037,184 | 4,990,638,760 | +1.31% | | Max residency | 421,225,624 | 424,324,264 | +0.73% | * -O1 | | GHC HEAD | This MR | Diff | | --------------- | --------------- | --------------- | ------ | | Bytes allocated | 245,849,209,992 | 246,562,088,672 | +0.28% | | Bytes copied | 26,943,452,560 | 27,089,972,296 | +0.54% | | Max residency | 982,643,440 | 991,663,432 | +0.91% | * -O2 | | GHC HEAD | This MR | Diff | | --------------- | --------------- | --------------- | ------ | | Bytes allocated | 291,044,511,408 | 291,863,910,912 | +0.28% | | Bytes copied | 37,044,237,616 | 36,121,690,472 | -2.49% | | Max residency | 1,071,600,328 | 1,086,396,256 | +1.38% | Extra compiler allocations -------------------------- Runtime allocations of programs are as reported above (NoFib section). The compiler now allocates more than before. Main source of allocation in this patch compared to base commit is the new SRT algorithm (GHC.Cmm.Info.Build). Below is some of the extra work we do with this patch, numbers generated by profiled stage 2 compiler when building a pathological case (the test 'ManyConstructors') with '-O2': - We now sort the final STG for a module, which means traversing the entire program, generating free variable set for each top-level binding, doing SCC analysis, and re-ordering the program. In ManyConstructors this step allocates 97,889,952 bytes. - We now do SRT analysis on static data, which in a program like ManyConstructors causes analysing 10,000 bindings that we would previously just skip. This step allocates 70,898,352 bytes. - We now maintain an SRT map for the entire module as we compile Cmm groups: data ModuleSRTInfo = ModuleSRTInfo { ... , moduleSRTMap :: SRTMap } (SRTMap is just a strict Map from the 'containers' library) This map gets an entry for most bindings in a module (exceptions are THUNKs and CAFFY static functions). For ManyConstructors this map gets 50015 entries. - Once we're done with code generation we generate a NameSet from SRTMap for the non-CAFFY names in the current module. This set gets the same number of entries as the SRTMap. - Finally we update CafInfos in ModDetails for the non-CAFFY Ids, using the NameSet generated in the previous step. This usually does the least amount of allocation among the work listed here. Only place with this patch where we do less work in the CAF analysis in the tidying pass (CoreTidy). However that doesn't save us much, as the pass still needs to traverse the whole program and update IdInfos for other reasons. Only thing we don't here do is the `hasCafRefs` pass over the RHS of bindings, which is a stateless pass that returns a boolean value, so it doesn't allocate much. (Metric changes blow are all increased allocations) Metric changes -------------- Metric Increase: ManyAlternatives ManyConstructors T13035 T14683 T1969 T9961 - - - - - 2a87a565 by Andreas Klebinger at 2020-01-31T12:21:10+03:00 A few optimizations in STG and Cmm parts: (Guided by the profiler output) - Add a few bang patterns, INLINABLE annotations, and a seqList in a few places in Cmm and STG parts. - Do not add external variables as dependencies in STG dependency analysis (GHC.Stg.DepAnal). - - - - - bef704b6 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Improve skolemisation This patch avoids skolemiseUnboundMetaTyVar making up a fresh Name when it doesn't need to. See Note [Skolemising and identity] Improves error messsages for partial type signatures. - - - - - cd110423 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Improve pretty-printing for TyConBinders In particular, show their kinds. - - - - - 913287a0 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Fix scoping of TyCon binders in TcTyClsDecls This patch fixes #17566 by refactoring the way we decide the final identity of the tyvars in the TyCons of a possibly-recursive nest of type and class decls, possibly with associated types. It's all laid out in Note [Swizzling the tyvars before generaliseTcTyCon] Main changes: * We have to generalise each decl (with its associated types) all at once: TcTyClsDecls.generaliseTyClDecl * The main new work is done in TcTyClsDecls.swizzleTcTyConBndrs * The mysterious TcHsSyn.zonkRecTyVarBndrs dies altogether Other smaller things: * A little refactoring, moving bindTyClTyVars from tcTyClDecl1 to tcDataDefn, tcSynRhs, etc. Clearer, reduces the number of parameters * Reduce the amount of swizzling required. Specifically, bindExplicitTKBndrs_Q_Tv doesn't need to clone a new Name for the TyVarTv, and not cloning means that in the vasly common case, swizzleTyConBndrs is a no-op In detail: Rename newTyVarTyVar --> cloneTyVarTyVar Add newTyVarTyTyVar that doesn't clone Use the non-cloning newTyVarTyVar in bindExplicitTKBndrs_Q_Tv Rename newFlexiKindedTyVarTyVar --> cloneFlexiKindedTyVarTyVar * Define new utility function and use it HsDecls.familyDeclName :: FamilyDecl (GhcPass p) -> IdP (GhcPass p) Updates haddock submodule. - - - - - 58ed6c4a by Ben Gamari at 2020-02-01T02:29:23-05:00 rts/M32Alloc: Don't attempt to unmap non-existent pages The m32 allocator's `pages` list may contain NULLs in the case that the page was flushed. Some `munmap` implementations (e.g. FreeBSD's) don't like it if we pass them NULL. Don't do that. - - - - - 859db7d6 by Ömer Sinan Ağacan at 2020-02-01T14:18:49+03:00 Improve/fix -fcatch-bottoms documentation Old documentation suggests that -fcatch-bottoms only adds a default alternative to bottoming case expression, but that's not true. We use a very simplistic "is exhaustive" check and add default alternatives to any case expression that does not cover all constructors of the type. In case of GADTs this simple check assumes all constructors should be covered, even the ones ruled out by the type of the scrutinee. Update the documentation to reflect this. (Originally noticed in #17648) [ci skip] - - - - - 54dfa94a by John Ericson at 2020-02-03T21:14:24-05:00 Fix docs for FrontendResult Other variant was removed in ac1a379363618a6f2f17fff65ce9129164b6ef30 but docs were no changed. - - - - - 5e63d9c0 by John Ericson at 2020-02-03T21:15:02-05:00 Refactor HscMain.finish I found the old control flow a bit hard to follow; I rewrote it to first decide whether to desugar, and then use that choice when computing whether to simplify / what sort of interface file to write. I hope eventually we will always write post-tc interface files, which will make the logic of this function even simpler, and continue the thrust of this refactor. - - - - - e580e5b8 by Stefan Schulze Frielinghaus at 2020-02-04T09:29:00-05:00 Do not build StgCRunAsm.S for unregisterised builds For unregisterised builds StgRun/StgReturn are implemented via a mini interpreter in StgCRun.c and therefore would collide with the implementations in StgCRunAsm.S. - - - - - e3b0bd97 by Stefan Schulze Frielinghaus at 2020-02-04T09:29:00-05:00 fixup! fixup! Do not build StgCRunAsm.S for unregisterised builds - - - - - eb629fab by John Ericson at 2020-02-04T09:29:38-05:00 Delete some superfluous helper functions in HscMain The driver code is some of the nastiest in GHC, and I am worried about being able to untangle all the tech debt. In `HscMain` we have a number of helpers which are either not-used or little used. I delete them so we can reduce cognative load, distilling the essential complexity away from the cruft. - - - - - c90eca55 by Sebastian Graf at 2020-02-05T09:21:29-05:00 PmCheck: Record type constraints arising from existentials in `PmCoreCt`s In #17703 (a follow-up of !2192), we established that contrary to my belief, type constraints arising from existentials in code like ```hs data Ex where Ex :: a -> Ex f _ | let x = Ex @Int 15 = case x of Ex -> ... ``` are in fact useful. This commit makes a number of refactorings and improvements to comments, but fundamentally changes `addCoreCt.core_expr` to record the type constraint `a ~ Int` in addition to `x ~ Ex @a y` and `y ~ 15`. Fixes #17703. - - - - - 6d3b5d57 by Ömer Sinan Ağacan at 2020-02-05T09:22:10-05:00 testlib: Extend existing *_opts in extra_*_opts Previously we'd override the existing {run,hc} opts in extra_{run,hc}_opts, which caused flakiness in T1969, see #17712. extra_{run,hc}_opts now extends {run,hc} opts, instead of overriding. Also we shrank the allocation area for T1969 in order to increase residency sampling frequency. Fixes #17712 - - - - - 9c89a48d by Ömer Sinan Ağacan at 2020-02-05T09:22:52-05:00 Remove CafInfo-related code from STG lambda lift pass After c846618ae0 we don't have accurate CafInfos for Ids in the current module and we're free to introduce new CAFFY or non-CAFFY bindings or change CafInfos of existing binders; so no we no longer need to maintain CafInfos in Core or STG passes. - - - - - 70ddb8bf by Ryan Scott at 2020-02-05T09:23:30-05:00 Add regression test for #17773 - - - - - e8004e5d by Ben Gamari at 2020-02-05T13:55:19-05:00 gitlab-ci: Allow Windows builds to fail again Due to T7702 and the process issues described in #17777. - - - - - 29b72c00 by Ben Gamari at 2020-02-06T11:55:41-05:00 VarSet: Introduce nonDetFoldVarSet - - - - - c4e6b35d by Ben Gamari at 2020-02-06T11:55:41-05:00 Move closeOverKinds and friends to TyCoFVs - - - - - ed2f0e5c by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Reform the free variable finders for types This patch delivers on (much of) #17509. * Introduces the shallow vs deep free variable distinction * Introduce TyCoRep.foldType, foldType :: Monoid a => TyCoFolder env a -> env -> Type -> a and use it in the free variable finders. * Substitution in TyCoSubst * ASSERTs are on for checkValidSubst * checkValidSubst uses shallowTyCoVarsOfTypes etc Quite a few things still to do * We could use foldType in lots of other places * We could use mapType for substitution. (Check that we get good code!) * Some (but not yet all) clients of substitution can now save time by using shallowTyCoVarsOfTypes * All calls to tyCoVarsOfTypes should be inspected; most of them should be shallow. Maybe. * Currently shallowTyCoVarsOfTypes still returns unification variables, but not CoVarHoles. Reason: we need to return unification variables in some of the calls in TcSimplify, eg when promoting. * We should do the same thing for tyCoFVsOfTypes, which is currently unchanged. * tyCoFVsOfTypes returns CoVarHoles, because of the use in TcSimplify.mkResidualConstraints. See Note [Emitting the residual implication in simplifyInfer] * #17509 talks about "relevant" variables too. - - - - - 01a1f4fb by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for noFreeVarsOfType - - - - - 0e59afd6 by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Simplify closeOverKinds - - - - - 9ca5c88e by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for coVarsOfType - - - - - 5541b87c by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for exactTyCoVarsOfType This entailed * Adding a tcf_view field to TyCoFolder * Moving exactTyCoVarsOtType to TcType. It properly belongs there, since only the typechecker calls this function. But it also means that we can "see" and inline tcView. Metric Decrease: T14683 - - - - - 7c122851 by Simon Peyton Jones at 2020-02-06T11:56:02-05:00 Comments only - - - - - 588acb99 by Adam Sandberg Eriksson at 2020-02-08T10:15:38-05:00 slightly better named cost-centres for simple pattern bindings #17006 ``` main = do print $ g [1..100] a where g xs x = map (`mod` x) xs a :: Int = 324 ``` The above program previously attributed the cost of computing 324 to a cost centre named `(...)`, with this change the cost is attributed to `a` instead. This change only affects simple pattern bindings (decorated variables: type signatures, parens, ~ annotations and ! annotations). - - - - - 309f8cfd by Richard Eisenberg at 2020-02-08T10:16:33-05:00 Remove unnecessary parentheses - - - - - 7755ffc2 by Richard Eisenberg at 2020-02-08T10:16:33-05:00 Introduce IsPass; refactor wrappers. There are two main payloads of this patch: 1. This introduces IsPass, which allows e.g. printing code to ask what pass it is running in (Renamed vs Typechecked) and thus print extension fields. See Note [IsPass] in Hs.Extension 2. This moves the HsWrap constructor into an extension field, where it rightly belongs. This is done for HsExpr and HsCmd, but not for HsPat, which is left as an exercise for the reader. There is also some refactoring around SyntaxExprs, but this is really just incidental. This patch subsumes !1721 (sorry @chreekat). Along the way, there is a bit of refactoring in GHC.Hs.Extension, including the removal of NameOrRdrName in favor of NoGhcTc. This meant that we had no real need for GHC.Hs.PlaceHolder, so I got rid of it. Updates haddock submodule. ------------------------- Metric Decrease: haddock.compiler ------------------------- - - - - - 7d452be4 by Dylan Yudaken at 2020-02-08T10:17:17-05:00 Fix hs_try_putmvar losing track of running cap If hs_try_putmvar was called through an unsafe import, it would lose track of the running cap causing a deadlock - - - - - c2e301ae by Ben Gamari at 2020-02-08T10:17:55-05:00 compiler: Qualify imports of Data.List - - - - - aede171a by Ben Gamari at 2020-02-08T10:17:55-05:00 testsuite: Fix -Wcompat-unqualified-imports issues - - - - - 4435a8e0 by Ben Gamari at 2020-02-08T10:17:55-05:00 Introduce -Wcompat-unqualified-imports This implements the warning proposed in option (B) of the Data.List.singleton CLC [discussion][]. This warning, which is included in `-Wcompat` is intended to help users identify imports of modules that will change incompatibly in future GHC releases. This currently only includes `Data.List` due to the expected specialisation and addition of `Data.List.singleton`. Fixes #17244. [discussion]: https://groups.google.com/d/msg/haskell-core-libraries/q3zHLmzBa5E/PmlAs_kYAQAJ - - - - - 28b5349a by Ben Gamari at 2020-02-08T10:17:55-05:00 Bump stm and process submodules - - - - - 7d04b9f2 by Ben Gamari at 2020-02-08T10:18:31-05:00 hadrian: Allow override of Cabal configuration in hadrian.settings Fixes #17612 by adding a `cabal.configure.opts` key for `hadrian.settings`. - - - - - 88bf81aa by Andreas Klebinger at 2020-02-08T10:19:10-05:00 Optimize unpackCString# to allocate less. unpackCString# is a recursive function which for each iteration returns a Cons cell containing the current Char, and a thunk for unpacking the rest of the string. In this patch we change from storing addr + offset inside this thunk to storing only the addr, simply incrementing the address on each iteration. This saves one word of allocation per unpacked character. For a program like "main = print "<largishString>" this amounts to 2-3% fewer % in bytes allocated. I also removed the now redundant local unpack definitions. This removes one call per unpack operation. - - - - - bec76733 by Ben Gamari at 2020-02-08T10:19:57-05:00 Fix GhcThreaded setting This adopts a patch from NetBSD's packaging fixing the `GhcThreaded` option of the make build system. In addition we introduce a `ghcThreaded` option in hadrian's `Flavour` type. Also fix Hadrian's treatment of the `Use Threaded` entry in `settings`. Previously it would incorrectly claim `Use Threaded = True` if we were building the `threaded` runtime way. However, this is inconsistent with the `make` build system, which defines it to be whether the `ghc` executable is linked against the threaded runtime. Fixes #17692. - - - - - 545cf1e1 by Ben Gamari at 2020-02-08T10:20:37-05:00 hadrian: Depend upon libray dependencies when configuring packages This will hopefully fix #17631. - - - - - 047d3d75 by Ben Gamari at 2020-02-08T10:21:16-05:00 testsuite: Add test for #15316 This is the full testcase for T15316. - - - - - 768e5866 by Julien Debon at 2020-02-08T10:22:07-05:00 doc(Data.List): Add some examples to Data.List - - - - - 3900cb83 by Julien Debon at 2020-02-08T10:22:07-05:00 Apply suggestion to libraries/base/GHC/List.hs - - - - - bd666766 by Ben Gamari at 2020-02-08T10:22:45-05:00 users-guide: Clarify that bundled patsyns were introduced in GHC 8.0 Closes #17094. - - - - - 95741ea1 by Pepe Iborra at 2020-02-08T10:23:23-05:00 Update to hie-bios 0.3.2 style program cradle - - - - - fb5c1912 by Sylvain Henry at 2020-02-08T10:24:07-05:00 Remove redundant case This alternative is redundant and triggers no warning when building with 8.6.5 - - - - - 5d83d948 by Matthew Pickering at 2020-02-08T10:24:43-05:00 Add mkHieFileWithSource which doesn't read the source file from disk cc/ @pepeiborra - - - - - dfdae56d by Andreas Klebinger at 2020-02-08T10:25:20-05:00 Rename ghcAssert to stgAssert in hp2ps/Main.h. This fixes #17763 - - - - - 658f7ac6 by Ben Gamari at 2020-02-08T10:26:00-05:00 includes: Avoid using single-line comments in HsFFI.h While single-line comments are supported by C99, dtrace on SmartOS apparently doesn't support them yet. - - - - - c95920a6 by Ömer Sinan Ağacan at 2020-02-08T10:26:42-05:00 Import qualified Prelude in parser This is in preparation of backwards-incompatible changes in happy. See https://github.com/simonmar/happy/issues/166 - - - - - b6dc319a by Ömer Sinan Ağacan at 2020-02-08T10:27:23-05:00 Add regression test for #12760 The bug seems to be fixed in the meantime, make sure it stays fixed. Closes #12760 - - - - - b3857b62 by Ben Gamari at 2020-02-08T10:28:03-05:00 base: Drop out-of-date comment The comment in GHC.Base claimed that ($) couldn't be used in that module as it was wired-in. However, this is no longer true; ($) is merely known key and is defined in Haskell (with a RuntimeRep-polymorphic type) in GHC.Base. The one piece of magic that ($) retains is that it a special typing rule to allow type inference with higher-rank types (e.g. `runST $ blah`; see Note [Typing rule for ($)] in TcExpr). - - - - - 1183ae94 by Daniel Gröber at 2020-02-08T10:29:00-05:00 rts: Fix Arena blocks accounting for MBlock sized allocations When requesting more than BLOCKS_PER_MBLOCK blocks allocGroup can return a different number of blocks than requested. Here we use the number of requested blocks, however arenaFree will subtract the actual number of blocks we got from arena_blocks (possibly) resulting in a negative value and triggering ASSERT(arena_blocks >= 0). - - - - - 97d59db5 by Daniel Gröber at 2020-02-08T10:29:48-05:00 rts: Fix need_prealloc being reset when retainer profiling is on - - - - - 1f630025 by Krzysztof Gogolewski at 2020-02-09T02:52:27-05:00 Add a test for #15712 - - - - - 2ac784ab by Ben Gamari at 2020-02-09T02:53:05-05:00 hadrian: Add --test-metrics argument Allowing the test metric output to be captured to a file, a la the METRIC_FILE environment variable of the make build system. - - - - - f432d8c6 by Ben Gamari at 2020-02-09T02:53:05-05:00 hadrian: Fix --test-summary argument This appears to be a cut-and-paste error. - - - - - a906595f by Arnaud Spiwack at 2020-02-09T02:53:50-05:00 Fix an outdated note link This link appears to have been forgotten in 0dad81ca5fd1f63bf8a3b6ad09787559e8bd05c0 . - - - - - 3ae83da1 by Alp Mestanogullari at 2020-02-09T02:54:28-05:00 hadrian: Windows fixes (bindists, CI) This commit implements a few Windows-specific fixes which get us from a CI job that can't even get as far as starting the testsuite driver, to a state where we can run the entire testssuite (but have test failures to fix). - Don't forget about a potential extension for the haddock program, when preparing the bindist. - Build the timeout program, used by the testsuite driver on Windows in place of the Python script used elsewhere, using the boot compiler. We could alternatively build it with the compiler that we're going to test but this would be a lot more tedious to write. - Implement a wrapper-script less installation procedure for Windows, in `hadrian/bindist/Makefile. - Make dependencies a bit more accurate in the aforementioned Makefile. - Update Windows/Hadrian CI job accordingly. This patch fixes #17486. - - - - - 82f9be8c by Roland Senn at 2020-02-09T02:55:06-05:00 Fix #14628: Panic (No skolem Info) in GHCi This patch implements the [sugggestion from Simon (PJ)](https://gitlab.haskell.org/ghc/ghc/issues/14628#note_146559): - Make `TcErrors.getSkolemInfo` return a `SkolemInfo` rather than an `Implication`. - If `getSkolemInfo` gets `RuntimeUnk`s, just return a new data constructor in `SkolemInfo`, called `RuntimeUnkSkol`. - In `TcErrors.pprSkols` print something sensible for a `RuntimeUnkSkol`. The `getSkolemInfo` function paniced while formating suggestions to add type annotations (subfunction `suggestAddSig`) to a *"Couldn't match type ‘x’ with ‘y’"* error message. The `getSkolemInfo` function didn't find any Implication value and paniced. With this patch the `getSkolemInfo` function does no longer panic, if it finds `RuntimeUnkSkol`s. As the panic occured while processing an error message, we don't need to implement any new error message! - - - - - b2e18e26 by Andreas Klebinger at 2020-02-09T02:55:46-05:00 Fix -ddump-stg-final. Once again make sure this dumps the STG used for codegen. - - - - - 414e2f62 by Sylvain Henry at 2020-02-09T02:56:26-05:00 Force -fPIC for intree GMP (fix #17799) Configure intree GMP with `--with-pic` instead of patching it. Moreover the correct patching was only done for x86_64/darwin (see #17799). - - - - - f0fd72ee by Sebastian Graf at 2020-02-09T17:22:38-05:00 8.10 Release notes for improvements to the pattern-match checker [skip ci] A little late to the game, but better late than never. - - - - - 00dc0f7e by Ömer Sinan Ağacan at 2020-02-09T17:23:17-05:00 Add regression test for #13142 Closes #13142 - - - - - f3e737bb by Sebastian Graf at 2020-02-10T20:04:09-05:00 Fix long distance info for record updates For record updates where the `record_expr` is a variable, as in #17783: ```hs data PartialRec = No | Yes { a :: Int, b :: Bool } update No = No update r@(Yes {}) = r { b = False } ``` We should make use of long distance info in `-Wincomplete-record-updates` checking. But the call to `matchWrapper` in the `RecUpd` case didn't specify a scrutinee expression, which would correspond to the `record_expr` `r` here. That is fixed now. Fixes #17783. - - - - - 5670881d by Tamar Christina at 2020-02-10T20:05:04-05:00 Fs: Fix UNC remapping code. - - - - - 375b3c45 by Oleg Grenrus at 2020-02-11T05:07:30-05:00 Add singleton to Data.OldList - - - - - de32beff by Richard Eisenberg at 2020-02-11T05:08:10-05:00 Do not create nested quantified constraints Previously, we would accidentally make constraints like forall a. C a => forall b. D b => E a b c as we traversed superclasses. No longer! This patch also expands Note [Eagerly expand given superclasses] to work over quantified constraints; necessary for T16502b. Close #17202 and #16502. test cases: typecheck/should_compile/T{17202,16502{,b}} - - - - - e319570e by Ben Gamari at 2020-02-11T05:08:47-05:00 rts: Use nanosleep instead of usleep usleep was removed in POSIX.1-2008. - - - - - b75e7486 by Ben Gamari at 2020-02-11T05:09:24-05:00 rts: Remove incorrect assertions around MSG_THROWTO messages Previously we would assert that threads which are sending a `MSG_THROWTO` message must have their blocking status be blocked on the message. In the usual case of a thread throwing to another thread this is guaranteed by `stg_killThreadzh`. However, `throwToSelf`, used by the GC to kill threads which ran out of heap, failed to guarantee this. Noted while debugging #17785. - - - - - aba51b65 by Sylvain Henry at 2020-02-11T05:10:04-05:00 Add arithmetic exception primops (#14664) - - - - - b157399f by Ben Gamari at 2020-02-11T05:10:40-05:00 configure: Don't assume Gnu linker on Solaris Compl Yue noticed that the linker was dumping the link map on SmartOS. This is because Smartos uses the Solaris linker, which uses the `-64` flag, not `-m64` like Gnu ld, to indicate that it should link for 64-bits. Fix the configure script to handle the Solaris linker correctly. - - - - - d8d73d77 by Simon Peyton Jones at 2020-02-11T05:11:18-05:00 Notes only: telescopes This documentation-only patch fixes #17793 - - - - - 58a4ddef by Alp Mestanogullari at 2020-02-11T05:12:17-05:00 hadrian: build (and ship) iserv on Windows - - - - - 82023524 by Matthew Pickering at 2020-02-11T18:04:17-05:00 TemplateHaskellQuotes: Allow nested splices There is no issue with nested splices as they do not require any compile time code execution. All execution is delayed until the top-level splice. - - - - - 50e24edd by Ömer Sinan Ağacan at 2020-02-11T18:04:57-05:00 Remove Hadrian's copy of (Data.Functor.<&>) The function was added to base with base-4.11 (GHC 8.4) - - - - - f82a2f90 by Sylvain Henry at 2020-02-12T01:56:46-05:00 Document GMP build [skip ci] - - - - - da7f7479 by Sylvain Henry at 2020-02-12T01:57:27-05:00 Module hierarchy: ByteCode and Runtime (cf #13009) Update haddock submodule - - - - - 04f51297 by Ömer Sinan Ağacan at 2020-02-12T01:58:11-05:00 Fix naming of tests for #12923 - - - - - 31fc3321 by Ömer Sinan Ağacan at 2020-02-12T01:58:11-05:00 Add regression test for #12926 Closes #12926 - - - - - f0c0ee7d by Krzysztof Gogolewski at 2020-02-12T01:58:51-05:00 Fix order of arguments in specializer (#17801) See https://gitlab.haskell.org/ghc/ghc/issues/17801#note_253330 No regression test, as it's hard to trigger. - - - - - 059c3c9d by Sebastian Graf at 2020-02-12T11:00:58+01:00 Separate CPR analysis from the Demand analyser The reasons for that can be found in the wiki: https://gitlab.haskell.org/ghc/ghc/wikis/nested-cpr/split-off-cpr We now run CPR after demand analysis (except for after the final demand analysis run just before code gen). CPR got its own dump flags (`-ddump-cpr-anal`, `-ddump-cpr-signatures`), but not its own flag to activate/deactivate. It will run with `-fstrictness`/`-fworker-wrapper`. As explained on the wiki page, this step is necessary for a sane Nested CPR analysis. And it has quite positive impact on compiler performance: Metric Decrease: T9233 T9675 T9961 T15263 - - - - - f5ffd8d9 by Ben Gamari at 2020-02-12T17:22:37-05:00 base: Expose GHC.Unicode.unicodeVersion This exposes a Data.Version.Version representing the version of the Unicode database used by `base`. This should clear up some confusion I have seen in tickets regarding with which Unicode versions a given GHC can be expected to work. While in town I also regenerated (but did not update) the Unicode database with database 12.0.0. Strangely, the file cited in the README no longer existed. Consequently, I used https://www.unicode.org/Public/12.0.0/ucd/UnicodeData.txt and was slightly surprised to find that there were a few changes. - - - - - 6c2585e0 by Ben Gamari at 2020-02-12T17:22:37-05:00 base: Update Unicode database to 12.1.0 Using `curl https://www.unicode.org/Public/12.1.0/ucd/UnicodeData.txt | libraries/base/cbits/ubconfc 12.1.0`. - - - - - df084681 by Krzysztof Gogolewski at 2020-02-12T23:58:52+01:00 Always display inferred variables using braces We now always show "forall {a}. T" for inferred variables, previously this was controlled by -fprint-explicit-foralls. This implements part 1 of https://github.com/ghc-proposals/ghc-proposals/pull/179. Part of GHC ticket #16320. Furthermore, when printing a levity restriction error, we now display the HsWrap of the expression. This lets users see the full elaboration with -fprint-typechecker-elaboration (see also #17670) - - - - - 16d643cf by Sylvain Henry at 2020-02-13T09:16:04-05:00 Remove -ddump-srts flag This flag is deemed not useful. - - - - - fa28ae95 by Sylvain Henry at 2020-02-13T09:16:04-05:00 Fix flag documentation (#17826) - - - - - 1bfd8259 by Sylvain Henry at 2020-02-13T09:16:43-05:00 Ensure that Hadrian is built correctly before using it When Hadrian failed to build, the script would pick a previously built Hadrian (if available) instead of failing. - - - - - cd6e786a by Ömer Sinan Ağacan at 2020-02-14T05:29:56-05:00 Add test for #17648 - - - - - 9f2c3677 by Sylvain Henry at 2020-02-14T05:30:39-05:00 GMP expects the Target platform as --host parameter - - - - - aa6086fd by Oleg Grenrus at 2020-02-14T05:31:16-05:00 Add explicit LANGUAGE Safe to template-haskell (cherry picked from commit a5e0f376821ca882880b03b07b451aa574e289ec) - - - - - af6a0c36 by Ben Gamari at 2020-02-14T05:31:53-05:00 hadrian: Add execution and target architecture to stage-compilation figure - - - - - cf739945 by Sylvain Henry at 2020-02-14T05:32:37-05:00 Module hierarchy: HsToCore (cf #13009) - - - - - 719db318 by Simon Peyton Jones at 2020-02-14T05:33:16-05:00 De-duplicate overlapping Notes Documentation only. Fixes #17827 - - - - - 7550417a by Sylvain Henry at 2020-02-14T05:33:56-05:00 Hadrian: drop Sphinx flag checking for PDF documentation (#17825) It seems that Sphinx produces the ghc-flags.txt in doc/users_guide/_build rather than pdfRoot. We could copy ghc-flags.txt into pdfRoot (like happens naturally in the HTML case) but the benefit is pretty small. Let's just only check the HTML case. - - - - - 813842f4 by Ben Gamari at 2020-02-14T10:16:36-05:00 make: Be more selective in building windows-extra-src tarball - - - - - 0725f4bb by Ben Gamari at 2020-02-14T10:16:36-05:00 Rework handling of win32 toolchain tarballs - - - - - 565ce7ae by Ben Gamari at 2020-02-14T10:16:36-05:00 gitlab-ci: Consolidate CI logic This moves nearly all of the CI logic to .gitlab/ci.sh. This improves things in a number of ways: * it's harder for inconsistencies to arise between architectures * it's easier to share logic between architectures * on Windows, it's easier to ensure that all CI steps are executed from within a properly initialized mingw session. While in town I also add a FreeBSD build job and update the Windows job to use the gitlab-runner PowerShell executor, since cmd.exe will be deprecated soon (fixing #17699). - - - - - 9cbace74 by Ben Gamari at 2020-02-14T10:16:36-05:00 gitlab-ci: Deduplicate nightly job configuration - - - - - 6e837144 by Ben Gamari at 2020-02-14T10:16:36-05:00 integer-gmp: Fix unused command-line argument -L is only needed during linking. - - - - - e5ee07ab by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Don't ask sed to operate in-place on symlinks Some sed implementations (e.g. FreeBSD) refuse to operate in-place on symlinks. - - - - - 71e5e68f by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Disable tests that assume name of libstdc++ on FreeBSD - - - - - 7b2da0f4 by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Mark T6132 as broken on FreeBSD - - - - - 8ef7a15a by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite/T16930: Don't rely on gnu grep specific --include In BSD grep this flag only affects directory recursion. - - - - - 6060003e by Ben Gamari at 2020-02-14T10:16:36-05:00 Pass -Wno-unused-command-line-arguments during link on FreeBSD FreeBSD cc throws a warning if we pass -pthread without actually using any pthread symbols. - - - - - 97497bae by Ben Gamari at 2020-02-14T10:16:36-05:00 base: Always clamp reads/writes to 2GB in length Previously we did this only on Darwin due to #17414. However, even on other platforms >2GB writes are on shaky ground. POSIX explicitly says that the result is implementation-specified and Linux will write at most 0x7ffff000, even on 64-bit platforms. Moreover, getting the sign of the syscall result correct is tricky, as demonstrated by the fact that T17414 currently fails on FreeBSD. For simplicity we now just uniformly clamp to 0x7ffff000 on all platforms. - - - - - 49be2a3f by Ben Gamari at 2020-02-14T10:16:36-05:00 configure: Fix sphinx version test The check for the "v" prefix is redundant. - - - - - f7f7a556 by Ben Gamari at 2020-02-14T10:16:37-05:00 users-guide: Fix unknown link targets - - - - - a204102c by Ben Gamari at 2020-02-14T10:16:37-05:00 docs/compare-flags: Don't use python f-strings - - - - - 92e15a37 by Ben Gamari at 2020-02-14T10:16:37-05:00 gitlab-ci: Fix various shellcheck warnings - - - - - 459f7c6e by Ben Gamari at 2020-02-14T10:16:37-05:00 hadrian: Drop empty arguments from target list Fixes #17748. - - - - - c06df28d by Ben Gamari at 2020-02-14T10:16:37-05:00 users-guide: Fix "invalid file" failure I have no idea how this worked previously. Different Python version? - - - - - 3fe8444f by Ben Gamari at 2020-02-14T10:16:59-05:00 testsuite: Mark T7702 as fragile on Windows Due to #16799. There was previously an attempt to mark it as broken but the `opsys` name was incorrect. - - - - - fe02f781 by Ben Gamari at 2020-02-14T10:16:59-05:00 testsuite: Assert the opsys names are known Previously opsys would take any string. This meant it was very easy for a typo to silently render the predicate ineffective. Fix this by checking the given operating system name against a list of known values. - - - - - 149e2a3a by Ben Gamari at 2020-02-14T10:16:59-05:00 compare-flags: Don't rely on encoding flag of subprocess.check_output Apparently it isn't supported by some slightly older Python versions. - - - - - 798d59f6 by Ben Gamari at 2020-02-14T10:16:59-05:00 rts: Add more debug output to failed path in onIOComplete This will help track down #17035. - - - - - e35f3f98 by Ben Gamari at 2020-02-14T10:16:59-05:00 gitlab-ci: Allow i386 Windows builds to fail again Due to the resistance of #17736 to resolution. - - - - - 261a3cf8 by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Build integer-simple job in the validate flavour - - - - - b613a961 by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Always use mingw64 python on Windows - - - - - 1bc8c8cd by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Allow Windows build to fail due to #17777 The fact that `exec` isn't POSIX compliant means that things can break in arbitrarily bad ways. Sometimes things happen to work correctly but sadly this isn't always the case. - - - - - ac63020d by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Drop unnecessary GHC_VERSION check - - - - - 6926f369 by Ben Gamari at 2020-02-14T10:17:00-05:00 Bump process submodule Folds in the second part of Phyx's Windows process exit fixes [1], hopefully finally resolving issue #17480. [1] https://github.com/haskell/process/pull/160 - - - - - 584eee71 by Tamar Christina at 2020-02-14T10:17:00-05:00 SysTools: Use "process job" when spawning processes on Windows GHC should make calls using process jobs when calling out to GCC and LD. The reason is these use the exec () family of posix functions. Window's process model doesn't allow replacement of processes so this is emulated by creating a new process and immediately exiting the old one. Because of this when using normal Windows wait functions you would return even without the child process having finished. In this case if you are depending on data from the child you will enter a race condition. The usual fix for this is to use process jobs and wait for the termination of all children that have ever been spawn by the process you called. But also waiting for the freeing of all resources. - - - - - ecabfa28 by Tamar Christina at 2020-02-14T10:17:00-05:00 Revert "compiler: Disable atomic renaming on Windows" The original reason this was disabled should be fixed by the previous commit. This reverts commit 1c1b63d63efe8b0f789aa7d5b87cfac3edd213eb. - - - - - 06d60c66 by Ben Gamari at 2020-02-14T10:17:00-05:00 Bump Cabal submodule - - - - - 8cabb384 by Ben Gamari at 2020-02-14T10:17:00-05:00 compare-flags: Fix output - - - - - 8cf646d3 by Ben Gamari at 2020-02-14T10:17:00-05:00 users-guide: Document -ddump-srts - - - - - 932307a5 by Ben Gamari at 2020-02-14T10:17:00-05:00 users-guide: Fix broken reference - - - - - e77818de by Ben Gamari at 2020-02-15T09:26:55-05:00 Accept performance changes These manifested in the integer-simple job. Metric Decrease: T12227 T5549 T14936 T4830 Conversions T5237 T8766 T4801 T10359 Metric Increase: T12234 T6048 T3294 T14683 T3064 T9872b T9872c T783 T5837 T10678 T14697 T5631 T9203 T13719 T12707 T13056 T9630 T10547 T9872d T1969 WWRec T10370 T5321FD haddock.Cabal T5642 T9872a T15263 T12425 MultiLayerModules T5205 T9233 T13379 haddock.base T9020 T13035 T12150 T9961 - - - - - 785008c1 by Ben Gamari at 2020-02-15T09:30:13-05:00 testsuite: Sort test names in expected change output - - - - - 9e851472 by Ömer Sinan Ağacan at 2020-02-16T10:38:41+03:00 Revert "users-guide: Document -ddump-srts" This reverts commit 8cf646d36b02b8ea1c289cb52781c9171853b514. The flag was removed by 16d643cf. [ci skip] - - - - - 9792c816 by Ben Gamari at 2020-02-16T09:47:08-05:00 testsuite: Probe whether symlinks are usable on Windows Closes #17706. - - - - - ee1e5342 by Vladislav Zavialov at 2020-02-16T09:47:44-05:00 Fix the "unused terminals: 2" warning in Parser.y - - - - - b4a8ce52 by Roland Senn at 2020-02-18T20:14:42-05:00 If a :reload finds syntax errors in the module graph, remove the loaded modules. (Fixes #17549) The processing in `compiler/main/GhcMake.hs` computes the ModuleGraph. If it finds errors in the module header or in the import specifications, then the new module graph is incomplete and should not be used. The code before #17549 just reported the errors and left the old ModuleGraph in place. The new code of this MR replaces the old ModuleGraph with an empty one. - - - - - d7029cc0 by Sylvain Henry at 2020-02-18T20:15:30-05:00 Hadrian: refactor GMP in-tree build support (#17756) * Hadrian doesn't use integer-gmp/config.mk file anymore to determine if building GMP in-tree is required. "config.mk" is created by Cabal when the integer-gmp package is configured and this file is still untracked by Hadrian. This led to a tricky configure "race" because "config.mk" is built by the "setup-config" rule, but this rule is also used to find dependencies, in particular the "ghc-gmp.h" header, but the creation of this file was depending (without being tracked) on "config.mk". Now Hadrian only builds in-tree GMP if `--with-intree-gmp` is passed to the top-level configure script. * in-tree GMP isn't built once for all in a fixed stage (Stage1) anymore. It is built per stage which is required if we build a cross-compiler * switching between in-tree and external GMP is now supported without having to clean the build directory first. * "wrappers.c" now includes "ghc-gmp.h" instead of "ghc.h". It helps ensuring that the build system generates "ghc-gmp.h". * build in-tree GMP in "<root>/stageN/gmp/gmpbuild" and produce useful artefacts (libgmp.a, gmp.h, objs/*.o) in "<root>/stageN/gmp" - - - - - 40d917fb by Vladislav Zavialov at 2020-02-18T20:16:07-05:00 Remove the MonadFail P instance There were two issues with this instance: * its existence meant that a pattern match failure in the P monad would produce a user-visible parse error, but the error message would not be helpful to the user * due to the MFP migration strategy, we had to use CPP in Lexer.x, and that created issues for #17750 Updates haddock submodule. - - - - - 5a1ce45d by Joshua Price at 2020-02-18T20:16:47-05:00 Fix unboxed tuple size limit (#17837) - - - - - 192caf58 by Vladislav Zavialov at 2020-02-18T20:17:24-05:00 Fix testsuite driver output (#17847) - - - - - 1500f089 by Sylvain Henry at 2020-02-18T20:18:12-05:00 Modules: Llvm (#13009) - - - - - d53e81c0 by Niklas Hambüchen at 2020-02-20T10:36:22-05:00 8.10 Release notes for atomic .o writes [skip ci] - - - - - 19680ee5 by Niklas Hambüchen at 2020-02-20T10:37:53-05:00 8.10 Release notes for --disable-delayed-os-memory-return [skip ci] - - - - - 74ad75e8 by Simon Peyton Jones at 2020-02-20T21:17:57-05:00 Re-implement unsafe coercions in terms of unsafe equality proofs (Commit message written by Omer, most of the code is written by Simon and Richard) See Note [Implementing unsafeCoerce] for how unsafe equality proofs and the new unsafeCoerce# are implemented. New notes added: - [Checking for levity polymorphism] in CoreLint.hs - [Implementing unsafeCoerce] in base/Unsafe/Coerce.hs - [Patching magic definitions] in Desugar.hs - [Wiring in unsafeCoerce#] in Desugar.hs Only breaking change in this patch is unsafeCoerce# is not exported from GHC.Exts, instead of GHC.Prim. Fixes #17443 Fixes #16893 NoFib ----- -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.1% 0.0% -0.0% -0.0% -0.0% CSD -0.1% 0.0% -0.0% -0.0% -0.0% FS -0.1% 0.0% -0.0% -0.0% -0.0% S -0.1% 0.0% -0.0% -0.0% -0.0% VS -0.1% 0.0% -0.0% -0.0% -0.0% VSD -0.1% 0.0% -0.0% -0.0% -0.1% VSM -0.1% 0.0% -0.0% -0.0% -0.0% anna -0.0% 0.0% -0.0% -0.0% -0.0% ansi -0.1% 0.0% -0.0% -0.0% -0.0% atom -0.1% 0.0% -0.0% -0.0% -0.0% awards -0.1% 0.0% -0.0% -0.0% -0.0% banner -0.1% 0.0% -0.0% -0.0% -0.0% bernouilli -0.1% 0.0% -0.0% -0.0% -0.0% binary-trees -0.1% 0.0% -0.0% -0.0% -0.0% boyer -0.1% 0.0% -0.0% -0.0% -0.0% boyer2 -0.1% 0.0% -0.0% -0.0% -0.0% bspt -0.1% 0.0% -0.0% -0.0% -0.0% cacheprof -0.1% 0.0% -0.0% -0.0% -0.0% calendar -0.1% 0.0% -0.0% -0.0% -0.0% cichelli -0.1% 0.0% -0.0% -0.0% -0.0% circsim -0.1% 0.0% -0.0% -0.0% -0.0% clausify -0.1% 0.0% -0.0% -0.0% -0.0% comp_lab_zift -0.1% 0.0% -0.0% -0.0% -0.0% compress -0.1% 0.0% -0.0% -0.0% -0.0% compress2 -0.1% 0.0% -0.0% -0.0% -0.0% constraints -0.1% 0.0% -0.0% -0.0% -0.0% cryptarithm1 -0.1% 0.0% -0.0% -0.0% -0.0% cryptarithm2 -0.1% 0.0% -0.0% -0.0% -0.0% cse -0.1% 0.0% -0.0% -0.0% -0.0% digits-of-e1 -0.1% 0.0% -0.0% -0.0% -0.0% digits-of-e2 -0.1% 0.0% -0.0% -0.0% -0.0% dom-lt -0.1% 0.0% -0.0% -0.0% -0.0% eliza -0.1% 0.0% -0.0% -0.0% -0.0% event -0.1% 0.0% -0.0% -0.0% -0.0% exact-reals -0.1% 0.0% -0.0% -0.0% -0.0% exp3_8 -0.1% 0.0% -0.0% -0.0% -0.0% expert -0.1% 0.0% -0.0% -0.0% -0.0% fannkuch-redux -0.1% 0.0% -0.0% -0.0% -0.0% fasta -0.1% 0.0% -0.5% -0.3% -0.4% fem -0.1% 0.0% -0.0% -0.0% -0.0% fft -0.1% 0.0% -0.0% -0.0% -0.0% fft2 -0.1% 0.0% -0.0% -0.0% -0.0% fibheaps -0.1% 0.0% -0.0% -0.0% -0.0% fish -0.1% 0.0% -0.0% -0.0% -0.0% fluid -0.1% 0.0% -0.0% -0.0% -0.0% fulsom -0.1% 0.0% +0.0% +0.0% +0.0% gamteb -0.1% 0.0% -0.0% -0.0% -0.0% gcd -0.1% 0.0% -0.0% -0.0% -0.0% gen_regexps -0.1% 0.0% -0.0% -0.0% -0.0% genfft -0.1% 0.0% -0.0% -0.0% -0.0% gg -0.1% 0.0% -0.0% -0.0% -0.0% grep -0.1% 0.0% -0.0% -0.0% -0.0% hidden -0.1% 0.0% -0.0% -0.0% -0.0% hpg -0.1% 0.0% -0.0% -0.0% -0.0% ida -0.1% 0.0% -0.0% -0.0% -0.0% infer -0.1% 0.0% -0.0% -0.0% -0.0% integer -0.1% 0.0% -0.0% -0.0% -0.0% integrate -0.1% 0.0% -0.0% -0.0% -0.0% k-nucleotide -0.1% 0.0% -0.0% -0.0% -0.0% kahan -0.1% 0.0% -0.0% -0.0% -0.0% knights -0.1% 0.0% -0.0% -0.0% -0.0% lambda -0.1% 0.0% -0.0% -0.0% -0.0% last-piece -0.1% 0.0% -0.0% -0.0% -0.0% lcss -0.1% 0.0% -0.0% -0.0% -0.0% life -0.1% 0.0% -0.0% -0.0% -0.0% lift -0.1% 0.0% -0.0% -0.0% -0.0% linear -0.1% 0.0% -0.0% -0.0% -0.0% listcompr -0.1% 0.0% -0.0% -0.0% -0.0% listcopy -0.1% 0.0% -0.0% -0.0% -0.0% maillist -0.1% 0.0% -0.0% -0.0% -0.0% mandel -0.1% 0.0% -0.0% -0.0% -0.0% mandel2 -0.1% 0.0% -0.0% -0.0% -0.0% mate -0.1% 0.0% -0.0% -0.0% -0.0% minimax -0.1% 0.0% -0.0% -0.0% -0.0% mkhprog -0.1% 0.0% -0.0% -0.0% -0.0% multiplier -0.1% 0.0% -0.0% -0.0% -0.0% n-body -0.1% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.1% 0.0% -0.0% -0.0% -0.0% para -0.1% 0.0% -0.0% -0.0% -0.0% paraffins -0.1% 0.0% -0.0% -0.0% -0.0% parser -0.1% 0.0% -0.0% -0.0% -0.0% parstof -0.1% 0.0% -0.0% -0.0% -0.0% pic -0.1% 0.0% -0.0% -0.0% -0.0% pidigits -0.1% 0.0% -0.0% -0.0% -0.0% power -0.1% 0.0% -0.0% -0.0% -0.0% pretty -0.1% 0.0% -0.1% -0.1% -0.1% primes -0.1% 0.0% -0.0% -0.0% -0.0% primetest -0.1% 0.0% -0.0% -0.0% -0.0% prolog -0.1% 0.0% -0.0% -0.0% -0.0% puzzle -0.1% 0.0% -0.0% -0.0% -0.0% queens -0.1% 0.0% -0.0% -0.0% -0.0% reptile -0.1% 0.0% -0.0% -0.0% -0.0% reverse-complem -0.1% 0.0% -0.0% -0.0% -0.0% rewrite -0.1% 0.0% -0.0% -0.0% -0.0% rfib -0.1% 0.0% -0.0% -0.0% -0.0% rsa -0.1% 0.0% -0.0% -0.0% -0.0% scc -0.1% 0.0% -0.1% -0.1% -0.1% sched -0.1% 0.0% -0.0% -0.0% -0.0% scs -0.1% 0.0% -0.0% -0.0% -0.0% simple -0.1% 0.0% -0.0% -0.0% -0.0% solid -0.1% 0.0% -0.0% -0.0% -0.0% sorting -0.1% 0.0% -0.0% -0.0% -0.0% spectral-norm -0.1% 0.0% -0.0% -0.0% -0.0% sphere -0.1% 0.0% -0.0% -0.0% -0.0% symalg -0.1% 0.0% -0.0% -0.0% -0.0% tak -0.1% 0.0% -0.0% -0.0% -0.0% transform -0.1% 0.0% -0.0% -0.0% -0.0% treejoin -0.1% 0.0% -0.0% -0.0% -0.0% typecheck -0.1% 0.0% -0.0% -0.0% -0.0% veritas -0.0% 0.0% -0.0% -0.0% -0.0% wang -0.1% 0.0% -0.0% -0.0% -0.0% wave4main -0.1% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 -0.1% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 -0.1% 0.0% -0.0% -0.0% -0.0% x2n1 -0.1% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.5% -0.3% -0.4% Max -0.0% 0.0% +0.0% +0.0% +0.0% Geometric Mean -0.1% -0.0% -0.0% -0.0% -0.0% Test changes ------------ - break006 is marked as broken, see #17833 - The compiler allocates less when building T14683 (an unsafeCoerce#- heavy happy-generated code) on 64-platforms. Allocates more on 32-bit platforms. - Rest of the increases are tiny amounts (still enough to pass the threshold) in micro-benchmarks. I briefly looked at each one in a profiling build: most of the increased allocations seem to be because of random changes in the generated code. Metric Decrease: T14683 Metric Increase: T12150 T12234 T12425 T13035 T14683 T5837 T6048 Co-Authored-By: Richard Eisenberg <rae at cs.brynmawr.edu> Co-Authored-By: Ömer Sinan Ağacan <omeragacan at gmail.com> - - - - - 6880d6aa by Sylvain Henry at 2020-02-20T21:18:48-05:00 Disentangle DynFlags and SDoc Remove several uses of `sdocWithDynFlags`. The remaining ones are mostly CodeGen related (e.g. depend on target platform constants) and will be fixed separately. Metric Decrease: T12425 T9961 WWRec T1969 T14683 - - - - - 70a90110 by Julien Debon at 2020-02-20T21:19:27-05:00 doc(List): Add examples to GHC.List * Add examples * Cleanup documentation * Clarify merge process and Marge bot - - - - - c8439fc7 by Peter Trommler at 2020-02-20T21:20:05-05:00 Fix testsuite on powerpc64le Remove expect broken on recomp tests, #11260 was closed by !2264 and #11323 most likely by !2264 as well. GHCi scripts tests work on GHCi but not the external interpreter, adjust test configuration accordingly. Fixes unexpected passes. Mark test requiring DWARF expect fail on powerpc64[le] for #11261. - - - - - 65b7256a by Ömer Sinan Ağacan at 2020-02-20T21:20:45-05:00 Use concatMap(M) instead of `concat . map` and the monadic variant - - - - - 8b76d457 by Roland Senn at 2020-02-20T21:21:28-05:00 Fix #17832: Weird handling of exports named main in 8.10-rc1 Switching from `lookupGlobalOccRn_maybe` to `lookupInfoOccRn` to check whether a `main` function is in scope. Unfortunately `lookupGlobalOccRn_maybe` complains if there are multiple `main` functions in scope. - - - - - 466e1ad5 by Krzysztof Gogolewski at 2020-02-20T21:22:11-05:00 Use TTG for HsSplicedT constructor The constructor HsSplicedT occurs only in the GhcTc pass. This enforces this fact statically via TTG. - - - - - 4e622fca by Alexis King at 2020-02-20T21:22:49-05:00 Normalize types when dropping absent arguments from workers fixes #17852 - - - - - a533e547 by Adam Sandberg Eriksson at 2020-02-20T21:23:31-05:00 Mention users guide and release notes in merge request template - - - - - 05251b17 by Ben Gamari at 2020-02-20T21:24:08-05:00 gitlab-ci: Fix typo in BIN_DIST_PREP_TAR_COMP variable name - - - - - f44c7e67 by Ben Gamari at 2020-02-20T21:24:46-05:00 gitlab-ci: Avoid duplicating ~/.cabal contents with every build Previously our attempt to cache the cabal store would `cp cabal-cache ~/.cabal`. However, if the latter already existed this meant that we would end up with ~/.cabal/cabal-cache. Not only would this not help caching but it would exponentially grow the size of ~/.cabal. Not good! - - - - - c5ec9965 by Ben Gamari at 2020-02-20T21:56:13-05:00 GHC.Hs.Extension: Use Type instead of * - - - - - 89cb4cc4 by Ben Gamari at 2020-02-20T21:56:13-05:00 Use Type instead of * in GHC - - - - - 04eb0d6c by Ben Gamari at 2020-02-20T21:56:13-05:00 Enable -Wstar-is-type in -Wall As noted in [proposal 0143][proposal] this is supposed to happen in 8.12. Also fix an incorrect claim in the users guide that -Wstar-is-type is enabled by default. [proposal]: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0143-remove-star-kind.rst - - - - - 6de966f1 by Andreas Klebinger at 2020-02-20T21:56:15-05:00 Fix #17724 by having occAnal preserve used bindings. It sometimes happened that occAnal would remove bindings as dead code by relying on bindings to be in dependency order. The fix was contributed by SPJ. - - - - - abd7f962 by Ben Gamari at 2020-02-20T21:56:15-05:00 users-guide: Mention dependency on `exceptions` in release notes Fixes #17845. - - - - - 58175379 by Sylvain Henry at 2020-02-20T21:56:20-05:00 Hadrian: minor GMP refactoring Somehow I forgot to totally remove `gmpContext` in d7029cc09edc052c2f97effe33233c53340fcce0. This patch fixes it and adds some additional comments. - - - - - 33fa8d94 by Ryan Scott at 2020-02-20T21:56:21-05:00 Generalize liftData to work over any Quote (#17857) The Overloaded Quotations proposal generalized the type of `lift` to work over any `Quote`, but not the type of `liftData`, leading to #17857. Thankfully, generalizing `liftData` is extremely straightforward. Fixes #17857. - - - - - 3cea6795 by Sylvain Henry at 2020-02-20T21:56:23-05:00 Make: fix sdist target (#17848) - - - - - e2cce997 by Sylvain Henry at 2020-02-20T21:56:23-05:00 Hadrian: fix source-dist target (#17849) - - - - - 0a4c89b2 by Matthew Pickering at 2020-02-21T20:44:45-05:00 Special case `mkTyConApp liftedTypeKind []` We really need to make sure that these are shared because otherwise GHC will allocate thousands of identical `TyConApp` nodes. See #17292 ------------------------- Metric Decrease: haddock.Cabal T14683 ------------------------- - - - - - 0482f58a by Matthew Pickering at 2020-02-21T20:45:21-05:00 TH: wrapGenSyns, don't split the element type too much The invariant which allowed the pervious method of splitting the type of the body to find the type of the elements didn't work in the new overloaded quotation world as the type can be something like `WriterT () m a` rather than `Q a` like before. Fixes #17839 - - - - - be7068a6 by Vladislav Zavialov at 2020-02-21T20:45:59-05:00 Parser API annotations: RealSrcLoc During parsing, GHC collects lexical information about AST nodes and stores it in a map. It is needed to faithfully restore original source code, e.g. compare these expressions: a = b a = b The position of the equality sign is not recorded in the AST, so it must be stored elsewhere. This system is described in Note [Api annotations]. Before this patch, the mapping was represented by: Map (SrcSpan, AnnKeywordId) SrcSpan After this patch, the mapping is represented by: Map (RealSrcSpan, AnnKeywordId) RealSrcSpan The motivation behind this change is to avoid using the Ord SrcSpan instance (required by Map here), as it interferes with #17632 (see the discussion there). SrcSpan is isomorphic to Either String RealSrcSpan, but we shouldn't use those strings as Map keys. Those strings are intended as hints to the user, e.g. "<interactive>" or "<compiler-generated code>", so they are not a valid way to identify nodes in the source code. - - - - - 240f5bf6 by Sylvain Henry at 2020-02-21T20:46:40-05:00 Modules: Driver (#13009) submodule updates: nofib, haddock - - - - - 9d094111 by Sylvain Henry at 2020-02-21T20:47:19-05:00 Hadrian: `docs` rule needs `configure` (#17840) - - - - - 1674353a by Ben Gamari at 2020-02-23T17:31:19-05:00 fs: Port fixes from ghc-jailbreak repository * Override rename, unlink, and remove * Factor out wchar conversion - - - - - 853210f2 by Adam Sandberg Ericsson at 2020-02-23T17:32:03-05:00 show gcc linker options in configure summary - - - - - 2831544a by Adam Sandberg Ericsson at 2020-02-23T17:32:44-05:00 hadrian: docs depend on stage1 ghc - - - - - 1d9df9e0 by Adam Sandberg Ericsson at 2020-02-23T17:33:23-05:00 ci: after 5ce63d52fed the linux bindist for doc-tarball has changed name - - - - - 26e8fff3 by Vladislav Zavialov at 2020-02-24T02:05:30-05:00 Remove Ord SrcLoc, Ord SrcSpan Before this patch, GHC relied on Ord SrcSpan to identify source elements, by using SrcSpan as Map keys: blackList :: Map SrcSpan () -- compiler/GHC/HsToCore/Coverage.hs instanceMap :: Map SrcSpan Name -- compiler/GHC/HsToCore/Docs.hs Firstly, this design is not valid in presence of UnhelpfulSpan, as it distinguishes between UnhelpfulSpan "X" and UnhelpfulSpan "Y", but those strings are messages for the user, unfit to serve as identifiers for source elements. Secondly, this design made it hard to extend SrcSpan with additional data. Recall that the definition of SrcSpan is: data SrcSpan = RealSrcSpan !RealSrcSpan | UnhelpfulSpan !FastString Say we want to extend the RealSrcSpan constructor with additional information: data SrcSpan = RealSrcSpan !RealSrcSpan !AdditionalInformation | UnhelpfulSpan !FastString getAdditionalInformation :: SrcSpan -> AdditionalInformation getAdditionalInformation (RealSrcSpan _ a) = a Now, in order for Map SrcSpan to keep working correctly, we must *ignore* additional information when comparing SrcSpan values: instance Ord SrcSpan where compare (RealSrcSpan r1 _) (RealSrcSpan r2 _) = compare r1 r2 ... However, this would violate an important law: a == b therefore f a == f b Ignoring AdditionalInformation in comparisons would mean that with f=getAdditionalInformation, the law above does not hold. A more robust design is to avoid Ord SrcSpan altogether, which is what this patch implements. The mappings are changed to use RealSrcSpan instead: blackList :: Set RealSrcSpan -- compiler/GHC/HsToCore/Coverage.hs instanceMap :: Map RealSrcSpan Name -- compiler/GHC/HsToCore/Docs.hs All SrcSpan comparisons are now done with explicit comparison strategies: SrcLoc.leftmost_smallest SrcLoc.leftmost_largest SrcLoc.rightmost_smallest These strategies are not subject to the law mentioned above and can easily discard both the string stored in UnhelpfulSpan and AdditionalInformation. Updates haddock submodule. - - - - - 5aa6c188 by Ben Gamari at 2020-02-24T02:06:09-05:00 users-guide: Shuffle text - - - - - e3f17413 by Ben Gamari at 2020-02-24T02:06:09-05:00 users-guide: Drop old release notes - - - - - 84dd9610 by Ben Gamari at 2020-02-24T02:06:09-05:00 Bump directory submodule to 1.3.6.0 - - - - - e295a024 by Stefan Pavikevik at 2020-02-24T20:53:44-05:00 check for safe arguments, raising error when invalid (fix #17720) - - - - - 354e2787 by Krzysztof Gogolewski at 2020-02-24T20:54:35-05:00 Comments, small refactor * Remove outdated Note [HsForAllTy tyvar binders] and [Context quantification]. Since the wildcard refactor 1e041b7382, HsForAllTy no longer has an flag controlling explicity. The field `hsq_implicit` is gone too. The current situation is covered by Note [HsType binders] which is already linked from LHsQTyVars. * Small refactor in CoreLint, extracting common code to a function * Remove "not so sure about WpFun" in TcEvidence, per Richard's comment https://gitlab.haskell.org/ghc/ghc/merge_requests/852#note_223226 * Use mkIfThenElse in Foreign/Call, as it does exactly what we need. - - - - - 1b1067d1 by Sylvain Henry at 2020-02-24T20:55:25-05:00 Modules: CmmToAsm (#13009) - - - - - 621468f6 by Alexis King at 2020-02-26T15:08:09-05:00 Treat coercions as arguments for floating and inlining This reverts commit 8924224ecfa065ebc67b96a90d01cf9d2edd0e77 and fixes #17787. - - - - - def486c9 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Allow libnuma library path to be specified - - - - - ed03d4e7 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Refactor gmp arguments Move the gmp configuration to its own binding. - - - - - 09b88384 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Tell Cabal about integer-gmp library location - - - - - 161e08c5 by Krzysztof Gogolewski at 2020-02-26T15:09:30-05:00 Remove dead code * FailablePattern can no longer be created since ab51bee40c82 Therefore, Opt_WarnMissingMonadFailInstances has no effect anymore. * XWrap is no longer used, it was moved to an extension field - - - - - e0d09db3 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Use 8.8.3 to bootstrap on Windows This should fix #17861. - - - - - 972bcf3a by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Fix symlink test Needs to `write` bytes, not str. - - - - - 273e60de by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Add shell subcommand for debugging within CI environment - - - - - 43b13ed3 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Fix colors on Darwin Darwin sh doesn't support \e. - - - - - 217546a7 by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Flush stdout buffers in InitEventLogging Otherwise we are sensitive to libc's buffering strategy. Similar to the issue fixed in 543dfaab166c81f46ac4af76918ce32190aaab22. - - - - - c7d4fa55 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Add run_hadrian subcommand I've ruined two trees already by failing to pass --flavour to hadrian. Let's factor this out so it can be reused during troubleshooting. - - - - - 7dc54873 by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Allow tests to be marked as broken on the command line This allows us to work-around distribution-specific breakage easily. - - - - - 25e2458e by Ben Gamari at 2020-02-26T15:10:09-05:00 hadrian: Add --broken-test flag This exposes the flag of the same name supported by the testsuite driver. - - - - - 55769996 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Mark some tests as broken on Alpine - - - - - 9ee7f87d by Ben Gamari at 2020-02-26T15:10:09-05:00 SysTools: Don't use process jobs if they are broken - - - - - bfaa3961 by Ben Gamari at 2020-02-26T15:10:09-05:00 Bump hsc2hs submodule Fixes name of C compiler. - - - - - b2b49a0a by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Make hasMetricsFile RHS more descriptive - - - - - 817f93ea by Sylvain Henry at 2020-02-26T15:10:58-05:00 Modules: Core (#13009) Update haddock submodule - - - - - 74311e10 by Sebastian Graf at 2020-02-27T16:22:45-05:00 PmCheck: Implement Long-distance information with Covered sets Consider ```hs data T = A | B | C f :: T -> Int f A = 1 f x = case x of A -> 2 B -> 3 C -> 4 ``` Clearly, the RHS returning 2 is redundant. But we don't currently see that, because our approximation to the covered set of the inner case expression just picks up the positive information from surrounding pattern matches. It lacks the context sensivity that `x` can't be `A` anymore! Therefore, we adopt the conceptually and practically superior approach of reusing the covered set of a particular GRHS from an outer pattern match. In this case, we begin checking the `case` expression with the covered set of `f`s second clause, which encodes the information that `x` can't be `A` anymore. After this MR, we will successfully warn about the RHS returning 2 being redundant. Perhaps surprisingly, this was a great simplification to the code of both the coverage checker and the desugarer. Found a redundant case alternative in `unix` submodule, so we have to bump it with a fix. Metric Decrease: T12227 - - - - - 59c023ba by Adam Sandberg Ericsson at 2020-02-27T16:23:25-05:00 configure: correctly generate LIBRARY_template_haskell_VERSION - - - - - 9be82389 by Krzysztof Gogolewski at 2020-02-28T02:35:35-05:00 boot: Remove remote origin check Previously, we used relative paths in submodules. When cloning from GitHub, they had to be manually tweaked. Since a76b233d we use absolute paths, so this workaround can be removed. - - - - - f4b6b594 by Ben Gamari at 2020-02-28T02:36:12-05:00 nonmoving: Fix marking in compact regions Previously we were tracing the object we were asked to mark, even if it lives in a compact region. However, there is no need to do this; we need only to mark the region itself as live. I have seen a segfault due to this due to the concurrent mark seeing a an object in the process of being compacted by the mutator. - - - - - f97d1fb6 by Alp Mestanogullari at 2020-02-28T02:36:59-05:00 base: use an explicit import list in System.Environment.ExecutablePath This was making -Werror builds fail on Windows (at least with Hadrian). - - - - - 66f5d6d6 by Simon Peyton Jones at 2020-02-28T22:03:23-05:00 Improve error handling for VTA + deferred type errors This fixes #17792 See Note [VTA for out-of-scope functions] in TcExpr - - - - - 37f12603 by Ilias Tsitsimpis at 2020-02-28T22:04:04-05:00 llvm-targets: Add arm-unknown-linux-gnueabi Add arm-unknown-linux-gnueabi, which is used by Debian's ARM EABI port (armel), as an LLVM target. - - - - - 327b29e1 by Vladislav Zavialov at 2020-02-29T05:06:31-05:00 Monotonic locations (#17632) When GHC is parsing a file generated by a tool, e.g. by the C preprocessor, the tool may insert #line pragmas to adjust the locations reported to the user. As the result, the locations recorded in RealSrcLoc are not monotonic. Elements that appear later in the StringBuffer are not guaranteed to have a higher line/column number. In fact, there are no guarantees whatsoever, as #line pragmas can arbitrarily modify locations. This lack of guarantees makes ideas such as #17544 infeasible. This patch adds an additional bit of information to every SrcLoc: newtype BufPos = BufPos { bufPos :: Int } A BufPos represents the location in the StringBuffer, unaffected by any pragmas. Updates haddock submodule. Metric Increase: haddock.Cabal haddock.base haddock.compiler MultiLayerModules Naperian parsing001 T12150 - - - - - 99d2de86 by Ben Gamari at 2020-02-29T05:07:10-05:00 plugins: Ensure that loadInterface plugins can see annotations loadInterface replaces the `mi_decls`, `mi_insts`, `mi_fam_insts`, `mi_rules`, `mi_anns` fields of ModIface with `undefined` before inserting the interface into the EPS. However, we still want to give loadInterface plugins access to these fields. Consequently, we want to pass the unmodified `ModIface` the plugin. - - - - - a999ee96 by Xavier Denis at 2020-02-29T05:07:50-05:00 Rename ghci.sh and build.sh to ghci and build respectively Convert hadrian buildscripts to unsuffixed, dashed form final cleanups - - - - - b5fb58fd by Ömer Sinan Ağacan at 2020-02-29T05:08:36-05:00 Document and refactor a few things around bitmap scavenging - Added a few comments in StgPAP - Added a few comments and assertions in scavenge_small_bitmap and walk_large_bitmap - Did tiny refactor in GHC.Data.Bitmap: added some comments, deleted dead code, used PlatformWordSize type. - - - - - 18757cab by Sylvain Henry at 2020-02-29T05:09:25-05:00 Refactor runtime interpreter code In #14335 we want to be able to use both the internal interpreter (for the plugins) and the external interpreter (for TH and GHCi) at the same time. This patch performs some preliminary refactoring: the `hsc_interp` field of HscEnv replaces `hsc_iserv` and is now used to indicate which interpreter (internal, external) to use to execute TH and GHCi. Opt_ExternalInterpreter flag and iserv options in DynFlags are now queried only when we set the session DynFlags. It should help making GHC multi-target in the future by selecting an interpreter according to the selected target. - - - - - b86a6395 by Adam Sandberg Ericsson at 2020-02-29T05:10:06-05:00 docs: correct relative links to haddocks from users guide (fixes #17866) - - - - - 0f55df7f by Adam Sandberg Ericsson at 2020-02-29T05:10:06-05:00 docs: correct link to th haddocks from users guide - - - - - 252e5117 by Jean-Baptiste Mazon at 2020-02-29T05:10:46-05:00 rts: enforce POSIX numeric locale for heap profiles - - - - - 34c7d230 by Sylvain Henry at 2020-02-29T05:11:27-05:00 Fix Hadrian's ``--configure`` (fix #17883) - - - - - 04d30137 by Ömer Sinan Ağacan at 2020-02-29T05:12:06-05:00 Simplify IfaceIdInfo type IfaceIdInfo type is confusing: there's practically no difference between `NoInfo` and `HasInfo []`. The comments say NoInfo is used when -fomit-interface-pragmas is enabled, but we don't need to distinguish `NoInfo` from `HasInfo []` in when reading the interface so the distinction is not important. This patch simplifies the type by removing NoInfo. When we have no info we use an empty list. With this change we no longer read the info list lazily when reading an IfaceInfoItem, but when reading an IfaceId the ifIdInfo field is read lazily, so I doubt this is going to be a problem. - - - - - 3979485b by Roland Senn at 2020-02-29T17:36:59+01:00 Show breakpoint locations of breakpoints which were ignored during :force (#2950) GHCi is split up into 2 major parts: The user-interface (UI) and the byte-code interpreter. With `-fexternal-interpreter` they even run in different processes. Communication between the UI and the Interpreter (called `iserv`) is done using messages over a pipe. This is called `Remote GHCI` and explained in the Note [Remote GHCi] in `compiler/ghci/GHCi.hs`. To process a `:force` command the UI sends a `Seq` message to the `iserv` process. Then `iserv` does the effective evaluation of the value. When during this process a breakpoint is hit, the `iserv` process has no additional information to enhance the `Ignoring breakpoint` output with the breakpoint location. To be able to print additional breakpoint information, there are 2 possible implementation choices: 1. Store the needed information in the `iserv` process. 2. Print the `Ignoring breakpoint` from the UI process. For option 1 we need to store the breakpoint info redundantely in 2 places and this is bad. Therfore option 2 was implemented in this MR: - The user enters a `force` command - The UI sends a `Seq` message to the `iserv` process. - If processing of the `Seq` message hits a breakpoint, the `iserv` process returns control to the UI process. - The UI looks up the source location of the breakpoint, and prints the enhanced `Ignoring breakpoint` output. - The UI sends a `ResumeSeq` message to the `iserv` process, to continue forcing. - - - - - 3cf7303b by Krzysztof Gogolewski at 2020-03-02T01:18:33-05:00 Remove dead code * The names in PrelName and THNames are no longer used since TH merged types and kinds, Typeable is kind-polymorphic, .net support was removed * unqualQuasiQuote no longer used since 6f8ff0bbad3b9fa3 - - - - - dbea7e9d by Ilias Tsitsimpis at 2020-03-02T01:19:12-05:00 Do not define hs_atomic{read,write}64() on non-64bit Do not define hs_atomicread64() and hs_atomicwrite64() on machines where WORD_SIZE_IN_BITS is less than 64, just like we do with the rest of the atomic functions which work on 64-bit values. Without this, compilation fails on MIPSel and PowerPC with the following error: /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicread64': atomic.c:(.text.hs_atomicread64+0x8): undefined reference to `__sync_add_and_fetch_8' /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicwrite64': atomic.c:(.text.hs_atomicwrite64+0x38): undefined reference to `__sync_bool_compare_and_swap_8' Fixes #17886. - - - - - 7c0c76fb by Roland Senn at 2020-03-02T17:13:55-05:00 Set `ImpredicativeTypes` during :print command. (#14828) If ImpredicativeTypes is not enabled, then `:print <term>` will fail if the type of <term> has nested `forall`s or `=>`s. This is because the GHCi debugger's internals will attempt to unify a metavariable with the type of <term> and then display the result, but if the type has nested `forall`s or `=>`s, then unification will fail. As a result, `:print` will bail out and the unhelpful result will be `<term> = (_t1::t1)` (where `t1` is a metavariable). Beware: <term> can have nested `forall`s even if its definition doesn't use RankNTypes! Here is an example from #14828: class Functor f where fmap :: (a -> b) -> f a -> f b Somewhat surprisingly, `:print fmap` considers the type of fmap to have nested foralls. This is because the GHCi debugger sees the type `fmap :: forall f. Functor f => forall a b. (a -> b) -> f a -> f b`. We could envision deeply instantiating this type to get the type `forall f a b. Functor f => (a -> b) -> f a -> f b`, but this trick wouldn't work for higher-rank types. Instead, we adopt a simpler fix: enable `ImpredicativeTypes` when using `:print` and friends in the GHCi debugger. This is allows metavariables to unify with types that have nested (or higher-rank) `forall`s/`=>`s, which makes `:print fmap` display as `fmap = (_t1::forall a b. Functor f => (a -> b) -> f a -> f b)`, as expected. Although ImpredicativeTypes is a somewhat unpredictable from a type inference perspective, there is no danger in using it in the GHCi debugger, since all of the terms that the GHCi debugger deals with have already been typechecked. - - - - - 2a2f51d7 by Sylvain Henry at 2020-03-02T17:14:38-05:00 Use configure script to detect that we should use in-tree GMP on Windows - - - - - 8c663c2c by Andreas Klebinger at 2020-03-04T16:12:14+01:00 Be explicit about how stack usage of mvar primops are covered. This fixes #17893 [skip-ci] - - - - - cedd6f30 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Add getCurrentThreadCPUTime helper - - - - - ace618cd by Ben Gamari at 2020-03-05T14:53:12-05:00 nonmoving-gc: Track time usage of nonmoving marking - - - - - 022b5ad5 by Ben Gamari at 2020-03-05T14:53:12-05:00 Stats: Add sync pauses to +RTS -S output - - - - - 06763234 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Report nonmoving collector statistics in machine-readable output - - - - - 70d2b995 by Ben Gamari at 2020-03-09T06:10:52-04:00 nonmoving: Fix collection of sparks Previously sparks living in the non-moving heap would be promptly GC'd by the minor collector since pruneSparkQueue uses the BF_EVACUATED flag, which non-moving heap blocks do not have set. Fix this by implementing proper support in pruneSparkQueue for determining reachability in the non-moving heap. The story is told in Note [Spark management in the nonmoving heap]. - - - - - 9668781a by Ben Gamari at 2020-03-09T06:11:30-04:00 gitlab-ci: Disable Sphinx documentation in Alpine build - - - - - 8eb2c263 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 Fix Windows breakage by not touching locales on Windows - - - - - b8dab057 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: ensure C numerics in heap profiles using Windows locales if needed - - - - - 7d95260f by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: refactor and comment profile locales - - - - - 5b627813 by Ryan Scott at 2020-03-09T16:34:14-04:00 Use InstanceSigs in GND/DerivingVia-generated code (#17899) Aside from making the generated code easier to read when `-ddump-deriv` is enabled, this makes the error message in `T15073` substantially simpler (see the updated `T15073` expected stderr). Fixes #17899. - - - - - 70b50778 by Ben Gamari at 2020-03-10T02:05:42-04:00 SysTools: Ensure that error parser can handle absolute paths on Windows This fixes #17786, where the error parser fails to correctly handle the drive name in absolute Windows paths. Unfortunately I couldn't find a satisfactory way to test this. - - - - - 85b861d8 by Ben Gamari at 2020-03-10T02:05:42-04:00 testsuite: Add test for #17786 This isn't pretty but it's perhaps better than nothing. - - - - - ee2c50cb by Sylvain Henry at 2020-03-10T02:06:33-04:00 Hadrian: track missing configure results - - - - - ca8f51d4 by Ömer Sinan Ağacan at 2020-03-10T02:07:22-04:00 Add regression test for T17904 Closes #17904 - - - - - 5fa9cb82 by Richard Eisenberg at 2020-03-10T12:29:46-04:00 anyRewritableTyVar now looks in RuntimeReps Previously, anyRewritableTyVar looked only at the arg and res of `arg -> res`, but their RuntimeReps are also subject to rewriting. Easy to fix. Test case: typecheck/should_compile/T17024 Fixes #17024. - - - - - 5ba01d83 by Ben Price at 2020-03-10T12:30:27-04:00 Clarify a Lint message When developing a plugin I had a shadowing problem, where I generated code app = \f{v r7B} x{v r7B} -> f{v r7B} x{v r7B} This is obviously wrong, since the occurrence of `f` to the right of the arrow refers to the `x` binder (they share a Unique). However, it is rather confusing when Lint reports Mismatch in type between binder and occurrence Var: x{v rB7} since it is printing the binder, rather than the occurrence. It is rather easy to read this as claiming there is something wrong with the `x` occurrence! We change the report to explicitly print both the binder and the occurrence variables. - - - - - 7b2c827b by Simon Peyton Jones at 2020-03-10T12:31:15-04:00 Comments only Clarify code added in #17852 and MR !2724 - - - - - 3300eeac by Krzysztof Gogolewski at 2020-03-10T12:31:54-04:00 Misc cleanup - Remove Note [Existentials in shift_con_pat]. The function shift_con_pat has been removed 15 years ago in 23f40f0e9be6d4. - Remove kcLookupTcTyCon - it's the same as tcLookupTcTyCon - Remove ASSERT in tyConAppArgN. It's already done by getNth, and it's the only reason getNth exists. - Remove unused function nextRole - - - - - abf5736b by Krzysztof Gogolewski at 2020-03-10T18:05:01+01:00 Typos in comments [skip ci] - - - - - bb586f89 by Ben Gamari at 2020-03-11T00:14:59-04:00 rts: Prefer darwin-specific getCurrentThreadCPUTime macOS Catalina now supports a non-POSIX-compliant version of clock_gettime which cannot use the clock_gettime codepath. Fixes #17906. - - - - - 20800b9a by Sylvain Henry at 2020-03-11T08:17:19-04:00 Split GHC.Iface.Utils module * GHC.Iface.Recomp: recompilation avoidance stuff * GHC.Iface.Make: mkIface* Moved `writeIfaceFile` into GHC.Iface.Load alongside `readIface` and renamed it `writeIface` for consistency. - - - - - 1daa2029 by Greg Steuck at 2020-03-11T08:17:56-04:00 Fixed a minor typo in codegen.rst - - - - - 0bc23338 by Ryan Scott at 2020-03-11T08:18:32-04:00 Re-quantify when generalising over rewrite rule types Previously, `tcRules` would check for naughty quantification candidates (see `Note [Naughty quantification candidates]` in `TcMType`) when generalising over the type of a rewrite rule. This caused sensible-looking rewrite rules (like those in #17710) to be rejected. A more permissing (and easier-to-implement) approach is to do what is described in `Note [Generalising in tcTyFamInstEqnGuts]` in `TcTyClsDecls`: just re-quantify all the type variable binders, regardless of the order in which the user specified them. After all, the notion of type variable specificity has no real meaning in rewrite rules, since one cannot "visibly apply" a rewrite rule. I have written up this wisdom in `Note [Re-quantify type variables in rules]` in `TcRules`. As a result of this patch, compiling the `ExplicitForAllRules1` test case now generates one fewer warning than it used to. As far as I can tell, this is benign, since the thing that the disappearing warning talked about was also mentioned in an entirely separate warning. Fixes #17710. - - - - - 336eac7e by Ben Gamari at 2020-03-11T08:19:08-04:00 testsuite: Mark ghci056 and ghcilink004 as fragile in unreg As noted in #17018. Also fix fragile declaration of T13786, which only runs in the normal way. - - - - - c61b9b02 by Simon Peyton Jones at 2020-03-11T08:19:44-04:00 Deepen call stack for isIn I see quite a few warnings like: WARNING: file compiler/utils/Util.hs, line 593 Over-long elem in unionLists But the call stack is uninformative. Better to add HasDebugCallStack to isIn. Ditto isn'tIn. - - - - - 3aa9b35f by Ömer Sinan Ağacan at 2020-03-11T08:20:27-04:00 Zero any slop after compaction in compacting GC In copying GC, with the relevant debug flags enabled, we release the old blocks after a GC, and the block allocator zeroes the space before releasing a block. This effectively zeros the old heap. In compacting GC we reuse the blocks and previously we didn't zero the unused space in a compacting generation after compaction. With this patch we zero the slop between the free pointer and the end of the block when we're done with compaction and when switching to a new block (because the current block doesn't have enough space for the next object we're shifting). - - - - - 8e6febce by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor GHC.Driver.Session (Ways and Flags) * extract flags and ways into their own modules (with some renaming) * remove one SOURCE import of GHC.Driver.Session from GHC.Driver.Phases * when GHC uses dynamic linking (WayDyn), `interpWays` was only reporting WayDyn even if the host was profiled (WayProf). Now it returns both as expected (might fix #16803). * `mkBuildTag :: [Way] -> String` wasn't reporting a canonical tag for differently ordered lists. Now we sort and nub the list to fix this. - - - - - bc41e471 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor interpreterDynamic and interpreterProfiled * `interpreterDynamic` and `interpreterProfiled` now take `Interp` parameters instead of DynFlags * slight refactoring of `ExternalInterp` so that we can read the iserv configuration (which is pure) without reading an MVar. - - - - - a6989971 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Use a Set to represent Ways Should make `member` queries faster and avoid messing up with missing `nubSort`. Metric Increase: hie002 - - - - - cb93a1a4 by Ryan Scott at 2020-03-11T20:34:14-04:00 Make DeriveFunctor-generated code require fewer beta reductions Issue #17880 demonstrates that `DeriveFunctor`-generated code is surprisingly fragile when rank-_n_ types are involved. The culprit is that `$fmap` (the algorithm used to generate `fmap` implementations) was too keen on applying arguments with rank-_n_ types to lambdas, which fail to typecheck more often than not. In this patch, I change `$fmap` (both the specification and the implementation) to produce code that avoids creating as many lambdas, avoiding problems when rank-_n_ field types arise. See the comments titled "Functor instances" in `TcGenFunctor` for a more detailed description. Not only does this fix #17880, but it also ensures that the code that `DeriveFunctor` generates will continue to work after simplified subsumption is implemented (see #17775). What is truly amazing is that #17880 is actually a regression (introduced in GHC 7.6.3) caused by commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e, the fix #7436. Prior to that commit, the version of `$fmap` that was used was almost identical to the one used in this patch! Why did that commit change `$fmap` then? It was to avoid severe performance issues that would arise for recursive `fmap` implementations, such as in the example below: ```hs data List a = Nil | Cons a (List a) deriving Functor -- ===> instance Functor List where fmap f Nil = Nil fmap f (Cons x xs) = Cons (f x) (fmap (\y -> f y) xs) ``` The fact that `\y -> f y` was eta expanded caused significant performance overheads. Commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e fixed this performance issue, but it went too far. As a result, this patch partially reverts 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e. To ensure that the performance issues pre-#7436 do not resurface, I have taken some precautionary measures: * I have added a special case to `$fmap` for situations where the last type variable in an application of some type occurs directly. If this special case fires, we avoid creating a lambda expression. This ensures that we generate `fmap f (Cons x xs) = Cons (f x) (fmap f xs)` in the derived `Functor List` instance above. For more details, see `Note [Avoid unnecessary eta expansion in derived fmap implementations]` in `TcGenFunctor`. * I have added a `T7436b` test case to ensure that the performance of this derived `Functor List`-style code does not regress. When implementing this, I discovered that `$replace`, the algorithm which generates implementations of `(<$)`, has a special case that is very similar to the `$fmap` special case described above. `$replace` marked this special case with a custom `Replacer` data type, which was a bit overkill. In order to use the same machinery for both `Functor` methods, I ripped out `Replacer` and instead implemented a simple way to detect the special case. See the updated commentary in `Note [Deriving <$]` for more details. - - - - - 1f9db3e7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Properly parenthesise LastStmt After ApplicatveDo strips the last `return` during renaming, the pretty printer has to restore it. However, if the return was followed by `$`, the dollar was stripped too and not restored. For example, the last stamement in: ``` foo = do x <- ... ... return $ f x ``` would be printed as: ``` return f x ``` This commit preserved the dolar, so it becomes: ``` return $ f x ``` - - - - - 5cb93af7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Do not print ApplicativeDo join * Do not print `join` in ApplictiveStmt, unless ppr-debug * Print parens around multiple parallel binds When ApplicativeDo is enabled, the renamer analyses the statements of a `do` block and in certain cases marks them as needing to be rewritten using `join`. For example, if you have: ``` foo = do a <- e1 b <- e2 doSomething a b ``` it will be desugared into: ``` foo = join (doSomething <$> e1 <*> e2) ``` After renaming but before desugaring the expression is stored essentially as: ``` foo = do [will need join] (a <- e1 | b <- e2) [no return] doSomething a b ``` Before this change, the pretty printer would print a call to `join`, even though it is not needed at this stage at all. The expression will be actually rewritten into one using join only at desugaring, at which point a literal call to join will be inserted. - - - - - 3a259092 by Simon Peyton Jones at 2020-03-12T09:46:29-04:00 Expose compulsory unfoldings always The unsafeCoerce# patch requires that unsafeCoerce# has a compulsory unfolding that is always available. So we have to be careful to expose compulsory unfoldings unconditionally and consistently. We didn't get this quite right: #17871. This patch fixes it. No real surprises here. See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy - - - - - 6a65b8c2 by Alp Mestanogullari at 2020-03-13T02:29:20-04:00 hadrian: improve dependency tracking for the check-* programs The code in Rules.Register responsible for finding all the build artifacts that Cabal installs when registering a library (static/shared libs, .hi files, ...) was looking in the wrong place. This patch fixes that logic and makes sure we gather all those artifacts in a list to declare that the rule for a given `.conf` file, our proxy for "Hadrian, please install this package in the package db for this stage", also produces those artifacts under the said package database. We also were completely missing some logic to declare that the check-* programs have dependencies besides their source code, at least when testing an in-tree compiler. Finally, this patch also removes redundant packages from 'testsuitePackages', since they should already be covered by the stage<N>Packages lists from Settings.Default. With this patch, after a complete build and freezing stage 1, a change to `compiler/parser/Parser.y` results in rebuilding the ghc lib, reinstalling it, and rebuilding the few programs that depend on it, _including_ `check-ppr` and `check-api-annotations` (therefore fixing #17273). - - - - - 44fad4a9 by Sylvain Henry at 2020-03-13T02:30:22-04:00 Rename isDllName I wanted to fix the dangling comment in `isDllName` ("This is the cause of #", #8696 is already mentioned earlier). I took the opportunity to change the function name to better reflect what it does. - - - - - 2f292db8 by Paavo at 2020-03-13T02:31:03-04:00 Update documentation for closureSize - - - - - f124ff0d by Ben Gamari at 2020-03-13T02:31:40-04:00 gitlab-ci: Rework triggering of release builds Use a push option instead of tagging. - - - - - 7f25557a by Ben Gamari at 2020-03-13T10:38:09-04:00 gitlab-ci: Distinguish integer-simple test envs Previously two integer-simple jobs declared the same test environment. One (the nightly job) was built in the perf way, the other in the validate way. Consequently they had appreciably different performance characteristics, causing in the nightly job to spuriously fail with performance changes. - - - - - c12a2ec5 by Simon Peyton Jones at 2020-03-14T05:25:30-04:00 Fix Lint Ticket #17590 pointed out a bug in the way the linter dealt with type lets, exposed by the new uniqAway story. The fix is described in Note [Linting type lets]. I ended up putting the in-scope Ids in a different env field, le_ids, rather than (as before) sneaking them into the TCvSubst. Surprisingly tiresome, but done. Metric Decrease: hie002 - - - - - b989845e by Sylvain Henry at 2020-03-14T05:26:11-04:00 Hadrian: fix absolute buildroot support (#17822) Shake's "**" wildcard doesn't match absolute root. We must use "//" instead. - - - - - 4f117135 by Sylvain Henry at 2020-03-14T05:26:49-04:00 Make: refactor GMP rules Document and use simpler rules for the ghc-gmp.h header. - - - - - 7432b327 by Sylvain Henry at 2020-03-14T05:27:28-04:00 Use correct option name (-opti) (fix #17314) s/pgmo/opti - - - - - 8f7dd571 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Allow overriding LD_STAGE0 and AR_STAGE0 in the configure script. Previously it was possible to override the stage0 C compiler via `CC_STAGE0`, but you couldn't override `ld` or `ar` in stage0. This change allows overriding them by setting `LD_STAGE0` or `AR_STAGE0`, respectively. Our team uses this feature internally to take more control of our GHC build and make it run more hermetically. - - - - - 7c3e39a9 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Use AC_ARG_VAR for LD_STAGE0 and AR_STAGE0. - - - - - 20d4d676 by Ben Gamari at 2020-03-14T05:28:43-04:00 nonmoving: Don't traverse filled segment list in pause The non-moving collector would previously walk the entire filled segment list during the preparatory pause. However, this is far more work than is strictly necessary. We can rather get away with merely collecting the allocators' filled segment list heads and process the lists themselves during the concurrent phase. This can significantly reduce the maximum gen1 GC pause time in programs with high rates of long-lived allocations. - - - - - fdfa2d01 by Ben Gamari at 2020-03-14T05:29:18-04:00 nonmoving: Remove redundant bitmap clearing nonmovingSweep already clears the bitmap in the sweep loop. There is no reason to do so a second time. - - - - - 2f8c7767 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Simple refactor of cheapEqExpr No change in functionality. Just seems tidier (and signficantly more efficient) to deal with ticks directly than to call stripTicksTopE. - - - - - 88f7a762 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Improve CSE.combineAlts This patch improves the way that CSE combines identical alternatives. See #17901. I'm still not happy about the duplication between CSE.combineAlts and GHC.Core.Utils.combineIdenticalAlts; see the Notes with those functions. But this patch is a step forward. Metric Decrease: T12425 T5642 - - - - - 8b95ddd3 by Ben Gamari at 2020-03-14T05:30:31-04:00 gitlab-ci: Add integer-simple release build for Windows Closes #16144. - - - - - e3c374cc by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Wrap an implication around class-sig kind errors Ticket #17841 showed that we can get a kind error in a class signature, but lack an enclosing implication that binds its skolems. This patch * Adds the wrapping implication: the new call to checkTvConstraints in tcClassDecl1 * Simplifies the API to checkTvConstraints, which was not otherwise called at all. * Simplifies TcErrors.report_unsolved by *not* initialising the TidyEnv from the typechecker lexical envt. It's enough to do so from the free vars of the unsolved constraints; and we get silly renamings if we add variables twice: once from the lexical scope and once from the implication constraint. - - - - - 73133a3b by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Refactoring in TcSMonad This patch is just refactoring: no change in behaviour. I removed the rather complicated checkConstraintsTcS checkTvConstraintsTcS in favour of simpler functions emitImplicationTcS emitTvImplicationTcS pushLevelNoWorkList The last of these is a little strange, but overall it's much better I think. - - - - - 93c88c26 by Ben Gamari at 2020-03-14T05:31:42-04:00 base: Make `open` calls interruptible As noted in #17912, `open` system calls were `safe` rather than `interruptible`. Consequently, the program could not be interrupted with SIGINT if stuck in a slow open operation. Fix this by marking `c_safe_open` as interruptible. - - - - - bee4cdad by Vladislav Zavialov at 2020-03-14T05:32:18-04:00 Remove second tcLookupTcTyCon in tcDataDefn Before this patch, tcDataDefn used to call tcLookupTcTyCon twice in a row: 1. in bindTyClTyVars itself 2. in the continuation passed to it Now bindTyClTyVars passes the TcTyCon to the continuation, making the second lookup unnecessary. - - - - - 3f116d35 by Cale Gibbard at 2020-03-14T19:34:42-04:00 Enable stage1 build of haddock The submodule has already been bumped to contain the fix. - - - - - 49e9d739 by Ömer Sinan Ağacan at 2020-03-14T19:35:24-04:00 rts: Fix printClosure when printing fwd ptrs - - - - - 1de3ab4a by Krzysztof Gogolewski at 2020-03-14T19:36:04-04:00 Remove unused field var_inline (#17915) - - - - - d30aeb4b by Krzysztof Gogolewski at 2020-03-15T03:57:41-04:00 Document restriction on SCC pragma syntax Currently, the names of cost centres must be quoted or be lowercase identifiers. Fixes #17916. - - - - - b4774598 by Brian Foley at 2020-03-15T03:58:18-04:00 Remove some dead code >From the notes.ghc.drop list found using weeder in #17713 - - - - - dd6ffe6b by Viktor Dukhovni at 2020-03-15T03:58:55-04:00 Note platform-specific Foreign.C.Types in context Also fix the markup in the general note at the top of the module. Haddock (usability trade-off), does not support multi-line emphasised text. - - - - - 2e82465f by Sylvain Henry at 2020-03-15T10:57:10-04:00 Refactor CmmToAsm (disentangle DynFlags) This patch disentangles a bit more DynFlags from the native code generator (CmmToAsm). In more details: - add a new NCGConfig datatype in GHC.CmmToAsm.Config which contains the configuration of a native code generation session - explicitly pass NCGConfig/Platform arguments when necessary - as a consequence `sdocWithPlatform` is gone and there are only a few `sdocWithDynFlags` left - remove the use of `unsafeGlobalDynFlags` from GHC.CmmToAsm.CFG - remove `sdocDebugLevel` (now we pass the debug level via NCGConfig) There are still some places where DynFlags is used, especially because of pretty-printing (CLabel), because of Cmm helpers (such as `cmmExprType`) and because of `Outputable` instance for the instructions. These are left for future refactoring as this patch is already big. - - - - - c35c545d by Judah Jacobson at 2020-03-15T10:57:48-04:00 Add a -no-haddock flag. This flag undoes the effect of a previous "-haddock" flag. Having both flags makes it easier for build systems to enable Haddock parsing in a set of global flags, but then disable it locally for specific targets (e.g., third-party packages whose comments don't pass the validation in the latest GHC). I added the flag to expected-undocumented-flags.txt since `-haddock` was alreadyin that list. - - - - - cfcc3c9a by Ömer Sinan Ağacan at 2020-03-15T10:58:27-04:00 Fix global_link of TSOs for threads reachable via dead weaks Fixes #17785 Here's how the problem occurs: - In generation 0 we have a TSO that is finished (i.e. it has no more work to do or it is killed). - The TSO only becomes reachable after collectDeadWeakPtrs(). - After collectDeadWeakPtrs() we switch to WeakDone phase where we don't move TSOs to different lists anymore (like the next gen's thread list or the resurrected_threads list). - So the TSO will never be moved to a generation's thread list, but it will be promoted to generation 1. - Generation 1 collected via mark-compact, and because the TSO is reachable it is marked, and its `global_link` field, which is bogus at this point (because the TSO is not in a list), will be threaded. - Chaos ensues. In other words, when these conditions hold: - A TSO is reachable only after collectDeadWeakPtrs() - It's finished (what_next is ThreadComplete or ThreadKilled) - It's retained by mark-compact collector (moving collector doesn't evacuate the global_list field) We end up doing random mutations on the heap because the TSO's global_list field is not valid, but it still looks like a heap pointer so we thread it during compacting GC. The fix is simple: when we traverse old_threads lists to resurrect unreachable threads the threads that won't be resurrected currently stays on the old_threads lists. Those threads will never be visited again by MarkWeak so we now reset the global_list fields. This way compacting GC does not thread pointers to nowhere. Testing ------- The reproducer in #17785 is quite large and hard to build, because of the dependencies, so I'm not adding a regression test. In my testing the reproducer would take a less than 5 seconds to run, and once in every ~5 runs would fail with a segfault or an assertion error. In other cases it also fails with a test failure. Because the tests never fail with the bug fix, assuming the code is correct, this also means that this bug can sometimes lead to incorrect runtime results. After the fix I was able to run the reproducer repeatedly for about an hour, with no runtime crashes or test failures. To run the reproducer clone the git repo: $ git clone https://github.com/osa1/streamly --branch ghc-segfault Then clone primitive and atomic-primops from their git repos and point to the clones in cabal.project.local. The project should then be buildable using GHC HEAD. Run the executable `properties` with `+RTS -c -DZ`. In addition to the reproducer above I run the test suite using: $ make slowtest EXTRA_HC_OPTS="-debug -with-rtsopts=-DS \ -with-rtsopts=-c +RTS -c -RTS" SKIPWAY='nonmoving nonmoving_thr' This enables compacting GC always in both GHC when building the test programs and when running the test programs, and also enables sanity checking when running the test programs. These set of flags are not compatible for all tests so there are some failures, but I got the same set of failures with this patch compared to GHC HEAD. - - - - - 818b3c38 by Lysxia at 2020-03-16T23:52:42-04:00 base: add strict IO functions: readFile', getContents', hGetContents' - - - - - 18a346a4 by Sylvain Henry at 2020-03-16T23:53:24-04:00 Modules: Core (#13009) Update submodule: haddock - - - - - 92327e3a by Ömer Sinan Ağacan at 2020-03-16T23:54:04-04:00 Update sanity checking for TSOs: - Remove an invalid assumption about GC checking what_next field. The GC doesn't care about what_next at all, if a TSO is reachable then all its pointers are followed (other than global_tso, which is only followed by compacting GC). - Remove checkSTACK in checkTSO: TSO stacks will be visited in checkHeapChain, or checkLargeObjects etc. - Add an assertion in checkTSO to check that the global_link field is sane. - Did some refactor to remove forward decls in checkGlobalTSOList and added braces around single-statement if statements. - - - - - e1aa4052 by PHO at 2020-03-17T07:36:09-04:00 Don't use non-portable operator "==" in configure.ac The test operator "==" is a Bash extension and produces a wrong result if /bin/sh is not Bash. - - - - - 89f034dd by Maximilian Tagher at 2020-03-17T07:36:48-04:00 Document the units of -ddump-timings Right now, in the output of -ddump-timings to a file, you can't tell what the units are: ``` CodeGen [TemplateTestImports]: alloc=22454880 time=14.597 ``` I believe bytes/milliseconds are the correct units, but confirmation would be appreciated. I'm basing it off of this snippet from `withTiming'`: ``` when (verbosity dflags >= 2 && prtimings == PrintTimings) $ liftIO $ logInfo dflags (defaultUserStyle dflags) (text "!!!" <+> what <> colon <+> text "finished in" <+> doublePrec 2 time <+> text "milliseconds" <> comma <+> text "allocated" <+> doublePrec 3 (realToFrac alloc / 1024 / 1024) <+> text "megabytes") ``` which implies time is in milliseconds, and allocations in bytes (which divided by 1024 would be KB, and again would be MB) - - - - - beffa147 by Simon Peyton Jones at 2020-03-17T07:37:25-04:00 Implement mapTyCo like foldTyCo This patch makes mapType use the successful idiom described in TyCoRep Note [Specialising foldType] I have not yet changed any functions to use mapType, though there may be some suitable candidates. This patch should be a no-op in terms of functionality but, because it inlines the mapper itself, I'm hoping that there may be some modest perf improvements. Metric Decrease: T5631 T5642 T3064 T9020 T14683 hie002 haddock.Cabal haddock.base haddock.compiler - - - - - 5800ebfe by Ömer Sinan Ağacan at 2020-03-17T07:38:08-04:00 Don't update ModDetails with CafInfos when opts are disabled This is consistent with the interface file behavior where we omit HsNoCafRefs annotations with -fomit-interface-pragmas (implied by -O0). ModDetails and ModIface are just different representations of the same thing, so they really need to be in sync. This patch does the right thing and does not need too much explanation, but here's an example of a problem not doing this causes in !2842: -- MyInteger.hs module MyInteger ( MyInteger (MyInteger) , ToMyInteger (toMyInteger) ) where newtype MyInteger = MyInteger Integer class ToMyInteger a where toMyInteger :: a -> MyInteger instance ToMyInteger Integer where toMyInteger = MyInteger {- . succ -} -- Main.hs module Main ( main ) where import MyInteger (MyInteger (MyInteger), toMyInteger) main :: IO () main = do let (MyInteger i) = (id . toMyInteger) (41 :: Integer) print i If I build this with -O0, without this fix, we generate a ModDetails with accurate LFInfo for toMyInteger (MyInteger.$fToMyIntegerInteger) which says that it's a LFReEntrant with arity 1. This means in the use site (Main) we tag the value: R3 = MyInteger.$fToMyIntegerInteger_closure + 1; R2 = GHC.Base.id_closure; R1 = GHC.Base.._closure; Sp = Sp - 16; call stg_ap_ppp_fast(R4, R3, R2, R1) args: 24, res: 0, upd: 24; Now we change the definition by uncommenting the `succ` part and it becomes a thunk: MyInteger.$fToMyIntegerInteger [InlPrag=INLINE (sat-args=0)] :: MyInteger.ToMyInteger GHC.Integer.Type.Integer [GblId[DFunId(nt)]] = {} \u [] $ctoMyInteger_rEA; and its LFInfo is now LFThunk. This change in LFInfo makes a difference in the use site: we can no longer tag it. But becuase the interface fingerprint does not change (because ModIface does not change) we don't rebuild Main and tag the thunk. (1.2% increase in allocations when building T12545 on armv7 because we generate more code without CafInfos) Metric Increase: T12545 - - - - - 5b632dad by Paavo at 2020-03-17T07:38:48-04:00 Add example for Data.Semigroup.diff - - - - - 4d85d68b by Paavo at 2020-03-17T07:38:48-04:00 Clean up - - - - - 75168d07 by Paavo at 2020-03-17T07:38:48-04:00 Make example collapsible - - - - - 53ff2cd0 by Richard Eisenberg at 2020-03-17T13:46:57+00:00 Fix #17021 by checking more return kinds All the details are in new Note [Datatype return kinds] in TcTyClsDecls. Test case: typecheck/should_fail/T17021{,b} typecheck/should_compile/T17021a Updates haddock submodule - - - - - 528df8ec by Sylvain Henry at 2020-03-18T10:06:43-04:00 Modules: Core operations (#13009) - - - - - 4e8a71c1 by Richard Eisenberg at 2020-03-18T10:07:19-04:00 Add release note about fix to #16502. We thought we needed to update the manual, but the fix for #16502 actually brings the implementation in line with the manual. So we just alert users of how to update their code. - - - - - 5cbf9934 by Andreas Klebinger at 2020-03-19T00:39:27-04:00 Update "GHC differences to the FFI Chapter" in user guide. The old entry had a heavy focus on how things had been. Which is not what I generally look for in a user guide. I also added a small section on behaviour of nested safe ffi calls. [skip-ci] - - - - - b03fd3bc by Sebastian Graf at 2020-03-19T00:40:06-04:00 PmCheck: Use ConLikeSet to model negative info In #17911, Simon recognised many warnings stemming from over-long list unions while coverage checking Cabal's `LicenseId` module. This patch introduces a new `PmAltConSet` type which uses a `UniqDSet` instead of an association list for `ConLike`s. For `PmLit`s, it will still use an assocation list, though, because a similar map data structure would entail a lot of busy work. Fixes #17911. - - - - - 64f20756 by Sylvain Henry at 2020-03-19T12:16:49-04:00 Refactoring: use Platform instead of DynFlags when possible Metric Decrease: ManyConstructors T12707 T13035 T1969 - - - - - cb1785d9 by Ömer Sinan Ağacan at 2020-03-19T12:16:54-04:00 FastString: fix eager reading of string ptr in hashStr This read causes NULL dereferencing when len is 0. Fixes #17909 In the reproducer in #17909 this bug is triggered as follows: - SimplOpt.dealWithStringLiteral is called with a single-char string ("=" in #17909) - tailFS gets called on the FastString of the single-char string. - tailFS checks the length of the string, which is 1, and calls mkFastStringByteString on the tail of the ByteString, which is an empty ByteString as the original ByteString has only one char. - ByteString's unsafeUseAsCStringLen returns (NULL, 0) for the empty ByteString, which is passed to mkFastStringWith. - mkFastStringWith gets hash of the NULL pointer via hashStr, which fails on empty strings because of this bug. - - - - - 73a7383e by Richard Eisenberg at 2020-03-20T20:42:56-04:00 Simplify treatment of heterogeneous equality Previously, if we had a [W] (a :: k1) ~ (rhs :: k2), we would spit out a [D] k1 ~ k2 and part the W as irreducible, hoping for a unification. But we needn't do this. Instead, we now spit out a [W] co :: k2 ~ k1 and then use co to cast the rhs of the original Wanted. This means that we retain the connection between the spat-out constraint and the original. The problem with this new approach is that we cannot use the casted equality for substitution; it's too like wanteds-rewriting- wanteds. So, we forbid CTyEqCans that mention coercion holes. All the details are in Note [Equalities with incompatible kinds] in TcCanonical. There are a few knock-on effects, documented where they occur. While debugging an error in this patch, Simon and I ran into infelicities in how patterns and matches are printed; we made small improvements. This patch includes mitigations for #17828, which causes spurious pattern-match warnings. When #17828 is fixed, these lines should be removed. - - - - - faa36e5b by Sylvain Henry at 2020-03-20T20:43:41-04:00 Hadrian: ignore in-tree GMP objects with ``--lint`` - - - - - 9a96ff6b by Richard Eisenberg at 2020-03-20T20:44:17-04:00 Update core spec to reflect changes to Core. Key changes: * Adds a new rule for forall-coercions over coercion variables, which was implemented but conspicuously missing from the spec. * Adds treatment for FunCo. * Adds treatment for ForAllTy over coercion variables. * Improves commentary (including restoring a Note lost in 03d4852658e1b7407abb4da84b1b03bfa6f6db3b) in the source. No changes to running code. - - - - - 7e0451c6 by Sergej Jaskiewicz at 2020-03-20T20:44:55-04:00 Fix event message in withTiming' This typo caused generating 'end' events without the corresponding 'begin' events. - - - - - 1542a626 by Ben Gamari at 2020-03-22T22:37:47-04:00 fs.h: Add missing declarations on Windows - - - - - 3bcf2ccd by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump process submodule Avoids redundant case alternative warning. - - - - - 3b363ef9 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Normalize slashes in ghc-api annotations output Enable `normalise_slashes` on `annotations`, `listcomps`, and `parseTree` to fix Windows failures. - - - - - 25fc9429 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - 7f58ec6d by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Fix TOP of T17786 - - - - - aadcd909 by GHC GitLab CI at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - dc1eb10d by GHC GitLab CI at 2020-03-22T22:37:47-04:00 hadrian: Fix executable extension passed to testsuite driver - - - - - 58f62e2c by GHC GitLab CI at 2020-03-22T22:37:47-04:00 gitlab-ci: Require that Windows-hadrian job passes - - - - - 8dd2415d by Ben Gamari at 2020-03-22T22:37:47-04:00 hadrian: Eliminate redundant .exe from GHC path Previously we were invoking: bash -c "c:/GitLabRunner/builds/eEQrxK4p/0/ghc/ghc/toolchain/bin/ghc.exe.exe testsuite/mk/ghc-config.hs -o _build/test/bin/ghc-config.exe" - - - - - 373621f6 by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump hsc2hs submodule - - - - - abc02b40 by Hécate at 2020-03-22T22:38:33-04:00 Annotate the non-total function in Data.Foldable as such - - - - - 19f12557 by Josef Svenningsson at 2020-03-23T14:05:33-04:00 Fix ApplicativeDo regression #17835 A previous fix for #15344 made sure that monadic 'fail' is used properly when translating ApplicativeDo. However, it didn't properly account for when a 'fail' will be inserted which resulted in some programs failing with a type error. - - - - - 2643ba46 by Paavo at 2020-03-24T08:31:32-04:00 Add example and doc for Arg (Fixes #17153) - - - - - 703221f4 by Roland Senn at 2020-03-25T14:45:04-04:00 Use export list of Main module in function TcRnDriver.hs:check_main (Fix #16453) - Provide the export list of the `Main` module as parameter to the `compiler/typecheck/TcRnDriver.hs:check_main` function. - Instead of `lookupOccRn_maybe` call the function `lookupInfoOccRn`. It returns the list `mains_all` of all the main functions in scope. - Select from this list `mains_all` all `main` functions that are in the export list of the `Main` module. - If this new list contains exactly one single `main` function, then typechecking continues. - Otherwise issue an appropriate error message. - - - - - 3e27205a by Sebastian Graf at 2020-03-25T14:45:40-04:00 Remove -fkill-absence and -fkill-one-shot flags They seem to be a benchmarking vestige of the Cardinality paper and probably shouldn't have been merged to HEAD in the first place. - - - - - 262e42aa by Peter Trommler at 2020-03-25T22:41:39-04:00 Do not panic on linker errors - - - - - 0de03cd7 by Sylvain Henry at 2020-03-25T22:42:02-04:00 DynFlags refactoring III Use Platform instead of DynFlags when possible: * `tARGET_MIN_INT` et al. replaced with `platformMinInt` et al. * no more DynFlags in PreRules: added a new `RuleOpts` datatype * don't use `wORD_SIZE` in the compiler * make `wordAlignment` use `Platform` * make `dOUBLE_SIZE` a constant Metric Decrease: T13035 T1969 - - - - - 7a04920b by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: fix a typo in liftA doc This change removes an extra '|' that should not be rendered in the liftA documentation. Tracking: #17929 - - - - - 1c5a15f7 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add Control.Applicative optional example This change adds an optional example. Tracking: #17929 - - - - - 6d172e63 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add markup around Except - - - - - eb2162c8 by John Ericson at 2020-03-26T12:37:08-04:00 Remove unused `ghciTablesNextToCode` from compiler proper - - - - - f51efc4b by Joachim Breitner at 2020-03-26T12:37:09-04:00 Prepare to use run-time tablesNextToCode in compiler exclusively Factor out CPP as much as possible to prepare for runtime determinattion. Progress towards #15548 - - - - - 1c446220 by Joachim Breitner at 2020-03-26T12:37:09-04:00 Use run-time tablesNextToCode in compiler exclusively (#15548) Summary: - There is no more use of the TABLES_NEXT_TO_CODE CPP macro in `compiler/`. GHCI_TABLES_NEXT_TO_CODE is also removed entirely. The field within `PlatformMisc` within `DynFlags` is used instead. - The field is still not exposed as a CLI flag. We might consider some way to ensure the right RTS / libraries are used before doing that. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082 - - - - - 1941ef4f by Sylvain Henry at 2020-03-29T17:28:51-04:00 Modules: Types (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - 1c7c6f1a by Sylvain Henry at 2020-03-29T17:28:51-04:00 Remove GHC.Types.Unique.Map module This module isn't used anywhere in GHC. - - - - - f1a6c73d by Sylvain Henry at 2020-03-29T17:28:51-04:00 Merge GHC.Types.CostCentre.Init into GHC.Driver.CodeOutput - - - - - 54250f2d by Simon Peyton Jones at 2020-03-29T17:29:30-04:00 Demand analysis: simplify the demand for a RHS Ticket #17932 showed that we were using a stupid demand for the RHS of a let-binding, when the result is a product. This was the result of a "fix" in 2013, which (happily) turns out to no longer be necessary. So I just deleted the code, which simplifies the demand analyser, and fixes #17932. That in turn uncovered that the anticipation of worker/wrapper in CPR analysis was inaccurate, hence the logic that decides whether to unbox an argument in WW was extracted into a function `wantToUnbox`, now consulted by CPR analysis. I tried nofib, and got 0.0% perf changes. All this came up when messing about with !2873 (ticket #17917), but is idependent of it. Unfortunately, this patch regresses #4267 and realised that it is now blocked on #16335. - - - - - 03060b2f by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 on Windows Fixes line ending normalization issue. - - - - - 1f7995ba by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 Fix missing quoting and expected exit code. - - - - - ef9c608e by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - e54500c1 by Sylvain Henry at 2020-03-29T17:30:47-04:00 Store ComponentId details As far as GHC is concerned, installed package components ("units") are identified by an opaque ComponentId string provided by Cabal. But we don't want to display it to users (as it contains a hash) so GHC queries the database to retrieve some infos about the original source package (name, version, component name). This patch caches these infos in the ComponentId itself so that we don't need to provide DynFlags (which contains installed package informations) to print a ComponentId. In the future we want GHC to support several independent package states (e.g. for plugins and for target code), hence we need to avoid implicitly querying a single global package state. - - - - - 7e7cb714 by Marius Bakke at 2020-03-29T17:31:27-04:00 testsuite: Remove test that dlopens a PIE object. glibc 2.30 disallowed dlopening PIE objects, so just remove the test. Fixes #17952. - - - - - 6c8f80d8 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Correct haddocks for testBit in Data.Bits It conflated the nth bit with the bit at offset n. Now we instead give the definition in terms of `bit and `.&.` on top of clearer phrasing. - - - - - c916f190 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Apply suggestion to libraries/base/Data/Bits.hs - - - - - 64bf7f51 by Ben Gamari at 2020-03-29T17:32:41-04:00 gitlab-ci: Add FreeBSD release job - - - - - a0d8e92e by Ryan Scott at 2020-03-29T17:33:20-04:00 Run checkNewDataCon before constraint-solving newtype constructors Within `checkValidDataCon`, we used to run `checkValidType` on the argument types of a newtype constructor before running `checkNewDataCon`, which ensures that the user does not attempt non-sensical things such as newtypes with multiple arguments or constraints. This works out in most situations, but this falls over on a corner case revealed in #17955: ```hs newtype T = Coercible () T => T () ``` `checkValidType`, among other things, peforms an ambiguity check on the context of a data constructor, and that it turn invokes the constraint solver. It turns out that there is a special case in the constraint solver for representational equalities (read: `Coercible` constraints) that causes newtypes to be unwrapped (see `Note [Unwrap newtypes first]` in `TcCanonical`). This special case does not know how to cope with an ill formed newtype like `T`, so it ends up panicking. The solution is surprisingly simple: just invoke `checkNewDataCon` before `checkValidType` to ensure that the illicit newtype constructor context is detected before the constraint solver can run amok with it. Fixes #17955. - - - - - 45eb9d8c by Krzysztof Gogolewski at 2020-03-29T17:33:59-04:00 Minor cleanup - Simplify mkBuildExpr, the function newTyVars was called only on a one-element list. - TTG: use noExtCon in more places. This is more future-proof. - In zonkExpr, panic instead of printing a warning. - - - - - f024b6e3 by Sylvain Henry at 2020-03-30T12:48:39+02:00 Expect T4267 to pass Since 54250f2d8de910b094070c1b48f086030df634b1 we expected T4267 to fail, but it passes on CI. - - - - - 57b888c0 by Ryan Scott at 2020-03-31T10:54:20-04:00 Require GHC 8.8 as the minimum compiler for bootstrapping This allows us to remove several bits of CPP that are either always true or no longer reachable. As an added bonus, we no longer need to worry about importing `Control.Monad.Fail.fail` qualified to avoid clashing with `Control.Monad.fail`, since the latter is now the same as the former. - - - - - 33f09551 by Ryan Scott at 2020-03-31T10:54:57-04:00 Add regression test for #17963 The panic in #17963 happened to be fixed by commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70. This patch adds a regression test to ensure that it remains fixed. Fixes #17963. - - - - - 09a36e80 by Ömer Sinan Ağacan at 2020-03-31T10:55:37-04:00 Simplify stderrSupportsAnsiColors The combinator andM is used only once, and the code is shorter and simpler if you inline it. - - - - - 95bccdd0 by Ben Gamari at 2020-03-31T10:56:19-04:00 base: Ensure that encoding global variables aren't inlined As noted in #17970, these (e.g. `getFileSystemEncoding` and `setFileSystemEncoding`) previously had unfoldings, which would break their global-ness. While not strictly necessary, I also add a NOINLINE on `initLocaleEncoding` since it is used in `System.IO`, ensuring that we only system's query the locale encoding once. Fixes #17970. - - - - - 982aaa83 by Andreas Klebinger at 2020-03-31T10:56:55-04:00 Update hadrian index revision. Required in order to build hadrian using ghc-8.10 - - - - - 4b9c5864 by Ben Gamari at 2020-03-31T10:57:32-04:00 integer-gmp: Bump version and add changelog entry - - - - - 9b39f2e6 by Ryan Scott at 2020-04-01T01:20:00-04:00 Clean up "Eta reduction for data families" Notes Before, there were two distinct Notes named "Eta reduction for data families". This renames one of them to "Implementing eta reduction for data families" to disambiguate the two and fixes references in other parts of the codebase to ensure that they are pointing to the right place. Fixes #17313. [ci skip] - - - - - 7627eab5 by Ryan Scott at 2020-04-01T01:20:38-04:00 Fix the changelog/@since information for hGetContents'/getContents'/readFile' Fixes #17979. [ci skip] - - - - - 0002db1b by Sylvain Henry at 2020-04-01T01:21:27-04:00 Kill wORDS_BIGENDIAN and replace it with platformByteOrder (#17957) Metric Decrease: T13035 T1969 - - - - - 7b217179 by Sebastian Graf at 2020-04-01T15:03:24-04:00 PmCheck: Adjust recursion depth for inhabitation test In #17977, we ran into the reduction depth limit of the typechecker. That was only a symptom of a much broader issue: The recursion depth of the coverage checker for trying to instantiate strict fields in the `nonVoid` test was far too high (100, the `defaultMaxTcBound`). As a result, we were performing quite poorly on `T17977`. Short of a proper termination analysis to prove emptyness of a type, we just arbitrarily default to a much lower recursion limit of 3. Fixes #17977. - - - - - 3c09f636 by Andreas Klebinger at 2020-04-01T15:03:59-04:00 Make hadrian pass on the no-colour setting to GHC. Fixes #17983. - - - - - b943b25d by Simon Peyton Jones at 2020-04-02T01:45:58-04:00 Re-engineer the binder-swap transformation The binder-swap transformation is implemented by the occurrence analyser -- see Note [Binder swap] in OccurAnal. However it had a very nasty corner in it, for the case where the case scrutinee was a GlobalId. This led to trouble and hacks, and ultimately to #16296. This patch re-engineers how the occurrence analyser implements the binder-swap, by actually carrying out a substitution rather than by adding a let-binding. It's all described in Note [The binder-swap substitution]. I did a few other things along the way * Fix a bug in StgCse, which could allow a loop breaker to be CSE'd away. See Note [Care with loop breakers] in StgCse. I think it can only show up if occurrence analyser sets up bad loop breakers, but still. * Better commenting in SimplUtils.prepareAlts * A little refactoring in CoreUnfold; nothing significant e.g. rename CoreUnfold.mkTopUnfolding to mkFinalUnfolding * Renamed CoreSyn.isFragileUnfolding to hasCoreUnfolding * Move mkRuleInfo to CoreFVs We observed respectively 4.6% and 5.9% allocation decreases for the following tests: Metric Decrease: T9961 haddock.base - - - - - 42d68364 by Sebastian Graf at 2020-04-02T01:46:34-04:00 Preserve precise exceptions in strictness analysis Fix #13380 and #17676 by 1. Changing `raiseIO#` to have `topDiv` instead of `botDiv` 2. Give it special treatment in `Simplifier.Util.mkArgInfo`, treating it as if it still had `botDiv`, to recover dead code elimination. This is the first commit of the plan outlined in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2525#note_260886. - - - - - 0a88dd11 by Ömer Sinan Ağacan at 2020-04-02T01:47:25-04:00 Fix a pointer format string in RTS - - - - - 5beac042 by Ömer Sinan Ağacan at 2020-04-02T01:48:05-04:00 Remove unused closure stg_IND_direct - - - - - 88f38b03 by Ben Gamari at 2020-04-02T01:48:42-04:00 Session: Memoize stderrSupportsAnsiColors Not only is this a reasonable efficiency measure but it avoids making reentrant calls into ncurses, which is not thread-safe. See #17922. - - - - - 27740f24 by Ryan Scott at 2020-04-02T01:49:21-04:00 Make Hadrian build with Cabal-3.2 GHC 8.10 ships with `Cabal-3.2.0.0`, so it would be convenient to make Hadrian supporting building against 3.2.* instead of having to rebuild the entirety of `Cabal-3.0.0.0`. There is one API change in `Cabal-3.2.*` that affects Hadrian: the `synopsis` and `description` functions now return `ShortText` instead of `String`. Since Hadrian manipulates these `String`s in various places, I found that the simplest fix was to use CPP to convert `ShortText` to `String`s where appropriate. - - - - - 49802002 by Sylvain Henry at 2020-04-02T01:50:00-04:00 Update Stack resolver for hadrian/build-stack Broken by 57b888c0e90be7189285a6b078c30b26d0923809 - - - - - 30a63e79 by Ryan Scott at 2020-04-02T01:50:36-04:00 Fix two ASSERT buglets in reifyDataCon Two `ASSERT`s in `reifyDataCon` were always using `arg_tys`, but `arg_tys` is not meaningful for GADT constructors. In fact, it's worse than non-meaningful, since using `arg_tys` when reifying a GADT constructor can lead to failed `ASSERT`ions, as #17305 demonstrates. This patch applies the simplest possible fix to the immediate problem. The `ASSERT`s now use `r_arg_tys` instead of `arg_tys`, as the former makes sure to give something meaningful for GADT constructors. This makes the panic go away at the very least. There is still an underlying issue with the way the internals of `reifyDataCon` work, as described in https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227023, but we leave that as future work, since fixing the underlying issue is much trickier (see https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227087). - - - - - ef7576c4 by Zubin Duggal at 2020-04-03T06:24:56-04:00 Add outputable instances for the types in GHC.Iface.Ext.Types, add -ddump-hie flag to dump pretty printed contents of the .hie file Metric Increase: hie002 Because of the regression on i386: compile_time/bytes allocated increased from i386-linux-deb9 baseline @ HEAD~10: Expected hie002 (normal) compile_time/bytes allocated: 583014888.0 +/-10% Lower bound hie002 (normal) compile_time/bytes allocated: 524713399 Upper bound hie002 (normal) compile_time/bytes allocated: 641316377 Actual hie002 (normal) compile_time/bytes allocated: 877986292 Deviation hie002 (normal) compile_time/bytes allocated: 50.6 % *** unexpected stat test failure for hie002(normal) - - - - - 9462452a by Andreas Klebinger at 2020-04-03T06:25:33-04:00 Improve and refactor StgToCmm codegen for DataCons. We now differentiate three cases of constructor bindings: 1)Bindings which we can "replace" with a reference to an existing closure. Reference the replacement closure when accessing the binding. 2)Bindings which we can "replace" as above. But we still generate a closure which will be referenced by modules importing this binding. 3)For any other binding generate a closure. Then reference it. Before this patch 1) did only apply to local bindings and we didn't do 2) at all. - - - - - a214d214 by Moritz Bruder at 2020-04-03T06:26:11-04:00 Add singleton to NonEmpty in libraries/base This adds a definition to construct a singleton non-empty list (Data.List.NonEmpty) according to issue #17851. - - - - - f7597aa0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Testsuite: measure compiler stats for T16190 We were mistakenly measuring program stats - - - - - a485c3c4 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Move blob handling into StgToCmm Move handling of big literal strings from CmmToAsm to StgToCmm. It avoids the use of `sdocWithDynFlags` (cf #10143). We might need to move this handling even higher in the pipeline in the future (cf #17960): this patch will make it easier. - - - - - cc2918a0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Refactor CmmStatics In !2959 we noticed that there was some redundant code (in GHC.Cmm.Utils and GHC.Cmm.StgToCmm.Utils) used to deal with `CmmStatics` datatype (before SRT generation) and `RawCmmStatics` datatype (after SRT generation). This patch removes this redundant code by using a single GADT for (Raw)CmmStatics. - - - - - 9e60273d by Maxim Koltsov at 2020-04-03T06:27:32-04:00 Fix haddock formatting in Control.Monad.ST.Lazy.Imp.hs - - - - - 1b7e8a94 by Andreas Klebinger at 2020-04-03T06:28:08-04:00 Turn newlines into spaces for hadrian/ghci. The newlines break the command on windows. - - - - - 4291bdda by Simon Peyton Jones at 2020-04-03T06:28:44-04:00 Major improvements to the specialiser This patch is joint work of Alexis King and Simon PJ. It does some significant refactoring of the type-class specialiser. Main highlights: * We can specialise functions with types like f :: Eq a => a -> Ord b => b => blah where the classes aren't all at the front (#16473). Here we can correctly specialise 'f' based on a call like f @Int @Bool dEqInt x dOrdBool This change really happened in an earlier patch commit 2d0cf6252957b8980d89481ecd0b79891da4b14b Author: Sandy Maguire <sandy at sandymaguire.me> Date: Thu May 16 12:12:10 2019 -0400 work that this new patch builds directly on that work, and refactors it a bit. * We can specialise functions with implicit parameters (#17930) g :: (?foo :: Bool, Show a) => a -> String Previously we could not, but now they behave just like a non-class argument as in 'f' above. * We can specialise under-saturated calls, where some (but not all of the dictionary arguments are provided (#17966). For example, we can specialise the above 'f' based on a call map (f @Int dEqInt) xs even though we don't (and can't) give Ord dictionary. This may sound exotic, but #17966 is a program from the wild, and showed significant perf loss for functions like f, if you need saturation of all dictionaries. * We fix a buglet in which a floated dictionary had a bogus demand (#17810), by using zapIdDemandInfo in the NonRec case of specBind. * A tiny side benefit: we can drop dead arguments to specialised functions; see Note [Drop dead args from specialisations] * Fixed a bug in deciding what dictionaries are "interesting"; see Note [Keep the old dictionaries interesting] This is all achieved by by building on Sandy Macguire's work in defining SpecArg, which mkCallUDs uses to describe the arguments of the call. Main changes: * Main work is in specHeader, which marched down the [InBndr] from the function definition and the [SpecArg] from the call site, together. * specCalls no longer has an arity check; the entire mechanism now handles unders-saturated calls fine. * mkCallUDs decides on an argument-by-argument basis whether to specialise a particular dictionary argument; this is new. See mk_spec_arg in mkCallUDs. It looks as if there are many more lines of code, but I think that all the extra lines are comments! - - - - - 40a85563 by Ömer Sinan Ağacan at 2020-04-03T18:26:19+03:00 Revert accidental change in 9462452 [ci skip] - - - - - bd75e5da by Ryan Scott at 2020-04-04T07:07:58-04:00 Enable ImpredicativeTypes internally when typechecking selector bindings This is necessary for certain record selectors with higher-rank types, such as the examples in #18005. See `Note [Impredicative record selectors]` in `TcTyDecls`. Fixes #18005. - - - - - dcfe29c8 by Ömer Sinan Ağacan at 2020-04-06T13:16:08-04:00 Don't override proc CafInfos in ticky builds Fixes #17947 When we have a ticky label for a proc, IdLabels for the ticky counter and proc entry share the same Name. This caused overriding proc CafInfos with the ticky CafInfos (i.e. NoCafRefs) during SRT analysis. We now ignore the ticky labels when building SRTMaps. This makes sense because: - When building the current module they don't need to be in SRTMaps as they're initialized as non-CAFFY (see mkRednCountsLabel), so they don't take part in the dependency analysis and they're never added to SRTs. (Reminder: a "dependency" in the SRT analysis is a CAFFY dependency, non-CAFFY uses are not considered as dependencies for the algorithm) - They don't appear in the interfaces as they're not exported, so it doesn't matter for cross-module concerns whether they're in the SRTMap or not. See also the new Note [Ticky labels in SRT analysis]. - - - - - cec2c71f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Fix an tricky specialiser loop Issue #17151 was a very tricky example of a bug in which the specialiser accidentally constructs a recurive dictionary, so that everything turns into bottom. I have fixed variants of this bug at least twice before: see Note [Avoiding loops]. It was a bit of a struggle to isolate the problem, greatly aided by the work that Alexey Kuleshevich did in distilling a test case. Once I'd understood the problem, it was not difficult to fix, though it did lead me a bit of refactoring in specImports. - - - - - e850d14f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Refactoring only This refactors DictBinds into a data type rather than a pair. No change in behaviour, just better code - - - - - f38e8d61 by Daniel Gröber at 2020-04-07T02:00:05-04:00 rts: ProfHeap: Fix memory leak when not compiled with profiling If we're doing heap profiling on an unprofiled executable we keep allocating new space in initEra via nextEra on each profiler run but we don't have a corresponding freeEra call. We do free the last era in endHeapProfiling but previous eras will have been overwritten by initEra and will never get free()ed. Metric Decrease: space_leak_001 - - - - - bcd66859 by Sebastian Graf at 2020-04-07T02:00:41-04:00 Re-export GHC.Magic.noinline from base - - - - - 3d2991f8 by Ben Gamari at 2020-04-07T18:36:09-04:00 simplifier: Kill off ufKeenessFactor We used to have another factor, ufKeenessFactor, which would scale the discounts before they were subtracted from the size. This was justified with the following comment: -- We multiple the raw discounts (args_discount and result_discount) -- ty opt_UnfoldingKeenessFactor because the former have to do with -- *size* whereas the discounts imply that there's some extra -- *efficiency* to be gained (e.g. beta reductions, case reductions) -- by inlining. However, this is highly suspect since it means that we subtract a *scaled* size from an absolute size, resulting in crazy (e.g. negative) scores in some cases (#15304). We consequently killed off ufKeenessFactor and bumped up the ufUseThreshold to compensate. Adjustment of unfolding use threshold ===================================== Since this removes a discount from our inlining heuristic, I revisited our default choice of -funfolding-use-threshold to minimize the change in overall inlining behavior. Specifically, I measured runtime allocations and executable size of nofib and the testsuite performance tests built using compilers (and core libraries) built with several values of -funfolding-use-threshold. This comes as a result of a quantitative comparison of testsuite performance and code size as a function of ufUseThreshold, comparing GHC trees using values of 50, 60, 70, 80, 90, and 100. The test set consisted of nofib and the testsuite performance tests. A full summary of these measurements are found in the description of !2608 Comparing executable sizes (relative to the base commit) across all nofib tests, we see that sizes are similar to the baseline: gmean min max median thresh 50 -6.36% -7.04% -4.82% -6.46% 60 -5.04% -5.97% -3.83% -5.11% 70 -2.90% -3.84% -2.31% -2.92% 80 -0.75% -2.16% -0.42% -0.73% 90 +0.24% -0.41% +0.55% +0.26% 100 +1.36% +0.80% +1.64% +1.37% baseline +0.00% +0.00% +0.00% +0.00% Likewise, looking at runtime allocations we see that 80 gives slightly better optimisation than the baseline: gmean min max median thresh 50 +0.16% -0.16% +4.43% +0.00% 60 +0.09% -0.00% +3.10% +0.00% 70 +0.04% -0.09% +2.29% +0.00% 80 +0.02% -1.17% +2.29% +0.00% 90 -0.02% -2.59% +1.86% +0.00% 100 +0.00% -2.59% +7.51% -0.00% baseline +0.00% +0.00% +0.00% +0.00% Finally, I had to add a NOINLINE in T4306 to ensure that `upd` is worker-wrappered as the test expects. This makes me wonder whether the inlining heuristic is now too liberal as `upd` is quite a large function. The same measure was taken in T12600. Wall clock time compiling Cabal with -O0 thresh 50 60 70 80 90 100 baseline build-Cabal 93.88 89.58 92.59 90.09 100.26 94.81 89.13 Also, this change happens to avoid the spurious test output in `plugin-recomp-change` and `plugin-recomp-change-prof` (see #17308). Metric Decrease: hie002 T12234 T13035 T13719 T14683 T4801 T5631 T5642 T9020 T9872d T9961 Metric Increase: T12150 T12425 T13701 T14697 T15426 T1969 T3064 T5837 T6048 T9203 T9872a T9872b T9872c T9872d haddock.Cabal haddock.base haddock.compiler - - - - - 255418da by Sylvain Henry at 2020-04-07T18:36:49-04:00 Modules: type-checker (#13009) Update Haddock submodule - - - - - 04b6cf94 by Ryan Scott at 2020-04-07T19:43:20-04:00 Make NoExtCon fields strict This changes every unused TTG extension constructor to be strict in its field so that the pattern-match coverage checker is smart enough any such constructors are unreachable in pattern matches. This lets us remove nearly every use of `noExtCon` in the GHC API. The only ones we cannot remove are ones underneath uses of `ghcPass`, but that is only because GHC 8.8's and 8.10's coverage checkers weren't smart enough to perform this kind of reasoning. GHC HEAD's coverage checker, on the other hand, _is_ smart enough, so we guard these uses of `noExtCon` with CPP for now. Bumps the `haddock` submodule. Fixes #17992. - - - - - 7802fa17 by Ryan Scott at 2020-04-08T16:43:44-04:00 Handle promoted data constructors in typeToLHsType correctly Instead of using `nlHsTyVar`, which hardcodes `NotPromoted`, have `typeToLHsType` pick between `Promoted` and `NotPromoted` by checking if a type constructor is promoted using `isPromotedDataCon`. Fixes #18020. - - - - - ce481361 by Ben Gamari at 2020-04-09T16:17:21-04:00 hadrian: Use --export-dynamic when linking iserv As noticed in #17962, the make build system currently does this (see 3ce0e0ba) but the change was never ported to Hadrian. - - - - - fa66f143 by Ben Gamari at 2020-04-09T16:17:21-04:00 iserv: Don't pass --export-dynamic on FreeBSD This is definitely a hack but it's probably the best we can do for now. Hadrian does the right thing here by passing --export-dynamic only to the linker. - - - - - 39075176 by Ömer Sinan Ağacan at 2020-04-09T16:18:00-04:00 Fix CNF handling in compacting GC Fixes #17937 Previously compacting GC simply ignored CNFs. This is mostly fine as most (see "What about small compacts?" below) CNF objects don't have outgoing pointers, and are "large" (allocated in large blocks) and large objects are not moved or compacted. However if we do GC *during* sharing-preserving compaction then the CNF will have a hash table mapping objects that have been moved to the CNF to their location in the CNF, to be able to preserve sharing. This case is handled in the copying collector, in `scavenge_compact`, where we evacuate hash table entries and then rehash the table. Compacting GC ignored this case. We now visit CNFs in all generations when threading pointers to the compacted heap and thread hash table keys. A visited CNF is added to the list `nfdata_chain`. After compaction is done, we re-visit the CNFs in that list and rehash the tables. The overhead is minimal: the list is static in `Compact.c`, and link field is added to `StgCompactNFData` closure. Programs that don't use CNFs should not be affected. To test this CNF tests are now also run in a new way 'compacting_gc', which just passes `-c` to the RTS, enabling compacting GC for the oldest generation. Before this patch the result would be: Unexpected failures: compact_gc.run compact_gc [bad exit code (139)] (compacting_gc) compact_huge_array.run compact_huge_array [bad exit code (1)] (compacting_gc) With this patch all tests pass. I can also pass `-c -DS` without any failures. What about small compacts? Small CNFs are still not handled by the compacting GC. However so far I'm unable to write a test that triggers a runtime panic ("update_fwd: unknown/strange object") by allocating a small CNF in a compated heap. It's possible that I'm missing something and it's not possible to have a small CNF. NoFib Results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS +0.1% 0.0% 0.0% +0.0% +0.0% CSD +0.1% 0.0% 0.0% 0.0% 0.0% FS +0.1% 0.0% 0.0% 0.0% 0.0% S +0.1% 0.0% 0.0% 0.0% 0.0% VS +0.1% 0.0% 0.0% 0.0% 0.0% VSD +0.1% 0.0% +0.0% +0.0% -0.0% VSM +0.1% 0.0% +0.0% -0.0% 0.0% anna +0.0% 0.0% -0.0% -0.0% -0.0% ansi +0.1% 0.0% +0.0% +0.0% +0.0% atom +0.1% 0.0% +0.0% +0.0% +0.0% awards +0.1% 0.0% +0.0% +0.0% +0.0% banner +0.1% 0.0% +0.0% +0.0% +0.0% bernouilli +0.1% 0.0% 0.0% -0.0% +0.0% binary-trees +0.1% 0.0% -0.0% -0.0% 0.0% boyer +0.1% 0.0% +0.0% +0.0% +0.0% boyer2 +0.1% 0.0% +0.0% +0.0% +0.0% bspt +0.1% 0.0% -0.0% -0.0% -0.0% cacheprof +0.1% 0.0% -0.0% -0.0% -0.0% calendar +0.1% 0.0% +0.0% +0.0% +0.0% cichelli +0.1% 0.0% +0.0% +0.0% +0.0% circsim +0.1% 0.0% +0.0% +0.0% +0.0% clausify +0.1% 0.0% -0.0% +0.0% +0.0% comp_lab_zift +0.1% 0.0% +0.0% +0.0% +0.0% compress +0.1% 0.0% +0.0% +0.0% 0.0% compress2 +0.1% 0.0% -0.0% 0.0% 0.0% constraints +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm1 +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm2 +0.1% 0.0% +0.0% +0.0% +0.0% cse +0.1% 0.0% +0.0% +0.0% +0.0% digits-of-e1 +0.1% 0.0% +0.0% -0.0% -0.0% digits-of-e2 +0.1% 0.0% -0.0% -0.0% -0.0% dom-lt +0.1% 0.0% +0.0% +0.0% +0.0% eliza +0.1% 0.0% +0.0% +0.0% +0.0% event +0.1% 0.0% +0.0% +0.0% +0.0% exact-reals +0.1% 0.0% +0.0% +0.0% +0.0% exp3_8 +0.1% 0.0% +0.0% -0.0% 0.0% expert +0.1% 0.0% +0.0% +0.0% +0.0% fannkuch-redux +0.1% 0.0% -0.0% 0.0% 0.0% fasta +0.1% 0.0% -0.0% +0.0% +0.0% fem +0.1% 0.0% -0.0% +0.0% 0.0% fft +0.1% 0.0% -0.0% +0.0% +0.0% fft2 +0.1% 0.0% +0.0% +0.0% +0.0% fibheaps +0.1% 0.0% +0.0% +0.0% +0.0% fish +0.1% 0.0% +0.0% +0.0% +0.0% fluid +0.0% 0.0% +0.0% +0.0% +0.0% fulsom +0.1% 0.0% -0.0% +0.0% 0.0% gamteb +0.1% 0.0% +0.0% +0.0% 0.0% gcd +0.1% 0.0% +0.0% +0.0% +0.0% gen_regexps +0.1% 0.0% -0.0% +0.0% 0.0% genfft +0.1% 0.0% +0.0% +0.0% +0.0% gg +0.1% 0.0% 0.0% +0.0% +0.0% grep +0.1% 0.0% -0.0% +0.0% +0.0% hidden +0.1% 0.0% +0.0% -0.0% 0.0% hpg +0.1% 0.0% -0.0% -0.0% -0.0% ida +0.1% 0.0% +0.0% +0.0% +0.0% infer +0.1% 0.0% +0.0% 0.0% -0.0% integer +0.1% 0.0% +0.0% +0.0% +0.0% integrate +0.1% 0.0% -0.0% -0.0% -0.0% k-nucleotide +0.1% 0.0% +0.0% +0.0% 0.0% kahan +0.1% 0.0% +0.0% +0.0% +0.0% knights +0.1% 0.0% -0.0% -0.0% -0.0% lambda +0.1% 0.0% +0.0% +0.0% -0.0% last-piece +0.1% 0.0% +0.0% 0.0% 0.0% lcss +0.1% 0.0% +0.0% +0.0% 0.0% life +0.1% 0.0% -0.0% +0.0% +0.0% lift +0.1% 0.0% +0.0% +0.0% +0.0% linear +0.1% 0.0% -0.0% +0.0% 0.0% listcompr +0.1% 0.0% +0.0% +0.0% +0.0% listcopy +0.1% 0.0% +0.0% +0.0% +0.0% maillist +0.1% 0.0% +0.0% -0.0% -0.0% mandel +0.1% 0.0% +0.0% +0.0% 0.0% mandel2 +0.1% 0.0% +0.0% +0.0% +0.0% mate +0.1% 0.0% +0.0% 0.0% +0.0% minimax +0.1% 0.0% -0.0% 0.0% -0.0% mkhprog +0.1% 0.0% +0.0% +0.0% +0.0% multiplier +0.1% 0.0% +0.0% 0.0% 0.0% n-body +0.1% 0.0% +0.0% +0.0% +0.0% nucleic2 +0.1% 0.0% +0.0% +0.0% +0.0% para +0.1% 0.0% 0.0% +0.0% +0.0% paraffins +0.1% 0.0% +0.0% -0.0% 0.0% parser +0.1% 0.0% -0.0% -0.0% -0.0% parstof +0.1% 0.0% +0.0% +0.0% +0.0% pic +0.1% 0.0% -0.0% -0.0% 0.0% pidigits +0.1% 0.0% +0.0% -0.0% -0.0% power +0.1% 0.0% +0.0% +0.0% +0.0% pretty +0.1% 0.0% -0.0% -0.0% -0.1% primes +0.1% 0.0% -0.0% -0.0% -0.0% primetest +0.1% 0.0% -0.0% -0.0% -0.0% prolog +0.1% 0.0% -0.0% -0.0% -0.0% puzzle +0.1% 0.0% -0.0% -0.0% -0.0% queens +0.1% 0.0% +0.0% +0.0% +0.0% reptile +0.1% 0.0% -0.0% -0.0% +0.0% reverse-complem +0.1% 0.0% +0.0% 0.0% -0.0% rewrite +0.1% 0.0% -0.0% -0.0% -0.0% rfib +0.1% 0.0% +0.0% +0.0% +0.0% rsa +0.1% 0.0% -0.0% +0.0% -0.0% scc +0.1% 0.0% -0.0% -0.0% -0.1% sched +0.1% 0.0% +0.0% +0.0% +0.0% scs +0.1% 0.0% +0.0% +0.0% +0.0% simple +0.1% 0.0% -0.0% -0.0% -0.0% solid +0.1% 0.0% +0.0% +0.0% +0.0% sorting +0.1% 0.0% -0.0% -0.0% -0.0% spectral-norm +0.1% 0.0% +0.0% +0.0% +0.0% sphere +0.1% 0.0% -0.0% -0.0% -0.0% symalg +0.1% 0.0% -0.0% -0.0% -0.0% tak +0.1% 0.0% +0.0% +0.0% +0.0% transform +0.1% 0.0% +0.0% +0.0% +0.0% treejoin +0.1% 0.0% +0.0% -0.0% -0.0% typecheck +0.1% 0.0% +0.0% +0.0% +0.0% veritas +0.0% 0.0% +0.0% +0.0% +0.0% wang +0.1% 0.0% 0.0% +0.0% +0.0% wave4main +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve1 +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve2 +0.1% 0.0% +0.0% +0.0% +0.0% x2n1 +0.1% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -0.0% -0.1% Max +0.1% 0.0% +0.0% +0.0% +0.0% Geometric Mean +0.1% -0.0% -0.0% -0.0% -0.0% Bumping numbers of nonsensical perf tests: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 It's simply not possible for this patch to increase allocations, and I've wasted enough time on these test in the past (see #17686). I think these tests should not be perf tests, but for now I'll bump the numbers. - - - - - dce50062 by Sylvain Henry at 2020-04-09T16:18:44-04:00 Rts: show errno on failure (#18033) - - - - - 045139f4 by Hécate at 2020-04-09T23:10:44-04:00 Add an example to liftIO and explain its purpose - - - - - 101fab6e by Sebastian Graf at 2020-04-09T23:11:21-04:00 Special case `isConstraintKindCon` on `AlgTyCon` Previously, the `tyConUnique` record selector would unfold into a huge case expression that would be inlined in all call sites, such as the `INLINE`-annotated `coreView`, see #18026. `constraintKindTyConKey` only occurs as the `Unique` of an `AlgTyCon` anyway, so we can make the code a lot more compact, but have to move it to GHC.Core.TyCon. Metric Decrease: T12150 T12234 - - - - - f5212dfc by Sebastian Graf at 2020-04-09T23:11:57-04:00 DmdAnal: No need to attach a StrictSig to DataCon workers In GHC.Types.Id.Make we were giving a strictness signature to every data constructor wrapper Id that we weren't looking at in demand analysis anyway. We used to use its CPR info, but that has its own CPR signature now. `Note [Data-con worker strictness]` then felt very out of place, so I moved it to GHC.Core.DataCon. - - - - - 75a185dc by Sylvain Henry at 2020-04-09T23:12:37-04:00 Hadrian: fix --summary - - - - - 723062ed by Ömer Sinan Ağacan at 2020-04-10T09:18:14+03:00 testsuite: Move no_lint to the top level, tweak hie002 - We don't want to benchmark linting so disable lints in hie002 perf test - Move no_lint to the top-level to be able to use it in tests other than those in `testsuite/tests/perf/compiler`. - Filter out -dstg-lint in no_lint. - hie002 allocation numbers on 32-bit are unstable, so skip it on 32-bit Metric Decrease: hie002 ManyConstructors T12150 T12234 T13035 T1969 T4801 T9233 T9961 - - - - - bcafaa82 by Peter Trommler at 2020-04-10T19:29:33-04:00 Testsuite: mark T11531 fragile The test depends on a link editor allowing undefined symbols in an ELF shared object. This is the standard but it seems some distributions patch their link editor. See the report by @hsyl20 in #11531. Fixes #11531 - - - - - 0889f5ee by Takenobu Tani at 2020-04-12T11:44:52+09:00 testsuite: Fix comment for a language extension [skip ci] - - - - - cd4f92b5 by Simon Peyton Jones at 2020-04-12T11:20:58-04:00 Significant refactor of Lint This refactoring of Lint was triggered by #17923, which is fixed by this patch. The main change is this. Instead of lintType :: Type -> LintM LintedKind we now have lintType :: Type -> LintM LintedType Previously, all of typeKind was effectively duplicate in lintType. Moreover, since we have an ambient substitution, we still had to apply the substition here and there, sometimes more than once. It was all very tricky, in the end, and made my head hurt. Now, lintType returns a fully linted type, with all substitutions performed on it. This is much simpler. The same thing is needed for Coercions. Instead of lintCoercion :: OutCoercion -> LintM (LintedKind, LintedKind, LintedType, LintedType, Role) we now have lintCoercion :: Coercion -> LintM LintedCoercion Much simpler! The code is shorter and less bug-prone. There are a lot of knock on effects. But life is now better. Metric Decrease: T1969 - - - - - 0efaf301 by Josh Meredith at 2020-04-12T11:21:34-04:00 Implement extensible interface files - - - - - 54ca66a7 by Ryan Scott at 2020-04-12T11:22:10-04:00 Use conLikeUserTyVarBinders to quantify field selector types This patch: 1. Writes up a specification for how the types of top-level field selectors should be determined in a new section of the GHC User's Guide, and 2. Makes GHC actually implement that specification by using `conLikeUserTyVarBinders` in `mkOneRecordSelector` to preserve the order and specificity of type variables written by the user. Fixes #18023. - - - - - 35799dda by Ben Gamari at 2020-04-12T11:22:50-04:00 hadrian: Don't --export-dynamic on Darwin When fixing #17962 I neglected to consider that --export-dynamic is only supported on ELF platforms. - - - - - e8029816 by Alexis King at 2020-04-12T11:23:27-04:00 Add an INLINE pragma to Control.Category.>>> This fixes #18013 by adding INLINE pragmas to both Control.Category.>>> and GHC.Desugar.>>>. The functional change in this patch is tiny (just two lines of pragmas!), but an accompanying Note explains in gory detail what’s going on. - - - - - 0da186c1 by Krzysztof Gogolewski at 2020-04-14T07:55:20-04:00 Change zipWith to zipWithEqual in a few places - - - - - 074c1ccd by Andreas Klebinger at 2020-04-14T07:55:55-04:00 Small change to the windows ticker. We already have a function to go from time to ms so use it. Also expand on the state of timer resolution. - - - - - b69cc884 by Alp Mestanogullari at 2020-04-14T07:56:38-04:00 hadrian: get rid of unnecessary levels of nesting in source-dist - - - - - d0c3b069 by Julien Debon at 2020-04-14T07:57:16-04:00 doc (Foldable): Add examples to Data.Foldable See #17929 - - - - - 5b08e0c0 by Ben Gamari at 2020-04-14T23:28:20-04:00 StgCRun: Enable unwinding only on Linux It's broken on macOS due and SmartOS due to assembler differences (#15207) so let's be conservative in enabling it. Also, refactor things to make the intent clearer. - - - - - 27cc2e7b by Ben Gamari at 2020-04-14T23:28:57-04:00 rts: Don't mark evacuate_large as inline This function has two callsites and is quite large. GCC consequently decides not to inline and warns instead. Given the situation, I can't blame it. Let's just remove the inline specifier. - - - - - 9853fc5e by Ben Gamari at 2020-04-14T23:29:48-04:00 base: Enable large file support for OFD locking impl. Not only is this a good idea in general but this should also avoid issue #17950 by ensuring that off_t is 64-bits. - - - - - 7b41f21b by Matthew Pickering at 2020-04-14T23:30:24-04:00 Hadrian: Make -i paths absolute The primary reason for this change is that ghcide does not work with relative paths. It also matches what cabal and stack do, they always pass absolute paths. - - - - - 41230e26 by Daniel Gröber at 2020-04-14T23:31:01-04:00 Zero out pinned block alignment slop when profiling The heap profiler currently cannot traverse pinned blocks because of alignment slop. This used to just be a minor annoyance as the whole block is accounted into a special cost center rather than the respective object's CCS, cf. #7275. However for the new root profiler we would like to be able to visit _every_ closure on the heap. We need to do this so we can get rid of the current 'flip' bit hack in the heap traversal code. Since info pointers are always non-zero we can in principle skip all the slop in the profiler if we can rely on it being zeroed. This assumption caused problems in the past though, commit a586b33f8e ("rts: Correct handling of LARGE ARR_WORDS in LDV profiler"), part of !1118, tried to use the same trick for BF_LARGE objects but neglected to take into account that shrink*Array# functions don't ensure that slop is zeroed when not compiling with profiling. Later, commit 0c114c6599 ("Handle large ARR_WORDS in heap census (fix as we will only be assuming slop is zeroed when profiling is on. This commit also reduces the ammount of slop we introduce in the first place by calculating the needed alignment before doing the allocation for small objects where we know the next available address. For large objects we don't know how much alignment we'll have to do yet since those details are hidden behind the allocateMightFail function so there we continue to allocate the maximum additional words we'll need to do the alignment. So we don't have to duplicate all this logic in the cmm code we pull it into the RTS allocatePinned function instead. Metric Decrease: T7257 haddock.Cabal haddock.base - - - - - 15fa9bd6 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Expand and add more notes regarding slop - - - - - caf3f444 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: allocatePinned: Fix confusion about word/byte units - - - - - c3c0f662 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Underline some Notes as is conventional - - - - - e149dea9 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Fix nomenclature in OVERWRITING_CLOSURE macros The additional commentary introduced by commit 8916e64e5437 ("Implement shrinkSmallMutableArray# and resizeSmallMutableArray#.") unfortunately got this wrong. We set 'prim' to true in overwritingClosureOfs because we _don't_ want to call LDV_recordDead(). The reason is because of this "inherently used" distinction made in the LDV profiler so I rename the variable to be more appropriate. - - - - - 1dd3d18c by Daniel Gröber at 2020-04-14T23:31:38-04:00 Remove call to LDV_RECORD_CREATE for array resizing - - - - - 19de2fb0 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Assert LDV_recordDead is not called for inherently used closures The comments make it clear LDV_recordDead should not be called for inhererently used closures, so add an assertion to codify this fact. - - - - - 0b934e30 by Ryan Scott at 2020-04-14T23:32:14-04:00 Bump template-haskell version to 2.17.0.0 This requires bumping the `exceptions` and `text` submodules to bring in commits that bump their respective upper version bounds on `template-haskell`. Fixes #17645. Fixes #17696. Note that the new `text` commit includes a fair number of additions to the Haddocks in that library. As a result, Haddock has to do more work during the `haddock.Cabal` test case, increasing the number of allocations it requires. Therefore, ------------------------- Metric Increase: haddock.Cabal ------------------------- - - - - - 22cc8e51 by Ryan Scott at 2020-04-15T17:48:47-04:00 Fix #18052 by using pprPrefixOcc in more places This fixes several small oversights in the choice of pretty-printing function to use. Fixes #18052. - - - - - ec77b2f1 by Daniel Gröber at 2020-04-15T17:49:24-04:00 rts: ProfHeap: Fix wrong time in last heap profile sample We've had this longstanding issue in the heap profiler, where the time of the last sample in the profile is sometimes way off causing the rendered graph to be quite useless for long runs. It seems to me the problem is that we use mut_user_time() for the last sample as opposed to getRTSStats(), which we use when calling heapProfile() in GC.c. The former is equivalent to getProcessCPUTime() but the latter does some additional stuff: getProcessCPUTime() - end_init_cpu - stats.gc_cpu_ns - stats.nonmoving_gc_cpu_ns So to fix this just use getRTSStats() in both places. - - - - - 85fc32f0 by Sylvain Henry at 2020-04-17T12:45:25-04:00 Hadrian: fix dyn_o/dyn_hi rule (#17534) - - - - - bfde3b76 by Ryan Scott at 2020-04-17T12:46:02-04:00 Fix #18065 by fixing an InstCo oversight in Core Lint There was a small thinko in Core Lint's treatment of `InstCo` coercions that ultimately led to #18065. The fix: add an apostrophe. That's it! Fixes #18065. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> - - - - - a05348eb by Cale Gibbard at 2020-04-17T13:08:47-04:00 Change the fail operator argument of BindStmt to be a Maybe Don't use noSyntaxExpr for it. There is no good way to defensively case on that, nor is it clear one ought to do so. - - - - - 79e27144 by John Ericson at 2020-04-17T13:08:47-04:00 Use trees that grow for rebindable operators for `<-` binds Also add more documentation. - - - - - 18bc16ed by Cale Gibbard at 2020-04-17T13:08:47-04:00 Use FailOperator in more places, define a couple datatypes (XBindStmtRn and XBindStmtTc) to help clarify the meaning of XBindStmt in the renamer and typechecker - - - - - 84cc8394 by Simon Peyton Jones at 2020-04-18T13:20:29-04:00 Add a missing zonk in tcHsPartialType I omitted a vital zonk when refactoring tcHsPartialType in commit 48fb3482f8cbc8a4b37161021e846105f980eed4 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Wed Jun 5 08:55:17 2019 +0100 Fix typechecking of partial type signatures This patch fixes it and adds commentary to explain why. Fixes #18008 - - - - - 2ee96ac1 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Bump FreeBSD bootstrap compiler to 8.10.1 - - - - - 434312e5 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Enable FreeBSD job for so-labelled MRs - - - - - ddffb227 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Use rules syntax for conditional jobs - - - - - e2586828 by Ben Gamari at 2020-04-18T13:21:05-04:00 Bump hsc2hs submodule - - - - - 15ab6cd5 by Ömer Sinan Ağacan at 2020-04-18T13:21:44-04:00 Improve prepForeignCall error reporting Show parameters and description of the error code when ffi_prep_cif fails. This may be helpful for debugging #17018. - - - - - 3ca52151 by Sylvain Henry at 2020-04-18T20:04:14+02:00 GHC.Core.Opt renaming * GHC.Core.Op => GHC.Core.Opt * GHC.Core.Opt.Simplify.Driver => GHC.Core.Opt.Driver * GHC.Core.Opt.Tidy => GHC.Core.Tidy * GHC.Core.Opt.WorkWrap.Lib => GHC.Core.Opt.WorkWrap.Utils As discussed in: * https://mail.haskell.org/pipermail/ghc-devs/2020-April/018758.html * https://gitlab.haskell.org/ghc/ghc/issues/13009#note_264650 - - - - - 15312bbb by Sylvain Henry at 2020-04-18T20:04:46+02:00 Modules (#13009) * SysTools * Parser * GHC.Builtin * GHC.Iface.Recomp * Settings Update Haddock submodule Metric Decrease: Naperian parsing001 - - - - - eaed0a32 by Alexis King at 2020-04-19T03:16:44-04:00 Add missing addInScope call for letrec binders in OccurAnal This fixes #18044, where a shadowed variable was incorrectly substituted by the binder swap on the RHS of a floated-in letrec. This can only happen when the uniques line up *just* right, so writing a regression test would be very difficult, but at least the fix is small and straightforward. - - - - - 36882493 by Shayne Fletcher at 2020-04-20T04:36:43-04:00 Derive Ord instance for Extension Metric Increase: T12150 T12234 - - - - - b43365ad by Simon Peyton Jones at 2020-04-20T04:37:20-04:00 Fix a buglet in redundant-constraint warnings Ticket #18036 pointed out that we were reporting a redundant constraint when it really really wasn't. Turned out to be a buglet in the SkolemInfo for the relevant implication constraint. Easily fixed! - - - - - d5fae7da by Ömer Sinan Ağacan at 2020-04-20T14:39:28-04:00 Mark T12010 fragile on 32-bit - - - - - bca02fca by Adam Sandberg Ericsson at 2020-04-21T06:38:45-04:00 docs: drop note about not supporting shared libraries on unix systems [skip ci] - - - - - 6655f933 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Use ParserFlags in GHC.Runtime.Eval (#17957) Instead of passing `DynFlags` to functions such as `isStmt` and `hasImport` in `GHC.Runtime.Eval` we pass `ParserFlags`. It's a much simpler structure that can be created purely with `mkParserFlags'`. - - - - - 70be0fbc by Sylvain Henry at 2020-04-21T06:39:32-04:00 GHC.Runtime: avoid DynFlags (#17957) * add `getPlatform :: TcM Platform` helper * remove unused `DynFlags` parameter from `emptyPLS` - - - - - 35e43d48 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid DynFlags in Ppr code (#17957) * replace `DynFlags` parameters with `SDocContext` parameters for a few Ppr related functions: `bufLeftRenderSDoc`, `printSDoc`, `printSDocLn`, `showSDocOneLine`. * remove the use of `pprCols :: DynFlags -> Int` in Outputable. We already have the information via `sdocLineLength :: SDocContext -> Int` - - - - - ce5c2999 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid using sdocWithDynFlags (#17957) Remove one use of `sdocWithDynFlags` from `GHC.CmmToLlvm.llvmCodeGen'` and from `GHC.Driver.CodeOutput.profilingInitCode` - - - - - f2a98996 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid `sdocWithDynFlags` in `pprCLbl` (#17957) * add a `DynFlags` parameter to `pprCLbl` * put `maybe_underscore` and `pprAsmCLbl` in a `where` clause to avoid `DynFlags` parameters - - - - - 747093b7 by Sylvain Henry at 2020-04-21T06:39:32-04:00 CmmToAsm DynFlags refactoring (#17957) * Remove `DynFlags` parameter from `isDynLinkName`: `isDynLinkName` used to test the global `ExternalDynamicRefs` flag. Now we test it outside of `isDynLinkName` * Add new fields into `NCGConfig`: current unit id, sse/bmi versions, externalDynamicRefs, etc. * Replace many uses of `DynFlags` by `NCGConfig` * Moved `BMI/SSE` datatypes into `GHC.Platform` - - - - - ffd7eef2 by Takenobu Tani at 2020-04-22T23:09:50-04:00 stg-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Stg/Syntax.hs <= stgSyn/StgSyn.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/CostCentre.hs <= profiling/CostCentre.hs This patch also updates old file path [2]: * utils/genapply/Main.hs <= utils/genapply/GenApply.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: commit 0cc4aad36f [skip ci] - - - - - e8a5d81b by Jonathan DK Gibbons at 2020-04-22T23:10:28-04:00 Refactor the `MatchResult` type in the desugarer This way, it does a better job of proving whether or not the fail operator is used. - - - - - dcb7fe5a by John Ericson at 2020-04-22T23:10:28-04:00 Remove panic in dsHandleMonadicFailure Rework dsHandleMonadicFailure to be correct by construction instead of using an unreachable panic. - - - - - cde23cd4 by John Ericson at 2020-04-22T23:10:28-04:00 Inline `adjustMatchResult` It is just `fmap` - - - - - 72cb6bcc by John Ericson at 2020-04-22T23:10:28-04:00 Generalize type of `matchCanFail` - - - - - 401f7bb3 by John Ericson at 2020-04-22T23:10:28-04:00 `MatchResult'` -> `MatchResult` Inline `MatchResult` alias accordingly. - - - - - 6c9fae23 by Alexis King at 2020-04-22T23:11:12-04:00 Mark DataCon wrappers CONLIKE Now that DataCon wrappers don’t inline until phase 0 (see commit b78cc64e923716ac0512c299f42d4d0012306c05), it’s important that case-of-known-constructor and RULE matching be able to see saturated applications of DataCon wrappers in unfoldings. Making them conlike is a natural way to do it, since they are, in fact, precisely the sort of thing the CONLIKE pragma exists to solve. Fixes #18012. This also bumps the version of the parsec submodule to incorporate a patch that avoids a metric increase on the haddock perf tests. The increase was not really a flaw in this patch, as parsec was implicitly relying on inlining heuristics. The patch to parsec just adds some INLINABLE pragmas, and we get a nice performance bump out of it (well beyond the performance we lost from this patch). Metric Decrease: T12234 WWRec haddock.Cabal haddock.base haddock.compiler - - - - - 48b8951e by Roland Senn at 2020-04-22T23:11:51-04:00 Fix tab-completion for :break (#17989) In tab-completion for the `:break` command, only those identifiers should be shown, that are accepted in the `:break` command. Hence these identifiers must be - defined in an interpreted module - top-level - currently in scope - listed in a `ModBreaks` value as a possible breakpoint. The identifiers my be qualified or unqualified. To get all possible top-level breakpoints for tab-completeion with the correct qualification do: 1. Build the list called `pifsBreaks` of all pairs of (Identifier, module-filename) from the `ModBreaks` values. Here all identifiers are unqualified. 2. Build the list called `pifInscope` of all pairs of (Identifiers, module-filename) with identifiers from the `GlobalRdrEnv`. Take only those identifiers that are in scope and have the correct prefix. Here the identifiers may be qualified. 3. From the `pifInscope` list seclect all pairs that can be found in the `pifsBreaks` list, by comparing only the unqualified part of the identifier. The remaining identifiers can be used for tab-completion. This ensures, that we show only identifiers, that can be used in a `:break` command. - - - - - 34a45ee6 by Peter Trommler at 2020-04-22T23:12:27-04:00 PPC NCG: Add DWARF constants and debug labels Fixes #11261 - - - - - ffde2348 by Simon Peyton Jones at 2020-04-22T23:13:06-04:00 Do eager instantation in terms This patch implements eager instantiation, a small but critical change to the type inference engine, #17173. The main change is this: When inferring types, always return an instantiated type (for now, deeply instantiated; in future shallowly instantiated) There is more discussion in https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html There is quite a bit of refactoring in this patch: * The ir_inst field of GHC.Tc.Utils.TcType.InferResultk has entirely gone. So tcInferInst and tcInferNoInst have collapsed into tcInfer. * Type inference of applications, via tcInferApp and tcInferAppHead, are substantially refactored, preparing the way for Quick Look impredicativity. * New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs are beatifully dual. We can see the zipper! * GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return a wrapper * In HsExpr, HsTypeApp now contains the the actual type argument, and is used in desugaring, rather than putting it in a mysterious wrapper. * I struggled a bit with good error reporting in Unify.matchActualFunTysPart. It's a little bit simpler than before, but still not great. Some smaller things * Rename tcPolyExpr --> tcCheckExpr tcMonoExpr --> tcLExpr * tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat Metric Decrease: T9961 Reduction of 1.6% in comiler allocation on T9961, I think. - - - - - 6f84aca3 by Ben Gamari at 2020-04-22T23:13:43-04:00 rts: Ensure that sigaction structs are initialized I noticed these may have uninitialized fields when looking into #18037. The reporter says that zeroing them doesn't fix the MSAN failures they observe but zeroing them is the right thing to do regardless. - - - - - c29f0fa6 by Andreas Klebinger at 2020-04-22T23:14:21-04:00 Add "ddump-cmm-opt" as alias for "ddump-opt-cmm". - - - - - 4b4a8b60 by Ben Gamari at 2020-04-22T23:14:57-04:00 llvmGen: Remove -fast-llvm flag Issue #18076 drew my attention to the undocumented `-fast-llvm` flag for the LLVM code generator introduced in 22733532171330136d87533d523f565f2a4f102f. Speaking to Moritz about this, the motivation for this flag was to avoid potential incompatibilities between LLVM and the assembler/linker toolchain by making LLVM responsible for machine-code generation. Unfortunately, this cannot possibly work: the LLVM backend's mangler performs a number of transforms on the assembler generated by LLVM that are necessary for correctness. These are currently: * mangling Haskell functions' symbol types to be `object` instead of `function` on ELF platforms (necessary for tables-next-to-code) * mangling AVX instructions to ensure that we don't assume alignment (which LLVM otherwise does) * mangling Darwin's subsections-via-symbols directives Given that these are all necessary I don't believe that we can support `-fast-llvm`. Let's rather remove it. - - - - - 831b6642 by Moritz Angermann at 2020-04-22T23:15:33-04:00 Fix build warning; add more informative information to the linker; fix linker for empty sections - - - - - c409961a by Ryan Scott at 2020-04-22T23:16:12-04:00 Update commentary and slightly refactor GHC.Tc.Deriv.Infer There was some out-of-date commentary in `GHC.Tc.Deriv.Infer` that has been modernized. Along the way, I removed the `bad` constraints in `simplifyDeriv`, which did not serve any useful purpose (besides being printed in debugging output). Fixes #18073. - - - - - 125aa2b8 by Ömer Sinan Ağacan at 2020-04-22T23:16:51-04:00 Remove leftover comment in tcRnModule', redundant bind The code for the comment was moved in dc8c03b2a5c but the comment was forgotten. - - - - - 8ea37b01 by Sylvain Henry at 2020-04-22T23:17:34-04:00 RTS: workaround a Linux kernel bug in timerfd Reading a timerfd may return 0: https://lkml.org/lkml/2019/8/16/335. This is currently undocumented behavior and documentation "won't happen anytime soon" (https://lkml.org/lkml/2020/2/13/295). With this patch, we just ignore the result instead of crashing. It may fix #18033 but we can't be sure because we don't have enough information. See also this discussion about the kernel bug: https://github.com/Azure/sonic-swss-common/pull/302/files/1f070e7920c2e5d63316c0105bf4481e73d72dc9 - - - - - cd8409c2 by Ryan Scott at 2020-04-23T11:39:24-04:00 Create di_scoped_tvs for associated data family instances properly See `Note [Associated data family instances and di_scoped_tvs]` in `GHC.Tc.TyCl.Instance`, which explains all of the moving parts. Fixes #18055. - - - - - 339e8ece by Ben Gamari at 2020-04-23T11:40:02-04:00 hadrian/ghci: Allow arguments to be passed to GHCi Previously the arguments passed to hadrian/ghci were passed both to `hadrian` and GHCi. This is rather odd given that there are essentially not arguments in the intersection of the two. Let's just pass them to GHCi; this allows `hadrian/ghci -Werror`. - - - - - 5946c85a by Ben Gamari at 2020-04-23T11:40:38-04:00 testsuite: Don't attempt to read .std{err,out} files if they don't exist Simon reports that he was previously seeing framework failures due to an attempt to read the non-existing T13456.stderr. While I don't know exactly what this is due to, it does seem like a non-existing .std{out,err} file should be equivalent to an empty file. Teach the testsuite driver to treat it as such. - - - - - c42754d5 by John Ericson at 2020-04-23T18:32:43-04:00 Trees That Grow refactor for `ConPat` and `CoPat` - `ConPat{In,Out}` -> `ConPat` - `CoPat` -> `XPat (CoPat ..)` Note that `GHC.HS.*` still uses `HsWrap`, but only when `p ~ GhcTc`. After this change, moving the type family instances out of `GHC.HS.*` is sufficient to break the cycle. Add XCollectPat class to decide how binders are collected from XXPat based on the pass. Previously we did this with IsPass, but that doesn't work for Haddock's DocNameI, and the constraint doesn't express what actual distinction is being made. Perhaps a class for collecting binders more generally is in order, but we haven't attempted this yet. Pure refactor of code around ConPat - InPat/OutPat synonyms removed - rename several identifiers - redundant constraints removed - move extension field in ConPat to be first - make ConPat use record syntax more consistently Fix T6145 (ConPatIn became ConPat) Add comments from SPJ. Add comment about haddock's use of CollectPass. Updates haddock submodule. - - - - - 72da0c29 by mniip at 2020-04-23T18:33:21-04:00 Add :doc to GHC.Prim - - - - - 2c23e2e3 by mniip at 2020-04-23T18:33:21-04:00 Include docs for non-primop entries in primops.txt as well - - - - - 0ac29c88 by mniip at 2020-04-23T18:33:21-04:00 GHC.Prim docs: note and test - - - - - b0fbfc75 by John Ericson at 2020-04-24T12:07:14-04:00 Switch order on `GhcMake.IsBoot` In !1798 we were requested to replace many `Bool`s with this data type. But those bools had `False` meaning `NotBoot`, so the `Ord` instance would be flipped if we use this data-type as-is. Since the planned formally-`Bool` occurrences vastly outnumber the current occurrences, we figured it would be better to conform the `Ord` instance to how the `Bool` is used now, fixing any issues, rather than fix them currently with the bigger refactor later in !1798. That way, !1798 can be a "pure" refactor with no behavioral changes. - - - - - af332442 by Sylvain Henry at 2020-04-26T13:55:14-04:00 Modules: Utils and Data (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - cd4434c8 by Sylvain Henry at 2020-04-26T13:55:16-04:00 Fix misleading Ptr phantom type in SerializedCompact (#15653) - - - - - 22bf5c73 by Ömer Sinan Ağacan at 2020-04-26T13:55:22-04:00 Tweak includes in non-moving GC headers We don't use hash tables in non-moving GC so remove the includes. This breaks Compact.c as existing includes no longer include Hash.h, so include Hash.h explicitly in Compact.c. - - - - - 99823ed2 by Sylvain Henry at 2020-04-27T20:24:46-04:00 TH: fix Show/Eq/Ord instances for Bytes (#16457) We shouldn't compare pointer values but the actual bytes. - - - - - c62271a2 by Alp Mestanogullari at 2020-04-27T20:25:33-04:00 hadrian: always capture both stdout and stderr when running a builder fails The idea being that when a builder('s command) fails, we quite likely want to have all the information available to figure out why. Depending on the builder _and_ the particular problem, the useful bits of information can be printed on stdout or stderr. We accomplish this by defining a simple wrapper for Shake's `cmd` function, that just _always_ captures both streams in case the command returns a non-zero exit code, and by using this wrapper everywhere in `hadrian/src/Builder.hs`. Fixes #18089. - - - - - 4b9764db by Ryan Scott at 2020-04-28T15:40:04-04:00 Define a Quote IO instance Fixes #18103. - - - - - 518a63d4 by Ryan Scott at 2020-04-28T15:40:42-04:00 Make boxed 1-tuples have known keys Unlike other tuples, which use special syntax and are "known" by way of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not use special syntax. Therefore, in order to make sure that the internals of GHC are aware of the `data Unit a = Unit a` definition in `GHC.Tuple`, we give `Unit` known keys. For the full details, see `Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)` in `GHC.Builtin.Types`. Fixes #18097. - - - - - 2cfc4ab9 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Document backpack fields in DynFlags - - - - - 10a2ba90 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo * Rename InstalledPackageInfo into GenericUnitInfo The name InstalledPackageInfo is only kept for alleged backward compatibility reason in Cabal. ghc-boot has its own stripped down copy of this datatype but it doesn't need to keep the name. Internally we already use type aliases (UnitInfo in GHC, PackageCacheFormat in ghc-pkg). * Rename UnitInfo fields: add "unit" prefix and fix misleading names * Add comments on every UnitInfo field * Rename SourcePackageId into PackageId "Package" already indicates that it's a "source package". Installed package components are called units. Update Haddock submodule - - - - - 69562e34 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Remove unused `emptyGenericUnitInfo` - - - - - 9e2c8e0e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo load/store from databases Converting between UnitInfo stored in package databases and UnitInfo as they are used in ghc-pkg and ghc was done in a very convoluted way (via BinaryStringRep and DbUnitModuleRep type classes using fun deps, etc.). It was difficult to understand and even more to modify (I wanted to try to use a GADT for UnitId but fun deps got in the way). The new code uses much more straightforward functions to convert between the different representations. Much simpler. - - - - - ea717aa4 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Factorize mungePackagePaths code This patch factorizes the duplicated code used in ghc-pkg and in GHC to munge package paths/urls. It also fixes haddock-html munging in GHC (allowed to be either a file or a url) to mimic ghc-pkg behavior. - - - - - 10d15f1e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactoring unit management code Over the years the unit management code has been modified a lot to keep up with changes in Cabal (e.g. support for several library components in the same package), to integrate BackPack, etc. I found it very hard to understand as the terminology wasn't consistent, was referring to past concepts, etc. The terminology is now explained as clearly as I could in the Note "About Units" and the code is refactored to reflect it. ------------------- Many names were misleading: UnitId is not an Id but could be a virtual unit (an indefinite one instantiated on the fly), IndefUnitId constructor may contain a definite instantiated unit, etc. * Rename IndefUnitId into InstantiatedUnit * Rename IndefModule into InstantiatedModule * Rename UnitId type into Unit * Rename IndefiniteUnitId constructor into VirtUnit * Rename DefiniteUnitId constructor into RealUnit * Rename packageConfigId into mkUnit * Rename getPackageDetails into unsafeGetUnitInfo * Rename InstalledUnitId into UnitId Remove references to misleading ComponentId: a ComponentId is just an indefinite unit-id to be instantiated. * Rename ComponentId into IndefUnitId * Rename ComponentDetails into UnitPprInfo * Fix display of UnitPprInfo with empty version: this is now used for units dynamically generated by BackPack Generalize several types (Module, Unit, etc.) so that they can be used with different unit identifier types: UnitKey, UnitId, Unit, etc. * GenModule: Module, InstantiatedModule and InstalledModule are now instances of this type * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit, PackageDatabase Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor. Add basic support for UnitKey. They should be used more in the future to avoid mixing them up with UnitId as we do now. Add many comments. Update Haddock submodule - - - - - 8bfb0219 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Unit: split and rename modules Introduce GHC.Unit.* hierarchy for everything concerning units, packages and modules. Update Haddock submodule - - - - - 71484b09 by Alexis King at 2020-04-30T01:57:35-04:00 Allow block arguments in arrow control operators Arrow control operators have their own entries in the grammar, so they did not cooperate with BlockArguments. This was just a minor oversight, so this patch adjusts the grammar to add the desired behavior. fixes #18050 - - - - - a48cd2a0 by Alexis King at 2020-04-30T01:57:35-04:00 Allow LambdaCase to be used as a command in proc notation - - - - - f4d3773c by Alexis King at 2020-04-30T01:57:35-04:00 Document BlockArguments/LambdaCase support in arrow notation - - - - - 5bdfdd13 by Simon Peyton Jones at 2020-04-30T01:58:15-04:00 Add tests for #17873 - - - - - 19b701c2 by Simon Peyton Jones at 2020-04-30T07:30:13-04:00 Mark rule args as non-tail-called This was just an omission...b I'd failed to call markAllNonTailCall on rule args. I think this bug has been here a long time, but it's quite hard to trigger. Fixes #18098 - - - - - 014ef4a3 by Matthew Pickering at 2020-04-30T07:30:50-04:00 Hadrian: Improve tool-args command to support more components There is a new command to hadrian, tool:path/to/file.hs, which returns the options needed to compile that file in GHCi. This is now used in the ghci script with argument `ghc/Main.hs` but its main purpose is to support the new multi-component branch of ghcide. - - - - - 2aa67611 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Clear bitmap after initializing block size Previously nonmovingInitSegment would clear the bitmap before initializing the segment's block size. This is broken since nonmovingClearBitmap looks at the segment's block size to determine how much bitmap to clear. - - - - - 54dad3cf by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Explicitly memoize block count A profile cast doubt on whether the compiler hoisted the bound out the loop as I would have expected here. It turns out it did but nevertheless it seems clearer to just do this manually. - - - - - 99ff8145 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Eagerly flush all capabilities' update remembered sets (cherry picked from commit 2fa79119570b358a4db61446396889b8260d7957) - - - - - 05b0a9fd by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 Remove OneShotInfo field of LFReEntrant, document OneShotInfo The field is only used in withNewTickyCounterFun and it's easier to directly pass a parameter for one-shot info to withNewTickyCounterFun instead of passing it via LFReEntrant. This also makes !2842 simpler. Other changes: - New Note (by SPJ) [OneShotInfo overview] added. - Arity argument of thunkCode removed as it's always 0. - - - - - a43620c6 by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 GHC.StgToCmm.Ticky: remove a few unused stuff - - - - - 780de9e1 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Use platform in Iface Binary - - - - - f8386c7b by Sylvain Henry at 2020-05-01T10:37:39-04:00 Refactor PprDebug handling If `-dppr-debug` is set, then PprUser and PprDump styles are silently replaced with PprDebug style. This was done in `mkUserStyle` and `mkDumpStyle` smart constructors. As a consequence they needed a DynFlags parameter. Now we keep the original PprUser and PprDump styles until they are used to create an `SDocContext`. I.e. the substitution is only performed in `initSDocContext`. - - - - - b3df9e78 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Remove PprStyle param of logging actions Use `withPprStyle` instead to apply a specific style to a SDoc. - - - - - de9fc995 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Fully remove PprDebug PprDebug was a pain to deal with consistently as it is implied by `-dppr-debug` but it isn't really a PprStyle. We remove it completely and query the appropriate SDoc flag instead (`sdocPprDebug`) via helpers (`getPprDebug` and its friends). - - - - - 8b51fcbd by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Only call checkSingle if we would report warnings - - - - - fd7ea0fe by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Pick up `EvVar`s bound in `HsWrapper`s for long-distance info `HsWrapper`s introduce evidence bindings through `WpEvLam` which the pattern-match coverage checker should be made aware of. Failing to do so caused #18049, where the resulting impreciseness of imcompleteness warnings seemingly contradicted with `-Winaccessible-code`. The solution is simple: Collect all the evidence binders of an `HsWrapper` and add it to the ambient `Deltas` before desugaring the wrapped expression. But that means we pick up many more evidence bindings, even when they wrap around code without a single pattern match to check! That regressed `T3064` by over 300%, so now we are adding long-distance info lazily through judicious use of `unsafeInterleaveIO`. Fixes #18049. - - - - - 7bfe9ac5 by Ben Gamari at 2020-05-03T04:41:33-04:00 rts: Enable tracing of nonmoving heap census with -ln Previously this was not easily available to the user. Fix this. Non-moving collection lifecycle events are now reported with -lg. - - - - - c560dd07 by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Move eventlog documentation users guide - - - - - 02543d5e by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Add documentation for non-moving GC events - - - - - b465dd45 by Alexis King at 2020-05-03T04:42:12-04:00 Flatten nested casts in the simple optimizer Normally, we aren’t supposed to generated any nested casts, since mkCast takes care to flatten them, but the simple optimizer didn’t use mkCast, so they could show up after inlining. This isn’t really a problem, since the simplifier will clean them up immediately anyway, but it can clutter the -ddump-ds output, and it’s an extremely easy fix. closes #18112 - - - - - 8bdc03d6 by Simon Peyton Jones at 2020-05-04T01:56:59-04:00 Don't return a panic in tcNestedSplice In GHC.Tc.Gen.Splice.tcNestedSplice we were returning a typechecked expression of "panic". That is usually OK, because the result is discarded. But it happens that tcApp now looks at the typechecked expression, trivially, to ask if it is tagToEnum. So being bottom is bad. Moreover a debug-trace might print it out. So better to return a civilised expression, even though it is usually discarded. - - - - - 0bf640b1 by Baldur Blöndal at 2020-05-04T01:57:36-04:00 Don't require parentheses around via type (`-XDerivingVia'). Fixes #18130". - - - - - 30272412 by Artem Pelenitsyn at 2020-05-04T13:19:59-04:00 Remove custom ExceptionMonad class (#18075) (updating haddock submodule accordingly) - - - - - b9f7c08f by jneira at 2020-05-04T13:20:37-04:00 Remove unused hs-boot file - - - - - 1d8f80cd by Sylvain Henry at 2020-05-05T03:22:46-04:00 Remove references to -package-key * remove references to `-package-key` which has been removed in 2016 (240ddd7c39536776e955e881d709bbb039b48513) * remove support for `-this-package-key` which has been deprecated at the same time - - - - - 7bc3a65b by Sylvain Henry at 2020-05-05T03:23:31-04:00 Remove SpecConstrAnnotation (#13681) This has been deprecated since 2013. Use GHC.Types.SPEC instead. Make GHC.Exts "not-home" for haddock Metric Decrease: haddock.base - - - - - 3c862f63 by DenisFrezzato at 2020-05-05T03:24:15-04:00 Fix Haskell98 short description in documentation - - - - - 2420c555 by Ryan Scott at 2020-05-05T03:24:53-04:00 Add regression tests for #16244, #16245, #16758 Commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70 ended up fixing quite a few bugs: * This commit fixes #16244 completely. A regression test has been added. * This commit fixes one program from #16245. (The program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211369 still panics, and the program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211400 still loops infinitely.) A regression test has been added for this program. * This commit fixes #16758. Accordingly, this patch removes the `expect_broken` label from the `T16758` test case, moves it from `should_compile` to `should_fail` (as it should produce an error message), and checks in the expected stderr. - - - - - 40c71c2c by Sylvain Henry at 2020-05-05T03:25:31-04:00 Fix colorized error messages (#18128) In b3df9e780fb2f5658412c644849cd0f1e6f50331 I broke colorized messages by using "dump" style instead of "user" style. This commits fixes it. - - - - - 7ab6ab09 by Richard Eisenberg at 2020-05-06T04:39:32-04:00 Refactor hole constraints. Previously, holes (both expression holes / out of scope variables and partial-type-signature wildcards) were emitted as *constraints* via the CHoleCan constructor. While this worked fine for error reporting, there was a fair amount of faff in keeping these constraints in line. In particular, and unlike other constraints, we could never change a CHoleCan to become CNonCanonical. In addition: * the "predicate" of a CHoleCan constraint was really the type of the hole, which is not a predicate at all * type-level holes (partial type signature wildcards) carried evidence, which was never used * tcNormalise (used in the pattern-match checker) had to create a hole constraint just to extract it again; it was quite messy The new approach is to record holes directly in WantedConstraints. It flows much more nicely now. Along the way, I did some cleaning up of commentary in GHC.Tc.Errors.Hole, which I had a hard time understanding. This was instigated by a future patch that will refactor the way predicates are handled. The fact that CHoleCan's "predicate" wasn't really a predicate is incompatible with that future patch. No test case, because this is meant to be purely internal. It turns out that this change improves the performance of the pattern-match checker, likely because fewer constraints are sloshing about in tcNormalise. I have not investigated deeply, but an improvement is not a surprise here: ------------------------- Metric Decrease: PmSeriesG ------------------------- - - - - - 420b957d by Ben Gamari at 2020-05-06T04:40:08-04:00 rts: Zero block flags with -DZ Block flags are very useful for determining the state of a block. However, some block allocator users don't touch them, leading to misleading values. Ensure that we zero then when zero-on-gc is set. This is safe and makes the flags more useful during debugging. - - - - - 740b3b8d by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix incorrect failed_to_evac value during deadlock gc Previously we would incorrectly set the failed_to_evac flag if we evacuated a value due to a deadlock GC. This would cause us to mark more things as dirty than strictly necessary. It also turned up a nasty but which I will fix next. - - - - - b2d72c75 by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix handling of dirty objects Previously we (incorrectly) relied on failed_to_evac to be "precise". That is, we expected it to only be true if *all* of an object's fields lived outside of the non-moving heap. However, does not match the behavior of failed_to_evac, which is true if *any* of the object's fields weren't promoted (meaning that some others *may* live in the non-moving heap). This is problematic as we skip the non-moving write barrier for dirty objects (which we can only safely do if *all* fields point outside of the non-moving heap). Clearly this arises due to a fundamental difference in the behavior expected of failed_to_evac in the moving and non-moving collector. e.g., in the moving collector it is always safe to conservatively say failed_to_evac=true whereas in the non-moving collector the safe value is false. This issue went unnoticed as I never wrote down the dirtiness invariant enforced by the non-moving collector. We now define this invariant as An object being marked as dirty implies that all of its fields are on the mark queue (or, equivalently, update remembered set). To maintain this invariant we teach nonmovingScavengeOne to push the fields of objects which we fail to evacuate to the update remembered set. This is a simple and reasonably cheap solution and avoids the complexity and fragility that other, more strict alternative invariants would require. All of this is described in a new Note, Note [Dirty flags in the non-moving collector] in NonMoving.c. - - - - - 9f3e6884 by Zubin Duggal at 2020-05-06T04:41:08-04:00 Allow atomic update of NameCache in readHieFile The situation arises in ghcide where multiple different threads may need to update the name cache, therefore with the older interface it could happen that you start reading a hie file with name cache A and produce name cache A + B, but another thread in the meantime updated the namecache to A + C. Therefore if you write the new namecache you will lose the A' updates from the second thread. Updates haddock submodule - - - - - edec6a6c by Ryan Scott at 2020-05-06T04:41:57-04:00 Make isTauTy detect higher-rank contexts Previously, `isTauTy` would only detect higher-rank `forall`s, not higher-rank contexts, which led to some minor bugs observed in #18127. Easily fixed by adding a case for `(FunTy InvisArg _ _)`. Fixes #18127. - - - - - a95e7fe0 by Ömer Sinan Ağacan at 2020-05-06T04:42:39-04:00 ELF linker: increment curSymbol after filling in fields of current entry The bug was introduced in a8b7cef4d45 which added a field to the `symbols` array elements and then updated this code incorrectly: - oc->symbols[curSymbol++] = nm; + oc->symbols[curSymbol++].name = nm; + oc->symbols[curSymbol].addr = symbol->addr; - - - - - cab1871a by Sylvain Henry at 2020-05-06T04:43:21-04:00 Move LeadingUnderscore into Platform (#17957) Avoid direct use of DynFlags to know if symbols must be prefixed by an underscore. - - - - - 94e7c563 by Sylvain Henry at 2020-05-06T04:43:21-04:00 Don't use DynFlags in showLinkerState (#17957) - - - - - 9afd9251 by Ryan Scott at 2020-05-06T04:43:58-04:00 Refactoring: Use bindSigTyVarsFV in rnMethodBinds `rnMethodBinds` was explicitly using `xoptM` to determine if `ScopedTypeVariables` is enabled before bringing type variables bound by the class/instance header into scope. However, this `xoptM` logic is already performed by the `bindSigTyVarsFV` function. This patch uses `bindSigTyVarsFV` in `rnMethodBinds` to reduce the number of places where we need to consult if `ScopedTypeVariables` is on. This is purely refactoring, and there should be no user-visible change in behavior. - - - - - 6f6d72b2 by Brian Foley at 2020-05-08T15:29:25-04:00 Remove further dead code found by a simple Python script. Avoid removing some functions that are part of an API even though they're not used in-tree at the moment. - - - - - 78bf8bf9 by Julien Debon at 2020-05-08T15:29:28-04:00 Add doc examples for Bifoldable See #17929 - - - - - 66f0a847 by Julien Debon at 2020-05-08T15:29:29-04:00 doc (Bitraversable): Add examples to Bitraversable * Add examples to Data.Bitraversable * Fix formatting for (,) in Bitraversable and Bifoldable * Fix mistake on bimapAccumR documentation See #17929 - - - - - 9749fe12 by Baldur Blöndal at 2020-05-08T15:29:32-04:00 Specify kind variables for inferred kinds in base. - - - - - 4e9aef9e by John Ericson at 2020-05-08T15:29:36-04:00 HsSigWcTypeScoping: Pull in documentation from stray location - - - - - f4d5c6df by John Ericson at 2020-05-08T15:29:36-04:00 Rename local `real_fvs` to `implicit_vs` It doesn't make sense to call the "free" variables we are about to implicitly bind the real ones. - - - - - 20570b4b by John Ericson at 2020-05-08T15:29:36-04:00 A few tiny style nits with renaming - Use case rather than guards that repeatedly scrutenize same thing. - No need for view pattern when `L` is fine. - Use type synnonym to convey the intent like elsewhere. - - - - - 09ac8de5 by John Ericson at 2020-05-08T15:29:36-04:00 Add `forAllOrNothing` function with note - - - - - bb35c0e5 by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Document lawlessness of Ap's Num instance - - - - - cdd229ff by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply suggestion to libraries/base/Data/Monoid.hs - - - - - 926d2aab by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply more suggestions from Simon Jakobi - - - - - 7a763cff by Adam Gundry at 2020-05-08T15:29:41-04:00 Reject all duplicate declarations involving DuplicateRecordFields (fixes #17965) This fixes a bug that resulted in some programs being accepted that used the same identifier as a field label and another declaration, depending on the order they appeared in the source code. - - - - - 88e3c815 by Simon Peyton Jones at 2020-05-08T15:29:41-04:00 Fix specialisation for DFuns When specialising a DFun we must take care to saturate the unfolding. See Note [Specialising DFuns] in Specialise. Fixes #18120 - - - - - 86c77b36 by Greg Steuck at 2020-05-08T15:29:45-04:00 Remove unused SEGMENT_PROT_RWX It's been unused for a year and is problematic on any OS which requires W^X for security. - - - - - 9d97f4b5 by nineonine at 2020-05-08T15:30:03-04:00 Add test for #16167 - - - - - aa318338 by Ryan Scott at 2020-05-08T15:30:04-04:00 Bump exceptions submodule so that dist-boot is .gitignore'd `exceptions` is a stage-0 boot library as of commit 30272412fa437ab8e7a8035db94a278e10513413, which means that building `exceptions` in a GHC tree will generate a `dist-boot` directory. However, this directory was not specified in `exceptions`' `.gitignore` file, which causes it to dirty up the current `git` working directory. Accordingly, this bumps the `exceptions` submodule to commit ghc/packages/exceptions at 23c0b8a50d7592af37ca09beeec16b93080df98f, which adds `dist-boot` to the `.gitignore` file. - - - - - ea86360f by Ömer Sinan Ağacan at 2020-05-08T15:30:30-04:00 Linker.c: initialize n_symbols of ObjectCode with other fields - - - - - 951c1fb0 by Sylvain Henry at 2020-05-09T21:46:38-04:00 Fix unboxed-sums GC ptr-slot rubbish value (#17791) This patch allows boot libraries to use unboxed sums without implicitly depending on `base` package because of `absentSumFieldError`. See updated Note [aBSENT_SUM_FIELD_ERROR_ID] in GHC.Core.Make - - - - - b352d63c by Ben Gamari at 2020-05-09T21:47:14-04:00 rts: Make non-existent linker search path merely a warning As noted in #18105, previously this resulted in a rather intrusive error message. This is in contrast to the general expectation that search paths are merely places to look, not places that must exist. Fixes #18105. - - - - - cf4f1e2f by Ben Gamari at 2020-05-13T02:02:33-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 - - - - - a03da9bf by Ömer Sinan Ağacan at 2020-05-13T02:03:16-04:00 Pack some of IdInfo fields into a bit field This reduces residency of compiler quite a bit on some programs. Example stats when building T10370: Before: 2,871,242,832 bytes allocated in the heap 4,693,328,008 bytes copied during GC 33,941,448 bytes maximum residency (276 sample(s)) 375,976 bytes maximum slop 83 MiB total memory in use (0 MB lost due to fragmentation) After: 2,858,897,344 bytes allocated in the heap 4,629,255,440 bytes copied during GC 32,616,624 bytes maximum residency (278 sample(s)) 314,400 bytes maximum slop 80 MiB total memory in use (0 MB lost due to fragmentation) So -3.9% residency, -1.3% bytes copied and -0.4% allocations. Fixes #17497 Metric Decrease: T9233 T9675 - - - - - 670c3e5c by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Fix base URL Revert a change previously made for testing purposes. - - - - - 8ad8dc41 by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Improve diagnostics output - - - - - 8c0740b7 by Simon Jakobi at 2020-05-13T02:04:33-04:00 docs: Add examples for Data.Semigroup.Arg{Min,Max} Context: #17153 - - - - - cb22348f by Ben Gamari at 2020-05-13T02:05:11-04:00 Add few cleanups of the CAF logic Give the NameSet of non-CAFfy names a proper newtype to distinguish it from all of the other NameSets floating about. - - - - - 90e38b81 by Emeka Nkurumeh at 2020-05-13T02:05:51-04:00 fix printf warning when using with ghc with clang on mingw - - - - - 86d8ac22 by Sebastian Graf at 2020-05-13T02:06:29-04:00 CprAnal: Don't attach CPR sigs to expandable bindings (#18154) Instead, look through expandable unfoldings in `cprTransform`. See the new Note [CPR for expandable unfoldings]: ``` Long static data structures (whether top-level or not) like xs = x1 : xs1 xs1 = x2 : xs2 xs2 = x3 : xs3 should not get CPR signatures, because they * Never get WW'd, so their CPR signature should be irrelevant after analysis (in fact the signature might even be harmful for that reason) * Would need to be inlined/expanded to see their constructed product * Recording CPR on them blows up interface file sizes and is redundant with their unfolding. In case of Nested CPR, this blow-up can be quadratic! But we can't just stop giving DataCon application bindings the CPR property, for example fac 0 = 1 fac n = n * fac (n-1) fac certainly has the CPR property and should be WW'd! But FloatOut will transform the first clause to lvl = 1 fac 0 = lvl If lvl doesn't have the CPR property, fac won't either. But lvl doesn't have a CPR signature to extrapolate into a CPR transformer ('cprTransform'). So instead we keep on cprAnal'ing through *expandable* unfoldings for these arity 0 bindings via 'cprExpandUnfolding_maybe'. In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one for each data declaration. It's wasteful to attach CPR signatures to each of them (and intractable in case of Nested CPR). ``` Fixes #18154. - - - - - e34bf656 by Ben Gamari at 2020-05-13T02:07:08-04:00 users-guide: Add discussion of shared object naming Fixes #18074. - - - - - 5d0f2445 by Ben Gamari at 2020-05-13T02:07:47-04:00 testsuite: Print sign of performance changes Executes the minor formatting change in the tabulated performance changes suggested in #18135. - - - - - 9e4b981f by Ben Gamari at 2020-05-13T02:08:24-04:00 testsuite: Add testcase for #18129 - - - - - 266310c3 by Ivan-Yudin at 2020-05-13T02:09:03-04:00 doc: Reformulate the opening paragraph of Ch. 4 in User's guide Removes mentioning of Hugs (it is not helpful for new users anymore). Changes the wording for the rest of the paragraph. Fixes #18132. - - - - - 55e35c0b by Baldur Blöndal at 2020-05-13T20:02:48-04:00 Predicate, Equivalence derive via `.. -> a -> All' - - - - - d7e0b57f by Alp Mestanogullari at 2020-05-13T20:03:30-04:00 hadrian: add a --freeze2 option to freeze stage 1 and 2 - - - - - d880d6b2 by Artem Pelenitsyn at 2020-05-13T20:04:11-04:00 Don't reload environment files on every setSessionDynFlags Makes `interpretPackageEnv` (which loads envirinment files) a part of `parseDynamicFlags` (parsing command-line arguments, which is typically done once) instead of `setSessionDynFlags` (which is typically called several times). Making several (transitive) calls to `interpretPackageEnv`, as before, caused #18125 #16318, which should be fixed now. - - - - - 102cfd67 by Ryan Scott at 2020-05-13T20:04:46-04:00 Factor out HsPatSigType for pat sigs/RULE term sigs (#16762) This implements chunks (2) and (3) of https://gitlab.haskell.org/ghc/ghc/issues/16762#note_270170. Namely, it introduces a dedicated `HsPatSigType` AST type, which represents the types that can appear in pattern signatures and term-level `RULE` binders. Previously, these were represented with `LHsSigWcType`. Although `LHsSigWcType` is isomorphic to `HsPatSigType`, the intended semantics of the two types are slightly different, as evidenced by the fact that they have different code paths in the renamer and typechecker. See also the new `Note [Pattern signature binders and scoping]` in `GHC.Hs.Types`. - - - - - b17574f7 by Hécate at 2020-05-13T20:05:28-04:00 fix(documentation): Fix the RST links to GHC.Prim - - - - - df021fb1 by Baldur Blöndal at 2020-05-13T20:06:06-04:00 Document (->) using inferred quantification for its runtime representations. Fixes #18142. - - - - - 1a93ea57 by Takenobu Tani at 2020-05-13T20:06:54-04:00 Tweak man page for ghc command This commit updates the ghc command's man page as followings: * Enable `man_show_urls` to show URL addresses in the `DESCRIPTION` section of ghc.rst, because sphinx currently removes hyperlinks for man pages. * Add a `SEE ALSO` section to point to the GHC homepage - - - - - a951e1ba by Takenobu Tani at 2020-05-13T20:07:37-04:00 GHCi: Add link to the user's guide in help message This commit adds a link to the user's guide in ghci's `:help` message. Newcomers could easily reach to details of ghci. - - - - - 404581ea by Jeff Happily at 2020-05-13T20:08:15-04:00 Handle single unused import - - - - - 1c999e5d by Ben Gamari at 2020-05-13T20:09:07-04:00 Ensure that printMinimalImports closes handle Fixes #18166. - - - - - c9f5a8f4 by Ben Gamari at 2020-05-13T20:09:51-04:00 hadrian: Tell testsuite driver about LLVM availability This reflects the logic present in the Make build system into Hadrian. Fixes #18167. - - - - - c05c0659 by Simon Jakobi at 2020-05-14T03:31:21-04:00 Improve some folds over Uniq[D]FM * Replace some non-deterministic lazy folds with strict folds. * Replace some O(n log n) folds in deterministic order with O(n) non-deterministic folds. * Replace some folds with set-operations on the underlying IntMaps. This reduces max residency when compiling `nofib/spectral/simple/Main.hs` with -O0 by about 1%. Maximum residency when compiling Cabal also seems reduced on the order of 3-9%. - - - - - 477f13bb by Simon Jakobi at 2020-05-14T03:31:58-04:00 Use Data.IntMap.disjoint Data.IntMap gained a dedicated `disjoint` function in containers-0.6.2.1. This patch applies this function where appropriate in hopes of modest compiler performance improvements. Closes #16806. - - - - - e9c0110c by Ben Gamari at 2020-05-14T12:25:53-04:00 IdInfo: Add reference to bitfield-packing ticket - - - - - 9bd20e83 by Sebastian Graf at 2020-05-15T10:42:09-04:00 DmdAnal: Improve handling of precise exceptions This patch does two things: Fix possible unsoundness in what was called the "IO hack" and implement part 2.1 of the "fixing precise exceptions" plan in https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions, which, in combination with !2956, supersedes !3014 and !2525. **IO hack** The "IO hack" (which is a fallback to preserve precise exceptions semantics and thus soundness, rather than some smart thing that increases precision) is called `exprMayThrowPreciseException` now. I came up with two testcases exemplifying possible unsoundness (if twisted enough) in the old approach: - `T13380d`: Demonstrating unsoundness of the "IO hack" when resorting to manual state token threading and direct use of primops. More details below. - `T13380e`: Demonstrating unsoundness of the "IO hack" when we have Nested CPR. Not currently relevant, as we don't have Nested CPR yet. - `T13380f`: Demonstrating unsoundness of the "IO hack" for safe FFI calls. Basically, the IO hack assumed that precise exceptions can only be thrown from a case scrutinee of type `(# State# RealWorld, _ #)`. I couldn't come up with a program using the `IO` abstraction that violates this assumption. But it's easy to do so via manual state token threading and direct use of primops, see `T13380d`. Also similar code might be generated by Nested CPR in the (hopefully not too) distant future, see `T13380e`. Hence, we now have a more careful test in `forcesRealWorld` that passes `T13380{d,e}` (and will hopefully be robust to Nested CPR). **Precise exceptions** In #13380 and #17676 we saw that we didn't preserve precise exception semantics in demand analysis. We fixed that with minimal changes in !2956, but that was terribly unprincipled. That unprincipledness resulted in a loss of precision, which is tracked by these new test cases: - `T13380b`: Regression in dead code elimination, because !2956 was too syntactic about `raiseIO#` - `T13380c`: No need to apply the "IO hack" when the IO action may not throw a precise exception (and the existing IO hack doesn't detect that) Fixing both issues in !3014 turned out to be too complicated and had the potential to regress in the future. Hence we decided to only fix `T13380b` and augment the `Divergence` lattice with a new middle-layer element, `ExnOrDiv`, which means either `Diverges` (, throws an imprecise exception) or throws a *precise* exception. See the wiki page on Step 2.1 for more implementational details: https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions#dead-code-elimination-for-raiseio-with-isdeadenddiv-introducing-exnordiv-step-21 - - - - - 568d7279 by Ben Gamari at 2020-05-15T10:42:46-04:00 GHC.Cmm.Opt: Handle MO_XX_Conv This MachOp was introduced by 2c959a1894311e59cd2fd469c1967491c1e488f3 but a wildcard match in cmmMachOpFoldM hid the fact that it wasn't handled. Ideally we would eliminate the match but this appears to be a larger task. Fixes #18141. - - - - - 5bcf8606 by Ryan Scott at 2020-05-17T08:46:38-04:00 Remove duplicate Note [When to print foralls] in GHC.Core.TyCo.Ppr There are two different Notes named `[When to print foralls]`. The most up-to-date one is in `GHC.Iface.Type`, but there is a second one in `GHC.Core.TyCo.Ppr`. The latter is less up-to-date, as it was written before GHC switched over to using ifaces to pretty-print types. I decided to just remove the latter and replace it with a reference to the former. [ci skip] - - - - - 55f0e783 by Fumiaki Kinoshita at 2020-05-21T12:10:44-04:00 base: Add Generic instances to various datatypes under GHC.* * GHC.Fingerprint.Types: Fingerprint * GHC.RTS.Flags: GiveGCStats, GCFlags, ConcFlags, DebugFlags, CCFlags, DoHeapProfile, ProfFlags, DoTrace, TraceFlags, TickyFlags, ParFlags and RTSFlags * GHC.Stats: RTSStats and GCStats * GHC.ByteOrder: ByteOrder * GHC.Unicode: GeneralCategory * GHC.Stack.Types: SrcLoc Metric Increase: haddock.base - - - - - a9311cd5 by Gert-Jan Bottu at 2020-05-21T12:11:31-04:00 Explicit Specificity Implementation for Ticket #16393. Explicit specificity allows users to manually create inferred type variables, by marking them with braces. This way, the user determines which variables can be instantiated through visible type application. The additional syntax is included in the parser, allowing users to write braces in type variable binders (type signatures, data constructors etc). This information is passed along through the renamer and verified in the type checker. The AST for type variable binders, data constructors, pattern synonyms, partial signatures and Template Haskell has been updated to include the specificity of type variables. Minor notes: - Bumps haddock submodule - Disables pattern match checking in GHC.Iface.Type with GHC 8.8 - - - - - 24e61aad by Ben Price at 2020-05-21T12:12:17-04:00 Lint should say when it is checking a rule It is rather confusing that when lint finds an error in a rule attached to a binder, it reports the error as in the RHS, not the rule: ... In the RHS of foo We add a clarifying line: ... In the RHS of foo In a rule attached to foo The implication that the rule lives inside the RHS is a bit odd, but this niggle is already present for unfoldings, whose pattern we are following. - - - - - 78c6523c by Ben Gamari at 2020-05-21T12:13:01-04:00 nonmoving: Optimise the write barrier - - - - - 13f6c9d0 by Andreas Klebinger at 2020-05-21T12:13:45-04:00 Refactor linear reg alloc to remember past assignments. When assigning registers we now first try registers we assigned to in the past, instead of picking the "first" one. This is in extremely helpful when dealing with loops for which variables are dead for part of the loop. This is important for patterns like this: foo = arg1 loop: use(foo) ... foo = getVal() goto loop; There we: * assign foo to the register of arg1. * use foo, it's dead after this use as it's overwritten after. * do other things. * look for a register to put foo in. If we pick an arbitrary one it might differ from the register the start of the loop expect's foo to be in. To fix this we simply look for past register assignments for the given variable. If we find one and the register is free we use that register. This reduces the need for fixup blocks which match the register assignment between blocks. In the example above between the end and the head of the loop. This patch also moves branch weight estimation ahead of register allocation and adds a flag to control it (cmm-static-pred). * It means the linear allocator is more likely to assign the hotter code paths first. * If it assign these first we are: + Less likely to spill on the hot path. + Less likely to introduce fixup blocks on the hot path. These two measure combined are surprisingly effective. Based on nofib we get in the mean: * -0.9% instructions executed * -0.1% reads/writes * -0.2% code size. * -0.1% compiler allocations. * -0.9% compile time. * -0.8% runtime. Most of the benefits are simply a result of removing redundant moves and spills. Reduced compiler allocations likely are the result of less code being generated. (The added lookup is mostly non-allocating). - - - - - edc2cc58 by Andreas Klebinger at 2020-05-21T12:14:25-04:00 NCG: Codelayout: Distinguish conditional and other branches. In #18053 we ended up with a suboptimal code layout because the code layout algorithm didn't distinguish between conditional and unconditional control flow. We can completely eliminate unconditional control flow instructions by placing blocks next to each other, not so much for conditionals. In terms of implementation we simply give conditional branches less weight before computing the layout. Fixes #18053 - - - - - b7a6b2f4 by Gleb Popov at 2020-05-21T12:15:26-04:00 gitlab-ci: Set locale to C.UTF-8. - - - - - a8c27cf6 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow spaces in GHCi :script file names This patch updates the user interface of GHCi so that file names passed to the ':script' command may contain spaces escaped with a backslash. For example: :script foo\ bar.script The implementation uses a modified version of 'words' that does not break on escaped spaces. Fixes #18027. - - - - - 82663959 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Add extra tests for GHCi :script syntax checks The syntax for GHCi's ":script" command allows for only a single file name to be passed as an argument. This patch adds a test for the cases in which a file name is missing or multiple file names are passed. Related to #T18027. - - - - - a0b79e1b by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow GHCi :script file names in double quotes This patch updates the user interface of GHCi so that file names passed to the ':script' command can be wrapped in double quotes. For example: :script "foo bar.script" The implementation uses a modified version of 'words' that treats character sequences enclosed in double quotes as single words. Fixes #18027. - - - - - cf566330 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Update documentation for GHCi :script This patch adds the fixes that allow for file names containing spaces to be passed to GHCi's ':script' command to the release notes for 8.12 and expands the user-guide documentation for ':script' by mentioning how such file names can be passed. Related to #18027. - - - - - 0004ccb8 by Tuan Le at 2020-05-21T12:16:46-04:00 llvmGen: Consider Relocatable read-only data as not constantReferences: #18137 - - - - - 964d3ea2 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_pat` - - - - - b797aa42 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_lpat` and `tc_lpats` - - - - - 5108e84a by John Ericson at 2020-05-21T12:17:30-04:00 More judiciously panic in `ts_pat` - - - - - 510e0451 by John Ericson at 2020-05-21T12:17:30-04:00 Put `PatEnv` first in `GHC.Tc.Gen.Pat.Checker` - - - - - cb4231db by John Ericson at 2020-05-21T12:17:30-04:00 Tiny cleaup eta-reduce away a function argument In GHC, not in the code being compiled! - - - - - 6890c38d by John Ericson at 2020-05-21T12:17:30-04:00 Use braces with do in `SplicePat` case for consistency - - - - - 3451584f by buggymcbugfix at 2020-05-21T12:18:06-04:00 Fix spelling mistakes and typos - - - - - b552e531 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Add INLINABLE pragmas to Enum list producers The INLINABLE pragmas ensure that we export stable (unoptimised) unfoldings in the interface file so we can do list fusion at usage sites. Related tickets: #15185, #8763, #18178. - - - - - e7480063 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Piggyback on Enum Word methods for Word64 If we are on a 64 bit platform, we can use the efficient Enum Word methods for the Enum Word64 instance. - - - - - 892b0c41 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Document INLINE(ABLE) pragmas that enable fusion - - - - - 2b363ebb by Richard Eisenberg at 2020-05-21T12:18:45-04:00 MR template should ask for key part - - - - - a95bbd0b by Sebastian Graf at 2020-05-21T12:19:37-04:00 Make `Int`'s `mod` and `rem` strict in their first arguments They used to be strict until 4d2ac2d (9 years ago). It's obviously better to be strict for performance reasons. It also blocks #18067. NoFib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- integer -1.1% +0.4% wheel-sieve2 +21.2% +20.7% -------------------------------------------------------------------------------- Min -1.1% -0.0% Max +21.2% +20.7% Geometric Mean +0.2% +0.2% ``` The regression in `wheel-sieve2` is due to reboxing that likely will go away with the resolution of #18067. See !3282 for details. Fixes #18187. - - - - - d3d055b8 by Galen Huntington at 2020-05-21T12:20:18-04:00 Clarify pitfalls of NegativeLiterals; see #18022. - - - - - 1b508a9e by Alexey Kuleshevich at 2020-05-21T12:21:02-04:00 Fix wording in primops documentation to reflect the correct reasoning: * Besides resizing functions, shrinking ones also mutate the size of a mutable array and because of those two `sizeofMutabeByteArray` and `sizeofSmallMutableArray` are now deprecated * Change reference in documentation to the newer functions `getSizeof*` instead of `sizeof*` for shrinking functions * Fix incorrect mention of "byte" instead of "small" - - - - - 4ca0c8a1 by Andreas Klebinger at 2020-05-21T12:21:53-04:00 Don't variable-length encode magic iface constant. We changed to use variable length encodings for many types by default, including Word32. This makes sense for numbers but not when Word32 is meant to represent four bytes. I added a FixedLengthEncoding newtype to Binary who's instances interpret their argument as a collection of bytes instead of a number. We then use this when writing/reading magic numbers to the iface file. I also took the libery to remove the dummy iface field. This fixes #18180. - - - - - a1275081 by Krzysztof Gogolewski at 2020-05-21T12:22:35-04:00 Add a regression test for #11506 The testcase works now. See explanation in https://gitlab.haskell.org/ghc/ghc/issues/11506#note_273202 - - - - - 8a816e5f by Krzysztof Gogolewski at 2020-05-21T12:23:55-04:00 Sort deterministically metric output Previously, we sorted according to the test name and way, but the metrics (max_bytes_used/peak_megabytes_allocated etc.) were appearing in nondeterministic order. - - - - - 566cc73f by Sylvain Henry at 2020-05-21T12:24:45-04:00 Move isDynLinkName into GHC.Types.Name It doesn't belong into GHC.Unit.State - - - - - d830bbc9 by Adam Sandberg Ericsson at 2020-05-23T13:36:20-04:00 docs: fix formatting and add some links [skip ci] - - - - - 49301ad6 by Andrew Martin at 2020-05-23T13:37:01-04:00 Implement cstringLength# and FinalPtr This function and its accompanying rule resolve issue #5218. A future PR to the bytestring library will make the internal Data.ByteString.Internal.unsafePackAddress compute string length with cstringLength#. This will improve the status quo because it is eligible for constant folding. Additionally, introduce a new data constructor to ForeignPtrContents named FinalPtr. This additional data constructor, when used in the IsString instance for ByteString, leads to more Core-to-Core optimization opportunities, fewer runtime allocations, and smaller binaries. Also, this commit re-exports all the functions from GHC.CString (including cstringLength#) in GHC.Exts. It also adds a new test driver. This test driver is used to perform substring matches on Core that is dumped after all the simplifier passes. In this commit, it is used to check that constant folding of cstringLength# works. - - - - - dcd6bdcc by Ben Gamari at 2020-05-23T13:37:48-04:00 simplCore: Ignore ticks in rule templates This fixes #17619, where a tick snuck in to the template of a rule, resulting in a panic during rule matching. The tick in question was introduced via post-inlining, as discussed in `Note [Simplifying rules]`. The solution we decided upon was to simply ignore ticks in the rule template, as discussed in `Note [Tick annotations in RULE matching]`. Fixes #18162. Fixes #17619. - - - - - 82cb8913 by John Ericson at 2020-05-23T13:38:32-04:00 Fix #18145 and also avoid needless work with implicit vars - `forAllOrNothing` now is monadic, so we can trace whether we bind an explicit `forall` or not. - #18145 arose because the free vars calculation was needlessly complex. It is now greatly simplified. - Replaced some other implicit var code with `filterFreeVarsToBind`. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - a60dc835 by Ben Gamari at 2020-05-23T13:39:12-04:00 Bump process submodule Fixes #17926. - - - - - 856adf54 by Ben Gamari at 2020-05-23T13:40:21-04:00 users-guide: Clarify meaning of -haddock flag Fixes #18206. - - - - - 7ae57afd by Ben Gamari at 2020-05-23T13:41:03-04:00 git: Add ignored commits file This can be used to tell git to ignore bulk renaming commits like the recently-finished module hierarchy refactoring. Configured with, git config blame.ignoreRevsFile .git-ignore-revs - - - - - 63d30e60 by jneira at 2020-05-24T01:54:42-04:00 Add hie-bios script for windows systems It is a direct translation of the sh script - - - - - 59182b88 by jneira at 2020-05-24T01:54:42-04:00 Honour previous values for CABAL and CABFLAGS The immediate goal is let the hie-bios.bat script set CABFLAGS with `-v0` and remove all cabal output except the compiler arguments - - - - - 932dc54e by jneira at 2020-05-24T01:54:42-04:00 Add specific configuration for windows in hie.yaml - - - - - e0eda070 by jneira at 2020-05-24T01:54:42-04:00 Remove not needed hie-bios output - - - - - a0ea59d6 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Move Config module into GHC.Settings - - - - - 37430251 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Core.Arity into GHC.Core.Opt.Arity - - - - - a426abb9 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Hs.Types into GHC.Hs.Type See discussion in https://gitlab.haskell.org/ghc/ghc/issues/13009#note_268610 - - - - - 1c91a7a0 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Bump haddock submodule - - - - - 66bd24d1 by Ryan Scott at 2020-05-24T01:56:03-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. - - - - - 01c43634 by Matthew Pickering at 2020-05-24T01:56:42-04:00 Remove unused hs-boot file - - - - - 7a07aa71 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix cross-compiler build (#16051) - - - - - 15ccca16 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix distDir per stage - - - - - b420fb24 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix hp2ps error during cross-compilation Fixed by @alp (see https://gitlab.haskell.org/ghc/ghc/issues/16051#note_274265) - - - - - cd339ef0 by Joshua Price at 2020-05-24T15:22:56-04:00 Make Unicode brackets opening/closing tokens (#18225) The tokens `[|`, `|]`, `(|`, and `|)` are opening/closing tokens as described in GHC Proposal #229. This commit makes the unicode variants (`⟦`, `⟧`, `⦇`, and `⦈`) act the same as their ASCII counterparts. - - - - - 013d7120 by Ben Gamari at 2020-05-25T09:48:17-04:00 Revert "Specify kind variables for inferred kinds in base." As noted in !3132, this has rather severe knock-on consequences in user-code. We'll need to revisit this before merging something along these lines. This reverts commit 9749fe1223d182b1f8e7e4f7378df661c509f396. - - - - - 4c4312ed by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Drop redundant ad-hoc boot module check To determine whether the module is a boot module Coverage.addTicksToBinds was checking for a `boot` suffix in the module source filename. This is quite ad-hoc and shouldn't be necessary; the callsite in `deSugar` already checks that the module isn't a boot module. - - - - - 1abf3c84 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make tickBoxCount strict This could otherwise easily cause a leak of (+) thunks. - - - - - b2813750 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make ccIndices strict This just seems like a good idea. - - - - - 02e278eb by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Don't produce ModBreaks if not HscInterpreted emptyModBreaks contains a bottom and consequently it's important that we don't use it unless necessary. - - - - - b8c014ce by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Factor out addMixEntry - - - - - 53814a64 by Zubin Duggal at 2020-05-26T03:03:24-04:00 Add info about typeclass evidence to .hie files See `testsuite/tests/hiefile/should_run/HieQueries.hs` and `testsuite/tests/hiefile/should_run/HieQueries.stdout` for an example of this We add two new fields, `EvidenceVarBind` and `EvidenceVarUse` to the `ContextInfo` associated with an Identifier. These are associated with the appropriate identifiers for the evidence variables collected when we come across `HsWrappers`, `TcEvBinds` and `IPBinds` while traversing the AST. Instance dictionary and superclass selector dictionaries from `tcg_insts` and classes defined in `tcg_tcs` are also recorded in the AST as originating from their definition span This allows us to save a complete picture of the evidence constructed by the constraint solver, and will let us report this to the user, enabling features like going to the instance definition from the invocation of a class method(or any other method taking a constraint) and finding all usages of a particular instance. Additionally, - Mark NodeInfo with an origin so we can differentiate between bindings origininating in the source vs those in ghc - Along with typeclass evidence info, also include information on Implicit Parameters - Add a few utility functions to HieUtils in order to query the new info Updates haddock submodule - - - - - 6604906c by Sebastian Graf at 2020-05-26T03:04:04-04:00 Make WorkWrap.Lib.isWorkerSmallEnough aware of the old arity We should allow a wrapper with up to 82 parameters when the original function had 82 parameters to begin with. I verified that this made no difference on NoFib, but then again it doesn't use huge records... Fixes #18122. - - - - - cf772f19 by Sylvain Henry at 2020-05-26T03:04:45-04:00 Enhance Note [About units] for Backpack - - - - - ede24126 by Takenobu Tani at 2020-05-27T00:13:55-04:00 core-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Core.hs <= coreSyn/CoreSyn.hs * GHC/Core/Coercion.hs <= types/Coercion.hs * GHC/Core/Coercion/Axiom.hs <= types/CoAxiom.hs * GHC/Core/Coercion/Opt.hs <= types/OptCoercion.hs * GHC/Core/DataCon.hs <= basicTypes/DataCon.hs * GHC/Core/FamInstEnv.hs <= types/FamInstEnv.hs * GHC/Core/Lint.hs <= coreSyn/CoreLint.hs * GHC/Core/Subst.hs <= coreSyn/CoreSubst.hs * GHC/Core/TyCo/Rep.hs <= types/TyCoRep.hs * GHC/Core/TyCon.hs <= types/TyCon.hs * GHC/Core/Type.hs <= types/Type.hs * GHC/Core/Unify.hs <= types/Unify.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/Var.hs <= basicTypes/Var.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [skip ci] - - - - - 04750304 by Ben Gamari at 2020-05-27T00:14:33-04:00 eventlog: Fix racy flushing Previously no attempt was made to avoid multiple threads writing their capability-local eventlog buffers to the eventlog writer simultaneously. This could result in multiple eventlog streams being interleaved. Fix this by documenting that the EventLogWriter's write() and flush() functions may be called reentrantly and fix the default writer to protect its FILE* by a mutex. Fixes #18210. - - - - - d6203f24 by Joshua Price at 2020-05-27T00:15:17-04:00 Make `identifier` parse unparenthesized `->` (#18060) - - - - - 28deee28 by Ben Gamari at 2020-05-28T16:23:21-04:00 GHC.Core.Unfold: Refactor traceInline This reduces duplication as well as fixes a bug wherein -dinlining-check would override -ddump-inlinings. Moreover, the new variant - - - - - 1f393e1e by Ben Gamari at 2020-05-28T16:23:21-04:00 Avoid unnecessary allocations due to tracing utilities While ticky-profiling the typechecker I noticed that hundreds of millions of SDocs are being allocated just in case -ddump-*-trace is enabled. This is awful. We avoid this by ensuring that the dump flag check is inlined into the call site, ensuring that the tracing document needn't be allocated unless it's actually needed. See Note [INLINE conditional tracing utilities] for details. Fixes #18168. Metric Decrease: T9961 haddock.Cabal haddock.base haddock.compiler - - - - - 5f621a78 by Vladislav Zavialov at 2020-05-28T16:23:58-04:00 Add Semigroup/Monoid for Q (#18123) - - - - - dc5f004c by Xavier Denis at 2020-05-28T16:24:37-04:00 Fix #18071 Run the core linter on candidate instances to ensure they are well-kinded. Better handle quantified constraints by using a CtWanted to avoid having unsolved constraints thrown away at the end by the solver. - - - - - 10e6982c by Sebastian Graf at 2020-05-28T16:25:14-04:00 FloatOut: Only eta-expand dead-end RHS if arity will increase (#18231) Otherwise we risk turning trivial RHS into non-trivial RHS, introducing unnecessary bindings in the next Simplifier run, resulting in more churn. Fixes #18231. - - - - - 08dab5f7 by Sebastian Graf at 2020-05-28T16:25:14-04:00 DmdAnal: Recognise precise exceptions from case alternatives (#18086) Consider ```hs m :: IO () m = do putStrLn "foo" error "bar" ``` `m` (from #18086) always throws a (precise or imprecise) exception or diverges. Yet demand analysis infers `<L,A>` as demand signature instead of `<L,A>x` for it. That's because the demand analyser sees `putStrLn` occuring in a case scrutinee and decides that it has to `deferAfterPreciseException`, because `putStrLn` throws a precise exception on some control flow paths. This will mask the `botDiv` `Divergence`of the single case alt containing `error` to `topDiv`. Since `putStrLn` has `topDiv` itself, the final `Divergence` is `topDiv`. This is easily fixed: `deferAfterPreciseException` works by `lub`ing with the demand type of a virtual case branch denoting the precise exceptional control flow. We used `nopDmdType` before, but we can be more precise and use `exnDmdType`, which is `nopDmdType` with `exnDiv`. Now the `Divergence` from the case alt will degrade `botDiv` to `exnDiv` instead of `topDiv`, which combines with the result from the scrutinee to `exnDiv`, and all is well. Fixes #18086. - - - - - aef95f11 by Ben Gamari at 2020-05-28T16:25:53-04:00 Ticky-ticky: Record DataCon name in ticker name This makes it significantly easier to spot the nature of allocations regressions and comes at a reasonably low cost. - - - - - 8f021b8c by Ben Gamari at 2020-05-28T16:26:34-04:00 hadrian: Don't track GHC's verbosity argument Teach hadrian to ignore GHC's -v argument in its recompilation check, thus fixing #18131. - - - - - 13d9380b by Ben Gamari at 2020-05-28T16:27:20-04:00 Rip out CmmStackInfo(updfr_space) As noted in #18232, this field is currently completely unused and moreover doesn't have a clear meaning. - - - - - f10d11fa by Andreas Klebinger at 2020-05-29T01:38:42-04:00 Fix "build/elem" RULE. An redundant constraint prevented the rule from matching. Fixing this allows a call to elem on a known list to be translated into a series of equality checks, and eventually a simple case expression. Surprisingly this seems to regress elem for strings. To avoid this we now also allow foldrCString to inline and add an UTF8 variant. This results in elem being compiled to a tight non-allocating loop over the primitive string literal which performs a linear search. In the process this commit adds UTF8 variants for some of the functions in GHC.CString. This is required to make this work for both ASCII and UTF8 strings. There are also small tweaks to the CString related rules. We now allow ourselfes the luxury to compare the folding function via eqExpr, which helps to ensure the rule fires before we inline foldrCString*. Together with a few changes to allow matching on both the UTF8 and ASCII variants of the CString functions. - - - - - bbeb2389 by Ben Gamari at 2020-05-29T01:39:19-04:00 CoreToStg: Add Outputable ArgInfo instance - - - - - 0e3361ca by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Make Lint check return type of a join point Consider join x = rhs in body It's important that the type of 'rhs' is the same as the type of 'body', but Lint wasn't checking that invariant. Now it does! This was exposed by investigation into !3113. - - - - - c49f7df0 by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Do not float join points in exprIsConApp_maybe We hvae been making exprIsConApp_maybe cleverer in recent times: commit b78cc64e923716ac0512c299f42d4d0012306c05 Date: Thu Nov 15 17:14:31 2018 +0100 Make constructor wrappers inline only during the final phase commit 7833cf407d1f608bebb1d38bb99d3035d8d735e6 Date: Thu Jan 24 17:58:50 2019 +0100 Look through newtype wrappers (Trac #16254) commit c25b135ff5b9c69a90df0ccf51b04952c2dc6ee1 Date: Thu Feb 21 12:03:22 2019 +0000 Fix exprIsConApp_maybe But alas there was still a bug, now immortalised in Note [Don't float join points] in SimpleOpt. It's quite hard to trigger because it requires a dead join point, but it came up when compiling Cabal Cabal.Distribution.Fields.Lexer.hs, when working on !3113. Happily, the fix is extremly easy. Finding the bug was not so easy. - - - - - 46720997 by Ben Gamari at 2020-05-29T01:39:19-04:00 Allow simplification through runRW# Because runRW# inlines so late, we were previously able to do very little simplification across it. For instance, given even a simple program like case runRW# (\s -> let n = I# 42# in n) of I# n# -> f n# we previously had no way to avoid the allocation of the I#. This patch allows the simplifier to push strict contexts into the continuation of a runRW# application, as explained in in Note [Simplification of runRW#] in GHC.CoreToStg.Prep. Fixes #15127. Metric Increase: T9961 Metric Decrease: ManyConstructors Co-Authored-By: Simon Peyton-Jone <simonpj at microsoft.com> - - - - - 277c2f26 by Ben Gamari at 2020-05-29T01:39:55-04:00 Eta expand un-saturated primops Now since we no longer try to predict CAFfyness we have no need for the solution to #16846. Eta expanding unsaturated primop applications is conceptually simpler, especially in the presence of levity polymorphism. This essentially reverts cac8dc9f51e31e4c0a6cd9bc302f7e1bc7c03beb, as suggested in #18079. Closes #18079. - - - - - f44d7ae0 by Simon Jakobi at 2020-05-29T01:40:34-04:00 base: Scrap deprecation plan for Data.Monoid.{First,Last} See the discussion on the libraries mailing list for context: https://mail.haskell.org/pipermail/libraries/2020-April/030357.html - - - - - 8b494895 by Jeremy Schlatter at 2020-05-29T01:41:12-04:00 Fix typo in documentation - - - - - 998450f4 by Gleb Popov at 2020-05-29T01:41:53-04:00 Always define USE_PTHREAD_FOR_ITIMER for FreeBSD. - - - - - f9a513e0 by Alp Mestanogullari at 2020-05-29T01:42:36-04:00 hadrian: introduce 'install' target Its logic is very simple. It `need`s the `binary-dist-dir` target and runs suitable `configure` and `make install` commands for the user. A new `--prefix` command line argument is introduced to specify where GHC should be installed. - - - - - 67738db1 by Travis Whitaker at 2020-05-29T13:34:48-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. - - - - - aac19e6c by Peter Trommler at 2020-05-29T13:35:24-04:00 PPC NCG: No per-symbol .section ".toc" directives All position independent symbols are collected during code generation and emitted in one go. Prepending each symbol with a .section ".toc" directive is redundant. This patch drops the per-symbol directives leading to smaller assembler files. Fixes #18250 - - - - - 4413828b by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Teach getNumProcessors to return available processors Previously we would report the number of physical processors, which can be quite wrong in a containerized setting. Now we rather return how many processors are in our affinity mask when possible. I also refactored the code to prefer platform-specific since this will report logical CPUs instead of physical (using `machdep.cpu.thread_count` on Darwin and `cpuset_getaffinity` on FreeBSD). Fixes #14781. - - - - - 1449435c by Ben Gamari at 2020-05-30T06:07:31-04:00 users-guide: Note change in getNumProcessors in users guide - - - - - 3d960169 by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Drop compatibility shims for Windows Vista We can now assume that the thread and processor group interfaces are available. - - - - - 7f8f948c by Peter Trommler at 2020-05-30T06:08:07-04:00 PPC NCG: Fix .size directive on powerpc64 ELF v1 Thanks to Sergei Trofimovich for pointing out the issue. Fixes #18237 - - - - - 7c555b05 by Andreas Klebinger at 2020-05-30T06:08:43-04:00 Optimize GHC.Utils.Monad. Many functions in this module are recursive and as such are marked loop breakers. Which means they are unlikely to get an unfolding. This is *bad*. We always want to specialize them to specific Monads. Which requires a visible unfolding at the use site. I rewrote the recursive ones from: foo f x = ... foo x' ... to foo f x = go x where go x = ... As well as giving some pragmas to make all of them available for specialization. The end result is a reduction of allocations of about -1.4% for nofib/spectral/simple/Main.hs when compiled with `-O`. ------------------------- Metric Decrease: T12425 T14683 T5631 T9233 T9675 T9961 WWRec ------------------------- - - - - - 8b1cb5df by Ben Gamari at 2020-05-30T06:09:20-04:00 Windows: Bump Windows toolchain to 0.2 - - - - - 6947231a by Zubin Duggal at 2020-05-30T06:10:02-04:00 Simplify contexts in GHC.Iface.Ext.Ast - - - - - 2ee4f36c by Daniel Gröber at 2020-06-01T06:32:56-04:00 Cleanup OVERWRITING_CLOSURE logic The code is just more confusing than it needs to be. We don't need to mix the threaded check with the ldv profiling check since ldv's init already checks for this. Hence they can be two separate checks. Taking the sanity checking into account is also cleaner via DebugFlags.sanity. No need for checking the DEBUG define. The ZERO_SLOP_FOR_LDV_PROF and ZERO_SLOP_FOR_SANITY_CHECK definitions the old code had also make things a lot more opaque IMO so I removed those. - - - - - 6159559b by Daniel Gröber at 2020-06-01T06:32:56-04:00 Fix OVERWRITING_CLOSURE assuming closures are not inherently used The new ASSERT in LDV_recordDead() was being tripped up by MVars when removeFromMVarBlockedQueue() calls OVERWRITING_CLOSURE() via OVERWRITE_INFO(). - - - - - 38992085 by Daniel Gröber at 2020-06-01T06:32:56-04:00 Always zero shrunk mutable array slop when profiling When shrinking arrays in the profiling way we currently don't always zero the leftover slop. This means we can't traverse such closures in the heap profiler. The old Note [zeroing slop] and #8402 have some rationale for why this is so but I belive the reasoning doesn't apply to mutable closures. There users already have to ensure multiple threads don't step on each other's toes so zeroing should be safe. - - - - - b0c1f2a6 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for #18151 - - - - - 9a99a178 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for desugaring of PostfixOperators - - - - - 2b89ca5b by Ben Gamari at 2020-06-01T06:33:37-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. - - - - - d412d7a3 by Kirill Elagin at 2020-06-01T06:34:21-04:00 Winferred-safe-imports: Do not exit with error Currently, when -Winferred-safe-imports is enabled, even when it is not turned into an error, the compiler will still exit with exit code 1 if this warning was emitted. Make sure it is really treated as a warning. - - - - - f945eea5 by Ben Gamari at 2020-06-01T06:34:58-04:00 nonmoving: Optimise log2_ceil - - - - - aab606e4 by Bodigrim at 2020-06-01T06:35:36-04:00 Clarify description of fromListN - - - - - 7e5220e2 by Bodigrim at 2020-06-01T06:35:36-04:00 Apply suggestion to libraries/base/GHC/Exts.hs - - - - - f3fb1ce9 by fendor at 2020-06-01T06:36:18-04:00 Add `isInScope` check to `lintCoercion` Mirrors the behaviour of `lintType`. - - - - - 5ac4d946 by fendor at 2020-06-01T06:36:18-04:00 Lint rhs of IfaceRule - - - - - 1cef6126 by Jeremy Schlatter at 2020-06-01T06:37:00-04:00 Fix wording in documentation The duplicate "orphan instance" phrase here doesn't make sense, and was probably an accident. - - - - - 5aaf08f2 by Takenobu Tani at 2020-06-01T06:37:43-04:00 configure: Modify aclocal.m4 according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * Rename: * compiler/GHC/Parser.hs <= compiler/parser/Parser.hs * compiler/GHC/Parser/Lexer.hs <= compiler/Parser/Lexer.hs * Add: * compiler/GHC/Cmm/Lexer.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular - - - - - 15857ad8 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Don't fail if we can't unlink __symlink_test Afterall, it's possible we were unable to create it due to lack of symlink permission. - - - - - 4a7229ef by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Refactor ghostscript detection Tamar reported that he saw crashes due to unhandled exceptions. - - - - - 2ab37eaf by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/perf_notes: Fix ill-typed assignments - - - - - e45d5b66 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/testutil: Fix bytes/str mismatch - - - - - 7002d0cb by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Work around spurious mypy failure - - - - - 11390e3a by Takenobu Tani at 2020-06-01T06:39:05-04:00 Clean up file paths for new module hierarchy This updates comments only. This patch replaces file references according to new module hierarchy. See also: * https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular * https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 8f2e5732 by Takenobu Tani at 2020-06-01T06:39:05-04:00 Modify file paths to module paths for new module hierarchy This updates comments only. This patch replaces module references according to new module hierarchy [1][2]. For files under the `compiler/` directory, I replace them as module paths instead of file paths. For instance, `GHC.Unit.State` instead of `compiler/GHC/Unit/State.hs` [3]. For current and future haddock's markup, this patch encloses the module name with "" [4]. [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 [3]: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3375#note_276613 [4]: https://haskell-haddock.readthedocs.io/en/latest/markup.html#linking-to-modules - - - - - 68b71c4a by Tom Ellis at 2020-06-01T06:39:55-04:00 Rename the singleton tuple GHC.Tuple.Unit to GHC.Tuple.Solo - - - - - 95da76c2 by Sylvain Henry at 2020-06-01T06:40:41-04:00 Hadrian: fix binary-dist target for cross-compilation - - - - - 730fcd54 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for the @-operator Since GHC diverges from the Haskell Report by allowing the user to define (@) as an infix operator, we better give a good error message when the user does so unintentionally. In general, this is rather hard to do, as some failures will be discovered only in the renamer or the type checker: x :: (Integer, Integer) x @ (a, b) = (1, 2) This patch does *not* address this general case. However, it gives much better error messages when the binding is not syntactically valid: pairs xs @ (_:xs') = zip xs xs' Before this patch, the error message was rather puzzling: <interactive>:1:1: error: Parse error in pattern: pairs After this patch, the error message includes a hint: <interactive>:1:1: error: Parse error in pattern: pairs In a function binding for the ‘@’ operator. Perhaps you meant an as-pattern, which must not be surrounded by whitespace - - - - - 0fde5377 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TypeApplications With this patch, we always parse f @t as a type application, thereby producing better error messages. This steals two syntactic forms: * Prefix form of the @-operator in expressions. Since the @-operator is a divergence from the Haskell Report anyway, this is not a major loss. * Prefix form of @-patterns. Since we are stealing loose infix form anyway, might as well sacrifice the prefix form for the sake of much better error messages. - - - - - c68e7e1e by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TemplateHaskellQuotes While [e| |], [t| |], [d| |], and so on, steal syntax from list comprehensions, [| |] and [|| ||] do not steal any syntax. Thus we can improve error messages by always accepting them in the lexer. Turns out the renamer already performs necessary validation. - - - - - 120aedbd by Ben Gamari at 2020-06-01T16:07:02-04:00 gitlab-ci: Disable use of ld.lld on ARMv7 It turns out that lld non-deterministically fails on ARMv7. I suspect this may be due to the a kernel regression as this only started happening when we upgraded to 5.4. Nevertheless, easily avoided by simply sticking with gold. Works around #18280. - - - - - d6279ff0 by Ben Gamari at 2020-06-02T13:03:30-04:00 gitlab-ci: Ensure that workaround for #18280 applies to bindisttest We need to ensure that the `configure` flags working around #18280 are propagated to the bindisttest `configure` as well. - - - - - cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00 gitlab-ci: Allow ARMv7 job to fail Due to #18298. - - - - - 32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00 Clean up boot vs non-boot disambiguating types We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule. - - - - - c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00 docs: Add more details on InterruptibleFFI. Details from https://gitlab.haskell.org/ghc/ghc/issues/8684 and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430 - - - - - 1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00 Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr. MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd. This regression did not make it into a release of GHC. Here, the original behavior is restored, and FinalPtr is given the same treatment as PlainPtr. - - - - - 2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00 Fix documentation on type families not being extracted It looks like the location of the Names used for CoAxioms on type families are now located at their type constructors. Previously, Docs.hs thought the Names were located in the RHS, so the RealSrcSpan in the instanceMap and getInstLoc didn't match up. Fixes #18241 - - - - - 6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00 GHC.Hs.Instances: Compile with -O0 This module contains exclusively Data instances, which are going to be slow no matter what we do. Furthermore, they are incredibly slow to compile with optimisation (see #9557). Consequently we compile this with -O0. See #18254. - - - - - c330331a by nineonine at 2020-06-04T04:37:59-04:00 Add test for #17669 - - - - - cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00 rts: Add Windows-specific implementation of rtsSleep Previously we would use the POSIX path, which uses `nanosleep`. However, it turns out that `nanosleep` is provided by `libpthread` on Windows. In general we don't want to incur such a dependency. Avoid this by simply using `Sleep` on Windows. Fixes #18272. - - - - - ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00 compiler: Disable use of process jobs with process < 1.6.9 Due to #17926. - - - - - 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 69afa45f by Ben Gamari at 2020-07-16T13:47:46-04:00 testsuite: Don't disable LLVM ways due to unversioned llc Previously we would silently disable the LLVM testsuite ways when LLC is set to an unversioned llc executable (e.g. `llc` instead of `llc-5.0`). Presumably this was because we were lax in checking the LLVM version in configure. However, this is no longer the case and consequently this confusing behavior is no longer necessary. See Trac #16121. Test Plan: Validate Reviewers: angerman Reviewed By: angerman Subscribers: michalt, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4333 - - - - - 30 changed files: - − .circleci/config.yml - − .circleci/fetch-submodules.sh - − .circleci/images/aarch64-linux-deb9/Dockerfile - − .circleci/images/i386-linux-deb8/Dockerfile - − .circleci/images/i386-linux-deb9/Dockerfile - − .circleci/images/linters/Dockerfile - − .circleci/images/update-image - − .circleci/images/x86_64-freebsd/Dockerfile - − .circleci/images/x86_64-freebsd/build-toolchain.sh - − .circleci/images/x86_64-linux-centos7/Dockerfile - − .circleci/images/x86_64-linux-deb8/Dockerfile - − .circleci/images/x86_64-linux-deb9/Dockerfile - − .circleci/images/x86_64-linux-fedora27/Dockerfile - − .circleci/prepare-system.sh - − .circleci/push-test-metrics.sh - .ghcid - + .git-ignore-revs - + .gitattributes - .gitignore - .gitlab-ci.yml - + .gitlab/ci.sh - − .gitlab/darwin-init.sh - − .gitlab/fix-submodules.py - + .gitlab/issue_templates/bug.md - + .gitlab/issue_templates/documentation_issue.md - + .gitlab/issue_templates/feature_request.md - + .gitlab/linters/check-changelogs.sh - .gitlab/linters/check-cpp.py - .gitlab/linters/check-makefiles.py - + .gitlab/linters/check-version-number.sh The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb4eb5f30022e01c5df06c81b698fdcf4ddb74c0...69afa45ff3914d3e593b52b845706a1fddd831a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb4eb5f30022e01c5df06c81b698fdcf4ddb74c0...69afa45ff3914d3e593b52b845706a1fddd831a8 You're receiving 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 Jul 16 17:57:21 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 16 Jul 2020 13:57:21 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18463 Message-ID: <5f109501858e2_80b3f848639200c3515278@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T18463 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18463 You're receiving 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 Jul 16 18:01:17 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 16 Jul 2020 14:01:17 -0400 Subject: [Git][ghc/ghc][wip/T12561] 2556 commits: Fix typo [skip ci] Message-ID: <5f1095ed693b4_80b3f8486fb6f7c352681b@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T12561 at Glasgow Haskell Compiler / GHC Commits: 84c77a67 by Alexandre Esteves at 2019-03-21T17:43:03-04:00 Fix typo [skip ci] - - - - - 7092b2de by Matthew Pickering at 2019-03-21T23:38:58-04:00 Only run check-makefiles.py linter in testsuite dir - - - - - 322239de by Matthew Pickering at 2019-03-21T23:38:58-04:00 Run linters on merge requests It seems that it has failed to execute at all since it was implemented. We now run the linters on merge requests. - - - - - 8f8d532c by Ben Gamari at 2019-03-21T23:45:03-04:00 gitlab-ci: Do full `perf` build when building Windows releases - - - - - 2ef72d3f by Ben Gamari at 2019-03-21T23:45:03-04:00 gitlab-ci: Pass --target explicitly to configure on Windows Otherwise configure fails in the 32-bit case with ``` This GHC (c:/GitLabRunner/builds/8fc0e283/0/ghc/ghc/toolchain/bin/ghc) does not generate code for the build platform GHC target platform : x86_64-unknown-mingw32 Desired build platform : i386-unknown-mingw32 ``` - - - - - 8b14f536 by Ben Gamari at 2019-03-21T23:51:08-04:00 Bump cabal submodule Due to https://github.com/haskell/cabal/issues/5953. - - - - - dbe4557f by Matthew Pickering at 2019-03-22T10:02:32-04:00 CI: Allow failure in packaging step This depends on the windows build which is still allowed to fail. If that job fails then the packaging job will also fail. - - - - - 366f1c68 by Ben Gamari at 2019-03-22T10:08:38-04:00 gitlab: Deploy documentation snapshot via GitLab Pages - - - - - d608d543 by Tamar Christina at 2019-03-22T10:14:45-04:00 Force LF line ending for md5sum [skip-ci] - - - - - cd07086a by Ben Gamari at 2019-03-22T10:34:51-04:00 gitlab-ci: Fix linters - - - - - ab51bee4 by Herbert Valerio Riedel at 2019-03-22T10:34:51-04:00 base: Remove `Monad(fail)` method and reexport `MonadFail(fail)` instead As per https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail Coauthored-by: Ben Gamari <ben at well-typed.com> - - - - - 266b49ca by Ben Gamari at 2019-03-22T18:33:20-04:00 gitlab-ci: Clean up linter I'm not sure why these steps were done but they seem counterproductive and unnecessary. - - - - - 44b08ede by Ben Gamari at 2019-03-22T18:38:11-04:00 gitlab-ci: Fix YAML syntax - - - - - 971f4530 by Ben Gamari at 2019-03-22T18:49:34-04:00 gitlab-ci: Compute merge base against remote tracking branch Previously we would use the local branch with the name `$CI_MERGE_REQUEST_TARGET_BRANCH_NAME` to compute the merge base when linting. However, this branch isn't necessarily up-to-date. We should rather use `origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME`. - - - - - 8d01b572 by Ben Gamari at 2019-03-23T12:37:56-04:00 gitlab-ci: Explicitly fetch target branch `git fetch`, which we used previously, doesn't update the remote tracking branches. - - - - - cd85f8a7 by Ben Gamari at 2019-03-24T08:46:13-04:00 gitlab-ci: Allow linters to fail for now They are broken and I don't have time to fix them at the moment. - - - - - d763b2e7 by Haskell-mouse at 2019-03-25T14:02:22-04:00 User's Guide: extensions compatibility Adds the mention that extensions "AllowAmbiguousTypes" and "RankNTypes" are not always compatible with each other. Specifies the conditions and causes of failing in resolving of ambiguity. - - - - - 200d65ef by Matthew Pickering at 2019-03-25T14:02:25-04:00 Check hadrian/ghci.sh script output to determine pass/fail ghci always exits with exit code 0 so you have to check the output to see if the modules loaded succesfully. - - - - - 8e07368f by Matthew Pickering at 2019-03-25T14:02:27-04:00 Refactor ./hadrian/ghci.sh for better error messages By separating these two lines, if the first command fails then `ghci` is not loaded. Before it would still load ghci but display lots of errors about not being able to find modules. - - - - - 3769e3a8 by Takenobu Tani at 2019-03-25T14:02:29-04:00 Update Wiki URLs to point to GitLab This moves all URL references to Trac Wiki to their corresponding GitLab counterparts. This substitution is classified as follows: 1. Automated substitution using sed with Ben's mapping rule [1] Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy... New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy... 2. Manual substitution for URLs containing `#` index Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy...#Zzz New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy...#zzz 3. Manual substitution for strings starting with `Commentary` Old: Commentary/XxxYyy... New: commentary/xxx-yyy... See also !539 [1]: https://gitlab.haskell.org/bgamari/gitlab-migration/blob/master/wiki-mapping.json - - - - - b9da2868 by Ryan Scott at 2019-03-25T14:02:33-04:00 Correct duplicate 4.12.0.0 entry in base's changelog See #16490. [ci skip] - - - - - ab41c1b4 by Andrey Mokhov at 2019-03-27T07:20:03-04:00 Hadrian: Bump Shake to 0.17.6 The new release of Shake comes with these relevant features: * use symlinks for --shared * add --compact for a Bazel/Buck style output - - - - - 646f2e79 by Andrey Mokhov at 2019-03-27T07:20:03-04:00 Hadrian: trace the execution of expensive Cabal calls We use Cabal to parse, configure, register and copy packages, which are expensive operations that are currently not visible to Shake's profiling infrastructure. By using `traced` we tell Shake to add these IO actions to the profiling report, helping us to identify performance bottlenecks. We use short tracing keys, as recommended in Shake docs: the name of the current target is already available in the rest of the profiling information. - - - - - fb12f53c by Alp Mestanogullari at 2019-03-27T07:20:05-04:00 Hadrian: introduce an easy way for users to build with -split-sections Any user can now trivially build any number of Haskell packages with `-split-sections` by using `splitSections`/`splitSectionsIf` on any existing or new flavour: -- build all packages but the ghc library with -split-sections splitSections :: Flavour -> Flavour -- build all packages that satisfy the given predicate -- with --split-sections splitSectionsIf :: (Package -> Bool) -> Flavour -> Flavour See the new section in `doc/user-settings.md`. - - - - - 3dec527a by David Eichmann at 2019-03-27T07:20:09-04:00 Hadrian: don't use -zorigin on darwin. - - - - - 5730f863 by Ömer Sinan Ağacan at 2019-03-27T07:20:10-04:00 Minor refactoring in copy array primops: - `emitCopySmallArray` now checks size before generating code and doesn't generate any code when size is 0. `emitCopyArray` already does this so this makes small/large array cases the same in argument checking. - In both `emitCopySmallArray` and `emitCopyArray` read the `dflags` after checking the argument. - - - - - 4acdb769 by Chaitanya Koparkar at 2019-03-27T07:20:11-04:00 Fix a few broken Trac links [skip ci] This patch only attempts to fix links that don't automatically re-direct to the correct URL. - - - - - 97ad5cfb by Artem Pelenitsyn at 2019-03-29T14:18:12-04:00 Add some tips to the Troubleshooting section of README - - - - - 8a20bfc2 by Michael Peyton Jones at 2019-03-29T14:18:14-04:00 Visibility: handle multiple units with the same name Fixes #16228. The included test case is adapted from the reproduction in the issue, and fails without this patch. ------ We compute an initial visilibity mapping for units based on what is present in the package databases. To seed this, we compute a set of all the package configs to add visibilities for. However, this set was keyed off the unit's *package name*. This is correct, since we compare packages across databases by version. However, we would only ever consider a single, most-preferable unit from the database in which it was found. The effect of this was that only one of the libraries in a Cabal package would be added to this initial set. This would cause attempts to use modules from the omitted libraries to fail, claiming that the package was hidden (even though `ghc-pkg` would correctly show it as visible). A solution is to do the selection of the most preferable packages separately, and then be sure to consider exposing all units in the same package in the same package db. We can do this by picking a most-preferable unit for each package name, and then considering exposing all units that are equi-preferable with that unit. ------ Why wasn't this bug apparent to all people trying to use sub-libraries in Cabal? The answer is that Cabal explicitly passes `-package` and `-package-id` flags for all the packages it wants to use, rather than relying on the state of the package database. So this bug only really affects people who are trying to use package databases produced by Cabal outside of Cabal itself. One particular example of this is the way that the Nixpkgs Haskell infrastructure provides wrapped GHCs: typically these are equipped with a package database containing all the needed package dependencies, and the user is not expected to pass `-package` flags explicitly. - - - - - 754b5455 by Artem Pelenitsyn at 2019-03-29T14:18:20-04:00 docs: make nfib compute the Fibonacci sequence [skipci] - - - - - 1a567133 by Ben Gamari at 2019-03-29T14:18:20-04:00 ci: Check that changelogs don't contain "TBA" This ensures that the release dates in the library changelogs are properly set. - - - - - 6e15ca54 by Ben Gamari at 2019-03-29T14:18:22-04:00 Bump transformers to 0.5.6.2 See #16199. - - - - - 6f7115df by Ben Gamari at 2019-03-30T07:42:38-04:00 ci: Ensure index.html is preserved in documentation tarball - - - - - 33173a51 by Alexandre at 2019-04-01T03:32:28-04:00 Add support for bitreverse primop This commit includes the necessary changes in code and documentation to support a primop that reverses a word's bits. It also includes a test. - - - - - a3971b4e by Alexandre at 2019-04-01T03:32:28-04:00 Bump ghc-prim's version where needed - - - - - 061276ea by Michael Sloan at 2019-04-01T03:32:30-04:00 Remove unnecessary uses of UnboxedTuples pragma (see #13101 / #15454) Also removes a couple unnecessary MagicHash pragmas - - - - - e468c613 by David Eichmann at 2019-04-01T03:32:34-04:00 Support Shake's --lint-fsatrace feature. Using this feature requires fsatrace (e.g. https://github.com/jacereda/fsatrace). Simply use the `--lint-fsatrace` option when running hadrian. Shake version >= 0.17.7 is required to support linting out of tree build dirs. - - - - - 1e9e4197 by Ben Gamari at 2019-04-01T03:32:34-04:00 gitlab: Add merge request template for backports for 8.8 - - - - - 55650d14 by Ben Gamari at 2019-04-01T03:32:34-04:00 gitlab: Add some simply issue templates - - - - - 27b99ed8 by Takenobu Tani at 2019-04-01T03:32:36-04:00 Clean up URLs to point to GitLab This moves URL references to old Trac to their corresponding GitLab counterparts. This patch does not update the submodule library, such as libraries/Cabal. See also !539, !606, !618 [ci skip] - - - - - 18d1555d by Adam Sandberg Eriksson at 2019-04-01T03:32:38-04:00 configure: document the use of the LD variable - - - - - 10352efa by Ben Gamari at 2019-04-01T18:22:34-04:00 gitlab: Add feature request MR template - - - - - 1e52054b by Ben Gamari at 2019-04-01T19:16:21-04:00 gitlab: Move feature request template to issue_templates Whoops. - - - - - e5c21ca9 by Ben Gamari at 2019-04-01T19:16:25-04:00 gitlab: Mention ~"user facing" label - - - - - 39282422 by Ryan Scott at 2019-04-01T20:01:38-04:00 Bump array submodule This bumps `array` to version 0.5.4.0 so that we can distinguish it with `MIN_VERSION_array` (as it introduces some changes to the `Show` instance for `UArray`). - - - - - 7cf5ba3d by Michal Terepeta at 2019-04-01T20:07:49-04:00 Improve performance of newSmallArray# This: - Hoists part of the condition outside of the initialization loop in `stg_newSmallArrayzh`. - Annotates one of the unlikely branches as unlikely, also in `stg_newSmallArrayzh`. - Adds a couple of annotations to `allocateMightFail` indicating which branches are likely to be taken. Together this gives about 5% improvement. Signed-off-by: Michal Terepeta <michal.terepeta at gmail.com> - - - - - dd9c82ef by David Eichmann at 2019-04-01T20:13:55-04:00 Hadrian: correct deps for ghc builder. Previously, when needing ghc as a builder, the ghcDeps (Files the GHC binary depends on) for the current stage were needed. This is incorrect as the previous stage's ghc is used for building. This commit fixes the issue, needing the previous stage's ghcDeps. - - - - - 345306d3 by Alexandre Baldé at 2019-04-02T12:34:30-04:00 Fix formatting issue in ghc-prim's changelog [skip ci] - - - - - f54b5124 by David Eichmann at 2019-04-02T12:40:39-04:00 Hadrian: traceAllow deep dependencies when compilling haskell object files. - - - - - d132b30a by David Eichmann at 2019-04-02T12:40:39-04:00 Hadrian: lint ignore autom4te and ghc-pkg cache files. - - - - - bf734195 by Simon Marlow at 2019-04-02T12:46:46-04:00 Add myself to libraries/ghci - - - - - 5a75ccd0 by klebinger.andreas at gmx.at at 2019-04-03T00:34:57-04:00 Fix faulty substitutions in StgCse (#11532). `substBndr` should rename bindings which shadow existing ids. However while it was renaming the bindings it was not adding proper substitutions for renamed bindings. Instead of adding a substitution of the form `old -> new` for renamed bindings it mistakenly added `old -> old` if no replacement had taken place while adding none if `old` had been renamed. As a byproduct this should improve performance, as we no longer add useless substitutions for unshadowed bindings. - - - - - 2ec749b5 by Nathan Collins at 2019-04-03T00:41:05-04:00 users-guide: Fix typo - - - - - ea192a09 by Andrew Martin at 2019-04-03T00:41:05-04:00 base: Add documentation that liftA2 used to not be a typeclass method - - - - - 733f1b52 by Frank Steffahn at 2019-04-03T00:41:05-04:00 users-guide: Typo in Users Guide, Glasgow Exts - - - - - 3364def0 by Ben Gamari at 2019-04-03T00:41:05-04:00 integer-gmp: Write friendlier documentation for Integer - - - - - dd3a3d08 by Ben Gamari at 2019-04-03T00:41:05-04:00 integer-simple: Add documentation for Integer type - - - - - 722fdddf by Chris Martin at 2019-04-03T00:41:05-04:00 Correct two misspellings of "separately" - - - - - bf6dbe3d by Chris Martin at 2019-04-03T00:41:05-04:00 Inline the definition of 'ap' in the Monad laws The law as it is currently written is meaningless, because nowhere have we defined the implementation of 'ap'. The reader of the Control.Monad documentation is provided with only a type signature, > ap :: Monad m => m (a -> b) -> m a -> m b an informal description, > In many situations, the liftM operations can be replaced by uses of > ap, which promotes function application. and a relationship between 'ap' and the 'liftM' functions > return f `ap` x1 `ap` ... `ap` xn > is equivalent to > liftMn f x1 x2 ... xn Without knowing how 'ap' is defined, a law involving 'ap' cannot provide any guidance for how to write a lawful Monad instance, nor can we conclude anything from the law. I suspect that a reader equipped with the understanding that 'ap' was defined prior to the invention of the Applicative class could deduce that 'ap' must be defined in terms of (>>=), but nowhere as far as I can tell have we written this down explicitly for readers without the benefit of historical context. If the law is meant to express a relationship among (<*>), (>>=), and 'return', it seems that it is better off making this statement directly, sidestepping 'ap' altogether. - - - - - 7b090b53 by Ben Gamari at 2019-04-03T03:57:40-04:00 configure: Always use AC_LINK_ELSEIF when testing against assembler This fixes #16440, where the build system incorrectly concluded that the `.subsections_via_symbols` assembler directive was supported on a Linux system. This was caused by the fact that gcc was invoked with `-flto`; when so-configured gcc does not call the assembler but rather simply serialises its AST for compilation during the final link. This is described in Note [autoconf assembler checks and -flto]. - - - - - 4626cf21 by Sebastian Graf at 2019-04-03T04:03:47-04:00 Fix Uncovered set of literal patterns Issues #16289 and #15713 are proof that the pattern match checker did an unsound job of estimating the value set abstraction corresponding to the uncovered set. The reason is that the fix from #11303 introducing `NLit` was incomplete: The `LitCon` case desugared to `Var` rather than `LitVar`, which would have done the necessary case splitting analogous to the `ConVar` case. This patch rectifies that by introducing the fresh unification variable in `LitCon` in value abstraction position rather than pattern postition, recording a constraint equating it to the constructor expression rather than the literal. Fixes #16289 and #15713. - - - - - 6f13e7b1 by Ben Gamari at 2019-04-03T08:12:26-04:00 gitlab-ci: Build hyperlinked sources for releases Fixes #16445. - - - - - 895394c2 by Ben Gamari at 2019-04-03T08:15:06-04:00 gitlab: Fix label names in issue templates - - - - - 75abaaea by Yuriy Syrovetskiy at 2019-04-04T04:23:19-04:00 Replace git.haskell.org with gitlab.haskell.org (#16196) - - - - - 25c02ea1 by Ryan Scott at 2019-04-04T04:29:29-04:00 Fix #16518 with some more kind-splitting smarts This patch corrects two simple oversights that led to #16518: 1. `HsUtils.typeToLHsType` was taking visibility into account in the `TyConApp` case, but not the `AppTy` case. I've factored out the visibility-related logic into its own `go_app` function and now invoke `go_app` from both the `TyConApp` and `AppTy` cases. 2. `Type.fun_kind_arg_flags` did not properly split kinds with nested `forall`s, such as `(forall k. k -> Type) -> (forall k. k -> Type)`. This was simply because `fun_kind_arg_flags`'s `FunTy` case always bailed out and assumed all subsequent arguments were `Required`, which clearly isn't the case for nested `forall`s. I tweaked the `FunTy` case to recur on the result kind. - - - - - 51fd3571 by Ryan Scott at 2019-04-04T04:35:39-04:00 Use funPrec, not topPrec, to parenthesize GADT argument types A simple oversight. Fixes #16527. - - - - - 6c0dd085 by Ben Gamari at 2019-04-04T08:12:24-04:00 testsuite: Add testcase for #16111 - - - - - cbb88865 by klebinger.andreas at gmx.at at 2019-04-04T08:12:25-04:00 Restore Xmm registers properly in StgCRun.c This fixes #16514: Xmm6-15 was restored based off rax instead of rsp. The code was introduced in the fix for #14619. - - - - - 33b0a291 by Ryan Scott at 2019-04-04T08:12:28-04:00 Tweak error messages for narrowly-kinded assoc default decls This program, from #13971, currently has a rather confusing error message: ```hs class C a where type T a :: k type T a = Int ``` ``` • Kind mis-match on LHS of default declaration for ‘T’ • In the default type instance declaration for ‘T’ In the class declaration for ‘C’ ``` It's not at all obvious why GHC is complaining about the LHS until you realize that the default, when printed with `-fprint-explicit-kinds`, is actually `type T @{k} @* a = Int`. That is to say, the kind of `a` is being instantiated to `Type`, whereas it ought to be a kind variable. The primary thrust of this patch is to weak the error message to make this connection more obvious: ``` • Illegal argument ‘*’ in: ‘type T @{k} @* a = Int’ The arguments to ‘T’ must all be type variables • In the default type instance declaration for ‘T’ In the class declaration for ‘C’ ``` Along the way, I performed some code cleanup suggested by @rae in https://gitlab.haskell.org/ghc/ghc/issues/13971#note_191287. Before, we were creating a substitution from the default declaration's type variables to the type family tycon's type variables by way of `tcMatchTys`. But this is overkill, since we already know (from the aforementioned validity checking) that all the arguments in a default declaration must be type variables anyway. Therefore, creating the substitution is as simple as using `zipTvSubst`. I took the opportunity to perform this refactoring while I was in town. Fixes #13971. - - - - - 3a38ea44 by Eric Crockett at 2019-04-07T15:21:59-04:00 Fix #16282. Previously, -W(all-)missed-specs was created with 'NoReason', so no information about the flag was printed along with the warning. Now, -Wall-missed-specs is listed as the Reason if it was set, otherwise -Wmissed-specs is listed as the reason. - - - - - 63b7d5fb by Michal Terepeta at 2019-04-08T14:29:34-04:00 Generate straightline code for inline array allocation GHC has an optimization for allocating arrays when the size is statically known -- it'll generate the code allocating and initializing the array inline (instead of a call to a procedure from `rts/PrimOps.cmm`). However, the generated code uses a loop to do the initialization. Since we already check that the requested size is small (we check against `maxInlineAllocSize`), we can generate faster straightline code instead. This brings about 15% improvement for `newSmallArray#` in my testing and slightly simplifies the code in GHC. Signed-off-by: Michal Terepeta <michal.terepeta at gmail.com> - - - - - 2b3f4718 by Phuong Trinh at 2019-04-08T14:35:43-04:00 Fix #16500: look for interface files in -hidir flag in OneShot mode We are currently ignoring options set in the hiDir field of hsc_dflags when looking for interface files while compiling in OneShot mode. This is inconsistent with the behaviour of other directory redirecting fields (such as objectDir or hieDir). It is also inconsistent with the behaviour of compilation in CompManager mode (a.k.a `ghc --make`) which looks for interface files in the directory set in hidir flag. This changes Finder.hs so that we use the value of hiDir while looking for interface in OneShot mode. - - - - - 97502be8 by Yuriy Syrovetskiy at 2019-04-08T14:41:51-04:00 Add `-optcxx` option (#16477) - - - - - 97d3d546 by Ben Gamari at 2019-04-08T14:47:54-04:00 testsuite: Unmark T16190 as broken Was broken via #16389 yet strangely it has started passing despite the fact that the suggested root cause has not changed. - - - - - a42d206a by Yuriy Syrovetskiy at 2019-04-08T14:54:02-04:00 Fix whitespace style - - - - - 4dda2270 by Matthew Pickering at 2019-04-08T15:00:08-04:00 Use ./hadrian/ghci.sh in .ghcid - - - - - d236d9d0 by Sebastian Graf at 2019-04-08T15:06:15-04:00 Make `singleConstructor` cope with pattern synonyms Previously, `singleConstructor` didn't handle singleton `COMPLETE` sets of a single pattern synonym, resulting in incomplete pattern warnings in #15753. This is fixed by making `singleConstructor` (now named `singleMatchConstructor`) query `allCompleteMatches`, necessarily making it effectful. As a result, most of this patch is concerned with threading the side-effect through to `singleMatchConstructor`. Unfortunately, this is not enough to completely fix the original reproduction from #15753 and #15884, which are related to function applications in pattern guards being translated too conservatively. - - - - - 1085090e by Ömer Sinan Ağacan at 2019-04-08T15:12:22-04:00 Skip test ArithInt16 and ArithWord16 in GHCi way These tests use unboxed tuples, which GHCi doesn't support - - - - - 7287bb9e by Ömer Sinan Ağacan at 2019-04-08T15:18:33-04:00 testsuite: Show exit code of GHCi tests on failure - - - - - f5604d37 by John Ericson at 2019-04-08T15:24:43-04:00 settings.in: Reformat We're might be about to switch to generating it in Hadrian/Make. This reformat makes it easier to programmingmatically generate and end up with the exact same thing, which is good for diffing to ensure no regressions. I had this as part of !712, but given the difficulty of satisfying CI, I figured I should break things up even further. - - - - - cf9e1837 by Ryan Scott at 2019-04-08T15:30:51-04:00 Bump hpc submodule Currently, the `hpc` submodule is pinned against the `wip/final-mfp` branch, not against `master`. This pins it back against `master`. - - - - - 36d38047 by Ben Gamari at 2019-04-09T10:23:47-04:00 users-guide: Document how to disable package environments As noted in #16309 this somehow went undocumented. - - - - - af4cea7f by Artem Pyanykh at 2019-04-09T10:30:13-04:00 codegen: fix memset unroll for small bytearrays, add 64-bit sets Fixes #16052 When the offset in `setByteArray#` is statically known, we can provide better alignment guarantees then just 1 byte. Also, memset can now do 64-bit wide sets. The current memset intrinsic is not optimal however and can be improved for the case when we know that we deal with (baseAddress at known alignment) + offset For instance, on 64-bit `setByteArray# s 1# 23# 0#` given that bytearray is 8 bytes aligned could be unrolled into `movb, movw, movl, movq, movq`; but currently it is `movb x23` since alignment of 1 is all we can embed into MO_Memset op. - - - - - bd2de4f0 by Artem Pyanykh at 2019-04-09T10:30:13-04:00 codegen: use newtype for Alignment in BasicTypes - - - - - 14a78707 by Artem Pyanykh at 2019-04-09T10:30:13-04:00 docs: add a note about changes in memset unrolling to 8.10.1-notes - - - - - fe40ddd9 by Sylvain Henry at 2019-04-09T12:50:15-04:00 Hadrian: fix library install paths in bindist Makefile (#16498) GHC now works out-of-the-box (i.e. without any wrapper script) by assuming that @bin@ and @lib@ directories sit next to each other. In particular, its RUNPATH uses $ORIGIN-based relative path to find the libraries. However, to be good citizens we want to support the case where @bin@ and @lib@ directories (respectively BINDIR and LIBDIR) don't sit next to each other or are renamed. To do that the install script simply creates GHC specific @bin@ and @lib@ siblings directories into: LIBDIR/ghc-VERSION/{bin,lib} Then it installs wrapper scripts into BINDIR that call the appropriate programs into LIBDIR/ghc-VERSION/bin/. The issue fixed by this patch is that libraries were not installed into LIBDIR/ghc-VERSION/lib but directly into LIBDIR. - - - - - 9acdc4c0 by Ben Gamari at 2019-04-09T12:56:38-04:00 gitlab: Bump cabal-install version used by Windows builds to 2.4 Hopefully fixes Windows Hadrian build. - - - - - fc3f421b by Joachim Breitner at 2019-04-09T23:17:37-04:00 GHC no longer ever defines TABLES_NEXT_TO_CODE on its own It should be entirely the responsibility of make/Hadrian to ensure that everything that needs this flag gets it. GHC shouldn't be hardcoded to assist with bootstrapping since it builds other things besides itself. Reviewers: Subscribers: TerrorJack, rwbarton, carter GHC Trac Issues: #15548 -- progress towards but not fix Differential Revision: https://phabricator.haskell.org/D5082 -- extract from that - - - - - be0dde8e by Ryan Scott at 2019-04-09T23:23:50-04:00 Use ghc-prim < 0.7, not <= 0.6.1, as upper version bounds Using `ghc-prim <= 0.6.1` is somewhat dodgy from a PVP point of view, as it makes it awkward to support new minor releases of `ghc-prim`. Let's instead use `< 0.7`, which is the idiomatic way of expressing PVP-compliant upper version bounds. - - - - - 42504f4a by Carter Schonwald at 2019-04-10T20:28:41-04:00 removing x87 register support from native code gen * simplifies registers to have GPR, Float and Double, by removing the SSE2 and X87 Constructors * makes -msse2 assumed/default for x86 platforms, fixing a long standing nondeterminism in rounding behavior in 32bit haskell code * removes the 80bit floating point representation from the supported float sizes * theres still 1 tiny bit of x87 support needed, for handling float and double return values in FFI calls wrt the C ABI on x86_32, but this one piece does not leak into the rest of NCG. * Lots of code thats not been touched in a long time got deleted as a consequence of all of this all in all, this change paves the way towards a lot of future further improvements in how GHC handles floating point computations, along with making the native code gen more accessible to a larger pool of contributors. - - - - - c401f8a4 by Sylvain Henry at 2019-04-11T19:51:24-04:00 Hadrian: fix binary-dir with --docs=none Hadrian's "binary-dist" target must check that the "docs" directory exists (it may not since we can disable docs generation). - - - - - 091195a4 by Ömer Sinan Ağacan at 2019-04-11T19:57:38-04:00 Remove unused remilestoning script - - - - - fa0ccbb8 by Ömer Sinan Ağacan at 2019-04-11T19:57:38-04:00 Update a panic message Point users to the right URL - - - - - beaa07d2 by Sylvain Henry at 2019-04-12T13:17:21-04:00 Hadrian: fix ghci wrapper script generation (#16508) - - - - - e05df3e1 by Ben Gamari at 2019-04-12T13:23:30-04:00 gitlab-ci: Ensure that version number has three components - - - - - 885d2e04 by klebinger.andreas at gmx.at at 2019-04-12T14:40:04-04:00 Add -ddump-stg-final to dump stg as it is used for codegen. Intermediate STG does not contain free variables which can be useful sometimes. So adding a flag to dump that info. - - - - - 3c759ced by Alp Mestanogullari at 2019-04-12T14:46:54-04:00 Hadrian: add a --test-accept/-a flag, to mimic 'make accept' When -a or --test-accept is passed, and if one runs the 'test' target, then any test failing because of mismatching output and which is not expected to fail will have its expected output adjusted by the test driver, effectively considering the new output correct from now on. When this flag is passed, hadrian's 'test' target becomes sensitive to the PLATFORM and OS environment variable, just like the Make build system: - when the PLATFORM env var is set to "YES", when accepting a result, accept it for the current platform; - when the OS env var is set to "YES", when accepting a result, accept it for all wordsizes of the current operating system. This can all be combined with `--only="..."` and `TEST="..." to only accept the new output of a subset of tests. - - - - - f4b5a6c0 by Alp Mestanogullari at 2019-04-12T14:46:54-04:00 Hadrian: document -a/--test-accept - - - - - 30a0988d by Ben Gamari at 2019-04-12T15:41:07-04:00 gitlab: Disable windows-hadrian job Not only is it reliably failing due to #16574 but all of the quickly failing builds also causes the Windows runners to run out of disk space. - - - - - 8870a51b by Ben Gamari at 2019-04-12T15:41:07-04:00 gitlab: Don't run lint-submods job on Marge branches This broke Marge by creating a second pipeline (consisting of only the `lint-submods` job). Marge then looked at this pipeline and concluded that CI for her merge branch passed. However, this is ignores the fact that the majority of the CI jobs are triggered on `merge_request` and are therefore in another pipeline. - - - - - 7876d088 by Ben Gamari at 2019-04-13T09:51:59-04:00 linters: Fix check-version-number This should have used `grep -E`, not `grep -e` - - - - - 2e7b2e55 by Ara Adkins at 2019-04-13T10:00:02-04:00 [skip ci] Update CI badge in readme This trivial MR updates the CI badge in the readme to point to the new CI on gitlab, rather than the very out-of-date badge from Travis. - - - - - 40848a43 by Ben Gamari at 2019-04-13T10:02:36-04:00 base: Better document implementation implications of Data.Timeout As noted in #16546 timeout uses asynchronous exceptions internally, an implementation detail which can leak out in surprising ways. Note this fact. Also expose the `Timeout` tycon. [skip ci] - - - - - 5f183081 by David Eichmann at 2019-04-14T01:08:15-04:00 Hadrian: add rts shared library symlinks for backwards compatability Fixes test T3807 when building with Hadrian. Trac #16370 - - - - - 9b142c53 by Sylvain Henry at 2019-04-14T01:14:23-04:00 Hadrian: add binary-dist-dir target This patch adds an Hadrian target "binary-dist-dir". Compared to "binary-dist", it only builds a binary distribution directory without creating the Tar archive. It makes the use/test of the bindist installation script easier. - - - - - 6febc444 by Krzysztof Gogolewski at 2019-04-14T01:20:29-04:00 Fix assertion failures reported in #16533 - - - - - edcef7b3 by Artem Pyanykh at 2019-04-14T01:26:35-04:00 codegen: unroll memcpy calls for small bytearrays - - - - - 6094d43f by Artem Pyanykh at 2019-04-14T01:26:35-04:00 docs: mention memcpy optimization for ByteArrays in 8.10.1-notes - - - - - d2271fe4 by Simon Jakobi at 2019-04-14T08:43:17-04:00 Ord docs: Add explanation on 'min' and 'max' operator interactions [ci skip] - - - - - e7cad16c by Krzysztof Gogolewski at 2019-04-14T08:49:23-04:00 Add a safeguard to Core Lint Lint returns a pair (Maybe a, WarnsAndErrs). The Maybe monad allows to handle an unrecoverable failure. In case of such a failure, the error should be added to the second component of the pair. If this is not done, Lint will silently accept bad programs. This situation actually happened during development of linear types. This adds a safeguard. - - - - - c54a093f by Ben Gamari at 2019-04-14T08:55:29-04:00 CODEOWNERS: Add simonmar as owner of rts/linker I suspect this is why @simonmar wasn't notified of !706. [skip ci] - - - - - 1825f50d by Alp Mestanogullari at 2019-04-14T09:01:38-04:00 Hadrian: don't accept p_dyn for executables, to fix --flavour=prof - - - - - b024e289 by Giles Anderson at 2019-04-15T06:20:29-04:00 Document how -O3 is handled by GHC -O2 is the highest value of optimization. -O3 will be reverted to -O2. - - - - - 4b1ef06d by Giles Anderson at 2019-04-15T06:20:29-04:00 Apply suggestion to docs/users_guide/using-optimisation.rst - - - - - 71cf94db by Fraser Tweedale at 2019-04-15T06:26:37-04:00 GHCi: fix load order of .ghci files Directives in .ghci files in the current directory ("local .ghci") can be overridden by global files. Change the order in which the configs are loaded: global and $HOME/.ghci first, then local. Also introduce a new field to GHCiState to control whether local .ghci gets sourced or ignored. This commit does not add a way to set this value (a subsequent commit will add this), but the .ghci sourcing routine respects its value. Fixes: https://gitlab.haskell.org/ghc/ghc/issues/14689 Related: https://gitlab.haskell.org/ghc/ghc/issues/6017 Related: https://gitlab.haskell.org/ghc/ghc/issues/14250 - - - - - 5c06b60d by Fraser Tweedale at 2019-04-15T06:26:38-04:00 users-guide: update startup script order Update users guide to match the new startup script order. Also clarify that -ignore-dot-ghci does not apply to scripts specified via the -ghci-script option. Part of: https://gitlab.haskell.org/ghc/ghc/issues/14689 - - - - - aa490b35 by Fraser Tweedale at 2019-04-15T06:26:38-04:00 GHCi: add 'local-config' setting Add the ':set local-config { source | ignore }' setting to control whether .ghci file in current directory will be sourced or not. The directive can be set in global config or $HOME/.ghci, which are processed before local .ghci files. The default is "source", preserving current behaviour. Related: https://gitlab.haskell.org/ghc/ghc/issues/6017 Related: https://gitlab.haskell.org/ghc/ghc/issues/14250 - - - - - ed94d345 by Fraser Tweedale at 2019-04-15T06:26:38-04:00 users-guide: document :set local-config Document the ':set local-config' command and add a warning about sourcing untrusted local .ghci scripts. Related: https://gitlab.haskell.org/ghc/ghc/issues/6017 Related: https://gitlab.haskell.org/ghc/ghc/issues/14250 - - - - - be05bd81 by Gabor Greif at 2019-04-15T17:19:03-04:00 asm-emit-time IND_STATIC elimination When a new closure identifier is being established to a local or exported closure already emitted into the same module, refrain from adding an IND_STATIC closure, and instead emit an assembly-language alias. Inter-module IND_STATIC objects still remain, and need to be addressed by other measures. Binary-size savings on nofib are around 0.1%. - - - - - 57eb5bc6 by erthalion at 2019-04-16T15:40:36-04:00 Show dynamic object files (#16062) Closes #16062. When -dynamic-too is specified, reflect that in the progress message, like: $ ghc Main.hs -dynamic-too [1 of 1] Compiling Lib ( Main.hs, Main.o, Main.dyn_o ) instead of: $ ghc Main.hs -dynamic-too [1 of 1] Compiling Lib ( Main.hs, Main.o ) - - - - - 894ec447 by Andrey Mokhov at 2019-04-16T15:46:44-04:00 Hadrian: Generate GHC wrapper scripts This is a temporary workaround for #16534. We generate wrapper scripts <build-root>/ghc-stage1 and <build-root>/ghc-stage2 that can be used to run Stage1 and Stage2 GHCs with the right arguments. See https://gitlab.haskell.org/ghc/ghc/issues/16534. - - - - - e142ec99 by Sven Tennie at 2019-04-17T23:19:00-04:00 Typeset Big-O complexities with Tex-style notation (#16090) E.g. use `\(\mathcal{O}(n^2)\)` instead of `/O(n^2)/`. - - - - - f0f495f0 by klebinger.andreas at gmx.at at 2019-04-17T23:25:10-04:00 Add an Outputable instance for SDoc with ppr = id. When printf debugging this can be helpful. - - - - - e28706ea by Sylvain Henry at 2019-04-18T08:12:07-04:00 Gitlab: allow execution of CI pipeline from the web interface [skip ci] - - - - - 4c8a67a4 by Alp Mestanogullari at 2019-04-18T08:18:18-04:00 Hadrian: fix ghcDebugged and document it - - - - - 5988f17a by Alp Mestanogullari at 2019-04-18T22:46:12-04:00 Hadrian: fix the value we pass to the test driver for config.compiler_debugged We used to pass YES/NO, while that particular field is set to True/False. This happens to fix an unexpected pass, T9208. - - - - - 57cf1133 by Alec Theriault at 2019-04-18T22:52:25-04:00 TH: make `Lift` and `TExp` levity-polymorphic Besides the obvious benefits of being able to manipulate `TExp`'s of unboxed types, this also simplified `-XDeriveLift` all while making it more capable. * `ghc-prim` is explicitly depended upon by `template-haskell` * The following TH things are parametrized over `RuntimeRep`: - `TExp(..)` - `unTypeQ` - `unsafeTExpCoerce` - `Lift(..)` * The following instances have been added to `Lift`: - `Int#`, `Word#`, `Float#`, `Double#`, `Char#`, `Addr#` - unboxed tuples of lifted types up to arity 7 - unboxed sums of lifted types up to arity 7 Ideally we would have levity-polymorphic _instances_ of unboxed tuples and sums. * The code generated by `-XDeriveLift` uses expression quotes instead of generating large amounts of TH code and having special hard-coded cases for some unboxed types. - - - - - fdfd9731 by Alec Theriault at 2019-04-18T22:52:25-04:00 Add test case for #16384 Now that `TExp` accepts unlifted types, #16384 is fixed. Since the real issue there was GHC letting through an ill-kinded type which `-dcore-lint` rightly rejected, a reasonable regression test is that the program from #16384 can now be accepted without `-dcore-lint` complaining. - - - - - eb2a4df8 by Michal Terepeta at 2019-04-19T23:32:08-04:00 StgCmmPrim: remove an unnecessary instruction in doNewArrayOp Previously we would generate a local variable pointing after the array header and use it to initialize the array elements. But we already use stores with offset, so it's easy to just add the header to those offsets during compilation and avoid generating the local variable (which would become a LEA instruction when using native codegen; LLVM already optimizes it away). Signed-off-by: Michal Terepeta <michal.terepeta at gmail.com> - - - - - fcef26b6 by klebinger.andreas at gmx.at at 2019-04-19T23:38:16-04:00 Don't indent single alternative case expressions for STG. Makes the width of STG dumps slightly saner. Especially for things like unboxing. Fixes #16580 - - - - - e7280c93 by Vladislav Zavialov at 2019-04-19T23:44:24-04:00 Tagless final encoding of ExpCmdI in the parser Before this change, we used a roundabout encoding: 1. a GADT (ExpCmdG) 2. a class to pass it around (ExpCmdI) 3. helpers to match on it (ecHsApp, ecHsIf, ecHsCase, ...) It is more straightforward to turn these helpers into class methods, removing the need for a GADT. - - - - - 99dd5d6b by Alec Theriault at 2019-04-19T23:50:29-04:00 Haddock: support strict GADT args with docs Rather than massaging the output of the parser to re-arrange docs and bangs, it is simpler to patch the two places in which the strictness info is needed (to accept that the `HsBangTy` may be inside an `HsDocTy`). Fixes #16585. - - - - - 10776562 by Andrey Mokhov at 2019-04-19T23:56:38-04:00 Hadrian: Drop old/unused CI scripts - - - - - 37b1a6da by Ben Gamari at 2019-04-20T11:55:20-04:00 gitlab-ci: Improve error message on failure of doc-tarball job Previously the failure was quite nondescript. - - - - - e3fe2601 by Ben Gamari at 2019-04-20T11:55:35-04:00 gitlab-ci: Allow doc-tarball job to fail Due to allowed failure of Windows job. - - - - - bd3872df by Ben Gamari at 2019-04-20T11:55:38-04:00 gitlab-ci: Only run release notes lint on release tags - - - - - 2145b738 by Ben Gamari at 2019-04-20T11:55:38-04:00 gitlab-ci: Add centos7 release job - - - - - 983c53c3 by Ben Gamari at 2019-04-20T11:55:38-04:00 gitlab-ci: Do not build profiled libraries on 32-bit Windows Due to #15934. - - - - - 5cf771f3 by Ben Gamari at 2019-04-21T09:07:13-04:00 users-guide: Add pretty to package list - - - - - 6ac5da78 by Ben Gamari at 2019-04-21T09:07:13-04:00 users-guide: Add libraries section to 8.10.1 release notes - - - - - 3e963de3 by Andrew Martin at 2019-04-21T09:13:20-04:00 improve docs for casArray and casSmallArray - - - - - 98bffb07 by Andrew Martin at 2019-04-21T09:13:20-04:00 [skip ci] say "machine words" instead of "Int units" in the primops docs - - - - - 3aefc14a by Andrew Martin at 2019-04-21T09:13:20-04:00 [skip ci] correct formatting of casArray# in docs for casSmallArray# - - - - - 0e96d120 by Andrew Martin at 2019-04-21T09:13:20-04:00 [skip ci] correct the docs for casArray a little more. clarify that the returned element may be two different things - - - - - 687152f2 by Artem Pyanykh at 2019-04-21T09:19:29-04:00 testsuite: move tests related to linker under tests/rts/linker - - - - - 36e51406 by Artem Pyanykh at 2019-04-21T09:19:29-04:00 testsuite: fix ifdef lint errors under tests/rts/linker - - - - - 1a7a329b by Matthew Pickering at 2019-04-22T14:37:30-04:00 Correct off by one error in ghci +c Fixes #16569 - - - - - 51655fd8 by Alp Mestanogullari at 2019-04-22T14:44:11-04:00 Hadrian: use the testsuite driver's config.haddock arg more correctly 4 haddock tests assume that .haddock files have been produced, by using the 'req_haddock' modifier. The testsuite driver assumes that this condition is satisfied if 'config.haddock' is non-empty, but before this patch Hadrian was always passing the path to where the haddock executable should be, regardless of whether it is actually there or not. Instead, we now pass an empty config.haddock when we can't find all of <build root>/docs/html/libraries/<pkg>/<pkg>.haddock>, where <pkg> ranges over array, base, ghc-prim, process and template-haskell, and pass the path to haddock when all those file exists. This has the (desired) effect of skipping the 4 tests (marked as 'missing library') when the docs haven't been built, and running the haddock tests when they have. - - - - - 1959bad3 by Vladislav Zavialov at 2019-04-22T14:50:18-04:00 Stop misusing EWildPat in pattern match coverage checking EWildPat is a constructor of HsExpr used in the parser to represent wildcards in ambiguous positions: * in expression context, EWildPat is turned into hsHoleExpr (see rnExpr) * in pattern context, EWildPat is turned into WildPat (see checkPattern) Since EWildPat exists solely for the needs of the parser, we could remove it by improving the parser. However, EWildPat has also been used for a different purpose since 8a50610: to represent patterns that the coverage checker cannot handle. Not only this is a misuse of EWildPat, it also stymies the removal of EWildPat. - - - - - 6a491726 by Fraser Tweedale at 2019-04-23T09:27:30-04:00 osReserveHeapMemory: handle signed rlim_t rlim_t is a signed type on FreeBSD, and the build fails with a sign-compare error. Add explicit (unsigned) cast to handle this case. - - - - - ab9b3ace by Alexandre Baldé at 2019-04-23T09:33:37-04:00 Fix error message for './configure' regarding '--with-ghc' [skip ci] - - - - - 465f8f48 by Ben Gamari at 2019-04-24T12:19:24-04:00 gitlab-ci: source-tarball job should have no dependencies - - - - - 0fc69416 by Vladislav Zavialov at 2019-04-25T14:28:56-04:00 Introduce MonadP, make PV a newtype Previously we defined type PV = P, this had the downside that if we wanted to change PV, we would have to modify P as well. Now PV is free to evolve independently from P. The common operations addError, addFatalError, getBit, addAnnsAt, were abstracted into a class called MonadP. - - - - - f85efdec by Vladislav Zavialov at 2019-04-25T14:28:56-04:00 checkPattern error hint is PV context There is a hint added to error messages reported in checkPattern. Instead of passing it manually, we put it in a ReaderT environment inside PV. - - - - - 4e228267 by Ömer Sinan Ağacan at 2019-04-25T14:35:09-04:00 Minor RTS refactoring: - Remove redundant casting in evacuate_static_object - Remove redundant parens in STATIC_LINK - Fix a typo in GC.c - - - - - faa94d47 by Ben Gamari at 2019-04-25T17:16:21-04:00 update-autoconf: Initial commit - - - - - 4811cd39 by Ben Gamari at 2019-04-25T17:16:21-04:00 Update autoconf scripts Scripts taken from autoconf a8d79c3130da83c7cacd6fee31b9acc53799c406 - - - - - 0040af59 by Ben Gamari at 2019-04-25T17:16:21-04:00 gitlab-ci: Reintroduce DWARF-enabled bindists It seems that this was inadvertently dropped in 1285d6b95fbae7858abbc4722bc2301d7fe40425. - - - - - 2c115085 by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 rename: hadle type signatures with typos When encountering type signatures for unknown names, suggest similar alternatives. This fixes issue #16504 - - - - - fb9408dd by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 Print suggestions in a single message - - - - - e8bf8834 by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 osa1's patch: consistent suggestion message - - - - - 1deb2bb0 by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 Comment on 'candidates' function - - - - - 8ee47432 by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 Suggest only local candidates from global env - - - - - e23f78ba by Wojciech Baranowski at 2019-04-29T21:02:38-04:00 Use pp_item - - - - - 1abb76ab by Ben Gamari at 2019-04-29T21:08:45-04:00 ghci: Ensure that system libffi include path is searched Previously hsc2hs failed when building against a system FFI. - - - - - 014ed644 by Sebastian Graf at 2019-04-30T20:23:21-04:00 Compute demand signatures assuming idArity This does four things: 1. Look at `idArity` instead of manifest lambdas to decide whether to use LetUp 2. Compute the strictness signature in LetDown assuming at least `idArity` incoming arguments 3. Remove the special case for trivial RHSs, which is subsumed by 2 4. Don't perform the W/W split when doing so would eta expand a binding. Otherwise we would eta expand PAPs, causing unnecessary churn in the Simplifier. NoFib Results -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- fannkuch-redux +0.3% 0.0% gg -0.0% -0.1% maillist +0.2% +0.2% minimax 0.0% +0.8% pretty 0.0% -0.1% reptile -0.0% -1.2% -------------------------------------------------------------------------------- Min -0.0% -1.2% Max +0.3% +0.8% Geometric Mean +0.0% -0.0% - - - - - d37d91e9 by John Ericson at 2019-04-30T20:29:31-04:00 Generate settings by make/hadrian instead of configure This allows it to eventually become stage-specific - - - - - 53d1cd96 by John Ericson at 2019-04-30T20:29:31-04:00 Remove settings.in It is no longer needed - - - - - 2988ef5e by John Ericson at 2019-04-30T20:29:31-04:00 Move cGHC_UNLIT_PGM to be "unlit command" in settings The bulk of the work was done in #712, making settings be make/Hadrian controlled. This commit then just moves the unlit command rules in make/Hadrian from the `Config.hs` generator to the `settings` generator in each build system. I think this is a good change because the crucial benefit is *settings* don't affect the build: ghc gets one baby step closer to being a regular cabal executable, and make/Hadrian just maintains settings as part of bootstrapping. - - - - - 37a4fd97 by Alp Mestanogullari at 2019-04-30T20:35:35-04:00 Build Hadrian with -Werror in the 'ghc-in-ghci' CI job - - - - - 1bef62c3 by Ben Gamari at 2019-04-30T20:41:42-04:00 ErrUtils: Emit progress messages to eventlog - - - - - ebfa3528 by Ben Gamari at 2019-04-30T20:41:42-04:00 Emit GHC timing events to eventlog - - - - - 4186b410 by Sven Tennie at 2019-05-03T13:40:36-04:00 Typeset Big-O complexities with Tex-style notation (#16090) Use `\min` instead of `min` to typeset it as an operator. - - - - - 9047f184 by Shayne Fletcher at 2019-05-03T21:54:50+03:00 Make Extension derive Bounded - - - - - 0dde64f2 by Ben Gamari at 2019-05-03T21:54:50+03:00 testsuite: Mark concprog001 as fragile Due to #16604. - - - - - 8f929388 by Alp Mestanogullari at 2019-05-03T21:54:50+03:00 Hadrian: generate JUnit testsuite report in Linux CI job We also keep it as an artifact, like we do for non-Hadrian jobs, and list it as a junit report, so that the test results are reported in the GitLab UI for merge requests. - - - - - 52fc2719 by Vladislav Zavialov at 2019-05-03T21:54:50+03:00 Pattern/expression ambiguity resolution This patch removes 'EWildPat', 'EAsPat', 'EViewPat', and 'ELazyPat' from 'HsExpr' by using the ambiguity resolution system introduced earlier for the command/expression ambiguity. Problem: there are places in the grammar where we do not know whether we are parsing an expression or a pattern, for example: do { Con a b <- x } -- 'Con a b' is a pattern do { Con a b } -- 'Con a b' is an expression Until we encounter binding syntax (<-) we don't know whether to parse 'Con a b' as an expression or a pattern. The old solution was to parse as HsExpr always, and rejig later: checkPattern :: LHsExpr GhcPs -> P (LPat GhcPs) This meant polluting 'HsExpr' with pattern-related constructors. In other words, limitations of the parser were affecting the AST, and all other code (the renamer, the typechecker) had to deal with these extra constructors. We fix this abstraction leak by parsing into an overloaded representation: class DisambECP b where ... newtype ECP = ECP { runECP_PV :: forall b. DisambECP b => PV (Located b) } See Note [Ambiguous syntactic categories] for details. Now the intricacies of parsing have no effect on the hsSyn AST when it comes to the expression/pattern ambiguity. - - - - - 9b59e126 by Ningning Xie at 2019-05-03T21:54:50+03:00 Only skip decls with CUSKs with PolyKinds on (fix #16609) - - - - - 87bc954a by Ömer Sinan Ağacan at 2019-05-03T21:54:50+03:00 Fix interface version number printing in --show-iface Before Version: Wanted [8, 0, 9, 0, 2, 0, 1, 9, 0, 4, 2, 5], got [8, 0, 9, 0, 2, 0, 1, 9, 0, 4, 2, 5] After Version: Wanted 809020190425, got 809020190425 - - - - - cc495d57 by Ryan Scott at 2019-05-03T21:54:50+03:00 Make equality constraints in kinds invisible Issues #12102 and #15872 revealed something strange about the way GHC handles equality constraints in kinds: it treats them as _visible_ arguments! This causes a litany of strange effects, from strange error messages (https://gitlab.haskell.org/ghc/ghc/issues/12102#note_169035) to bizarre `Eq#`-related things leaking through to GHCi output, even without any special flags enabled. This patch is an attempt to contain some of this strangeness. In particular: * In `TcHsType.etaExpandAlgTyCon`, we propagate through the `AnonArgFlag`s of any `Anon` binders. Previously, we were always hard-coding them to `VisArg`, which meant that invisible binders (like those whose kinds were equality constraint) would mistakenly get flagged as visible. * In `ToIface.toIfaceAppArgsX`, we previously assumed that the argument to a `FunTy` always corresponding to a `Required` argument. We now dispatch on the `FunTy`'s `AnonArgFlag` and map `VisArg` to `Required` and `InvisArg` to `Inferred`. As a consequence, the iface pretty-printer correctly recognizes that equality coercions are inferred arguments, and as a result, only displays them in `-fprint-explicit-kinds` is enabled. * Speaking of iface pretty-printing, `Anon InvisArg` binders were previously being pretty-printed like `T (a :: b ~ c)`, as if they were required. This seemed inconsistent with other invisible arguments (that are printed like `T @{d}`), so I decided to switch this to `T @{a :: b ~ c}`. Along the way, I also cleaned up a minor inaccuracy in the users' guide section for constraints in kinds that was spotted in https://gitlab.haskell.org/ghc/ghc/issues/12102#note_136220. Fixes #12102 and #15872. - - - - - f862963b by Ömer Sinan Ağacan at 2019-05-03T20:50:03-04:00 rts: Properly free the RTSSummaryStats structure `stat_exit` always allocates a `RTSSummaryStats` but only sometimes frees it, which casues leaks. With this patch we unconditionally free the structure, fixing the leak. Fixes #16584 - - - - - 0af93d16 by Ömer Sinan Ağacan at 2019-05-03T20:56:18-04:00 StgCmmMonad: remove emitProc_, don't export emitProc - - - - - 0a3e4db3 by Ömer Sinan Ağacan at 2019-05-03T20:56:18-04:00 PrimOps.cmm: remove unused stuff - - - - - 63150b9e by iustin at 2019-05-04T17:54:23-04:00 Fix typo in 8.8.1 notes related to traceBinaryEvent - fixes double mention of `traceBinaryEvent#` (the second one should be `traceEvent#`, I think) - fixes note about `traceEvent#` taking a `String` - the docs say it takes a zero-terminated ByteString. - - - - - dc8a5868 by gallais at 2019-05-04T18:00:30-04:00 [ typo ] 'castFloatToWord32' -> 'castFloatToWord64' Probably due to a copy/paste gone wrong. - - - - - 615b4be6 by Chaitanya Koparkar at 2019-05-05T10:39:24-04:00 Fix #16593 by having only one definition of -fprint-explicit-runtime-reps [skip ci] - - - - - ead3f835 by Vladislav Zavialov at 2019-05-05T10:39:24-04:00 'warnSpaceAfterBang' only in patterns (#16619) - - - - - 27941064 by John Ericson at 2019-05-06T14:59:29-04:00 Remove cGhcEnableTablesNextToCode Get "Tables next to code" from the settings file instead. - - - - - 821fa9e8 by Takenobu Tani at 2019-05-06T15:05:36-04:00 Remove `$(TOP)/ANNOUNCE` file Remove `$(TOP)/ANNOUNCE` because maintaining this file is expensive for each release. Currently, release announcements of ghc are made on ghc blogs and wikis. [skip ci] - - - - - e172a6d1 by Alp Mestanogullari at 2019-05-06T15:11:43-04:00 Enable external interpreter when TH is requested but no internal interpreter is available - - - - - ba0aed2e by Alp Mestanogullari at 2019-05-06T17:32:56-04:00 Hadrian: override $(ghc-config-mk), to prevent redundant config generation This required making the 'ghc-config-mk' variable overridable in testsuite/mk/boilerplate.mk, and then making use of this in hadrian to point to '<build root>/test/ghcconfig' instead, which is where we always put the test config. Previously, we would build ghc-config and run it against the GHC to be tested, a second time, while we're running the tests, because some include testsuite/mk/boilerplate.mk. This was causing unexpected output failures. - - - - - 96197961 by Ryan Scott at 2019-05-07T06:35:58-04:00 Add /includes/dist to .gitignore As of commit d37d91e9a444a7822eef1558198d21511558515e, the GHC build now autogenerates a `includes/dist/build/settings` file. To avoid dirtying the current `git` status, this adds `includes/dist` to `.gitignore`. [ci skip] - - - - - 78a5c4ce by Ryan Scott at 2019-05-07T17:03:04-04:00 Check for duplicate variables in associated default equations A follow-up to !696's, which attempted to clean up the error messages for ill formed associated type family default equations. The previous attempt, !696, forgot to account for the possibility of duplicate kind variable arguments, as in the following example: ```hs class C (a :: j) where type T (a :: j) (b :: k) type T (a :: k) (b :: k) = k ``` This patch addresses this shortcoming by adding an additional check for this. Fixes #13971 (hopefully for good this time). - - - - - f58ea556 by Kevin Buhr at 2019-05-07T17:09:13-04:00 Add regression test for old typechecking issue #505 - - - - - 786e665b by Ryan Scott at 2019-05-08T01:55:45-04:00 Fix #16603 by documenting some important changes in changelogs This addresses some glaring omissions from `libraries/base/changelog.md` and `docs/users_guide/8.8.1-notes.rst`, fixing #16603 in the process. - - - - - 0eeb4cfa by Ryan Scott at 2019-05-08T02:01:54-04:00 Fix #16632 by using the correct SrcSpan in checkTyClHdr `checkTyClHdr`'s case for `HsTyVar` was grabbing the wrong `SrcSpan`, which lead to error messages pointing to the wrong location. Easily fixed. - - - - - ed5f858b by Shayne Fletcher at 2019-05-08T15:29:01-04:00 Implement ImportQualifiedPost - - - - - d9bdff60 by Kevin Buhr at 2019-05-08T15:35:13-04:00 stg_floatToWord32zh: zero-extend the Word32 (#16617) The primop stgFloatToWord32 was sign-extending the 32-bit word, resulting in weird negative Word32s. Zero-extend them instead. Closes #16617. - - - - - 9a3acac9 by Ömer Sinan Ağacan at 2019-05-08T15:41:17-04:00 Print PAP object address in stg_PAP_info entry code Continuation to ce23451c - - - - - 4c86187c by Richard Eisenberg at 2019-05-08T15:47:33-04:00 Regression test for #16627. test: typecheck/should_fail/T16627 - - - - - 93f34bbd by John Ericson at 2019-05-08T15:53:40-04:00 Purge TargetPlatform_NAME and cTargetPlatformString - - - - - 9d9af0ee by Kevin Buhr at 2019-05-08T15:59:46-04:00 Add regression test for old issue #507 - - - - - 396e01b4 by Vladislav Zavialov at 2019-05-08T16:05:52-04:00 Add a regression test for #14548 - - - - - 5eb94454 by Oleg Grenrus at 2019-05-10T16:26:28-04:00 Add Generic tuple instances up to 15-tuple Why 15? Because we have Eq instances up to 15. Metric Increase: T9630 haddock.base - - - - - c7913f71 by Roland Senn at 2019-05-10T16:32:38-04:00 Fix bugs and documentation for #13456 - - - - - bfcd986d by David Eichmann at 2019-05-10T16:38:57-04:00 Hadrian: programs need registered ghc-pkg libraries In Hadrian, building programs (e.g. `ghc` or `haddock`) requires libraries located in the ghc-pkg package database i.e. _build/stage1/lib/x86_64-linux-ghc-8.9.0.20190430/libHSdeepseq-1.4.4.0-ghc8.9.0.20190430.so Add the corresponding `need`s for these library files and the subsequent rules. - - - - - 10f579ad by Ben Gamari at 2019-05-10T16:45:05-04:00 gitlab-ci: Disable cleanup job on Windows As discussed in the Note, we now have a cron job to handle this and the cleanup job itself is quite fragile. [skip ci] - - - - - 6f07f828 by Kevin Buhr at 2019-05-10T16:51:11-04:00 Add regression test case for old issue #493 - - - - - 4e25bf46 by Giles Anderson at 2019-05-13T19:01:52-04:00 Change GHC.hs to Packages.hs in Hadrian user-settings.md ... "all packages that are currently built as part of the GHC are defined in src/Packages.hs" - - - - - 357be128 by Kevin Buhr at 2019-05-14T16:41:19-04:00 Add regression test for old parser issue #504 - - - - - 015a21b8 by John Ericson at 2019-05-14T16:41:19-04:00 hadrian: Make settings stage specific - - - - - f9e4ea40 by John Ericson at 2019-05-14T16:41:19-04:00 Dont refer to `cLeadingUnderscore` in test Can't use this config entry because it's about to go away - - - - - e529c65e by John Ericson at 2019-05-14T16:41:19-04:00 Remove all target-specific portions of Config.hs 1. If GHC is to be multi-target, these cannot be baked in at compile time. 2. Compile-time flags have a higher maintenance than run-time flags. 3. The old way makes build system implementation (various bootstrapping details) with the thing being built. E.g. GHC doesn't need to care about which integer library *will* be used---this is purely a crutch so the build system doesn't need to pass flags later when using that library. 4. Experience with cross compilation in Nixpkgs has shown things work nicer when compiler's can *optionally* delegate the bootstrapping the package manager. The package manager knows the entire end-goal build plan, and thus can make top-down decisions on bootstrapping. GHC can just worry about GHC, not even core library like base and ghc-prim! - - - - - 5cf8032e by Oleg Grenrus at 2019-05-14T16:41:19-04:00 Update terminal title while running test-suite Useful progress indicator even when `make test VERBOSE=1`, and when you do something else, but have terminal title visible. - - - - - c72c369b by Vladislav Zavialov at 2019-05-14T16:41:19-04:00 Add a minimized regression test for #12928 - - - - - a5fdd185 by Vladislav Zavialov at 2019-05-14T16:41:19-04:00 Guard CUSKs behind a language pragma GHC Proposal #36 describes a transition plan away from CUSKs and to top-level kind signatures: 1. Introduce a new extension, -XCUSKs, on by default, that detects CUSKs as they currently exist. 2. We turn off the -XCUSKs extension in a few releases and remove it sometime thereafter. This patch implements phase 1 of this plan, introducing a new language extension to control whether CUSKs are enabled. When top-level kind signatures are implemented, we can transition to phase 2. - - - - - 684dc290 by Vladislav Zavialov at 2019-05-14T16:41:19-04:00 Restore the --coerce option in 'happy' configuration happy-1.19.10 has been released with a fix for --coerce in the presence of higher rank types. This should result in about 10% performance improvement in the parser. - - - - - a416ae26 by Alp Mestanogullari at 2019-05-14T16:41:20-04:00 Hadrian: 'need' source files for various docs in Rules.Documentation Previously, changing one of the .rst files from the user guide would not cause the user guide to be rebuilt. This patch take a first stab at declaring the documentation source files that our documentation rules depend on, focusing on the .rst files only for now. We eventually might want to rebuild docs when we, say, change the haddock style file, but this level of tracking isn't really necessary for now. This fixes #16645. - - - - - 7105fb66 by Ben Gamari at 2019-05-16T12:47:59-04:00 rts: Explicit state that CONSTR tag field is zero-based This was a bit unclear as we use both one-based and zero-based tags in GHC. [skip ci] - - - - - 5bb80cf2 by David Eichmann at 2019-05-20T15:41:55+01:00 Improve test runner logging when calculating performance metric baseline #16662 We attempt to get 75 commit hashes via `git log`, but this only gave 10 hashes in a CI run (see #16662). Better logging may help solve this error if it occurs again in the future. - - - - - b46efa2b by David Eichmann at 2019-05-20T19:45:56+01:00 Recalculate Performance Test Baseline T9630 #16680 Metric Decrease: T9630 - - - - - 54095bbd by Takenobu Tani at 2019-05-21T16:54:00-04:00 users-guide: Fix directive errors on 8.10 The following sections are not displayed due to a directive error: * -Wunused-record-wildcards * -Wredundant-record-wildcards I changed the location of the `since` directive. [skip ci] - - - - - 8fc654c3 by David Eichmann at 2019-05-21T16:57:37-04:00 Include CPP preprocessor dependencies in -M output Issue #16521 - - - - - 0af519ac by David Eichmann at 2019-05-21T17:01:16-04:00 Refactor Libffi and RTS rules This removes a hack that copies libffi files to the rts build directory. This was done in a libffi rule, but now an rts rule correctly needs and copies the relevant files from the libffi build dir to the rts build dir. Issues: #16272 #16304 - - - - - 9342b1fa by Kirill Elagin at 2019-05-21T17:04:54-04:00 users-guide: Fix -rtsopts default - - - - - d0142f21 by Javran Cheng at 2019-05-21T17:08:29-04:00 Fix doc for Data.Function.fix. Doc-only change. - - - - - ddd905b4 by Shayne Fletcher at 2019-05-21T17:12:07-04:00 Update resolver for for happy 1.19.10 - - - - - e32c30ca by Alp Mestanogullari at 2019-05-21T17:15:45-04:00 distrib/configure.ac.in: remove mention to 'settings', since settings.in is gone Otherwise, when `./configure`ing a GHC bindist, produced by either Make or Hadrian, we would try to generate the `settings` file from the `settings.in` template that we used to have around but which has been gone since d37d91e9. That commit generates the settings file using the build systems instead, but forgot to remove this mention to the `settings` file. - - - - - 4a6c8436 by Ryan Scott at 2019-05-21T17:19:22-04:00 Fix #16666 by parenthesizing contexts in Convert Most places where we convert contexts in `Convert` are actually in positions that are to the left of some `=>`, such as in superclasses and instance contexts. Accordingly, these contexts need to be parenthesized at `funPrec`. To accomplish this, this patch changes `cvtContext` to require a precedence argument for the purposes of calling `parenthesizeHsContext` and adjusts all `cvtContext` call sites accordingly. - - - - - c32f64e5 by Ben Gamari at 2019-05-21T17:23:01-04:00 gitlab-ci: Allow Windows Hadrian build to fail Due to #16574. - - - - - 412a1f39 by Ben Gamari at 2019-05-21T17:23:01-04:00 Update .gitlab-ci.yml - - - - - 0dc79856 by Julian Leviston at 2019-05-21T20:55:44-04:00 Allow for multiple linker instances. Fixes Haskell portion of #3372. - - - - - 21272670 by Michael Sloan at 2019-05-22T16:37:57-04:00 Have GHCi use object code for UnboxedTuples modules #15454 The idea is to automatically enable -fobject-code for modules that use UnboxedTuples, along with all the modules they depend on. When looking into how to solve this, I was pleased to find that there was already highly similar logic for enabling code generation when -fno-code is specified but TemplateHaskell is used. The state before this patch was that if you used unboxed tuples then you had to enable `-fobject-code` globally rather than on a per module basis. - - - - - ddae344e by Michael Sloan at 2019-05-22T16:41:31-04:00 Use datatype for unboxed returns when loading ghc into ghci See #13101 and #15454 - - - - - 78c3f330 by Kevin Buhr at 2019-05-22T16:45:08-04:00 Add regression test for old Word32 arithmetic issue (#497) - - - - - ecc9366a by Alec Theriault at 2019-05-22T16:48:45-04:00 RTS: Fix restrictive cast Commit e75a9afd2989e0460f9b49fa07c1667299d93ee9 added an `unsigned` cast to account for OSes that have signed `rlim_t` signed. Unfortunately, the `unsigned` cast has the unintended effect of narrowing `rlim_t` to only 4 bytes. This leads to some spurious out of memory crashes (in particular: Haddock crashes with OOM whenn building docs of `ghc`-the-library). In this case, `W_` is a better type to cast to: we know it will be unsigned too and it has the same type as `*len` (so we don't suffer from accidental narrowing). - - - - - 2c15b85e by Alp Mestanogullari at 2019-05-22T16:52:22-04:00 Hadrian: add --test-root-dirs, to only run specific directories of tests We can specify several of those, by using the flag multiple times or just once but combining the directories with ':'. Along the way, this patch also fixes the testsuite-related --only flag, so that we can use it many times instead of being force to specify a space-separated list of test in a single --only flag. - - - - - 6efe04de by Ryan Scott at 2019-05-22T16:56:01-04:00 Use HsTyPats in associated type family defaults Associated type family default declarations behave strangely in a couple of ways: 1. If one tries to bind the type variables with an explicit `forall`, the `forall`'d part will simply be ignored. (#16110) 2. One cannot use visible kind application syntax on the left-hand sides of associated default equations, unlike every other form of type family equation. (#16356) Both of these issues have a common solution. Instead of using `LHsQTyVars` to represent the left-hand side arguments of an associated default equation, we instead use `HsTyPats`, which is what other forms of type family equations use. In particular, here are some highlights of this patch: * `FamEqn` is no longer parameterized by a `pats` type variable, as the `feqn_pats` field is now always `HsTyPats`. * The new design for `FamEqn` in chronicled in `Note [Type family instance declarations in HsSyn]`. * `TyFamDefltEqn` now becomes the same thing as `TyFamInstEqn`. This means that many of `TyFamDefltEqn`'s code paths can now reuse the code paths for `TyFamInstEqn`, resulting in substantial simplifications to various parts of the code dealing with associated type family defaults. Fixes #16110 and #16356. - - - - - 4ba73e00 by Luite Stegeman at 2019-05-22T16:59:39-04:00 fix Template Haskell cross compilation on 64 bit compiler with 32 bit target - - - - - 535a26c9 by David Eichmann at 2019-05-23T18:26:37+01:00 Revert "Add Generic tuple instances up to 15-tuple" #16688 This reverts commit 5eb9445444c4099fc9ee0803ba45db390900a80f. It has caused an increase in variance of performance test T9630, causing CI to fail. - - - - - 04b4b984 by Alp Mestanogullari at 2019-05-23T22:32:15-04:00 add an --hadrian mode to ./validate When the '--hadrian' flag is passed to the validate script, we use hadrian to build GHC, package it up in a binary distribution and later on run GHC's testsuite against the said bindist, which gets installed locally in the process. Along the way, this commit fixes a typo, an omission (build iserv binaries before producing the bindist archive) and moves the Makefile that enables 'make install' on those bindists from being a list of strings in the code to an actual file (it was becoming increasingly annoying to work with). Finally, the Settings.Builders.Ghc part of this patch is necessary for being able to use the installed binary distribution, in 'validate'. - - - - - 0b449d34 by Ömer Sinan Ağacan at 2019-05-23T22:35:54-04:00 Add a test for #16597 - - - - - 59f4cb6f by Iavor Diatchki at 2019-05-23T22:39:35-04:00 Add a `NOINLINE` pragma on `someNatVal` (#16586) This fixes #16586, see `Note [NOINLINE someNatVal]` for details. - - - - - 6eedbd83 by Ryan Scott at 2019-05-23T22:43:12-04:00 Some forall-related cleanup in deriving code * Tweak the parser to allow `deriving` clauses to mention explicit `forall`s or kind signatures without gratuitous parentheses. (This fixes #14332 as a consequence.) * Allow Haddock comments on `deriving` clauses with explicit `forall`s. This requires corresponding changes in Haddock. - - - - - c931f256 by David Eichmann at 2019-05-24T11:22:29+01:00 Allow metric change after reverting "Add Generic tuple instances up to 15-tuple" #16688 Metrics increased on commit 5eb9445444c4099fc9ee0803ba45db390900a80f and decreased on revert commit 535a26c90f458801aeb1e941a3f541200d171e8f. Metric Decrease: T9630 haddock.base - - - - - d9dfbde3 by Michael Sloan at 2019-05-24T16:55:07+01:00 Add PlainPanic for throwing exceptions without depending on pprint This commit splits out a subset of GhcException which do not depend on pretty printing (SDoc), as a new datatype called PlainGhcException. These exceptions can be caught as GhcException, because 'fromException' will convert them. The motivation for this change is that that the Panic module transitively depends on many modules, primarily due to pretty printing code. It's on the order of about 130 modules. This large set of dependencies has a few implications: 1. To avoid cycles / use of boot files, these dependencies cannot throw GhcException. 2. There are some utility modules that use UnboxedTuples and also use `panic`. This means that when loading GHC into GHCi, about 130 additional modules would need to be compiled instead of interpreted. Splitting the non-pprint exception throwing into a new module resolves this issue. See #13101 - - - - - 70c24471 by Moritz Angermann at 2019-05-25T17:51:30-04:00 Add `keepCAFs` to RtsSymbols - - - - - 9be1749d by David Eichmann at 2019-05-25T17:55:05-04:00 Hadrian: Add Mising Libffi Dependencies #16653 Libffi is ultimately built from a single archive file (e.g. libffi-tarballs/libffi-3.99999+git20171002+77e130c.tar.gz). The file can be seen as the shallow dependency for the whole libffi build. Hence, in all libffi rules, the archive is `need`ed and the build directory is `trackAllow`ed. - - - - - 2d0cf625 by Sandy Maguire at 2019-05-26T08:57:20-04:00 Let the specialiser work on dicts under lambdas Following the discussion under #16473, this change allows the specializer to work on any dicts in a lambda, not just those that occur at the beginning. For example, if you use data types which contain dictionaries and higher-rank functions then once these are erased by the optimiser you end up with functions such as: ``` go_s4K9 Int# -> forall (m :: * -> *). Monad m => (forall x. Union '[State (Sum Int)] x -> m x) -> m () ``` The dictionary argument is after the Int# value argument, this patch allows `go` to be specialised. - - - - - 4b228768 by Moritz Angermann at 2019-05-27T01:19:49-04:00 Lowercase windows imports While windows and macOS are currently on case-insensitive file systems, this poses no issue on those. When cross compiling from linux with a case sensitive file system and mingw providing only lowercase headers, this in fact produces an issue. As such we just lowercase the import headers, which should still work fine on a case insensitive file system and also enable mingw's headers to be usable porperly. - - - - - 01f8e390 by Alp Mestanogullari at 2019-05-27T10:06:26-04:00 Hadrian: Fix problem with unlit path in settings file e529c65e introduced a problem in the logic for generating the path to the unlit command in the settings file, and this patches fixes it. This fixes many tests, the simplest of which is: > _build/stage1/bin/ghc testsuite/tests/parser/should_fail/T8430.lhs which failed because of a wrong path for unlit, and now fails for the right reason, with the error message expected for this test. This addresses #16659. - - - - - dcd843ac by mizunashi_mana at 2019-05-27T10:06:27-04:00 Fix typo of primop format - - - - - 3f6e5b97 by Joshua Price at 2019-05-27T10:06:28-04:00 Correct the large tuples section in user's guide Fixes #16644. - - - - - 1f51aad6 by Krzysztof Gogolewski at 2019-05-27T10:06:28-04:00 Fix tcfail158 (#15899) As described in #15899, this test was broken, but now it's back to normal. - - - - - 723216e3 by Sebastian Graf at 2019-05-27T10:06:29-04:00 Add a pprTraceWith function - - - - - 6d188dd5 by Simon Jakobi at 2019-05-27T10:06:31-04:00 base: Include (<$) in all exports of Functor Previously the haddocks for Control.Monad and Data.Functor gave the impression that `fmap` was the only Functor method. Fixes #16681. - - - - - 95b79173 by Jasper Van der Jeugt at 2019-05-27T10:06:32-04:00 Fix padding of entries in .prof files When the number of entries of a cost centre reaches 11 digits, it takes up the whole space reserved for it and the prof file ends up looking like: ... no. entries %time %alloc %time %alloc ... ... 120918 978250 0.0 0.0 0.0 0.0 ... 118891 0 0.0 0.0 73.3 80.8 ... 11890229702412351 8.9 13.5 73.3 80.8 ... 118903 153799689 0.0 0.1 0.0 0.1 ... This results in tooling not being able to parse the .prof file. I realise we have the JSON output as well now, but still it'd be good to fix this little weirdness. Original bug report and full prof file can be seen here: <https://github.com/jaspervdj/profiteur/issues/28>. - - - - - f80d3afd by John Ericson at 2019-05-27T10:06:33-04:00 hadrian: Fix generation of settings I jumbled some lines in e529c65eacf595006dd5358491d28c202d673732, messing up the leading underscores and rts ways settings. This broke at least stage1 linking on macOS, but probably loads of other things too. Should fix #16685 and #16658. - - - - - db8e3275 by Ömer Sinan Ağacan at 2019-05-27T10:06:37-04:00 Add missing opening braces in Cmm dumps Previously -ddump-cmm was generating code with unbalanced curly braces: stg_atomically_entry() // [R1] { info_tbls: [(cfl, label: stg_atomically_info rep: tag:16 HeapRep 1 ptrs { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset cfl: // cfk unwind Sp = Just Sp + 0; _cfk::P64 = R1; //tick src<rts/PrimOps.cmm:(1243,1)-(1245,1)> R1 = I64[_cfk::P64 + 8 + 8 + 0 * 8]; call stg_atomicallyzh(R1) args: 8, res: 0, upd: 8; } }, <---- OPENING BRACE MISSING After this patch: stg_atomically_entry() { // [R1] <---- MISSING OPENING BRACE HERE { info_tbls: [(cfl, label: stg_atomically_info rep: tag:16 HeapRep 1 ptrs { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset cfl: // cfk unwind Sp = Just Sp + 0; _cfk::P64 = R1; //tick src<rts/PrimOps.cmm:(1243,1)-(1245,1)> R1 = I64[_cfk::P64 + 8 + 8 + 0 * 8]; call stg_atomicallyzh(R1) args: 8, res: 0, upd: 8; } }, - - - - - 9334467f by Richard Eisenberg at 2019-05-28T00:24:50-04:00 Improve comments around injectivity checks - - - - - c8380a4a by Krzysztof Gogolewski at 2019-05-29T10:35:50-04:00 Handle hs-boot files in -Wmissing-home-modules (#16551) - - - - - 7a75a094 by Alp Mestanogullari at 2019-05-29T10:36:35-04:00 testsuite: introduce 'static_stats' tests They are a particular type of perf tests. This patch introduces a 'stats_files_dir' configuration field in the testsuite driver where all haddock timing files (and possibly others in the future) are assumed to live. We also change both the Make and Hadrian build systems to pass respectively $(TOP)/testsuite/tests/perf/haddock/ and <build root>/stage1/haddock-timing-files/ as the value of that new configuration field, and to generate the timing files in those directories in the first place while generating documentation with haddock. This new test type can be seen as one dedicated to examining stats files that are generated while building a GHC distribution. This also lets us get rid of the 'extra_files' directives in the all.T entries for haddock.base, haddock.Cabal and haddock.compiler. - - - - - 32acecc2 by P.C. Shyamshankar at 2019-05-29T10:37:16-04:00 Minor spelling fixes to users guide. - - - - - b58b389b by Oleg Grenrus at 2019-05-29T10:37:54-04:00 Remove stale 8.2.1-notes - - - - - 5bfd28f5 by Oleg Grenrus at 2019-05-29T10:37:54-04:00 Fix some warnings in users_guide (incl #16640) - short underline - :ghc-flag:, not :ghc-flags: - :since: have to be separate - newline before code block - workaround anchor generation so - pragma:SPECIALISE - pragma:SPECIALIZE-INLINE - pragma:SPECIALIZE-inline are different anchors, not all the same `pragma:SPECIALIZE` - - - - - a5b14ad4 by Kevin Buhr at 2019-05-29T10:38:30-04:00 Add test for old issue displaying unboxed tuples in error messages (#502) - - - - - f9d61ebb by Krzysztof Gogolewski at 2019-05-29T10:39:05-04:00 In hole fits, don't show VTA for inferred variables (#16456) We fetch the ArgFlag for every argument by using splitForAllVarBndrs instead of splitForAllTys in unwrapTypeVars. - - - - - 69b16331 by Krzysztof Gogolewski at 2019-05-29T10:39:43-04:00 Fix missing unboxed tuple RuntimeReps (#16565) Unboxed tuples and sums take extra RuntimeRep arguments, which must be manually passed in a few places. This was not done in deSugar/Check. This error was hidden because zipping functions in TyCoRep ignored lists with mismatching length. This is now fixed; the lengths are now checked by calling zipEqual. As suggested in #16565, I moved checking for isTyVar and isCoVar to zipTyEnv and zipCoEnv. - - - - - 9062b625 by Nathan Collins at 2019-05-29T10:40:21-04:00 Don't lose parentheses in show SomeAsyncException - - - - - cc0d05a7 by Daniel Gröber at 2019-05-29T10:41:02-04:00 Add hPutStringBuffer utility - - - - - 5b90e0a1 by Daniel Gröber at 2019-05-29T10:41:02-04:00 Allow using tagetContents for modules needing preprocessing This allows GHC API clients, most notably tooling such as Haskell-IDE-Engine, to pass unsaved files to GHC more easily. Currently when targetContents is used but the module requires preprocessing 'preprocessFile' simply throws an error because the pipeline does not support passing a buffer. This change extends `runPipeline` to allow passing the input buffer into the pipeline. Before proceeding with the actual pipeline loop the input buffer is immediately written out to a new tempfile. I briefly considered refactoring the pipeline at large to pass around in-memory buffers instead of files, but this seems needlessly complicated since no pipeline stages other than Hsc could really support this at the moment. - - - - - fb26d467 by Daniel Gröber at 2019-05-29T10:41:02-04:00 downsweep: Allow TargetFile not to exist when a buffer is given Currently 'getRootSummary' will fail with an exception if a 'TargetFile' is given but it does not exist even if an input buffer is passed along for this target. In this case it is not necessary for the file to exist since the buffer will be used as input for the compilation pipeline instead of the file anyways. - - - - - 4d51e0d8 by Ömer Sinan Ağacan at 2019-05-29T10:41:44-04:00 CNF.c: Move debug functions behind ifdef - - - - - ae968d41 by Vladislav Zavialov at 2019-05-29T10:42:20-04:00 tcMatchesFun s/rho/sigma #16692 - - - - - 2d2aa203 by Josh Meredith at 2019-05-29T10:43:03-04:00 Provide details in `plusSimplCount` errors - - - - - ace2e335 by John Ericson at 2019-05-29T16:06:45-04:00 Break up `Settings` into smaller structs As far as I can tell, the fields within `Settings` aren't *intrinsicly* related. They just happen to be initialized the same way (in particular prior to the rest of `DynFlags`), and that is why they are grouped together. Within `Settings`, however, there are groups of settings that clearly do share something in common, regardless of how they anything is initialized. In the spirit of GHC being a library, where the end cosumer may choose to initialize this configuration in arbitrary ways, I made some new data types for thoses groups internal to `Settings`, and used them to define `Settings` instead. Hopefully this is a baby step towards a general decoupling of the stateful and stateless parts of GHC. - - - - - bfccd832 by John Ericson at 2019-05-29T16:06:45-04:00 Inline `Settings` into `DynFlags` After the previous commit, `Settings` is just a thin wrapper around other groups of settings. While `Settings` is used by GHC-the-executable to initalize `DynFlags`, in principle another consumer of GHC-the-library could initialize `DynFlags` a different way. It therefore doesn't make sense for `DynFlags` itself (library code) to separate the settings that typically come from `Settings` from the settings that typically don't. - - - - - a1bf3413 by David Eichmann at 2019-05-29T16:07:24-04:00 Hadrian: Add note about Libffi's Indicating Inputs #16653 [skip ci] - - - - - 3aa71a22 by Alp Mestanogullari at 2019-05-30T07:28:32-04:00 Hadrian: always generate the libffi dynlibs manifest with globbing Instead of trying to deduce which dynlibs are expected to be found (and then copied to the RTS's build dir) in libffi's build directory, with some OS specific logic, we now always just use `getDirectoryFilesIO` to look for those dynlibs and record their names in the manifest. The previous logic ended up causing problems on Windows, where we don't build dynlibs at all for now but the manifest file's logic didn't take that into account because it was only partially reproducing the criterions that determine whether or not we will be building shared libraries. This patch also re-enables the Hadrian/Windows CI job, which was failing to build GHC precisely because of libffi shared libraries and the aforementionned duplicated logic. - - - - - ade53ce2 by Ben Gamari at 2019-05-30T07:29:10-04:00 CODEOWNERS: Use correct username for Richard Eisenberg In !980 Richard noted that he could not approve the MR. This mis-spelling was the reason. [skip ci] - - - - - 4ad37a32 by Ben Gamari at 2019-05-30T07:29:47-04:00 rts: Handle zero-sized mappings in MachO linker As noted in #16701, it is possible that we will find that an object has no segments needing to be mapped. Previously this would result in mmap being called for a zero-length mapping, which would fail. We now simply skip the mmap call in this case; the rest of the logic just works. - - - - - f81f3964 by Phuong Trinh at 2019-05-30T16:43:31-04:00 Use binary search to speedup checkUnload We are iterating through all object code for each heap objects when checking whether object code can be unloaded. For large projects in GHCi, this can be very expensive due to the large number of object code that needs to be loaded/unloaded. To speed it up, this arrangess all mapped sections of unloaded object code in a sorted array and use binary search to check if an address location fall on them. - - - - - 42129180 by Trịnh Tuấn Phương at 2019-05-30T16:43:31-04:00 Apply suggestion to rts/CheckUnload.c - - - - - 8e42e98e by Trịnh Tuấn Phương at 2019-05-30T16:43:31-04:00 Apply suggestion to rts/CheckUnload.c - - - - - 70afa539 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Export GhcMake.downsweep This is to enable #10887 as well as to make it possible to test downsweep on its own in the testsuite. - - - - - a8de5c5a by Daniel Gröber at 2019-05-30T16:44:08-04:00 Add failing test for #10887 - - - - - 8906bd66 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Refactor downsweep to allow returning multiple errors per module - - - - - 8e85ebf7 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Refactor summarise{File,Module} to reduce code duplication - - - - - 76c86fca by Daniel Gröber at 2019-05-30T16:44:08-04:00 Refactor summarise{File,Module} to extract checkSummaryTimestamp This introduces a slight change of behaviour in the interrest of keeping the code simple: Previously summariseModule would not call addHomeModuleToFinder for summaries that are being re-used but now we do. We're forced to to do this in summariseFile because the file being summarised might not even be on the regular search path! So if GHC is to find it at all we have to pre-populate the cache with its location. For modules however the finder cache is really just a cache so we don't have to pre-populate it with the module's location. As straightforward as that seems I did almost manage to introduce a bug (or so I thought) because the call to addHomeModuleToFinder I copied from summariseFile used to use `ms_location old_summary` instead of the `location` argument to checkSummaryTimestamp. If this call were to overwrite the existing entry in the cache that would have resulted in us using the old location of any module even if it was, say, moved to a different directory between calls to 'depanal'. However it turns out the cache just ignores the location if the module is already in the cache. Since summariseModule has to search for the module, which has the side effect of populating the cache, everything would have been fine either way. Well I'm adding a test for this anyways: tests/depanal/OldModLocation.hs. - - - - - 18d3f01d by Daniel Gröber at 2019-05-30T16:44:08-04:00 Make downsweep return all errors per-module instead of throwing some This enables API clients to handle such errors instead of immideately crashing in the face of some kinds of user errors, which is arguably quite bad UX. Fixes #10887 - - - - - 99e72769 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Catch preprocessor errors in downsweep This changes the way preprocessor failures are presented to the user. Previously the user would simply get an unlocated message on stderr such as: `gcc' failed in phase `C pre-processor'. (Exit code: 1) Now at the problematic source file is mentioned: A.hs:1:1: error: `gcc' failed in phase `C pre-processor'. (Exit code: 1) This also makes live easier for GHC API clients as the preprocessor error is now thrown as a SourceError exception. - - - - - b7ca94fd by Daniel Gröber at 2019-05-30T16:44:08-04:00 PartialDownsweep: Add test for import errors - - - - - 98e39818 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Add depanalPartial to make getting a partial modgraph easier As per @mpickering's suggestion on IRC this is to make the partial module-graph more easily accessible for API clients which don't intend to re-implementing depanal. - - - - - d2784771 by Daniel Gröber at 2019-05-30T16:44:08-04:00 Improve targetContents code docs - - - - - 424e85b2 by Ben Gamari at 2019-05-30T16:44:43-04:00 testsuite: Compile T9630 with +RTS -G1 For the reasons described in Note [residency] we run programs with -G1 when we care about the max_bytes_used metric. - - - - - 4879d7af by Matthew Pickering at 2019-05-31T01:56:16-04:00 Eventlog: Document the fact timestamps are nanoseconds [skip ci] - - - - - 0b01a354 by Takenobu Tani at 2019-05-31T01:56:54-04:00 Update `$(TOP)/*.md` documents I updated the top documents to the latest status: - HACKING.md: - Modify Phabricator to GitLab infomation - Remove old Trac information - Add link to GitLab activity - MAKEHELP.md: - Add link to hadrian wiki - Fix markdown format - INSTALL.md: - Modify boot command to remove python3 - Fix markdown format - README.md: - Modify tarball file suffix - Fix markdown format I checked the page display on the GitHub and GitLab web. [skip ci] - - - - - 973077ac by Sergei Trofimovich at 2019-05-31T01:57:31-04:00 powerpc32: fix 64-bit comparison (#16465) On powerpc32 64-bit comparison code generated dangling target labels. This caused ghc build failure as: $ ./configure --target=powerpc-unknown-linux-gnu && make ... SCCs aren't in reverse dependent order bad blockId n3U This happened because condIntCode' in PPC codegen generated label name but did not place the label into `cmp_lo` code block. The change adds the `cmp_lo` label into the case of negative comparison. Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - bb2ee86a by Sergei Trofimovich at 2019-05-31T01:57:31-04:00 powerpc32: fix stack allocation code generation When ghc was built for powerpc32 built failed as: It's a fallout of commit 3f46cffcc2850e68405a1 ("PPC NCG: Refactor stack allocation code") where word size used to be II32/II64 and changed to II8/panic "no width for given number of bytes" widthFromBytes ((platformWordSize platform) `quot` 8) The change restores initial behaviour by removing extra division. Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 08b4c813 by Matthew Pickering at 2019-05-31T01:58:08-04:00 Use types already in AST when making .hie file These were meant to be added in !214 but for some reason wasn't included in the patch. Update Haddock submodule for new Types.hs hyperlinker output - - - - - 284cca51 by David Hewson at 2019-05-31T01:58:47-04:00 support small arrays and CONSTR_NOCAF in ghc-heap - - - - - f071576c by Neil Mitchell at 2019-05-31T01:59:24-04:00 Expose doCpp - - - - - c70d039e by Ömer Sinan Ağacan at 2019-05-31T02:00:02-04:00 Remove unused RTS function 'unmark' - - - - - bb929009 by Ömer Sinan Ağacan at 2019-05-31T02:00:40-04:00 Fix arity type of coerced types in CoreArity Previously if we had f |> co where `f` had arity type `ABot N` and `co` had arity M and M < N, `arityType` would return `ABot M` which is wrong, because `f` is only known to diverge when applied to `N` args, as described in Note [ArityType]: If at = ABot n, then (f x1..xn) definitely diverges. Partial applications to fewer than n args may *or may not* diverge. This caused incorrect eta expansion in the simplifier, causing #16066. We now return `ATop M` for the same expression so the simplifier can't assume partial applications of `f |> co` is divergent. A regression test T16066 is also added. - - - - - e32786df by Ryan Scott at 2019-05-31T02:01:18-04:00 Put COMPLETE sigs into ModDetails with -fno-code (#16682) `mkBootModDetailsTc`, which creates a special `ModDetails` when `-fno-code` is enabled, was not properly filling in the `COMPLETE` signatures from the `TcGblEnv`, resulting in incorrect pattern-match coverage warnings. Easily fixed. Fixes #16682. - - - - - 0c6f7f7e by Simon Jakobi at 2019-05-31T02:01:55-04:00 Implement (Functor.<$) for Array - - - - - 495a65cb by Simon Jakobi at 2019-05-31T02:02:33-04:00 Implement (Functor.<$) for Data.Functor.{Compose,Product,Sum} This allows us to make use of the (<$) implementations of the underlying functors. - - - - - 0e0d87da by Zubin Duggal at 2019-05-31T07:34:57+01:00 Fix and enforce validation of header for .hie files Implements #16686 The files version is automatically generated from the current GHC version in the same manner as normal interface files. This means that clients can first read the version and then decide how to read the rest of the file. - - - - - 1d43d4a3 by Nathan Collins at 2019-05-31T23:55:49-04:00 Improve ThreadId Show instance By making it include parens when a derived instance would. For example, this changes the (hypothetical) code `show (Just (ThreadId 3))` to produce `"Just (ThreadId 3)"` instead of the current `"Just ThreadId 3"`. - - - - - 45f88494 by Ryan Scott at 2019-05-31T23:56:27-04:00 Reject nested foralls in foreign imports (#16702) This replaces a panic observed in #16702 with a simple error message stating that nested `forall`s simply aren't allowed in the type signature of a `foreign import` (at least, not at present). Fixes #16702. - - - - - 76e58890 by Ryan Scott at 2019-05-31T23:57:05-04:00 Fix space leaks in dynLoadObjs (#16708) When running the test suite on a GHC built with the `quick` build flavour, `-fghci-leak-check` noticed some space leaks. Careful investigation led to `Linker.dynLoadObjs` being the culprit. Pattern-matching on `PeristentLinkerState` and a dash of `$!` were sufficient to fix the issue. (ht to mpickering for his suggestions, which were crucial to discovering a fix) Fixes #16708. - - - - - 1503da32 by Ömer Sinan Ağacan at 2019-06-01T11:18:57-04:00 Fix rewriting invalid shifts to errors Fixes #16449. 5341edf3 removed a code in rewrite rules for bit shifts, which broke the "silly shift guard", causing generating invalid bit shifts or heap overflow in compile time while trying to evaluate those invalid bit shifts. The "guard" is explained in Note [Guarding against silly shifts] in PrelRules.hs. More specifically, this was the breaking change: --- a/compiler/prelude/PrelRules.hs +++ b/compiler/prelude/PrelRules.hs @@ -474,12 +474,11 @@ shiftRule shift_op ; case e1 of _ | shift_len == 0 -> return e1 - | shift_len < 0 || wordSizeInBits dflags < shift_len - -> return (mkRuntimeErrorApp rUNTIME_ERROR_ID wordPrimTy - ("Bad shift length" ++ show shift_len)) This patch reverts this change. Two new tests added: - T16449_1: The original reproducer in #16449. This was previously casing a heap overflow in compile time when CmmOpt tries to evaluate the large (invalid) bit shift in compile time, using `Integer` as the result type. Now it builds as expected. We now generate an error for the shift as expected. - T16449_2: Tests code generator for large (invalid) bit shifts. - - - - - 2e297b36 by Ömer Sinan Ağacan at 2019-06-01T11:19:35-04:00 rts: Remove unused decls from CNF.h - - - - - 33e37d06 by Takenobu Tani at 2019-06-02T22:54:43-04:00 Add `-haddock` option under ci condition to fix #16415 In order to use the `:doc` command in ghci, it is necessary to compile for core libraries with `-haddock` option. Especially, the `-haddock` option is essential for release building. Note: * The `-haddock` option may affect compile time and binary size. * But hadrian has already set `-haddock` as the default. * This patch affects the make-based building. This patch has been split from !532. - - - - - 43a39c3c by Takenobu Tani at 2019-06-02T22:54:43-04:00 Add `-haddock` to perf.mk rather than prepare-system.sh To cover ci conditions from ghc8.6 to 8.9, I add `-haddock` option to `mk/flavours/perf.mk` rather than `.circleci/prepare-system.sh`. Because in windows condition of ghc-8.9, `mk/flavours/*` is included after `prepare-system.sh`. In addition, in linux condition of ghc-8.6, `mk/flavors/perf.mk` is used. - - - - - c4f94320 by Takenobu Tani at 2019-06-02T22:54:43-04:00 Add `-haddock` to prepare-system.sh and .gitlab-ci.yml To cover ci conditions from ghc8.6 to 8.9, I add `-haddock` option to `.circleci/prepare-system.sh` and .gitlab-ci.yml. after including `mk/flavours/*`. - - - - - 799b1d26 by Ben Gamari at 2019-06-02T22:55:18-04:00 gitlab-ci: Use GHC 8.6.5 for Windows CI builds - - - - - 286827be by David Eichmann at 2019-06-04T01:09:05-04:00 TestRunner: Added --chart to display a chart of performance tests This uses the Chart.js javascript library. Everything is put into a standalone .html file and opened with the default browser. I also simplified the text output to use the same data as the chart. You can now use a commit range with git's ".." syntax. The --ci option will use results from CI (you'll need to fetch them first): $ git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/ci/perf $ python3 testsuite/driver/perf_notes.py --ci --chart --test-env x86_64-darwin --test-name T9630 master~500..master - - - - - db78ac6f by Andrew Martin at 2019-06-04T01:09:43-04:00 Use a better strategy for determining the offset applied to foreign function arguments that have an unlifted boxed type. We used to use the type of the argument. We now use the type of the foreign function. Add a test to confirm that the roundtrip conversion between an unlifted boxed type and Any is sound in the presence of a foreign function call. - - - - - 114b014f by Alp Mestanogullari at 2019-06-04T01:10:20-04:00 Hadrian: fix OSX build failure and add an OSX/Hadrian CI job The OSX build failure introduced in 3aa71a22 was due to a change in the glob we use to collect libffi shared libraries in hadrian/src/Rules/Libffi.hs. This commit fixes the problem and adds an OSX CI job that builds GHC with Hadrian, to make sure we don't break it again. - - - - - 002594b7 by Xavier Denis at 2019-06-04T14:41:29-04:00 Add GHCi :instances command This commit adds the `:instances` command to ghci following proosal number 41. This makes it possible to query which instances are available to a given type. The output of this command is all the possible instances with type variables and constraints instantiated. - - - - - 3ecc03df by Ben Gamari at 2019-06-04T14:42:04-04:00 gitlab-ci: Run bindisttest during CI - - - - - c16f3297 by Ben Gamari at 2019-06-04T14:42:04-04:00 make: Fix bindist installation This fixes a few vestigial references to `settings` left over from !655. Fixes #16715. - - - - - ba4e3934 by Alp Mestanogullari at 2019-06-04T14:43:17-04:00 Hadrian: profiling and debug enabled ways support -eventlog too - - - - - 567894b4 by Matthew Pickering at 2019-06-07T09:36:32+01:00 gitlab-ci: Disable darwin hadrian job See #16771 We don't have enough capacity for the two jobs currently. [skip ci] - - - - - d3915b30 by Andrew Martin at 2019-06-07T10:20:42-04:00 [skip ci] Improve the documentation of the CNF primops. In this context, the term "size" is ambiguous and is now avoided. Additionally, the distinction between a CNF and the blocks that comprise it has been emphasize. The vocabulary has been made more consistent with the vocabulary in the C source for CNF. - - - - - e963beb5 by Sebastian Graf at 2019-06-07T10:21:21-04:00 TmOracle: Replace negative term equalities by refutable PmAltCons The `PmExprEq` business was a huge hack and was at the same time vastly too powerful and not powerful enough to encode negative term equalities, i.e. facts of the form "forall y. x ≁ Just y". This patch introduces the concept of 'refutable shapes': What matters for the pattern match checker is being able to encode knowledge of the kind "x can no longer be the literal 5". We encode this knowledge in a `PmRefutEnv`, mapping a set of newly introduced `PmAltCon`s (which are just `PmLit`s at the moment) to each variable denoting above inequalities. So, say we have `x ≁ 42 ∈ refuts` in the term oracle context and try to solve an equality like `x ~ 42`. The entry in the refutable environment will immediately lead to a contradiction. This machinery renders the whole `PmExprEq` and `ComplexEq` business unnecessary, getting rid of a lot of (mostly dead) code. See the Note [Refutable shapes] in TmOracle for a place to start. Metric Decrease: T11195 - - - - - 0b7372f6 by Matthew Pickering at 2019-06-07T10:21:57-04:00 Add HEAP_PROF_SAMPLE_END event to mark end of samples This allows a user to observe how long a sampling period lasts so that the time taken can be removed from the profiling output. Fixes #16697 - - - - - d1dc0ed7 by Roland Senn at 2019-06-07T10:22:47-04:00 Fix #16700: Tiny errors in output of GHCi commands :forward and :info `:info Coercible` now outputs the correct section number of the GHCi User's guide together with the secion title. `:forward x` gives the correct syntax hint. - - - - - 387050d0 by John Ericson at 2019-06-07T10:23:23-04:00 Factor out 'getLibDir' / 'getBaseDir' into a new GHC.BaseDir ghc-boot module ghc-pkg and ghc already both needed this. I figure it is better to deduplicate, especially seeing that changes to one (FreeBSD CPP) didn't make it to the other. Additionally in !1090 I make ghc-pkg look up the settings file, which makes it use the top dir a bit more widely. If that lands, any difference in the way they find the top dir would be more noticable. That change also means sharing more code between ghc and ghc-package (namely the settings file parsing code), so I'd think it better to get off the slipperly slope of duplicating code now. - - - - - da26ffe7 by Simon Peyton Jones at 2019-06-07T10:24:00-04:00 Preserve ShadowInfo when rewriting evidence When the canonicaliser rewrites evidence of a Wanted, it should preserve the ShadowInfo (ctev_nosh) field. That is, a WDerive should rewrite to WDerive, and WOnly to WOnly. Previously we were unconditionally making a WDeriv, thereby rewriting WOnly to WDeriv. This bit Nick Frisby (issue #16735) in the context of his plugin, but we don't have a compact test case. The fix is simple, but does involve a bit more plumbing, to pass the old ShadowInfo around, to use when building the new Wanted. - - - - - 9bb58799 by Ben Gamari at 2019-06-07T10:24:38-04:00 Hadrian: Delete target symlink in createFileLinkUntracked Previously createFileLinkUntracked would fail if the symlink already existed. - - - - - be63d299 by Simon Jakobi at 2019-06-07T10:25:16-04:00 Fix isValidNatural: The BigNat in NatJ# must have at least 2 limbs Previously the `integer-gmp` variant of `isValidNatural` would fail to detect values `<= maxBound::Word` that were incorrectly encoded using the `NatJ#` constructor. - - - - - e87b9f87 by Moritz Angermann at 2019-06-07T10:26:04-04:00 llvm-targets: Add x86_64 android layout - - - - - 60db142b by code5hot at 2019-06-07T10:26:46-04:00 Update Traversable.hs with a note about an intuitive law - - - - - f11aca52 by code5hot at 2019-06-07T10:26:46-04:00 Used terminology from a paper. Added it as a reference. - - - - - 13b3d45d by code5hot at 2019-06-07T10:26:46-04:00 remove backticks from markup - it doesn't mean what I think it means - - - - - cfd3e0f1 by Zejun Wu at 2019-06-07T10:27:34-04:00 Pass preprocessor options to C compiler when building foreign C files (#16737) - - - - - 5991d877 by Ben Gamari at 2019-06-07T10:28:09-04:00 base: Export Finalizers As requested in #16750. - - - - - 3d97bad6 by Alp Mestanogullari at 2019-06-07T10:28:47-04:00 Hadrian: use deb9 Docker images instead of deb8 for CI jobs This should fix #16739, where we seem to be getting extra carets in a test's output because of the gcc that ships with the deb8 image, whule we're not observing those extra carets in the deb9-based (Make) jobs. - - - - - 1afb4995 by Ben Gamari at 2019-06-07T10:29:23-04:00 gitlab-ci: Create index.html in documentation deployment Otherwise navigating to https://ghc.gitlab.haskell.org/ghc will result in a 404. - - - - - 07dc79c3 by Matthew Pickering at 2019-06-08T13:34:18-04:00 gitlab-ci: Linters, don't allow to fail Ben disabled them in cd85f8a71bb56cff332560e1d571b3406789fb71 but didn't say how or why they were broken. - - - - - fd840b64 by Matthew Pickering at 2019-06-08T13:34:18-04:00 gitlab-ci: Don't run two submodule checking jobs on Marge jobs - - - - - 310d0c4c by Matthew Pickering at 2019-06-08T13:34:18-04:00 Fix two lint failures in rts/linker/MachO.c - - - - - fe965316 by Ben Gamari at 2019-06-08T13:34:18-04:00 gitlab-ci: Use --unshallow when fetching for linters GitLab creates a shallow clone. However, this means that we may not have the base commit of an MR when linting, causing `git merge-base` to fail. Fix this by passing `--unshallow` to `git fetch`, ensuring that we have the entire history. - - - - - f58234ea by Ben Gamari at 2019-06-08T13:34:18-04:00 gitlab-ci: Fix submodule linter The job script didn't even try to compute the base commit to lint with respect to. - - - - - c392f987 by Ben Gamari at 2019-06-08T13:34:18-04:00 gitlab-ci: A few clarifying comments - - - - - 709290b0 by Matthew Pickering at 2019-06-08T13:38:15-04:00 Remove trailing whitespace [skip ci] This should really be caught by the linters! (#16711) - - - - - b2f106f5 by Ben Gamari at 2019-06-08T14:02:02-04:00 gitlab-ci: Disable shallow clones Previously we were passing `--unshallow` to `git fetch` in the linting rules to ensure that the base commit which we were linting with respect to was available. However, this breaks due to GitLab's re-use of working directories since `git fetch --unshallow` fails on a repository which is not currently shallow. Given that `git fetch --unshallow` circumvents the efficiencies provided by shallow clones anyways, let's just disable them entirely. There is no documented way to do disable shallow clones but on checking the GitLab implementation it seems that setting `GIT_DEPTH=0` should do the trick. - - - - - 4a72259d by Ben Gamari at 2019-06-08T14:40:55-04:00 gitlab-ci: Fix submodule linting of commits There is no notion of a base commit when we aren't checking a merge request. Just check the HEAD commit. - - - - - 87540029 by Ben Gamari at 2019-06-08T16:44:55-04:00 gitlab-ci: Ensure that all commits on a branch are submodule-linted The previous commit reworked things such that the submodule linter would only run on the head commit. However, the linter only checks the submodules which are touched by the commits it is asked to lint. Consequently it would be possible for a bad submodule to sneak through. Thankfully, we can use the handy CI_COMMIT_BEFORE_SHA attribute to find the base commit of the push. - - - - - 0462b0e0 by Alexandre Baldé at 2019-06-09T11:48:34-04:00 Explain that 'mappend' and '(<>)' should be the same [skip ci] - - - - - 970e4802 by Matthew Pickering at 2019-06-09T11:49:09-04:00 hadrian: Properly partition options in sourceArgs Previously if you build the `ghc` package then it would has the default opts and the library opts. This is different behaviour to make where the library opts are only reserved for things in the `libraries` subdirectory (I believe) Fixes #16716 - - - - - a018c3a8 by Ben Gamari at 2019-06-09T11:49:44-04:00 testsuite: Suppress ticks in T4918 output As noted in #16741, this test otherwise breaks when `base` is compiled with `-g`. - - - - - f7370333 by chessai at 2019-06-09T18:41:02-04:00 Introduce log1p and expm1 primops Previously log and exp were primitives yet log1p and expm1 were FFI calls. Fix this non-uniformity. - - - - - 41bf4045 by Ben Gamari at 2019-06-09T18:41:38-04:00 testsuite: Add test for #16514 - - - - - b9fe91fc by Simon Jakobi at 2019-06-09T18:42:21-04:00 Small refactorings in ExtractDocs - - - - - 9d238791 by Kevin Buhr at 2019-06-09T18:42:57-04:00 Handle trailing path separator in package DB names (#16360) Package DB directories with trailing separator (provided via GHC_PACKAGE_PATH or via -package-db) resulted in incorrect calculation of ${pkgroot} substitution variable. Keep the trailing separator while resolving as directory or file, but remove it before dropping the last path component with takeDirectory. Closes #16360. - - - - - a22e51ea by Richard Eisenberg at 2019-06-09T18:43:38-04:00 Fix #16517 by bumping the TcLevel for method sigs There were actually two bugs fixed here: 1. candidateQTyVarsOfType needs to be careful that it does not try to zap metavariables from an outer scope as "naughty" quantification candidates. This commit adds a simple check to avoid doing so. 2. We weren't bumping the TcLevel in kcHsKindSig, which was used only for class method sigs. This mistake led to the acceptance of class C a where meth :: forall k. Proxy (a :: k) -> () Note that k is *locally* quantified. This patch fixes the problem by using tcClassSigType, which correctly bumps the level. It's a bit inefficient because tcClassSigType does other work, too, but it would be tedious to repeat much of the code there with only a few changes. This version works well and is simple. And, while updating comments, etc., I noticed that tcRnType was missing a pushTcLevel, leading to #16767, which this patch also fixes, by bumping the level. In the refactoring here, I also use solveEqualities. This initially failed ghci/scripts/T15415, but that was fixed by teaching solveEqualities to respect -XPartialTypeSignatures. This patch also cleans up some Notes around error generation that came up in conversation. Test case: typecheck/should_fail/T16517, ghci/scripts/T16767 - - - - - 10452959 by Roland Senn at 2019-06-09T18:44:18-04:00 Add disable/enable commands to ghci debugger #2215 This patch adds two new commands `:enable` and `:disable` to the GHCi debugger. Opposite to `:set stop <n> :continue` a breakpoint disabled with `:disable` will not loose its previously set stop command. A new field breakEnabled is added to the BreakLocation data structure to track the enable/disable state. When a breakpoint is disabled with a `:disable` command, the following happens: The corresponding BreakLocation data element is searched dictionary of the `breaks` field of the GHCiStateMonad. If the break point is found and not already in the disabled state, the breakpoint is removed from bytecode. The BreakLocation data structure is kept in the breaks list and the new breakEnabled field is set to false. The `:enable` command works similar. The breaks field in the GHCiStateMonad was changed from an association list to int `IntMap`. - - - - - 13572480 by Ben Gamari at 2019-06-09T18:44:54-04:00 rts: Separate population of eventTypes from initial event generation Previously these two orthogonal concerns were both implemented in postHeaderEvents which made it difficult to send header events after RTS initialization. - - - - - ed20412a by nineonine at 2019-06-09T18:45:31-04:00 Do not report error if Name in pragma is unbound - - - - - 8a48a8a4 by Ben Gamari at 2019-06-09T18:46:08-04:00 testsuite: Add test for #16509 - - - - - 69c58f8a by David Eichmann at 2019-06-09T18:46:46-04:00 Hadrian: need CPP preprocessor dependencies #16660 Use the new -include-cpp-deps ghc option (#16521) when generating .dependencies files in hadrian. This is version gated as -include-cpp-deps is a relatively new option. - - - - - 1c7bb03d by Richard Eisenberg at 2019-06-09T18:47:24-04:00 Comments only: document tcdDataCusk better. - - - - - 5023adce by John Ericson at 2019-06-09T18:47:59-04:00 Remove CPP ensuring word size is 32 or 64 bits around Addr# <-> int# primops It shouldn't be needed these days, and those primops are "highly deprecated" anyways. This fits with my plans because it removes one bit of target-dependence of the builtin primops, and this is the hardest part of GHC to make multi-target. CC @carter - - - - - 8e60e3f0 by Daniel Gröber at 2019-06-09T18:48:38-04:00 rts: Fix RetainerProfile early return with TREC_CHUNK When pop() returns with `*c == NULL` retainerProfile will immediately return. All other code paths is pop() continue with the next stackElement when this happens so it seems weird to me that TREC_CHUNK we would suddenly abort everything even though the stack might still have elements left to process. - - - - - 1a3420ca by Ben Gamari at 2019-06-10T07:59:41-04:00 base: Mark CPUTime001 as fragile As noted in #16224, CPUTime001 has been quite problematic, reporting non-monotonic timestamps in CI. Unfortunately I've been unable to reproduce this locally. - - - - - 9bc10993 by Vladislav Zavialov at 2019-06-10T08:00:16-04:00 Print role annotations in TemplateHaskell brackets (#16718) - - - - - 0345b1b0 by Richard Eisenberg at 2019-06-10T23:52:10-04:00 Comments only: document newtypes' DataConWrapId - - - - - 58a5d728 by David Eichmann at 2019-06-10T23:52:50-04:00 Refactor the rules for .hi and .o into a single rule using `&%>` #16764 Currently the rule for .hi files just triggers (via need) the rule for the .o file, and .o rule generates both the .o and .hi file. Likewise for .o-boot and .hi-boot files. This is a bit of an abuse of Shake, and in fact shake supports rules with multiple output with the &%> function. This exact use case appears in Neil Mitchell's paper *Shake Before Building* section 6.3. - - - - - 2f945086 by Ben Gamari at 2019-06-10T23:53:25-04:00 testsuite: Fix and extend closure_size test This was previously broken in several ways. This is fixed and it also now tests arrays. Unfortunately I was unable to find a way to continue testing PAP and FUN sizes; these simply depend too much upon the behavior of the simplifier. I also tried to extend this to test non-empty arrays as well but unfortunately this was non-trivial as the array card size constant isn't readily available from haskell. Fixes #16531. - - - - - e5d275f4 by Ben Gamari at 2019-06-10T23:53:25-04:00 ghc-heap: Add closure_size_noopt test This adds a new test, only run in the `normal` way, to verify the size of FUNs and PAPs. - - - - - fe7e7e4a by Yuras Shumovich at 2019-06-11T18:39:58-04:00 Warn about unused packages Reviewers: bgamari, simonpj Reviewed By: simonpj Subscribers: hvr, simonpj, mpickering, rwbarton, carter GHC Trac Issues: #15838 Differential Revision: https://phabricator.haskell.org/D5285 - - - - - 39f50bff by Alp Mestanogullari at 2019-06-11T18:40:37-04:00 Refine the GHCI macro into HAVE[_{INTERNAL, EXTERNAL}]_INTERPRETER As discussed in #16331, the GHCI macro, defined through 'ghci' flags in ghc.cabal.in, ghc-bin.cabal.in and ghci.cabal.in, is supposed to indicate whether GHC is built with support for an internal interpreter, that runs in the same process. It is however overloaded in a few places to mean "there is an interpreter available", regardless of whether it's an internal or external interpreter. For the sake of clarity and with the hope of more easily being able to build stage 1 GHCs with external interpreter support, this patch splits the previous GHCI macro into 3 different ones: - HAVE_INTERNAL_INTERPRETER: GHC is built with an internal interpreter - HAVE_EXTERNAL_INTERPRETER: GHC is built with support for external interpreters - HAVE_INTERPRETER: HAVE_INTERNAL_INTERPRETER || HAVE_EXTERNAL_INTERPRETER - - - - - 45616133 by Alec Theriault at 2019-06-11T18:41:14-04:00 Make `haddock_testsuite` respect `--test-accept` Suppose you've made changes that affect the output of `haddockHtmlTest` so that the following is failing: ./hadrian/build.sh -c --only=haddockHtmlTest test Then, the following will accept new output for Haddock's test cases. ./hadrian/build.sh -c --only=haddockHtmlTest test --test-accept You still do need to make sure those new changes (which show up in Haddock's tree) get committed though. Fixes #16694 - - - - - 762098bf by Alp Mestanogullari at 2019-06-11T18:41:52-04:00 rts/RtsFlags.c: mention that -prof too enables support for +RTS -l - - - - - 457fe789 by Alp Mestanogullari at 2019-06-11T18:42:30-04:00 Hadrian: teach the RTS that PROFILING implies TRACING As discussed in #16744, both the Make and Hadrian build systems have special code to always pass -eventlog whenever -prof or -debug are passed. However, there is some similar logic in the RTS itself only for defining TRACING when the DEBUG macro is defined, but no such logic is implemented to define TRACING when the PROFILING macro is defined. This patch adds such a logic and therefore fixes #16744. - - - - - cf7f36ae by Ben Gamari at 2019-06-11T18:43:05-04:00 rts/linker: Mmap into low memory on AArch64 This extends mmapForLinker to use the same low-memory mapping strategy used on x86_64 on AArch64. See #16784. - - - - - 0b7f81f5 by Ben Gamari at 2019-06-11T18:43:05-04:00 rts/linker: Use mmapForLinker to map PLT The PLT needs to be located within a close distance of the code calling it under the small memory model. Fixes #16784. - - - - - 1389b2cc by Ömer Sinan Ağacan at 2019-06-11T18:43:43-04:00 Fix an error message in CheckUnload.c:searchHeapBlocks - - - - - aad6115a by Alp Mestanogullari at 2019-06-11T18:44:20-04:00 testsuite/mk/boilerplate.mk: rename 'ghc-config-mk' to 'ghc_config_mk' Make/shell variable names which contain dashes can cause problems under some conditions. The 'ghc-config-mk' variable from testsuite/mk/boilerplate.mk that I made overridable (by Hadrian) in ba0aed2e was working as expected when our Hadrian/Linux job was based off the deb8 Docker image, but broke when I switched the job to use our deb9-based image, in 3d97bad6. The exact circumstances/tool versions that trigger this problem are unknown, but changing the variable's name to 'ghc_config_mk' lets us work around the issue. This fixes the annth_compunits and annth_make test failures that showed up when we switched the Hadrian/Linux job to use the deb9 environment. - - - - - 9b4ff57d by Ben Gamari at 2019-06-12T07:35:25-04:00 llvm-targets: Add armv7l-unknown-linux-gnueabi Fixes #15208. [skip ci] - - - - - c05ca251 by Ben Gamari at 2019-06-12T07:36:01-04:00 testsuite: Add haddock perf test output to gitignore [skip ci] - - - - - bbc752c5 by Ben Gamari at 2019-06-12T07:36:36-04:00 rts/linker: Make elf_got.c a bit more legible - - - - - 217e6db4 by Ben Gamari at 2019-06-12T07:36:36-04:00 rts/linker: Only mprotect GOT after it is filled This fixes a regression, introduced by 67c422ca, where we mprotect'd the global offset table (GOT) region to PROT_READ before we had finished filling it, resulting in a linker crash. Fixes #16779. - - - - - 1219f8e8 by Krzysztof Gogolewski at 2019-06-12T07:37:12-04:00 Use DeriveFunctor throughout the codebase (#15654) - - - - - bd2d13ff by Ben Gamari at 2019-06-12T08:19:59-04:00 Bump binary to 0.8.7.0 (cherry picked from commit 983ada70a013c7642a751f6e41587ff95b57d0f8) - - - - - 381c3ae3 by Ben Gamari at 2019-06-12T08:19:59-04:00 Bump Cabal submodule (cherry picked from commit ff438786613f07df9b2d43eaeac49b13815d849d) Metric Increase: haddock.Cabal - - - - - 0354c7de by Ben Gamari at 2019-06-12T08:19:59-04:00 Bump time submodule to 1.9.3 (cherry picked from commit fdb07571036b1498800589d45b61781e6acdd368) - - - - - e0b16eaa by Ben Gamari at 2019-06-12T08:19:59-04:00 Bump terminfo to 0.4.1.4 (cherry picked from commit 1134488b4c9cef904ea82f22f1978646eea612df) - - - - - 2ce320b0 by Ben Gamari at 2019-06-12T08:19:59-04:00 gitlab-ci: Test using slowtest in deb9-debug job - - - - - 90e7c450 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Mark hWaitForInput-accurate-stdin as broken in threaded ways As noted in #16535. - - - - - 488187f8 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Mark T13167 as fragile in threaded2 As noted in #16536. - - - - - 9b583320 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Mark T13910 as broken in optasm Due to #16537. - - - - - eb644865 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Mark T14761c as broken in hpc, profasm, and optasm ways As noted in #16540. - - - - - 1a204e07 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Mark T16180 as broken in ghci and ext-interp ways As noted in #16541. - - - - - 8d482e45 by Ben Gamari at 2019-06-12T08:19:59-04:00 testsuite: Omit tcrun022 in hpc way As noted in #16542, the expected rule doesn't fire. However, this doesn't seem terribly surpring given the circumstances. - - - - - 68cfdfdb by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Mark Overflow as broken in hpc way As noted in #16543. - - - - - a3929a4f by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Mark T2783 as fragile in threaded1 It was previously marked as broken but it passes non-deterministically. See #2783. - - - - - bb7ed32f by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Skip T7919 in ghci way It times out pretty reliably. It's not clear that much is gained by running this test in the ghci way anyways. - - - - - 329dcd7a by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Fix fragile_for test modifier - - - - - 55b5bb14 by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Fix omit_ways usage omit_ways expects a list but this was broken in several cases. - - - - - 264ad286 by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Mark threadstatus-T9333 as fragile in ghci way As noted in #16555. - - - - - 587bef66 by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Omit profasm way for cc017 cc017 requires TH but we can't load dynamic profiled objects. - - - - - dc5a37fd by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Skip T493 in ghci way. T493 tests #493, which is an FFI test. FFI tests should be skipped in ghci way. - - - - - e3f71d0e by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Mark T16449_2 as broken due to #16742 - - - - - b5a13a1e by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Mark T16737 as broken in ghci way due to #16541 - - - - - b09374a4 by Ben Gamari at 2019-06-12T08:20:25-04:00 testsuite: Note intentional typo in T7130 I earlier accidentally corrected it breaking the test. - - - - - a798c130 by Ben Gamari at 2019-06-12T08:20:25-04:00 linters/check-makefiles: Limit lint to Makefiles Previously we would apply this rule, which is only intended for testsuite Makefiles, to all files. This lead to a number of false-positives in all.T files. - - - - - 0782141e by Ben Gamari at 2019-06-12T08:20:25-04:00 gitlab-ci: Fetch submodules before running submodule linter - - - - - 898f7e92 by Ben Gamari at 2019-06-12T08:20:25-04:00 Fix uses of #ifdef/#ifndef The linter now enforces our preference for `#if defined()` and `#if !defined()`. - - - - - 0a13a04c by Ben Gamari at 2019-06-12T08:20:25-04:00 Bump unix submodule Marks posix002 as fragile in threaded2 way due to #16550. - - - - - a8579e5b by Ben Gamari at 2019-06-12T08:27:25-04:00 process: Bump submodule * Skip process005 in ghci way * Mark process002 as fragile in threaded2 - - - - - 3f1022c5 by Ben Gamari at 2019-06-12T08:27:25-04:00 testsuite: Skip cgrun078 in ghci way This test requires FFI usage. - - - - - 1cbfef47 by Ben Gamari at 2019-06-12T08:27:25-04:00 testsuite: Unbreak galois_raytrace on i386 galois_raytrace was previously broken on i386 due to use of x87 arithmethic on that platform. However, 42504f4a575395a35eec5c3fd7c9ef6e2b54e68e removes x87 support; this resulted in an unexpected pass. Unmark this test as broken. - - - - - 20160f1a by Ben Gamari at 2019-06-12T08:27:25-04:00 testsuite: Don't run tests requiring TH in profasm way when GhcDynamic Since we can't load profiled objects when GhcDynamic==YES. Affects: * T16737 * T16384 * T16718 * T16619 * T16190 - - - - - 7b751ed8 by Ben Gamari at 2019-06-12T17:52:35-04:00 gitlab-ci: Bump Docker image Fixes linters. - - - - - 5ffc266e by Ben Gamari at 2019-06-13T02:48:13-04:00 Add a few missing llvm-targets This should finally fix #14261. [skip ci] - - - - - fc6b23be by Phuong Trinh at 2019-06-13T02:48:50-04:00 Fix #16525: ObjectCode freed wrongly because of lack of info header check `checkUnload` currently doesn't check the info header of static objects. Thus, it may free an `ObjectCode` struct wrongly even if there's still a live static object whose info header lies in a mapped section of that `ObjectCode`. This fixes the issue by adding an appropriate check. - - - - - a657543c by Ben Gamari at 2019-06-13T02:49:25-04:00 PrelRules: Ensure that string unpack/append rule fires with source notes Previously the presence of source notes could hide nested applications of `unpackFoldrCString#` from our constant folding logic. For instance, consider the expression: ```haskell unpackFoldrCString# "foo" c (unpackFoldrCString# "baz" c n) ``` Specifically, ticks appearing in two places can defeat the rule: a. Surrounding the inner application of `unpackFoldrCString#` b. Surrounding the fold function, `c` The latter caused the `str_rules` testcase to fail when `base` was built with `-g3`. Fixes #16740. - - - - - e98d32a6 by David Eichmann at 2019-06-13T02:50:00-04:00 Hadrian: Track RTS library symlink targets This requires creating RTS library symlinks when registering, outside of the rule for the registered library file. - - - - - 35113117 by Alp Mestanogullari at 2019-06-13T02:50:37-04:00 Hadrian: Do not allow the Linux jobs to fail anymore MR !1151 makes the Hadrian/Linux job pass by fixing the last two test failures, so we can now be stricter and not allow those jobs to fail anymore, easily letting us see when patches introduce test failures. - - - - - 70b5eefe by Ben Gamari at 2019-06-13T02:51:13-04:00 users-guide: Fix a few markup issues Strangely these were only causing the build to fail in the aarch64-linux job, despite Sphinx throwing errors in all jobs I checked. Also changes some `#ifdef`s to `#if defined` to satisfy the linter. - - - - - 9721b40d by Ben Gamari at 2019-06-13T02:51:13-04:00 gitlab-ci: Don't build PDF user's guide on AArch64 For reasons I don't understand sphinx seems to fail to produce a .idx file for makeindex. - - - - - d550b771 by Ben Gamari at 2019-06-13T02:51:50-04:00 Clean up .circleci Move prepare-system.sh to .gitlab and remove everything else. - - - - - c53dfb3b by Ben Gamari at 2019-06-13T11:52:47-04:00 testsuite: A more portable solution to #9399 Previously we used an awful hybrid batch script/Bourne shell script to allow this test to run both on Windows and Linux (fixing #9399). However, this breaks on some libc implementations (e.g. musl). Fix this. Fixes #16798. - - - - - 74b5d049 by Ben Gamari at 2019-06-13T11:53:22-04:00 gitlab-ci: Disable deb9-llvm job, introduce nightly LLVM job This should help alleviate queue times as the LLVM job is one of the longest that we have. - - - - - 5ce63d52 by Ben Gamari at 2019-06-13T11:53:22-04:00 gitlab-ci: Disable validate-x86_64-linux-deb9 job to reduce load Enable artifacts on to ensure we have bindist coverage. - - - - - 7bc5d6c6 by Ben Gamari at 2019-06-13T23:34:41-04:00 Maintain separate flags for C++ compiler invocations Previously we would pass flags intended for the C compiler to the C++ compiler (see #16738). This would cause, for instance, `-std=gnu99` to be passed to the C++ compiler, causing spurious test failures. Fix this by maintaining a separate set of flags for C++ compilation invocations. - - - - - 71e75ba6 by Ömer Sinan Ağacan at 2019-06-13T23:35:19-04:00 Remove unused Unique field from StgFCallOp Fixes #16696 - - - - - ec25fe59 by Alp Mestanogullari at 2019-06-13T23:35:56-04:00 Hadrian: remove superfluous dependencies in Rules.Compile Each package's object files were 'need'ing the library files of all transitive dependencies of the current package, whichi is pointless since the said libraries are not needed until we link those object files together. This fixes #16759. - - - - - 3bc6df32 by Andreas Klebinger at 2019-06-13T23:36:34-04:00 Add Outputable instances for Float, Double. - - - - - effdd948 by Andrew Martin at 2019-06-14T10:48:13-04:00 Implement the -XUnliftedNewtypes extension. GHC Proposal: 0013-unlifted-newtypes.rst Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/98 Issues: #15219, #1311, #13595, #15883 Implementation Details: Note [Implementation of UnliftedNewtypes] Note [Unifying data family kinds] Note [Compulsory newtype unfolding] This patch introduces the -XUnliftedNewtypes extension. When this extension is enabled, GHC drops the restriction that the field in a newtype must be of kind (TYPE 'LiftedRep). This allows types like Int# and ByteArray# to be used in a newtype. Additionally, coerce is made levity-polymorphic so that it can be used with newtypes over unlifted types. The bulk of the changes are in TcTyClsDecls.hs. With -XUnliftedNewtypes, getInitialKind is more liberal, introducing a unification variable to return the kind (TYPE r0) rather than just returning (TYPE 'LiftedRep). When kind-checking a data constructor with kcConDecl, we attempt to unify the kind of a newtype with the kind of its field's type. When typechecking a data declaration with tcTyClDecl, we again perform a unification. See the implementation note for more on this. Co-authored-by: Richard Eisenberg <rae at richarde.dev> - - - - - 5279dda8 by Ben Gamari at 2019-06-14T10:48:51-04:00 PrelRules: Don't break let/app invariant in shiftRule Previously shiftRule would rewrite as invalid shift like ``` let x = I# (uncheckedIShiftL# n 80) in ... ``` to ``` let x = I# (error "invalid shift") in ... ``` However, this breaks the let/app invariant as `error` is not okay-for-speculation. There isn't an easy way to avoid this so let's not try. Instead we just take advantage of the undefined nature of invalid shifts and return zero. Fixes #16742. - - - - - 503e830c by Ben Gamari at 2019-06-14T23:10:08-04:00 gitlab-ci: Lint testsuite for framework failures This introduces a new lint job checking for framework failures and listing broken tests. - - - - - b5ea9323 by Ben Gamari at 2019-06-14T23:10:08-04:00 lint: Only apply --interactive lint to testsuite .T files - - - - - 5c97211c by Ben Gamari at 2019-06-14T23:10:08-04:00 gitlab-ci: Lint the linters - - - - - 257165b4 by Alp Mestanogullari at 2019-06-14T23:10:46-04:00 Remove duplicates from 'ghc --info' output - - - - - 5da6c86f by Ben Gamari at 2019-06-15T15:14:01-04:00 Bump unix submodule Skips `executeFile001` test in `threaded2` way. Fixes #16814. - - - - - 20b4d5ec by Ben Gamari at 2019-06-15T23:32:38-04:00 Disable optimisation when building Cabal lib for stage0 This disables optimisation when building Cabal for Hadrian and stage0 `ghc-cabal`. Cabal is performance critical in neither case nor will any performance difference here be visible to the end-user. See #16817. - - - - - 76b7f619 by Ben Gamari at 2019-06-15T23:32:38-04:00 Disable optimisation when building Cabal in development flavours This updates the make and Hadrian build flavours targetting developers to disable optimisation when building the Cabal library. Cabal tends to tickle some very bad compiler performance cases (e.g. #16577) so disabling optimisation here makes a sizeable impact on overall build time. See #16817. - - - - - 0d2a4258 by Ben Gamari at 2019-06-15T23:33:13-04:00 testsuite: Introduce concurrent_ways set Previously we just tested for the threaded2 when determining whether to skip tests which are fragile under concurrent execution. However, this isn't the only way which is concurrent. - - - - - beacb6fd by Ben Gamari at 2019-06-15T23:33:13-04:00 testsuite: Skip hDuplicateTo001 in concurrent ways As noted in #16819, this operation is racy under concurrent execution. - - - - - ca721193 by Aiken Cairncross at 2019-06-15T23:33:50-04:00 Fix typo in error message - - - - - 57b71848 by Ben Gamari at 2019-06-15T23:34:25-04:00 testsuite: Add assertions that way lists are in fact lists Previously there were a few cases where operations like `omit_ways` were incorrectly passed a single way (e.g. `omit_ways('threaded2')`). This won't work as the author expected. - - - - - 25ee60cd by Ryan Scott at 2019-06-15T23:35:03-04:00 Synchronize ClsInst.doTyConApp with TcTypeable validity checks (#15862) Issue #15862 demonstrated examples of type constructors on which `TcTypeable.tyConIsTypeable` would return `False`, but the `Typeable` constraint solver in `ClsInst` (in particular, `doTyConApp`) would try to generate `Typeable` evidence for anyway, resulting in disaster. This incongruity was caused by the fact that `doTyConApp` was using a weaker validity check than `tyConIsTypeable` to determine if a type constructor warrants `Typeable` evidence or not. The solution, perhaps unsurprisingly, is to use `tyConIsTypeable` in `doTyConApp` instead. To avoid import cycles between `ClsInst` and `TcTypeable`, I factored out `tyConIsTypeable` into its own module, `TcTypeableValidity`. Fixes #15862. - - - - - 4138bf86 by Krzysztof Gogolewski at 2019-06-15T23:35:38-04:00 Remove dead code - - - - - db313f98 by Ben Gamari at 2019-06-16T06:26:38-04:00 base/Event/Poll: Drop POLLRDHUP enum item Previously the Event enumeration produced by hsc2hs would sometimes include a currently-unused POLLRDHUP item. This unused binding would result in a build failure. Drop it. - - - - - 81608e82 by Ben Gamari at 2019-06-16T06:26:38-04:00 testsuite: Fix T8602 on musl Musl wants hash-bangs on all executables. - - - - - a0f68379 by Ben Gamari at 2019-06-16T06:26:38-04:00 testsuite: Ensure T5423 flushes C output buffer Previously T5423 would fail to flush the printf output buffer. Consequently it was platform-dependent whether the C or Haskell print output would be emitted first. - - - - - 543dfaab by Ben Gamari at 2019-06-16T06:26:38-04:00 testsuite: Flush conc059's printf buffer Otherwise it the order out the Haskell and C output will be system-dependent. - - - - - e647752e by Ben Gamari at 2019-06-16T06:26:38-04:00 testsuite: Ensure that ffi005 output order is predictable The libc output buffer wasn't being flushed, making the order system-depedent. - - - - - 338336d3 by Ben Gamari at 2019-06-16T06:26:38-04:00 gitlab-ci: Build alpine release bindists - - - - - 75c6ccf7 by Alp Mestanogullari at 2019-06-16T06:27:17-04:00 fix runghc's GHC detection logic to cover the "in-tree Hadrian build" scenario Before this patch, runghc would only run the GHC detection logic on Windows and assume that it was invoked through a wrapper script on all other platforms. This patch lifts this limitation and makes that logic work for the scenario where someone is calling the runghc executable directly, without passing an explicit path to GHC. - - - - - 3c35e140 by Ben Gamari at 2019-06-16T19:38:51-04:00 testsuite: Really fix #16741 The previous fix, !1095, didn't work as `--show-iface` ignores `-dsuppress-ticks`. Rework the test instead. - - - - - b3bb1b06 by Ben Gamari at 2019-06-16T19:38:51-04:00 gitlab-ci: Don't allow failure of deb9-dwarf job This #16741 out of the way this should now pass. - - - - - b965de1e by Ömer Sinan Ağacan at 2019-06-16T19:39:29-04:00 Use TupleSections in CmmParse.y, simplify a few exprs - - - - - 63965ae3 by Ben Gamari at 2019-06-17T01:20:21-04:00 make: Clean includes/settings file Now since this is generated by the build system we should ensure that it is properly cleaned. [skip ci] - - - - - bb141114 by Siddharth Bhat at 2019-06-17T01:20:57-04:00 Add link to mfix.github.io/ghc in HACKING.md - - - - - 24afbfe9 by Ben Gamari at 2019-06-17T10:20:32-04:00 gitlab-ci: Run nofib on binary distributions Updates docker images to ensure that the `time` utility is available. - - - - - 62f0213d by Fumiaki Kinoshita at 2019-06-18T16:00:20-04:00 Data.Ord: give a field name getDown to Down - - - - - da33f2bb by Fumiaki Kinoshita at 2019-06-18T16:00:20-04:00 Add more newtype-derived instances to Data.Ord.Down Metric Increase: haddock.base - - - - - dbf9ca20 by Ben Gamari at 2019-06-18T16:00:56-04:00 testsuite: Add testcase for #16689 - - - - - 29ec33cd by Ben Gamari at 2019-06-18T16:00:56-04:00 SafeHaskell: Don't throw -Wsafe warning if module is declared Safe Fixes #16689. - - - - - a491e40c by Ben Gamari at 2019-06-18T16:01:31-04:00 hadrian: Compile UserSettings with -O0 This guarantees that the interface file for `UserSettings` doesn't contain any unfoldings, ensuring that a change in it requires minimal rebuilds. - - - - - 74bd6b22 by Ben Gamari at 2019-06-18T16:02:07-04:00 testsuite: Add test for #16832 - - - - - 6a92f59d by Ben Gamari at 2019-06-18T16:02:42-04:00 gitlab-ci: Run alpine builds during nightly job - - - - - 4549cadf by Andreas Klebinger at 2019-06-18T16:03:19-04:00 Make sure mkSplitUniqSupply stores the precomputed mask only. mkSplitUniqSupply was lazy on the boxed char. This caused a bunch of issues: * The closure captured the boxed Char * The mask was recomputed on every split of the supply. * It also caused the allocation of MkSplitSupply to happen in it's own (allocated) closure. The reason of which I did not further investigate. We know force the computation of the mask inside mkSplitUniqSupply. * This way the mask is computed at most once per UniqSupply creation. * It allows ww to kick in, causing the closure to retain the unboxed value. Requesting Uniques in a loop is now faster by about 20%. I did not check the impact on the overall compiler, but I added a test to avoid regressions. - - - - - 8584430e by Ömer Sinan Ağacan at 2019-06-19T15:00:11+03:00 Fix a Note name in CmmNode ("Continuation BlockIds" is referenced in CmmProcPoint) [skip ci] - - - - - 9d58554f by Ömer Sinan Ağacan at 2019-06-19T22:14:26-04:00 Properly trim IdInfos of DFunIds and PatSyns in TidyPgm Not doing this right caused #16608. We now properly trim IdInfos of DFunIds and PatSyns. Some further refactoring done by SPJ. Two regression tests T16608_1 and T16608_2 added. Fixes #16608 - - - - - 39c758e1 by Roland Senn at 2019-06-19T22:15:04-04:00 Fix #1620: ModBreaks.modBreaks_array not initialised After a :cd command and after setting some package flags, GHCi unloads all loaded modules by resetting the list of targets. This patch deletes eventually defined debugger breakpoints, before GHCi resets the target list. The common code is factored out into the new function clearAllTargets. - - - - - 3c9b57b0 by Simon Peyton Jones at 2019-06-19T22:15:39-04:00 Fix two places that failed the substitution invariant The substition invariant relies on keeping the in-scope set in sync, and we weren't always doing so, which means that a DEBUG compiler crashes sometimes with an assertion failure This patch fixes a couple more cases. Still not validate clean (with -DEEBUG) but closer! - - - - - 48fb3482 by Simon Peyton Jones at 2019-06-19T22:15:39-04:00 Fix typechecking of partial type signatures Partial type sigs had grown hair. tcHsParialSigType was doing lots of unnecessary work, and tcInstSig was cloning it unnecessarily -- and the result didn't even work: #16728. This patch cleans it all up, described by TcHsType Note [Checking parital type signatures] I basically just deleted code... but very carefully! Some refactoring along the way * Distinguish more explicintly between "anonymous" wildcards "_" and "named" wildcards "_a". I changed the names of a number of functions to make this distinction much more apparent. The patch also revealed that the code in `TcExpr` that implements the special typing rule for `($)` was wrong. It called `getRuntimeRep` in a situation where where was no particular reason to suppose that the thing had kind `TYPE r`. This caused a crash in typecheck/should_run/T10846. The fix was easy, and actually simplifies the code in `TcExpr` quite a bit. Hooray. - - - - - 3ae23992 by Simon Peyton Jones at 2019-06-19T22:15:39-04:00 Comments and tiny refactor * Added Note [Quantified varaibles in partial type signatures] in TcRnTypes * Kill dVarSetElemsWellScoped; it was only called in one function, quantifyTyVars. I inlined it because it was only scopedSort . dVarSetElems * Kill Type.tyCoVarsOfBindersWellScoped, never called. - - - - - bff2f24b by John Ericson at 2019-06-19T22:16:16-04:00 Move 'Platform' to ghc-boot ghc-pkg needs to be aware of platforms so it can figure out which subdire within the user package db to use. This is admittedly roundabout, but maybe Cabal could use the same notion of a platform as GHC to good affect too. - - - - - a298b96e by John Ericson at 2019-06-19T22:16:16-04:00 Add 'stringEncodeArch' and 'stringEncodeOS' to GHC.Platform - - - - - d406a16a by John Ericson at 2019-06-19T22:16:16-04:00 ghc-pkg needs settings file to un-hardcode target platform This matches GHC itself getting the target platform from there. - - - - - aa4891a7 by Ben Gamari at 2019-06-19T22:16:51-04:00 users-guide: Fix a variety of broken links and syntax - - - - - fe819dd6 by Ben Gamari at 2019-06-19T22:16:51-04:00 users-guide: Update -Wsafe description for #16689 We no longer emit a warning when a safe module is explicitly declared as such. - - - - - c311277b by Matthías Páll Gissurarson at 2019-06-21T03:21:21+02:00 Add HoleFitPlugins and RawHoleFits This patch adds a new kind of plugin, Hole fit plugins. These plugins can change what candidates are considered when looking for valid hole fits, and add hole fits of their own. The type of a plugin is relatively simple, ``` type FitPlugin = TypedHole -> [HoleFit] -> TcM [HoleFit] type CandPlugin = TypedHole -> [HoleFitCandidate] -> TcM [HoleFitCandidate] data HoleFitPlugin = HoleFitPlugin { candPlugin :: CandPlugin , fitPlugin :: FitPlugin } data TypedHole = TyH { tyHRelevantCts :: Cts -- ^ Any relevant Cts to the hole , tyHImplics :: [Implication] -- ^ The nested implications of the hole with the -- innermost implication first. , tyHCt :: Maybe Ct -- ^ The hole constraint itself, if available. } This allows users and plugin writers to interact with the candidates and fits as they wish, even going as far as to allow them to reimplement the current functionality (since `TypedHole` contains all the relevant information). As an example, consider the following plugin: ``` module HolePlugin where import GhcPlugins import TcHoleErrors import Data.List (intersect, stripPrefix) import RdrName (importSpecModule) import TcRnTypes import System.Process plugin :: Plugin plugin = defaultPlugin { holeFitPlugin = hfp, pluginRecompile = purePlugin } hfp :: [CommandLineOption] -> Maybe HoleFitPluginR hfp opts = Just (fromPureHFPlugin $ HoleFitPlugin (candP opts) (fp opts)) toFilter :: Maybe String -> Maybe String toFilter = flip (>>=) (stripPrefix "_module_") replace :: Eq a => a -> a -> [a] -> [a] replace match repl str = replace' [] str where replace' sofar (x:xs) | x == match = replace' (repl:sofar) xs replace' sofar (x:xs) = replace' (x:sofar) xs replace' sofar [] = reverse sofar -- | This candidate plugin filters the candidates by module, -- using the name of the hole as module to search in candP :: [CommandLineOption] -> CandPlugin candP _ hole cands = do let he = case tyHCt hole of Just (CHoleCan _ h) -> Just (occNameString $ holeOcc h) _ -> Nothing case toFilter he of Just undscModName -> do let replaced = replace '_' '.' undscModName let res = filter (greNotInOpts [replaced]) cands return $ res _ -> return cands where greNotInOpts opts (GreHFCand gre) = not $ null $ intersect (inScopeVia gre) opts greNotInOpts _ _ = True inScopeVia = map (moduleNameString . importSpecModule) . gre_imp -- Yes, it's pretty hacky, but it is just an example :) searchHoogle :: String -> IO [String] searchHoogle ty = lines <$> (readProcess "hoogle" [(show ty)] []) fp :: [CommandLineOption] -> FitPlugin fp ("hoogle":[]) hole hfs = do dflags <- getDynFlags let tyString = showSDoc dflags . ppr . ctPred <$> tyHCt hole res <- case tyString of Just ty -> liftIO $ searchHoogle ty _ -> return [] return $ (take 2 $ map (RawHoleFit . text . ("Hoogle says: " ++)) res) ++ hfs fp _ _ hfs = return hfs ``` with this plugin available, you can compile the following file ``` {-# OPTIONS -fplugin=HolePlugin -fplugin-opt=HolePlugin:hoogle #-} module Main where import Prelude hiding (head, last) import Data.List (head, last) t :: [Int] -> Int t = _module_Prelude g :: [Int] -> Int g = _module_Data_List main :: IO () main = print $ t [1,2,3] ``` and get the following output: ``` Main.hs:14:5: error: • Found hole: _module_Prelude :: [Int] -> Int Or perhaps ‘_module_Prelude’ is mis-spelled, or not in scope • In the expression: _module_Prelude In an equation for ‘t’: t = _module_Prelude • Relevant bindings include t :: [Int] -> Int (bound at Main.hs:14:1) Valid hole fits include Hoogle says: GHC.List length :: [a] -> Int Hoogle says: GHC.OldList length :: [a] -> Int t :: [Int] -> Int (bound at Main.hs:14:1) g :: [Int] -> Int (bound at Main.hs:17:1) length :: forall (t :: * -> *) a. Foldable t => t a -> Int with length @[] @Int (imported from ‘Prelude’ at Main.hs:5:1-34 (and originally defined in ‘Data.Foldable’)) maximum :: forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a with maximum @[] @Int (imported from ‘Prelude’ at Main.hs:5:1-34 (and originally defined in ‘Data.Foldable’)) (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits) | 14 | t = _module_Prelude | ^^^^^^^^^^^^^^^ Main.hs:17:5: error: • Found hole: _module_Data_List :: [Int] -> Int Or perhaps ‘_module_Data_List’ is mis-spelled, or not in scope • In the expression: _module_Data_List In an equation for ‘g’: g = _module_Data_List • Relevant bindings include g :: [Int] -> Int (bound at Main.hs:17:1) Valid hole fits include Hoogle says: GHC.List length :: [a] -> Int Hoogle says: GHC.OldList length :: [a] -> Int g :: [Int] -> Int (bound at Main.hs:17:1) head :: forall a. [a] -> a with head @Int (imported from ‘Data.List’ at Main.hs:7:19-22 (and originally defined in ‘GHC.List’)) last :: forall a. [a] -> a with last @Int (imported from ‘Data.List’ at Main.hs:7:25-28 (and originally defined in ‘GHC.List’)) | 17 | g = _module_Data_List ``` This relatively simple plugin has two functions, as an example of what is possible to do with hole fit plugins. The candidate plugin starts by filtering the candidates considered by module, indicated by the name of the hole (`_module_Data_List`). The second function is in the fit plugin, where the plugin invokes a local hoogle instance to search by the type of the hole. By adding the `RawHoleFit` type, we can also allow these completely free suggestions, used in the plugin above to display fits found by Hoogle. Additionally, the `HoleFitPluginR` wrapper can be used for plugins to maintain state between invocations, which can be used to speed up invocation of plugins that have expensive initialization. ``` -- | HoleFitPluginR adds a TcRef to hole fit plugins so that plugins can -- track internal state. Note the existential quantification, ensuring that -- the state cannot be modified from outside the plugin. data HoleFitPluginR = forall s. HoleFitPluginR { hfPluginInit :: TcM (TcRef s) -- ^ Initializes the TcRef to be passed to the plugin , hfPluginRun :: TcRef s -> HoleFitPlugin -- ^ The function defining the plugin itself , hfPluginStop :: TcRef s -> TcM () -- ^ Cleanup of state, guaranteed to be called even on error } ``` Of course, the syntax here is up for debate, but hole fit plugins allow us to experiment relatively easily with ways to interact with typed-holes without having to dig deep into GHC. Reviewers: bgamari Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5373 - - - - - 2485c08a by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Skip dynamicToo006 when dynamic linking is not available This was previously failling on Windows. - - - - - aa516431 by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Mark T3372 as fragile on Windows On Windows we must lock package databases even when opening for read-only access. This means that concurrent GHC sessions are very likely to fail with file lock contention. See #16773. - - - - - 2eedb120 by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Add stderr output for UnsafeInfered02 on Windows This test uses TemplateHaskell causing GHC to build dynamic objects on platforms where dynamic linking is available. However, Windows doesn't support dynamic linking. Consequently the test would fail on Windows with: ```patch --- safeHaskell/safeInfered/UnsafeInfered02.run/UnsafeInfered02.stderr.normalised 2019-06-04 15:10:10.521594200 +0000 +++ safeHaskell/safeInfered/UnsafeInfered02.run/UnsafeInfered02.comp.stderr.normalised 2019-06-04 15:10:10.523546200 +0000 @@ -1,5 +1,5 @@ -[1 of 2] Compiling UnsafeInfered02_A ( UnsafeInfered02_A.hs, UnsafeInfered02_A.o, UnsafeInfered02_A.dyn_o ) -[2 of 2] Compiling UnsafeInfered02 ( UnsafeInfered02.hs, UnsafeInfered02.o, UnsafeInfered02.dyn_o ) +[1 of 2] Compiling UnsafeInfered02_A ( UnsafeInfered02_A.hs, UnsafeInfered02_A.o ) +[2 of 2] Compiling UnsafeInfered02 ( UnsafeInfered02.hs, UnsafeInfered02.o ) UnsafeInfered02.hs:4:1: UnsafeInfered02_A: Can't be safely imported! ``` The other approach I considered for this issue is to pass `-v0` to GHC. However, I felt we should probably do this consistently for all of the tests in this directory and this would take more time than I currently have. - - - - - 3967d13a by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Mark OldModLocation as broken on Windows Strangely the path it emits contains duplicate path delimiters (#16772), ```patch --- ghc-api/downsweep/OldModLocation.run/OldModLocation.stderr.normalised 2019-06-04 14:40:26.326075000 +0000 +++ ghc-api/downsweep/OldModLocation.run/OldModLocation.run.stderr.normalised 2019-06-04 14:40:26.328029200 +0000 @@ -1 +1 @@ -[Just "A.hs",Just "mydir/B.hs"] +[Just "A.hs",Just "mydir//B.hs"] ``` - - - - - 31f2ea68 by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Mark T7170 as broken on Windows Due to #16801. - - - - - 7bd1c3e1 by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Mark T7702 as broken on Windows Due to #16799. - - - - - 84900724 by Ben Gamari at 2019-06-21T13:32:34-04:00 testsuite: Mark T15633a and T15633b as fragile on Windows As noted in #16813, these tests seem to be fragile on Windows. - - - - - 49fff41d by Ben Gamari at 2019-06-21T13:32:34-04:00 linker: Disable code unloading As noted in #16841, there are currently a variety of bugs in the unloading logic. These only affect Windows since code unloading is disabled on Linux, where we build with `GhcDynamic=YES` by default. In the interest of getting the tree green on Windows disable code unloading until the issues are resolved. - - - - - e0595d22 by Ben Gamari at 2019-06-22T09:36:53-04:00 testsuite: Mark T16608_* as fragile on Darwin As noted in #16855. - - - - - 655c6e26 by Ben Gamari at 2019-06-22T10:06:05-04:00 ghci: Don't rely on resolution of System.IO to base module Previously we would hackily evaluate a textual code snippet to compute actions to disable I/O buffering and flush the stdout/stderr handles. This broke in a number of ways (#15336, #16563). Instead we now ship a module (`GHC.GHCi.Helpers`) with `base` containing the needed actions. We can then easily refer to these via `Orig` names. - - - - - 8f8fc31b by Ben Gamari at 2019-06-22T10:06:05-04:00 testsuite: Add test for #16563 - - - - - 22e721c1 by Ben Gamari at 2019-06-22T10:06:05-04:00 testsuite: Mark T5611 as broken in ghci way As described in #16845. - - - - - b0d6bf2a by Ben Gamari at 2019-06-22T10:06:05-04:00 rts: Reset STATIC_LINK field of reverted CAFs When we revert a CAF we must reset the STATIC_LINK field lest the GC might ignore the CAF (e.g. as it carries the STATIC_FLAG_LIST flag) and will consequently overlook references to object code that we are trying to unload. This would result in the reachable object code being unloaded. See Note [CAF lists] and Note [STATIC_LINK fields]. This fixes #16842. Idea-due-to: Phuong Trinh <lolotp at fb.com> - - - - - 1f2fff89 by Ben Gamari at 2019-06-22T10:06:05-04:00 testsuite: Add caf_crash testcase - - - - - ade3db53 by Ben Gamari at 2019-06-23T17:19:48-04:00 testsuite: Test for #13786 - - - - - 5a502cd1 by Ben Gamari at 2019-06-23T17:19:48-04:00 ghci: Load static objects in batches Previously in the case where GHC was dynamically linked we would load static objects one-by-one by linking each into its own shared object and dlopen'ing each in order. However, this meant that the link would fail in the event that the objects had cyclic symbol dependencies. Here we fix this by merging each "run" of static objects into a single shared object and loading this. Fixes #13786 for the case where GHC is dynamically linked. - - - - - 9bbcc3be by Ryan Scott at 2019-06-23T17:20:41-04:00 Refactor UnliftedNewtypes-relation kind signature validity checks This fixes three infelicities related to the programs that are (and aren't) accepted with `UnliftedNewtypes`: * Enabling `UnliftedNewtypes` would permit newtypes to have return kind `Id Type`, which had disastrous results (i.e., GHC panics). * Data family declarations ending in kind `TYPE r` (for some `r`) weren't being accepted if `UnliftedNewtypes` wasn't enabled, despite the GHC proposal specifying otherwise. * GHC wasn't warning about programs that _would_ typecheck if `UnliftedNewtypes` were enabled in certain common cases. As part of fixing these issues, I factored out the logic for checking all of the various properties about data type/data family return kinds into a single `checkDataKindSig` function. I also cleaned up some of the formatting in the existing error message that gets thrown. Fixes #16821, fixes #16827, and fixes #16829. - - - - - 71aca77c by Erik de Castro Lopo at 2019-06-24T01:11:46-04:00 Fixes for LLVM 7 LLVM version numberinf changed recently. Previously, releases were numbered 4.0, 5.0 and 6.0 but with version 7, they dropped the redundant ".0". Fix requires for Llvm detection and some code. - - - - - 581cbc28 by Erik de Castro Lopo at 2019-06-24T01:12:22-04:00 Add MonadFail instance for ParserM - - - - - 15b26223 by Andrey Mokhov at 2019-06-25T01:36:10-04:00 Fix cyclic dependencies when using --configure This resolves #16809 (https://gitlab.haskell.org/ghc/ghc/issues/16809). This patch removes the unnecessary dependency on configure-generated flags `windowsHost`, `osxHost` and `iosHost`, using the information provided by the module `System.Info` instead. We also take care to use the `CrossCompiling` flag generated by the configure script only after the latter had a chance to run. - - - - - ebd63e8d by Ömer Sinan Ağacan at 2019-06-25T01:36:50-04:00 Simplify link_caf and mkForeignLabel functions - - - - - c346585b by Ben Gamari at 2019-06-25T08:37:46-04:00 testsuite: A major revamp of the driver This tries to put the testsuite driver into a slightly more maintainable condition: * Add type annotations where easily done * Use pathlib.Path instead of str paths * Make it pass the mypy typechecker - - - - - bb40bd37 by Ben Gamari at 2019-06-25T08:37:46-04:00 testsuite: Fix a few issues in JUnit output * Make it pass mypy * Fix a typo in test name field * Report more stderr output * Report stdout output - - - - - 95f56853 by Ben Gamari at 2019-06-25T08:37:46-04:00 gitlab-ci: Add testsuite typechecking lint - - - - - 9542ab06 by Ben Gamari at 2019-06-25T08:38:22-04:00 testsuite: Don't run T16525a with -DS unless compiler_debugged Originally I was thinking of just skipping the test unless compiled_debugged==True. However, the test will likely be useful even without -DS, so let's run it either way. - - - - - d0993a29 by Ben Gamari at 2019-06-25T08:38:22-04:00 testsuite: Fix expected output for caf_crash - - - - - 757b71d9 by Ben Gamari at 2019-06-25T08:38:22-04:00 testsuite: Mark ghci058 as broken on Windows Due to #16858. - - - - - 38ded743 by Siddharth Bhat at 2019-06-25T15:15:16+02:00 [skip ci] Typo fix: b*ar*nches -> b*ra*nches - - - - - 8a03d5a1 by Ben Gamari at 2019-06-25T22:20:24-04:00 testsuite: Add test for #16846 - - - - - 5ff0a171 by Ben Gamari at 2019-06-25T22:20:24-04:00 CoreToStg: Enable CAFfyness checking with -dstg-lint The debugging involved in finding #16846 wouldn't have been necessary had the consistentCafInfo check been enabled. However, :wq - - - - - cac8dc9f by Ben Gamari at 2019-06-25T22:20:24-04:00 Don't eta-expand unsaturated primops Previously, as described in Note [Primop wrappers], `hasNoBinding` would return False in the case of `PrimOpId`s. This would result in eta expansion of unsaturated primop applications during CorePrep. Not only did this expansion result in unnecessary allocations, but it also meant lead to rather nasty inconsistencies between the CAFfy-ness determinations made by TidyPgm and CorePrep. This fixes #16846. - - - - - b90437d8 by Ben Gamari at 2019-06-25T22:20:59-04:00 testsuite: Unbreak T16608 tests Sleep to avoid non-determinism due to Darwin's poor mtime resolution. Fixes #16855. - - - - - ff2b99e1 by Ömer Sinan Ağacan at 2019-06-25T22:21:38-04:00 Remove unused UniqSupply functions - - - - - 4c2127c4 by Ben Gamari at 2019-06-25T22:52:26-04:00 Bump containers submodule to v0.6.2.1 - - - - - 5c3f2080 by Ben Gamari at 2019-06-25T22:52:26-04:00 Bump Cabal submodule to what will become 3.0.0.0 Metric Increase: haddock.Cabal - - - - - a863c44f by Oleg Grenrus at 2019-06-25T23:25:08-04:00 Add -Winferred-safe-imports warning This commit partly reverts e69619e923e84ae61a6bb4357f06862264daa94b commit by reintroducing Sf_SafeInferred SafeHaskellMode. We preserve whether module was declared or inferred Safe. When declared-Safe module imports inferred-Safe, we warn. This inferred status is volatile, often enough it's a happy coincidence, something which cannot be relied upon. However, explicitly Safe or Trustworthy packages won't accidentally become Unsafe. Updates haddock submodule. - - - - - 8ec5ceb0 by Oleg Grenrus at 2019-06-25T23:25:08-04:00 Add -Wmissing-safe-haskell-mode warning - - - - - c99d9aab by Ben Gamari at 2019-06-26T08:15:02-04:00 testsuite: Fix T16832 The test seems to have been missing the name of its script and didn't build with HEAD. How it made it through CI is beyond me. - - - - - e0899925 by Siddharth Bhat at 2019-06-26T08:16:30-04:00 [skip ci] add a blurb about the purpose of Printer.c - - - - - 58e84b30 by Ben Gamari at 2019-06-26T08:18:25-04:00 testsuite: Use safe FFI call in T5611 The original issue, #5611, was concerned with safe calls. However, the test inexplicably used an unsafe call. Fix this. - - - - - 12752342 by Ben Gamari at 2019-06-26T08:18:25-04:00 testsuite: Add T5611a This is the same as T5611 but with an unsafe call to sleep. - - - - - 551b79e4 by Ben Gamari at 2019-06-26T08:18:25-04:00 testsuite: Mark T5611 and T5611a as fragile - - - - - 44d08c32 by Ben Gamari at 2019-06-26T08:20:54-04:00 testsuite: Run and report on fragile tests This allows us to run (but ignore the result of) fragile testcases. Hopefully this should allow us to more easily spot when a fragile test becomes un-fragile. - - - - - 1c4f18d0 by Ben Gamari at 2019-06-26T08:20:54-04:00 testsuite: More type signatures - - - - - a586b33f by Matthew Pickering at 2019-06-27T10:42:29-04:00 rts: Correct handling of LARGE ARR_WORDS in LDV profiler This implements the correct fix for #11627 by skipping over the slop (which is zeroed) rather than adding special case logic for LARGE ARR_WORDS which runs the risk of not performing a correct census by ignoring any subsequent blocks. This approach implements similar logic to that in Sanity.c - - - - - ed4cbd93 by Matthew Pickering at 2019-06-27T10:42:29-04:00 rts: Correct assertion in LDV_recordDead It is possible that void_total is exactly equal to not_used and the other assertions for this check for <= rather than <. - - - - - 07cffc49 by Matthew Pickering at 2019-06-27T10:42:29-04:00 rts: Do not traverse nursery for dead closures in LDV profile It is important that `heapCensus` and `LdvCensusForDead` traverse the same areas. `heapCensus` increases the `not_used` counter which tracks how many closures are live but haven't been used yet. `LdvCensusForDead` increases the `void_total` counter which tracks how many dead closures there are. The `LAG` is then calculated by substracting the `void_total` from `not_used` and so it is essential that `not_used >= void_total`. This fact is checked by quite a few assertions. However, if a program has low maximum residency but allocates a lot in the nursery then these assertions were failing (see #16753 and #15903) because `LdvCensusForDead` was observing dead closures from the nursery which totalled more than the `not_used`. The same closures were not counted by `heapCensus`. Therefore, it seems that the correct fix is to make `LdvCensusForDead` agree with `heapCensus` and not traverse the nursery for dead closures. Fixes #16100 #16753 #15903 #8982 - - - - - c1f67887 by Roland Senn at 2019-06-27T10:43:10-04:00 Improve doc for :type-at. (#14780) - - - - - 52f10216 by Roland Zumkeller at 2019-06-27T10:43:47-04:00 configure: prefer cc over gcc Fixes #16857. - - - - - 90e0ab7d by Sylvain Henry at 2019-06-27T10:44:25-04:00 Fix Happy deps for Stack (#16825) - - - - - d35cec7a by Fraser Tweedale at 2019-06-27T10:45:01-04:00 getExecutablePath: get path from sysctl on FreeBSD - - - - - 2a68b8b7 by nineonine at 2019-06-27T10:45:39-04:00 Fix #16805 by formatting warning message - - - - - 217258d0 by Ben Gamari at 2019-06-27T10:46:18-04:00 testsuite: Add more type annotations to perf_notes - - - - - 4ec233ec by Sylvain Henry at 2019-06-27T23:58:37-04:00 Fix GCC warnings with __clear_cache builtin (#16867) - - - - - ef6d9a50 by Artem Pelenitsyn at 2019-06-27T23:59:15-04:00 typo in the docs for DynFlags.hs - - - - - 11bac115 by Travis Whitaker at 2019-06-28T15:25:05-04:00 Correct closure observation, construction, and mutation on weak memory machines. Here the following changes are introduced: - A read barrier machine op is added to Cmm. - The order in which a closure's fields are read and written is changed. - Memory barriers are added to RTS code to ensure correctness on out-or-order machines with weak memory ordering. Cmm has a new CallishMachOp called MO_ReadBarrier. On weak memory machines, this is lowered to an instruction that ensures memory reads that occur after said instruction in program order are not performed before reads coming before said instruction in program order. On machines with strong memory ordering properties (e.g. X86, SPARC in TSO mode) no such instruction is necessary, so MO_ReadBarrier is simply erased. However, such an instruction is necessary on weakly ordered machines, e.g. ARM and PowerPC. Weam memory ordering has consequences for how closures are observed and mutated. For example, consider a closure that needs to be updated to an indirection. In order for the indirection to be safe for concurrent observers to enter, said observers must read the indirection's info table before they read the indirectee. Furthermore, the entering observer makes assumptions about the closure based on its info table contents, e.g. an INFO_TYPE of IND imples the closure has an indirectee pointer that is safe to follow. When a closure is updated with an indirection, both its info table and its indirectee must be written. With weak memory ordering, these two writes can be arbitrarily reordered, and perhaps even interleaved with other threads' reads and writes (in the absence of memory barrier instructions). Consider this example of a bad reordering: - An updater writes to a closure's info table (INFO_TYPE is now IND). - A concurrent observer branches upon reading the closure's INFO_TYPE as IND. - A concurrent observer reads the closure's indirectee and enters it. (!!!) - An updater writes the closure's indirectee. Here the update to the indirectee comes too late and the concurrent observer has jumped off into the abyss. Speculative execution can also cause us issues, consider: - An observer is about to case on a value in closure's info table. - The observer speculatively reads one or more of closure's fields. - An updater writes to closure's info table. - The observer takes a branch based on the new info table value, but with the old closure fields! - The updater writes to the closure's other fields, but its too late. Because of these effects, reads and writes to a closure's info table must be ordered carefully with respect to reads and writes to the closure's other fields, and memory barriers must be placed to ensure that reads and writes occur in program order. Specifically, updates to a closure must follow the following pattern: - Update the closure's (non-info table) fields. - Write barrier. - Update the closure's info table. Observing a closure's fields must follow the following pattern: - Read the closure's info pointer. - Read barrier. - Read the closure's (non-info table) fields. This patch updates RTS code to obey this pattern. This should fix long-standing SMP bugs on ARM (specifically newer aarch64 microarchitectures supporting out-of-order execution) and PowerPC. This fixes issue #15449. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - bd660ede by Ben Gamari at 2019-06-28T15:25:30-04:00 rts: Assert that LDV profiling isn't used with parallel GC I'm not entirely sure we are careful about ensuring this; this is a last-ditch check. - - - - - 82693938 by Moritz Angermann at 2019-07-02T16:18:05-04:00 Add _GLOBAL_OFFSET_TABLE_ support This adds lookup logic for _GLOBAL_OFFSET_TABLE_ as well as relocation logic for R_ARM_BASE_PREL and R_ARM_GOT_BREL which the gnu toolchain (gas, gcc, ...) prefers to produce. Apparently recent llvm toolchains will produce those as well. - - - - - 348e3f8e by Edward Amsden at 2019-07-02T16:18:05-04:00 Lookup _GLOBAL_OFFSET_TABLE by symbol->addr when doing relocations - - - - - e9abcad4 by Moritz Angermann at 2019-07-02T16:18:05-04:00 No atomics on arm32; this will just yield stubs. As such the internal linker will fail for them. The alternative would be to implement them as stubs in the linker and have them barf when called. > Not all operations are supported by all target processors. If a particular operation cannot be implemented on the target processor, a warning is generated and a call an external function is generated. The external function carries the same name as the built-in version, with an additional suffix ‘_n’ where n is the size of the data type. (https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html) - - - - - 023a2bc7 by Ben Gamari at 2019-07-02T16:18:05-04:00 Apply suggestion to rts/linker/elf_got.c - - - - - 0bed9647 by Ben Gamari at 2019-07-02T16:18:05-04:00 Apply suggestion to rts/linker/Elf.c - - - - - cef80c0b by nineonine at 2019-07-02T16:18:44-04:00 Fix #15843 by extending Template Haskell AST for tuples to support sections - - - - - 294b55dc by Eric Wolf at 2019-07-02T16:19:21-04:00 Add test for #16575 just use the test to show the defective behaviour, so we can see the difference, when it gets fixed - - - - - 60b9eab9 by Ömer Sinan Ağacan at 2019-07-02T16:19:59-04:00 Fix stage 1 warnings - - - - - df3e5b74 by David Eichmann at 2019-07-02T16:20:36-04:00 Hadrian: disable cloud build cache for symlinks #16800 This is a temporary workaround shake not supporting symlinks when using cloud/cached builds. - - - - - acd79558 by Abhiroop Sarkar at 2019-07-03T09:33:39-04:00 Add support for SIMD operations in the NCG This adds support for constructing vector types from Float#, Double# etc and performing arithmetic operations on them Cleaned-Up-By: Ben Gamari <ben at well-typed.com> - - - - - 973c61b5 by Ben Gamari at 2019-07-03T09:34:16-04:00 gitlab-ci: Fix doc-tarball job Previously we used the deb9-debug job which used the `validate` build flavour which disabled `BUILD_SPHINX_PDF`. Fix this. Fixes #16890. - - - - - a25f6f55 by Ryan Scott at 2019-07-03T09:34:54-04:00 Bump template-haskell version to 2.16.0.0 Commit cef80c0b9edca3d21b5c762f51dfbab4c5857d8a debuted a breaking change to `template-haskell`, so in order to guard against it properly with CPP, we need to bump the `template-haskell` version number accordingly. - - - - - f7a2e709 by Ben Gamari at 2019-07-04T15:29:49-04:00 Bump parsec submodule to 3.1.14.0 - - - - - d7f7e1ed by Siddharth Bhat at 2019-07-04T21:22:00-04:00 Make printer untag when chasing a pointer in a RET_FUN frame This is to mimic what `Scav.c` does. This should fix a crash in the printer. - - - - - 675d27fc by Ben Gamari at 2019-07-04T21:22:35-04:00 gitlab: Reduce size of template headings - - - - - 679427f8 by Vladislav Zavialov at 2019-07-04T21:23:10-04:00 Produce all DerivInfo in tcTyAndClassDecls Before this refactoring: * DerivInfo for data family instances was returned from tcTyAndClassDecls * DerivInfo for data declarations was generated with mkDerivInfos and added at a later stage of the pipeline in tcInstDeclsDeriv After this refactoring: * DerivInfo for both data family instances and data declarations is returned from tcTyAndClassDecls in a single list. This uniform treatment results in a more convenient arrangement to fix #16731. - - - - - 53aa59f3 by Simon Peyton Jones at 2019-07-04T21:23:49-04:00 Add a missing zonk (fixes #16902) In the eager unifier, when unifying (tv1 ~ tv2), when we decide to swap them over, to unify (tv2 ~ tv1), I'd forgotten to ensure that tv1's kind was fully zonked, which is an invariant of uUnfilledTyVar2. That could lead us to build an infinite kind, or (in the case of #16902) update the same unification variable twice. Yikes. Now we get an error message rather than non-termination, which is much better. The error message is not great, but it's a very strange program, and I can't see an easy way to improve it, so for now I'm just committing this fix. Here's the decl data F (a :: k) :: (a ~~ k) => Type where MkF :: F a and the rather error message of which I am not proud T16902.hs:11:10: error: • Expected a type, but found something with kind ‘a1’ • In the type ‘F a’ - - - - - ed662901 by Daniel Gröber at 2019-07-04T21:24:26-04:00 rts: Fix -hT option with profiling rts In dumpCensus we switch/case on doHeapProfile twice. The second switch tries to barf on unknown doHeapProfile modes but HEAP_BY_CLOSURE_TYPE is checked by the first switch and not included in the second. So when trying to pass -hT to the profiling rts it barfs. This commit simply merges the two switches into one which fixes this problem. - - - - - 80afdf6b by Simon Peyton Jones at 2019-07-04T21:25:05-04:00 Fix over-eager implication constraint discard Ticket #16247 showed that we were discarding an implication constraint that had empty ic_wanted, when we still needed to keep it so we could check whether it had a bad telescope. Happily it's a one line fix. All the rest is comments! - - - - - f002250a by Andreas Klebinger at 2019-07-04T21:25:43-04:00 Dont gather ticks when only striping them in STG. Adds stripStgTicksTopE which only returns the stripped expression. So far we also allocated a list for the stripped ticks which was never used. Allocation difference is as expected very small but present. About 0.02% difference when compiling with -O. - - - - - a76b233d by Artem Pelenitsyn at 2019-07-05T07:06:55-04:00 Make all submodules have absolute URLs The relative URLs were a workaround to let most contributors fork from Github due to a weakness in the haskell.org server. This workaround is no longer needed. And relative submodule URLs are an impediment to forking which makes contributions harder than they should be. The URLs are chosen to clone from https, because this makes sure that anybody, even not a registered Gitlab user, can clone a fork recursively. - - - - - 62b82135 by Ryan Scott at 2019-07-05T07:07:38-04:00 More sensible SrcSpans for recursive pattern synonym errors (#16900) Attach the `SrcSpan` of the first pattern synonym binding involved in the recursive group when throwing the corresponding error message, similarly to how it is done for type synonyms. Fixes #16900. - - - - - 2fd1ed54 by nineonine at 2019-07-05T07:08:17-04:00 Fix #16895 by checking whether infix expression operator is a variable - - - - - 03f5adcd by David Eichmann at 2019-07-08T07:07:10-04:00 Bump Shake and copy instead of hard link from cloud cache This is important as in hard link mode shake makes all such files read only to avoid accidentally modifying cache files via the hard link. It turns out, many Hadrian rules attempt read access to such files and hence fail in the hard link mode. These rules could be refactored to avoid write access, but using copy instead of hard link a much simpler solution. - - - - - 5af815f2 by Kevin Buhr at 2019-07-08T07:07:11-04:00 Add test for old issue w/ bad source locations for warnings in .lhs files (#515) - - - - - 6a03d77b by Ryan Scott at 2019-07-09T11:52:45-04:00 Use an empty data type in TTG extension constructors (#15247) To avoid having to `panic` any time a TTG extension constructor is consumed, this MR introduces an uninhabited 'NoExtCon' type and uses that in every extension constructor's type family instance where it is appropriate. This also introduces a 'noExtCon' function which eliminates a 'NoExtCon', much like 'Data.Void.absurd' eliminates a 'Void'. I also renamed the existing `NoExt` type to `NoExtField` to better distinguish it from `NoExtCon`. Unsurprisingly, there is a lot of code churn resulting from this. Bumps the Haddock submodule. Fixes #15247. - - - - - b05c8423 by Phuong Trinh at 2019-07-09T22:55:41-04:00 Fix #16511: changes in interface dependencies should trigger recompilation If the union of dependencies of imported modules change, the `mi_deps` field of the interface files should change as well. Because of that, we need to check for changes in this in recompilation checker which we are not doing right now. This adds a checks for that. - - - - - fb43bddc by John Ericson at 2019-07-09T22:56:18-04:00 Fix two more `#ifndef` for the linter - - - - - 0472f0f6 by John Ericson at 2019-07-09T22:56:18-04:00 Remove most uses of TARGET platform macros These prevent multi-target builds. They were gotten rid of in 3 ways: 1. In the compiler itself, replacing `#if` with runtime `if`. In these cases, we care about the target platform still, but the target platform is dynamic so we must delay the elimination to run time. 2. In the compiler itself, replacing `TARGET` with `HOST`. There was just one bit of this, in some code splitting strings representing lists of paths. These paths are used by GHC itself, and not by the compiled binary. (They are compiler lookup paths, rather than RPATHS or something that does matter to the compiled binary, and thus would legitamentally be target-sensative.) As such, the path-splitting method only depends on where GHC runs and not where code it produces runs. This should have been `HOST` all along. 3. Changing the RTS. The RTS doesn't care about the target platform, full stop. 4. `includes/stg/HaskellMachRegs.h` This file is also included in the genapply executable. This is tricky because the RTS's host platform really is that utility's target platform. so that utility really really isn't multi-target either. But at least it isn't an installed part of GHC, but just a one-off tool when building the RTS. Lying with the `HOST` to a one-off program (genapply) that isn't installed doesn't seem so bad. It's certainly better than the other way around of lying to the RTS though not to genapply. The RTS is more important, and it is installed, *and* this header is installed as part of the RTS. - - - - - 24782b89 by John Ericson at 2019-07-09T22:56:18-04:00 Deduplicate "unique subdir" code between GHC and Cabal The code, including the generated module with the version, is now in ghc-boot. Config.hs reexports stuff as needed, ghc-pkg doesn't need any tricks at all. - - - - - 42ff8653 by Ben Gamari at 2019-07-09T22:56:53-04:00 testsuite: Fix #16818 Renames performance metrics to include whether they are compile-time or runtime metrics. - - - - - 18ac9ad4 by Alp Mestanogullari at 2019-07-09T22:57:31-04:00 Hadrian: implement key-value settings for builder options They take the general form `foo.bar.baz [+]= some values`, where `=` completely overrides the arguments for a builder and `+=` extends them. We currenly only support settings for updating the GHC and C compiler options, of the form: ``` {stage0, ..., stage3 or *}.{package name or *} .ghc.{c, hs, link, deps, toolargs or *}.opts {stage0, ..., stage3 or *}.{package name or *} .cc.{c, deps or *}.opts ``` The supported settings and their use is covered in the new section of `hadrian/doc/user-settings.md`, while the implementation is explained in a new Note [Hadrian settings]. Most of the logic is implemented in a new module, `Settings.Parser`, which contains key-value assignment/extension parsers as well as utilities for specifying allowed settings at a high-level, generating a `Predicate` from such a description or generating the list of possible completions for a given string. The additions to the `Settings` module make use of this to describe the settings that Hadrian currently supports, and apply all such key-value settings (from the command line and `<root>/hadrian.settings`) to the flavour that Hadrian is going to proceed with. This new setting system comes with support for generating Bash completions, implemented in `hadrian/completion.sh` and Hadrian's `autocomplete` target: > source hadrian/completion.sh > hadrian/build.sh stage1.base.ghc.<TAB> stage1.base.ghc.c.opts stage1.base.ghc.hs.opts stage1.base.ghc.*.opts stage1.base.ghc.deps.opts stage1.base.ghc.link.opts stage1.base.ghc.toolargs.opts - - - - - 7f8bf98e by Alp Mestanogullari at 2019-07-09T22:58:09-04:00 Hadrian: fix source-dist rule The first problem was that the list of files/dirs to embed or ignore was not up-to-date. The second problem was that the 'Cwd' option used when running the Tar builder in the source-dist rule didn't actually change the current directory and was therefore failing. Finally, the source-dist rule did not pre-generate Haskell modules derived from .x (alex) and .y (happy) files, like the Make build system does -- this is now fixed. We might be doing too much work for that last step (we seem to be building many things until we get to generating the source distribution), but extracting the distribution and running ./configure && hadrian/build.sh --flavour=quickest -j from there does work for me now. - - - - - d7423f10 by Ömer Sinan Ağacan at 2019-07-09T22:58:48-04:00 Testsuite tweaks and refactoring - Rename requires_th to req_th for consistency with other req functions (e.g. req_interp, req_profiling etc.) - req_th (previously requires_th) now checks for interpreter (via req_interp). With this running TH tests are skipped when running the test suite with stage=1. - Test tweaks: - T9360a, T9360b: Use req_interp - recomp009, T13938, RAE_T32a: Use req_th - Fix check-makefiles linter: it now looks for Makefiles instead of .T files (which are actually Python files) - - - - - 897a59a5 by Ömer Sinan Ağacan at 2019-07-09T22:59:26-04:00 Minor refactoring in CoreSimpl When `join_ids` is empty `extendVarSetList existing_joins join_ids` is already no-op, so no need to check whether `join_ids` is empty or not before extending the joins set. - - - - - 85da17e5 by Eric Wolf at 2019-07-09T23:00:03-04:00 Add testcase T16804 for #16804 slightly larger testcase for :type-at and :uses so we can see changes, if #16804 is done. - - - - - 8fcc931c by Eric Wolf at 2019-07-09T23:00:03-04:00 T16804: adjust src spans - - - - - a35e0916 by Ben Gamari at 2019-07-09T23:00:42-04:00 hadrian/doc: Add some discussion of compilation stages This documents some of the lore surrounding the nature and naming of GHC's stage numbers. - - - - - d2e290d3 by Simon Peyton Jones at 2019-07-09T23:01:24-04:00 Fix erroneous float in CoreOpt The simple optimiser was making an invalid transformation to join points -- yikes. The fix is easy. I also added some documentation about the fact that GHC uses a slightly more restrictive version of join points than does the paper. Fix #16918 - - - - - cb5271ac by Kevin Buhr at 2019-07-11T17:46:19-04:00 Add regression test for old panic on inlining undeclared identifier (#495) - - - - - 01ec8549 by Andreas Klebinger at 2019-07-11T17:46:57-04:00 Special case a few common patterns in unionLists. In particular we very often pass one empty list and in these cases we want to avoid the overhead of computing `xs ++ []`. This should fix #14759 and #16911. - - - - - b507aceb by Ryan Scott at 2019-07-11T17:47:41-04:00 Don't typecheck too much (or too little) in DerivingVia (#16923) Previously, GHC would typecheck the `via` type once per class in a `deriving` clause, which caused the problems observed in #16923. This patch restructures some of the functionality in `TcDeriv` and `TcHsType` to avoid this problem. We now typecheck the `via` type exactly once per `deriving` clause and *then* typecheck all of the classes in the clause. See `Note [Don't typecheck too much in DerivingVia]` in `TcDeriv` for the full details. - - - - - 8449c5b6 by nineonine at 2019-07-11T17:48:18-04:00 Allow reusing temporary object files generated by GHCi by writing to -odir in case -fwrite-interface was specified (#16670) - - - - - d5c899d1 by Ben Gamari at 2019-07-11T17:48:54-04:00 head.hackage: Run build on head.hackage's master branch The GitLab CI infrastructure is now in the master branch. - - - - - 8a209384 by Ben Gamari at 2019-07-11T17:48:54-04:00 head.hackage: Run builds with -dcore-lint - - - - - e4c73514 by Simon Peyton Jones at 2019-07-12T02:20:01-04:00 Fix kind-checking for data/newtypes In one spot in kcConDecl we were passing in the return kind signature rether than the return kind. e.g. #16828 newtype instance Foo :: Type -> Type where MkFoo :: a -> Foo a We were giving kcConDecl the kind (Type -> Type), whereas it was expecting the ultimate return kind, namely Type. This "looking past arrows" was being done, independently, in several places, but we'd missed one. This patch moves it all to one place -- the new function kcConDecls (note the plural). I also took the opportunity to rename tcDataFamHeader to tcDataFamInstHeader (The previous name was consistently a source of confusion.) - - - - - de3935a6 by Shayne Fletcher at 2019-07-12T02:20:43-04:00 Add shake 0.18.3 to extra deps - - - - - a31b24a5 by Ashley Yakeley at 2019-07-13T16:35:41-04:00 base: Data.Fixed: make HasResolution poly-kinded (#10055, #15622) - - - - - 688a1b89 by Alp Mestanogullari at 2019-07-13T16:36:18-04:00 compiler: trace SysTools commands to emit start/stop eventlog markers This patch was motivated by some performance characterization work done for #16822, where we suspected that GHC was spending a lot of time waiting on the linker to be done. (That turned out to be true.) The tracing is taken care of by ErrUtils.withTiming, so this patch just defines and uses a little wrapper around that function in all the helpers for calling the various systools (C compiler, linker, unlit, ...). With this patch, assuming a GHC executable linked against an eventlog-capable RTS (RTS ways that contain the debug, profiling or eventlog way units), we can measure how much time is spent in each of the SysTools when building hello.hs by simply doing: ghc hello.hs -ddump-timings +RTS -l The event names are "systool:{cc, linker, as, unlit, ...}". - - - - - 348cc8eb by Andreas Klebinger at 2019-07-13T16:36:57-04:00 Add two CmmSwitch optimizations. Move switch expressions into a local variable when generating switches. This avoids duplicating the expression if we translate the switch to a tree search. This fixes #16933. Further we now check if all branches of a switch have the same destination, replacing the switch with a direct branch if that is the case. Both of these patterns appear in the ENTER macro used by the RTS but are unlikely to occur in intermediate Cmm generated by GHC. Nofib result summary: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- Min -0.0% -0.0% -15.7% -15.6% 0.0% Max -0.0% 0.0% +5.4% +5.5% 0.0% Geometric Mean -0.0% -0.0% -1.0% -1.0% -0.0% Compiler allocations go up slightly: +0.2% Example output before and after the change taken from RTS code below. All but one of the memory loads `I32[_c3::I64 - 8]` are eliminated. Instead the data is loaded once from memory in block c6. Also the switch in block `ud` in the original code has been eliminated completely. Cmm without this commit: ``` stg_ap_0_fast() { // [R1] { [] } {offset ca: _c1::P64 = R1; // CmmAssign goto c2; // CmmBranch c2: if (_c1::P64 & 7 != 0) goto c4; else goto c6; c6: _c3::I64 = I64[_c1::P64]; if (I32[_c3::I64 - 8] < 26 :: W32) goto ub; else goto ug; ub: if (I32[_c3::I64 - 8] < 15 :: W32) goto uc; else goto ue; uc: if (I32[_c3::I64 - 8] < 8 :: W32) goto c7; else goto ud; ud: switch [8 .. 14] (%MO_SS_Conv_W32_W64(I32[_c3::I64 - 8])) { case 8, 9, 10, 11, 12, 13, 14 : goto c4; } ue: if (I32[_c3::I64 - 8] >= 25 :: W32) goto c4; else goto uf; uf: if (%MO_SS_Conv_W32_W64(I32[_c3::I64 - 8]) != 23) goto c7; else goto c4; c4: R1 = _c1::P64; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; ug: if (I32[_c3::I64 - 8] < 28 :: W32) goto uh; else goto ui; uh: if (I32[_c3::I64 - 8] < 27 :: W32) goto c7; else goto c8; ui: if (I32[_c3::I64 - 8] < 29 :: W32) goto c8; else goto c7; c8: _c1::P64 = P64[_c1::P64 + 8]; goto c2; c7: R1 = _c1::P64; call (_c3::I64)(R1) args: 8, res: 0, upd: 8; } } ``` Cmm with this commit: ``` stg_ap_0_fast() { // [R1] { [] } {offset ca: _c1::P64 = R1; goto c2; c2: if (_c1::P64 & 7 != 0) goto c4; else goto c6; c6: _c3::I64 = I64[_c1::P64]; _ub::I64 = %MO_SS_Conv_W32_W64(I32[_c3::I64 - 8]); if (_ub::I64 < 26) goto uc; else goto uh; uc: if (_ub::I64 < 15) goto ud; else goto uf; ud: if (_ub::I64 < 8) goto c7; else goto c4; uf: if (_ub::I64 >= 25) goto c4; else goto ug; ug: if (_ub::I64 != 23) goto c7; else goto c4; c4: R1 = _c1::P64; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; uh: if (_ub::I64 < 28) goto ui; else goto uj; ui: if (_ub::I64 < 27) goto c7; else goto c8; uj: if (_ub::I64 < 29) goto c8; else goto c7; c8: _c1::P64 = P64[_c1::P64 + 8]; goto c2; c7: R1 = _c1::P64; call (_c3::I64)(R1) args: 8, res: 0, upd: 8; } } ``` - - - - - 232002c4 by James Foster at 2019-07-13T16:37:34-04:00 Make HsInstances and DynFlags compile with -O0 for Stage0 to speed up Hadrian builds (fixes #16936) - - - - - a7176fa1 by Ömer Sinan Ağacan at 2019-07-13T16:38:13-04:00 Minor refactoring in CmmBuildInfoTables - Replace `catMaybes (map ...)` with `mapMaybe ...` - Remove a list->set->list conversion - - - - - ff04eb59 by John Ericson at 2019-07-14T01:19:22-04:00 Remove purely external primops The compiler doesn't create uses nor compiles the uses that exist specially. These are just plain C-- FFI. These `await*` ones are especially important to so convert because "true" primops are hard to make platform-specific currently. The other exports are part of this commit so this module always exports something, which avoids silly CPP elsewhere. More will be added later once `foreign import prim` is extended. - - - - - f9b00038 by Matthew Pickering at 2019-07-14T01:19:58-04:00 hadrian: Build debug rts with -O0 -g3 and disable rts stripping Fixes #16920 - - - - - f508b7ce by Ben Gamari at 2019-07-14T01:20:34-04:00 Don't package settings in bindist Since !712 the `settings` file is produced by the build system instead of autoconf. However, this introduced a subtle bug where we would fail to rebuild the `settings` file with what we have learned from the install-time `configure` invocation. Fix this by not packaging `settings` in the bindist tarball. The build system will take care of the rest. Also fix a bug where the value of `UseLibdw` was not being persisted to the install time `configure`. - - - - - e7ed53c9 by John Ericson at 2019-07-14T01:21:11-04:00 Remove LLVM_TARGET platform macros Instead following @angerman's suggestion put them in the config file. Maybe we could re-key llvm-targets someday, but this is good for now. - - - - - bd9fc1b2 by John Ericson at 2019-07-14T01:21:48-04:00 Make CPP linter skip certain files - docs which document the lint and need to contain the unutterable - vendored code which is outside our purview - - - - - d7c6c471 by John Ericson at 2019-07-14T01:21:48-04:00 Expunge #ifdef and #ifndef from the codebase These are unexploded minds as far as the linter is concerned. I don't want to hit in my MRs by mistake! I did this with `sed`, and then rolled back some changes in the docs, config.guess, and the linter itself. - - - - - fce8f240 by xplorld at 2019-07-14T08:32:48-04:00 rename type parameter in `instance Applicative ((->) a)`, fixing #16928 - - - - - 78ed46f3 by Niklas Hambüchen at 2019-07-14T08:33:26-04:00 primops: haddock: Fix typo in referenced function. Found by @lehins. - - - - - a39a3cd6 by Ben Gamari at 2019-07-15T00:14:40-04:00 gitlab-ci: Disable submodule linter for now - - - - - 0670f98a by Arnaud Spiwack at 2019-07-15T09:23:15+02:00 Add a note in the simplifier about in-scope set as a substitution See also the discussion at #16592 - - - - - 284a2f44 by Vladislav Zavialov at 2019-07-15T18:29:05-04:00 Decouple AddAnn from P - - - - - 1befd2c0 by Vladislav Zavialov at 2019-07-15T18:29:05-04:00 PV is not P (#16611) - - - - - 5728d9fa by Artem Pelenitsyn at 2019-07-16T02:40:08-04:00 Sort out Hadrian colored output flags (fix #16397) Hadrian used to have a separate flag --progress-colour to control colored output during the build. After introduction of a Shake flag with similar purpose Hadrian's flag became redundant. The commit removes --progress-colour and switches to Shake's flag. The only difference between the two is that Hadrian has special default mode when it tries to determine if the terminal support colored output. The user can override it using (Shake's) `--[no-]color`. - - - - - db948dae by Ben Gamari at 2019-07-16T02:40:43-04:00 Revert "Add support for SIMD operations in the NCG" Unfortunately this will require more work; register allocation is quite broken. This reverts commit acd795583625401c5554f8e04ec7efca18814011. - - - - - 373c9cb3 by Daniel Gröber at 2019-07-16T02:41:23-04:00 rts: Divorce init of Heap profiler from CCS profiler Currently initProfiling gets defined by Profiling.c only if PROFILING is defined. Otherwise the ProfHeap.c defines it. This is just needlessly complicated so in this commit I make Profiling and ProfHeap into properly seperate modules and call their respective init functions from RtsStartup.c. - - - - - 52f755aa by Daniel Gröber at 2019-07-16T02:41:23-04:00 rts: Rename the nondescript initProfiling2 to refreshProfilingCCSs - - - - - 0a9b77b8 by John Ericson at 2019-07-17T12:20:26-04:00 Create {Int,Word}32Rep This prepares the way for making Int32# and Word32# the actual size they claim to be. Updates binary submodule for (de)serializing the new runtime reps. - - - - - 8add024f by Sebastian Graf at 2019-07-17T12:20:27-04:00 Make GHC-in-GHCi work on Windows By not building anything in the dynamic way on Windows, where we don't have a working story for DLLs yet. Also the ghcid command needs to call bash on the hadrian/ghci.sh script explicitly as the path gets interpreted differently otherwise. - - - - - d48da6ff by Ben Gamari at 2019-07-18T20:55:11-04:00 gitlab-ci: Run slow validate in -debug job Otherwise we don't compile the stage2 compiler with DEBUG, meaning the testsuite isn't checked with assertions. Metric Increase: haddock.Cabal - - - - - 272246bf by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: More type checking fixes - - - - - c7bcd017 by Ben Gamari at 2019-07-18T20:55:11-04:00 Add HasDebugCallStack to unionLists This should help identify a few cases where this is throwing warnings - - - - - 3cec2af6 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Mark static-plugins as broken in profiled ways See #16803. - - - - - e8adffb5 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Set -dinitial-unique when reversing uniques Otherwise the unique counter starts at 0, causing us to immediately underflow. - - - - - b9e9d8c9 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Fix req_th - - - - - d238d306 by Ben Gamari at 2019-07-18T20:55:11-04:00 Fix formatting of --info's "Debug on" field As noted in #16914, the value `True` was used instead of `YES` here, in contrast to the other boolean fields emitted by `--info`. This confused the testsuite driver and broke the `ghc_debugged` testsuite predicate. - - - - - eb8c40e3 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Mark hWaitForInput-accurate-stdin as broken in all threaded ways Previously it was not marked as broken in profthreaded - - - - - b16cabc1 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Print output from hp2ps - - - - - b62a2dfb by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Fix some ints used as bools - - - - - b3df1efb by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Skip forking tests in profiled ways As noted in #11645 and #8862, forking and profiling don't go well together. Bumps hpc and unix submodules. - - - - - 49dcbf86 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Mark test-hole-plugin as req_th This requires code loading and therefore can't be run in the profiled ways when GHC is dynamically linked. - - - - - ce8ffd80 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Unmark recomp007 as broken Fixed in #14759. - - - - - 82abc479 by Ben Gamari at 2019-07-18T20:55:11-04:00 testsuite: Mark T4808 as broken in threaded2 way As noted in #16909. - - - - - 73703d9b by Artem Pelenitsyn at 2019-07-19T18:06:22-04:00 Hide "Loading package environment" message with -v0 (fix #16879) - - - - - 9372ff92 by Vladislav Zavialov at 2019-07-19T18:06:57-04:00 Drop the orphan roles check (#16941) 9366e019 introduced a check for orphan roles to fix #8485 6ab5da99 changed the lookup code and made the check redundant. Now it is removed. - - - - - 69adb253 by Richard Eisenberg at 2019-07-19T18:07:37-04:00 Fix #16870 by improving documentation (only) - - - - - f1980a1e by Sebastian Graf at 2019-07-19T18:08:15-04:00 Make generated ghc-stage<n> scripts executable - - - - - bec17997 by James Foster at 2019-07-19T18:08:51-04:00 users-guide: corrected -fmax-relevant-binds reverse to be -fno-max-relevant-binds - - - - - 257d1fd8 by Ryan Scott at 2019-07-19T18:09:28-04:00 Don't maintainer-clean libraries/ghc-boot/ghc.mk (#16953) This makes the `maintainer-clean` rule in `ghc.mk` slightly more sophisticated so that it does not remove the version-controlled file `libraries/ghc-boot/ghc.mk`, which was checked into version control in commit 24782b89907ab36fb5aef3a17584f4c10f1e2690. Fixes #16953. - - - - - ff996555 by Richard Eisenberg at 2019-07-19T18:10:06-04:00 Add module doc for Plugins. This was requested in #15650. - - - - - 08ad7ef4 by Baldur Blöndal at 2019-07-20T07:51:22-04:00 Added do-notation examples for Functor, Applicative and Monad combinators. - - - - - 7b42ece5 by Alfredo Di Napoli at 2019-07-20T07:52:01-04:00 Line wrap when pp long expressions (fixes #16874) This commit fixes #16874 by using `fsep` rather than `sep` when pretty printing long patterns and expressions. - - - - - 3676375f by Andreas Klebinger at 2019-07-20T07:52:39-04:00 Bump nofib submodule. - - - - - 4dfd6a5f by Matthew Pickering at 2019-07-20T07:53:15-04:00 hadrian: Remove RTS -Waggregate-return warning This was removed from make in 077b92fa39839a8e83cd87398435424403cf6486 - - - - - 5042ba9d by Andreas Klebinger at 2019-07-21T05:03:04-04:00 Expose the GhcPrelude module. This makes it simpler to load Modules importing it when using ghc-the-package. ------------------------- Metric Decrease: haddock.compiler ------------------------- - - - - - 67ee741b by Ivan Kasatenko at 2019-07-21T05:03:40-04:00 Do not ignore events deletion when events to be added are provided (#16916) Kqueue/kevent implementation used to ignore events to be unsubscribed from when events to be subscribed to were provided. This resulted in a lost notification subscription, when GHC runtime didn't listen for any events, yet the kernel considered otherwise and kept waking up the IO manager thread. This commit fixes this issue by always adding and removing all of the provided subscriptions. - - - - - 32be4461 by Roland Senn at 2019-07-21T05:04:17-04:00 Fix #8487: Debugger confuses variables To display the free variables for a single breakpoint, GHCi pulls out the information from the fields `modBreaks_breakInfo` and `modBreaks_vars` of the `ModBreaks` data structure. For a specific breakpoint this gives 2 lists of types 'Id` (`Var`) and `OccName`. They are used to create the Id's for the free variables and must be kept in sync: If we remove an element from the Names list, then we also must remove the corresponding element from the OccNames list. - - - - - 4854a349 by Ben Gamari at 2019-07-21T05:04:53-04:00 ghc-cabal: Use fromFlagOrDefault instead of fromFlag As fromFlag is partial. The only case where we used fromFlag is when determining whether to strip libraries; we now assume that we shouldn't. - - - - - 4c7a8462 by Xavier Denis at 2019-07-23T11:43:59-04:00 Make sure to load interfaces when running :instances - - - - - f9af30f8 by Ömer Sinan Ağacan at 2019-07-23T11:44:38-04:00 Remove fix-submodules.py Now that we have absolute paths for submodules (since a76b233d) we no longer need this script. - - - - - 6ade71fb by Alp Mestanogullari at 2019-07-23T23:06:36-04:00 Hadrian: run the testsuite in Windows CI job Since MR !1025 fixed the Windows build, allowing us to build a binary distribution, we can now run the testsuite in that CI job. This required fixing 'createFileLink': it should not try to create symlinks on Windows (that requires admin priviledges, which Hadrian can't assume). We now instead fall back to copying. This patch also removes some duplicated logic for iserv in the test rules, where we handle our dependency on the iserv binaries in a special way. - - - - - 3dbcc368 by Richard Eisenberg at 2019-07-23T23:07:13-04:00 Simon and I like to work in hsSyn, too. - - - - - b95b6380 by John Ericson at 2019-07-24T16:49:53-04:00 Make stage 1 GHC target independent Now that the target macros are not being used, we remove them. This prevents target hardcoding regressions. - - - - - d0f8ed20 by Ben Gamari at 2019-07-24T16:50:28-04:00 gitlab-ci: Fix source tarball job * Use show! in source tarball job. Since we aren't actually building anything in this job `show` won't work. * Fix Docker image name * Make `version` file contain only version string - - - - - 90dd2ea0 by Vladislav Zavialov at 2019-07-24T23:11:22-04:00 ASSERT(vis_flag==ForallInvis) in hsScopedTvs - - - - - e07f0e2b by Vladislav Zavialov at 2019-07-24T23:11:57-04:00 Drop unused helpers 'mkTyClGroup' and 'emptyTyClGroup' - - - - - cb495b3c by Ryan Scott at 2019-07-25T17:25:26-04:00 Make DefUses = OrdList DefUse Before, `type DefUses = [DefUse]`. But lists are a terrible choice of data structure here, as we frequently append to the right of a `DefUses`, which yields some displeasing asymptotics. Let's instead use `OrdList`, which has constant-time appending to the right. This is one step on the way to #10347. - - - - - b9c99df1 by Ömer Sinan Ağacan at 2019-07-25T17:26:03-04:00 Printer: add an empty line between bindings in Rec STG binding groups Before: Rec { x2_r10T :: Lib.Bar [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Bar! [x3_r10U]; x3_r10U :: Lib.Foo [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Foo! [x1_r10p x2_r10T]; end Rec } After: Rec { x2_r10T :: Lib.Bar [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Bar! [x3_r10U]; x3_r10U :: Lib.Foo [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Foo! [x1_r10p x2_r10T]; end Rec } - - - - - 30b6f391 by Ryan Scott at 2019-07-26T00:57:02-04:00 Banish reportFloatingViaTvs to the shadow realm (#15831, #16181) GHC used to reject programs of this form: ``` newtype Age = MkAge Int deriving Eq via Const Int a ``` That's because an earlier implementation of `DerivingVia` would generate the following instance: ``` instance Eq Age where (==) = coerce @(Const Int a -> Const Int a -> Bool) @(Age -> Age -> Bool) (==) ``` Note that the `a` in `Const Int a` is not bound anywhere, which causes all sorts of issues. I figured that no one would ever want to write code like this anyway, so I simply banned "floating" `via` type variables like `a`, checking for their presence in the aptly named `reportFloatingViaTvs` function. `reportFloatingViaTvs` ended up being implemented in a subtly incorrect way, as #15831 demonstrates. Following counsel with the sage of gold fire, I decided to abandon `reportFloatingViaTvs` entirely and opt for a different approach that would _accept_ the instance above. This is because GHC now generates this instance instead: ``` instance forall a. Eq Age where (==) = coerce @(Const Int a -> Const Int a -> Bool) @(Age -> Age -> Bool) (==) ``` Notice that we now explicitly quantify the `a` in `instance forall a. Eq Age`, so everything is peachy scoping-wise. See `Note [Floating `via` type variables]` in `TcDeriv` for the full scoop. A pleasant benefit of this refactoring is that it made it much easier to catch the problem observed in #16181, so this patch fixes that issue too. Fixes #15831. Fixes #16181. - - - - - aae0457f by nineonine at 2019-07-26T00:57:39-04:00 Change behaviour of -ddump-cmm-verbose to dump each Cmm pass output to a separate file and add -ddump-cmm-verbose-by-proc to keep old behaviour (#16930) - - - - - 00d9d284 by Vladislav Zavialov at 2019-07-26T00:58:15-04:00 TemplateHaskell: reifyType (#16976) - - - - - ea08fa37 by Vladislav Zavialov at 2019-07-26T00:58:15-04:00 reifyTypeOfThing: panic on impossible cases - - - - - 7c9fb2f0 by Adam Sandberg Eriksson at 2019-07-26T09:49:14-04:00 ghc-heap: implement WEAK closure type #16974 - - - - - 26314386 by nineonine at 2019-07-26T09:49:51-04:00 Add regression test for #16946 - - - - - cd11f81f by Fumiaki Kinoshita at 2019-07-28T19:47:50-04:00 base: add Functor, Applicative, Monad, Alternative, MonadPlus, Generic and Generic1 instances to Kleisli - - - - - c1a06d49 by Dale Wijnand at 2019-07-28T19:48:27-04:00 hadrian: relink to the flavours doc in the ghc repo - - - - - 9f8cdb35 by Richard Eisenberg at 2019-07-29T19:32:16-04:00 Add Note [RuntimeRep and PrimRep] in RepType Also adds Note [Getting from RuntimeRep to PrimRep], which deocuments a related thorny process. This Note addresses #16964, which correctly observes that documentation for this thorny design is lacking. Documentation only. - - - - - 86f47b8e by Dale Wijnand at 2019-07-29T19:32:52-04:00 hadrian: Drop a stale limitation tracking issue https://github.com/snowleopard/hadrian/issues/187 was superseded by https://github.com/snowleopard/hadrian/issues/669, which has also been closed. So, optimistically, dropping this as a limitation issue. - - - - - 9c8a211a by Andreas Klebinger at 2019-07-30T01:33:50-04:00 Expand the preallocated Int range to [-16,255] Effects as I measured them: RTS Size: +0.1% Compile times: -0.5% Runtine nofib: -1.1% Nofib runtime result seems to mostly come from the `CS` benchmark which is very sensible to alignment changes so this is likely over represented. However the compile time changes are realistic. This is related to #16961. - - - - - 2829f6da by Simon Peyton Jones at 2019-07-30T01:34:27-04:00 Apply a missing substitution in mkEtaWW (#16979) The `mkEtaWW` case for newtypes forgot to apply the substitution to the newtype coercion, resulting in the Core Lint errors observed in #16979. Easily fixed. Fixes #16979. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - 371dadfb by Ben Gamari at 2019-07-31T04:27:59-04:00 Break up TyCoRep This breaks up the monstrous TyCoReps module into several new modules by topic: * TyCoRep: Contains the `Coercion`, `Type`, and related type definitions and a few simple predicates but nothing further * TyCoPpr: Contains the the pretty-printer logic * TyCoFVs: Contains the free variable computations (and `tyConAppNeedsKindSig`, although I suspect this should change) * TyCoSubst: Contains the substitution logic for types and coercions * TyCoTidy: Contains the tidying logic for types While we are able to eliminate a good number of `SOURCE` imports (and make a few others smaller) with this change, we must introduce one new `hs-boot` file for `TyCoPpr` so that `TyCoRep` can define `Outputable` instances for the types it defines. Metric Increase: haddock.Cabal haddock.compiler - - - - - b6fa7fe3 by Ben Gamari at 2019-07-31T04:27:59-04:00 gitignore: Add .mypy_cache - - - - - 88410e77 by Ben Gamari at 2019-07-31T04:27:59-04:00 Move tyConAppNeedsKindSig to Type Previously it was awkwardly in TyCoFVs (and before that in TyCoRep). Type seems like a sensible place for it to live. - - - - - 787fab43 by Ben Gamari at 2019-07-31T04:27:59-04:00 Work around redundant import issue As mentioned in #16997, GHC currently complains about this import. In general I'm reluctant to paper over things like this but in the case of an hs-boot file I think adding an import list is the right thing to do regardless of the bug. - - - - - 5e04841c by Ben Gamari at 2019-07-31T13:53:58-04:00 gitlab-ci: Fix it after upgrade It seems that the regular expression parser changed in GitLab 12.1 and now does now support forward slashes in the RE, even when escaped. - - - - - 986643cb by Ivan Kasatenko at 2019-08-01T13:49:50-04:00 Fix T16916 CI failures (#16966) 1. Slightly increased the waiting time for the tested effect to be more profound. 2. Introduced measuring of the actual time spent waiting and adjusing CPU time by it to compensate for threadDelay waiting time inconsistencies. - - - - - 95521140 by Andreas Klebinger at 2019-08-02T08:14:10-04:00 Add StandaloneDeriving example for DerivingVia. [skip-ci] - - - - - 1b9d32b8 by Ryan Scott at 2019-08-02T08:14:47-04:00 Rip out 9-year-old pattern variable hack (#17007) GHC had an ad hoc validity check in place to rule out pattern variables bound by type synonyms, such as in the following example: ```hs type ItemColID a b = Int -- Discards a,b get :: ItemColID a b -> ItemColID a b get (x :: ItemColID a b) = x :: ItemColID a b ``` This hack is wholly unnecessary nowadays, since OutsideIn(X) is more than capable of instantiating `a` and `b` to `Any`. In light of this, let's rip out this validity check. Fixes #17007. - - - - - 93bed40a by Ryan Scott at 2019-08-02T08:15:25-04:00 Use injectiveVarsOfType to catch dodgy type family instance binders (#17008) Previously, we detected dodgy type family instances binders by expanding type synonyms (via `exactTyCoVarsOfType`) and looking for type variables on the RHS that weren't mentioned on the (expanded) LHS. But this doesn't account for type families (like the example in #17008), so we instead use `injectiveVarsOfType` to only count LHS type variables that are in injective positions. That way, the `a` in `type instance F (x :: T a) = a` will not count if `T` is a type synonym _or_ a type family. Along the way, I moved `exactTyCoVarsOfType` to `TyCoFVs` to live alongside its sibling functions that also compute free variables. Fixes #17008. - - - - - c902f56b by Krzysztof Gogolewski at 2019-08-02T08:16:03-04:00 Remove build.nix.sh This file refers to shell.nix, which was removed in 430e6fedfda and c00d2f59d. - - - - - 5e960287 by Adam Sandberg Eriksson at 2019-08-02T08:16:45-04:00 docs: fixs -prof links in rts-flags section - - - - - 0c5cd771 by Alp Mestanogullari at 2019-08-02T22:20:14-04:00 compiler: emit finer grained codegen events to eventlog - - - - - 0ecacb1e by Alp Mestanogullari at 2019-08-02T22:20:14-04:00 Add Note [withTiming] in compiler/main/ErrUtils.hs - - - - - 4664bafc by Ben Gamari at 2019-08-02T22:20:50-04:00 rts: Always truncate output files Previously there were numerous places in the RTS where we would fopen with the "w" flag string. This is wrong as it will not truncate the file. Consequently if we write less data than the previous length of the file we will leave garbage at its end. Fixes #16993. - - - - - e3cbe319 by Ben Gamari at 2019-08-02T22:21:26-04:00 Packages: Add timing for package database initialization - - - - - a5227080 by Alp Mestanogullari at 2019-08-02T22:22:06-04:00 Hadrian: make settings, platformConstants, etc dependencies of lib:ghc This fixes #17003, where a user directly asked for the 'docs-haddock' target without building a complete stage 2 GHC first. Since haddock only depends on lib:ghc, the stage 2 GHC executable wasn't built, and neither were the settings, platformConstants, llvm-passes and llvm-targets files, since they are declared to be dependencies of exe:ghc. This makes sense in general since all GHC API users (haddock is one) will likely want those files to be there. - - - - - 7e404afd by Ben Gamari at 2019-08-04T18:16:51-04:00 gitlab-ci: Manually set SPHINXBUILD on Windows For some reason configure seems unable to find it on its own. Let's try giving it a hint. Addresses #16398. - - - - - 8a061d18 by Matthew Pickering at 2019-08-04T18:17:28-04:00 Update .gitignore Add some files generated by hadrian and some tooling files - - - - - 7d8d0012 by Simon Peyton Jones at 2019-08-04T18:18:08-04:00 Don't float unlifted join points to top level Ticket #16978 showed that we were floating a recursive, unlifted join point to top level. It's very much a corner case: joinrec j :: Int# j = jump j in ... But somehow it showed up in a real program. For non-recursive bindings in SetLevels.lvlBind we were already (correctly) checking for unlifted bindings, but when I wrote that code I didn't think that a /recursive/ binding could be unlifted but /join-points/ can be! Actually I don't think that SetLevels should be floating join points at all. SetLevels really floats things to move stuff out of loops and save allocation; but none of that applies to join points. The only reason to float join points is in cases like join j1 x = join j2 y = ... in ... which we might want to swizzle to join j2 x y = ... in join j1 x = ... in ... because now j1 looks small and might be inlined away altogether. But this is a very local float perhaps better done in the simplifier. Still: this patch fixes the crash, and does so in a way that is harmless if/when we change our strategy for floating join points. - - - - - 3b31a94d by Ben Gamari at 2019-08-04T18:18:08-04:00 testsuite: Add testsuite for #16978 - - - - - 2e031806 by Ben Gamari at 2019-08-04T18:18:45-04:00 configure: Search for LLVM executables with two-number versions Fedora uses the naming llc-7.0 while Debian uses llc-7. Ensure that both are found. Fixes #16990. - - - - - 6e5dfcd2 by Ben Gamari at 2019-08-04T18:19:21-04:00 testsuite: Rework tracking of fragile tests Breaks fragile tests into two groups, allowing us to easily preserve stdout/stderr of failing fragile tests. - - - - - ea16f6cb by Simon Peyton Jones at 2019-08-06T20:24:41-04:00 Remove dead parameter from coreToStgApp - - - - - 0c1ccf3c by James Foster at 2019-08-06T20:25:18-04:00 hadrian: Refactor file patterns for future Shake changes (fixes #17005) Shake will be moving from its current implementation of ?== to one from System.FilePattern. Support for `//` is being dropped, leaving only `*` and `**` as special forms. This commit converts the existing file patterns in Hadrian to the new format. It also removes all occurances of <//> and changes the user-settings docs to remove references to // and add **. The conversion is as follows: - //a ==> **/a - a// ==> a/** - a//b ==> a/**/b - - - - - c83e39bf by Matthew Pickering at 2019-08-06T20:25:54-04:00 Remove old/broken(?) .ghci script I was attempting to load hadrian into ghci by using `cabal new-repl exe:hadrian` but it failed because it tried to use this `.ghci` configuration. I'm not sure who used this script but you should really use the new-repl method. - - - - - 6f116005 by Ömer Sinan Ağacan at 2019-08-06T20:26:32-04:00 Introduce a type for "platform word size", use it instead of Int We introduce a PlatformWordSize type and use it in platformWordSize field. This removes to panic/error calls called when platform word size is not 32 or 64. We now check for this when reading the platform config. - - - - - 2073745c by mniip at 2019-08-07T10:18:07-04:00 Add a -fprint-axiom-incomps option (#15546) Supply branch incomps when building an IfaceClosedSynFamilyTyCon `pprTyThing` now has access to incomps. This also causes them to be written out to .hi files, but that doesn't pose an issue other than a more faithful bijection between `tyThingToIfaceDecl` and `tcIfaceDecl`. The machinery for displaying axiom incomps was already present but not in use. Since this is now a thing that pops up in ghci's :info the format was modified to look like a haskell comment. Documentation and a test for the new feature included. Test Plan: T15546 Reviewers: simonpj, bgamari, goldfire Reviewed By: simonpj Subscribers: rwbarton, carter GHC Trac Issues: #15546 Differential Revision: https://phabricator.haskell.org/D5097 - - - - - bca79345 by mniip at 2019-08-07T10:18:07-04:00 Fix test - - - - - 3d32286d by mniip at 2019-08-07T10:18:07-04:00 Explicitly number equations when printing axiom incompatibilities - - - - - ca8efc49 by mniip at 2019-08-07T10:18:07-04:00 Fix documentation - - - - - 2c1b1ad7 by mniip at 2019-08-07T10:18:07-04:00 Fix test - - - - - 8e2fe575 by Zubin Duggal at 2019-08-07T10:18:44-04:00 Fix bug preventing information about patterns from being serialized in .hie files - - - - - f1d0e49f by Ben Gamari at 2019-08-07T10:19:21-04:00 testsuite: Add tests for #16943 - - - - - 83ca42de by Ben Gamari at 2019-08-07T10:19:21-04:00 Revert "Make scanr a good producer and consumer" This reverts commit 4e1dfc3767167dddd0e151a2df8305b12aa0f49c. Due to #16943. - - - - - 81860281 by Joachim Breitner at 2019-08-10T14:39:27-04:00 Consolidate `TablesNextToCode` and `GhcUnreigsterised` in configure (#15548) `TablesNextToCode` is now a substituted by configure, where it has the correct defaults and error handling. Nowhere else needs to duplicate that, though we may want the compiler to to guard against bogus settings files. I renamed it from `GhcEnableTablesNextToCode` to `TablesNextToCode` to: - Help me guard against any unfixed usages - Remove any lingering connotation that this flag needs to be combined with `GhcUnreigsterised`. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082 - - - - - 422ffce0 by Ben Gamari at 2019-08-10T14:40:03-04:00 Add timing on loadInterface AndreasK recently mentioned that he thought that interface file loading may be a non-trivial cost. Let's measure. - - - - - 0424de2d by Ömer Sinan Ağacan at 2019-08-10T14:40:46-04:00 Add test for #16893 - - - - - 672cbab2 by Ömer Sinan Ağacan at 2019-08-10T14:41:26-04:00 Reformat comments in StgSyn This does not make any changes in the contents -- formatting only. Previously the comments were too noisy and I've always found it very hard to read. Hopefully it's easier to read now. - - - - - 328a0efa by Sebastian Graf at 2019-08-13T17:30:15-04:00 Add Foldable, Traversable instances for Uniq(D)FM The `UniqDFM` is deterministic, of course, while we provide an unsafe `NonDetUniqFM` wrapper for `UniqFM` to opt into nondeterministic instances. - - - - - b1d29c67 by Tamar Christina at 2019-08-13T17:30:50-04:00 Fix binary distribution - - - - - a38104b4 by Andreas Klebinger at 2019-08-14T16:55:42-04:00 Rework the Binary Integer instance. We used to serialise large integers as strings. Now they are serialized as a list of Bytes. This changes the size for a Integer in the higher 64bit range from 77 to 9 bytes when written to disk. The impact on the general case is small (<1% for interface files) as we don't use many Integers. But for code that uses many this should be a nice benefit. - - - - - aa4d8b07 by Andreas Klebinger at 2019-08-14T16:56:20-04:00 Use os.devnull instead of '/dev/null' in the testsuite driver. The later caused issues on windows by being translated into "\\dev\\null" and python then trying to open this non-existant file. So we now use os.devnull inside python and convert it to "/dev/null" when calling out to the shell, which is bound to run in a unix like environment. This fixes an issue a test producing unexpected stderr output failed with a framework failure instead of showing a diff of the output. - - - - - 6329c70a by Richard Eisenberg at 2019-08-14T17:47:25-04:00 GHCi supports not-necessarily-lifted join points Fixes #16509. See Note [Not-necessarily-lifted join points] in ByteCodeGen, which tells the full story. This commit also adds some comments and cleans some code in the byte-code generator, as I was exploring around trying to understand it. (This commit removes an old test -- this is really a GHCi problem, not a pattern-synonym problem.) test case: ghci/scripts/T16509 - - - - - ca71d551 by James Foster at 2019-08-15T12:01:43-04:00 Remove unused imports of the form 'import foo ()' (Fixes #17065) These kinds of imports are necessary in some cases such as importing instances of typeclasses or intentionally creating dependencies in the build system, but '-Wunused-imports' can't detect when they are no longer needed. This commit removes the unused ones currently in the code base (not including test files or submodules), with the hope that doing so may increase parallelism in the build system by removing unnecessary dependencies. - - - - - 95837c0f by Tobias Dammers at 2019-08-15T22:13:13-04:00 Add test cases for #16615 - - - - - 8d076841 by Tobias Dammers at 2019-08-15T22:13:13-04:00 Make add_info attach unfoldings (#16615) - - - - - 14208853 by Sylvain Henry at 2019-08-15T22:13:52-04:00 Cmm: constant folding `quotRem x 2^N` `quot` and `rem` are implemented efficiently when the second argument is a constant power of 2. This patch uses the same implementations for `quotRem` primop. - - - - - 47e16237 by Ömer Sinan Ağacan at 2019-08-15T22:14:31-04:00 Document types of LitNumbers, minor refactoring in Literal.hs - - - - - ac73c1b1 by Sylvain Henry at 2019-08-18T05:16:40-04:00 Faster exactLog2 Make `exactLog2` faster (use `countLeadingZeros` and Int32 bit-ops). On my Core i7-9700k Criterion reports ~50% speedup (from 16 to 8ns). - - - - - 1230d6f9 by Ömer Sinan Ağacan at 2019-08-18T05:17:20-04:00 Typo fix in CoreToStg - - - - - d0716279 by Ryan Scott at 2019-08-18T05:18:01-04:00 Fix #17067 by making data family type constructors actually injective `TcTyClsDecls.tcFamDecl1` was using `NotInjective` when creating data family type constructors, which is just plain wrong. This tweaks it to use `Injective` instead. Fixes #17067. - - - - - 993804bf by Sam Halliday at 2019-08-18T16:39:21-04:00 expose ModuleInfo.minf_rdr_env for tooling authors - - - - - 5b713aa3 by Ömer Sinan Ağacan at 2019-08-18T16:40:03-04:00 Fix COMPACT_NFDATA closure size, more CNF sanity checking We now do a shallow closure check on objects in compact regions. See the new comment on why we can't do a "normal" closure check. - - - - - ac7c738b by Richard Lupton at 2019-08-19T02:11:59-04:00 Generalized MonadUtils folds to Foldable (#16969) - - - - - 3a1efe1a by Richard Lupton at 2019-08-19T02:12:00-04:00 Re-export foldlM and foldrM from Data.Foldable in MonadUtils (#16969) - - - - - 2a394246 by Richard Lupton at 2019-08-19T02:12:00-04:00 Use Foldable instance of Bag for specialised Bag folds (#16969) - - - - - ac79dfe9 by Richard Lupton at 2019-08-19T02:12:00-04:00 Remove Bag fold specialisations (#16969) - - - - - 5e40356f by Ben Gamari at 2019-08-19T02:12:36-04:00 gitlab-ci: Update bootstrap compiled used for Darwin builds - - - - - d5055248 by Ben Gamari at 2019-08-22T09:25:08-04:00 gitlab-ci: Add Windows full build during the nightly pipeline - - - - - a33bad2d by Sylvain Henry at 2019-08-22T09:25:47-04:00 Doc: add Haddocks for quotRemWord2 primop - - - - - 605bce26 by James Foster at 2019-08-22T18:47:20-04:00 Add documentation for Hadrian expressions This commit adds documentation on Hadrian's 'Expr' type and references the documentation in hadrian/README.md - - - - - 8f32d2bc by TDecki at 2019-08-22T18:47:57-04:00 base: Reintroduce fusion for scanr While avoiding #16943. - - - - - c3e26ab3 by Ömer Sinan Ağacan at 2019-08-22T22:19:26-04:00 Remove special case in SRT generation with -split-sections Previously we were using an empty ModuleSRTInfo for each Cmm group with -split-section. As far as I can see this has no benefits, and simplifying this makes another patch simpler (!1304). We also remove some outdated comments: we no longer generate one module-level SRT. - - - - - a8300520 by Ömer Sinan Ağacan at 2019-08-23T12:04:15+03:00 Make non-streaming LLVM and C backends streaming This adds a Stream.consume function, uses it in LLVM and C code generators, and removes the use of Stream.collect function which was used to collect streaming Cmm generation results into a list. LLVM and C backends now properly use streamed Cmm generation, instead of collecting Cmm groups into a list before generating LLVM/C code. - - - - - 47070144 by Andreas Klebinger at 2019-08-23T19:26:42-04:00 Use variable length encoding for Binary instances. Use LEB128 encoding for Int/Word variants. This reduces the size of interface files significantly. (~19%). Also includes a few small optimizations to make unboxing work better that I have noticed while looking at the core. - - - - - cff44d86 by Sergei Trofimovich at 2019-08-23T19:27:21-04:00 configure.ac: fix '--disable-dwarf-debug' Before the change ./configure --disable-dwarf-debug enabled DWARF debugging unconditionally. This happened due to use of 5-argument form of `AC_ARG_ENABLE` without actually checking the passed `$enableval` parameter: ``` AC_ARG_ENABLE(dwarf-unwind, [AC_HELP_STRING([--enable-dwarf-unwind], [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])], [AC_CHECK_LIB(dw, dwfl_attach_state, [UseLibdw=YES], [AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)])])] [UseLibdw=NO] ) ``` Note: - `[UseLibdw=NO]` is called when `--{enable,disable}-dwarf-unwind` is not passed at all as a parameter (ok). - `[AC_CHECK_LIB(dw, dwfl_attach_state, [UseLibdw=YES],` is called for both: * `--enable-dwarf-unwind` being passed: `$enableval = "yes"` (ok). * --disable-dwarf-unwind` being passed: `$enableval = "no"` (bad). The change is to use 3-argument `AC_ARG_ENABLE` and check for passed value as `"$enable_dwarf_unwind" = "yes"`. Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 10763ce0 by Ömer Sinan Ağacan at 2019-08-27T10:45:02+03:00 Some more documentation for typePrimRep1 stuff [skip ci] - - - - - 89487be2 by Ömer Sinan Ağacan at 2019-08-27T15:21:50-04:00 Some tweaks in GHC.Compact haddocks - - - - - ee2fad9e by Andreas Klebinger at 2019-08-27T15:22:28-04:00 Remove redundant OPTIONS_GHC in BlockLayout.hs - - - - - 1c7ec449 by Ömer Sinan Ağacan at 2019-08-28T12:51:12+03:00 Return results of Cmm streams in backends This generalizes code generators (outputAsm, outputLlvm, outputC, and the call site codeOutput) so that they'll return the return values of the passed Cmm streams. This allows accumulating data during Cmm generation and returning it to the call site in HscMain. Previously the Cmm streams were assumed to return (), so the code generators returned () as well. This change is required by !1304 and !1530. Skipping CI as this was tested before and I only updated the commit message. [skip ci] - - - - - a308b435 by Sebastian Graf at 2019-08-28T11:33:49-04:00 Fix #17112 The `mkOneConFull` function of the pattern match checker used to try to guess the type arguments of the data type's type constructor by looking at the ambient type of the match. This doesn't work well for Pattern Synonyms, where the result type isn't even necessarily a TyCon application, and it shows in #11336 and #17112. Also the effort seems futile; why try to try hard when the type checker has already done the hard lifting? After this patch, we instead supply the type constructors arguments as an argument to the function and lean on the type-annotated AST. - - - - - 137c24e1 by Ryan Scott at 2019-08-28T22:36:40-04:00 Balance parentheses in GHC 8.10.1 release notes [ci skip] - - - - - 66282ba5 by luca at 2019-08-28T22:37:19-04:00 Remove Unused flag -ddump-shape [skip ci] - - - - - bf9dfe1c by Ömer Sinan Ağacan at 2019-08-29T04:28:35-04:00 Fix LLVM version check yet again There were two problems with LLVM version checking: - The parser would only parse x and x.y formatted versions. E.g. 1.2.3 would be rejected. - The version check was too strict and would reject x.y formatted versions. E.g. when we support version 7 it'd reject 7.0 ("LLVM version 7.0") and only accept 7 ("LLVM version 7"). We now parse versions with arbitrarily deep minor numbering (x.y.z.t...) and accept versions as long as the major version matches the supported version (e.g. 7.1, 7.1.2, 7.1.2.3 ...). - - - - - fc746e98 by Ben Gamari at 2019-08-29T04:29:13-04:00 gitlab-ci: Fix URL of Darwin's cabal-install tarball This was inadvertently referring to the cabal-install-latest/ directory which is volatile. - - - - - 304067a0 by Ömer Sinan Ağacan at 2019-08-29T09:38:25-04:00 Small optimization in the SRT algorithm Noticed by @simonmar in !1362: If the srtEntry is Nothing, then it should be safe to omit references to this SRT from other SRTs, even if it is a static function. When updating SRT map we don't omit references to static functions (see Note [Invalid optimisation: shortcutting]), but there's no reason to add an SRT entry for a static function if the function is not CAFFY. (Previously we'd add SRT entries for static functions even when they're not CAFFY) Using 9151b99e I checked sizes of all SRTs when building GHC and containers: - GHC: 583736 (HEAD), 581695 (this patch). 2041 less SRT entries. - containers: 2457 (HEAD), 2381 (this patch). 76 less SRT entries. - - - - - 78afc2c9 by Sergei Trofimovich at 2019-08-30T06:14:44-04:00 configure.ac: add --enable-numa switch Before the change ./configure detected numa support automatically withoun a nice way to disable autodetection. The change adds `--enable-numa` / `--disable-numa` switch to override the default. If `--enable-numa` is passed and `libnuma` is not present then configure will fail. Reported-by: Sergey Alirzaev Bug: https://github.com/gentoo-haskell/gentoo-haskell/issues/955 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c0956c14 by Vladislav Zavialov at 2019-08-30T06:15:21-04:00 Remove HsUtils/userHsLTyVarBndrs This patch removes 'userHsLTyVarBndrs' and 'userHsTyVarBndrs' from HsUtils. These helper functions were not used anywhere. - - - - - 7e6aeb13 by Eric Wolf at 2019-08-31T10:25:39+02:00 Add additional step to T16804 Add another small test step Use the same identifier name in different scopes and see, if ':uses' handles that. Add another test step to check wether local bindings with the same identifier name might get confused Add easier to understand test output Fix annotated lines from file correctly - - - - - e56251f6 by Ömer Sinan Ağacan at 2019-08-31T17:55:13-04:00 Remove redundant special case in STG pretty-printer This special case existed for no reason, and made things inconsistent. Before Boolean.$bT :: Boolean.Boolean [GblId, Str=m, Unf=OtherCon []] = CAF_ccs \ u [] Boolean.$bT1; After Boolean.$bF :: Boolean.Boolean [GblId, Str=m, Unf=OtherCon []] = \u [] Boolean.$bF1; The cost-centre is now hidden when not profiling, as is the case with other types of closures. - - - - - cfab4abe by Gershom Bazerman at 2019-09-01T00:34:05-04:00 cap max stack size at 32 bit limit (#17019) - - - - - 9acba780 by John Ericson at 2019-09-01T22:44:45-04:00 Use C99 Fixed width types to avoid hack in base's configure Define MD5Context in terms of `uint*_t` and don't use `HsFFI.h`. - - - - - 11679e5b by Ömer Sinan Ağacan at 2019-09-02T13:17:49+03:00 Few tweaks in -ddump-debug output, minor refactoring - Fixes crazy indentation in -ddump-debug output - We no longer dump empty sections in -ddump-debug when a code block does not have any generated debug info - Minor refactoring in Debug.hs and AsmCodeGen.hs - - - - - f96d57b8 by John Ericson at 2019-09-05T18:50:19-04:00 Make the C-- O and C types constructors with DataKinds The tightens up the kinds a bit. I use type synnonyms to avoid adding promotion ticks everywhere. - - - - - b55ee979 by John Ericson at 2019-09-05T18:50:56-04:00 Make sure all boolean settings entries use `YES` / `NO` Some where using `True` / `False`, a legacy of when they were in `Config.hs`. See #16914 / d238d3062a9858 for a similar problem. Also clean up the configure variables names for consistency and clarity while we're at it. "Target" makes clear we are talking about outputted code, not where GHC itself runs. - - - - - 821bece9 by Ömer Sinan Ağacan at 2019-09-07T04:50:21-04:00 Minor refactoring in deriveConstants Mainly we now generate this data PlatformConstants = PlatformConstants { pc_CONTROL_GROUP_CONST_291 :: Int, pc_STD_HDR_SIZE :: Int, pc_PROF_HDR_SIZE :: Int, pc_BLOCK_SIZE :: Int, } instead of data PlatformConstants = PlatformConstants { pc_platformConstants :: () , pc_CONTROL_GROUP_CONST_291 :: Int , pc_STD_HDR_SIZE :: Int , pc_PROF_HDR_SIZE :: Int , pc_BLOCK_SIZE :: Int ... } The first field has no use and according to (removed) comments it was to make code generator's work easier.. if anything this version is simpler because it has less repetition (the commas in strings are gone). - - - - - b0fdd7fe by Alp Mestanogullari at 2019-09-07T04:50:59-04:00 hadrian: fix _build/ghc-stage1 to make it callable from any directory - - - - - 51379b89 by Ömer Sinan Ağacan at 2019-09-08T21:40:32-04:00 Add a new flag -dno-typeable-binds for debugging See the user manual entry -- this helps when debugging as generated Core gets smaller without these bindings. - - - - - d0b45ac6 by Moritz Kiefer at 2019-09-08T21:41:12-04:00 Fix GHC version guard for Int32Rep/Word32Rep Those constructors have been added after GHC 8.8. The version guards in `binary` are correct, see https://github.com/kolmodin/binary/pull/167/files. - - - - - 4cf91d1a by Daniel Gröber at 2019-09-09T05:42:33-04:00 Use lazyness for FastString's z-encoding memoization Having an IORef in FastString to memoize the z-encoded version is unecessary because there is this amazing thing Haskell can do natively, it's called "lazyness" :) We simply remove the UNPACK and strictness annotations from the constructor field corresponding to the z-encoding, making it lazy, and store the (pure) z-encoded string there. The only complication here is 'hasZEncoding' which allows cheking if a z-encoding was computed for a given string. Since this is only used for compiler performance statistics though it's not actually necessary to have the current per-string granularity. Instead I add a global IORef counter to the FastStringTable and use unsafePerformIO to increment the counter whenever a lazy z-encoding is forced. - - - - - f5e2fde4 by Daniel Gröber at 2019-09-09T05:42:33-04:00 Update FastString docstrings 1) FastStrings are always UTF-8 encoded now. 2) Clarify what is meant by "hashed" 3) Add mention of lazy z-enc - - - - - 270fbe85 by Ryan Scott at 2019-09-09T05:43:12-04:00 Replace queryCygwinTerminal with Win32's isMinTTYHandle `SysTools.Terminal.queryCygwinTerminal` now exists in the `Win32` library under the name `isMinTTYHandle` since `Win32-2.5.0.0`. (GHC 8.4.4 ships with `Win32-2.6.1.0`, so this is well within GHC's support window.) We can therefore get replace `queryCygwinTerminal` with `isMinTTYHandle` and delete quite a bit of code from `SysTools.Terminal` in the process. Along the way I needed to replace some uses of `#if defined x` with `#if defined(x)` to please the CI linters. - - - - - 447864a9 by Sylvain Henry at 2019-09-10T00:04:50+02:00 Module hierarchy: StgToCmm (#13009) Add StgToCmm module hierarchy. Platform modules that are used in several other places (NCG, LLVM codegen, Cmm transformations) are put into GHC.Platform. - - - - - 60c26403 by Niklas Hambüchen at 2019-09-11T09:44:23-04:00 linker: Move -optl flags to end of linker invocation. Until now, giving `-optl` linker flags to `ghc` on the command line placed them in the wrong place in the `ld` command line: They were given before all the Haskell libararies, when they should appear after. Background: Most linkers like `ld.bfd` and `ld.gold`, but not the newer LLVM `lld`, work in a way where the order of `-l` flags given matters; earlier `-lmylib1` flags are supposed to create "holes" for linker symbols that are to be filled with later `lmylib2` flags that "fill the holes" for these symbols. As discovered in https://github.com/haskell/cabal/pull/5451#issuecomment-518001240, the `-optl` flags appeared before e.g. the -lHStext-1.2.3.1 -lHSbinary-0.8.6.0 -lHScontainers-0.6.0.1 flags that GHC added at the very end. Haskell libraries typically depend on C libraries, so `-lHS*` flags will create holes for the C libraries to fill in, but that only works when those libraries' `-l` flags are given **after** the `-lHS*` flags; until now they were given before, which was wrong. This meant that Cabal's `--ld-options` flag and `ld-options` `.cabal` file field were pretty ineffective, unless you used the `--ld-option=--start-group` hack as (https://github.com/haskell/cabal/pull/5451#issuecomment-406761676) that convinces the classical linkers to not be dependent on the order of linker flags given. This commit fixes the problem by simply flipping the order, putting `-optl` flags at the end, after Haskell libraries. The code change is effectively only `args1 ++ args` -> `args ++ args1` but the commit also renames the variables for improved clarity. Simple way to test it: ghc --make Main.hs -fforce-recomp -v -optl-s on a `Main.hs` like: import qualified Data.Set as Set main = print $ Set.fromList "hello" - - - - - 7032a913 by John Ericson at 2019-09-11T09:45:02-04:00 Remove COMPILING_GHC It is no longer used. I guess we are sharing fewer headers with the RTS than the comment claims. That's a relief! - - - - - 58569a5b by Peter Trommler at 2019-09-11T09:45:47-04:00 testsuite: check for RTS linker Fixes #16833 - - - - - df6fbe03 by Luke Lau at 2019-09-11T09:46:36-04:00 Bump Hadrian's QuickCheck dependency - - - - - d9e637df by John Ericson at 2019-09-11T09:47:26-04:00 Remove dead `ncgDebugIsOn` and `NCG_DEBUG` Haven't been used since 16206a6603e87e15d61c57456267c5f7ba68050e. - - - - - 7ef6fe8f by Ben Gamari at 2019-09-11T09:48:03-04:00 SetLevels: Fix potential panic in lvlBind 3b31a94d introduced a use of isUnliftedType which can panic in the case of levity-polymorphic types. Fix this by introducing mightBeUnliftedType which returns whether the type is *guaranteed* to be lifted. - - - - - c76cc0c6 by Ömer Sinan Ağacan at 2019-09-11T19:40:06-04:00 Refactor bad coercion checking in a few places We do bad coercion checking in a few places in the compiler, but they all checked it differently: - CoreToStg.coreToStgArgs: Disallowed lifted-to-unlifted, disallowed changing prim reps even when the sizes are the same. - StgCmmExpr.cgCase: Checked primRepSlot equality. This disallowed Int to Int64 coercions on 64-bit systems (and Int to Int32 on 32-bit) even though those are fine. - CoreLint: Only place where we do this right. Full rules are explained in Note [Bad unsafe coercion]. This patch implements the check explained in Note [Bad unsafe coercion] in CoreLint and uses it in CoreToStg.coreToStgArgs and StgCmmExpr.cgCase. This fixes #16952 and unblocks !1381 (which fixes #16893). This is the most conservative and correct change I came up with that fixes #16952. One remaining problem with coercion checking is that it's currently done in seemingly random places. What's special about CoreToStg.coreToStgArgs and StgCmmExpr.cgCase? My guess is that adding assertions to those places caught bugs before so we left assertions in those places. I think we should remove these assertions and do coercion checking in CoreLint and StgLint only (#17041). - - - - - 3a7d3923 by Tamar Christina at 2019-09-11T19:40:53-04:00 Windows: make openTempFile fully atomic. - - - - - 98b0d6ee by Pranay Sashank at 2019-09-12T04:52:33-04:00 Print the correct system memory in use with +RTS -s (#17158) Use `stats.max_mem_in_use_bytes` to print the memory usage instead of `stats.max_live_bytes` which prints maximum residency. Fixes (#17158). - - - - - a06629b4 by John Ericson at 2019-09-12T04:53:13-04:00 Do not throw away backpack instantiations for module lookup cache Currently, there is only one home package so this probably doesn't matter. But if we support multiple home packages, they could differ only in arguments (same indef component being applied). It looks like it used to be this way before 4e8a0607140b23561248a41aeaf837224aa6315b, but that commit doesn't seem to comment on this change in the particular. (It's main purpose is creating the InstalledUnitId and recategorizing the UnitId expressions accordingly.) Trying this as a separate commit for testing purposes. I leave it to others to decide whether this is a good change on its own. - - - - - 09fa5654 by John Ericson at 2019-09-12T04:53:51-04:00 Remove unused `#include`s from parser/cutils.c Looks like these have been unused since 7c665f9ce0980ee7c81a44c8f861686395637453. - - - - - 2b37a79d by Sebastian Graf at 2019-09-12T14:05:29-04:00 Bump Cabal submodule to 3.1 ------------------------- Metric Increase: haddock.Cabal T4029 ------------------------- - - - - - 86753475 by Ningning Xie at 2019-09-12T14:06:07-04:00 Fix StandaloneDeriving If I understand correctly, `deriving instance _ => Eq (Foo a)` is equivalent to `data Foo a deriving Eq`, rather than `data Foo a deriving Foo`. - - - - - a733002a by Ben Gamari at 2019-09-13T03:09:47-04:00 Update mailmap - - - - - 5b64aee2 by Simon Peyton Jones at 2019-09-13T03:10:26-04:00 Fix scoping of implicit parameters There was an outright bug in TcInteract.solveOneFromTheOther which meant that we did not always pick the innermost implicit parameter binding, causing #17104. The fix is easy, just a rearrangement of conditional tests - - - - - 47b12660 by Tamar Christina at 2019-09-13T03:11:06-04:00 Windows: Fix hsc2hs non-deterministic failures. - - - - - e3a7592b by Alp Mestanogullari at 2019-09-13T03:11:50-04:00 Add a test to make sure we don't regress on #17140 in the future - - - - - 6f3cd50e by Zubin Duggal at 2019-09-13T11:24:51-04:00 Explain how to update HieAst [skip ci] - - - - - 71428a43 by Zubin Duggal at 2019-09-13T11:24:51-04:00 Address review comments [skip CI] - - - - - ccb4e646 by John Ericson at 2019-09-13T11:25:29-04:00 Compiler should always get fingerprinting impl from base 07ee15915d5a0d6d1aeee137541eec6e9c153e65 started the transition, but the job was never finished. - - - - - c45c89d6 by Ben Gamari at 2019-09-13T11:26:05-04:00 gitlab: Add issue template for documentation issues Fixes #17180. - - - - - a0e220b7 by John Ericson at 2019-09-13T11:26:43-04:00 Remove empty NCG.h - - - - - 046ca133 by Andrew Martin at 2019-09-13T15:43:16-04:00 Add predicates for testing if IOError is ResourceVanished. This adds isResourceVanished, resourceVanishedErrorType, and isResourceVanishedErrorType to System.IO.Error, resolving #14730. - - - - - bd079345 by taylorfausak at 2019-09-14T06:25:27-04:00 Fix CONLIKE typo - - - - - cf7e78a3 by Ben Gamari at 2019-09-15T23:46:36-04:00 Rename GHC.StgToCmm.Con -> GHC.StgToCmm.DataCon Incredibly, Windows disallows the manipulation of any file matching Con(\..*)?. The `GHC.StgToCmm.Con` was introduced in the renamings in 447864a9, breaking the Windows build. Work around this by renaming it to `GHC.StgToCmm.DataCon` Fixes #17187. - - - - - 7208160d by Sylvain Henry at 2019-09-15T23:47:22-04:00 Fix Hadrian build with Stack (#17189) Broken by 2b37a79d61e9b3787873dc9f7458ef2bde4809b0 - - - - - b5ae3868 by Sylvain Henry at 2019-09-16T13:32:22-04:00 Allow validation with Hadrian built with Stack [skip ci] - - - - - 7915afc6 by Sebastian Graf at 2019-09-16T13:33:05-04:00 Encode shape information in `PmOracle` Previously, we had an elaborate mechanism for selecting the warnings to generate in the presence of different `COMPLETE` matching groups that, albeit finely-tuned, produced wrong results from an end user's perspective in some cases (#13363). The underlying issue is that at the point where the `ConVar` case has to commit to a particular `COMPLETE` group, there's not enough information to do so and the status quo was to just enumerate all possible complete sets nondeterministically. The `getResult` function would then pick the outcome according to metrics defined in accordance to the user's guide. But crucially, it lacked knowledge about the order in which affected clauses appear, leading to the surprising behavior in #13363. In !1010 we taught the term oracle to reason about literal values a variable can certainly not take on. This MR extends that idea to `ConLike`s and thereby fixes #13363: Instead of committing to a particular `COMPLETE` group in the `ConVar` case, we now split off the matching constructor incrementally and record the newly covered case as a refutable shape in the oracle. Whenever the set of refutable shapes covers any `COMPLETE` set, the oracle recognises vacuosity of the uncovered set. This patch goes a step further: Since at this point the information in value abstractions is merely a cut down representation of what the oracle knows, value abstractions degenerate to a single `Id`, the semantics of which is determined by the oracle state `Delta`. Value vectors become lists of `[Id]` given meaning to by a single `Delta`, value set abstractions (of which the uncovered set is an instance) correspond to a union of `Delta`s which instantiate the same `[Id]` (akin to models of formula). Fixes #11528 #13021, #13363, #13965, #14059, #14253, #14851, #15753, #17096, #17149 ------------------------- Metric Decrease: ManyAlternatives T11195 ------------------------- - - - - - ae4415b9 by Matthew Pickering at 2019-09-17T19:21:10-04:00 eventlog: Add biographical and retainer profiling traces This patch adds a new eventlog event which indicates the start of a biographical profiler sample. These are different to normal events as they also include the timestamp of when the census took place. This is because the LDV profiler only emits samples at the end of the run. Now all the different profiling modes emit consumable events to the eventlog. - - - - - 9c21b2fd by Richard Eisenberg at 2019-09-17T19:22:00-04:00 Fix #13571 by adding an extension flag check Test case: indexed-types/should_fail/T13571 - - - - - 8039b125 by Simon Peyton Jones at 2019-09-17T19:22:50-04:00 Comments only - - - - - 1c3af277 by Simon Peyton Jones at 2019-09-17T19:23:37-04:00 Improve error message for out-of-scope variables + VTA As #13834 and #17150 report, we get a TERRIBLE error message when you have an out of scope variable applied in a visible type application: (outOfScope @Int True) This very simple patch improves matters. See TcExpr Note [VTA for out-of-scope functions] - - - - - c77fc3b2 by John Ericson at 2019-09-17T19:24:20-04:00 Deduplicate `HaskellMachRegs.h` and `RtsMachRegs.h` headers Until 0472f0f6a92395d478e9644c0dbd12948518099f there was a meaningful host vs target distinction (though it wasn't used right, in genapply). After that, they did not differ in meaningful ways, so it's best to just only keep one. - - - - - c3eaaca6 by Simon Peyton Jones at 2019-09-19T09:03:19-04:00 Add a missing update of sc_hole_ty (#16312) In simplCast I totally failed to keep the sc_hole_ty field of ApplyToTy (see Note [The hole type in ApplyToTy]) up to date. When a cast goes by, of course the hole type changes. Amazingly this has not bitten us before, but #16312 finally triggered it. Fortunately the fix is simple. Fixes #16312. - - - - - de1723b2 by Ben Gamari at 2019-09-19T09:03:19-04:00 Simplify: Lazy pattern match - - - - - d9c6b86e by Richard Eisenberg at 2019-09-19T09:04:03-04:00 Refactor kindGeneralize and friends This commit should have no change in behavior.(*) The observation was that Note [Recipe for checking a signature] says that every metavariable in a type-checked type must either (A) be generalized (B) be promoted (C) be zapped. Yet the code paths for doing these were all somewhat separate. This led to some steps being skipped. This commit shores this all up. The key innovation is TcHsType.kindGeneralizeSome, with appropriate commentary. This commit also sets the stage for #15809, by turning the WARNing about bad level-numbers in generalisation into an ASSERTion. The actual fix for #15809 will be in a separate commit. Other changes: * zonkPromoteType is now replaced by kindGeneralizeNone. This might have a small performance degradation, because zonkPromoteType zonked and promoted all at once. The new code path promotes first, and then zonks. * A call to kindGeneralizeNone was added in tcHsPartialSigType. I think this was a lurking bug, because it did not follow Note [Recipe for checking a signature]. I did not try to come up with an example showing the bug. This is the (*) above. Because of this change, there is an error message regression in partial-sigs/should_fail/T14040a. This problem isn't really a direct result of this refactoring, but is a symptom of something deeper. See #16775, which addresses the deeper problem. * I added a short-cut to quantifyTyVars, in case there's nothing to quantify. * There was a horribly-outdated Note that wasn't referred to. Gone now. * While poking around with T14040a, I discovered a small mistake in the Coercion.simplifyArgsWorker. Easy to fix, happily. * See new Note [Free vars in coercion hole] in TcMType. Previously, we were doing the wrong thing when looking at a coercion hole in the gather-candidates algorithm. Fixed now, with lengthy explanation. Metric Decrease: T14683 - - - - - f594a68a by Richard Eisenberg at 2019-09-19T09:04:03-04:00 Use level numbers for generalisation This fixes #15809, and is covered in Note [Use level numbers for quantification] in TcMType. This patch removes the "global tyvars" from the environment, a nice little win. - - - - - c675d08f by Richard Eisenberg at 2019-09-19T09:04:03-04:00 Test #17077. - - - - - 912afaf4 by Ben Gamari at 2019-09-19T09:04:39-04:00 CoreUtils: Use mightBeUnliftedType in exprIsTopLevelBindable Also add reference from isUnliftedType to mightBeUnliftedType. - - - - - baf47661 by Sebastian Graf at 2019-09-19T09:05:20-04:00 Extract PmTypes module from PmExpr and PmOracle Apparently ghc-lib-parser's API blew up because the newly induced cyclic dependency between TcRnTypes and PmOracle pulled in the other half of GHC into the relevant strongly-connected component. This patch arranges it so that PmTypes exposes mostly data type definitions and type class instances to be used within PmOracle, without importing the any of the possibly offending modules DsMonad, TcSimplify and FamInst. - - - - - 2a8867cf by Sebastian Graf at 2019-09-19T09:05:58-04:00 Add a regression test for #11822 The particular test is already fixed, but the issue seems to have multiple different test cases lumped together. - - - - - 52173990 by Ben Gamari at 2019-09-19T09:06:36-04:00 testsuite: Add testcase for #17206 - - - - - b3e5c731 by Alp Mestanogullari at 2019-09-19T21:42:17-04:00 ErrUtils: split withTiming into withTiming and withTimingSilent 'withTiming' becomes a function that, when passed '-vN' (N >= 2) or '-ddump-timings', will print timing (and possibly allocations) related information. When additionally built with '-eventlog' and executed with '+RTS -l', 'withTiming' will also emit both 'traceMarker' and 'traceEvent' events to the eventlog. 'withTimingSilent' on the other hand will never print any timing information, under any circumstance, and will only emit 'traceEvent' events to the eventlog. As pointed out in !1672, 'traceMarker' is better suited for things that we might want to visualize in tools like eventlog2html, while 'traceEvent' is better suited for internal events that occur a lot more often and that we don't necessarily want to visualize. This addresses #17138 by using 'withTimingSilent' for all the codegen bits that are expressed as a bunch of small computations over streams of codegen ASTs. - - - - - 4853d962 by Ben Gamari at 2019-09-19T21:42:55-04:00 users guide: Fix link to let generalization blog post Fixes #17200. - - - - - 51192964 by Sylvain Henry at 2019-09-20T05:14:34-04:00 Module hierarchy: Hs (#13009) Add GHC.Hs module hierarchy replacing hsSyn. Metric Increase: haddock.compiler - - - - - 2f8ce45a by Ben Gamari at 2019-09-20T05:15:11-04:00 testsuite: Add test for #17202 - - - - - f257bf73 by Matthew Pickering at 2019-09-20T05:15:52-04:00 hadrian/ghci.sh: Enable building in parallel - - - - - 070f7b85 by Matthew Pickering at 2019-09-20T05:15:52-04:00 Remove trailing whitespace - - - - - 5390b553 by Matthew Pickering at 2019-09-20T05:15:52-04:00 Pass -j to ghc-in-ghci CI job - - - - - 1b7e1d31 by John Ericson at 2019-09-20T05:16:36-04:00 Remove pointless partiality in `Parser.ajs` - - - - - 17554248 by Simon Peyton Jones at 2019-09-20T10:50:21+01:00 Fix PmOracle.addVarCoreCt in-scope set PmOracle.addVarCoreCt was giving a bogus (empty) in-scope set to exprIsConApp_maybe, which resulted in a substitution-invariant failure (see MR !1647 discussion). This patch fixes it, by taking the free vars of the expression. - - - - - 0dad81ca by Simon Peyton Jones at 2019-09-20T10:50:21+01:00 Fix bogus type of case expression Issue #17056 revealed that we were sometimes building a case expression whose type field (in the Case constructor) was bogus. Consider a phantom type synonym type S a = Int and we want to form the case expression case x of K (a::*) -> (e :: S a) We must not make the type field of the Case constructor be (S a) because 'a' isn't in scope. We must instead expand the synonym. Changes in this patch: * Expand synonyms in the new function CoreUtils.mkSingleAltCase. * Use mkSingleAltCase in MkCore.wrapFloat, which was the proximate source of the bug (when called by exprIsConApp_maybe) * Use mkSingleAltCase elsewhere * Documentation CoreSyn new invariant (6) in Note [Case expression invariants] CoreSyn Note [Why does Case have a 'Type' field?] CoreUtils Note [Care with the type of a case expression] * I improved Core Lint's error reporting, which was pretty confusing in this case, because it didn't mention that the offending type was the return type of a case expression. * A little bit of cosmetic refactoring in CoreUtils - - - - - 1ea8c451 by Sebastian Graf at 2019-09-21T09:52:34-04:00 PredType for type constraints in the pattern match checker instead of EvVar Using EvVars for capturing type constraints implied side-effects in DsM when we just wanted to *construct* type constraints. But giving names to type constraints is only necessary when passing Givens to the type checker, of which the majority of the pattern match checker should be unaware. Thus, we simply generate `newtype TyCt = TyCt PredType`, which are nicely stateless. But at the same time this means we have to allocate EvVars when we want to query the type oracle! So we keep the type oracle state as `newtype TyState = TySt (Bag EvVar)`, which nicely makes a distinction between new, unchecked `TyCt`s and the inert set in `TyState`. - - - - - ded96fb3 by Ömer Sinan Ağacan at 2019-09-21T09:53:29-04:00 Document MIN_PAYLOAD_SIZE and mark-compact GC mark bits This updates the documentation of the MIN_PAYLOAD_SIZE constant and adds a new Note [Mark bits in mark-compact collector] explaning why the mark-compact collector uses two bits per objet and why we need MIN_PAYLOAD_SIZE. - - - - - a7867c79 by Sebastian Graf at 2019-09-21T14:56:58+01:00 Get rid of PmFake The pattern match oracle can now cope with the abundance of information that ViewPatterns, NPlusKPats, overloaded lists, etc. provide. No need to have PmFake anymore! Also got rid of a spurious call to `allCompleteMatches`, which we used to call *for every constructor* match. Naturally this blows up quadratically for programs like `ManyAlternatives`. ------------------------- Metric Decrease: ManyAlternatives Metric Increase: T11822 ------------------------- - - - - - fa66e3e5 by Alp Mestanogullari at 2019-09-21T23:31:08-04:00 Fix haddocks for marker events in Debug.Trace - - - - - da12da79 by Daniel Gröber at 2019-09-22T14:34:56+02:00 rts: retainer: Remove cStackSize debug counter This can only ever be one since 5f1d949ab9 ("Remove explicit recursion in retainer profiling"), so it's pointless. - - - - - 3ebaa4b5 by Daniel Gröber at 2019-09-22T15:17:53+02:00 rts: Remove bitrotten retainer debug code The `defined(DEBUG_RETAINER) == true` branch doesn't even compile anymore because 1) retainerSet was renamed to RetainerSet and 2) even if I fix that the context in Rts.h seems to have changed such that it's not in scope. If 3) I fix that 'flip' is still not in scope :) At that point I just gave up. - - - - - 63023dc2 by Daniel Gröber at 2019-09-22T15:18:09+02:00 rts: Fix outdated references to 'ldvTime' This got renamed to 'era' in dbef766ce7 ("[project @ 2001-11-26 16:54:21 by simonmar] Profiling cleanup"). - - - - - ead05f80 by Daniel Gröber at 2019-09-22T15:18:09+02:00 rts: retainer: Turn global traversal state into a struct Global state is ugly and hard to test. Since the profiling code isn't quite as performance critical as, say, GC we should prefer better code here. I would like to move the 'flip' bit into the struct too but that's complicated by the fact that the defines which use it directly are also called from ProfHeap where the traversalState is not easily available. Maybe in a future commit. - - - - - 94ecdb4f by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move info.next.parent to stackElement I don't see a point in having this live in 'info', just seems to make the code more complicated. - - - - - f79ac2ef by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Generalise per-stackElement data This essentially ammounts to s/retainer/stackData/, s/c_child_r/data/ and some temporary casting of c_child_r to stackData until refactoring of this module is completed by a subsequent commit. We also introduce a new union 'stackData' which will contain the actual extra data to be stored on the stack. The idea is to make the heap traversal logic of the retainer profiler ready for extraction into it's own module. So talking about "retainers" there doesn't really make sense anymore. Essentially the "retainers" we store in the stack are just data associated with the push()ed closures which we return when pop()ing it. - - - - - f083358b by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Fix comment typo s/keeps/keep/ - - - - - 2f2f6dd5 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: Generalise profiling heap traversal flip bit handling This commit starts renaming some flip bit related functions for the generalised heap traversal code and adds provitions for sharing the per-closure profiling header field currently used exclusively for retainer profiling with other heap traversal profiling modes. - - - - - e40b3c23 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: GC: Remove redundant #include "RetainerProfiler.h" - - - - - b03db9da by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Pull retainer specific code into a callback This essentially turns the heap traversal code into a visitor. You add a bunch of roots to the work-stack and then the callback you give to traverseWorkStack() will be called with every reachable closure at least once. - - - - - 48e816f0 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: simplify pop() control flow Instead of breaking out of the switch-in-while construct using `return` this uses `goto out` which makes it possible to share a lot of the out-variable assignment code in all the cases. I also replaced the nasty `while(true)` business by the real loop condition: `while(*c == NULL)`. All `break` calls inside the switch aready have either a check for NULL or an assignment of `c` to NULL so this should not change any behaviour. Using `goto out` also allowed me to remove another minor wart: In the MVAR_*/WEAK cases the popOff() call used to happen before reading the stackElement. This looked like a use-after-free hazard to me as the stack is allocated in blocks and depletion of a block could mean it getting freed and possibly overwritten by zero or garbage, depending on the block allocator's behaviour. - - - - - b92ed68a by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: Add note reference to SET_PROF_HDR for profiling 'flip' bit - - - - - f3bb7397 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerSet: Remove obsolete fist/second-approach choice In the old code when DEBUG_RETAINER was set, FIRST_APPROACH is implied. However ProfHeap.c now depends on printRetainerSetShort which is only available with SECOND_APPROACH. This is because with FIRST_APPROACH retainerProfile() will free all retainer sets before returning so by the time ProfHeap calls dumpCensus the retainer set pointers are segfaulty. Since all of this debugging code obviously hasn't been compiled in ages anyways I'm taking the liberty of just removing it. Remember guys: Dead code is a liability not an asset :) - - - - - ec1d76e2 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Remove obsolete debug code Commit dbef766ce7 ("Profiling cleanup.") made this debug code obsolete by removing the 'cost' function without a replacement. As best I can tell the retainer profiler used to do some heap census too and this debug code was mainly concerned with that. - - - - - b7e15d17 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Rename heap traversal functions for extraction This gets all remaining functions in-line with the new 'traverse' prefix and module name. - - - - - 64ec45a7 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Reduce DEBUG_RETAINER ifdef noise Keeping track of the maximum stack seems like a good idea in all configurations. The associated ASSERTs only materialize in debug mode but having the statistic is nice. To make the debug code less prone to bitrotting I introduce a function 'debug()' which doesn't actually print by default and is #define'd away only when the standard DEBUG define is off. - - - - - bd78b696 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Cleanup comments and strings for traversal extraction A lot of comments and strings are still talking about old names, fix that. - - - - - cb7220b3 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Remove outdated invariants on traversePushStack These invariants don't seem to make any sense in the current code. The text talks about c_child_r as if it were an StgClosure, for which RSET() would make sense, but it's a retainer aka 'CostCentreStack*'. - - - - - bb92660c by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Use global STATIC_INLINE macro STATIC_INLINE already does what the code wanted here, no need to duplicate the functionality here. - - - - - 2b76cf9e by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move heap traversal declarations to new header - - - - - 44d5cc0d by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Abstract maxStackSize for generic traversal - - - - - fd213d17 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Update obsolete docs for traverseMaybeInitClosureData - - - - - 39f2878c by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move actual 'flip' bit flip to generic traversal code - - - - - f9b4c4f2 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Remove traverse-stack chunk support There's simply no need anymore for this whole business. Instead of individually traversing roots in retainRoot() we just push them all onto the stack and traverse everything in one go. This feature was not really used anyways. There is an `ASSERT(isEmptyWorkStack(ts))` at the top of retainRoot() which means there really can't ever have been any chunks at the toplevel. The only place where this was probably used is in traversePushStack but only way back when we were still using explicit recursion on the C callstack. Since the code was changed to use an explicit traversal-stack these stack-chunks can never escape one call to traversePushStack anymore. See commit 5f1d949ab9 ("Remove explicit recursion in retainer profiling") - - - - - c7def600 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move mut_list reset to generic traversal code - - - - - 9bf27060 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Make visit callback easier to implement Currently it is necessary for user code to expend at least one extra bit in the closure header just to know whether visit() should return true or false, to indicate if children should be traversed. The generic traversal code already has this information in the visited bit so simply pass it to the visit callback. - - - - - 96adf179 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Improve Note [Profiling heap traversal visited bit] - - - - - 187192a6 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerProfile.c: Re-enable and fix warnings Turns out some genius disabled warnings for RetainerProfile.c in the build system. That would have been good to know about five silent type mismatch crashes ago.. :) - - - - - eb29735e by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerProfile.c: Minimize #includes A lot of these includes are presumably leftovers from when the retainer profiler still did it's own heap profiling. - - - - - 383f9089 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: Split heap traversal from retainer profiler This finally moves the newly generalised heap traversal code from the retainer profiler into it's own file. - - - - - 52c5ea71 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: TraverseHeap: Make comment style consistent - - - - - 75355228 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: TraverseHeap: Make pushStackElement argument const - - - - - a8137780 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: TraverseHeap: Move stackElement.cp back into nextPos union The 'cp' field really is only used when type==posTypeFresh so it's more space efficient to have it in the nextPos union. - - - - - 7f10cc2d by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerProfile: Explain retainVisitClosure return values [ci skip] - - - - - 111f2761 by Daniel Gröber at 2019-09-22T15:33:41+02:00 rts: TraverseHeap: Add doc comment for getTraverseStackMaxSize - - - - - 68ddb43c by Ben Gamari at 2019-09-23T00:34:00-04:00 gitlab-ci: Fix URL of Windows cabal-install tarball - - - - - 0e478407 by Takenobu Tani at 2019-09-23T17:51:37-04:00 users-guide: Fix links and formats for GHC 8.10 This commit only fixes links and markdown syntax. [skip ci] - - - - - 74631bbc by Adam Sandberg Eriksson at 2019-09-23T17:52:32-04:00 base: add newtypes for socklen_t and ndfs_t to System.Posix.Types #16568 Metric Increase: haddock.base T4029 - - - - - 4470a144 by Björn Gohla at 2019-09-23T17:53:23-04:00 add Hadrian rule to build user guide as Info book - - - - - dbbea5a8 by Björn Gohla at 2019-09-23T17:53:23-04:00 use the Make builder instead of raw cmd_ - - - - - b0e3b173 by Björn Gohla at 2019-09-23T17:53:23-04:00 detect makeinfo in configure(.ac) - - - - - 9fe4d2df by Björn Gohla at 2019-09-23T17:53:23-04:00 explicit dependence on makeinfo - - - - - b650c2b6 by Björn Gohla at 2019-09-23T17:53:23-04:00 alphabetical ordering - - - - - 27789294 by Björn Gohla at 2019-09-23T17:53:23-04:00 sort-paragraphs in runBuilderWith - - - - - d0c2f3a2 by Artem Pyanykh at 2019-09-23T17:54:04-04:00 [hadrian] Rebuild programs on dynamicGhcPrograms/ghcProfiled change Currently, if you change these ^ flavour parameters, rebuilding is not triggered, since `programContext` doesn't set up a dependency on those values. Exposing these values via an oracle does set the dependency and properly triggers a rebuild of binaries. Several attempts to factor out these actions ended up in cyclic dependency here or there. I'm not absolutely happy with this variant either, but at least it works. ==== Issue repro: In UserSettings.hs: ``` dbgDynamic = defaultFlavour { name = "dbg-dynamic" , dynamicGhcPrograms = pure True, ... } dbgStatic = defaultFlavour { name = "dbg-static" , dynamicGhcPrograms = pure False ... } ``` Then in console: ``` $ hadrian/build.sh -j --flavour=dbg-dynamic ... does the build $ hadrian/build.sh -j --flavour=dbg-static ... does nothing, considers binaries up to date ``` - - - - - 238b58e4 by Kari Pahula at 2019-09-23T17:54:42-04:00 Add -fkeep-going to make compiler continue despite errors (#15424) Add a new optional failure handling for upsweep which continues the compilation on other modules if any of them has errors. - - - - - 146f26cc by Sebastian Graf at 2019-09-24T01:06:40-04:00 Some leftovers from !1732. Comments only [skip ci] - - - - - b5f24fb4 by Takenobu Tani at 2019-09-24T01:07:19-04:00 Hadrian: Add -haddock option for GHCi's :doc command This commit adds -haddock option to Hadrian-based build system. To enable :doc command on GHCi, core libraries must be compiled with -haddock option. Especially, the `-haddock` option is essential for a release build. Assuming current GitLab CI condition (.gitlab-ci.yml), I add -haddock option to the default flavour only. This has already been done for Make-based build system. Please see #16415. - - - - - f97a7aac by Sebastian Graf at 2019-09-24T01:07:57-04:00 Fix some duplication in the parser D3673 experienced reduce/reduce conflicts when trying to use opt_instance for associated data families. That was probably because the author tried to use it for Haskell98-syntax without also applying it to GADT-syntax, which actually leads to a reduce/reduce conflict. Consider the following state: ``` data . T = T data . T where T :: T ``` The parser must decide at this point whether or not to reduce an empty `opt_instance`. But doing so would also commit to either Haskell98 or GADT syntax! Good thing we also accept an optional "instance" for GADT syntax, so the `opt_instance` is there in both productions and there's no reduce/reduce conflict anymore. Also no need to inline `opt_instance`, how it used to be. - - - - - b23f01fd by Ben Gamari at 2019-09-24T08:49:43-04:00 base: Add link to "A reflection on types" Fixes #17181. - - - - - 4bbe0dba by Ben Gamari at 2019-09-24T08:50:20-04:00 gitlab-ci: Bump ci-images This bumps the CI Docker images to ghc/ci-images at 990c5217d1d0e03aea415f951afbc3b1a89240c6. - - - - - 6bca867c by Ben Gamari at 2019-09-24T08:50:59-04:00 hadrian: Update source-repository - - - - - b2d47536 by Ben Gamari at 2019-09-24T08:51:45-04:00 testsuite: Mark threadstatus-9333 as fragile in profthreaded Due to #16555. - - - - - ed520678 by Andreas Klebinger at 2019-09-24T21:08:42-04:00 Fix bounds check in ocResolve_PEi386 for relocation values. The old test was wrong at least for gcc and the value -2287728808L. It also relied on implementation defined behaviour (right shift on a negative value), which might or might not be ok. Either way it's now a simple comparison which will always work. - - - - - 218c5dbf by Matthew Pickering at 2019-09-24T21:09:23-04:00 Add ghcide configuration files This commit adds three new files 1. A hie.yaml file to the project root which specifies to IDEs how to set up the correct environment for loading GHC. This currently specifies to call the `./hadrian/hie-bios` script. 2. A `hie.yaml` file for the hadrian subcomponent, which uses the `cabal` cradle type. 2. The `./hadrian/hie-bios` script which supplies the correct arguments for an IDE to start a session. With these two files it is possible to run ``` ghcide compiler/ ``` and successfully load all the modules for use in the IDE. or ``` ghcide --cwd hadrian/ src/ ``` to test loading all of Hadrian's modules. Closes #17194 - - - - - 2970dc7a by Kari Pahula at 2019-09-25T13:52:48-04:00 Add -Wderiving-defaults (#15839) Enabling both DeriveAnyClass and GeneralizedNewtypeDeriving can cause a warning when no explicit deriving strategy is in use. This change adds an enable/suppress flag for it. - - - - - 4540bbe2 by John Ericson at 2019-09-25T13:53:42-04:00 includes/CodeGen.Platform.hs don't include ghcautoconf.h It doesn't need it, and it shouldn't need it or else multi-target will break. - - - - - ebc65025 by Sebastian Graf at 2019-09-25T13:54:22-04:00 PmCheck: Only ever check constantly many models against a single pattern Introduces a new flag `-fmax-pmcheck-deltas` to achieve that. Deprecates the old `-fmax-pmcheck-iter` mechanism in favor of this new flag. >From the user's guide: Pattern match checking can be exponential in some cases. This limit makes sure we scale polynomially in the number of patterns, by forgetting refined information gained from a partially successful match. For example, when matching `x` against `Just 4`, we split each incoming matching model into two sub-models: One where `x` is not `Nothing` and one where `x` is `Just y` but `y` is not `4`. When the number of incoming models exceeds the limit, we continue checking the next clause with the original, unrefined model. This also retires the incredibly hard to understand "maximum number of refinements" mechanism, because the current mechanism is more general and should catch the same exponential cases like PrelRules at the same time. ------------------------- Metric Decrease: T11822 ------------------------- - - - - - d90d0bad by Ben Gamari at 2019-09-25T13:55:09-04:00 base: Move Ix typeclass to GHC.Ix The `Ix` class seems rather orthogonal to its original home in `GHC.Arr`. - - - - - 795986aa by Ryan Scott at 2019-09-25T13:56:07-04:00 Remove unneeded CPP now that GHC 8.6 is the minimum The minimum required GHC version for bootstrapping is 8.6, so we can get rid of some unneeded `#if `__GLASGOW_HASKELL__` CPP guards, as well as one `MIN_VERSION_ghc_prim(0,5,3)` guard (since GHC 8.6 bundles `ghc-prim-0.5.3`). - - - - - 0b5eede9 by Vladislav Zavialov at 2019-09-25T21:06:04+03:00 Standalone kind signatures (#16794) Implements GHC Proposal #54: .../ghc-proposals/blob/master/proposals/0054-kind-signatures.rst With this patch, a type constructor can now be given an explicit standalone kind signature: {-# LANGUAGE StandaloneKindSignatures #-} type Functor :: (Type -> Type) -> Constraint class Functor f where fmap :: (a -> b) -> f a -> f b This is a replacement for CUSKs (complete user-specified kind signatures), which are now scheduled for deprecation. User-facing changes ------------------- * A new extension flag has been added, -XStandaloneKindSignatures, which implies -XNoCUSKs. * There is a new syntactic construct, a standalone kind signature: type <name> :: <kind> Declarations of data types, classes, data families, type families, and type synonyms may be accompanied by a standalone kind signature. * A standalone kind signature enables polymorphic recursion in types, just like a function type signature enables polymorphic recursion in terms. This obviates the need for CUSKs. * TemplateHaskell AST has been extended with 'KiSigD' to represent standalone kind signatures. * GHCi :info command now prints the kind signature of type constructors: ghci> :info Functor type Functor :: (Type -> Type) -> Constraint ... Limitations ----------- * 'forall'-bound type variables of a standalone kind signature do not scope over the declaration body, even if the -XScopedTypeVariables is enabled. See #16635 and #16734. * Wildcards are not allowed in standalone kind signatures, as partial signatures do not allow for polymorphic recursion. * Associated types may not be given an explicit standalone kind signature. Instead, they are assumed to have a CUSK if the parent class has a standalone kind signature and regardless of the -XCUSKs flag. * Standalone kind signatures do not support multiple names at the moment: type T1, T2 :: Type -> Type -- rejected type T1 = Maybe type T2 = Either String See #16754. * Creative use of equality constraints in standalone kind signatures may lead to GHC panics: type C :: forall (a :: Type) -> a ~ Int => Constraint class C a where f :: C a => a -> Int See #16758. Implementation notes -------------------- * The heart of this patch is the 'kcDeclHeader' function, which is used to kind-check a declaration header against its standalone kind signature. It does so in two rounds: 1. check user-written binders 2. instantiate invisible binders a la 'checkExpectedKind' * 'kcTyClGroup' now partitions declarations into declarations with a standalone kind signature or a CUSK (kinded_decls) and declarations without either (kindless_decls): * 'kinded_decls' are kind-checked with 'checkInitialKinds' * 'kindless_decls' are kind-checked with 'getInitialKinds' * DerivInfo has been extended with a new field: di_scoped_tvs :: ![(Name,TyVar)] These variables must be added to the context in case the deriving clause references tcTyConScopedTyVars. See #16731. - - - - - 4f81fab0 by Ryan Scott at 2019-09-26T14:04:38-04:00 Make -fbyte-code prevent unboxed tuples/sums from implying object code (#16876) This resolves #16876 by making the explicit use of `-fbyte-code` prevent code that enables `UnboxedTuples` or `UnboxedSums` from automatically compiling to object code. This allows for a nice middle ground where most code that enables `UnboxedTuples`/-`Sums` will still benefit from automatically enabling `-fobject-code`, but allows power users who wish to avoid this behavior in certain corner cases (such as `lens`, whose use case is documented in #16876) to do so. Along the way, I did a little cleanup of the relevant code and documentation: * `enableCodeGenForUnboxedTuples` was only checking for the presence of `UnboxedTuples`, but `UnboxedSums` has the same complications. I fixed this and renamed the function to `enableCodeGenForUnboxedTuplesOrSums`. * I amended the users' guide with a discussion of these issues. - - - - - 289fc8da by Sebastian Graf at 2019-09-27T22:10:17-04:00 PmCheck: Elaborate what 'model' means in the user guide [skip ci] - - - - - 9c02a793 by Ron Mordechai at 2019-09-27T22:11:06-04:00 Allow users to disable Unicode with an env var Unicode renders funny on my terminal and I like to avoid it where possible. Most applications which print out non-ascii characters allow users to disable such prints with an environment variable (e.g. Homebrew). This diff disables Unicode usage when the environment variable `GHC_NO_UNICODE` is set. To test, set the env var and compile a bad program. Note that GHC does not print Unicode bullets but instead prints out asterisks: ``` $ GHC_NO_UNICODE= _build/stage1/bin/ghc ../Temp.hs [1 of 1] Compiling Temp ( ../Temp.hs, ../Temp.o ) ../Temp.hs:4:23: error: * Couldn't match type `Bool' with `a -> Bool' Expected type: Bool -> a -> Bool Actual type: Bool -> Bool * In the first argument of `foldl', namely `(&& (flip $ elem u))' In the expression: foldl (&& (flip $ elem u)) True v In an equation for `isPermut': isPermut u v = foldl (&& (flip $ elem u)) True v * Relevant bindings include v :: [a] (bound at ../Temp.hs:4:12) u :: [a] (bound at ../Temp.hs:4:10) isPermut :: [a] -> [a] -> Bool (bound at ../Temp.hs:4:1) | 4 | isPermut u v = foldl (&& (flip $ elem u)) True v | ^^^^^^^^^^^^^^^^^^ ``` (Broken code taken from Stack Overflow) - - - - - 144abba3 by Ben Gamari at 2019-09-27T22:11:53-04:00 configure: Don't depend upon alex in source dist build This fixes #16860 by verifying that the generated sources don't already exist before asserting that the `alex` executable was found. This replicates the logic already used for `happy` in the case of `alex`. - - - - - c6fb913c by John Ericson at 2019-09-27T22:12:35-04:00 Just get RTS libs from its package conf `rts.conf` already contains this exact information in its `extra-libraries` stanza. - - - - - f07862b4 by Ben Gamari at 2019-09-27T22:13:16-04:00 ghc-prim: Fix documentation of Type As pointed out in #17243, `Type` is not the only kind having values. - - - - - 0201d0bf by chris-martin at 2019-09-27T22:14:00-04:00 Clarify the purpose and status of the GHC.TypeLits module - - - - - 444e554f by chris-martin at 2019-09-27T22:14:00-04:00 Expand description of DataKinds to mention data constructors, and include mention of TypeError - - - - - 1582dafa by Sebastian Graf at 2019-09-27T22:14:44-04:00 PmCheck: Look at precendence to give type signatures to some wildcards Basically do what we currently only do for -XEmptyCase in other cases where adding the type signature won't distract from pattern matches in other positions. We use the precedence to guide us, equating "need to parenthesise" with "too much noise". - - - - - ad0c4390 by Shayne Fletcher at 2019-09-27T22:15:27-04:00 Add test for expected dependencies of 'Parser' - - - - - 0b1fa64d by Ben Gamari at 2019-09-27T22:16:04-04:00 testsuite: Mark cgrun071 as broken on i386 As described in #17247. - - - - - 24620182 by Daniel Gröber at 2019-09-27T22:17:04-04:00 Raise minimum GHC version to 8.6 commit 795986aaf33e ("Remove unneeded CPP now that GHC 8.6 is the minimum") broke the 8.4 build. - - - - - e0bbb961 by Ben Gamari at 2019-09-27T22:17:44-04:00 testsuite: Mark compact_gc as fragile in the ghci way As noted in #17253. - - - - - bb984ac6 by Ben Gamari at 2019-09-27T22:18:42-04:00 testsuite: Mark hs_try_putmvar003 as fragile in threaded1 Due to #16361. Note that I'm leaving out threaded2 since it's not clear whether the single crash in that way was due to other causes. - - - - - ad2a1f99 by Ben Gamari at 2019-09-27T22:19:26-04:00 testsuite: Mark T3389 as broken in profiled ways on i386 As noted in #17256. - - - - - 6f9fa0be by Ben Gamari at 2019-09-27T22:20:04-04:00 testsuite: Mark TH tests as fragile in LLVM built external-interpreter Due to #16087. This drops the previous explicit list of broken tests and rather encompasses the entire set of tests since they all appear to be broken. - - - - - c5d888d4 by Sebastian Graf at 2019-09-28T17:11:41-04:00 PmCheck: No ConLike instantiation in pmcheck `pmcheck` used to call `refineToAltCon` which would refine the knowledge we had about a variable by equating it to a `ConLike` application. Since we weren't particularly smart about this in the Check module, we simply freshened the constructors existential and term binders utimately through a call to `mkOneConFull`. But that instantiation is unnecessary for when we match against a concrete pattern! The pattern will already have fresh binders and field types. So we don't call `refineToAltCon` from `Check` anymore. Subsequently, we can simplify a couple of call sites and functions in `PmOracle`. Also implementing `computeCovered` becomes viable and we don't have to live with the hack that was `addVarPatVecCt` anymore. A side-effect of not indirectly calling `mkOneConFull` anymore is that we don't generate the proper strict argument field constraints anymore. Instead we now desugar ConPatOuts as if they had bangs on their strict fields. This implies that `PmVar` now carries a `HsImplBang` that we need to respect by a (somewhat ephemeral) non-void check. We fix #17234 in doing so. - - - - - ce64b397 by Sebastian Graf at 2019-09-28T17:12:26-04:00 `exprOkForSpeculation` for Note [IO hack in the demand analyser] In #14998 I realised that the notion of speculative execution *exactly matches* eager evaluation of expressions in a case alternative where the scrutinee is an IO action. Normally we have to `deferIO` any result from that single case alternative to prevent this speculative execution, so we had a special case in place in the demand analyser that would check if the scrutinee was a prim-op, in which case we assumed that it would be ok to do the eager evaluation. Now we just check if the scrutinee is `exprOkForSpeculation`, corresponding to the notion that we want to push evaluation of the scrutinee *after* eagerly evaluating stuff from the case alternative. This fixes #14988, because it resolves the last open Item 4 there. - - - - - f3cb8c7c by Ömer Sinan Ağacan at 2019-09-30T22:39:53-04:00 Refactor iface file generation: This commit refactors interface file generation to allow information from the later passed (NCG, STG) to be stored in interface files. We achieve this by splitting interface file generation into two parts: * Partial interfaces, built based on the result of the core pipeline * A fully instantiated interface, which also contains the final fingerprints and can optionally contain information produced by the backend. This change is required by !1304 and !1530. -dynamic-too handling is refactored too: previously when generating code we'd branch on -dynamic-too *before* code generation, but now we do it after. (Original code written by @AndreasK in !1530) Performance ~~~~~~~~~~~ Before this patch interface files where created and immediately flushed to disk which made space leaks impossible. With this change we instead use NFData to force all iface related data structures to avoid space leaks. In the process of refactoring it was discovered that the code in the ToIface Module allocated a lot of thunks which were immediately forced when writing/forcing the interface file. So we made this module more strict to avoid creating many of those thunks. Bottom line is that allocations go down by about ~0.1% compared to master. Residency is not meaningfully different after this patch. Runtime was not benchmarked. Co-Authored-By: Andreas Klebinger <klebinger.andreas at gmx.at> Co-Authored-By: Ömer Sinan Ağacan <omer at well-typed.com> - - - - - 6a1700aa by Simon Peyton Jones at 2019-09-30T22:40:30-04:00 Fix arguments for unbound binders in RULE application We were failing to correctly implement Note [Unbound RULE binders] in Rules.hs. In particular, when cooking up a fake Refl, were were failing to apply the substitition. This patch fixes that problem, and simultaneously tidies up the impedence mis-match between RuleSubst and TCvSubst. Thanks to Sebastian! - - - - - 97811ef5 by Takenobu Tani at 2019-09-30T22:41:35-04:00 Add help message for GHCi :instances command This commit updates GHCi's help message for GHC 8.10. - - - - - 6f8550a3 by Sebastian Graf at 2019-09-30T22:42:14-04:00 Move pattern match checker modules to GHC.HsToCore.PmCheck - - - - - b36dd49b by Takenobu Tani at 2019-09-30T22:42:53-04:00 testsuite: Add minimal test for :doc command Currently, there are no testcases for GHCi `:doc` command. Perhaps because it was experimental. And it could be changed in the future. But `:doc` command is already useful, so I add a minimal regression test to keep current behavior. See also 85309a3cda for implementation of `:doc` command. - - - - - bdba6ac2 by Vladislav Zavialov at 2019-09-30T22:43:31-04:00 Do not rely on CUSKs in 'base' Use standalone kind signatures instead of complete user-specified kinds in Data.Type.Equality and Data.Typeable - - - - - dbdf6a3d by Ben Gamari at 2019-09-30T22:44:07-04:00 testsuite: Mark T3389 as broken in hpc way on i386 See #17256. - - - - - 822481d5 by Ben Gamari at 2019-09-30T22:44:44-04:00 Bump process submodule Marks process003 as fragile, as noted in #17245. - - - - - 6548b7b0 by Sebastian Graf at 2019-10-01T09:22:10+00:00 Add a bunch of testcases for the pattern match checker Adds regression tests for tickets #17207, #17208, #17215, #17216, #17218, #17219, #17248 - - - - - 58013220 by Sebastian Graf at 2019-10-01T09:22:18+00:00 Add testcases inspired by Luke Maranget's pattern match series In his paper "Warnings for Pattern Matching", Luke Maranget describes three series in his appendix for which GHC's pattern match checker scaled very badly. We mostly avoid this now with !1752. This commit adds regression tests for each of the series. Fixes #17264. - - - - - 9c002177 by Ryan Scott at 2019-10-01T16:24:12-04:00 Refactor some cruft in TcDeriv * `mk_eqn_stock`, `mk_eqn_anyclass`, and `mk_eqn_no_mechanism` all took a continuation of type `DerivSpecMechanism -> DerivM EarlyDerivSpec` to represent its primary control flow. However, in practice this continuation was always instantiated with the `mk_originative_eqn` function, so there's not much point in making this be a continuation in the first place. This patch removes these continuations in favor of invoking `mk_originative_eqn` directly, which is simpler. * There were several parts of `TcDeriv` that took different code paths if compiling an `.hs-boot` file. But this is silly, because ever since 101a8c770b9d3abd57ff289bffea3d838cf25c80 we simply error eagerly whenever attempting to derive any instances in an `.hs-boot` file. This patch removes all of the unnecessary `.hs-boot` code paths, leaving only one (which errors out). * Remove various error continuation arguments from `mk_eqn_stock` and related functions. - - - - - 9a27a063 by David Eichmann at 2019-10-01T16:55:33-04:00 Hadrian: Libffi rule now `produces` dynamic library files. - - - - - 0956c194 by David Eichmann at 2019-10-01T16:55:33-04:00 Hadrian: do not cache GHC configure rule - - - - - 8924224e by Ömer Sinan Ağacan at 2019-10-01T16:55:37-04:00 Make small INLINE functions behave properly Simon writes: Currently we check for a type arg rather than isTyCoArg. This in turn makes INLINE things look bigger than they should be, and stops them being inlined into boring contexts when they perfectly well could be. E.g. f x = g <refl> x {-# INLINE g #-} ... (map (f x) xs) ... The context is boring, so don't inline unconditionally. But f's RHS is no bigger than its call, provided you realise that the coercion argument is ultimately cost-free. This happens in practice for $WHRefl. It's not a big deal: at most it means we have an extra function call overhead. But it's untidy, and actually worse than what happens without an INLINE pragma. Fixes #17182 This makes 0.0% change in nofib binary sizes. - - - - - 53b0c6e0 by Gabor Greif at 2019-10-03T08:15:50-04:00 Typo in comment [ci skip] - - - - - 60229e9e by Ryan Scott at 2019-10-03T12:17:10-04:00 Merge TcTypeableValidity into TcTypeable, document treatment of casts This patch: * Implements a refactoring (suggested in https://gitlab.haskell.org/ghc/ghc/merge_requests/1199#note_207345) that moves all functions from `TcTypeableValidity` back to `TcTypeable`, as the former module doesn't really need to live on its own. * Adds `Note [Typeable instances for casted types]` to `TcTypeable` explaining why the `Typeable` solver currently does not support types containing casts. Resolves #16835. - - - - - 3b9d4907 by Richard Eisenberg at 2019-10-03T12:17:13-04:00 Note [Don't flatten tuples from HsSyn] in MkCore Previously, we would sometimes flatten 1-tuples and sometimes not. This didn't cause damage because there is no way to generate HsSyn with 1-tuples. But, with the upcoming fix to #16881, there will be. Without this patch, obscure lint errors would have resulted. No test case, as there is not yet a way to tickle this. - - - - - 8a254d6b by Ömer Sinan Ağacan at 2019-10-03T12:17:19-04:00 Fix new compact block allocation in allocateForCompact allocateForCompact() is called when nursery of a compact region is full, to add new blocks to the compact. New blocks added to an existing region needs a StgCompactNFDataBlock header, not a StgCompactNFData. This fixes allocateForCompact() so that it now correctly allocates space for StgCompactNFDataBlock instead of StgCompactNFData as before. Fixes #17044. A regression test T17044 added. - - - - - 3c7b172b by James Brock at 2019-10-03T12:17:24-04:00 docs String, hyperlink to Data.List Add a reference to the documentation for Data.List in the description for String. On the generated Haddock for Data.String, http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-String.html there is curently no hyperlink to Data.List, which is where a reader will find most of the useful functions which can operate on Strings. I imagine this has confused beginners who came to this page looking for String operations. - - - - - 67bf734c by John Ericson at 2019-10-03T12:17:28-04:00 Add `module {-# SOURCE #-} Foo` syntax for hs-boot in bkp This is a good convenience for testing. - - - - - 6655ec73 by Richard Eisenberg at 2019-10-03T12:17:30-04:00 Improve documentation around empty tuples/lists This patch also changes the way we handle empty lists, simplifying them somewhat. See Note [Empty lists]. Previously, we had to special-case empty lists in the type-checker. Now no more! Finally, this patch improves some documentation around the ir_inst field used in the type-checker. This breaks a test case, but I really think the problem is #17251, not really related to this patch. Test case: typecheck/should_compile/T13680 - - - - - 9a4ff210 by John Ericson at 2019-10-03T12:17:31-04:00 Make Haddock submodule remote point to gitlab mirror This makes it match the others - - - - - cb364bc2 by Ben Gamari at 2019-10-03T12:17:32-04:00 testsuite: Mark print037 as fragile, not broken See #16205. - - - - - 259f4dff by Ben Gamari at 2019-10-03T12:17:32-04:00 Exclude rts.cabal from source distributions This modifies both the Hadrian and make build systems to avoid included the rts.cabal generated by autoconf in the source distribution. Fixes #17265. - - - - - e4c93896 by Ben Gamari at 2019-10-03T12:17:32-04:00 DynFlags: Only warn when split-sections is ignored Previously we would throw an error which seems a bit harsh. As reported in #17283. - - - - - ee6324ad by Tobias Guggenmos at 2019-10-03T12:17:33-04:00 Improve documentation for runtime debugging flags - - - - - 47386fe8 by Tobias Guggenmos at 2019-10-03T12:17:33-04:00 Add new debug flag -DZ Zeros heap memory after gc freed it. - - - - - d0924b15 by Stefan Schulze Frielinghaus at 2019-10-03T12:17:34-04:00 Extend argument of createIOThread to word size Function createIOThread expects its second argument to be of size word. The natural size of the second parameter is 32bits. Thus for some 64bit architectures, where a write of the lower half of a register does not clear the upper half, the value must be zero extended. - - - - - 1357d023 by Ben Gamari at 2019-10-03T12:17:34-04:00 rules/haddock: Ensure that RTS stats directory exists It may not exist if the source tarball was extracted yet not the testsuite tarball. - - - - - ec93d2a9 by Fumiaki Kinoshita at 2019-10-04T21:43:49-04:00 Add Monad instances to `(,,) a b` and `(,,,) a b c` - - - - - 05419e55 by John Ericson at 2019-10-04T21:44:29-04:00 Per stage headers, ghc_boot_platform.h -> stage 0 ghcplatform.h The generated headers are now generated per stage, which means we can skip hacks like `ghc_boot_platform.h` and just have that be the stage 0 header as proper. In general, stages are to be embraced: freely generate everything in each stage but then just build what you depend on, and everything is symmetrical and efficient. Trying to avoid stages because bootstrapping is a mind bender just creates tons of bespoke mini-mind-benders that add up to something far crazier. Hadrian was pretty close to this "stage-major" approach already, and so was fairly easy to fix. Make needed more work, however: it did know about stages so at least there was a scaffold, but few packages except for the compiler cared, and the compiler used its own counting system. That said, make and Hadrian now work more similarly, which is good for the transition to Hadrian. The merits of embracing stage aside, the change may be worthy for easing that transition alone. - - - - - 75a5dd8e by John Ericson at 2019-10-04T21:44:29-04:00 Remove {Build,Host}Platform_NAME from header They are only used in a file we construct directly, so just skip CPP. - - - - - b538476b by Daroc Alden at 2019-10-04T21:45:09-04:00 Deprecate -fwarn-hi-shadowing, because it was never implemented and is not used. This fixes #10913. - - - - - dd8f76b2 by John Ericson at 2019-10-04T21:45:48-04:00 Factor out a smaller part of Platform for host fallback - - - - - d15b44d6 by John Ericson at 2019-10-04T21:45:49-04:00 Pull out the settings file parsing code into it's own module. This has two benefits: 1. One less hunk of code dependent on DynFlags 2. Add a little bit of error granularity to distrinugish between missing data and bad data. This could someday be shared with ghc-pkg which aims to work even with a missing file. I also am about to to make --supported-extensions use this too. - - - - - eb892b28 by John Ericson at 2019-10-04T21:45:49-04:00 Add tryFindTopDir to look for the top dir without blowing up if it is not found. - - - - - 0dded5ec by John Ericson at 2019-10-04T21:45:49-04:00 Always enable the external interpreter You can always just not use or even build `iserv`. I don't think the maintenance cost of the CPP is worth...I can't even tell what the benefit is. - - - - - 0d31ccdd by Artem Pyanykh at 2019-10-04T21:46:28-04:00 [linker, macho] Don't map/allocate zero size sections and segments Zero size sections are common even during regular build on MacOS. For instance: ``` $ ar -xv libHSghc-prim-0.6.1.a longlong.o $ otool -l longlong.o longlong.o: Mach header magic cputype cpusubtype caps filetype ncmds sizeofcmds flags 0xfeedfacf 16777223 3 0x00 1 2 176 0x00002000 Load command 0 cmd LC_SEGMENT_64 cmdsize 152 segname vmaddr 0x0000000000000000 vmsize 0x0000000000000000 <-- segment size = 0 fileoff 208 filesize 0 maxprot 0x00000007 initprot 0x00000007 nsects 1 flags 0x0 Section sectname __text segname __TEXT addr 0x0000000000000000 size 0x0000000000000000 <-- section size = 0 offset 208 align 2^0 (1) reloff 0 nreloc 0 flags 0x80000000 reserved1 0 reserved2 0 cmd LC_BUILD_VERSION cmdsize 24 platform macos sdk 10.14 minos 10.14 ntools 0 ``` The issue of `mmap`ing 0 bytes was resolved in !1050, but the problem remained. These 0 size segments and sections were still allocated in object code, which lead to failed `ASSERT(size > 0)` in `addProddableBlock` further down the road. With this change zero size segments **and** sections are not mapped/allocated at all. Test plan: 1. Build statically linked GHC. 2. Run `ghc --interactive`. Observe that REPL loads successfully (which was not the case before). 3. Load several more compiled hs files into repl. No failures. - - - - - 93f02b62 by Roland Senn at 2019-10-04T21:47:07-04:00 New fix for #11647. Avoid side effects like #17171 If a main module doesn't contain a header, we omit the check whether the main module is exported. With this patch GHC, GHCi and runghc use the same code. - - - - - 8039b625 by Matthew Bauer at 2019-10-04T21:47:47-04:00 Add musl systems to llvm-targets This was done in Nixpkgs, but never upstreamed. Musl is pretty much the same as gnu, but with a different libc. I’ve used the same values for everything. - - - - - ee8118ca by John Ericson at 2019-10-05T00:11:58-04:00 Clean up `#include`s in the compiler - Remove unneeded ones - Use <..> for inter-package. Besides general clean up, helps distinguish between the RTS we link against vs the RTS we compile for. - - - - - 241921a0 by Ben Gamari at 2019-10-05T19:18:40-04:00 rts: Fix CNF dirtying logic Previously due to a silly implementation bug CNFs would never have their dirty flag set, resulting in their being added again and again to the `mut_list`. Fix this. Fixes #17297. - - - - - 825c108b by Ryan Scott at 2019-10-07T12:00:59-04:00 Only flatten up to type family arity in coreFlattenTyFamApp (#16995) Among other uses, `coreFlattenTyFamApp` is used by Core Lint as a part of its check to ensure that each type family axiom reduces according to the way it is defined in the source code. Unfortunately, the logic that `coreFlattenTyFamApp` uses to flatten type family applications disagreed with the logic in `TcFlatten`, which caused it to spuriously complain this program: ```hs type family Param :: Type -> Type type family LookupParam (a :: Type) :: Type where LookupParam (f Char) = Bool LookupParam x = Int foo :: LookupParam (Param ()) foo = 42 ``` This is because `coreFlattenTyFamApp` tries to flatten the `Param ()` in `LookupParam (Param ())` to `alpha` (where `alpha` is a flattening skolem), and GHC is unable to conclude that `alpha` is apart from `f Char`. This patch spruces up `coreFlattenTyFamApp` so that it instead flattens `Param ()` to `alpha ()`, which GHC _can_ know for sure is apart from `f Char`. See `Note [Flatten], wrinkle 3` in `FamInstEnv`. - - - - - b2577081 by Ben Gamari at 2019-10-07T12:01:46-04:00 Refactor, document, and optimize LLVM configuration loading As described in the new Note [LLVM Configuration] in SysTools, we now load llvm-targets and llvm-passes lazily to avoid the overhead of doing so when -fllvm isn't used (also known as "the common case"). Noticed in #17003. Metric Decrease: T12234 T12150 - - - - - 93c71ae6 by Ben Gamari at 2019-10-07T12:02:23-04:00 configure: Determine library versions of template-haskell, et al. These are needed by the user guide documentation. Fixes #17260. - - - - - b7890611 by Andrey Mokhov at 2019-10-07T12:03:13-04:00 Hadrian: Stop using in-tree Cabal - - - - - 0ceb98f6 by Andrey Mokhov at 2019-10-07T12:03:13-04:00 Switch to cabal-version=3.0 in ghc-heap.cabal - - - - - e3418e96 by Andrey Mokhov at 2019-10-07T12:03:13-04:00 Switch to cabal-version=3.0 in base.cabal and rts.cabal - - - - - 805653f6 by John Ericson at 2019-10-07T12:04:19-04:00 Get rid of wildcard patterns in prim Cmm emitting code This way, we can be sure we don't miss a case. - - - - - ab945819 by Ryan Scott at 2019-10-07T12:05:09-04:00 Refactor some cruft in TcGenGenerics * `foldBal` contains needless partiality that can easily be avoided. * `mkProd_E` and `mkProd_P` both contain unique supply arguments that are completely unused, which can be removed. - - - - - d0edba3a by John Ericson at 2019-10-07T12:05:47-04:00 Remove CONFIGURE_ARGS from configure.ac It looks like it's been unused since at least 34cc75e1a62638f2833815746ebce0a9114dc26b. - - - - - 9a6bfb0a by John Ericson at 2019-10-07T12:06:26-04:00 Keep OSTYPE local to configure.ac Unused outside it since b6be81b841e34ca45b3549c4c79e886a8761e59a. - - - - - 4df39fd0 by John Ericson at 2019-10-07T12:07:08-04:00 Get rid of GHC_PACKAGE_DB_FLAG We no longer support booting from older GHC since 527bcc41630918977c73584d99125ff164400695. - - - - - 31a29a7a by John Ericson at 2019-10-07T12:07:46-04:00 Remove GhcLibsWithUnix d679ca43e7477284d733b94ff542be5363be3353 meant to remove it but did not finish the job. - - - - - 77ca39e3 by Ben Gamari at 2019-10-08T05:11:03-04:00 gitlab-ci: Add missing TEST_ENV variables This should fix #16985. - - - - - 9a2798e1 by Ben Gamari at 2019-10-08T05:11:03-04:00 hadrian: Add `validate` and `slow validate` flavours - - - - - ab311696 by Ben Gamari at 2019-10-08T05:11:03-04:00 validate: Use Hadrian's validate flavour - - - - - 98179a77 by Ben Gamari at 2019-10-08T05:11:03-04:00 gitlab-ci: Use validate flavour in hadrian builds - - - - - 8af9eba8 by Ben Gamari at 2019-10-08T05:11:40-04:00 base: Document the fact that Typeable is automatically "derived" This fixes #17060. - - - - - 397c6ed5 by Sebastian Graf at 2019-10-08T05:12:15-04:00 PmCheck: Identify some semantically equivalent expressions By introducing a `CoreMap Id` to the term oracle, we can represent syntactically equivalent expressions by the same `Id`. Combine that with `CoreOpt.simpleCoreExpr` and it might even catch non-trivial semantic equalities. Unfortunately due to scoping issues, this will not solve #17208 for view patterns yet. - - - - - 8a2e8408 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Refer to language extension flags via :extension: Previously several were referred to via :ghc-flag:`-X...`. - - - - - 7cd54538 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Make reverse flags addressable via :ghc-flag: Previously one could not easily link to the :reverse: flag of a ghc-flag. - - - - - e9813afc by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Document -XHaskell98 and -XHaskell2010 - - - - - eaeb28a1 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Fix various warnings - - - - - 180cf177 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Document NondecreasingIndentation - - - - - 0a26f9e8 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Document -fworker-wrapper - - - - - ca4791db by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Rework pragma key generation Previously we had a hack to handle the case of multi-token SPECIALISE pragmas. Now we use a slightly more general rule of using a prefix of tokens containing only alphabetical characters. - - - - - 98c09422 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Run sphinx in nit-picky mode This ensure that it blurts an error on missing references. - - - - - a95f7185 by Ben Gamari at 2019-10-08T05:12:58-04:00 doc: Write out documented flag list - - - - - 9402608e by Ben Gamari at 2019-10-08T05:12:58-04:00 gitlab-ci: Check coverage of GHC flags in users guide This ensures that all GHC flags are documented during the documentation build. Fixes #17315. - - - - - 9ac3bcbb by Andrew Martin at 2019-10-08T13:24:52-04:00 Document the UnliftedFFITypes extension. - - - - - 77f3ba23 by Andrew Martin at 2019-10-08T13:24:52-04:00 Rephrase a bunch of things in the unlifted ffi types documentation. Add a section on pinned byte arrays. - - - - - a70db7bf by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] link to foreign cmm call - - - - - 0d413259 by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] make the table better - - - - - 0c7a5bcd by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] can not -> may not - - - - - 6a5c249d by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] clarify what unsound means - - - - - bf02c264 by Ryan Scott at 2019-10-08T13:25:37-04:00 Mark newtype constructors as used in the Coercible solver (#10347) Currently, newtype constructors are not marked as used when they are accessed under the hood by uses of `coerce`, as described in #10347. This fixes #10347 by co-opting the `tcg_keep` field of `TcGblEnv` to track uses of newtype constructors in the `Coercible` solver. See `Note [Tracking unused binding and imports]` in `TcRnTypes`. Since #10347 is fixed, I was able to simplify the code in `TcDeriv` slightly, as the hack described in `Note [Newtype deriving and unused constructors]` is no longer necessary. - - - - - 9612e91c by Richard Eisenberg at 2019-10-08T13:26:20-04:00 Solve constraints from top-level groups sooner Previously, all constraints from all top-level groups (as separated by top-level splices) were lumped together and solved at the end. This could leak metavariables to TH, though, and that's bad. This patch solves each group's constraints before running the next group's splice. Naturally, we now report fewer errors in some cases. One nice benefit is that this also fixes #11680, but in a much simpler way than the original fix for that ticket. Admittedly, the error messages degrade just a bit from the fix from #11680 (previously, we informed users about variables that will be brought into scope below a top-level splice, and now we just report an out-of-scope error), but the amount of complexity required throughout GHC to get that error was just not worth it. This patch thus reverts much of f93c9517a2c6e158e4a5c5bc7a3d3f88cb4ed119. Fixes #16980 Test cases: th/T16980{,a} - - - - - c2d4011c by Vladislav Zavialov at 2019-10-08T13:27:12-04:00 Bump array and haddock submodules - - - - - f691f0c2 by Sebastian Graf at 2019-10-08T13:27:49-04:00 PmCheck: Look up parent data family TyCon when populating `PossibleMatches` The vanilla COMPLETE set is attached to the representation TyCon of a data family instance, whereas the user-defined COMPLETE sets are attached to the parent data family TyCon itself. Previously, we weren't trying particularly hard to get back to the representation TyCon to the parent data family TyCon, resulting in bugs like #17207. Now we should do much better. Fixes the original issue in #17207, but I found another related bug that isn't so easy to fix. - - - - - 0c0a15a8 by Ben Gamari at 2019-10-09T16:21:14-04:00 Rename STAGE macro to GHC_STAGE To avoid polluting the macro namespace - - - - - 63a5371d by Ben Gamari at 2019-10-09T16:21:14-04:00 Relayout generated header body - - - - - 817c1a94 by Ben Gamari at 2019-10-09T16:21:14-04:00 Define GHC_STAGE in headers instead of command-line - - - - - 5f2c49d8 by Ben Gamari at 2019-10-09T16:21:14-04:00 Remove GHC_STAGE guards from MachDeps This allows the stage1 compiler (which needs to run on the build platform and produce code for the host) to depend upon properties of the target. This is wrong. However, it's no more wrong than it was previously and @Erichson2314 is working on fixing this so I'm going to remove the guard so we can finally bootstrap HEAD with ghc-8.8 (see issue #17146). - - - - - 35cc5eff by Ben Gamari at 2019-10-09T16:21:15-04:00 Test - - - - - d584e3f0 by Ryan Scott at 2019-10-09T16:21:50-04:00 Use addUsedDataCons more judiciously in TcDeriv (#17324) If you derive an instance like this: ```hs deriving <...> instance Foo C ``` And the data constructors for `C` aren't in scope, then `doDerivInstErrorChecks1` throws an error. Moreover, it will _only_ throw an error if `<...>` is either `stock` or `newtype`. This is because the code that the `anyclass` or `via` strategies would generate would not require the use of the data constructors for `C`. However, `doDerivInstErrorChecks1` has another purpose. If you write this: ```hs import M (C(MkC1, ..., MkCn)) deriving <...> instance Foo C ``` Then `doDerivInstErrorChecks1` will call `addUsedDataCons` on `MkC1` through `MkCn` to ensure that `-Wunused-imports` does not complain about them. However, `doDerivInstErrorChecks1` was doing this for _every_ deriving strategy, which mean that if `<...>` were `anyclass` or `via`, then the warning about `MkC1` through `MkCn` being unused would be suppressed! The fix is simple enough: only call `addUsedDataCons` when the strategy is `stock` or `newtype`, just like the other code paths in `doDerivInstErrorChecks1`. Fixes #17324. - - - - - 30f5ac07 by Sebastian Graf at 2019-10-11T22:10:12-04:00 Much simpler language for PmCheck Simon realised that the simple language composed of let bindings, bang patterns and flat constructor patterns is enough to capture the semantics of the source pattern language that are important for pattern-match checking. Well, given that the Oracle is smart enough to connect the dots in this less informationally dense form, which it is now. So we transform `translatePat` to return a list of `PmGrd`s relative to an incoming match variable. `pmCheck` then trivially translates each of the `PmGrd`s into constraints that the oracle understands. Since we pass in the match variable, we incidentally fix #15884 (coverage checks for view patterns) through an interaction with !1746. - - - - - 166e1c2a by Stefan Schulze Frielinghaus at 2019-10-11T22:10:51-04:00 Hadrian: Take care of assembler source files Fixes #17286. - - - - - c2290596 by John Ericson at 2019-10-12T06:32:18-04:00 Simplify Configure in a few ways - No need to distinguish between gcc-llvm and clang. First of all, gcc-llvm is quite old and surely unmaintained by now. Second of all, none of the code actually care about that distinction! Now, it does make sense to consider C multiple frontends for LLVMs in the form of clang vs clang-cl (same clang, yes, but tweaked interface). But this is better handled in terms of "gccish vs mvscish" and "is LLVM", yielding 4 combinations. Therefore, I don't think it is useful saving the existing code for that. - Get the remaining CC_LLVM_BACKEND, and also TABLES_NEXT_TO_CODE in mk/config.h the normal way, rather than hacking it post-hoc. No point keeping these special cases around for now reason. - Get rid of hand-rolled `die` function and just use `AC_MSG_ERROR`. - Abstract check + flag override for unregisterised and tables next to code. Oh, and as part of the above I also renamed/combined some variables where it felt appropriate. - GccIsClang -> CcLlvmBackend. This is for `AC_SUBST`, like the other Camal case ones. It was never about gcc-llvm, or Apple's renamed clang, to be clear. - llvm_CC_FLAVOR -> CC_LLVM_BACKEND. This is for `AC_DEFINE`, like the other all-caps snake case ones. llvm_CC_FLAVOR was just silly indirection *and* an odd name to boot. - - - - - f1ce3535 by Vladislav Zavialov at 2019-10-12T06:33:05-04:00 Escape stats file command (#13676) - - - - - cd1a8808 by Vladislav Zavialov at 2019-10-12T06:33:05-04:00 Skip T13767 on Darwin The CI job fails with: +++ rts/T13676.run/T13676.run.stderr.normalised 2019-10-09 12:27:56.000000000 -0700 @@ -0,0 +1,4 @@ +dyld: Library not loaded: @rpath/libHShaskeline-0.7.5.0-ghc8.9.0.20191009.dylib + Referenced from: /Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib/bin/ghc + Reason: image not found +*** Exception: readCreateProcess: '/Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib/bin/ghc' '-B/Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib' '-e' ''/''$'/'' == '/''/x0024'/''' +RTS '-tT13676.t' (exit -6): failed Unable to reproduce locally. - - - - - 0a338264 by Ryan Scott at 2019-10-12T06:33:42-04:00 Use newDFunName for both manual and derived instances (#17339) Issue #17339 was caused by using a slightly different version of `newDFunName` for derived instances that, confusingly enough, did not take all arguments to the class into account when generating the `DFun` name. I cannot think of any good reason for doing this, so this patch uses `newDFunName` uniformly for both derived instances and manually written instances alike. Fixes #17339. - - - - - c50e4c92 by Simon Peyton Jones at 2019-10-12T13:35:24-04:00 Fix validity checking for inferred types GHC is suposed to uphold the principle that an /inferred/ type for a let-binding should obey the rules for that module. E.g. we should only accept an inferred higher rank type if we have RankNTypes on. But we were failing to check this: TcValidity.checkValidType allowed arbitrary rank for inferred types. This patch fixes the bug. It might in principle cause some breakage, but if so that's good: the user should add RankNTypes and/or a manual signature. (And almost every package has explicit user signatures for all top-level things anyway.) Let's see. Fixes #17213. Metric Decrease: T10370 - - - - - 226d86d2 by Simon Peyton Jones at 2019-10-12T13:36:02-04:00 Do not add a 'solved dict' for quantified constraints GHC has a wonderful-but-delicate mechanism for building recursive dictionaries by adding a goal to the "solved dictionaries" before solving the sub-goals. See Note [Solved dictionaries] in TcSMonad Ticket #17267 showed that if you use this mechanism for local /quantified/ constraints you can get a loop -- or even unsafe coerce. This patch fixes the bug. Specifically * Make TcSMonad.addSolvedDict be conditional on using a /top level/ instance, not a quantified one. * Moreover, we /also/ don't want to add a solved dict for equalities (a~b). * Add lots more comments to Note [Solved dictionaries] to explain the above cryptic stuff. * Extend InstanceWhat to identify those strange built-in equality instances. A couple of other things along the way * Delete the unused Type.isIPPred_maybe. * Stop making addSolvedDict conditional on not being an impolicit parameter. This comes from way back. But it's irrelevant now because IP dicts are never solved via an instance. - - - - - 5ab1a28d by nineonine at 2019-10-13T06:31:40-04:00 Template Haskell: make unary tuples legal (#16881) - - - - - c1bd07cd by Andreas Klebinger at 2019-10-13T06:32:19-04:00 Fix #17334 where NCG did not properly update the CFG. Statements can change the basic block in which instructions are placed during instruction selection. We have to keep track of this switch of the current basic block as we need this information in order to properly update the CFG. This commit implements this change and fixes #17334. We do so by having stmtToInstr return the new block id if a statement changed the basic block. - - - - - 1eda9f28 by Takenobu Tani at 2019-10-13T19:06:02-04:00 users-guide: Add GHCi's ::<builtin-command> form This commit explicitly adds description about double colon command of GHCi. [skip ci] - - - - - 27145351 by Takenobu Tani at 2019-10-13T19:06:40-04:00 Add GHCi help message for :def! and :: commands - - - - - 78463fc5 by Ryan Scott at 2019-10-14T08:38:36-04:00 Add docs/users_guide/.log to .gitignore When the users guide fails to build (as in #17346), a `docs/users_guide/.log` file will be generated with contents that look something like this: ``` WARNING: unknown config value 'latex_paper_size' in override, ignoring /home/rgscott/Software/ghc5/docs/users_guide/ghci.rst:3410: WARNING: u'ghc-flag' reference target not found: -pgmo ?option? /home/rgscott/Software/ghc5/docs/users_guide/ghci.rst:3410: WARNING: u'ghc-flag' reference target not found: -pgmo ?port? Encoding error: 'ascii' codec can't encode character u'\u27e8' in position 132: ordinal not in range(128) The full traceback has been saved in /tmp/sphinx-err-rDF2LX.log, if you want to report the issue to the developers. ``` This definitely should not be checked in to version control, so let's add this to `.gitignore`. - - - - - 4aba72d6 by Ryan Scott at 2019-10-14T08:39:12-04:00 Mention changes from #16980, #17213 in 8.10.1 release notes The fixes for these issues both have user-facing consequences, so it would be good to mention them in the release notes for GHC 8.10.1. While I'm in town, also mention `UnboxedSums` in the release notes entry related to `-fobject-code`. - - - - - 0ca044fd by Ben Gamari at 2019-10-14T08:39:48-04:00 gitlab-ci: Move hadrian-ghc-in-ghci job first This is a very cheap job and can catch a number of "easy" failure modes (e.g. missing imports in the compiler). Let's run it first. - - - - - a2d3594c by Ryan Scott at 2019-10-15T01:35:34-04:00 Refactor some cruft in TcDerivInfer.inferConstraints The latest installment in my quest to clean up the code in `TcDeriv*`. This time, my sights are set on `TcDerivInfer.inferConstraints`, which infers the context for derived instances. This function is a wee bit awkward at the moment: * It's not terribly obvious from a quick glance, but `inferConstraints` is only ever invoked when using the `stock` or `anyclass` deriving strategies, as the code for inferring the context for `newtype`- or `via`-derived instances is located separately in `mk_coerce_based_eqn`. But there's no good reason for things to be this way, so I moved this code from `mk_coerce_based_eqn` to `inferConstraints` so that everything related to inferring instance contexts is located in one place. * In this process, I discovered that the Haddocks for the auxiliary function `inferConstraintsDataConArgs` are completely wrong. It claims that it handles both `stock` and `newtype` deriving, but this is completely wrong, as discussed above—it only handles `stock`. To rectify this, I renamed this function to `inferConstraintsStock` to reflect its actual purpose and created a new `inferConstraintsCoerceBased` function to specifically handle `newtype` (and `via`) deriving. Doing this revealed some opportunities for further simplification: * Removing the context-inference–related code from `mk_coerce_based_eqn` made me realize that the overall structure of the function is basically identical to `mk_originative_eqn`. In fact, I was easily able to combine the two functions into a single `mk_eqn_from_mechanism` function. As part of this merger, I now invoke `atf_coerce_based_error_checks` from `doDerivInstErrorChecks1`. * I discovered that GHC defined this function: ```hs typeToTypeKind = liftedTypeKind `mkVisFunTy` liftedTypeKind ``` No fewer than four times in different modules. I consolidated all of these definitions in a single location in `TysWiredIn`. - - - - - 426b0ddc by Ryan Scott at 2019-10-15T01:36:14-04:00 Don't skip validity checks for built-in classes (#17355) Issue #17355 occurred because the control flow for `TcValidity.check_valid_inst_head` was structured in such a way that whenever it checked a special, built-in class (like `Generic` or `HasField`), it would skip the most important check of all: `checkValidTypePats`, which rejects nonsense like this: ```hs instance Generic (forall a. a) ``` This fixes the issue by carving out `checkValidTypePats` from `check_valid_inst_head` so that `checkValidTypePats` is always invoked. `check_valid_inst_head` has also been renamed to `check_special_inst_head` to reflect its new purpose of _only_ checking for instances headed by special classes. Fixes #17355. - - - - - a55b8a65 by Alp Mestanogullari at 2019-10-15T18:41:18-04:00 iface: export a few more functions from BinIface - - - - - 9c11f817 by Ben Gamari at 2019-10-15T18:41:54-04:00 hadrian: Add support for bindist compressors other than Xz Fixes #17351. - - - - - 535a88e1 by klebinger.andreas at gmx.at at 2019-10-16T07:04:21-04:00 Add loop level analysis to the NCG backend. For backends maintaining the CFG during codegen we can now find loops and their nesting level. This is based on the Cmm CFG and dominator analysis. As a result we can estimate edge frequencies a lot better for methods, resulting in far better code layout. Speedup on nofib: ~1.5% Increase in compile times: ~1.9% To make this feasible this commit adds: * Dominator analysis based on the Lengauer-Tarjan Algorithm. * An algorithm estimating global edge frequences from branch probabilities - In CFG.hs A few static branch prediction heuristics: * Expect to take the backedge in loops. * Expect to take the branch NOT exiting a loop. * Expect integer vs constant comparisons to be false. We also treat heap/stack checks special for branch prediction to avoid them being treated as loops. - - - - - cc2bda50 by adithyaov at 2019-10-16T07:05:01-04:00 Compiling with -S and -fno-code no longer panics (fixes #17143) - - - - - 19641957 by Takenobu Tani at 2019-10-16T07:05:41-04:00 testsuite: Add test for #8305 This is a test for the current algorithm of GHCi command name resolution. I add this test in preparation for updating GHCi command name resolution. For the current algorithm, see https://downloads.haskell.org/ghc/latest/docs/html/users_guide/ghci.html#the-ghci-files - - - - - 6ede3554 by Sebastian Graf at 2019-10-16T07:06:20-04:00 Infer rho-types instead of sigma-types in guard BindStmts and TransStmts In #17343 we saw that we didn't handle the pattern guard `!_ <- undefined` correctly: The `undefined` was never evaluated. Indeed, elaboration failed to insert the invisible type aruments to `undefined`. So `undefined` was trivially a normal-form and in turn never entered. The problem is that we used to infer a sigma-type for the RHS of the guard, the leading qualifiers of which will never be useful in a pattern match situation. Hence we infer a rho-type now. Fixes #17343. - - - - - 798037a1 by John Ericson at 2019-10-16T07:06:58-04:00 Delete ghctags cabal file It came back to life in 381c3ae31b68019177f1cd20cb4da2f9d3b7d6c6 by mistake. - - - - - 51fad9e6 by Richard Eisenberg at 2019-10-16T15:58:58-04:00 Break up TcRnTypes, among other modules. This introduces three new modules: - basicTypes/Predicate.hs describes predicates, moving this logic out of Type. Predicates don't really exist in Core, and so don't belong in Type. - typecheck/TcOrigin.hs describes the origin of constraints and types. It was easy to remove from other modules and can often be imported instead of other, scarier modules. - typecheck/Constraint.hs describes constraints as used in the solver. It is taken from TcRnTypes. No work other than module splitting is in this patch. This is the first step toward homogeneous equality, which will rely more strongly on predicates. And homogeneous equality is the next step toward a dependently typed core language. - - - - - 11d4fc50 by Ben Gamari at 2019-10-16T15:59:52-04:00 hadrian: Introduce enableDebugInfo flavour transformer Also refactor things a bit to eliminate repetition. - - - - - deb96399 by Ryan Scott at 2019-10-16T16:00:29-04:00 Make Coverage.TM a newtype - - - - - 42ebc3f6 by Brian Wignall at 2019-10-16T16:01:06-04:00 Add hyperlinks to PDF/HTML documentation; closes #17342 - - - - - b15a7fb8 by Ben Gamari at 2019-10-17T01:03:11-04:00 testsuite: Ensure that makefile tests get run Previously `makefile_test` and `run_command` tests could easily end up in a situation where they wouldn't be run if the user used the `only_ways` modifier. The reason is to build the set of a ways to run the test in we first start with a candidate set determined by the test type (e.g. `makefile_test`, `compile_run`, etc.) and then filter that set with the constraints given by the test's modifiers. `makefile_test` and `run_command` tests' candidate sets were simply `{normal}`, and consequently most uses of `only_ways` would result in the test being never run. To avoid this we rather use all ways as the candidate sets for these test types. This may result in a few more testcases than we would like (given that some `run_command` tests are insensitive to way) but this can be fixed by adding modifiers and we would much rather run too many tests than too few. This fixes #16042 and a number of other tests afflicted by the same issue. However, there were a few cases that required special attention: * `T14028` is currently failing and is therefore marked as broken due to #17300 * `T-signals-child` is fragile in the `threaded1` and `threaded2` ways (tracked in #17307) - - - - - 4efdda90 by Richard Eisenberg at 2019-10-17T01:03:51-04:00 Tiny fixes to comments around flattening. - - - - - c4c9904b by Ben Gamari at 2019-10-17T01:04:26-04:00 testsuite: Assert that testsuite ways are known This ensures that all testsuite way names given to `omit_ways`, `only_ways`, etc. are known ways. - - - - - 697be2b6 by Ömer Sinan Ağacan at 2019-10-18T15:26:53-04:00 rts/GC: Add an obvious assertion during block initialization Namely ensure that block descriptors are initialized with valid generation numbers. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 61d2ed42 by Ben Gamari at 2019-10-18T15:26:53-04:00 rts: Add Note explaining applicability of selector optimisation depth limit This was slightly non-obvious so a note seems deserved. - - - - - 11395037 by Ben Gamari at 2019-10-18T15:26:53-04:00 rts/Capability: A few documentation comments - - - - - 206f782a by Ben Gamari at 2019-10-18T15:26:53-04:00 rts: Give stack flags proper macros This were previously quite unclear and will change a bit under the non-moving collector so let's clear this up now. - - - - - 81d4675e by Ben Gamari at 2019-10-18T15:26:53-04:00 rts/GC: Refactor gcCAFs - - - - - 4d674c4e by Ben Gamari at 2019-10-18T15:26:53-04:00 rts: Fix macro parenthesisation - - - - - bfcafd39 by Ben Gamari at 2019-10-18T15:27:42-04:00 rts/Schedule: Allow synchronization without holding a capability The concurrent mark-and-sweep will be performed by a GHC task which will not hold a capability. This is necessary to avoid a concurrent mark from interfering with minor generation collections. However, the major collector must synchronize with the mutators at the end of marking to flush their update remembered sets. This patch extends the `requestSync` mechanism used to synchronize garbage collectors to allow synchronization without holding a capability. This change is fairly straightforward as the capability was previously only required for two reasons: 1. to ensure that we don't try to re-acquire a capability that we the sync requestor already holds. 2. to provide a way to suspend and later resume the sync request if there is already a sync pending. When synchronizing without holding a capability we needn't worry about consideration (1) at all. (2) is slightly trickier and may happen, for instance, when a capability requests a minor collection and shortly thereafter the non-moving mark thread requests a post-mark synchronization. In this case we need to ensure that the non-moving mark thread suspends his request until after the minor GC has concluded to avoid dead-locking. For this we introduce a condition variable, `sync_finished_cond`, which a non-capability-bearing requestor will wait on and which is signalled after a synchronization or GC has finished. - - - - - 921e4e36 by Ömer Sinan Ağacan at 2019-10-18T15:27:56-04:00 rts/BlockAlloc: Allow aligned allocation requests This implements support for block group allocations which are aligned to an integral number of blocks. This will be used by the nonmoving garbage collector, which uses the block allocator to allocate the segments which back its heap. These segments are a fixed number of blocks in size, with each segment being aligned to the segment size boundary. This allows us to easily find the segment metadata stored at the beginning of the segment. - - - - - 4b431f33 by Tamar Christina at 2019-10-20T16:21:10+01:00 Windows: Update tarballs to GCC 9.2 and remove MAX_PATH limit. - - - - - 8057ac96 by Ben Gamari at 2019-10-20T21:15:14-04:00 Merge branches 'wip/gc/sync-without-capability' and 'wip/gc/aligned-block-allocation' into wip/gc/preparation - - - - - 32500f64 by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00 rts/StableName: Expose FOR_EACH_STABLE_NAME, freeSnEntry, SNT_size These will be needed when we implement sweeping in the nonmoving collector. - - - - - 4be5152a by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Disable aggregate-return warnings from gcc This warning is a bit of a relic; there is little reason to avoid aggregate return values in 2019. - - - - - 04471c4f by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00 rts/Scav: Expose scavenging functions To keep the non-moving collector nicely separated from the moving collector its scavenging phase will live in another file, `NonMovingScav.c`. However, it will need to use these functions so let's expose them. - - - - - 6ff29c06 by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Introduce flag to enable the nonmoving old generation This flag will enable the use of a non-moving oldest generation. - - - - - b3ef2d1a by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Introduce debug flag for non-moving GC - - - - - 68e0647f by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00 rts: Non-concurrent mark and sweep This implements the core heap structure and a serial mark/sweep collector which can be used to manage the oldest-generation heap. This is the first step towards a concurrent mark-and-sweep collector aimed at low-latency applications. The full design of the collector implemented here is described in detail in a technical note B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell Compiler" (2018) The basic heap structure used in this design is heavily inspired by K. Ueno & A. Ohori. "A fully concurrent garbage collector for functional programs on multicore processors." /ACM SIGPLAN Notices/ Vol. 51. No. 9 (presented by ICFP 2016) This design is intended to allow both marking and sweeping concurrent to execution of a multi-core mutator. Unlike the Ueno design, which requires no global synchronization pauses, the collector introduced here requires a stop-the-world pause at the beginning and end of the mark phase. To avoid heap fragmentation, the allocator consists of a number of fixed-size /sub-allocators/. Each of these sub-allocators allocators into its own set of /segments/, themselves allocated from the block allocator. Each segment is broken into a set of fixed-size allocation blocks (which back allocations) in addition to a bitmap (used to track the liveness of blocks) and some additional metadata (used also used to track liveness). This heap structure enables collection via mark-and-sweep, which can be performed concurrently via a snapshot-at-the-beginning scheme (although concurrent collection is not implemented in this patch). The mark queue is a fairly straightforward chunked-array structure. The representation is a bit more verbose than a typical mark queue to accomodate a combination of two features: * a mark FIFO, which improves the locality of marking, reducing one of the major overheads seen in mark/sweep allocators (see [1] for details) * the selector optimization and indirection shortcutting, which requires that we track where we found each reference to an object in case we need to update the reference at a later point (e.g. when we find that it is an indirection). See Note [Origin references in the nonmoving collector] (in `NonMovingMark.h`) for details. Beyond this the mark/sweep is fairly run-of-the-mill. [1] R. Garner, S.M. Blackburn, D. Frampton. "Effective Prefetch for Mark-Sweep Garbage Collection." ISMM 2007. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - c7e73d12 by Ben Gamari at 2019-10-20T21:15:37-04:00 testsuite: Add nonmoving WAY This simply runs the compile_and_run tests with `-xn`, enabling the nonmoving oldest generation. - - - - - f8f77a07 by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Mark binder as const - - - - - bd8e3ff4 by Ben Gamari at 2019-10-20T21:15:52-04:00 rts: Implement concurrent collection in the nonmoving collector This extends the non-moving collector to allow concurrent collection. The full design of the collector implemented here is described in detail in a technical note B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell Compiler" (2018) This extension involves the introduction of a capability-local remembered set, known as the /update remembered set/, which tracks objects which may no longer be visible to the collector due to mutation. To maintain this remembered set we introduce a write barrier on mutations which is enabled while a concurrent mark is underway. The update remembered set representation is similar to that of the nonmoving mark queue, being a chunked array of `MarkEntry`s. Each `Capability` maintains a single accumulator chunk, which it flushed when it (a) is filled, or (b) when the nonmoving collector enters its post-mark synchronization phase. While the write barrier touches a significant amount of code it is conceptually straightforward: the mutator must ensure that the referee of any pointer it overwrites is added to the update remembered set. However, there are a few details: * In the case of objects with a dirty flag (e.g. `MVar`s) we can exploit the fact that only the *first* mutation requires a write barrier. * Weak references, as usual, complicate things. In particular, we must ensure that the referee of a weak object is marked if dereferenced by the mutator. For this we (unfortunately) must introduce a read barrier, as described in Note [Concurrent read barrier on deRefWeak#] (in `NonMovingMark.c`). * Stable names are also a bit tricky as described in Note [Sweeping stable names in the concurrent collector] (`NonMovingSweep.c`). We take quite some pains to ensure that the high thread count often seen in parallel Haskell applications doesn't affect pause times. To this end we allow thread stacks to be marked either by the thread itself (when it is executed or stack-underflows) or the concurrent mark thread (if the thread owning the stack is never scheduled). There is a non-trivial handshake to ensure that this happens without racing which is described in Note [StgStack dirtiness flags and concurrent marking]. Co-Authored-by: Ömer Sinan Ağacan <omer at well-typed.com> - - - - - dd1b4fdd by Ben Gamari at 2019-10-20T21:15:52-04:00 Nonmoving: Disable memory inventory with concurrent collection - - - - - 4a44ab33 by Ben Gamari at 2019-10-20T21:15:52-04:00 rts: Shrink size of STACK's dirty and marking fields - - - - - 10373416 by Ben Gamari at 2019-10-20T21:15:52-04:00 Don't cleanup until we've stopped the collector This requires that we break nonmovingExit into two pieces since we need to first stop the collector to relinquish any capabilities, then we need to shutdown the scheduler, then we need to free the nonmoving allocators. - - - - - 26c3827f by Ben Gamari at 2019-10-21T11:43:54-04:00 Nonmoving: Ensure write barrier vanishes in non-threaded RTS - - - - - 17e5a032 by Ben Gamari at 2019-10-21T11:43:54-04:00 ThreadPaused: Add barrer on updated thunk - - - - - 8ea316da by David Eichmann at 2019-10-22T02:07:48-04:00 CI: Always dump performance metrics. - - - - - aa31ceaf by Matthew Bauer at 2019-10-22T02:39:01-04:00 Replace freebsd-gnueabihf with freebsd FreeBSD does not support GNU libc, so it makes no sense to use this triple. Most likely previous builds were just using the FreeBSD libc instead of gnueabihf. To fix this, we should just use armv6-unknown-freebsd and armv7-unknown-freebsd triples. Note that both of these are actually "soft-float", not "hard-float". FreeBSD has never officially released hard-float arm32: https://wiki.freebsd.org/ARMTier1 - - - - - fd8b666a by Stefan Schulze Frielinghaus at 2019-10-22T02:39:03-04:00 Implement s390x LLVM backend. This patch adds support for the s390x architecture for the LLVM code generator. The patch includes a register mapping of STG registers onto s390x machine registers which enables a registerised build. - - - - - 2d2cc76f by Tilman Blumhagen at 2019-10-22T02:39:04-04:00 Documentation for (&&) and (&&) states that they are lazy in their second argument (fixes #17354) - - - - - 06d51c4e by Ben Gamari at 2019-10-22T12:13:36-04:00 Fix unregisterised build This required some fiddling around with the location of forward declarations since the C sources generated by GHC's C backend only includes Stg.h. - - - - - 912e440e by Ben Gamari at 2019-10-22T12:17:00-04:00 rts: Tracing support for nonmoving collection events This introduces a few events to mark key points in the nonmoving garbage collection cycle. These include: * `EVENT_CONC_MARK_BEGIN`, denoting the beginning of a round of marking. This may happen more than once in a single major collection since we the major collector iterates until it hits a fixed point. * `EVENT_CONC_MARK_END`, denoting the end of a round of marking. * `EVENT_CONC_SYNC_BEGIN`, denoting the beginning of the post-mark synchronization phase * `EVENT_CONC_UPD_REM_SET_FLUSH`, indicating that a capability has flushed its update remembered set. * `EVENT_CONC_SYNC_END`, denoting that all mutators have flushed their update remembered sets. * `EVENT_CONC_SWEEP_BEGIN`, denoting the beginning of the sweep portion of the major collection. * `EVENT_CONC_SWEEP_END`, denoting the end of the sweep portion of the major collection. - - - - - 9f42cd81 by Ben Gamari at 2019-10-22T12:17:00-04:00 rts: Introduce non-moving heap census This introduces a simple census of the non-moving heap (not to be confused with the heap census used by the heap profiler). This collects basic heap usage information (number of allocated and free blocks) which is useful when characterising fragmentation of the nonmoving heap. - - - - - 711837cc by Ben Gamari at 2019-10-22T12:17:00-04:00 rts/Eventlog: More descriptive error message - - - - - 0d31819e by Ben Gamari at 2019-10-22T12:17:00-04:00 Allow census without live word count Otherwise the census is unsafe when mutators are running due to concurrent mutation. - - - - - 6f173181 by Ben Gamari at 2019-10-22T12:17:00-04:00 NonmovingCensus: Emit samples to eventlog - - - - - 13dd78dd by Ben Gamari at 2019-10-22T12:18:33-04:00 Nonmoving: Allow aging and refactor static objects logic This commit does two things: * Allow aging of objects during the preparatory minor GC * Refactor handling of static objects to avoid the use of a hashtable - - - - - 7b79e8b4 by Ben Gamari at 2019-10-22T12:18:33-04:00 Disable aging when doing deadlock detection GC - - - - - 8fffe12b by Ben Gamari at 2019-10-22T12:18:33-04:00 More comments for aging - - - - - 039d2906 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Eliminate integer division in nonmovingBlockCount Perf showed that the this single div was capturing up to 10% of samples in nonmovingMark. However, the overwhelming majority of cases is looking at small block sizes. These cases we can easily compute explicitly, allowing the compiler to turn the division into a significantly more efficient division-by-constant. While the increase in source code looks scary, this all optimises down to very nice looking assembler. At this point the only remaining hotspots in nonmovingBlockCount are due to memory access. - - - - - d15ac82d by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Allocate mark queues in larger block groups - - - - - 26d2d331 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMovingMark: Optimize representation of mark queue This shortens MarkQueueEntry by 30% (one word) - - - - - e5eda61e by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Optimize bitmap search during allocation Use memchr instead of a open-coded loop. This is nearly twice as fast in a synthetic benchmark. - - - - - dacf4cae by Ben Gamari at 2019-10-22T12:18:39-04:00 rts: Add prefetch macros - - - - - 786c52d2 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Prefetch when clearing bitmaps Ensure that the bitmap of the segmentt that we will clear next is in cache by the time we reach it. - - - - - 0387df5b by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Inline nonmovingClearAllBitmaps - - - - - e893877e by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Fuse sweep preparation into mark prep - - - - - e6f6823f by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Pre-fetch during mark This improved overall runtime on nofib's constraints test by nearly 10%. - - - - - 56c5ebdc by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Prefetch segment header - - - - - 19bfe460 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Optimise allocator cache behavior Previously we would look at the segment header to determine the block size despite the fact that we already had the block size at hand. - - - - - 53a1a27e by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMovingMark: Eliminate redundant check_in_nonmoving_heaps - - - - - b967e470 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Don't do major GC if one is already running Previously we would perform a preparatory moving collection, resulting in many things being added to the mark queue. When we finished with this we would realize in nonmovingCollect that there was already a collection running, in which case we would simply not run the nonmoving collector. However, it was very easy to end up in a "treadmilling" situation: all subsequent GC following the first failed major GC would be scheduled as major GCs. Consequently we would continuously feed the concurrent collector with more mark queue entries and it would never finish. This patch aborts the major collection far earlier, meaning that we avoid adding nonmoving objects to the mark queue and allowing the concurrent collector to finish. - - - - - 3bc172a4 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Clean mut_list - - - - - 8e79e2a9 by Ben Gamari at 2019-10-22T12:18:39-04:00 Unconditionally flush update remembered set during minor GC Flush the update remembered set. The goal here is to flush periodically to ensure that we don't end up with a thread who marks their stack on their local update remembered set and doesn't flush until the nonmoving sync period as this would result in a large fraction of the heap being marked during the sync pause. - - - - - b281e80b by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Add nonmoving_thr way - - - - - 07987957 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Add nonmoving_thr_ghc way This uses the nonmoving collector when compiling the testcases. - - - - - 01fd0242 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Don't run T15892 in nonmoving ways The nonmoving GC doesn't support `+RTS -G1`, which this test insists on. - - - - - 097f4fd0 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Nonmoving collector doesn't support -G1 - - - - - 4b91dd25 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Ensure that threaded tests are run in nonmoving_thr - - - - - 78ce35b9 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: bug1010 requires -c, which isn't supported by nonmoving - - - - - 6e97cc47 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Skip T15892 in nonmoving_thr_ghc - - - - - 5ce853c8 by Ben Gamari at 2019-10-22T12:18:44-04:00 ghc-heap: Skip heap_all test with debugged RTS The debugged RTS initializes the heap with 0xaa, which breaks the (admittedly rather fragile) assumption that uninitialized fields are set to 0x00: ``` Wrong exit code for heap_all(nonmoving)(expected 0 , actual 1 ) Stderr ( heap_all ): heap_all: user error (assertClosuresEq: Closures do not match Expected: FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 0, code = Nothing}, ptrArgs = [], dataArgs = [0]} Actual: FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 1032832, code = Nothing}, ptrArgs = [], dataArgs = [12297829382473034410]} CallStack (from HasCallStack): assertClosuresEq, called at heap_all.hs:230:9 in main:Main ) ``` - - - - - 6abefce7 by Ben Gamari at 2019-10-22T12:18:44-04:00 Skip ghc_heap_all test in nonmoving ways - - - - - 99baff8c by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Don't run T9630 in nonmoving ways The nonmoving collector doesn't support -G1 - - - - - 25ae8f7d by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Don't run T7160 in nonmoving_thr ways The nonmoving way finalizes things in a different order. - - - - - 8cab149b by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Mark length001 as failing under nonmoving ways This is consistent with the other unoptimized ways. - - - - - 5b130b3d by Ben Gamari at 2019-10-22T12:18:46-04:00 Merge branches 'wip/gc/optimize' and 'wip/gc/test' into wip/gc/everything - - - - - 246ce2af by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00 NonMoving: Implement indirection shortcutting This allows indirection chains residing in the non-moving heap to be shorted-out. - - - - - 875861ef by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00 NonMoving: Implement selector optimisation - - - - - c72e84c6 by Ben Gamari at 2019-10-22T12:20:15-04:00 NonMovingMark: Handle INDs left by shortcutting - - - - - 0f8fd3c6 by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00 NonMoving: Implement -xns to disable selector optimization - - - - - c936a245 by Ben Gamari at 2019-10-22T12:20:37-04:00 NonMoving: Introduce nonmovingSegmentLogBlockSize acccessor This will allow us to easily move the block size elsewhere. - - - - - 6dcef5ee by Ben Gamari at 2019-10-22T12:20:37-04:00 NonMoving: Move block size to block descriptor - - - - - dd8d1b49 by Ben Gamari at 2019-10-22T12:20:37-04:00 NonMoving: Move next_free_snap to block descriptor - - - - - 116e4646 by Ben Gamari at 2019-10-22T12:20:46-04:00 NonMoving: Add summarizing Note - - - - - 22eee2bc by Ben Gamari at 2019-10-22T12:20:48-04:00 Merge branches 'wip/gc/segment-header-to-bdescr' and 'wip/gc/docs' into wip/gc/everything2 - - - - - 3a862703 by Ömer Sinan Ağacan at 2019-10-22T18:56:32-04:00 rts: COMPACT_NFDATA support for the nonmoving collector This largely follows the model used for large objects, with appropriate adjustments made to account for references in the sharing deduplication hashtable. - - - - - 7c35d39b by Ben Gamari at 2019-10-22T18:56:32-04:00 rts: Mark nonmoving GC paths in moving collector as unlikely The expectation here is that the nonmoving GC is latency-centric, whereas the moving GC emphasizes throughput. Therefore we give the latter the benefit of better static branch prediction. - - - - - 91109404 by Ben Gamari at 2019-10-22T18:57:27-04:00 nonmoving: Trace GC preparation steps - - - - - a69b28f4 by Ben Gamari at 2019-10-22T18:57:27-04:00 nonmoving: Don't do two passes over large and compact object lists Previously we would first move the new objects to their appropriate non-moving GC list, then do another pass over that list to clear their mark bits. This is needlessly expensive. First clear the mark bits of the existing objects, then add the newly evacuated objects and, at the same time, clear their mark bits. This cuts the preparatory GC time in half for the Pusher benchmark with a large queue size. - - - - - 984745b0 by Ben Gamari at 2019-10-22T18:57:27-04:00 nonmoving: Upper-bound time we hold SM_MUTEX for during sweep - - - - - 96c5411a by David Feuer at 2019-10-23T05:58:37-04:00 Use an IORef for QSemN Replace the outer `MVar` in `QSemN` with an `IORef`. This should probably be lighter, and it removes the need for `uninterruptibleMask`. Previously Differential Revision https://phabricator.haskell.org/D4896 - - - - - faa30dcb by Andreas Klebinger at 2019-10-23T05:58:43-04:00 Warn about missing profiled libs when using the Interpreter. When GHC itself, or it's interpreter is profiled we need to load profiled libraries as well. This requirement is not always obvious, especially when TH implicilty uses the interpreter. When the libs were not found we fall back to assuming the are in a DLL. This is usually not the case so now we warn users when we do so. This makes it more obvious what is happening and gives users a way to fix the issue. This fixes #17121. - - - - - 1cd3fa29 by Richard Eisenberg at 2019-10-23T05:58:46-04:00 Implement a coverage checker for injectivity This fixes #16512. There are lots of parts of this patch: * The main payload is in FamInst. See Note [Coverage condition for injective type families] there for the overview. But it doesn't fix the bug. * We now bump the reduction depth every time we discharge a CFunEqCan. See Note [Flatten when discharging CFunEqCan] in TcInteract. * Exploration of this revealed a new, easy to maintain invariant for CTyEqCans. See Note [Almost function-free] in TcRnTypes. * We also realized that type inference for injectivity was a bit incomplete. This means we exchanged lookupFlattenTyVar for rewriteTyVar. See Note [rewriteTyVar] in TcFlatten. The new function is monadic while the previous one was pure, necessitating some faff in TcInteract. Nothing too bad. * zonkCt did not maintain invariants on CTyEqCan. It's not worth the bother doing so, so we just transmute CTyEqCans to CNonCanonicals. * The pure unifier was finding the fixpoint of the returned substitution, even when doing one-way matching (in tcUnifyTysWithTFs). Fixed now. Test cases: typecheck/should_fail/T16512{a,b} - - - - - 900cf195 by Alp Mestanogullari at 2019-10-23T05:58:48-04:00 compiler: introduce DynFlags plugins They have type '[CommandLineOpts] -> Maybe (DynFlags -> IO DynFlags)'. All plugins that supply a non-Nothing 'dynflagsPlugin' will see their updates applied to the current DynFlags right after the plugins are loaded. One use case for this is to superseede !1580 for registering hooks from a plugin. Frontend/parser plugins were considered to achieve this but they respectively conflict with how this plugin is going to be used and don't allow overriding/modifying the DynFlags, which is how hooks have to be registered. This commit comes with a test, 'test-hook-plugin', that registers a "fake" meta hook that replaces TH expressions with the 0 integer literal. - - - - - a19c7d17 by Ryan Scott at 2019-10-23T05:58:49-04:00 Reify oversaturated data family instances correctly (#17296) `TcSplice` was not properly handling oversaturated data family instances, such as the example in #17296, as it dropped arguments due to carelessly zipping data family instance arguments with `tyConTyVars`. For data families, the number of `tyConTyVars` can sometimes be less than the number of arguments it can accept in a data family instance due to the fact that data family instances can be oversaturated. To account for this, `TcSplice.mkIsPolyTvs` has now been renamed to `tyConArgsPolyKinded` and now factors in `tyConResKind` in addition to `tyConTyVars`. I've also added `Note [Reified instances and explicit kind signatures]` which explains the various subtleties in play here. Fixes #17296. - - - - - 9b2a5008 by Ben Gamari at 2019-10-23T05:58:50-04:00 testsuite: Don't run T7653 in ghci and profiled ways Currently this routinely fails in the i386 job. See #7653. - - - - - b521e8b6 by Ömer Sinan Ağacan at 2019-10-23T05:58:57-04:00 Refactor Compact.c: - Remove forward declarations - Introduce UNTAG_PTR and GET_PTR_TAG for dealing with pointer tags without having to cast arguments to StgClosure* - Remove dead code - Use W_ instead of StgWord - Use P_ instead of StgPtr - - - - - 17987a4b by Matthew Pickering at 2019-10-23T05:58:58-04:00 eventlog: Dump cost centre stack on each sample With this change it is possible to reconstruct the timing portion of a `.prof` file after the fact. By logging the stacks at each time point a more precise executation trace of the program can be observed rather than all identical cost centres being identified in the report. There are two new events: 1. `EVENT_PROF_BEGIN` - emitted at the start of profiling to communicate the tick interval 2. `EVENT_PROF_SAMPLE_COST_CENTRE` - emitted on each tick to communicate the current call stack. Fixes #17322 - - - - - 4798f3b9 by Takenobu Tani at 2019-10-23T05:59:00-04:00 Allow command name resolution for GHCi commands with option `!` #17345 This commit allows command name resolution for GHCi commands with option `!` as follows: ghci> :k! Int Int :: * = Int This commit changes implementation as follows: Before: * Prefix match with full string including the option `!` (e.g. `k!`) After (this patch): * Prefix match without option suffix `!` (e.g. `k`) * in addition, suffix match with option `!` See also #8305 and #8113 - - - - - aa778152 by Andreas Klebinger at 2019-10-23T05:59:01-04:00 Fix bug in the x86 backend involving the CFG. This is part two of fixing #17334. There are two parts to this commit: - A bugfix for computing loop levels - A bugfix of basic block invariants in the NCG. ----------------------------------------------------------- In the first bug we ended up with a CFG of the sort: [A -> B -> C] This was represented via maps as fromList [(A,B),(B,C)] and later transformed into a adjacency array. However the transformation did not include block C in the array (since we only looked at the keys of the map). This was still fine until we tried to look up successors for C and tried to read outside of the array bounds when accessing C. In order to prevent this in the future I refactored to code to include all nodes as keys in the map representation. And make this a invariant which is checked in a few places. Overall I expect this to make the code more robust as now any failed lookup will represent an error, versus failed lookups sometimes being expected and sometimes not. In terms of performance this makes some things cheaper (getting a list of all nodes) and others more expensive (adding a new edge). Overall this adds up to no noteable performance difference. ----------------------------------------------------------- Part 2: When the NCG generated a new basic block, it did not always insert a NEWBLOCK meta instruction in the stream which caused a quite subtle bug. During instruction selection a statement `s` in a block B with control of the sort: B -> C will sometimes result in control flow of the sort: ┌ < ┐ v ^ B -> B1 ┴ -> C as is the case for some atomic operations. Now to keep the CFG in sync when introducing B1 we clearly want to insert it between B and C. However there is a catch when we have to deal with self loops. We might start with code and a CFG of these forms: loop: stmt1 ┌ < ┐ .... v ^ stmtX loop ┘ stmtY .... goto loop: Now we introduce B1: ┌ ─ ─ ─ ─ ─┐ loop: │ ┌ < ┐ │ instrs v │ │ ^ .... loop ┴ B1 ┴ ┘ instrsFromX stmtY goto loop: This is simple, all outgoing edges from loop now simply start from B1 instead and the code generator knows which new edges it introduced for the self loop of B1. Disaster strikes if the statement Y follows the same pattern. If we apply the same rule that all outgoing edges change then we end up with: loop ─> B1 ─> B2 ┬─┐ │ │ └─<┤ │ │ └───<───┘ │ └───────<────────┘ This is problematic. The edge B1->B1 is modified as expected. However the modification is wrong! The assembly in this case looked like this: _loop: <instrs> _B1: ... cmpxchgq ... jne _B1 <instrs> <end _B1> _B2: ... cmpxchgq ... jne _B2 <instrs> jmp loop There is no edge _B2 -> _B1 here. It's still a self loop onto _B1. The problem here is that really B1 should be two basic blocks. Otherwise we have control flow in the *middle* of a basic block. A contradiction! So to account for this we add yet another basic block marker: _B: <instrs> _B1: ... cmpxchgq ... jne _B1 jmp _B1' _B1': <instrs> <end _B1> _B2: ... Now when inserting B2 we will only look at the outgoing edges of B1' and everything will work out nicely. You might also wonder why we don't insert jumps at the end of _B1'. There is no way another block ends up jumping to the labels _B1 or _B2 since they are essentially invisible to other blocks. View them as control flow labels local to the basic block if you'd like. Not doing this ultimately caused (part 2 of) #17334. - - - - - 1f40e68a by Ryan Yates at 2019-10-23T05:59:03-04:00 Full abort on validate failure merging `orElse`. Previously partial roll back of a branch of an `orElse` was attempted if validation failure was observed. Validation here, however, does not account for what part of the transaction observed inconsistent state. This commit fixes this by fully aborting and restarting the transaction. - - - - - 9c1f0f7c by Ben Gamari at 2019-10-23T05:59:03-04:00 Bump stm submodule - - - - - 6beea836 by Andreas Klebinger at 2019-10-23T05:59:04-04:00 Make dynflag argument for withTiming pure. 19 times out of 20 we already have dynflags in scope. We could just always use `return dflags`. But this is in fact not free. When looking at some STG code I noticed that we always allocate a closure for this expression in the heap. Clearly a waste in these cases. For the other cases we can either just modify the callsite to get dynflags or use the _D variants of withTiming I added which will use getDynFlags under the hood. - - - - - 8dd480cc by Matthew Pickering at 2019-10-23T05:59:06-04:00 Performance tests: Reduce acceptance threshold for bytes allocated tests The "new" performance testing infrastructure resets the baseline after every test so it's easy to miss gradual performance regressions over time. We should at least make these numbers smaller to catch patches which affect performance earlier. - - - - - 4af20bbc by Ben Gamari at 2019-10-23T05:59:06-04:00 users-guide: Fix :since: for -Wunused-packages Fixes #17382. - - - - - 21663693 by Ben Gamari at 2019-10-23T05:59:07-04:00 Drop duplicate -optl's from GHC invocations Previously the make build system would pass things like `-optl-optl-Wl,-x -optl-optl-Wl,noexecstack` to GHC. This would naturally result in mass confusion as GHC would pass `-optl-Wl,-x` to GCC. GCC would in turn interpret this as `-o ptl-Wl,-x`, setting the output pass of the invocation. The problem that `-optl` was added to the command-line in two places in the build system. Fix this. Fixes #17385. - - - - - bb0dc5a5 by Andreas Klebinger at 2019-10-23T05:59:07-04:00 Hadrian: Invoke ghc0 via bash when running tests to fix #17362. cmd uses RawCommand which uses Windows semantics to find the executable which sometimes seems to fail for unclear reasons. If we invoke ghc via bash then bash will find the ghc executable and the issue goes away. - - - - - 266435a7 by Ömer Sinan Ağacan at 2019-10-23T05:59:09-04:00 Add new flag for unarised STG dumps Previously -ddump-stg would dump pre and post-unarise STGs. Now we have a new flag for post-unarise STG and -ddump-stg only dumps coreToStg output. STG dump flags after this commit: - -ddump-stg: Dumps CoreToStg output - -ddump-stg-unarised: Unarise output - -ddump-stg-final: STG right before code gen (includes CSE and lambda lifting) - - - - - 8abddac8 by Ben Gamari at 2019-10-23T05:59:10-04:00 base: Add @since on GHC.IO.Handle.Lock.hUnlock Unfortunately this was introduced in base-4.11.0 (GHC 8.4.1) whereas the other locking primitives were added in base-4.10.0 (GHC 8.2.1). - - - - - 7f72b540 by Ben Gamari at 2019-10-23T14:56:46-04:00 Merge non-moving garbage collector This introduces a concurrent mark & sweep garbage collector to manage the old generation. The concurrent nature of this collector typically results in significantly reduced maximum and mean pause times in applications with large working sets. Due to the large and intricate nature of the change I have opted to preserve the fully-buildable history, including merge commits, which is described in the "Branch overview" section below. Collector design ================ The full design of the collector implemented here is described in detail in a technical note > B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell > Compiler" (2018) This document can be requested from @bgamari. The basic heap structure used in this design is heavily inspired by > K. Ueno & A. Ohori. "A fully concurrent garbage collector for > functional programs on multicore processors." /ACM SIGPLAN Notices/ > Vol. 51. No. 9 (presented at ICFP 2016) This design is intended to allow both marking and sweeping concurrent to execution of a multi-core mutator. Unlike the Ueno design, which requires no global synchronization pauses, the collector introduced here requires a stop-the-world pause at the beginning and end of the mark phase. To avoid heap fragmentation, the allocator consists of a number of fixed-size /sub-allocators/. Each of these sub-allocators allocators into its own set of /segments/, themselves allocated from the block allocator. Each segment is broken into a set of fixed-size allocation blocks (which back allocations) in addition to a bitmap (used to track the liveness of blocks) and some additional metadata (used also used to track liveness). This heap structure enables collection via mark-and-sweep, which can be performed concurrently via a snapshot-at-the-beginning scheme (although concurrent collection is not implemented in this patch). Implementation structure ======================== The majority of the collector is implemented in a handful of files: * `rts/Nonmoving.c` is the heart of the beast. It implements the entry-point to the nonmoving collector (`nonmoving_collect`), as well as the allocator (`nonmoving_allocate`) and a number of utilities for manipulating the heap. * `rts/NonmovingMark.c` implements the mark queue functionality, update remembered set, and mark loop. * `rts/NonmovingSweep.c` implements the sweep loop. * `rts/NonmovingScav.c` implements the logic necessary to scavenge the nonmoving heap. Branch overview =============== ``` * wip/gc/opt-pause: | A variety of small optimisations to further reduce pause times. | * wip/gc/compact-nfdata: | Introduce support for compact regions into the non-moving |\ collector | \ | \ | | * wip/gc/segment-header-to-bdescr: | | | Another optimization that we are considering, pushing | | | some segment metadata into the segment descriptor for | | | the sake of locality during mark | | | | * | wip/gc/shortcutting: | | | Support for indirection shortcutting and the selector optimization | | | in the non-moving heap. | | | * | | wip/gc/docs: | |/ Work on implementation documentation. | / |/ * wip/gc/everything: | A roll-up of everything below. |\ | \ | |\ | | \ | | * wip/gc/optimize: | | | A variety of optimizations, primarily to the mark loop. | | | Some of these are microoptimizations but a few are quite | | | significant. In particular, the prefetch patches have | | | produced a nontrivial improvement in mark performance. | | | | | * wip/gc/aging: | | | Enable support for aging in major collections. | | | | * | wip/gc/test: | | | Fix up the testsuite to more or less pass. | | | * | | wip/gc/instrumentation: | | | A variety of runtime instrumentation including statistics | | / support, the nonmoving census, and eventlog support. | |/ | / |/ * wip/gc/nonmoving-concurrent: | The concurrent write barriers. | * wip/gc/nonmoving-nonconcurrent: | The nonmoving collector without the write barriers necessary | for concurrent collection. | * wip/gc/preparation: | A merge of the various preparatory patches that aren't directly | implementing the GC. | | * GHC HEAD . . . ``` - - - - - 83655b06 by Ben Gamari at 2019-10-24T08:45:41-04:00 hadrian: Warn user if hadrian build fails due to lack of threaded RTS See #16873. - - - - - 6824f29a by Ryan Scott at 2019-10-24T08:46:19-04:00 Parenthesize GADT return types in pprIfaceConDecl (#17384) We were using `pprIfaceAppArgs` instead of `pprParendIfaceAppArgs` in `pprIfaceConDecl`. Oops. Fixes #17384. - - - - - 9de3f8b1 by Ryan Scott at 2019-10-24T18:38:32-04:00 Make isTcLevPoly more conservative with newtypes (#17360) `isTcLevPoly` gives an approximate answer for when a type constructor is levity polymorphic when fully applied, where `True` means "possibly levity polymorphic" and `False` means "definitely not levity polymorphic". `isTcLevPoly` returned `False` for newtypes, which is incorrect in the presence of `UnliftedNewtypes`, leading to #17360. This patch tweaks `isTcLevPoly` to return `True` for newtypes instead. Fixes #17360. - - - - - 243c72eb by Ryan Scott at 2019-10-24T18:39:08-04:00 Mark promoted InfixT names as IsPromoted (#17394) We applied a similar fix for `ConT` in #15572 but forgot to apply the fix to `InfixT` as well. This patch fixes #17394 by doing just that. - - - - - 87175e78 by James Foster at 2019-10-25T09:01:08-04:00 Make Hadrian use -dynamic-too in the basic case This commit makes Hadrian use the `-dynamic-too` flag when the current Flavour's libraryWays contains both vanilla and dynamic, cutting down the amount of repeated work caused by separate compilation of dynamic and static files. It does this for the basic case where '.o' and '.dyn_o' files are built with one command, but does not generalise to cases like '.prof_o' and '.prof_dyn_o'. - - - - - ecd89062 by Alp Mestanogullari at 2019-10-25T09:01:47-04:00 hadrian/ci: run testsuite against a freshly produced and installed bindist - - - - - 2a16b555 by Ben Gamari at 2019-10-25T09:02:26-04:00 testsuite: Mark T13786 as fragile in unreg build Due to #17018. - - - - - 08298926 by Ben Gamari at 2019-10-25T09:02:26-04:00 testsuite: Use fragile modifier in TH_foreignInterruptible It looks like this use of `skip` snuck through my previous refactoring. - - - - - 4c7d45d1 by Brian Wignall at 2019-10-25T09:03:04-04:00 Make documentation for byteSwap16 consistent with byteSwap32 (impl is same, with s/16/32) - - - - - 02822d84 by Ben Gamari at 2019-10-25T09:03:40-04:00 aclocal: A bit of reformatting - - - - - 519f5162 by Ben Gamari at 2019-10-25T09:03:40-04:00 configure: Drop GccLT46 GCC 4.6 was released 7 years ago. I think we can finally assume that it's available. This is a simplification prompted by #15742. - - - - - acedfc8b by Ben Gamari at 2019-10-25T09:04:16-04:00 gitlab-ci: Run check-uniques during lint job - - - - - 8916e64e by Andrew Martin at 2019-10-26T05:19:38-04:00 Implement shrinkSmallMutableArray# and resizeSmallMutableArray#. This is a part of GHC Proposal #25: "Offer more array resizing primitives". Resources related to the proposal: - Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/121 - Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0025-resize-boxed.rst Only shrinkSmallMutableArray# is implemented as a primop since a library-space implementation of resizeSmallMutableArray# (in GHC.Exts) is no less efficient than a primop would be. This may be replaced by a primop in the future if someone devises a strategy for growing arrays in-place. The library-space implementation always copies the array when growing it. This commit also tweaks the documentation of the deprecated sizeofMutableByteArray#, removing the mention of concurrency. That primop is unsound even in single-threaded applications. Additionally, the non-negativity assertion on the existing shrinkMutableByteArray# primop has been removed since this predicate is trivially always true. - - - - - 1be9c35c by Roland Senn at 2019-10-26T05:20:14-04:00 Fix #14690 - :steplocal panics after break-on-error `:steplocal` enables only breakpoints in the current top-level binding. When a normal breakpoint is hit, then the module name and the break id from the `BRK_FUN` byte code allow us to access the corresponding entry in a ModBreak table. From this entry we then get the SrcSpan (see compiler/main/InteractiveEval.hs:bindLocalsAtBreakpoint). With this source-span we can then determine the current top-level binding, needed for the steplocal command. However, if we break at an exception or at an error, we don't have an BRK_FUN byte-code, so we don't have any source information. The function `bindLocalsAtBreakpoint` creates an `UnhelpfulSpan`, which doesn't allow us to determine the current top-level binding. To avoid a `panic`, we have to check for `UnhelpfulSpan` in the function `ghc/GHCi/UI.hs:stepLocalCmd`. Hence a :steplocal command after a break-on-exception or a break-on-error is not possible. - - - - - 4820af10 by Adam Sandberg Eriksson at 2019-10-26T19:53:01-04:00 hadrian: point link to ghc gitlab [skip ci] - - - - - 609c7ee6 by Ben Gamari at 2019-10-26T19:53:36-04:00 gitlab-ci: Produce ARMv7 binary distributions - - - - - 8ac49411 by Ben Gamari at 2019-10-26T19:53:36-04:00 testsuite: Skip regalloc_unit_tests unless have_ncg This is a unit test for the native code generator's register allocator; naturally. the NCG is required. - - - - - 60575596 by Ben Gamari at 2019-10-26T19:53:36-04:00 Enable PDF documentation - - - - - 417f59d4 by Ben Gamari at 2019-10-26T19:53:36-04:00 rts: Fix ARM linker includes * Prefer #pragma once over guard macros * Drop redundant #includes * Fix order to ensure that necessary macros are defined when we condition on them - - - - - 4054f0e5 by Ömer Sinan Ağacan at 2019-10-26T19:54:16-04:00 Remove redundant -fno-cse options These were probably added with some GLOBAL_VARs, but those GLOBAL_VARs are now gone. - - - - - c62817f2 by Luke Lau at 2019-10-27T11:35:40-04:00 Fix RankNTypes :ghc-flag: in users guide This fixes a hadrian `build docs` failure - - - - - fc3a5205 by Luke Lau at 2019-10-27T11:35:40-04:00 Remove unused import - - - - - d2520bef by Luke Lau at 2019-10-27T11:35:40-04:00 Fix path to ghc-flags in users guide Hadrian rules It should point to the _build directory, not the source - - - - - 896d470a by Luke Lau at 2019-10-27T11:35:40-04:00 Add back documentation for deprecated -Whi-shadowing This was removed in b538476be3706264620c072e6e436debf9e0d3e4, but without it the compare-flags.py script fails. This adds it back and marks it as deprecated, with a notice that it is slated for removal. - - - - - 7d80f8b5 by Luke Lau at 2019-10-27T11:35:40-04:00 Remove documented flags from expected-undocumented-flags.txt - - - - - fa0d4809 by Ryan Scott at 2019-10-27T11:36:17-04:00 Parenthesize nullary constraint tuples using sigPrec (#17403) We were using `appPrec`, not `sigPrec`, as the precedence when determining whether or not to parenthesize `() :: Constraint`, which lead to the parentheses being omitted in function contexts like `(() :: Constraint) => String`. Easily fixed. Fixes #17403. - - - - - 90d06fd0 by Ben Gamari at 2019-10-27T17:27:17-04:00 hadrian: Silence output from Support SMP check Previously we would allow the output from the check of SMP support introduced by 83655b06e6d3e93b2d15bb0fa250fbb113d7fe68 leak to stdout. Silence this. See #16873. - - - - - 6635a3f6 by Josef Svenningsson at 2019-10-28T09:20:34-04:00 Fix #15344: use fail when desugaring applicative-do Applicative-do has a bug where it fails to use the monadic fail method when desugaring patternmatches which can fail. See #15344. This patch fixes that problem. It required more rewiring than I had expected. Applicative-do happens mostly in the renamer; that's where decisions about scheduling are made. This schedule is then carried through the typechecker and into the desugarer which performs the actual translation. Fixing this bug required sending information about the fail method from the renamer, through the type checker and into the desugarer. Previously, the desugarer didn't have enough information to actually desugar pattern matches correctly. As a side effect, we also fix #16628, where GHC wouldn't catch missing MonadFail instances with -XApplicativeDo. - - - - - cd9b9459 by Ryan Scott at 2019-10-28T09:21:13-04:00 Refactor TcDeriv to validity-check less in anyclass/via deriving (#13154) Due to the way `DerivEnv` is currently structured, there is an invariant that every derived instance must consist of a class applied to a non-empty list of argument types, where the last argument *must* be an application of a type constructor to some arguments. This works for many cases, but there are also some design patterns in standalone `anyclass`/`via` deriving that are made impossible due to enforcing this invariant, as documented in #13154. This fixes #13154 by refactoring `TcDeriv` and friends to perform fewer validity checks when using the `anyclass` or `via` strategies. The highlights are as followed: * Five fields of `DerivEnv` have been factored out into a new `DerivInstTys` data type. These fields only make sense for instances that satisfy the invariant mentioned above, so `DerivInstTys` is now only used in `stock` and `newtype` deriving, but not in other deriving strategies. * There is now a `Note [DerivEnv and DerivSpecMechanism]` describing the bullet point above in more detail, as well as explaining the exact requirements that each deriving strategy imposes. * I've refactored `mkEqnHelp`'s call graph to be slightly less complicated. Instead of the previous `mkDataTypeEqn`/`mkNewTypeEqn` dichotomy, there is now a single entrypoint `mk_eqn`. * Various bits of code were tweaked so as not to use fields that are specific to `DerivInstTys` so that they may be used by all deriving strategies, since not all deriving strategies use `DerivInstTys`. - - - - - e0e04856 by Alan Zimmerman at 2019-10-28T09:21:58-04:00 Attach API Annotations for {-# SOURCE #-} import pragma Attach the API annotations for the start and end locations of the {-# SOURCE #-} pragma in an ImportDecl. Closes #17388 - - - - - e951f219 by Sebastian Graf at 2019-10-28T09:22:35-04:00 Use FlexibleInstances for `Outputable (* p)` instead of match-all instances with equality constraints In #17304, Richard and Simon dicovered that using `-XFlexibleInstances` for `Outputable` instances of AST data types means users can provide orphan `Outputable` instances for passes other than `GhcPass`. Type inference doesn't currently to suffer, and Richard gave an example in #17304 that shows how rare a case would be where the slightly worse type inference would matter. So I went ahead with the refactoring, attempting to fix #17304. - - - - - ad1fe274 by Simon Peyton Jones at 2019-10-28T09:23:14-04:00 Better arity for join points A join point was getting too large an arity, leading to #17294. I've tightened up the invariant: see CoreSyn, Note [Invariants on join points], invariant 2b - - - - - fb4f245c by Takenobu Tani at 2019-10-29T03:45:02-04:00 users-guide: Fix :since: for -xn flag [skip ci] - - - - - 35abbfee by Takenobu Tani at 2019-10-29T03:45:41-04:00 users-guide: Add some new features and fix warnings for GHC 8.10 This updates the following: * Add description for ImportQualifiedPost extension * Add description for ghci command name resolution * Fix markdown warnings [skip ci] - - - - - 57dc1565 by Sylvain Henry at 2019-10-29T03:46:22-04:00 Use `not#` primitive to implement Word's complement - - - - - 28e52732 by Ben Gamari at 2019-10-29T03:46:59-04:00 linters: Add mode to lint given set of files This makes testing much easier. - - - - - db43b3b3 by Ben Gamari at 2019-10-29T03:46:59-04:00 linters: Add linter to catch unquoted use of $(TEST_HC) This is a common bug that creeps into Makefiles (e.g. see T12674). - - - - - ebee0d6b by Ben Gamari at 2019-10-29T03:46:59-04:00 testsuite: Fix quoting of $(TEST_HC) in T12674 I have no idea how this went unnoticed until now. - - - - - 3bd3456f by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 Refactor HscRecomp constructors: Make it evident in the constructors that the final interface is only available when HscStatus is not HscRecomp. (When HscStatus == HscRecomp we need to finish the compilation to get the final interface) `Maybe ModIface` return value of hscIncrementalCompile and the partial `expectIface` function are removed. - - - - - bbdd54aa by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 Return ModIface in compilation pipeline, remove IORef hack for generating ModIfaces The compilation phases now optionally return ModIface (for phases that generate an interface, currently only HscOut when (re)compiling a file). The value is then used by compileOne' to return the generated interface with HomeModInfo (which is then used by the batch mode compiler when building rest of the tree). hscIncrementalMode also returns a DynFlags with plugin info, to be used in the rest of the pipeline. Unfortunately this introduces a (perhaps less bad) hack in place of the previous IORef: we now record the DynFlags used to generate the partial infterface in HscRecomp and use the same DynFlags when generating the full interface. I spent almost three days trying to understand what's changing in DynFlags that causes a backpack test to fail, but I couldn't figure it out. There's a FIXME added next to the field so hopefully someone who understands this better than I do will fix it leter. - - - - - a56433a9 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 Remove unused DynFlags arg of lookupIfaceByModule - - - - - dcd40c71 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 HscMain: Move a comment closer to the relevant site - - - - - 593f6543 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 MkIface: Remove redundant parameter and outdated comments from addFingerprints - - - - - f868e1fe by Ben Gamari at 2019-10-29T03:48:20-04:00 gitlab-ci: Use Hadrian for unregisterised job - - - - - 7b2ecbc0 by Ben Gamari at 2019-10-29T03:48:20-04:00 gitlab-ci: Factor out Linux Hadrian validation logic - - - - - 8e5de15d by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Define USE_LIBFFI_FOR_ADJUSTORS when necessary - - - - - 6a090270 by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Define NOSMP when building rts unregisterised It seems that NOSMP was previously only defined when compiling the compiler, not the RTS. Fix this. In addition do some spring-cleaning and make the logic match that of the Make build system. - - - - - b741d19d by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Shuffle around RTS build flags Some of these flags wanted to be passed to .cmm builds as well as C builds. - - - - - d7cedd9d by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Drop -Werror=unused-but-set-variable from GHC flags Previously `hadrian` would pass `-optc-Werror=unused-but-set-variable` to all GHC invocations. This was a difference from the make build system and cause the unregisterised build to fail as the C that GHC produces contains many unused functions. Drop it from the GHC flags. Note, however, that the flag is still present in `Settings.Builders.Common.cWarnings` and therefore will still be applied during compilation of C sources. - - - - - 7d3a15c7 by Ben Gamari at 2019-10-29T03:48:55-04:00 base: Fix open-file locking The OFD locking path introduced in 3b784d440d4b01b4c549df7c9a3ed2058edfc780 due to #13945 appears to have never actually worked but we never noticed due to an oversight in the autoconf check. Fix it. Thanks to Oleg Grenrus for noticing this. - - - - - 78b70e63 by Ben Gamari at 2019-10-29T03:48:55-04:00 base: Split up file locking implementation This makes the CPP significantly easier to follow. - - - - - 63977398 by Ben Gamari at 2019-10-29T03:49:31-04:00 Don't substitute GccVersion variable Not only is it now unused but we generally can't assume that we are compiling with GCC, so it really shouldn't be used. - - - - - 72f7ac9a by Ben Gamari at 2019-10-29T03:50:06-04:00 Revert "Replace freebsd-gnueabihf with freebsd" This reverts commit aa31ceaf7568802590f73a740ffbc8b800096342 as suggested in #17392. - - - - - 3c0372d6 by Ben Gamari at 2019-10-29T20:31:36-04:00 distrib: Fix binary distribution installation This had silently regressed due to 81860281 and the variable renaming performed in b55ee979, as noted in #17374. - - - - - a7f423ee by Ben Gamari at 2019-10-29T20:31:36-04:00 gitlab-ci: Use pxz to compress binary distributions - - - - - db602643 by Ben Gamari at 2019-10-29T20:31:36-04:00 Don't include settings file in binary distribution The configuration in the installation environment (as determined by `autoconf`) may differ from the build environment and therefore we need to be sure to rebuild the settings file. Fixes #17374. - - - - - 260e2379 by Ben Gamari at 2019-10-29T20:31:36-04:00 gitlab-ci: Fix binary distribution testing - - - - - 01ef3e1f by Ömer Sinan Ağacan at 2019-10-29T20:32:18-04:00 Interpreter: initialize arity fields of AP_NOUPDs AP_NOUPD entry code doesn't use the arity field, but not initializing this field confuses printers/debuggers, and also makes testing harder as the field's value changes randomly. - - - - - 93ff9197 by Ben Gamari at 2019-10-30T07:36:49-04:00 rts: More aarch64 header fixes - - - - - 3e7569bc by Vladislav Zavialov at 2019-10-30T07:36:50-04:00 Whitespace forward compatibility for proposal #229 GHC Proposal #229 changes the lexical rules of Haskell, which may require slight whitespace adjustments in certain cases. This patch changes formatting in a few places in GHC and its testsuite in a way that enables it to compile under the proposed rules. - - - - - 4898df1c by Ben Gamari at 2019-10-30T18:15:52-04:00 gitlab-ci: Fix the ARMv7 triple Previously we were configuring the ARMv7 builds with a host/target triple of arm-linux-gnueabihf, which caused us to target ARMv6 and consequently rely on the old CP15 memory barrier implementation. This barrier has to be emulated on ARMv8 machines which is glacially slow. Hopefully this should fix the ARMv7 builds which currently consistently time out. - - - - - 337e9b5a by Ömer Sinan Ağacan at 2019-10-31T19:01:54-04:00 Remove redundant 0s in ghc-heap pointer strings Before: 0x0000004200c86888 After: 0x42000224f8 This is more concise and consistent with the RTS's printer (which uses %p formatter, and at least on Linux gcc prints the short form) and gdb's pointer formatter. - - - - - 97b6f7a3 by Ben Gamari at 2019-10-31T19:02:32-04:00 base: Clamp IO operation size to 2GB on Darwin As reported in #17414, Darwin throws EINVAL in response to large writes. - - - - - a9743eb7 by Ben Gamari at 2019-10-31T19:02:32-04:00 testsuite: Add test for #17414 - - - - - 73d6e508 by Ben Gamari at 2019-10-31T19:03:10-04:00 base: Various haddock fixes Just a few things I found while looking at #17383. - - - - - dc487642 by taylorfausak at 2019-11-01T04:54:47-04:00 Implement `round` for `Ratio` that doesn't explode with `Natural`s - - - - - 3932fb97 by taylorfausak at 2019-11-01T04:54:47-04:00 Fix rounding around 0 - - - - - baf47ff8 by taylorfausak at 2019-11-01T04:54:47-04:00 Add tests for rounding ratios - - - - - 214d8122 by taylorfausak at 2019-11-01T04:54:47-04:00 Fix running of ratio test case - - - - - 70b62c97 by Ben Gamari at 2019-11-01T04:55:24-04:00 mmap: Factor out protection flags - - - - - c6759080 by Ben Gamari at 2019-11-01T04:55:24-04:00 rts: Make m32 allocator per-ObjectCode MacOS Catalina is finally going to force our hand in forbidden writable exeutable mappings. Unfortunately, this is quite incompatible with the current global m32 allocator, which mixes symbols from various objects in a single page. The problem here is that some of these symbols may not yet be resolved (e.g. had relocations performed) as this happens lazily (and therefore we can't yet make the section read-only and therefore executable). The easiest way around this is to simply create one m32 allocator per ObjectCode. This may slightly increase fragmentation for short-running programs but I suspect will actually improve fragmentation for programs doing lots of loading/unloading since we can always free all of the pages allocated to an object when it is unloaded (although this ability will only be implemented in a later patch). - - - - - 35c99e72 by Simon Peyton Jones at 2019-11-01T04:56:02-04:00 Makes Lint less chatty: I found in #17415 that Lint was printing out truly gigantic warnings, unmanageably huge, with repeated copies of the same thing. This patch makes Lint less chatty, especially for warnings: * For **warnings**, I don't print details of the location, unless you add `-dppr-debug`. * For **errors**, I still print all the info. They are fatal and stop exection, whereas warnings appear repeatedly. * I've made much less use of `AnExpr` in `LintLocInfo`; the expression can be gigantic. - - - - - d2471964 by Simon Peyton Jones at 2019-11-01T04:56:38-04:00 Add another test for #17267 This one came in a comment from James Payor - - - - - 1e2e82aa by Simon Peyton Jones at 2019-11-01T04:57:15-04:00 Fix a bad error in tcMatchTy This patch fixes #17395, a very subtle and hard-to-trigger bug in tcMatchTy. It's all explained in Note [Matching in the presence of casts (2)] I have not added a regression test because it is very hard to trigger it, until we have the upcoming mkAppTyM patch, after which lacking this patch means you can't even compile the libraries. - - - - - 51067194 by Ben Gamari at 2019-11-01T15:48:37-04:00 base: Ensure that failIO isn't SOURCE imported failIO has useful information in its demand signature (specifically that it bottoms) which is hidden if it is SOURCE imported, as noted in #16588. Rejigger things such that we don't SOURCE import it. Metric Increase: T13701 - - - - - c751082c by Ben Gamari at 2019-11-01T15:48:37-04:00 testsuite: Make ExplicitForAllRules1 more robust Previously the test relied on `id` not inlining. Fix this. - - - - - dab12c87 by Ben Gamari at 2019-11-01T15:48:37-04:00 Describe optimisation of demand analysis of noinline As described in #16588. - - - - - c9236384 by Adam Sandberg Eriksson at 2019-11-01T15:49:16-04:00 template-haskell: require at least 1 GADT constructor name (#17379) - - - - - a4ce26e0 by Ben Gamari at 2019-11-01T15:49:53-04:00 hadrian: Make runtest invocation consistency with Make Use True/False instead of 0/1. This shouldn't be a functional change but we should be consistent. - - - - - cabafe34 by Ben Gamari at 2019-11-01T15:50:29-04:00 testsuite: Add test for #17423 - - - - - 4a6d3d68 by Simon Peyton Jones at 2019-11-01T23:11:37-04:00 Make CSE delay inlining less CSE delays inlining a little bit, to avoid losing vital specialisations; see Note [Delay inlining after CSE] in CSE. But it was being over-enthusiastic. This patch makes the delay only apply to Ids with specialisation rules, which avoids unnecessary delay (#17409). - - - - - 01006bc7 by Niklas Hambüchen at 2019-11-01T23:12:17-04:00 doc: Fix backticks - - - - - 9980fb58 by Niklas Hambüchen at 2019-11-01T23:12:17-04:00 Add +RTS --disable-delayed-os-memory-return. Fixes #17411. Sets `MiscFlags.disableDelayedOsMemoryReturn`. See the added `Note [MADV_FREE and MADV_DONTNEED]` for details. - - - - - 182b1199 by Sebastian Graf at 2019-11-02T20:16:33-04:00 Separate `LPat` from `Pat` on the type-level Since the Trees That Grow effort started, we had `type LPat = Pat`. This is so that `SrcLoc`s would only be annotated in GHC's AST, which is the reason why all GHC passes use the extension constructor `XPat` to attach source locations. See #15495 for the design discussion behind that. But now suddenly there are `XPat`s everywhere! There are several functions which dont't cope with `XPat`s by either crashing (`hsPatType`) or simply returning incorrect results (`collectEvVarsPat`). This issue was raised in #17330. I also came up with a rather clean and type-safe solution to the problem: We define ```haskell type family XRec p (f :: * -> *) = r | r -> p f type instance XRec (GhcPass p) f = Located (f (GhcPass p)) type instance XRec TH f = f p type LPat p = XRec p Pat ``` This is a rather modular embedding of the old "ping-pong" style, while we only pay for the `Located` wrapper within GHC. No ping-ponging in a potential Template Haskell AST, for example. Yet, we miss no case where we should've handled a `SrcLoc`: `hsPatType` and `collectEvVarsPat` are not callable at an `LPat`. Also, this gets rid of one indirection in `Located` variants: Previously, we'd have to go through `XPat` and `Located` to get from `LPat` to the wrapped `Pat`. Now it's just `Located` again. Thus we fix #17330. - - - - - 3c916162 by Richard Eisenberg at 2019-11-02T20:17:13-04:00 Update Note references -- comments only Follow-on from !2041. - - - - - 3b65655c by Ben Gamari at 2019-11-04T03:40:31-05:00 SysTools: Only apply Windows-specific workaround on Windows Issue #1110 was apparently due to a bug in Vista which prevented GCC from finding its binaries unless we explicitly added it to PATH. However, this workaround was incorrectly applied on non-Windows platforms as well, resulting in ill-formed PATHs (#17266). Fixes #17266. - - - - - 5d4f16ee by Leif Metcalf at 2019-11-04T03:41:09-05:00 Rephrase note on full-laziness - - - - - 120f2e53 by Ben Gamari at 2019-11-04T03:41:44-05:00 rts/linker: Ensure that code isn't writable For many years the linker would simply map all of its memory with PROT_READ|PROT_WRITE|PROT_EXEC. However operating systems have been becoming increasingly reluctant to accept this practice (e.g. #17353 and #12657) and for good reason: writable code is ripe for exploitation. Consequently mmapForLinker now maps its memory with PROT_READ|PROT_WRITE. After the linker has finished filling/relocating the mapping it must then call mmapForLinkerMarkExecutable on the sections of the mapping which contain executable code. Moreover, to make all of this possible it was necessary to redesign the m32 allocator. First, we gave (in an earlier commit) each ObjectCode its own m32_allocator. This was necessary since code loading and symbol resolution/relocation are currently interleaved, meaning that it is not possible to enforce W^X when symbols from different objects reside in the same page. We then redesigned the m32 allocator to take advantage of the fact that all of the pages allocated with the allocator die at the same time (namely, when the owning ObjectCode is unloaded). This makes a number of things simpler (e.g. no more page reference counting; the interface provided by the allocator for freeing is simpler). See Note [M32 Allocator] for details. - - - - - 7c28087a by Takenobu Tani at 2019-11-05T02:45:31-05:00 users-guide: Improve documentaion of CPP extension Currently, the description of CPP extension is given in the section of command-line options. Therefore, it is a little difficult to understand that it is a language extension. This commit explicitly adds a description for it. [skip ci] - - - - - d57059f7 by Ben Gamari at 2019-11-05T02:46:10-05:00 rts: Add missing const in HEAP_ALLOCED_GC This was previously unnoticed as this code-path is hit on very few platforms (e.g. OpenBSD). - - - - - 487ede42 by Peter Trommler at 2019-11-05T02:46:48-05:00 testsuite: skip test requiring RTS linker on PowerPC The RTS linker is not available on 64-bit PowerPC. Instead of marking tests that require the RTS linker as broken on PowerPC 64-bit skip the respective tests on all platforms where the RTS linker or a statically linked external interpreter is not available. Fixes #11259 - - - - - 1593debf by Sebastian Graf at 2019-11-05T11:38:30-05:00 Check EmptyCase by simply adding a non-void constraint We can handle non-void constraints since !1733, so we can now express the strictness of `-XEmptyCase` just by adding a non-void constraint to the initial Uncovered set. For `case x of {}` we thus check that the Uncovered set `{ x | x /~ ⊥ }` is non-empty. This is conceptually simpler than the plan outlined in #17376, because it talks to the oracle directly. In order for this patch to pass the testsuite, I had to fix handling of newtypes in the pattern-match checker (#17248). Since we use a different code path (well, the main code path) for `-XEmptyCase` now, we apparently also handle #13717 correctly. There's also some dead code that we can get rid off now. `provideEvidence` has been updated to provide output more in line with the old logic, which used `inhabitationCandidates` under the hood. A consequence of the shift away from the `UncoveredPatterns` type is that we don't report reduced type families for empty case matches, because the pretty printer is pure and only knows the match variable's type. Fixes #13717, #17248, #17386 - - - - - e6ffe148 by Ömer Sinan Ağacan at 2019-11-05T11:39:13-05:00 TidyPgm: replace an explicit loop with mapAccumL - - - - - b7460492 by Ömer Sinan Ağacan at 2019-11-05T11:39:13-05:00 CoreTidy: hide tidyRule - - - - - f9978f53 by Stefan Schulze Frielinghaus at 2019-11-05T11:39:51-05:00 Hadrian: enable interpreter for s390x - - - - - 3ce18700 by Ben Gamari at 2019-11-06T08:05:57-05:00 rts: Drop redundant flags for libffi These are now handled in the cabal file's include-dirs field. - - - - - ce9e2a1a by Ben Gamari at 2019-11-06T08:05:57-05:00 configure: Add --with-libdw-{includes,libraries} flags Fixing #17255. - - - - - 97f9674b by Takenobu Tani at 2019-11-06T08:06:37-05:00 configure: Add checking python3-sphinx This checks the configuration about python3-sphinx. We need python3-sphinx instead of python2-sphinx to build documentation. The approach is as follows: * Check python3 version with custom `conf.py` invoked from sphinx-build` executable * Place custom `conf.py` into new `utils/check-sphinx` directory If sphinx is for python2 not python3, it's treated as config ERROR instead of WARN. See also #17346 and #17356. - - - - - b4fb2328 by Dan Brooks at 2019-11-06T08:07:15-05:00 Adding examples to Semigroup/monoid - - - - - 708c60aa by Ryan Scott at 2019-11-07T08:39:36-05:00 Clean up TH's treatment of unary tuples (or, #16881 part two) !1906 left some loose ends in regards to Template Haskell's treatment of unary tuples. This patch ends to tie up those loose ends: * In addition to having `TupleT 1` produce unary tuples, `TupE [exp]` and `TupP [pat]` also now produce unary tuples. * I have added various special cases in GHC's pretty-printers to ensure that explicit 1-tuples are printed using the `Unit` type. See `testsuite/tests/th/T17380`. * The GHC 8.10.1 release notes entry has been tidied up a little. Fixes #16881. Fixes #17371. Fixes #17380. - - - - - a424229d by Stefan Schulze Frielinghaus at 2019-11-07T08:40:13-05:00 For s390x issue a warning if LLVM 9 or older is used For s390x the GHC calling convention is only supported since LLVM version 10. Issue a warning in case an older version of LLVM is used. - - - - - 55bc3787 by Ben Gamari at 2019-11-07T08:40:50-05:00 FlagChecker: Add ticky flags to hashed flags These affect output and therefore should be part of the flag hash. - - - - - fa0b1b4b by Stefan Schulze Frielinghaus at 2019-11-07T08:41:33-05:00 Bump libffi-tarballs submodule - - - - - a9566632 by Takenobu Tani at 2019-11-07T08:42:15-05:00 configure: Modify ERROR to WARN for sphinx's python check If sphinx's python version check failed, many people prefer to build without documents instead of stopping on the error. So this commit fixes the following: * Modify AC_MSG_ERROR to AC_MSG_WARN * Add clearing of SPHINXBUILD variable when check fails See also !2016. - - - - - d0ef8312 by Alp Mestanogullari at 2019-11-07T21:24:59-05:00 hadrian: fix support for the recording of perf test results Before this patch, Hadrian didn't care about the TEST_ENV and METRICS_FILE environment variables, that the performance testing infrastructure uses to record perf tests results from CI jobs. It now looks them up right before running the testsuite driver, and passes suitable --test-env/--metrics-file arguments when these environment variables are set. - - - - - 601e554c by Ben Gamari at 2019-11-07T21:25:36-05:00 Bump the process submodule This should fix the #17108 and #17249 with the fix from https://github.com/haskell/process/pull/159. - - - - - 6b7d7e1c by Ben Gamari at 2019-11-07T21:25:36-05:00 Bump hsc2hs submodule - - - - - b1c158c9 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts: Fix m32 allocator build on Windows An inconsistency in the name of m32_allocator_flush caused the build to fail with a missing prototype error. - - - - - ae431cf4 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts: Ensure that Rts.h is always included first In general this is the convention that we use in the RTS. On Windows things actually fail if we break it. For instance, you see things like: includes\stg\Types.h:26:9: error: warning: #warning "Mismatch between __USE_MINGW_ANSI_STDIO definitions. If using Rts.h make sure it is the first header included." [-Wcpp] - - - - - 0d141d28 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts: Remove undesireable inline specifier I have no idea why I marked this as inline originally but clearly it shouldn't be inlined. - - - - - 870376f9 by Ben Gamari at 2019-11-07T21:25:36-05:00 base: Add missing imports in Windows locking implementation - - - - - 23994738 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts/NonMoving: Fix various Windows build issues The Windows build seems to be stricter about not providing threading primitives in the non-threaded RTS. - - - - - a3ce52fd by Ben Gamari at 2019-11-07T21:25:36-05:00 users_guide: Set flags list file encoding Otherwise this fails on Windows. - - - - - 9db2e905 by Stefan Schulze Frielinghaus at 2019-11-08T05:36:54-05:00 Testsuite: Introduce req_rts_linker Some tests depend on the RTS linker. Introduce a modifier to skip such tests, in case the RTS linker is not available. - - - - - a4631335 by Szymon Nowicki-Korgol at 2019-11-08T05:37:34-05:00 Set correct length of DWARF .debug_aranges section (fixes #17428) - - - - - 3db2ab30 by Ben Gamari at 2019-11-08T05:38:11-05:00 hadrian: Add enableTickyGhc helper This took a bit of trial-and-error to get working so it seems worth having in the tree. - - - - - 5c87ebd7 by Ben Gamari at 2019-11-08T12:09:22-05:00 SetLevels: Don't set context level when floating cases When floating a single-alternative case we previously would set the context level to the level where we were floating the case. However, this is wrong as we are only moving the case and its binders. This resulted in #16978, where the disrepancy caused us to unnecessarily abstract over some free variables of the case body, resulting in shadowing and consequently Core Lint failures. (cherry picked from commit a2a0e6f3bb2d02a9347dec4c7c4f6d4480bc2421) - - - - - 43623b09 by Ben Gamari at 2019-11-08T12:10:01-05:00 testsuite: Run tests in nonmoving_thr in speed==slow - - - - - 6e4656cc by Ben Gamari at 2019-11-08T12:10:01-05:00 rts/nonmoving: Catch failure of createOSThread - - - - - 2e4fc04b by Ben Gamari at 2019-11-08T12:10:01-05:00 Bump unix submodule Marks executeFile001 as broken in all concurrent ways. - - - - - 8a10f9fb by Ben Gamari at 2019-11-09T18:03:01-05:00 template-haskell: Document assembler foreign file support See #16180. - - - - - 5ad3cb53 by Ben Gamari at 2019-11-09T18:03:01-05:00 template-haskell: Fix TBAs in changelog - - - - - 4a75a832 by Ben Gamari at 2019-11-09T18:03:01-05:00 base: Fix TBA in changelog - - - - - d7de0d81 by Ryan Scott at 2019-11-09T18:03:02-05:00 template-haskell: Fix italics in changelog [ci-skip] - - - - - 0fb246c3 by Ben Gamari at 2019-11-09T18:03:37-05:00 testsuite: Fix Windows cleanup path This was a regression introduced with the Path refactoring. - - - - - 925fbdbb by Ben Gamari at 2019-11-09T18:03:37-05:00 testsuite: Skip T16916 on Windows The event manager is not supported on Windows. - - - - - 7c2ce0a0 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Skip T14931 on Windows This test uses -dynamic-too, which is not supported on Windows. - - - - - 7c63edb4 by Ben Gamari at 2019-11-09T18:03:38-05:00 gitlab-ci: Don't allow Windows make job to fail While linking is still slow (#16084) all of the correctness issues which were preventing us from being able to enforce testsuite-green on Windows are now resolved. - - - - - a50ecda6 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Fix header #include order on Windows <Rts.h> must always come first. - - - - - dcb23ec9 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T13676 as broken on Darwin and Windows Due to #17447. - - - - - 411ba7ba by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T11627b as fragile It was previously marked as broken due to #12236 however it passes for me locally while failing on CI. - - - - - c1f1f3f9 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T16219 as unbroken This was previously broken due to #16386 yet it passes for me locally. - - - - - 1f871e70 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Remove redundant cleaning logic from T16511 The GHCi script for T16511 had some `rm` commands to clean up output from previous runs. This should be harmless since stderr was redirected to /dev/null; however, it seems that this redirection doesn't work on Windows (perhaps because GHCi uses `cmd` to execute the command-line; I'm not sure). I tried to fix it but was unable to find a sensible solution. Regardless, the cleaning logic is quite redundant now that we run each test in a hermetic environment. Let's just remove it. - - - - - 4d523cb1 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T17414 as fragile on Windows This consistently times out on Windows as described in #17453. I have tried increasing the timeout multiplier to two yet it stills fails. Disabling until we have time to investigate. - - - - - f73fbd2d by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Ignore stderr in PartialDownsweep As described in #17449, PartialDownsweep is currently fragile due to its dependence on the error messages produced by the C preprocessor. To eliminate this dependence we simply ignore stderr output, instead relying on the fact that the test will exit with a non-zero exit code on failure. Fixes #17449. - - - - - a9b14790 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Fix putStrLn in saks028 Bizarrely, `saks028` previously failed reliably, but only on Windows (#17450). The test would exit with a zero exit code but simply didn't emit the expected text to stderr. I believe this was due to the fact that the test used `putStrLn`, resulting in the output ending up on stdout. This worked on other platforms since (apparently) we redirect stdout to stderr when evaluating splices. However, on Windows it seems that the redirected output wasn't flushed as it was on other platforms. Anyways, it seems like the right thing to do here is to be explicit about our desire for the output to end up on stderr. Closes #17450. - - - - - b62ca659 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Drop T7995 This test is quite sensitive to the build configuration as it requires that ghc have unfoldings, which isn't true in the quick build flavours. I considered various options to make the test more robust but none of them seemed particularly appealing. Moreover, Simon PJ was a bit skeptical of the value of the test to begin with and I strongly suspect that any regression in #7995 would be accompanied by failures in our other compiler performance tests. Closes #17399. - - - - - 011f3121 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T16219 as fragile on Windows As noted in #17452, this test produces very long file paths which exceed the Windows MAX_PATH limitation. Mark the test as fragile for not until we can come up with a better solution. - - - - - 1f98e47d by Simon Peyton Jones at 2019-11-09T18:04:14-05:00 Use the right type in :force A missing prime meant that we were considering the wrong type in the GHCi debugger, when doing :force on multiple arguments (issue #17431). The fix is trivial. - - - - - 1f911de4 by Brian Wignall at 2019-11-09T18:04:57-05:00 Add IsList instance for ZipList (closes #17433) - - - - - e3672f40 by Brian Wignall at 2019-11-09T18:04:57-05:00 Incorporate MR review suggestions; add change in changelog - - - - - 3957bdf2 by Brian Wignall at 2019-11-09T18:04:57-05:00 Fix incorrect plurals - - - - - 6f4c1250 by Alina Banerjee at 2019-11-10T01:06:12-05:00 Improve SPECIALIZE pragma error messages (Fixes #12126) - - - - - fa25c8c4 by Richard Eisenberg at 2019-11-10T01:06:48-05:00 Update release notes about #16512 / #17405. - - - - - 55ca1085 by Richard Eisenberg at 2019-11-10T01:06:48-05:00 Fix #17405 by not checking imported equations Previously, we checked all imported type family equations for injectivity. This is very silly. Now, we check only for conflicts. Before I could even imagine doing the fix, I needed to untangle several functions that were (in my opinion) overly complicated. It's still not quite as perfect as I'd like, but it's good enough for now. Test case: typecheck/should_compile/T17405 - - - - - a9467f4f by Ben Gamari at 2019-11-10T21:06:33-05:00 testsuite: Mark tests fragile in threaded2 as fragile in all concurrent ways - - - - - 3e07ea8d by Ben Gamari at 2019-11-10T21:10:30-05:00 testsuite: Use small allocation area when measuring residency As suggested in #17387; this helps reduce the variance in our residency sampling. Metric Increase: T10370 T3586 lazy-bs-alloc Metric Decrease 'compile_time/peak_megabytes_allocated': T1969 Metric Decrease 'runtime/bytes allocated': space_leak_001 Metric Increase 'compile_time/bytes allocated': T1969 Metric Increase 'runtime/peak_megabytes_allocated': space_leak_001 Metric Decrease: T3064 T9675 - - - - - 049d9ae0 by Ben Gamari at 2019-11-10T21:10:30-05:00 testsuite: Don't check_stats at runtime if not requested Previously we would call check_stats to check the runtime metrics even if the test definition hadn't requested it. This would result in an error since the .stats file doesn't exist. - - - - - 64433428 by Alp Mestanogullari at 2019-11-11T08:49:01-05:00 hadrian: export METRICS_FILE to make it accessible to perf notes script This addresses #17456 and also fixes the --metrics-file argument that Hadrian passes to the testsuite driver. - - - - - 06640394 by Ben Gamari at 2019-11-11T08:50:45-05:00 testsuite: Disable T4334 in nonmoving_thr way - - - - - f8ec32d7 by Alp Mestanogullari at 2019-11-11T11:36:44-05:00 ci: push perf test metrics even when the testsuite doesn't pass The corresponding commit might introduce a regression on a perf test, in which case we certainly want to record it. The testsuite might also fail because of a test unrelated to performance, in which case we want to record that the perf test results were good. Either way, we likely want to record them under all circumstances but we don't without this patch. Metric Decrease: T3586 Metric Increase: lazy-bs-alloc - - - - - 643d42fc by Alp Mestanogullari at 2019-11-12T18:40:19-05:00 testsuite: don't collect compiler stats in collect_runtime_residency We instead want to collect the runtime stats (with collect_stats, instead of collect_compiler_stats). This should fix a number of perf tests failures we have been seeing, where we suddenly started measuring metrics we didn't intend to measure, which tend to fall outside of the acceptance window. Metric Decrease: lazy-bs-alloc T3586 Metric Increase: space_leak_001 T4801 T5835 T12791 - - - - - 535d0edc by Ömer Sinan Ağacan at 2019-11-13T07:06:12-05:00 Document CmmTopInfo type [ci skip] - - - - - 2d4f9ad8 by Ben Gamari at 2019-11-13T07:06:49-05:00 Ensure that coreView/tcView are able to inline Previously an import cycle between Type and TyCoRep meant that several functions in TyCoRep ended up SOURCE import coreView. This is quite unfortunate as coreView is intended to be fused into a larger pattern match and not incur an extra call. Fix this with a bit of restructuring: * Move the functions in `TyCoRep` which depend upon things in `Type` into `Type` * Fold contents of `Kind` into `Type` and turn `Kind` into a simple wrapper re-exporting kind-ish things from `Type` * Clean up the redundant imports that popped up as a result Closes #17441. Metric Decrease: T4334 - - - - - b795637f by Alp Mestanogullari at 2019-11-13T07:07:28-05:00 hadrian: fix Windows CI script By only using 'export' from within bash commands. - - - - - 6885e22c by Ben Gamari at 2019-11-13T07:08:03-05:00 testsuite: Add test for #17458 As noted in #17458, QuantifiedConstraints and UndecideableInstances could previously be used to write programs which can loop at runtime. This was fixed in !1870. - - - - - b4b19d89 by Ben Gamari at 2019-11-13T07:08:03-05:00 users guide: Fix broken link - - - - - 9a939a6c by Ryan Scott at 2019-11-13T07:08:40-05:00 Print name prefixly in the Outputable instance for StandaloneKindSig Issue #17461 was occurring because the `Outputable` instance for standalone kind signatures was simply calling `ppr` on the name in the kind signature, which does not add parentheses to infix names. The solution is simple: use `pprPrefixOcc` instead. Fixes #17461. - - - - - a06cfb59 by Ömer Sinan Ağacan at 2019-11-13T07:09:18-05:00 Only pass mod_location with HscRecomp instead of the entire ModSummary HscRecomp users only need the ModLocation of the module being compiled, so only pass that to users instead of the entire ModSummary Metric Decrease: T4801 - - - - - dd49b3f0 by Ben Gamari at 2019-11-13T17:01:21-05:00 Bump Haskeline and add exceptions as boot library Haskeline now depends upon exceptions. See #16752. - - - - - b06b1858 by Ben Gamari at 2019-11-14T11:30:20-05:00 base: Bump version to 4.14.0.0 Metric Increase: T4801 - - - - - 6ab80439 by Ben Gamari at 2019-11-14T23:05:30-05:00 gitlab-ci: Allow Windows to fail again - - - - - 46afc380 by Ben Gamari at 2019-11-15T09:45:36-05:00 gitlab-ci: Install process to global pkgdb before starting build This is an attempt to mitigate #17480 by ensuring that a functional version of the process library is available before attempting the build. - - - - - 8c5cb806 by Ben Gamari at 2019-11-15T10:45:55-05:00 Bump supported LLVM version to 9.0 - - - - - 8e5851f0 by Ben Gamari at 2019-11-15T10:45:55-05:00 llvm-targets: Update with Clang 9 - - - - - f3ffec27 by Ben Gamari at 2019-11-15T11:54:26-05:00 testsuite: Increase acceptance window of T4801 This statistic is rather unstable. Hopefully fixes #17475. - - - - - c2991f16 by Ben Gamari at 2019-11-15T11:56:10-05:00 users-guide: Drop 8.6.1 release notes - - - - - e8da1354 by Ben Gamari at 2019-11-17T06:48:16-05:00 gitlab-ci: Fix submodule linter We ran it against the .git directory despite the fact that the linter wants to be run against the repository. - - - - - 13290f91 by Ben Gamari at 2019-11-17T06:48:16-05:00 Bump version to 8.10.0 Bumps haddock submodule. - - - - - fa98f823 by Ben Gamari at 2019-11-17T06:48:16-05:00 testsuite: Don't collect residency for T4801 I previously increased the size of the acceptance window from 2% to 5% but this still isn't enough. Regardless, measuring bytes allocated should be sufficient to catch any regressions. - - - - - 002b2842 by Ivan Kasatenko at 2019-11-17T06:49:22-05:00 Make test 16916 more stable across runs - - - - - ca89dd3b by Ben Gamari at 2019-11-17T06:58:17-05:00 users-guide: Address #17329 Adopts the language suggested by @JakobBruenker. - - - - - 2f5ed225 by Ben Gamari at 2019-11-17T07:16:32-05:00 exceptions: Bump submodule back to master The previous commit hasn't made it to master yet. - - - - - 34515e7c by nineonine at 2019-11-17T13:33:22-08:00 Fix random typos [skip ci] - - - - - 4a37a29b by Mario Blažević at 2019-11-17T17:26:24-05:00 Fixed issue #17435, missing Data instances - - - - - 97f1bcae by Andreas Klebinger at 2019-11-17T17:26:24-05:00 Turn some comments into GHC.Hs.Utils into haddocks - - - - - cf7f8e5b by Ben Gamari at 2019-11-17T17:26:26-05:00 testsuite: Skip T17414 on Linux It is typical for $TMP to be a small tmpfson Linux. This test will fail in such cases since we must create a file larger than the filesystem. See #17459. - - - - - 88013b78 by nineonine at 2019-11-19T11:53:16-05:00 Optimize MonadUnique instances based on IO (#16843) Metric Decrease: T14683 - - - - - a8adb5b4 by Ben Gamari at 2019-11-19T11:53:55-05:00 desugar: Drop stale Note [Matching seqId] The need for this note vanished in eae703aa60f41fd232be5478e196b661839ec3de. - - - - - 08d595c0 by Ben Gamari at 2019-11-19T11:53:55-05:00 Give seq a more precise type and remove magic `GHC.Prim.seq` previously had the rather plain type: seq :: forall a b. a -> b -> b However, it also had a special typing rule to applications where `b` is not of kind `Type`. Issue #17440 noted that levity polymorphism allows us to rather give it the more precise type: seq :: forall (r :: RuntimeRep) a (b :: TYPE r). a -> b -> b This allows us to remove the special typing rule that we previously required to allow applications on unlifted arguments. T9404 contains a non-Type application of `seq` which should verify that this works as expected. Closes #17440. - - - - - ec8a463d by Viktor Dukhovni at 2019-11-19T11:54:45-05:00 Enable USE_PTHREAD_FOR_ITIMER also on FreeBSD If using a pthread instead of a timer signal is more reliable, and has no known drawbacks, then FreeBSD is also capable of supporting this mode of operation (tested on FreeBSD 12 with GHC 8.8.1, but no reason why it would not also work on FreeBSD 11 or GHC 8.6). Proposed by Kevin Zhang in: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241849 - - - - - cd40e12a by Ömer Sinan Ağacan at 2019-11-19T11:55:36-05:00 Packages.hs: use O(n*log(n)) ordNub instead of O(n*n) nub As reported in #8173 in some environments package lists can get quite long, so we use more efficient ordNub instead of nub on package lists. - - - - - 2b27cc16 by Ben Gamari at 2019-11-19T11:56:21-05:00 Properly account for libdw paths in make build system Should finally fix #17255. - - - - - 0418c38d by Ben Gamari at 2019-11-19T11:56:58-05:00 rts: Add missing include of SymbolExtras.h This broke the Windows build. - - - - - c819c0e4 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Use correct info table pointer accessor Previously we used INFO_PTR_TO_STRUCT instead of THUNK_INFO_PTR_TO_STRUCT when looking at a thunk. These two happen to be equivalent on 64-bit architectures due to alignment considerations however they are different on 32-bit platforms. This lead to #17487. To fix this we also employ a small optimization: there is only one thunk of type WHITEHOLE (namely stg_WHITEHOLE_info). Consequently, we can just use a plain pointer comparison instead of testing against info->type. - - - - - deed8e31 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Fix incorrect masking in mark queue type test We were using TAG_BITS instead of TAG_MASK. This happened to work on 64-bit platforms where TAG_BITS==3 since we only use tag values 0 and 3. However, this broken on 32-bit platforms where TAG_BITS==2. - - - - - 097f8072 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Rework mark queue representation The previous representation needlessly limited the array length to 16-bits on 32-bit platforms. - - - - - eb7b233a by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Fix handling on large object marking on 32-bit Previously we would reset the pointer pointing to the object to be marked to the beginning of the block when marking a large object. This did no harm on 64-bit but on 32-bit it broke, e.g. `arr020`, since we align pinned ByteArray allocations such that the payload is 8 byte-aligned. This means that the object might not begin at the beginning of the block., - - - - - a7571a74 by Ben Gamari at 2019-11-19T11:57:36-05:00 testsuite: Increase width of stack003 test Previously the returned tuple seemed to fit in registers on amd64. This meant that non-moving collector bug would cause the test to fail on i386 yet not amd64. - - - - - 098d5017 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Drop redundant write barrier on stack underflow Previously we would push stack-carried return values to the new stack on a stack overflow. While the precise reasoning for this barrier is unfortunately lost to history, in hindsight I suspect it was prompted by a missing barrier elsewhere (that has been since fixed). Moreover, there the redundant barrier is actively harmful: the stack may contain non-pointer values; blindly pushing these to the mark queue will result in a crash. This is precisely what happened in the `stack003` test. However, because of a (now fixed) deficiency in the test this crash did not trigger on amd64. - - - - - e57b7cc6 by Roland Zumkeller at 2019-11-19T20:39:19-05:00 Changing Thread IDs from 32 bits to 64 bits. - - - - - d1f3c637 by Roland Zumkeller at 2019-11-19T20:39:19-05:00 Use pointer equality in Eq/Ord for ThreadId Changes (==) to use only pointer equality. This is safe because two threads are the same iff they have the same id. Changes `compare` to check pointer equality first and fall back on ids only in case of inequality. See discussion in #16761. - - - - - ef8a08e0 by Alexey Kuleshevich at 2019-11-19T20:39:20-05:00 hpc: Fix encoding issues. Add test for and fix #17073 * Make sure files are being read/written in UTF-8. Set encoding while writing HTML output. Also set encoding while writing and reading .tix files although we don't yet have a ticket complaining that this poses problems. * Set encoding in html header to utf8 * Upgrade to new version of 'hpc' library and reuse `readFileUtf8` and `writeFileUtf8` functions * Update git submodule for `hpc` * Bump up `hpc` executable version Co-authored-by: Ben Gamari <ben at smart-cactus.org> - - - - - b79e46d6 by Vladislav Zavialov at 2019-11-19T20:39:20-05:00 Strip parentheses in expressions contexts in error messages This makes error messages a tad less noisy. - - - - - 13bbde77 by Ben Gamari at 2019-11-21T13:56:56-05:00 Bump hsc2hs submodule Including Phyx's backport of the process changes fixing #17480. - - - - - d4d10501 by Ben Gamari at 2019-11-23T09:42:38-05:00 Bump hsc2hs submodule again This fixes the Darwin build. - - - - - 889d475b by nineonine at 2019-11-23T18:53:29-05:00 Fix typo in Note reference [skip ci] - - - - - 8a33abfc by Ryan Scott at 2019-11-23T18:54:05-05:00 Target the IsList instance for ZipList at base-4.14.0.0 (#17489) This moves the changelog entry about the instance from `base-4.15.0.0` to `base-4.14.0.0`. This accomplishes part (1) from #17489. [ci skip] - - - - - e43e6ece by Ben Gamari at 2019-11-23T18:54:41-05:00 rts: Expose interface for configuring EventLogWriters This exposes a set of interfaces from the GHC API for configuring EventLogWriters. These can be used by consumers like [ghc-eventlog-socket](https://github.com/bgamari/ghc-eventlog-socket). - - - - - de6bbdf2 by Matheus Magalhães de Alcantara at 2019-11-23T18:55:23-05:00 Take care to not eta-reduce jumps in CorePrep CorePrep already had a check to prevent it from eta-reducing Ids that respond true to hasNoBinding (foreign calls, constructors for unboxed sums and products, and Ids with compulsory unfoldings). It did not, however, consider join points as ids that 'must be saturated'. Checking whether the Id responds True to 'isJoinId' should prevent CorePrep from turning saturated jumps like the following (from #17429) into undersaturated ones: (\ eta_XP -> join { mapped_s1vo _ = lvl_s1vs } in jump mapped_s1vo eta_XP) - - - - - 4a1e7e47 by Matheus Magalhães de Alcantara at 2019-11-23T18:55:23-05:00 Make CorePrep.tryEtaReducePrep and CoreUtils.tryEtaReduce line up Simon PJ says he prefers this fix to #17429 over banning eta-reduction for jumps entirely. Sure enough, this also works. Test case: simplCore/should_compile/T17429.hs - - - - - 15f1dc33 by Ryan Scott at 2019-11-23T18:56:00-05:00 Prevent -optc arguments from being duplicated in reverse order (#17471) This reverts a part of commit 7bc5d6c6578ab9d60a83b81c7cc14819afef32ba that causes all arguments to `-optc` (and `-optcxx`) to be passed twice to the C/C++ compiler, once in reverse order and then again in the correct order. While passing duplicate arguments is usually harmless it can cause breakage in this pattern, which is employed by Hackage libraries in the wild: ``` ghc Foo.hs foo.c -optc-D -optcFOO ``` As `FOO -D -D FOO` will cause compilers to error. Fixes #17471. - - - - - e85c9b22 by Ben Gamari at 2019-11-23T18:56:36-05:00 Bump ghc version to 8.11 - - - - - 0e6c2045 by Ben Gamari at 2019-11-23T18:57:12-05:00 rts: Consolidate spinlock implementation Previously we had two distinct implementations: one with spinlock profiling and another without. This seems like needless duplication. - - - - - cb11fcb5 by Ben Gamari at 2019-11-23T18:57:49-05:00 Packages: Don't use expectJust Throw a slightly more informative error on failure. Motivated by the errors seen in !2160. - - - - - 5747ebe9 by Sebastian Graf at 2019-11-23T18:58:25-05:00 Stricten functions ins GHC.Natural This brings `Natural` on par with `Integer` and fixes #17499. Also does some manual CSE for 0 and 1 literals. - - - - - c14b723f by Ömer Sinan Ağacan at 2019-11-23T18:59:06-05:00 Bump exceptions submodule Adds a few files generated by GHC's configure script to .gitignore - - - - - 7b4c7b75 by Brian Wignall at 2019-11-23T19:04:52-05:00 Fix typos - - - - - 6008206a by Viktor Dukhovni at 2019-11-24T14:33:18-05:00 On FreeBSD 12 sys/sysctl.h requires sys/types.h Else build fails with: In file included from ExecutablePath.hsc:42: /usr/include/sys/sysctl.h:1062:25: error: unknown type name 'u_int'; did you mean 'int'? int sysctl(const int *, u_int, void *, size_t *, const void *, size_t); ^~~~~ int compiling libraries/base/dist-install/build/System/Environment/ExecutablePath_hsc_make.c failed (exit code 1) Perhaps also also other FreeBSD releases, but additional include will no harm even if not needed. - - - - - b694b566 by Ben Gamari at 2019-11-24T14:33:54-05:00 configure: Fix HAVE_C11_ATOMICS macro Previously we were using AC_DEFINE instead of AC_DEFINE_UNQUOTED, resulted in the variable not being interpolated. Fixes #17505. - - - - - 8b8dc366 by Krzysztof Gogolewski at 2019-11-25T14:37:38+01:00 Remove prefix arrow support for GADTs (#17211) This reverts the change in #9096. The specialcasing done for prefix (->) is brittle and does not support VTA, type families, type synonyms etc. - - - - - 5a08f7d4 by Sebastian Graf at 2019-11-27T00:14:59-05:00 Make warnings for TH splices opt-in In #17270 we have the pattern-match checker emit incorrect warnings. The reason for that behavior is ultimately an inconsistency in whether we treat TH splices as written by the user (`FromSource :: Origin`) or as generated code (`Generated`). This was first reported in #14838. The current solution is to TH splices as `Generated` by default and only treat them as `FromSource` when the user requests so (-fenable-th-splice-warnings). There are multiple reasons for opt-in rather than opt-out: * It's not clear that the user that compiles a splice is the author of the code that produces the warning. Think of the situation where she just splices in code from a third-party library that produces incomplete pattern matches. In this scenario, the user isn't even able to fix that warning. * Gathering information for producing the warnings (pattern-match check warnings in particular) is costly. There's no point in doing so if the user is not interested in those warnings. Fixes #17270, but not #14838, because the proper solution needs a GHC proposal extending the TH AST syntax. - - - - - 8168b42a by Vladislav Zavialov at 2019-11-27T11:32:18+03:00 Whitespace-sensitive bang patterns (#1087, #17162) This patch implements a part of GHC Proposal #229 that covers five operators: * the bang operator (!) * the tilde operator (~) * the at operator (@) * the dollar operator ($) * the double dollar operator ($$) Based on surrounding whitespace, these operators are disambiguated into bang patterns, lazy patterns, strictness annotations, type applications, splices, and typed splices. This patch doesn't cover the (-) operator or the -Woperator-whitespace warning, which are left as future work. - - - - - 9e5477c4 by Ryan Scott at 2019-11-27T20:01:50-05:00 Fix @since annotations for isResourceVanishedError and friends (#17488) - - - - - e122ba33 by Sergei Trofimovich at 2019-11-27T20:02:29-05:00 .gitmodules: tweak 'exception' URL to avoid redirection warnings Avoid initial close warning of form: ``` Cloning into 'exceptions'... warning: redirecting to https://gitlab.haskell.org/ghc/packages/exceptions.git/ ``` Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 5f84b52a by Philipp Krüger at 2019-11-28T02:54:05-05:00 Reduce boolean blindness in OccInfo(OneOcc) #17482 * Transformed the type aliases `InterestingCxt`, `InsideLam` and `OneBranch` into data types. * Added Semigroup and Monoid instances for use in orOccInfo in OccurAnal.hs * Simplified some usage sites by using pattern matching instead of boolean algebra. Metric Increase: T12150 This increase was on a Mac-build of exactly 1%. This commit does *not* re-intruduce the asymptotic memory usage described in T12150. - - - - - 3748ba3a by Brian Wignall at 2019-11-28T02:54:52-05:00 Fix typos, using Wikipedia list of common typos - - - - - 6c59cc71 by Stefan Schulze Frielinghaus at 2019-11-28T02:55:33-05:00 Fix endian handling of LLVM backend Get rid of CPP macro WORDS_BIGENDIAN which is not defined anymore, and replace it by DynFlag. This fixes partially #17337. - - - - - 6985e0fc by Vladislav Zavialov at 2019-11-28T15:47:53+03:00 Factor out HsSCC/HsCoreAnn/HsTickPragma into HsPragE This is a refactoring with no user-visible changes (except for GHC API users). Consider the HsExpr constructors that correspond to user-written pragmas: HsSCC representing {-# SCC ... #-} HsCoreAnn representing {-# CORE ... #-} HsTickPragma representing {-# GENERATED ... #-} We can factor them out into a separate datatype, HsPragE. It makes the code a bit tidier, especially in the parser. Before this patch: hpc_annot :: { Located ( (([AddAnn],SourceText),(StringLiteral,(Int,Int),(Int,Int))), ((SourceText,SourceText),(SourceText,SourceText)) ) } After this patch: prag_hpc :: { Located ([AddAnn], HsPragE GhcPs) } - - - - - 7f695a20 by Ömer Sinan Ağacan at 2019-11-29T08:25:28-05:00 Pass ModDetails with (partial) ModIface in HscStatus (Partial) ModIface and ModDetails are generated at the same time, but they're passed differently: ModIface is passed in HscStatus consturctors while ModDetails is returned in a tuple. This refactors ModDetails passing so that it's passed around with ModIface in HscStatus constructors. This makes the code more consistent and hopefully easier to understand: ModIface and ModDetails are really very closely related. It makes sense to treat them the same way. - - - - - e921c90f by Ömer Sinan Ağacan at 2019-11-29T08:26:07-05:00 Improve few Foreign.Marshal.Utils docs In copyBytes and moveBytes mention which argument is source and which is destination. Also fixes some of the crazy indentation in the module and cleans trailing whitespace. - - - - - 316f2431 by Sebastian Graf at 2019-11-30T02:57:58-05:00 Hadrian docs: Rename the second "validate" entry to "slow-validate" [ci skip] That would be in line with the implementation. - - - - - 5aba5d32 by Vladislav Zavialov at 2019-11-30T02:58:34-05:00 Remove HasSrcSpan (#17494) Metric Decrease: haddock.compiler - - - - - d1de5c22 by Sylvain Henry at 2019-11-30T02:59:13-05:00 Use Hadrian by default in validate script (#17527) - - - - - 3a96a0b6 by Sebastian Graf at 2019-11-30T02:59:55-05:00 Simpler Semigroup instance for InsideLam and InterestingCtxt This mirrors the definition of `(&&)` and `(||)` now, relieving the Simplifier of a marginal amount of pressure. - - - - - f8cfe81a by Roland Senn at 2019-11-30T20:33:49+01:00 Improve tests for #17171 While backporting MR !1806 to 8.8.2 (!1885) I learnt the following: * Tests with `expect_fail` do not compare `*.stderr` output files. So a test using `expect_fail` will not detect future regressions on the `stderr` output. * To compare the `*.stderr` output files, I have to use the `exit_code(n)` function. * When a release is made, tests with `makefile_test` are converted to use `run_command`. * For the test `T17171a` the return code is `1` when running `makefile_test`, however it's `2` when running `run_command`. Therefore I decided: * To improve my tests for #17171 * To change test T17171a from `expect_fail` to `exit_code(2)` * To change both tests from `makefile_test` to `run_command` - - - - - 2b113fc9 by Vladislav Zavialov at 2019-12-01T08:17:05-05:00 Update DisambECP-related comments - - - - - beed7c3e by Ben Gamari at 2019-12-02T03:41:37-05:00 testsuite: Fix location of typing_stubs module This should fix the build on Debian 8. - - - - - 53251413 by Ben Gamari at 2019-12-02T03:42:14-05:00 testsuite: Don't override LD_LIBRARY_PATH, only prepend NixOS development environments often require that LD_LIBRARY_PATH be set in order to find system libraries. T1407 was overriding LD_LIBRARY_PATH, dropping these directories. Now it merely prepends, its directory. - - - - - 65400314 by Krzysztof Gogolewski at 2019-12-02T03:42:57-05:00 Convert warnings into assertions Since the invariants always hold in the testsuite, we can convert them to asserts. - - - - - 18baed64 by Alan Zimmerman at 2019-12-02T03:43:37-05:00 API Annotations: Unicode '->' on HsForallTy The code fragment type family Proxy2' ∷ ∀ k → k → Type where Proxy2' = Proxy' Generates AnnRarrow instead of AnnRarrowU for the first →. Fixes #17519 - - - - - 717f3236 by Brian Wignall at 2019-12-02T03:44:16-05:00 Fix more typos - - - - - bde48f8e by Ben Gamari at 2019-12-02T11:55:34-05:00 More Haddock syntax in GHC.Hs.Utils As suggested by RyanGlScott in !2163. - - - - - 038bedbc by Ben Gamari at 2019-12-02T11:56:18-05:00 Simplify: Fix pretty-printing of strictness A colleague recently hit the panic in Simplify.addEvals and I noticed that the message is quite unreadable due to incorrect pretty-printing. Fix this. - - - - - c500f652 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Fix changelog linting logic - - - - - 8ead967d by Ben Gamari at 2019-12-02T11:56:54-05:00 win32-init: Drop workaround for #17480 The `process` changes have now been merged into `hsc2hs`. (cherry picked from commit fa029f53132ad59f847ed012d3b835452cf16615) - - - - - d402209a by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Disable Sphinx build on Debian 8 The docutils version available appears to be too old to support the `table` directive's `:widths:` options. (cherry picked from commit 75764487a96a7a026948b5af5022781872d12baa) - - - - - f1f68824 by Ben Gamari at 2019-12-02T11:56:54-05:00 base: Fix <unistd.h> #include Previously we were including <sys/unistd.h> which is available on glibc but not musl. (cherry picked from commit e44b695ca7cb5f3f99eecfba05c9672c6a22205e) - - - - - 37eb94b3 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Bump Docker images Installs pxz on Centos7 (cherry picked from commit 86960e691f7a600be247c32a7cf795bf9abf7cc4) - - - - - aec98a79 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: pxz is unavailable on CentOS 7 Fall back to xz - - - - - 6708b8e5 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Set LANG on CentOS 7 It otherwise seems to default to ascii - - - - - 470ef0e7 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Consolidate release build configuration - - - - - 38338757 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Add Debian 10 builds - - - - - 012f13b5 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Fix Windows bindist collection Apparently variable interpolation in the `artifacts.paths` key of `gitlab-ci.yml` doesn't work on Windows as it does on WIndows. (cherry picked from commit 100cc756faa4468ed6950116bae30609c1c3468b) - - - - - a0f09e23 by Ben Gamari at 2019-12-02T11:56:54-05:00 testsuite: Simplify Python <3.5 fallback for TextIO (cherry picked from commit d092d8598694c23bc07cdcc504dff52fa5f33be1) - - - - - 2b2370ec by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Add release-x86_64-linux-deb9 job (cherry picked from commit cbedb3c4a90649f474cb716842ba53afc5a642ca) - - - - - b1c206fd by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Always build source tarball (cherry picked from commit 67b5de88ef923971f1980335137e3c7193213abd) - - - - - 4cbd5b47 by Sergei Trofimovich at 2019-12-02T11:57:33-05:00 configure.ac: make cross-compiler detection stricter Be more precise at detecting cross-compilation case. Before the change configuration $ ./configure --host=x86_64-pc-linux-gnu --target=x86_64-gentoo-linux-musl was not considered a cross-target. Even though libcs are different (`glibc` vs. `musl`). Without this patch build fails as: ``` "inplace/bin/ghc-cabal" check libraries/integer-gmp "inplace/bin/ghc-cabal" configure libraries/integer-gmp dist-install \ --with-ghc="/home/slyfox/dev/git/ghc/inplace/bin/ghc-stage1" \ --with-ghc-pkg="/home/slyfox/dev/git/ghc/inplace/bin/ghc-pkg" \ --disable-library-for-ghci --enable-library-vanilla --enable-library-for-ghci \ --enable-library-profiling --enable-shared --with-hscolour="/usr/bin/HsColour" \ --configure-option=CFLAGS="-Wall \ -Werror=unused-but-set-variable -Wno-error=inline \ -iquote /home/slyfox/dev/git/ghc/libraries/integer-gmp" \ --configure-option=LDFLAGS=" " --configure-option=CPPFLAGS=" \ " --gcc-options="-Wall -Werror=unused-but-set-variable -Wno-error=inline -iquote /home/slyfox/dev/git/ghc/libraries/integer-gmp \ " --with-gcc="x86_64-gentoo-linux-musl-gcc" --with-ld="x86_64-gentoo-linux-musl-ld.gold" --with-ar="x86_64-gentoo-linux-musl-ar" \ --with-alex="/usr/bin/alex" --with-happy="/usr/bin/happy" Configuring integer-gmp-1.0.2.0... configure: WARNING: unrecognized options: --with-compiler checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu checking for gcc... /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... configure: error: in `/home/slyfox/dev/git/ghc/libraries/integer-gmp/dist-install/build': configure: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details make[1]: *** [libraries/integer-gmp/ghc.mk:5: libraries/integer-gmp/dist-install/package-data.mk] Error 1 make: *** [Makefile:126: all] Error 2 ``` Note: here `ghc-stage1` is assumed to target `musl` target but is passed `glibc` toolchain. It happens because initial ./configure phase did not detect host/target as different. Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 5f7cb423 by Sylvain Henry at 2019-12-02T23:59:29-05:00 Add `timesInt2#` primop - - - - - fbbe18a2 by Sylvain Henry at 2019-12-02T23:59:29-05:00 Use the new timesInt2# primop in integer-gmp (#9431) - - - - - 5a4b8d0c by Athas at 2019-12-03T00:00:09-05:00 Document RTS behaviour upon encountering '--'. - - - - - 705a16df by Ben Gamari at 2019-12-03T07:11:33-05:00 Make BCO# lifted In #17424 Simon PJ noted that there is a potentially unsafe occurrence of unsafeCoerce#, coercing from an unlifted to lifted type. However, nowhere in the compiler do we assume that a BCO# is not a thunk. Moreover, in the case of a CAF the result returned by `createBCO` *will* be a thunk (as noted in [Updatable CAF BCOs]). Consequently it seems better to rather make BCO# a lifted type and rename it to BCO. - - - - - 35afe4f3 by Sylvain Henry at 2019-12-03T07:12:13-05:00 Use Int# primops in `Bits Int{8,16,32,64}` instances - - - - - 7a51b587 by Sylvain Henry at 2019-12-03T07:12:13-05:00 Add constant folding rule (#16402) narrowN (x .&. m) m .&. (2^N-1) = 2^N-1 ==> narrowN x e.g. narrow16 (x .&. 0x12FFFF) ==> narrow16 x - - - - - 10caee7f by Ben Gamari at 2019-12-03T21:04:50-05:00 users-guide: Add 8.12.1 release notes - - - - - 25019d18 by Ben Gamari at 2019-12-03T21:04:50-05:00 Drop Uniquable constraint for AnnTarget This relied on deriveUnique, which was far too subtle to be safely applied. Thankfully the instance doesn't appear to be used so let's just drop it. - - - - - 78b67ad0 by Ben Gamari at 2019-12-03T21:04:50-05:00 Simplify uniqAway This does two things: * Eliminate all uses of Unique.deriveUnique, which was quite easy to mis-use and extremely subtle. * Rename the previous "derived unique" notion to "local unique". This is possible because the only places where `uniqAway` can be safely used are those where local uniqueness (with respect to some InScopeSet) is sufficient. * Rework the implementation of VarEnv.uniqAway, as discussed in #17462. This should make the operation significantly more efficient than its previous iterative implementation.. Metric Decrease: T9872c T12227 T9233 T14683 T5030 T12545 hie002 Metric Increase: T9961 - - - - - f03a41d4 by Ben Gamari at 2019-12-03T21:05:27-05:00 Elf: Fix link info note generation Previously we would use the `.int` assembler directive to generate 32-bit words in the note section. However, `.int` is note guaranteed to produce 4-bytes; in fact, on some platforms (e.g. AArch64) it produces 8-bytes. Use the `.4bytes` directive to avoid this. Moreover, we used the `.align` directive, which is quite platform dependent. On AArch64 it appears to not even be idempotent (despite what the documentation claims). `.balign` is consequentially preferred as it offers consistent behavior across platforms. - - - - - 84585e5e by Vladislav Zavialov at 2019-12-05T16:07:44-05:00 Meaning-preserving SCC annotations (#15730) This patch implements GHC Proposal #176: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0176-scc-parsing.rst Before the change: 1 / 2 / 2 = 0.25 1 / {-# SCC "name" #-} 2 / 2 = 1.0 After the change: 1 / 2 / 2 = 0.25 1 / {-# SCC "name" #-} 2 / 2 = parse error - - - - - e49e5470 by Vladislav Zavialov at 2019-12-05T16:07:44-05:00 Improve error messages for SCC pragmas - - - - - a2b535d9 by Ben Gamari at 2019-12-05T16:07:45-05:00 users guide: Try to silence underfull \hbox warnings We use two tricks, as suggested here [1]: * Use microtype to try to reduce the incidence of underfull boxes * Bump up \hbadness to eliminate the warnings - - - - - 4e47217f by Bodigrim at 2019-12-05T16:07:47-05:00 Make sameNat and sameSymbol proxy-polymorphic - - - - - 8324f0b7 by Bodigrim at 2019-12-05T16:07:47-05:00 Test proxy-polymorphic sameNat and sameSymbol - - - - - 69001f54 by Ben Gamari at 2019-12-05T16:07:48-05:00 nonmoving: Clear segment bitmaps during sweep Previously we would clear the bitmaps of segments which we are going to sweep during the preparatory pause. However, this is unnecessary: the existence of the mark epoch ensures that the sweep will correctly identify non-reachable objects, even if we do not clear the bitmap. We now defer clearing the bitmap to sweep, which happens concurrently with mutation. - - - - - 58a9c429 by Ben Gamari at 2019-12-05T16:07:48-05:00 testsuite: Disable divByZero on non-NCG targets The LLVM backend does not guarantee any particular semantics for division by zero, making this test unreliable across platforms. - - - - - 8280bd8a by Ben Gamari at 2019-12-05T16:07:49-05:00 testsuite: Factor out terminal coloring - - - - - 92a52aaa by Ben Gamari at 2019-12-05T16:07:49-05:00 testsuite: Make performance metric summary more readable Along with some refactoring. - - - - - c4ca29c7 by Ben Gamari at 2019-12-05T16:07:49-05:00 testsuite: Use colors more consistently - - - - - 3354c68e by Vladislav Zavialov at 2019-12-05T16:07:49-05:00 Pretty-printing of the * kind Before this patch, GHC always printed the * kind unparenthesized. This led to two issues: 1. Sometimes GHC printed invalid or incorrect code. For example, GHC would print: type F @* x = x when it meant to print: type F @(*) x = x In the former case, instead of a kind application we were getting a type operator (@*). 2. Sometimes GHC printed kinds that were correct but hard to read. Should Either * Int be read as Either (*) Int or as (*) Either Int ? This depends on whether -XStarIsType is enabled, but it would be easier if we didn't have to check for the flag when reading the code. We can solve both problems by assigning (*) a different precedence. Note that Haskell98 kinds are not affected: ((* -> *) -> *) -> * does NOT become (((*) -> (*)) -> (*)) -> (*) The parentheses are added when (*) is used in a function argument position: F * * * becomes F (*) (*) (*) F A * B becomes F A (*) B Proxy * becomes Proxy (*) a * -> * becomes a (*) -> * - - - - - 70dd0e4b by Vladislav Zavialov at 2019-12-05T16:07:49-05:00 Parenthesize the * kind in TH.Ppr - - - - - a7a4efbf by Ben Gamari at 2019-12-05T16:07:49-05:00 rts/NonMovingSweep: Fix locking of new mutable list allocation Previously we used allocBlockOnNode_sync in nonmovingSweepMutLists despite the fact that we aren't in the GC and therefore the allocation spinlock isn't in use. This meant that sweep would end up spinning until the next minor GC, when the SM lock was moved away from the SM_MUTEX to the spinlock. This isn't a correctness issue but it sure isn't good for performance. Found thanks for Ward. Fixes #17539. - - - - - f171b358 by Matthias Braun at 2019-12-05T16:07:51-05:00 Fix typo in documentation of Base.hs. - - - - - 9897e8c8 by Gabor Greif at 2019-12-06T21:20:38-05:00 Implement pointer tagging for big families (#14373) Formerly we punted on these and evaluated constructors always got a tag of 1. We now cascade switches because we have to check the tag first and when it is MAX_PTR_TAG then get the precise tag from the info table and switch on that. The only technically tricky part is that the default case needs (logical) duplication. To do this we emit an extra label for it and branch to that from the second switch. This avoids duplicated codegen. Here's a simple example of the new code gen: data D = D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 On a 64-bit system previously all constructors would be tagged 1. With the new code gen D7 and D8 are tagged 7: [Lib.D7_con_entry() { ... {offset c1eu: // global R1 = R1 + 7; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; } }] [Lib.D8_con_entry() { ... {offset c1ez: // global R1 = R1 + 7; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; } }] When switching we now look at the info table only when the tag is 7. For example, if we derive Enum for the type above, the Cmm looks like this: c2Le: _s2Js::P64 = R1; _c2Lq::P64 = _s2Js::P64 & 7; switch [1 .. 7] _c2Lq::P64 { case 1 : goto c2Lk; case 2 : goto c2Ll; case 3 : goto c2Lm; case 4 : goto c2Ln; case 5 : goto c2Lo; case 6 : goto c2Lp; case 7 : goto c2Lj; } // Read info table for tag c2Lj: _c2Lv::I64 = %MO_UU_Conv_W32_W64(I32[I64[_s2Js::P64 & (-8)] - 4]); if (_c2Lv::I64 != 6) goto c2Lu; else goto c2Lt; Generated Cmm sizes do not change too much, but binaries are very slightly larger, due to the fact that the new instructions are longer in encoded form. E.g. previously entry code for D8 above would be 00000000000001c0 <Lib_D8_con_info>: 1c0: 48 ff c3 inc %rbx 1c3: ff 65 00 jmpq *0x0(%rbp) With this patch 00000000000001d0 <Lib_D8_con_info>: 1d0: 48 83 c3 07 add $0x7,%rbx 1d4: ff 65 00 jmpq *0x0(%rbp) This is one byte longer. Secondly, reading info table directly and then switching is shorter _c1co: movq -1(%rbx),%rax movl -4(%rax),%eax // Switch on info table tag jmp *_n1d5(,%rax,8) than doing the same switch, and then for the tag 7 doing another switch: // When tag is 7 _c1ct: andq $-8,%rbx movq (%rbx),%rax movl -4(%rax),%eax // Switch on info table tag ... Some changes of binary sizes in actual programs: - In NoFib the worst case is 0.1% increase in benchmark "parser" (see NoFib results below). All programs get slightly larger. - Stage 2 compiler size does not change. - In "containers" (the library) size of all object files increases 0.0005%. Size of the test program "bitqueue-properties" increases 0.03%. nofib benchmarks kindly provided by Ömer (@osa1): NoFib Results ============= -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS +0.0% 0.0% -0.0% -0.0% -0.0% CSD +0.0% 0.0% 0.0% +0.0% +0.0% FS +0.0% 0.0% 0.0% +0.0% 0.0% S +0.0% 0.0% -0.0% 0.0% 0.0% VS +0.0% 0.0% -0.0% +0.0% +0.0% VSD +0.0% 0.0% -0.0% +0.0% -0.0% VSM +0.0% 0.0% 0.0% 0.0% 0.0% anna +0.0% 0.0% +0.1% -0.9% -0.0% ansi +0.0% 0.0% -0.0% +0.0% +0.0% atom +0.0% 0.0% 0.0% 0.0% 0.0% awards +0.0% 0.0% -0.0% +0.0% 0.0% banner +0.0% 0.0% -0.0% +0.0% 0.0% bernouilli +0.0% 0.0% +0.0% +0.0% +0.0% binary-trees +0.0% 0.0% -0.0% -0.0% -0.0% boyer +0.0% 0.0% +0.0% 0.0% -0.0% boyer2 +0.0% 0.0% +0.0% 0.0% -0.0% bspt +0.0% 0.0% +0.0% +0.0% 0.0% cacheprof +0.0% 0.0% +0.1% -0.8% 0.0% calendar +0.0% 0.0% -0.0% +0.0% -0.0% cichelli +0.0% 0.0% +0.0% 0.0% 0.0% circsim +0.0% 0.0% -0.0% -0.1% -0.0% clausify +0.0% 0.0% +0.0% +0.0% 0.0% comp_lab_zift +0.0% 0.0% +0.0% 0.0% -0.0% compress +0.0% 0.0% +0.0% +0.0% 0.0% compress2 +0.0% 0.0% 0.0% 0.0% 0.0% constraints +0.0% 0.0% -0.0% -0.0% -0.0% cryptarithm1 +0.0% 0.0% +0.0% 0.0% 0.0% cryptarithm2 +0.0% 0.0% +0.0% -0.0% 0.0% cse +0.0% 0.0% +0.0% +0.0% 0.0% digits-of-e1 +0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 +0.0% 0.0% +0.0% -0.0% -0.0% dom-lt +0.0% 0.0% +0.0% +0.0% 0.0% eliza +0.0% 0.0% -0.0% +0.0% 0.0% event +0.0% 0.0% -0.0% -0.0% -0.0% exact-reals +0.0% 0.0% +0.0% +0.0% +0.0% exp3_8 +0.0% 0.0% -0.0% -0.0% -0.0% expert +0.0% 0.0% +0.0% +0.0% +0.0% fannkuch-redux +0.0% 0.0% +0.0% 0.0% 0.0% fasta +0.0% 0.0% -0.0% -0.0% -0.0% fem +0.0% 0.0% +0.0% +0.0% +0.0% fft +0.0% 0.0% +0.0% -0.0% -0.0% fft2 +0.0% 0.0% +0.0% +0.0% +0.0% fibheaps +0.0% 0.0% +0.0% +0.0% 0.0% fish +0.0% 0.0% +0.0% +0.0% 0.0% fluid +0.0% 0.0% +0.0% +0.0% +0.0% fulsom +0.0% 0.0% +0.0% -0.0% +0.0% gamteb +0.0% 0.0% +0.0% -0.0% -0.0% gcd +0.0% 0.0% +0.0% +0.0% 0.0% gen_regexps +0.0% 0.0% +0.0% -0.0% -0.0% genfft +0.0% 0.0% -0.0% -0.0% -0.0% gg +0.0% 0.0% 0.0% -0.0% 0.0% grep +0.0% 0.0% +0.0% +0.0% +0.0% hidden +0.0% 0.0% +0.0% -0.0% -0.0% hpg +0.0% 0.0% +0.0% -0.1% -0.0% ida +0.0% 0.0% +0.0% -0.0% -0.0% infer +0.0% 0.0% -0.0% -0.0% -0.0% integer +0.0% 0.0% -0.0% -0.0% -0.0% integrate +0.0% 0.0% 0.0% +0.0% 0.0% k-nucleotide +0.0% 0.0% -0.0% -0.0% -0.0% kahan +0.0% 0.0% -0.0% -0.0% -0.0% knights +0.0% 0.0% +0.0% -0.0% -0.0% lambda +0.0% 0.0% +1.2% -6.1% -0.0% last-piece +0.0% 0.0% +0.0% -0.0% -0.0% lcss +0.0% 0.0% +0.0% -0.0% -0.0% life +0.0% 0.0% +0.0% -0.0% -0.0% lift +0.0% 0.0% +0.0% +0.0% 0.0% linear +0.0% 0.0% +0.0% +0.0% +0.0% listcompr +0.0% 0.0% -0.0% -0.0% -0.0% listcopy +0.0% 0.0% -0.0% -0.0% -0.0% maillist +0.0% 0.0% +0.0% -0.0% -0.0% mandel +0.0% 0.0% +0.0% +0.0% +0.0% mandel2 +0.0% 0.0% +0.0% +0.0% -0.0% mate +0.0% 0.0% +0.0% +0.0% +0.0% minimax +0.0% 0.0% -0.0% +0.0% -0.0% mkhprog +0.0% 0.0% +0.0% +0.0% +0.0% multiplier +0.0% 0.0% 0.0% +0.0% -0.0% n-body +0.0% 0.0% +0.0% -0.0% -0.0% nucleic2 +0.0% 0.0% +0.0% +0.0% -0.0% para +0.0% 0.0% +0.0% +0.0% +0.0% paraffins +0.0% 0.0% +0.0% +0.0% +0.0% parser +0.1% 0.0% +0.4% -1.7% -0.0% parstof +0.0% 0.0% -0.0% -0.0% -0.0% pic +0.0% 0.0% +0.0% 0.0% -0.0% pidigits +0.0% 0.0% -0.0% -0.0% -0.0% power +0.0% 0.0% +0.0% -0.0% -0.0% pretty +0.0% 0.0% +0.0% +0.0% +0.0% primes +0.0% 0.0% +0.0% 0.0% 0.0% primetest +0.0% 0.0% +0.0% +0.0% +0.0% prolog +0.0% 0.0% +0.0% +0.0% +0.0% puzzle +0.0% 0.0% +0.0% +0.0% +0.0% queens +0.0% 0.0% 0.0% +0.0% +0.0% reptile +0.0% 0.0% +0.0% +0.0% 0.0% reverse-complem +0.0% 0.0% -0.0% -0.0% -0.0% rewrite +0.0% 0.0% +0.0% 0.0% -0.0% rfib +0.0% 0.0% +0.0% +0.0% +0.0% rsa +0.0% 0.0% +0.0% +0.0% +0.0% scc +0.0% 0.0% +0.0% +0.0% +0.0% sched +0.0% 0.0% +0.0% +0.0% +0.0% scs +0.0% 0.0% +0.0% +0.0% 0.0% simple +0.0% 0.0% +0.0% +0.0% +0.0% solid +0.0% 0.0% +0.0% +0.0% 0.0% sorting +0.0% 0.0% +0.0% -0.0% 0.0% spectral-norm +0.0% 0.0% -0.0% -0.0% -0.0% sphere +0.0% 0.0% +0.0% -1.0% 0.0% symalg +0.0% 0.0% +0.0% +0.0% +0.0% tak +0.0% 0.0% +0.0% +0.0% +0.0% transform +0.0% 0.0% +0.4% -1.3% +0.0% treejoin +0.0% 0.0% +0.0% -0.0% 0.0% typecheck +0.0% 0.0% -0.0% +0.0% 0.0% veritas +0.0% 0.0% +0.0% -0.1% +0.0% wang +0.0% 0.0% +0.0% +0.0% +0.0% wave4main +0.0% 0.0% +0.0% 0.0% -0.0% wheel-sieve1 +0.0% 0.0% +0.0% +0.0% +0.0% wheel-sieve2 +0.0% 0.0% +0.0% +0.0% 0.0% x2n1 +0.0% 0.0% +0.0% +0.0% 0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -6.1% -0.0% Max +0.1% 0.0% +1.2% +0.0% +0.0% Geometric Mean +0.0% -0.0% +0.0% -0.1% -0.0% NoFib GC Results ================ -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- circsim +0.0% 0.0% -0.0% -0.0% -0.0% constraints +0.0% 0.0% -0.0% 0.0% -0.0% fibheaps +0.0% 0.0% 0.0% -0.0% -0.0% fulsom +0.0% 0.0% 0.0% -0.6% -0.0% gc_bench +0.0% 0.0% 0.0% 0.0% -0.0% hash +0.0% 0.0% -0.0% -0.0% -0.0% lcss +0.0% 0.0% 0.0% -0.0% 0.0% mutstore1 +0.0% 0.0% 0.0% -0.0% -0.0% mutstore2 +0.0% 0.0% +0.0% -0.0% -0.0% power +0.0% 0.0% -0.0% 0.0% -0.0% spellcheck +0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -0.6% -0.0% Max +0.0% 0.0% +0.0% 0.0% 0.0% Geometric Mean +0.0% +0.0% +0.0% -0.1% +0.0% Fixes #14373 These performance regressions appear to be a fluke in CI. See the discussion in !1742 for details. Metric Increase: T6048 T12234 T12425 Naperian T12150 T5837 T13035 - - - - - ee07421f by Simon Peyton Jones at 2019-12-06T21:21:14-05:00 Work in progress on coercionLKind, coercionRKind This is a preliminary patch for #17515 - - - - - 0a4ca9eb by Simon Peyton Jones at 2019-12-06T21:21:14-05:00 Split up coercionKind This patch implements the idea in #17515, splitting `coercionKind` into: * `coercion{Left,Right}Kind`, which computes the left/right side of the pair * `coercionKind`, which computes the pair of coercible types This is reduces allocation since we frequently only need only one side of the pair. Specifically, we see the following improvements on x86-64 Debian 9: | test | new | old | relative chg. | | :------- | ---------: | ------------: | ------------: | | T5030 | 695537752 | 747641152.0 | -6.97% | | T5321Fun | 449315744 | 474009040.0 | -5.21% | | T9872a | 2611071400 | 2645040952.0 | -1.28% | | T9872c | 2957097904 | 2994260264.0 | -1.24% | | T12227 | 773435072 | 812367768.0 | -4.79% | | T12545 | 3142687224 | 3215714752.0 | -2.27% | | T14683 | 9392407664 | 9824775000.0 | -4.40% | Metric Decrease: T12545 T9872a T14683 T5030 T12227 T9872c T5321Fun T9872b - - - - - d46a72e1 by Gabor Greif at 2019-12-09T12:05:15-05:00 Fix comment typos The below is only necessary to fix the CI perf fluke that happened in 9897e8c8ef0b19a9571ef97a1d9bb050c1ee9121: ------------------------- Metric Decrease: T5837 T6048 T9020 T12425 T12234 T13035 T12150 Naperian ------------------------- - - - - - e3bba7e4 by Micha Wiedenmann at 2019-12-10T19:52:44-05:00 users guide: Motivation of DefaultSignatures - - - - - 843ceb38 by Ben Gamari at 2019-12-10T19:53:54-05:00 rts: Add a long form flag to enable the non-moving GC The old flag, `-xn`, was quite cryptic. Here we add `--nonmoving-gc` in addition. - - - - - 921d3238 by Ryan Scott at 2019-12-10T19:54:34-05:00 Ignore unary constraint tuples during typechecking (#17511) We deliberately avoid defining a magical `Unit%` class, for reasons that I have expounded upon in the newly added `Note [Ignore unary constraint tuples]` in `TcHsType`. However, a sneaky user could try to insert `Unit%` into their program by way of Template Haskell, leading to the interface-file error observed in #17511. To avoid this, any time we encounter a unary constraint tuple during typechecking, we drop the surrounding constraint tuple application. This is safe to do since `Unit% a` and `a` would be semantically equivalent (unlike other forms of unary tuples). Fixes #17511. - - - - - 436ec9f3 by Ben Gamari at 2019-12-10T19:55:37-05:00 gitlab-ci: Move changelog linting logic to shell script Allowing it to be easily used locally. - - - - - 2f6b434f by Ben Gamari at 2019-12-10T19:55:37-05:00 gitlab-ci: Move changelog linting logic to shell script Allowing it to be easily used locally. - - - - - 7a5a6e07 by Ben Gamari at 2019-12-10T19:56:25-05:00 base: Fix incorrect @since in GHC.Natural Fixes #17547. - - - - - 2bbfaf8a by Ben Gamari at 2019-12-10T19:57:01-05:00 hadrian: AArch64 supports the GHCi interpreter and SMP I'm not sure how this was omitted from the list of supported architectures. - - - - - 8f1ceb67 by John Ericson at 2019-12-10T19:57:39-05:00 Move Int# section of primops.txt.pp This matches the organization of the fixed-sized ones, and keeps each Int* next to its corresponding Word*. - - - - - 7a823b0f by John Ericson at 2019-12-10T19:57:39-05:00 Move Int64# and Word64# sections of primops.txt.pp This way it is next to the other fixed-sized ones. - - - - - 8dd9929a by Ben Gamari at 2019-12-10T19:58:19-05:00 testsuite: Add (broken) test for #17510 - - - - - 6e47a76a by Ben Gamari at 2019-12-10T19:58:59-05:00 Re-layout validate script This script was previously a whitespace nightmare. - - - - - f80c4a66 by Crazycolorz5 at 2019-12-11T14:12:17-05:00 rts: Specialize hashing at call site rather than in struct. Separate word and string hash tables on the type level, and do not store the hashing function. Thus when a different hash function is desire it is provided upon accessing the table. This is worst case the same as before the change, and in the majority of cases is better. Also mark the functions for aggressive inlining to improve performance. {F1686506} Reviewers: bgamari, erikd, simonmar Subscribers: rwbarton, thomie, carter GHC Trac Issues: #13165 Differential Revision: https://phabricator.haskell.org/D4889 - - - - - 2d1b9619 by Richard Eisenberg at 2019-12-11T14:12:55-05:00 Warn on inferred polymorphic recursion Silly users sometimes try to use visible dependent quantification and polymorphic recursion without a CUSK or SAK. This causes unexpected errors. So we now adjust expectations with a bit of helpful messaging. Closes #17541 and closes #17131. test cases: dependent/should_fail/T{17541{,b},17131} - - - - - 4dde485e by Oleg Grenrus at 2019-12-12T02:24:46-05:00 Add --show-unit-ids flag to ghc-pkg I only added it into --simple-output and ghc-pkg check output; there are probably other places where it can be adopted. - - - - - e6e1ec08 by Ben Gamari at 2019-12-12T02:25:33-05:00 testsuite: Simplify and clarify performance test baseline search The previous implementation was extremely complicated, seemingly to allow the local and CI namespaces to be searched incrementally. However, it's quite unclear why this is needed and moreover the implementation seems to have had quadratic runtime cost in the search depth(!). - - - - - 29c4609c by Ben Gamari at 2019-12-12T02:26:19-05:00 testsuite: Add test for #17549 - - - - - 9f0ee253 by Ben Gamari at 2019-12-12T02:26:56-05:00 gitlab-ci: Move -dwarf and -debug jobs to full-build stage This sacrifices some precision in favor of improving parallelism. - - - - - 7179b968 by Ben Gamari at 2019-12-12T02:27:34-05:00 Revert "rts: Drop redundant flags for libffi" This seems to have regressed builds using `--with-system-libffi` (#17520). This reverts commit 3ce18700f80a12c48a029b49c6201ad2410071bb. - - - - - cc7d5650 by Oleg Grenrus at 2019-12-16T10:20:56+02:00 Having no shake upper bound is irresposible Given that shake is far from "done" API wise, and is central component to the build system. - - - - - 9431f905 by Oleg Grenrus at 2019-12-16T10:55:50+02:00 Add index-state to hadrian/cabal.project Then one is freer to omit upper bounds, as we won't pick any new entries on Hackage while building hadrian itself. - - - - - 3e17a866 by Krzysztof Gogolewski at 2019-12-16T19:31:44-05:00 Remove dataConSig As suggested in #17291 - - - - - 75355fde by Krzysztof Gogolewski at 2019-12-16T19:31:44-05:00 Use "OrCoVar" functions less As described in #17291, we'd like to separate coercions and expressions in a more robust fashion. This is a small step in this direction. - `mkLocalId` now panicks on a covar. Calls where this was not the case were changed to `mkLocalIdOrCoVar`. - Don't use "OrCoVar" functions in places where we know the type is not a coercion. - - - - - f9686e13 by Richard Eisenberg at 2019-12-16T19:32:21-05:00 Do more validity checks for quantified constraints Close #17583. Test case: typecheck/should_fail/T17563 - - - - - af763765 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Fix Windows artifact collection Variable interpolation in gitlab-ci.yml apparently doesn't work. Sigh. - - - - - e6d4b902 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Use xz --threads on Debian 10 - - - - - 8ba650e9 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Allow debian 8 build to fail The python release shipped with deb8 (3.3) is too old for our testsuite driver. - - - - - ac25a3f6 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Use xz --threads on Alpine - - - - - cc628088 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Another approach for xz detection - - - - - 37d788ab by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Re-add release-x86_64-deb9 job Also eliminate some redundancy. - - - - - f8279138 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Drop redundant release-x86_64-linux-deb9 job - - - - - 8148ff06 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark cgrun057 as broken on ARMv7 Due to #17554. It's very surprising that this only occurs on ARMv7 but this is the only place I've seen this failure thusfar. - - - - - 85e5696d by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark prog001 as fragile on ARMv7 Due to #17555. - - - - - a5f0aab0 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T10272 as broken on ARMv7 Due to #17556. - - - - - 1e6827c6 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T13825-debugger as broken on ARMv7 Due to #17557. - - - - - 7cef0b7d by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T14028 as broken on ARMv7 Due to #17558. - - - - - 6ea4eb4b by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Make ghc_built_by_llvm check more precise Previously it would hackily look at the flavour name to determine whether LLVM was used to build stage2 ghc. However, this didn't work at all with Hadrian and would miss cases like ARM where we use the LLVM backend by default. See #16087 for the motivation for why ghc_built_by_llvm is needed at all. This should catch one of the ARMv7 failures described in #17555. - - - - - c3e82bf7 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T5435_* tests as broken on ARM `T5435_v_asm_a`, `T5435_v_asm_b`, and `T5435_v_gcc` all fail on ARMv7. See #17559. - - - - - eb2aa851 by Ben Gamari at 2019-12-17T07:24:40-05:00 gitlab-ci: Don't allow armv7 jobs to fail - - - - - efc92216 by Ben Gamari at 2019-12-17T07:24:40-05:00 Revert "testsuite: Mark cgrun057 as broken on ARMv7" This reverts commit 6cfc47ec8a478e1751cb3e7338954da1853c3996. - - - - - 1d2bb9eb by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark print002 as fragile on ARM Due to #17557. Also accepting spurious performance change. Metric Decrease: T1969 - - - - - 41f4e4fb by Josh Meredith at 2019-12-17T07:25:17-05:00 Fix ambiguous occurence error when building Hadrian - - - - - 4374983a by Josh Meredith at 2019-12-17T07:25:17-05:00 Rename SphinxMode constructors - - - - - a8f7ecd5 by Josh Meredith at 2019-12-17T07:25:17-05:00 Use *Mode suffix instead of *M - - - - - 58655b9d by Sylvain Henry at 2019-12-18T13:43:37+01:00 Add GHC-API logging hooks * Add 'dumpAction' hook to DynFlags. It allows GHC API users to catch dumped intermediate codes and information. The format of the dump (Core, Stg, raw text, etc.) is now reported allowing easier automatic handling. * Add 'traceAction' hook to DynFlags. Some dumps go through the trace mechanism (for instance unfoldings that have been considered for inlining). This is problematic because: 1) dumps aren't written into files even with -ddump-to-file on 2) dumps are written on stdout even with GHC API 3) in this specific case, dumping depends on unsafe globally stored DynFlags which is bad for GHC API users We introduce 'traceAction' hook which allows GHC API to catch those traces and to avoid using globally stored DynFlags. * Avoid dumping empty logs via dumpAction/traceAction (but still write empty files to keep the existing behavior) - - - - - fad866e0 by Moritz Kiefer at 2019-12-19T11:15:39-05:00 Avoid race condition in hDuplicateTo In our codebase we have some code along the lines of ``` newStdout <- hDuplicate stdout stderr `hDuplicateTo` stdout ``` to avoid stray `putStrLn`s from corrupting a protocol (LSP) that is run over stdout. On CI we have seen a bunch of issues where `dup2` returned `EBUSY` so this fails with `ResourceExhausted` in Haskell. I’ve spent some time looking at the docs for `dup2` and the code in `base` and afaict the following race condition is being triggered here: 1. The user calls `hDuplicateTo stderr stdout`. 2. `hDuplicateTo` calls `hClose_help stdout_`, this closes the file handle for stdout. 3. The file handle for stdout is now free, so another thread allocating a file might get stdout. 4. If `dup2` is called while `stdout` (now pointing to something else) is half-open, it returns EBUSY. I think there might actually be an even worse case where `dup2` is run after FD 1 is fully open again. In that case, you will end up not just redirecting the original stdout to stderr but also the whatever resulted in that file handle being allocated. As far as I can tell, `dup2` takes care of closing the file handle itself so there is no reason to do this in `hDuplicateTo`. So this PR replaces the call to `hClose_help` by the only part of `hClose_help` that we actually care about, namely, `flushWriteBuffer`. I tested this on our codebase fairly extensively and haven’t been able to reproduce the issue with this patch. - - - - - 0c114c65 by Sylvain Henry at 2019-12-19T11:16:17-05:00 Handle large ARR_WORDS in heap census (fix #17572) We can do a heap census with a non-profiling RTS. With a non-profiling RTS we don't zero superfluous bytes of shrunk arrays hence a need to handle the case specifically to avoid a crash. Revert part of a586b33f8e8ad60b5c5ef3501c89e9b71794bbed - - - - - 1a0d1a65 by John Ericson at 2019-12-20T10:50:22-05:00 Deduplicate copied monad failure handler code - - - - - 70e56b27 by Ryan Scott at 2019-12-20T10:50:57-05:00 lookupBindGroupOcc: recommend names in the same namespace (#17593) Previously, `lookupBindGroupOcc`'s error message would recommend all similar names in scope, regardless of whether they were type constructors, data constructors, or functions, leading to the confusion witnessed in #17593. This is easily fixed by only recommending names in the same namespace, using the `nameSpacesRelated` function. Fixes #17593. - - - - - 3c12355e by Stefan Schulze Frielinghaus at 2019-12-24T01:03:44-05:00 Fix endian handling w.r.t. CPP macro WORDS_BIGENDIAN Include header file `ghcautoconf.h` where the CPP macro `WORDS_BIGENDIAN` is defined. This finally fixes #17337 (in conjunction with commit 6c59cc71dc). - - - - - 11f8eef5 by Stefan Schulze Frielinghaus at 2019-12-24T01:03:44-05:00 fixup! Fix endian handling w.r.t. CPP macro WORDS_BIGENDIAN - - - - - 40327b03 by Sylvain Henry at 2019-12-24T01:04:24-05:00 Remove outdated comment - - - - - aeea92ef by Sylvain Henry at 2019-12-25T19:23:54-05:00 Switch to ReadTheDocs theme for the user-guide - - - - - 26493eab by Gabor Greif at 2019-12-25T19:24:32-05:00 Fix copy-paste error in comment - - - - - 776df719 by Gabor Greif at 2019-12-25T19:24:32-05:00 Fix comment about minimal gcc version to be consistent what FP_GCC_VERSION requires - - - - - 3b17114d by Ömer Sinan Ağacan at 2019-12-26T14:09:11-05:00 Minor refactor in ghc.cabal.in: - Remove outdated comments - Move cutils.c from parser to cbits - Remove unused cutils.h - - - - - 334290b6 by Ryan Scott at 2019-12-26T14:09:48-05:00 Replace panic/notHandled with noExtCon in DsMeta There are many spots in `DsMeta` where `panic` or `notHandled` is used after pattern-matching on a TTG extension constructor. This is overkill, however, as using `noExtCon` would work just as well. This patch switches out these panics for `noExtCon`. - - - - - 68252aa3 by Ben Gamari at 2019-12-27T15:11:38-05:00 testsuite: Skip T17499 when built against integer-simple Since it routinely times out in CI. - - - - - 0c51aeeb by Gabor Greif at 2019-12-27T15:12:17-05:00 suppress popup dialog about missing Xcode at configure tested with `bash` and `zsh`. - - - - - 8d76bcc2 by Gabor Greif at 2019-12-27T15:12:17-05:00 while at it rename XCode to the official Xcode - - - - - 47a68205 by Ben Gamari at 2019-12-27T15:12:55-05:00 testsuite: Mark cgrun057 as fragile on ARM As reported in #17554. Only marking on ARM for now although there is evidence to suggest that the issue may occur on other platforms as well. - - - - - d03dec8f by Gabor Greif at 2019-12-27T15:13:32-05:00 use shell variable CcLlvmBackend for test Previously we used `AC_DEFINE`d variable `CC_LLVM_BACKEND` which has an empty shell expansion. - - - - - 2528e684 by Ben Gamari at 2019-12-30T06:51:32-05:00 driver: Include debug level in the recompilation check hash Fixes #17586. - - - - - f14bb50b by Ben Gamari at 2019-12-30T06:52:09-05:00 rts: Ensure that nonmoving gc isn't used with profiling - - - - - b426de37 by Ben Gamari at 2019-12-30T06:52:45-05:00 llvmGen: Ensure that entry labels don't have predecessors The LLVM IR forbids the entry label of a procedure from having any predecessors. In the case of a simple looping function the LLVM code generator broke this invariant, as noted in #17589. Fix this by moving the function prologue to its own basic block, as suggested by @kavon in #11649. Fixes #11649 and #17589. - - - - - 613f7265 by Ben Gamari at 2019-12-30T06:52:45-05:00 llvmGen: Drop old fix for #11649 This was a hack which is no longer necessary now since we introduce a dedicated entry block for each procedure. - - - - - fdeffa5e by Ben Gamari at 2019-12-30T06:53:23-05:00 rts: Error on invalid --numa flags Previously things like `+RTS --numa-debug` would enable NUMA support, despite being an invalid flag. - - - - - 9ce3ba68 by Ben Gamari at 2019-12-30T06:53:23-05:00 rts: Fix --debug-numa mode under Docker As noted in #17606, Docker disallows the get_mempolicy syscall by default. This caused numerous tests to fail under CI in the `debug_numa` way. Avoid this by disabling the NUMA probing logic when --debug-numa is in use, instead setting n_numa_nodes in RtsFlags.c. Fixes #17606. - - - - - 5baa2a43 by Ben Gamari at 2019-12-30T06:54:01-05:00 testsuite: Disable derefnull when built with LLVM LLVM does not guarantee any particular semantics when dereferencing null pointers. Consequently, this test actually passes when built with the LLVM backend. - - - - - bd544d3d by Ben Gamari at 2019-12-30T06:54:38-05:00 hadrian: Track hash of Cabal Setup builder arguments Lest we fail to rebuild when they change. Fixes #17611. - - - - - 6e2c495e by Ben Gamari at 2019-12-30T06:55:19-05:00 TcIface: Fix inverted logic in typechecking of source ticks Previously we would throw away source ticks when the debug level was non-zero. This is precisely the opposite of what was intended. Fixes #17616. Metric Decrease: T13056 T9020 T9961 T12425 - - - - - 7fad387d by Ben Gamari at 2019-12-30T06:55:55-05:00 perf_notes: Add --zero-y argument This makes it easier to see the true magnitude of fluctuations. Also do some house-keeping in the argument parsing department. - - - - - 0d42b287 by Ben Gamari at 2019-12-30T06:55:55-05:00 testsuite: Enlarge acceptance window for T1969 As noted in #17624, it's quite unstable, especially, for some reason, on i386 and armv7 (something about 32-bit platforms perhaps?). Metric Increase: T1969 - - - - - eb608235 by Sylvain Henry at 2019-12-31T14:22:32-05:00 Module hierarchy (#13009): Stg - - - - - d710fd66 by Vladislav Zavialov at 2019-12-31T14:23:10-05:00 Testsuite: update some Haddock tests Fixed tests: * haddockA039: added to all.T * haddockE004: replaced with T17561 (marked as expect_broken) New tests: * haddockA040: deriving clause for a data instance * haddockA041: haddock and CPP #include - - - - - 859ebdd4 by Kevin Buhr at 2019-12-31T23:44:39-05:00 Add "-Iw" RTS flag for minimum wait between idle GCs (#11134) - - - - - dd4b6551 by Kevin Buhr at 2019-12-31T23:44:39-05:00 Add additional Note explaining the -Iw flag - - - - - c4279ff1 by Kevin Buhr at 2019-12-31T23:44:39-05:00 Fix some sloppy indentation - - - - - b84c09d5 by Ömer Sinan Ağacan at 2019-12-31T23:45:19-05:00 Tweak Cmm dumps to avoid generating sections for empty groups When dumping Cmm groups check if the group is empty, to avoid generating empty sections in dump files like ==================== Output Cmm ==================== [] Also fixes a few bad indentation in the code around changes. - - - - - b2e0323f by Gabor Greif at 2020-01-03T21:22:36-05:00 Simplify mrStr - - - - - 3c9dc06b by Brian Wignall at 2020-01-04T15:55:06-05:00 Fix typos, via a Levenshtein-style corrector - - - - - d561c8f6 by Sylvain Henry at 2020-01-04T15:55:46-05:00 Add Cmm related hooks * stgToCmm hook * cmmToRawCmm hook These hooks are used by Asterius and could be useful to other clients of the GHC API. It increases the Parser dependencies (test CountParserDeps) to 184. It's still less than 200 which was the initial request (cf https://mail.haskell.org/pipermail/ghc-devs/2019-September/018122.html) so I think it's ok to merge this. - - - - - ae6b6276 by Oleg Grenrus at 2020-01-04T15:56:22-05:00 Update to Cabal submodule to v3.2.0.0-alpha3 Metric Increase: haddock.Cabal - - - - - 073f7cfd by Vladislav Zavialov at 2020-01-04T15:56:59-05:00 Add lexerDbg to dump the tokens fed to the parser This a small utility function that comes in handy when debugging the lexer and the parser. - - - - - 558d4d4a by Sylvain Henry at 2020-01-04T15:57:38-05:00 Split integerGmpInternals test in several parts This is to prepare for ghc-bignum which implements some but not all of gmp functions. - - - - - 4056b966 by Ben Gamari at 2020-01-04T15:58:15-05:00 testsuite: Mark cgrun057 as fragile on all platforms I have seen this fail both on x86-64/Debian 9 and armv7/Debian 9 See #17554. - - - - - 5ffea0c6 by Tamar Christina at 2020-01-06T18:38:37-05:00 Fix overflow. - - - - - 99a9f51b by Sylvain Henry at 2020-01-06T18:39:22-05:00 Module hierarchy: Iface (cf #13009) - - - - - 7aa4a061 by Ben Gamari at 2020-01-07T13:11:48-05:00 configure: Only check GCC version if CC is GCC Also refactor FP_GCC_EXTRA_FLAGS in a few ways: * We no longer support compilers which lack support for -fno-builtin and -fwrapv so remove the condition on GccVersion * These flags are only necessary when using the via-C backend so make them conditional on Unregisterised. Fixes #15742. - - - - - 0805ed7e by John Ericson at 2020-01-07T13:12:25-05:00 Use non-empty lists to remove partiality in matching code - - - - - 7844f3a8 by Ben Gamari at 2020-01-07T13:13:02-05:00 testsuite: Mark T17073 as broken on Windows Due to #17607. - - - - - acf40cae by Ben Gamari at 2020-01-07T13:13:02-05:00 gitlab-ci: Disallow Windows from failing - - - - - 34bc02c7 by Ben Gamari at 2020-01-07T13:13:02-05:00 configure: Find Python3 for testsuite In addition, we prefer the Mingw64 Python distribution on Windows due to #17483. - - - - - e35fe8d5 by Ben Gamari at 2020-01-07T13:13:02-05:00 testsuite: Fix Windows platform test Previously we used platform.system() and while this worked fine (e.g. returned `Windows`, as expected) locally under both msys and MingW64 Python distributions, it inexplicably returned `MINGW64_NT-10.0` under MingW64 Python on CI. It seems os.name is more reliable so we now use that instead.. - - - - - 48ef6217 by Ben Gamari at 2020-01-07T13:13:39-05:00 gitlab-ci: Rename push-test-metrics.sh to test-metrics.sh Refactoring to follow. - - - - - 2234fa92 by Ben Gamari at 2020-01-07T13:13:39-05:00 gitlab-ci: Pull test metrics before running testsuite Otherwise the testsuite driver may not have an up-to-date baseline. - - - - - 1ca9adbc by Sylvain Henry at 2020-01-07T13:14:18-05:00 Remove `parallel` check from configure.ac `parallel` is no longer a submodule since 3cb063c805ec841ca33b8371ef8aba9329221b6c - - - - - b69a3460 by Ryan Scott at 2020-01-07T13:14:57-05:00 Monomorphize HsModule to GhcPs (#17642) Analyzing the call sites for `HsModule` reveals that it is only ever used with parsed code (i.e., `GhcPs`). This simplifies `HsModule` by concretizing its `pass` parameter to always be `GhcPs`. Fixes #17642. - - - - - d491a679 by Sylvain Henry at 2020-01-08T06:16:31-05:00 Module hierarchy: Renamer (cf #13009) - - - - - d589410f by Ben Gamari at 2020-01-08T06:17:09-05:00 Bump haskeline submodule to 0.8.0.1 (cherry picked from commit feb3b955402d53c3875dd7a9a39f322827e5bd69) - - - - - 923a1272 by Ryan Scott at 2020-01-08T06:17:47-05:00 Print Core type applications with no whitespace after @ (#17643) This brings the pretty-printer for Core in line with how visible type applications are normally printed: namely, with no whitespace after the `@` character (i.e., `f @a` instead of `f @ a`). While I'm in town, I also give the same treatment to type abstractions (i.e., `\(@a)` instead of `\(@ a)`) and coercion applications (i.e., `f @~x` instead of `f @~ x`). Fixes #17643. - - - - - 49f83a0d by Adam Sandberg Eriksson at 2020-01-12T21:28:09-05:00 improve docs for HeaderInfo.getImports [skip ci] - - - - - 9129210f by Matthew Pickering at 2020-01-12T21:28:47-05:00 Overloaded Quotation Brackets (#246) This patch implements overloaded quotation brackets which generalise the desugaring of all quotation forms in terms of a new minimal interface. The main change is that a quotation, for example, [e| 5 |], will now have type `Quote m => m Exp` rather than `Q Exp`. The `Quote` typeclass contains a single method for generating new names which is used when desugaring binding structures. The return type of functions from the `Lift` type class, `lift` and `liftTyped` have been restricted to `forall m . Quote m => m Exp` rather than returning a result in a Q monad. More details about the feature can be read in the GHC proposal. https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0246-overloaded-bracket.rst - - - - - 350e2b78 by Richard Eisenberg at 2020-01-12T21:29:27-05:00 Don't zap to Any; error instead This changes GHC's treatment of so-called Naughty Quantification Candidates to issue errors, instead of zapping to Any. Close #16775. No new test cases, because existing ones cover this well. - - - - - 0b5ddc7f by Brian Wignall at 2020-01-12T21:30:08-05:00 Fix more typos, via an improved Levenshtein-style corrector - - - - - f732dbec by Ben Gamari at 2020-01-12T21:30:49-05:00 gitlab-ci: Retain bindists used by head.hackage for longer Previously we would keep them for two weeks. However, on the stable branches two weeks can easily elapse with no pushes. - - - - - c8636da5 by Sylvain Henry at 2020-01-12T21:31:30-05:00 Fix LANG=C for readelf invocation in T14999 The test fails when used with LANG=fr_FR.UTF-8 - - - - - 077a88de by Jean-Baptiste Mazon at 2020-01-12T21:32:08-05:00 users-guide/debug-info: typo “behivior” - - - - - 61916c5d by Simon Peyton Jones at 2020-01-12T21:32:44-05:00 Add comments about TH levels - - - - - 1fd766ca by Simon Peyton Jones at 2020-01-12T21:32:44-05:00 Comments about constraint floating - - - - - de01427e by Simon Peyton Jones at 2020-01-12T21:32:45-05:00 Minor refactor around quantified constraints This patch clarifies a dark corner of quantified constraints. * See Note [Yukky eq_sel for a HoleDest] in TcSMonad * Minor refactor, breaking out new function TcInteract.doTopReactEqPred - - - - - 30be3bf1 by Simon Peyton Jones at 2020-01-12T21:32:45-05:00 Comments in TcHsType - - - - - c5977d4d by Sebastian Graf at 2020-01-16T05:58:58-05:00 Better documentation for mkEtaWW [skip ci] So that hopefully I understand it faster next time. Also got rid of the confusing `orig_expr`, which makes the call site in `etaExpand` look out of sync with the passed `n` (which is not the original `n`). - - - - - 22c0bdc3 by John Ericson at 2020-01-16T05:59:37-05:00 Handle TagToEnum in the same big case as the other primops Before, it was a panic because it was handled above. But there must have been an error in my reasoning (another caller?) because #17442 reported the panic was hit. But, rather than figuring out what happened, I can just make it impossible by construction. By adding just a bit more bureaucracy in the return types, I can handle TagToEnum in the same case as all the others, so the big case is is now total, and the panic is removed. Fixes #17442 - - - - - ee5d63f4 by John Ericson at 2020-01-16T05:59:37-05:00 Get rid of OpDest `OpDest` was basically a defunctionalization. Just turn the code that cased on it into those functions, and call them directly. - - - - - 1ff55226 by John Ericson at 2020-01-16T06:00:16-05:00 Remove special case case of bool during STG -> C-- Allow removing the no longer needed cgPrimOp, getting rid of a small a small layer violation too. Change which made the special case no longer needed was #6135 / 6579a6c73082387f82b994305011f011d9d8382b, which dates back to 2013, making me feel better. - - - - - f416fe64 by Adam Wespiser at 2020-01-16T06:00:53-05:00 replace dead html link (fixes #17661) - - - - - f6bf2ce8 by Sebastian Graf at 2020-01-16T06:01:32-05:00 Revert "`exprOkForSpeculation` for Note [IO hack in the demand analyser]" This reverts commit ce64b397777408731c6dd3f5c55ea8415f9f565b on the grounds of the regression it would introduce in a couple of packages. Fixes #17653. Also undoes a slight metric increase in #13701 introduced by that commit that we didn't see prior to !1983. Metric Decrease: T13701 - - - - - a71323ff by Ben Gamari at 2020-01-17T08:43:16-05:00 gitlab-ci: Don't FORCE_SYMLINKS on Windows Not all runners have symlink permissions enabled. - - - - - 0499e3bc by Ömer Sinan Ağacan at 2020-01-20T15:31:33-05:00 Fix +RTS -Z flag documentation Stack squeezing is done on context switch, not on GC or stack overflow. Fix the documentation. Fixes #17685 [ci skip] - - - - - a661df91 by Ömer Sinan Ağacan at 2020-01-20T15:32:13-05:00 Document Stg.FVs module Fixes #17662 [ci skip] - - - - - db24e480 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Don't trash STG registers Fixes #13904. - - - - - f3d7fdb3 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Fix typo in readnone attribute - - - - - 442751c6 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Add lower-expect to the -O0 optimisation set @kavon says that this will improve block layout for stack checks. - - - - - e90ecc93 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Fix #14251 Fixes the calling convention for functions passing raw SSE-register values by adding padding as needed to get the values in the right registers. This problem cropped up when some args were unused an dropped from the live list. This folds together 2e23e1c7de01c92b038e55ce53d11bf9db993dd4 and 73273be476a8cc6c13368660b042b3b0614fd928 previously from @kavon. Metric Increase: T12707 ManyConstructors - - - - - 66e511a4 by Ben Gamari at 2020-01-20T15:33:28-05:00 testsuite: Preserve more information in framework failures Namely print the entire exception in hopes that this will help track down #17649. - - - - - b62b8cea by Ömer Sinan Ağacan at 2020-01-20T15:34:06-05:00 Remove deprecated -smp flag It was deprecated in 2012 with 46258b40 - - - - - 0c04a86a by Ben Gamari at 2020-01-20T15:34:43-05:00 gitlab-ci: Reenable submodule linter - - - - - 2bfabd22 by Ben Gamari at 2020-01-20T15:34:43-05:00 gitlab-ci: Allow submodule cleaning to fail on Windows Currently CI is inexplicably failing with ``` $ git submodule foreach git clean -xdf fatal: not a git repository: libffi-tarballs/../.git/modules/libffi-tarballs ``` I have no idea how this working tree got into such a state but we do need to fail more gracefully when it happens. Consequently, we allow the cleaning step to fail. - - - - - 14bced99 by Xavier Denis at 2020-01-20T15:35:21-05:00 Put the docs for :instances in alphabetical position - - - - - 7e0bb82b by Ben Gamari at 2020-01-20T15:35:57-05:00 Add missing Note [Improvement from Ground Wanteds] Closes #17659. - - - - - 17e43a7c by Ben Gamari at 2020-01-20T15:36:32-05:00 unregisterised: Fix declaration for stg_NO_FINALIZER Previously it had a redundant _entry suffix. We never noticed this previously presumably because we never generated references to it (however hard to believe this may be). However, it did start failing in !1304. - - - - - 3dae006f by PHO at 2020-01-20T15:37:08-05:00 Avoid ./configure failure on NetBSD - - - - - 738e2912 by Ben Gamari at 2020-01-24T13:42:56-05:00 testsuite: Widen acceptance window of T1969 I have seen >20% fluctuations in this number, leading to spurious failures. - - - - - ad4eb7a7 by Gabor Greif at 2020-01-25T05:19:07-05:00 Document the fact, that openFileBlocking can consume an OS thread indefinitely. Also state that a deadlock can happen with the non-threaded runtime. [ci skip] - - - - - be910728 by Sebastian Graf at 2020-01-25T05:19:46-05:00 `-ddump-str-signatures` dumps Text, not STG [skip ci] - - - - - 0e57d8a1 by Ömer Sinan Ağacan at 2020-01-25T05:20:27-05:00 Fix chaining tagged and untagged ptrs in compacting GC Currently compacting GC has the invariant that in a chain all fields are tagged the same. However this does not really hold: root pointers are not tagged, so when we thread a root we initialize a chain without a tag. When the pointed objects is evaluated and we have more pointers to it from the heap, we then add *tagged* fields to the chain (because pointers to it from the heap are tagged), ending up chaining fields with different tags (pointers from roots are NOT tagged, pointers from heap are). This breaks the invariant and as a result compacting GC turns tagged pointers into non-tagged. This later causes problem in the generated code where we do reads assuming that the pointer is aligned, e.g. 0x7(%rax) -- assumes that pointer is tagged 1 which causes misaligned reads. This caused #17088. We fix this using the "pointer tagging for large families" patch (#14373, !1742): - With the pointer tagging patch the GC can know what the tagged pointer to a CONSTR should be (previously we'd need to know the family size -- large families are always tagged 1, small families are tagged depending on the constructor). - Since we now know what the tags should be we no longer need to store the pointer tag in the info table pointers when forming chains in the compacting GC. As a result we no longer need to tag pointers in chains with 1/2 depending on whether the field points to an info table pointer, or to another field: an info table pointer is always tagged 0, everything else in the chain is tagged 1. The lost tags in pointers can be retrieved by looking at the info table. Finally, instead of using tag 1 for fields and tag 0 for info table pointers, we use two different tags for fields: - 1 for fields that have untagged pointers - 2 for fields that have tagged pointers When unchaining we then look at the pointer to a field, and depending on its tag we either leave a tagged pointer or an untagged pointer in the field. This allows chaining untagged and tagged fields together in compacting GC. Fixes #17088 Nofib results ------------- Binaries are smaller because of smaller `Compact.c` code. make mode=fast EXTRA_RUNTEST_OPTS="-cachegrind" EXTRA_HC_OPTS="-with-rtsopts=-c" NoFibRuns=1 -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.3% 0.0% +0.0% +0.0% +0.0% CSD -0.3% 0.0% +0.0% +0.0% +0.0% FS -0.3% 0.0% +0.0% -0.0% -0.0% S -0.3% 0.0% +5.4% +0.8% +3.9% VS -0.3% 0.0% +0.0% -0.0% -0.0% VSD -0.3% 0.0% -0.0% -0.0% -0.2% VSM -0.3% 0.0% +0.0% +0.0% +0.0% anna -0.1% 0.0% +0.0% +0.0% +0.0% ansi -0.3% 0.0% +0.1% +0.0% +0.0% atom -0.2% 0.0% +0.0% +0.0% +0.0% awards -0.2% 0.0% +0.0% 0.0% -0.0% banner -0.3% 0.0% +0.0% +0.0% +0.0% bernouilli -0.3% 0.0% +0.1% +0.0% +0.0% binary-trees -0.2% 0.0% +0.0% 0.0% +0.0% boyer -0.3% 0.0% +0.2% +0.0% +0.0% boyer2 -0.2% 0.0% +0.2% +0.1% +0.0% bspt -0.2% 0.0% +0.0% +0.0% +0.0% cacheprof -0.2% 0.0% +0.0% +0.0% +0.0% calendar -0.3% 0.0% +0.0% +0.0% +0.0% cichelli -0.3% 0.0% +1.1% +0.2% +0.5% circsim -0.2% 0.0% +0.0% -0.0% -0.0% clausify -0.3% 0.0% +0.0% -0.0% -0.0% comp_lab_zift -0.2% 0.0% +0.0% +0.0% +0.0% compress -0.3% 0.0% +0.0% +0.0% +0.0% compress2 -0.3% 0.0% +0.0% -0.0% -0.0% constraints -0.3% 0.0% +0.2% +0.1% +0.1% cryptarithm1 -0.3% 0.0% +0.0% -0.0% 0.0% cryptarithm2 -0.3% 0.0% +0.0% +0.0% +0.0% cse -0.3% 0.0% +0.0% +0.0% +0.0% digits-of-e1 -0.3% 0.0% +0.0% +0.0% +0.0% digits-of-e2 -0.3% 0.0% +0.0% +0.0% -0.0% dom-lt -0.2% 0.0% +0.0% +0.0% +0.0% eliza -0.2% 0.0% +0.0% +0.0% +0.0% event -0.3% 0.0% +0.1% +0.0% -0.0% exact-reals -0.2% 0.0% +0.0% +0.0% +0.0% exp3_8 -0.3% 0.0% +0.0% +0.0% +0.0% expert -0.2% 0.0% +0.0% +0.0% +0.0% fannkuch-redux -0.3% 0.0% -0.0% -0.0% -0.0% fasta -0.3% 0.0% +0.0% +0.0% +0.0% fem -0.2% 0.0% +0.1% +0.0% +0.0% fft -0.2% 0.0% +0.0% -0.0% -0.0% fft2 -0.2% 0.0% +0.0% -0.0% +0.0% fibheaps -0.3% 0.0% +0.0% -0.0% -0.0% fish -0.3% 0.0% +0.0% +0.0% +0.0% fluid -0.2% 0.0% +0.4% +0.1% +0.1% fulsom -0.2% 0.0% +0.0% +0.0% +0.0% gamteb -0.2% 0.0% +0.1% +0.0% +0.0% gcd -0.3% 0.0% +0.0% +0.0% +0.0% gen_regexps -0.3% 0.0% +0.0% -0.0% -0.0% genfft -0.3% 0.0% +0.0% +0.0% +0.0% gg -0.2% 0.0% +0.7% +0.3% +0.2% grep -0.2% 0.0% +0.0% +0.0% +0.0% hidden -0.2% 0.0% +0.0% +0.0% +0.0% hpg -0.2% 0.0% +0.1% +0.0% +0.0% ida -0.3% 0.0% +0.0% +0.0% +0.0% infer -0.2% 0.0% +0.0% -0.0% -0.0% integer -0.3% 0.0% +0.0% +0.0% +0.0% integrate -0.2% 0.0% +0.0% +0.0% +0.0% k-nucleotide -0.2% 0.0% +0.0% +0.0% -0.0% kahan -0.3% 0.0% -0.0% -0.0% -0.0% knights -0.3% 0.0% +0.0% -0.0% -0.0% lambda -0.3% 0.0% +0.0% -0.0% -0.0% last-piece -0.3% 0.0% +0.0% +0.0% +0.0% lcss -0.3% 0.0% +0.0% +0.0% 0.0% life -0.3% 0.0% +0.0% -0.0% -0.0% lift -0.2% 0.0% +0.0% +0.0% +0.0% linear -0.2% 0.0% +0.0% +0.0% +0.0% listcompr -0.3% 0.0% +0.0% +0.0% +0.0% listcopy -0.3% 0.0% +0.0% +0.0% +0.0% maillist -0.3% 0.0% +0.0% -0.0% -0.0% mandel -0.2% 0.0% +0.0% +0.0% +0.0% mandel2 -0.3% 0.0% +0.0% +0.0% +0.0% mate -0.2% 0.0% +0.0% +0.0% +0.0% minimax -0.3% 0.0% +0.0% +0.0% +0.0% mkhprog -0.2% 0.0% +0.0% +0.0% +0.0% multiplier -0.3% 0.0% +0.0% -0.0% -0.0% n-body -0.2% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.2% 0.0% +0.0% +0.0% +0.0% para -0.2% 0.0% +0.0% -0.0% -0.0% paraffins -0.3% 0.0% +0.0% -0.0% -0.0% parser -0.2% 0.0% +0.0% +0.0% +0.0% parstof -0.2% 0.0% +0.8% +0.2% +0.2% pic -0.2% 0.0% +0.1% -0.1% -0.1% pidigits -0.3% 0.0% +0.0% +0.0% +0.0% power -0.2% 0.0% +0.0% -0.0% -0.0% pretty -0.3% 0.0% -0.0% -0.0% -0.1% primes -0.3% 0.0% +0.0% +0.0% -0.0% primetest -0.2% 0.0% +0.0% -0.0% -0.0% prolog -0.3% 0.0% +0.0% -0.0% -0.0% puzzle -0.3% 0.0% +0.0% +0.0% +0.0% queens -0.3% 0.0% +0.0% +0.0% +0.0% reptile -0.2% 0.0% +0.2% +0.1% +0.0% reverse-complem -0.3% 0.0% +0.0% +0.0% +0.0% rewrite -0.3% 0.0% +0.0% -0.0% -0.0% rfib -0.2% 0.0% +0.0% +0.0% -0.0% rsa -0.2% 0.0% +0.0% +0.0% +0.0% scc -0.3% 0.0% -0.0% -0.0% -0.1% sched -0.3% 0.0% +0.0% +0.0% +0.0% scs -0.2% 0.0% +0.1% +0.0% +0.0% simple -0.2% 0.0% +3.4% +1.0% +1.8% solid -0.2% 0.0% +0.0% +0.0% +0.0% sorting -0.3% 0.0% +0.0% +0.0% +0.0% spectral-norm -0.2% 0.0% -0.0% -0.0% -0.0% sphere -0.2% 0.0% +0.0% +0.0% +0.0% symalg -0.2% 0.0% +0.0% +0.0% +0.0% tak -0.3% 0.0% +0.0% +0.0% -0.0% transform -0.2% 0.0% +0.2% +0.1% +0.1% treejoin -0.3% 0.0% +0.2% -0.0% -0.1% typecheck -0.3% 0.0% +0.0% +0.0% +0.0% veritas -0.1% 0.0% +0.0% +0.0% +0.0% wang -0.2% 0.0% +0.0% -0.0% -0.0% wave4main -0.3% 0.0% +0.0% -0.0% -0.0% wheel-sieve1 -0.3% 0.0% +0.0% -0.0% -0.0% wheel-sieve2 -0.3% 0.0% +0.0% -0.0% -0.0% x2n1 -0.3% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min -0.3% 0.0% -0.0% -0.1% -0.2% Max -0.1% 0.0% +5.4% +1.0% +3.9% Geometric Mean -0.3% -0.0% +0.1% +0.0% +0.1% -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- circsim -0.2% 0.0% +1.6% +0.4% +0.7% constraints -0.3% 0.0% +4.3% +1.5% +2.3% fibheaps -0.3% 0.0% +3.5% +1.2% +1.3% fulsom -0.2% 0.0% +3.6% +1.2% +1.8% gc_bench -0.3% 0.0% +4.1% +1.3% +2.3% hash -0.3% 0.0% +6.6% +2.2% +3.6% lcss -0.3% 0.0% +0.7% +0.2% +0.7% mutstore1 -0.3% 0.0% +4.8% +1.4% +2.8% mutstore2 -0.3% 0.0% +3.4% +1.0% +1.7% power -0.2% 0.0% +2.7% +0.6% +1.9% spellcheck -0.3% 0.0% +1.1% +0.4% +0.4% -------------------------------------------------------------------------------- Min -0.3% 0.0% +0.7% +0.2% +0.4% Max -0.2% 0.0% +6.6% +2.2% +3.6% Geometric Mean -0.3% +0.0% +3.3% +1.0% +1.8% Metric changes -------------- While it sounds ridiculous, this change causes increased allocations in the following tests. We concluded that this change can't cause a difference in allocations and decided to land this patch. Fluctuations in "bytes allocated" metric is tracked in #17686. Metric Increase: Naperian T10547 T12150 T12234 T12425 T13035 T5837 T6048 - - - - - 8038cbd9 by Sebastian Graf at 2020-01-25T05:21:05-05:00 PmCheck: Formulate as translation between Clause Trees We used to check `GrdVec`s arising from multiple clauses and guards in isolation. That resulted in a split between `pmCheck` and `pmCheckGuards`, the implementations of which were similar, but subtly different in detail. Also the throttling mechanism described in `Note [Countering exponential blowup]` ultimately got quite complicated because it had to cater for both checking functions. This patch realises that pattern match checking doesn't just consider single guarded RHSs, but that it's always a whole set of clauses, each of which can have multiple guarded RHSs in turn. We do so by translating a list of `Match`es to a `GrdTree`: ```haskell data GrdTree = Rhs !RhsInfo | Guard !PmGrd !GrdTree -- captures lef-to-right match semantics | Sequence !GrdTree !GrdTree -- captures top-to-bottom match semantics | Empty -- For -XEmptyCase, neutral element of Sequence ``` Then we have a function `checkGrdTree` that matches a given `GrdTree` against an incoming set of values, represented by `Deltas`: ```haskell checkGrdTree :: GrdTree -> Deltas -> CheckResult ... ``` Throttling is isolated to the `Sequence` case and becomes as easy as one would expect: When the union of uncovered values becomes too big, just return the original incoming `Deltas` instead (which is always a superset of the union, thus a sound approximation). The returned `CheckResult` contains two things: 1. The set of values that were not covered by any of the clauses, for exhaustivity warnings. 2. The `AnnotatedTree` that enriches the syntactic structure of the input program with divergence and inaccessibility information. This is `AnnotatedTree`: ```haskell data AnnotatedTree = AccessibleRhs !RhsInfo | InaccessibleRhs !RhsInfo | MayDiverge !AnnotatedTree | SequenceAnn !AnnotatedTree !AnnotatedTree | EmptyAnn ``` Crucially, `MayDiverge` asserts that the tree may force diverging values, so not all of its wrapped clauses can be redundant. While the set of uncovered values can be used to generate the missing equations for warning messages, redundant and proper inaccessible equations can be extracted from `AnnotatedTree` by `redundantAndInaccessibleRhss`. For this to work properly, the interface to the Oracle had to change. There's only `addPmCts` now, which takes a bag of `PmCt`s. There's a whole bunch of `PmCt` variants to replace the different oracle functions from before. The new `AnnotatedTree` structure allows for more accurate warning reporting (as evidenced by a number of changes spread throughout GHC's code base), thus we fix #17465. Fixes #17646 on the go. Metric Decrease: T11822 T9233 PmSeriesS haddock.compiler - - - - - 86966d48 by Sebastian Graf at 2020-01-25T05:21:05-05:00 PmCheck: Properly handle constructor-bound type variables In https://gitlab.haskell.org/ghc/ghc/merge_requests/2192#note_246551 Simon convinced me that ignoring type variables existentially bound by data constructors have to be the same way as value binders. Sadly I couldn't think of a regression test, but I'm confident that this change strictly improves on the status quo. - - - - - c3fde723 by Ryan Scott at 2020-01-25T05:21:40-05:00 Handle local fixity declarations in DsMeta properly `DsMeta.rep_sig` used to skip over `FixSig` entirely, which had the effect of causing local fixity declarations to be dropped when quoted in Template Haskell. But there is no good reason for this state of affairs, as the code in `DsMeta.repFixD` (which handles top-level fixity declarations) handles local fixity declarations just fine. This patch factors out the necessary parts of `repFixD` so that they can be used in `rep_sig` as well. There was one minor complication: the fixity signatures for class methods in each `HsGroup` were stored both in `FixSig`s _and_ the list of `LFixitySig`s for top-level fixity signatures, so I needed to take action to prevent fixity signatures for class methods being converted to `Dec`s twice. I tweaked `RnSource.add` to avoid putting these fixity signatures in two places and added `Note [Top-level fixity signatures in an HsGroup]` in `GHC.Hs.Decls` to explain the new design. Fixes #17608. Bumps the Haddock submodule. - - - - - 6e2d9ee2 by Sylvain Henry at 2020-01-25T05:22:20-05:00 Module hierarchy: Cmm (cf #13009) - - - - - 8b726534 by PHO at 2020-01-25T05:23:01-05:00 Fix rts allocateExec() on NetBSD Similar to SELinux, NetBSD "PaX mprotect" prohibits marking a page mapping both writable and executable at the same time. Use libffi which knows how to work around it. - - - - - 6eb566a0 by Xavier Denis at 2020-01-25T05:23:39-05:00 Add ghc-in-ghci for stack based builds - - - - - b1a32170 by Xavier Denis at 2020-01-25T05:23:39-05:00 Create ghci.cabal.sh - - - - - 0a5e4f5f by Sylvain Henry at 2020-01-25T05:24:19-05:00 Split glasgow_exts into several files (#17316) - - - - - b3e5c678 by Ben Gamari at 2020-01-25T05:24:57-05:00 hadrian: Throw error on duplicate-named flavours Throw an error if the user requests a flavour for which there is more than one match. Fixes #17156. - - - - - 0940b59a by Ryan Scott at 2020-01-25T08:15:05-05:00 Do not bring visible foralls into scope in hsScopedTvs Previously, `hsScopedTvs` (and its cousin `hsWcScopedTvs`) pretended that visible dependent quantification could not possibly happen at the term level, and cemented that assumption with an `ASSERT`: ```hs hsScopedTvs (HsForAllTy { hst_fvf = vis_flag, ... }) = ASSERT( vis_flag == ForallInvis ) ... ``` It turns out that this assumption is wrong. You can end up tripping this `ASSERT` if you stick it to the man and write a type for a term that uses visible dependent quantification anyway, like in this example: ```hs {-# LANGUAGE ScopedTypeVariables #-} x :: forall a -> a -> a x = x ``` That won't typecheck, but that's not the point. Before the typechecker has a chance to reject this, the renamer will try to use `hsScopedTvs` to bring `a` into scope over the body of `x`, since `a` is quantified by a `forall`. This, in turn, causes the `ASSERT` to fail. Bummer. Instead of walking on this dangerous ground, this patch makes GHC adopt a more hardline stance by pattern-matching directly on `ForallInvis` in `hsScopedTvs`: ```hs hsScopedTvs (HsForAllTy { hst_fvf = ForallInvis, ... }) = ... ``` Now `a` will not be brought over the body of `x` at all (which is how it should be), there's no chance of the `ASSERT` failing anymore (as it's gone), and best of all, the behavior of `hsScopedTvs` does not change. Everyone wins! Fixes #17687. - - - - - 1132602f by Ryan Scott at 2020-01-27T10:03:42-05:00 Use splitLHs{ForAll,Sigma}TyInvis throughout the codebase Richard points out in #17688 that we use `splitLHsForAllTy` and `splitLHsSigmaTy` in places that we ought to be using the corresponding `-Invis` variants instead, identifying two bugs that are caused by this oversight: * Certain TH-quoted type signatures, such as those that appear in quoted `SPECIALISE` pragmas, silently turn visible `forall`s into invisible `forall`s. * When quoted, the type `forall a -> (a ~ a) => a` will turn into `forall a -> a` due to a bug in `DsMeta.repForall` that drops contexts that follow visible `forall`s. These are both ultimately caused by the fact that `splitLHsForAllTy` and `splitLHsSigmaTy` split apart visible `forall`s in addition to invisible ones. This patch cleans things up: * We now use `splitLHsForAllTyInvis` and `splitLHsSigmaTyInvis` throughout the codebase. Relatedly, the `splitLHsForAllTy` and `splitLHsSigmaTy` have been removed, as they are easy to misuse. * `DsMeta.repForall` now only handles invisible `forall`s to reduce the chance for confusion with visible `forall`s, which need to be handled differently. I also renamed it from `repForall` to `repForallT` to emphasize that its distinguishing characteristic is the fact that it desugars down to `L.H.TH.Syntax.ForallT`. Fixes #17688. - - - - - 97d0b0a3 by Matthew Pickering at 2020-01-27T10:04:19-05:00 Make Block.h compile with c++ compilers - - - - - 4bada77d by Tom Ellis at 2020-01-27T12:30:46-05:00 Disable two warnings for files that trigger them incomplete-uni-patterns and incomplete-record-updates will be in -Wall at a future date, so prepare for that by disabling those warnings on files that trigger them. - - - - - 0188404a by Tom Ellis at 2020-01-27T12:30:46-05:00 Add two warnings to stage 2 build - - - - - acae02c1 by Tom Ellis at 2020-01-27T12:30:46-05:00 Add two warnings to Hadrian - - - - - bf38a20e by Sylvain Henry at 2020-01-31T02:46:15-05:00 Call `interpretPackageEnv` from `setSessionDynFlags` interpretPackageEnv modifies the flags by reading the dreaded package environments. It is much less surprising to call it from `setSessionDynFlags` instead of reading package environments as a side-effect of `initPackages`. - - - - - 29c701c1 by Sylvain Henry at 2020-01-31T02:46:15-05:00 Refactor package related code The package terminology is a bit of a mess. Cabal packages contain components. Instances of these components when built with some flags/options/dependencies are called units. Units are registered into package databases and their metadata are called PackageConfig. GHC only knows about package databases containing units. It is a sad mismatch not fixed by this patch (we would have to rename parameters such as `package-id <unit-id>` which would affect users). This patch however fixes the following internal names: - Renames PackageConfig into UnitInfo. - Rename systemPackageConfig into globalPackageDatabase[Path] - Rename PkgConfXX into PkgDbXX - Rename pkgIdMap into unitIdMap - Rename ModuleToPkgDbAll into ModuleNameProvidersMap - Rename lookupPackage into lookupUnit - Add comments on DynFlags package related fields It also introduces a new `PackageDatabase` datatype instead of explicitly passing the following tuple: `(FilePath,[PackageConfig])`. The `pkgDatabase` field in `DynFlags` now contains the unit info for each unit of each package database exactly as they have been read from disk. Previously the command-line flag `-distrust-all-packages` would modify these unit info. Now this flag only affects the "dynamic" consolidated package state found in `pkgState` field. It makes sense because `initPackages` could be called first with this `distrust-all-packages` flag set and then again (using ghc-api) without and it should work (package databases are not read again from disk when `initPackages` is called the second time). Bump haddock submodule - - - - - 942c7148 by Ben Gamari at 2020-01-31T02:46:54-05:00 rename: Eliminate usage of mkVarOccUnique Replacing it with `newSysName`. Fixes #17061. - - - - - 41117d71 by Ben Gamari at 2020-01-31T02:47:31-05:00 base: Use one-shot kqueue on macOS The underlying reason requiring that one-shot usage be disabled (#13903) has been fixed. Closes #15768. - - - - - 01b15b83 by Ben Gamari at 2020-01-31T02:48:08-05:00 testsuite: Don't crash on encoding failure in print If the user doesn't use a Unicode locale then the testsuite driver would previously throw framework failures due to encoding failures. We now rather use the `replace` error-handling strategy. - - - - - c846618a by Ömer Sinan Ağacan at 2020-01-31T12:21:10+03:00 Do CafInfo/SRT analysis in Cmm This patch removes all CafInfo predictions and various hacks to preserve predicted CafInfos from the compiler and assigns final CafInfos to interface Ids after code generation. SRT analysis is extended to support static data, and Cmm generator is modified to allow generating static_link fields after SRT analysis. This also fixes `-fcatch-bottoms`, which introduces error calls in case expressions in CorePrep, which runs *after* CoreTidy (which is where we decide on CafInfos) and turns previously non-CAFFY things into CAFFY. Fixes #17648 Fixes #9718 Evaluation ========== NoFib ----- Boot with: `make boot mode=fast` Run: `make mode=fast EXTRA_RUNTEST_OPTS="-cachegrind" NoFibRuns=1` -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.0% 0.0% -0.0% -0.0% -0.0% CSD -0.0% 0.0% -0.0% -0.0% -0.0% FS -0.0% 0.0% -0.0% -0.0% -0.0% S -0.0% 0.0% -0.0% -0.0% -0.0% VS -0.0% 0.0% -0.0% -0.0% -0.0% VSD -0.0% 0.0% -0.0% -0.0% -0.5% VSM -0.0% 0.0% -0.0% -0.0% -0.0% anna -0.1% 0.0% -0.0% -0.0% -0.0% ansi -0.0% 0.0% -0.0% -0.0% -0.0% atom -0.0% 0.0% -0.0% -0.0% -0.0% awards -0.0% 0.0% -0.0% -0.0% -0.0% banner -0.0% 0.0% -0.0% -0.0% -0.0% bernouilli -0.0% 0.0% -0.0% -0.0% -0.0% binary-trees -0.0% 0.0% -0.0% -0.0% -0.0% boyer -0.0% 0.0% -0.0% -0.0% -0.0% boyer2 -0.0% 0.0% -0.0% -0.0% -0.0% bspt -0.0% 0.0% -0.0% -0.0% -0.0% cacheprof -0.0% 0.0% -0.0% -0.0% -0.0% calendar -0.0% 0.0% -0.0% -0.0% -0.0% cichelli -0.0% 0.0% -0.0% -0.0% -0.0% circsim -0.0% 0.0% -0.0% -0.0% -0.0% clausify -0.0% 0.0% -0.0% -0.0% -0.0% comp_lab_zift -0.0% 0.0% -0.0% -0.0% -0.0% compress -0.0% 0.0% -0.0% -0.0% -0.0% compress2 -0.0% 0.0% -0.0% -0.0% -0.0% constraints -0.0% 0.0% -0.0% -0.0% -0.0% cryptarithm1 -0.0% 0.0% -0.0% -0.0% -0.0% cryptarithm2 -0.0% 0.0% -0.0% -0.0% -0.0% cse -0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 -0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 -0.0% 0.0% -0.0% -0.0% -0.0% dom-lt -0.0% 0.0% -0.0% -0.0% -0.0% eliza -0.0% 0.0% -0.0% -0.0% -0.0% event -0.0% 0.0% -0.0% -0.0% -0.0% exact-reals -0.0% 0.0% -0.0% -0.0% -0.0% exp3_8 -0.0% 0.0% -0.0% -0.0% -0.0% expert -0.0% 0.0% -0.0% -0.0% -0.0% fannkuch-redux -0.0% 0.0% -0.0% -0.0% -0.0% fasta -0.0% 0.0% -0.0% -0.0% -0.0% fem -0.0% 0.0% -0.0% -0.0% -0.0% fft -0.0% 0.0% -0.0% -0.0% -0.0% fft2 -0.0% 0.0% -0.0% -0.0% -0.0% fibheaps -0.0% 0.0% -0.0% -0.0% -0.0% fish -0.0% 0.0% -0.0% -0.0% -0.0% fluid -0.1% 0.0% -0.0% -0.0% -0.0% fulsom -0.0% 0.0% -0.0% -0.0% -0.0% gamteb -0.0% 0.0% -0.0% -0.0% -0.0% gcd -0.0% 0.0% -0.0% -0.0% -0.0% gen_regexps -0.0% 0.0% -0.0% -0.0% -0.0% genfft -0.0% 0.0% -0.0% -0.0% -0.0% gg -0.0% 0.0% -0.0% -0.0% -0.0% grep -0.0% 0.0% -0.0% -0.0% -0.0% hidden -0.0% 0.0% -0.0% -0.0% -0.0% hpg -0.1% 0.0% -0.0% -0.0% -0.0% ida -0.0% 0.0% -0.0% -0.0% -0.0% infer -0.0% 0.0% -0.0% -0.0% -0.0% integer -0.0% 0.0% -0.0% -0.0% -0.0% integrate -0.0% 0.0% -0.0% -0.0% -0.0% k-nucleotide -0.0% 0.0% -0.0% -0.0% -0.0% kahan -0.0% 0.0% -0.0% -0.0% -0.0% knights -0.0% 0.0% -0.0% -0.0% -0.0% lambda -0.0% 0.0% -0.0% -0.0% -0.0% last-piece -0.0% 0.0% -0.0% -0.0% -0.0% lcss -0.0% 0.0% -0.0% -0.0% -0.0% life -0.0% 0.0% -0.0% -0.0% -0.0% lift -0.0% 0.0% -0.0% -0.0% -0.0% linear -0.1% 0.0% -0.0% -0.0% -0.0% listcompr -0.0% 0.0% -0.0% -0.0% -0.0% listcopy -0.0% 0.0% -0.0% -0.0% -0.0% maillist -0.0% 0.0% -0.0% -0.0% -0.0% mandel -0.0% 0.0% -0.0% -0.0% -0.0% mandel2 -0.0% 0.0% -0.0% -0.0% -0.0% mate -0.0% 0.0% -0.0% -0.0% -0.0% minimax -0.0% 0.0% -0.0% -0.0% -0.0% mkhprog -0.0% 0.0% -0.0% -0.0% -0.0% multiplier -0.0% 0.0% -0.0% -0.0% -0.0% n-body -0.0% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.0% 0.0% -0.0% -0.0% -0.0% para -0.0% 0.0% -0.0% -0.0% -0.0% paraffins -0.0% 0.0% -0.0% -0.0% -0.0% parser -0.1% 0.0% -0.0% -0.0% -0.0% parstof -0.1% 0.0% -0.0% -0.0% -0.0% pic -0.0% 0.0% -0.0% -0.0% -0.0% pidigits -0.0% 0.0% -0.0% -0.0% -0.0% power -0.0% 0.0% -0.0% -0.0% -0.0% pretty -0.0% 0.0% -0.3% -0.4% -0.4% primes -0.0% 0.0% -0.0% -0.0% -0.0% primetest -0.0% 0.0% -0.0% -0.0% -0.0% prolog -0.0% 0.0% -0.0% -0.0% -0.0% puzzle -0.0% 0.0% -0.0% -0.0% -0.0% queens -0.0% 0.0% -0.0% -0.0% -0.0% reptile -0.0% 0.0% -0.0% -0.0% -0.0% reverse-complem -0.0% 0.0% -0.0% -0.0% -0.0% rewrite -0.0% 0.0% -0.0% -0.0% -0.0% rfib -0.0% 0.0% -0.0% -0.0% -0.0% rsa -0.0% 0.0% -0.0% -0.0% -0.0% scc -0.0% 0.0% -0.3% -0.5% -0.4% sched -0.0% 0.0% -0.0% -0.0% -0.0% scs -0.0% 0.0% -0.0% -0.0% -0.0% simple -0.1% 0.0% -0.0% -0.0% -0.0% solid -0.0% 0.0% -0.0% -0.0% -0.0% sorting -0.0% 0.0% -0.0% -0.0% -0.0% spectral-norm -0.0% 0.0% -0.0% -0.0% -0.0% sphere -0.0% 0.0% -0.0% -0.0% -0.0% symalg -0.0% 0.0% -0.0% -0.0% -0.0% tak -0.0% 0.0% -0.0% -0.0% -0.0% transform -0.0% 0.0% -0.0% -0.0% -0.0% treejoin -0.0% 0.0% -0.0% -0.0% -0.0% typecheck -0.0% 0.0% -0.0% -0.0% -0.0% veritas -0.0% 0.0% -0.0% -0.0% -0.0% wang -0.0% 0.0% -0.0% -0.0% -0.0% wave4main -0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 -0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 -0.0% 0.0% -0.0% -0.0% -0.0% x2n1 -0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.3% -0.5% -0.5% Max -0.0% 0.0% -0.0% -0.0% -0.0% Geometric Mean -0.0% -0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- circsim -0.1% 0.0% -0.0% -0.0% -0.0% constraints -0.0% 0.0% -0.0% -0.0% -0.0% fibheaps -0.0% 0.0% -0.0% -0.0% -0.0% gc_bench -0.0% 0.0% -0.0% -0.0% -0.0% hash -0.0% 0.0% -0.0% -0.0% -0.0% lcss -0.0% 0.0% -0.0% -0.0% -0.0% power -0.0% 0.0% -0.0% -0.0% -0.0% spellcheck -0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.0% -0.0% -0.0% Max -0.0% 0.0% -0.0% -0.0% -0.0% Geometric Mean -0.0% +0.0% -0.0% -0.0% -0.0% Manual inspection of programs in testsuite/tests/programs --------------------------------------------------------- I built these programs with a bunch of dump flags and `-O` and compared STG, Cmm, and Asm dumps and file sizes. (Below the numbers in parenthesis show number of modules in the program) These programs have identical compiler (same .hi and .o sizes, STG, and Cmm and Asm dumps): - Queens (1), andre_monad (1), cholewo-eval (2), cvh_unboxing (3), andy_cherry (7), fun_insts (1), hs-boot (4), fast2haskell (2), jl_defaults (1), jq_readsPrec (1), jules_xref (1), jtod_circint (4), jules_xref2 (1), lennart_range (1), lex (1), life_space_leak (1), bargon-mangler-bug (7), record_upd (1), rittri (1), sanders_array (1), strict_anns (1), thurston-module-arith (2), okeefe_neural (1), joao-circular (6), 10queens (1) Programs with different compiler outputs: - jl_defaults (1): For some reason GHC HEAD marks a lot of top-level `[Int]` closures as CAFFY for no reason. With this patch we no longer make them CAFFY and generate less SRT entries. For some reason Main.o is slightly larger with this patch (1.3%) and the executable sizes are the same. (I'd expect both to be smaller) - launchbury (1): Same as jl_defaults: top-level `[Int]` closures marked as CAFFY for no reason. Similarly `Main.o` is 1.4% larger but the executable sizes are the same. - galois_raytrace (13): Differences are in the Parse module. There are a lot, but some of the changes are caused by the fact that for some reason (I think a bug) GHC HEAD marks the dictionary for `Functor Identity` as CAFFY. Parse.o is 0.4% larger, the executable size is the same. - north_array: We now generate less SRT entries because some of array primops used in this program like `NewArrayOp` get eliminated during Stg-to-Cmm and turn some CAFFY things into non-CAFFY. Main.o gets 24% larger (9224 bytes from 9000 bytes), executable sizes are the same. - seward-space-leak: Difference in this program is better shown by this smaller example: module Lib where data CDS = Case [CDS] [(Int, CDS)] | Call CDS CDS instance Eq CDS where Case sels1 rets1 == Case sels2 rets2 = sels1 == sels2 && rets1 == rets2 Call a1 b1 == Call a2 b2 = a1 == a2 && b1 == b2 _ == _ = False In this program GHC HEAD builds a new SRT for the recursive group of `(==)`, `(/=)` and the dictionary closure. Then `/=` points to `==` in its SRT field, and `==` uses the SRT object as its SRT. With this patch we use the closure for `/=` as the SRT and add `==` there. Then `/=` gets an empty SRT field and `==` points to `/=` in its SRT field. This change looks fine to me. Main.o gets 0.07% larger, executable sizes are identical. head.hackage ------------ head.hackage's CI script builds 428 packages from Hackage using this patch with no failures. Compiler performance -------------------- The compiler perf tests report that the compiler allocates slightly more (worst case observed so far is 4%). However most programs in the test suite are small, single file programs. To benchmark compiler performance on something more realistic I build Cabal (the library, 236 modules) with different optimisation levels. For the "max residency" row I run GHC with `+RTS -s -A100k -i0 -h` for more accurate numbers. Other rows are generated with just `-s`. (This is because `-i0` causes running GC much more frequently and as a result "bytes copied" gets inflated by more than 25x in some cases) * -O0 | | GHC HEAD | This MR | Diff | | --------------- | -------------- | -------------- | ------ | | Bytes allocated | 54,413,350,872 | 54,701,099,464 | +0.52% | | Bytes copied | 4,926,037,184 | 4,990,638,760 | +1.31% | | Max residency | 421,225,624 | 424,324,264 | +0.73% | * -O1 | | GHC HEAD | This MR | Diff | | --------------- | --------------- | --------------- | ------ | | Bytes allocated | 245,849,209,992 | 246,562,088,672 | +0.28% | | Bytes copied | 26,943,452,560 | 27,089,972,296 | +0.54% | | Max residency | 982,643,440 | 991,663,432 | +0.91% | * -O2 | | GHC HEAD | This MR | Diff | | --------------- | --------------- | --------------- | ------ | | Bytes allocated | 291,044,511,408 | 291,863,910,912 | +0.28% | | Bytes copied | 37,044,237,616 | 36,121,690,472 | -2.49% | | Max residency | 1,071,600,328 | 1,086,396,256 | +1.38% | Extra compiler allocations -------------------------- Runtime allocations of programs are as reported above (NoFib section). The compiler now allocates more than before. Main source of allocation in this patch compared to base commit is the new SRT algorithm (GHC.Cmm.Info.Build). Below is some of the extra work we do with this patch, numbers generated by profiled stage 2 compiler when building a pathological case (the test 'ManyConstructors') with '-O2': - We now sort the final STG for a module, which means traversing the entire program, generating free variable set for each top-level binding, doing SCC analysis, and re-ordering the program. In ManyConstructors this step allocates 97,889,952 bytes. - We now do SRT analysis on static data, which in a program like ManyConstructors causes analysing 10,000 bindings that we would previously just skip. This step allocates 70,898,352 bytes. - We now maintain an SRT map for the entire module as we compile Cmm groups: data ModuleSRTInfo = ModuleSRTInfo { ... , moduleSRTMap :: SRTMap } (SRTMap is just a strict Map from the 'containers' library) This map gets an entry for most bindings in a module (exceptions are THUNKs and CAFFY static functions). For ManyConstructors this map gets 50015 entries. - Once we're done with code generation we generate a NameSet from SRTMap for the non-CAFFY names in the current module. This set gets the same number of entries as the SRTMap. - Finally we update CafInfos in ModDetails for the non-CAFFY Ids, using the NameSet generated in the previous step. This usually does the least amount of allocation among the work listed here. Only place with this patch where we do less work in the CAF analysis in the tidying pass (CoreTidy). However that doesn't save us much, as the pass still needs to traverse the whole program and update IdInfos for other reasons. Only thing we don't here do is the `hasCafRefs` pass over the RHS of bindings, which is a stateless pass that returns a boolean value, so it doesn't allocate much. (Metric changes blow are all increased allocations) Metric changes -------------- Metric Increase: ManyAlternatives ManyConstructors T13035 T14683 T1969 T9961 - - - - - 2a87a565 by Andreas Klebinger at 2020-01-31T12:21:10+03:00 A few optimizations in STG and Cmm parts: (Guided by the profiler output) - Add a few bang patterns, INLINABLE annotations, and a seqList in a few places in Cmm and STG parts. - Do not add external variables as dependencies in STG dependency analysis (GHC.Stg.DepAnal). - - - - - bef704b6 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Improve skolemisation This patch avoids skolemiseUnboundMetaTyVar making up a fresh Name when it doesn't need to. See Note [Skolemising and identity] Improves error messsages for partial type signatures. - - - - - cd110423 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Improve pretty-printing for TyConBinders In particular, show their kinds. - - - - - 913287a0 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Fix scoping of TyCon binders in TcTyClsDecls This patch fixes #17566 by refactoring the way we decide the final identity of the tyvars in the TyCons of a possibly-recursive nest of type and class decls, possibly with associated types. It's all laid out in Note [Swizzling the tyvars before generaliseTcTyCon] Main changes: * We have to generalise each decl (with its associated types) all at once: TcTyClsDecls.generaliseTyClDecl * The main new work is done in TcTyClsDecls.swizzleTcTyConBndrs * The mysterious TcHsSyn.zonkRecTyVarBndrs dies altogether Other smaller things: * A little refactoring, moving bindTyClTyVars from tcTyClDecl1 to tcDataDefn, tcSynRhs, etc. Clearer, reduces the number of parameters * Reduce the amount of swizzling required. Specifically, bindExplicitTKBndrs_Q_Tv doesn't need to clone a new Name for the TyVarTv, and not cloning means that in the vasly common case, swizzleTyConBndrs is a no-op In detail: Rename newTyVarTyVar --> cloneTyVarTyVar Add newTyVarTyTyVar that doesn't clone Use the non-cloning newTyVarTyVar in bindExplicitTKBndrs_Q_Tv Rename newFlexiKindedTyVarTyVar --> cloneFlexiKindedTyVarTyVar * Define new utility function and use it HsDecls.familyDeclName :: FamilyDecl (GhcPass p) -> IdP (GhcPass p) Updates haddock submodule. - - - - - 58ed6c4a by Ben Gamari at 2020-02-01T02:29:23-05:00 rts/M32Alloc: Don't attempt to unmap non-existent pages The m32 allocator's `pages` list may contain NULLs in the case that the page was flushed. Some `munmap` implementations (e.g. FreeBSD's) don't like it if we pass them NULL. Don't do that. - - - - - 859db7d6 by Ömer Sinan Ağacan at 2020-02-01T14:18:49+03:00 Improve/fix -fcatch-bottoms documentation Old documentation suggests that -fcatch-bottoms only adds a default alternative to bottoming case expression, but that's not true. We use a very simplistic "is exhaustive" check and add default alternatives to any case expression that does not cover all constructors of the type. In case of GADTs this simple check assumes all constructors should be covered, even the ones ruled out by the type of the scrutinee. Update the documentation to reflect this. (Originally noticed in #17648) [ci skip] - - - - - 54dfa94a by John Ericson at 2020-02-03T21:14:24-05:00 Fix docs for FrontendResult Other variant was removed in ac1a379363618a6f2f17fff65ce9129164b6ef30 but docs were no changed. - - - - - 5e63d9c0 by John Ericson at 2020-02-03T21:15:02-05:00 Refactor HscMain.finish I found the old control flow a bit hard to follow; I rewrote it to first decide whether to desugar, and then use that choice when computing whether to simplify / what sort of interface file to write. I hope eventually we will always write post-tc interface files, which will make the logic of this function even simpler, and continue the thrust of this refactor. - - - - - e580e5b8 by Stefan Schulze Frielinghaus at 2020-02-04T09:29:00-05:00 Do not build StgCRunAsm.S for unregisterised builds For unregisterised builds StgRun/StgReturn are implemented via a mini interpreter in StgCRun.c and therefore would collide with the implementations in StgCRunAsm.S. - - - - - e3b0bd97 by Stefan Schulze Frielinghaus at 2020-02-04T09:29:00-05:00 fixup! fixup! Do not build StgCRunAsm.S for unregisterised builds - - - - - eb629fab by John Ericson at 2020-02-04T09:29:38-05:00 Delete some superfluous helper functions in HscMain The driver code is some of the nastiest in GHC, and I am worried about being able to untangle all the tech debt. In `HscMain` we have a number of helpers which are either not-used or little used. I delete them so we can reduce cognative load, distilling the essential complexity away from the cruft. - - - - - c90eca55 by Sebastian Graf at 2020-02-05T09:21:29-05:00 PmCheck: Record type constraints arising from existentials in `PmCoreCt`s In #17703 (a follow-up of !2192), we established that contrary to my belief, type constraints arising from existentials in code like ```hs data Ex where Ex :: a -> Ex f _ | let x = Ex @Int 15 = case x of Ex -> ... ``` are in fact useful. This commit makes a number of refactorings and improvements to comments, but fundamentally changes `addCoreCt.core_expr` to record the type constraint `a ~ Int` in addition to `x ~ Ex @a y` and `y ~ 15`. Fixes #17703. - - - - - 6d3b5d57 by Ömer Sinan Ağacan at 2020-02-05T09:22:10-05:00 testlib: Extend existing *_opts in extra_*_opts Previously we'd override the existing {run,hc} opts in extra_{run,hc}_opts, which caused flakiness in T1969, see #17712. extra_{run,hc}_opts now extends {run,hc} opts, instead of overriding. Also we shrank the allocation area for T1969 in order to increase residency sampling frequency. Fixes #17712 - - - - - 9c89a48d by Ömer Sinan Ağacan at 2020-02-05T09:22:52-05:00 Remove CafInfo-related code from STG lambda lift pass After c846618ae0 we don't have accurate CafInfos for Ids in the current module and we're free to introduce new CAFFY or non-CAFFY bindings or change CafInfos of existing binders; so no we no longer need to maintain CafInfos in Core or STG passes. - - - - - 70ddb8bf by Ryan Scott at 2020-02-05T09:23:30-05:00 Add regression test for #17773 - - - - - e8004e5d by Ben Gamari at 2020-02-05T13:55:19-05:00 gitlab-ci: Allow Windows builds to fail again Due to T7702 and the process issues described in #17777. - - - - - 29b72c00 by Ben Gamari at 2020-02-06T11:55:41-05:00 VarSet: Introduce nonDetFoldVarSet - - - - - c4e6b35d by Ben Gamari at 2020-02-06T11:55:41-05:00 Move closeOverKinds and friends to TyCoFVs - - - - - ed2f0e5c by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Reform the free variable finders for types This patch delivers on (much of) #17509. * Introduces the shallow vs deep free variable distinction * Introduce TyCoRep.foldType, foldType :: Monoid a => TyCoFolder env a -> env -> Type -> a and use it in the free variable finders. * Substitution in TyCoSubst * ASSERTs are on for checkValidSubst * checkValidSubst uses shallowTyCoVarsOfTypes etc Quite a few things still to do * We could use foldType in lots of other places * We could use mapType for substitution. (Check that we get good code!) * Some (but not yet all) clients of substitution can now save time by using shallowTyCoVarsOfTypes * All calls to tyCoVarsOfTypes should be inspected; most of them should be shallow. Maybe. * Currently shallowTyCoVarsOfTypes still returns unification variables, but not CoVarHoles. Reason: we need to return unification variables in some of the calls in TcSimplify, eg when promoting. * We should do the same thing for tyCoFVsOfTypes, which is currently unchanged. * tyCoFVsOfTypes returns CoVarHoles, because of the use in TcSimplify.mkResidualConstraints. See Note [Emitting the residual implication in simplifyInfer] * #17509 talks about "relevant" variables too. - - - - - 01a1f4fb by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for noFreeVarsOfType - - - - - 0e59afd6 by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Simplify closeOverKinds - - - - - 9ca5c88e by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for coVarsOfType - - - - - 5541b87c by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for exactTyCoVarsOfType This entailed * Adding a tcf_view field to TyCoFolder * Moving exactTyCoVarsOtType to TcType. It properly belongs there, since only the typechecker calls this function. But it also means that we can "see" and inline tcView. Metric Decrease: T14683 - - - - - 7c122851 by Simon Peyton Jones at 2020-02-06T11:56:02-05:00 Comments only - - - - - 588acb99 by Adam Sandberg Eriksson at 2020-02-08T10:15:38-05:00 slightly better named cost-centres for simple pattern bindings #17006 ``` main = do print $ g [1..100] a where g xs x = map (`mod` x) xs a :: Int = 324 ``` The above program previously attributed the cost of computing 324 to a cost centre named `(...)`, with this change the cost is attributed to `a` instead. This change only affects simple pattern bindings (decorated variables: type signatures, parens, ~ annotations and ! annotations). - - - - - 309f8cfd by Richard Eisenberg at 2020-02-08T10:16:33-05:00 Remove unnecessary parentheses - - - - - 7755ffc2 by Richard Eisenberg at 2020-02-08T10:16:33-05:00 Introduce IsPass; refactor wrappers. There are two main payloads of this patch: 1. This introduces IsPass, which allows e.g. printing code to ask what pass it is running in (Renamed vs Typechecked) and thus print extension fields. See Note [IsPass] in Hs.Extension 2. This moves the HsWrap constructor into an extension field, where it rightly belongs. This is done for HsExpr and HsCmd, but not for HsPat, which is left as an exercise for the reader. There is also some refactoring around SyntaxExprs, but this is really just incidental. This patch subsumes !1721 (sorry @chreekat). Along the way, there is a bit of refactoring in GHC.Hs.Extension, including the removal of NameOrRdrName in favor of NoGhcTc. This meant that we had no real need for GHC.Hs.PlaceHolder, so I got rid of it. Updates haddock submodule. ------------------------- Metric Decrease: haddock.compiler ------------------------- - - - - - 7d452be4 by Dylan Yudaken at 2020-02-08T10:17:17-05:00 Fix hs_try_putmvar losing track of running cap If hs_try_putmvar was called through an unsafe import, it would lose track of the running cap causing a deadlock - - - - - c2e301ae by Ben Gamari at 2020-02-08T10:17:55-05:00 compiler: Qualify imports of Data.List - - - - - aede171a by Ben Gamari at 2020-02-08T10:17:55-05:00 testsuite: Fix -Wcompat-unqualified-imports issues - - - - - 4435a8e0 by Ben Gamari at 2020-02-08T10:17:55-05:00 Introduce -Wcompat-unqualified-imports This implements the warning proposed in option (B) of the Data.List.singleton CLC [discussion][]. This warning, which is included in `-Wcompat` is intended to help users identify imports of modules that will change incompatibly in future GHC releases. This currently only includes `Data.List` due to the expected specialisation and addition of `Data.List.singleton`. Fixes #17244. [discussion]: https://groups.google.com/d/msg/haskell-core-libraries/q3zHLmzBa5E/PmlAs_kYAQAJ - - - - - 28b5349a by Ben Gamari at 2020-02-08T10:17:55-05:00 Bump stm and process submodules - - - - - 7d04b9f2 by Ben Gamari at 2020-02-08T10:18:31-05:00 hadrian: Allow override of Cabal configuration in hadrian.settings Fixes #17612 by adding a `cabal.configure.opts` key for `hadrian.settings`. - - - - - 88bf81aa by Andreas Klebinger at 2020-02-08T10:19:10-05:00 Optimize unpackCString# to allocate less. unpackCString# is a recursive function which for each iteration returns a Cons cell containing the current Char, and a thunk for unpacking the rest of the string. In this patch we change from storing addr + offset inside this thunk to storing only the addr, simply incrementing the address on each iteration. This saves one word of allocation per unpacked character. For a program like "main = print "<largishString>" this amounts to 2-3% fewer % in bytes allocated. I also removed the now redundant local unpack definitions. This removes one call per unpack operation. - - - - - bec76733 by Ben Gamari at 2020-02-08T10:19:57-05:00 Fix GhcThreaded setting This adopts a patch from NetBSD's packaging fixing the `GhcThreaded` option of the make build system. In addition we introduce a `ghcThreaded` option in hadrian's `Flavour` type. Also fix Hadrian's treatment of the `Use Threaded` entry in `settings`. Previously it would incorrectly claim `Use Threaded = True` if we were building the `threaded` runtime way. However, this is inconsistent with the `make` build system, which defines it to be whether the `ghc` executable is linked against the threaded runtime. Fixes #17692. - - - - - 545cf1e1 by Ben Gamari at 2020-02-08T10:20:37-05:00 hadrian: Depend upon libray dependencies when configuring packages This will hopefully fix #17631. - - - - - 047d3d75 by Ben Gamari at 2020-02-08T10:21:16-05:00 testsuite: Add test for #15316 This is the full testcase for T15316. - - - - - 768e5866 by Julien Debon at 2020-02-08T10:22:07-05:00 doc(Data.List): Add some examples to Data.List - - - - - 3900cb83 by Julien Debon at 2020-02-08T10:22:07-05:00 Apply suggestion to libraries/base/GHC/List.hs - - - - - bd666766 by Ben Gamari at 2020-02-08T10:22:45-05:00 users-guide: Clarify that bundled patsyns were introduced in GHC 8.0 Closes #17094. - - - - - 95741ea1 by Pepe Iborra at 2020-02-08T10:23:23-05:00 Update to hie-bios 0.3.2 style program cradle - - - - - fb5c1912 by Sylvain Henry at 2020-02-08T10:24:07-05:00 Remove redundant case This alternative is redundant and triggers no warning when building with 8.6.5 - - - - - 5d83d948 by Matthew Pickering at 2020-02-08T10:24:43-05:00 Add mkHieFileWithSource which doesn't read the source file from disk cc/ @pepeiborra - - - - - dfdae56d by Andreas Klebinger at 2020-02-08T10:25:20-05:00 Rename ghcAssert to stgAssert in hp2ps/Main.h. This fixes #17763 - - - - - 658f7ac6 by Ben Gamari at 2020-02-08T10:26:00-05:00 includes: Avoid using single-line comments in HsFFI.h While single-line comments are supported by C99, dtrace on SmartOS apparently doesn't support them yet. - - - - - c95920a6 by Ömer Sinan Ağacan at 2020-02-08T10:26:42-05:00 Import qualified Prelude in parser This is in preparation of backwards-incompatible changes in happy. See https://github.com/simonmar/happy/issues/166 - - - - - b6dc319a by Ömer Sinan Ağacan at 2020-02-08T10:27:23-05:00 Add regression test for #12760 The bug seems to be fixed in the meantime, make sure it stays fixed. Closes #12760 - - - - - b3857b62 by Ben Gamari at 2020-02-08T10:28:03-05:00 base: Drop out-of-date comment The comment in GHC.Base claimed that ($) couldn't be used in that module as it was wired-in. However, this is no longer true; ($) is merely known key and is defined in Haskell (with a RuntimeRep-polymorphic type) in GHC.Base. The one piece of magic that ($) retains is that it a special typing rule to allow type inference with higher-rank types (e.g. `runST $ blah`; see Note [Typing rule for ($)] in TcExpr). - - - - - 1183ae94 by Daniel Gröber at 2020-02-08T10:29:00-05:00 rts: Fix Arena blocks accounting for MBlock sized allocations When requesting more than BLOCKS_PER_MBLOCK blocks allocGroup can return a different number of blocks than requested. Here we use the number of requested blocks, however arenaFree will subtract the actual number of blocks we got from arena_blocks (possibly) resulting in a negative value and triggering ASSERT(arena_blocks >= 0). - - - - - 97d59db5 by Daniel Gröber at 2020-02-08T10:29:48-05:00 rts: Fix need_prealloc being reset when retainer profiling is on - - - - - 1f630025 by Krzysztof Gogolewski at 2020-02-09T02:52:27-05:00 Add a test for #15712 - - - - - 2ac784ab by Ben Gamari at 2020-02-09T02:53:05-05:00 hadrian: Add --test-metrics argument Allowing the test metric output to be captured to a file, a la the METRIC_FILE environment variable of the make build system. - - - - - f432d8c6 by Ben Gamari at 2020-02-09T02:53:05-05:00 hadrian: Fix --test-summary argument This appears to be a cut-and-paste error. - - - - - a906595f by Arnaud Spiwack at 2020-02-09T02:53:50-05:00 Fix an outdated note link This link appears to have been forgotten in 0dad81ca5fd1f63bf8a3b6ad09787559e8bd05c0 . - - - - - 3ae83da1 by Alp Mestanogullari at 2020-02-09T02:54:28-05:00 hadrian: Windows fixes (bindists, CI) This commit implements a few Windows-specific fixes which get us from a CI job that can't even get as far as starting the testsuite driver, to a state where we can run the entire testssuite (but have test failures to fix). - Don't forget about a potential extension for the haddock program, when preparing the bindist. - Build the timeout program, used by the testsuite driver on Windows in place of the Python script used elsewhere, using the boot compiler. We could alternatively build it with the compiler that we're going to test but this would be a lot more tedious to write. - Implement a wrapper-script less installation procedure for Windows, in `hadrian/bindist/Makefile. - Make dependencies a bit more accurate in the aforementioned Makefile. - Update Windows/Hadrian CI job accordingly. This patch fixes #17486. - - - - - 82f9be8c by Roland Senn at 2020-02-09T02:55:06-05:00 Fix #14628: Panic (No skolem Info) in GHCi This patch implements the [sugggestion from Simon (PJ)](https://gitlab.haskell.org/ghc/ghc/issues/14628#note_146559): - Make `TcErrors.getSkolemInfo` return a `SkolemInfo` rather than an `Implication`. - If `getSkolemInfo` gets `RuntimeUnk`s, just return a new data constructor in `SkolemInfo`, called `RuntimeUnkSkol`. - In `TcErrors.pprSkols` print something sensible for a `RuntimeUnkSkol`. The `getSkolemInfo` function paniced while formating suggestions to add type annotations (subfunction `suggestAddSig`) to a *"Couldn't match type ‘x’ with ‘y’"* error message. The `getSkolemInfo` function didn't find any Implication value and paniced. With this patch the `getSkolemInfo` function does no longer panic, if it finds `RuntimeUnkSkol`s. As the panic occured while processing an error message, we don't need to implement any new error message! - - - - - b2e18e26 by Andreas Klebinger at 2020-02-09T02:55:46-05:00 Fix -ddump-stg-final. Once again make sure this dumps the STG used for codegen. - - - - - 414e2f62 by Sylvain Henry at 2020-02-09T02:56:26-05:00 Force -fPIC for intree GMP (fix #17799) Configure intree GMP with `--with-pic` instead of patching it. Moreover the correct patching was only done for x86_64/darwin (see #17799). - - - - - f0fd72ee by Sebastian Graf at 2020-02-09T17:22:38-05:00 8.10 Release notes for improvements to the pattern-match checker [skip ci] A little late to the game, but better late than never. - - - - - 00dc0f7e by Ömer Sinan Ağacan at 2020-02-09T17:23:17-05:00 Add regression test for #13142 Closes #13142 - - - - - f3e737bb by Sebastian Graf at 2020-02-10T20:04:09-05:00 Fix long distance info for record updates For record updates where the `record_expr` is a variable, as in #17783: ```hs data PartialRec = No | Yes { a :: Int, b :: Bool } update No = No update r@(Yes {}) = r { b = False } ``` We should make use of long distance info in `-Wincomplete-record-updates` checking. But the call to `matchWrapper` in the `RecUpd` case didn't specify a scrutinee expression, which would correspond to the `record_expr` `r` here. That is fixed now. Fixes #17783. - - - - - 5670881d by Tamar Christina at 2020-02-10T20:05:04-05:00 Fs: Fix UNC remapping code. - - - - - 375b3c45 by Oleg Grenrus at 2020-02-11T05:07:30-05:00 Add singleton to Data.OldList - - - - - de32beff by Richard Eisenberg at 2020-02-11T05:08:10-05:00 Do not create nested quantified constraints Previously, we would accidentally make constraints like forall a. C a => forall b. D b => E a b c as we traversed superclasses. No longer! This patch also expands Note [Eagerly expand given superclasses] to work over quantified constraints; necessary for T16502b. Close #17202 and #16502. test cases: typecheck/should_compile/T{17202,16502{,b}} - - - - - e319570e by Ben Gamari at 2020-02-11T05:08:47-05:00 rts: Use nanosleep instead of usleep usleep was removed in POSIX.1-2008. - - - - - b75e7486 by Ben Gamari at 2020-02-11T05:09:24-05:00 rts: Remove incorrect assertions around MSG_THROWTO messages Previously we would assert that threads which are sending a `MSG_THROWTO` message must have their blocking status be blocked on the message. In the usual case of a thread throwing to another thread this is guaranteed by `stg_killThreadzh`. However, `throwToSelf`, used by the GC to kill threads which ran out of heap, failed to guarantee this. Noted while debugging #17785. - - - - - aba51b65 by Sylvain Henry at 2020-02-11T05:10:04-05:00 Add arithmetic exception primops (#14664) - - - - - b157399f by Ben Gamari at 2020-02-11T05:10:40-05:00 configure: Don't assume Gnu linker on Solaris Compl Yue noticed that the linker was dumping the link map on SmartOS. This is because Smartos uses the Solaris linker, which uses the `-64` flag, not `-m64` like Gnu ld, to indicate that it should link for 64-bits. Fix the configure script to handle the Solaris linker correctly. - - - - - d8d73d77 by Simon Peyton Jones at 2020-02-11T05:11:18-05:00 Notes only: telescopes This documentation-only patch fixes #17793 - - - - - 58a4ddef by Alp Mestanogullari at 2020-02-11T05:12:17-05:00 hadrian: build (and ship) iserv on Windows - - - - - 82023524 by Matthew Pickering at 2020-02-11T18:04:17-05:00 TemplateHaskellQuotes: Allow nested splices There is no issue with nested splices as they do not require any compile time code execution. All execution is delayed until the top-level splice. - - - - - 50e24edd by Ömer Sinan Ağacan at 2020-02-11T18:04:57-05:00 Remove Hadrian's copy of (Data.Functor.<&>) The function was added to base with base-4.11 (GHC 8.4) - - - - - f82a2f90 by Sylvain Henry at 2020-02-12T01:56:46-05:00 Document GMP build [skip ci] - - - - - da7f7479 by Sylvain Henry at 2020-02-12T01:57:27-05:00 Module hierarchy: ByteCode and Runtime (cf #13009) Update haddock submodule - - - - - 04f51297 by Ömer Sinan Ağacan at 2020-02-12T01:58:11-05:00 Fix naming of tests for #12923 - - - - - 31fc3321 by Ömer Sinan Ağacan at 2020-02-12T01:58:11-05:00 Add regression test for #12926 Closes #12926 - - - - - f0c0ee7d by Krzysztof Gogolewski at 2020-02-12T01:58:51-05:00 Fix order of arguments in specializer (#17801) See https://gitlab.haskell.org/ghc/ghc/issues/17801#note_253330 No regression test, as it's hard to trigger. - - - - - 059c3c9d by Sebastian Graf at 2020-02-12T11:00:58+01:00 Separate CPR analysis from the Demand analyser The reasons for that can be found in the wiki: https://gitlab.haskell.org/ghc/ghc/wikis/nested-cpr/split-off-cpr We now run CPR after demand analysis (except for after the final demand analysis run just before code gen). CPR got its own dump flags (`-ddump-cpr-anal`, `-ddump-cpr-signatures`), but not its own flag to activate/deactivate. It will run with `-fstrictness`/`-fworker-wrapper`. As explained on the wiki page, this step is necessary for a sane Nested CPR analysis. And it has quite positive impact on compiler performance: Metric Decrease: T9233 T9675 T9961 T15263 - - - - - f5ffd8d9 by Ben Gamari at 2020-02-12T17:22:37-05:00 base: Expose GHC.Unicode.unicodeVersion This exposes a Data.Version.Version representing the version of the Unicode database used by `base`. This should clear up some confusion I have seen in tickets regarding with which Unicode versions a given GHC can be expected to work. While in town I also regenerated (but did not update) the Unicode database with database 12.0.0. Strangely, the file cited in the README no longer existed. Consequently, I used https://www.unicode.org/Public/12.0.0/ucd/UnicodeData.txt and was slightly surprised to find that there were a few changes. - - - - - 6c2585e0 by Ben Gamari at 2020-02-12T17:22:37-05:00 base: Update Unicode database to 12.1.0 Using `curl https://www.unicode.org/Public/12.1.0/ucd/UnicodeData.txt | libraries/base/cbits/ubconfc 12.1.0`. - - - - - df084681 by Krzysztof Gogolewski at 2020-02-12T23:58:52+01:00 Always display inferred variables using braces We now always show "forall {a}. T" for inferred variables, previously this was controlled by -fprint-explicit-foralls. This implements part 1 of https://github.com/ghc-proposals/ghc-proposals/pull/179. Part of GHC ticket #16320. Furthermore, when printing a levity restriction error, we now display the HsWrap of the expression. This lets users see the full elaboration with -fprint-typechecker-elaboration (see also #17670) - - - - - 16d643cf by Sylvain Henry at 2020-02-13T09:16:04-05:00 Remove -ddump-srts flag This flag is deemed not useful. - - - - - fa28ae95 by Sylvain Henry at 2020-02-13T09:16:04-05:00 Fix flag documentation (#17826) - - - - - 1bfd8259 by Sylvain Henry at 2020-02-13T09:16:43-05:00 Ensure that Hadrian is built correctly before using it When Hadrian failed to build, the script would pick a previously built Hadrian (if available) instead of failing. - - - - - cd6e786a by Ömer Sinan Ağacan at 2020-02-14T05:29:56-05:00 Add test for #17648 - - - - - 9f2c3677 by Sylvain Henry at 2020-02-14T05:30:39-05:00 GMP expects the Target platform as --host parameter - - - - - aa6086fd by Oleg Grenrus at 2020-02-14T05:31:16-05:00 Add explicit LANGUAGE Safe to template-haskell (cherry picked from commit a5e0f376821ca882880b03b07b451aa574e289ec) - - - - - af6a0c36 by Ben Gamari at 2020-02-14T05:31:53-05:00 hadrian: Add execution and target architecture to stage-compilation figure - - - - - cf739945 by Sylvain Henry at 2020-02-14T05:32:37-05:00 Module hierarchy: HsToCore (cf #13009) - - - - - 719db318 by Simon Peyton Jones at 2020-02-14T05:33:16-05:00 De-duplicate overlapping Notes Documentation only. Fixes #17827 - - - - - 7550417a by Sylvain Henry at 2020-02-14T05:33:56-05:00 Hadrian: drop Sphinx flag checking for PDF documentation (#17825) It seems that Sphinx produces the ghc-flags.txt in doc/users_guide/_build rather than pdfRoot. We could copy ghc-flags.txt into pdfRoot (like happens naturally in the HTML case) but the benefit is pretty small. Let's just only check the HTML case. - - - - - 813842f4 by Ben Gamari at 2020-02-14T10:16:36-05:00 make: Be more selective in building windows-extra-src tarball - - - - - 0725f4bb by Ben Gamari at 2020-02-14T10:16:36-05:00 Rework handling of win32 toolchain tarballs - - - - - 565ce7ae by Ben Gamari at 2020-02-14T10:16:36-05:00 gitlab-ci: Consolidate CI logic This moves nearly all of the CI logic to .gitlab/ci.sh. This improves things in a number of ways: * it's harder for inconsistencies to arise between architectures * it's easier to share logic between architectures * on Windows, it's easier to ensure that all CI steps are executed from within a properly initialized mingw session. While in town I also add a FreeBSD build job and update the Windows job to use the gitlab-runner PowerShell executor, since cmd.exe will be deprecated soon (fixing #17699). - - - - - 9cbace74 by Ben Gamari at 2020-02-14T10:16:36-05:00 gitlab-ci: Deduplicate nightly job configuration - - - - - 6e837144 by Ben Gamari at 2020-02-14T10:16:36-05:00 integer-gmp: Fix unused command-line argument -L is only needed during linking. - - - - - e5ee07ab by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Don't ask sed to operate in-place on symlinks Some sed implementations (e.g. FreeBSD) refuse to operate in-place on symlinks. - - - - - 71e5e68f by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Disable tests that assume name of libstdc++ on FreeBSD - - - - - 7b2da0f4 by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Mark T6132 as broken on FreeBSD - - - - - 8ef7a15a by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite/T16930: Don't rely on gnu grep specific --include In BSD grep this flag only affects directory recursion. - - - - - 6060003e by Ben Gamari at 2020-02-14T10:16:36-05:00 Pass -Wno-unused-command-line-arguments during link on FreeBSD FreeBSD cc throws a warning if we pass -pthread without actually using any pthread symbols. - - - - - 97497bae by Ben Gamari at 2020-02-14T10:16:36-05:00 base: Always clamp reads/writes to 2GB in length Previously we did this only on Darwin due to #17414. However, even on other platforms >2GB writes are on shaky ground. POSIX explicitly says that the result is implementation-specified and Linux will write at most 0x7ffff000, even on 64-bit platforms. Moreover, getting the sign of the syscall result correct is tricky, as demonstrated by the fact that T17414 currently fails on FreeBSD. For simplicity we now just uniformly clamp to 0x7ffff000 on all platforms. - - - - - 49be2a3f by Ben Gamari at 2020-02-14T10:16:36-05:00 configure: Fix sphinx version test The check for the "v" prefix is redundant. - - - - - f7f7a556 by Ben Gamari at 2020-02-14T10:16:37-05:00 users-guide: Fix unknown link targets - - - - - a204102c by Ben Gamari at 2020-02-14T10:16:37-05:00 docs/compare-flags: Don't use python f-strings - - - - - 92e15a37 by Ben Gamari at 2020-02-14T10:16:37-05:00 gitlab-ci: Fix various shellcheck warnings - - - - - 459f7c6e by Ben Gamari at 2020-02-14T10:16:37-05:00 hadrian: Drop empty arguments from target list Fixes #17748. - - - - - c06df28d by Ben Gamari at 2020-02-14T10:16:37-05:00 users-guide: Fix "invalid file" failure I have no idea how this worked previously. Different Python version? - - - - - 3fe8444f by Ben Gamari at 2020-02-14T10:16:59-05:00 testsuite: Mark T7702 as fragile on Windows Due to #16799. There was previously an attempt to mark it as broken but the `opsys` name was incorrect. - - - - - fe02f781 by Ben Gamari at 2020-02-14T10:16:59-05:00 testsuite: Assert the opsys names are known Previously opsys would take any string. This meant it was very easy for a typo to silently render the predicate ineffective. Fix this by checking the given operating system name against a list of known values. - - - - - 149e2a3a by Ben Gamari at 2020-02-14T10:16:59-05:00 compare-flags: Don't rely on encoding flag of subprocess.check_output Apparently it isn't supported by some slightly older Python versions. - - - - - 798d59f6 by Ben Gamari at 2020-02-14T10:16:59-05:00 rts: Add more debug output to failed path in onIOComplete This will help track down #17035. - - - - - e35f3f98 by Ben Gamari at 2020-02-14T10:16:59-05:00 gitlab-ci: Allow i386 Windows builds to fail again Due to the resistance of #17736 to resolution. - - - - - 261a3cf8 by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Build integer-simple job in the validate flavour - - - - - b613a961 by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Always use mingw64 python on Windows - - - - - 1bc8c8cd by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Allow Windows build to fail due to #17777 The fact that `exec` isn't POSIX compliant means that things can break in arbitrarily bad ways. Sometimes things happen to work correctly but sadly this isn't always the case. - - - - - ac63020d by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Drop unnecessary GHC_VERSION check - - - - - 6926f369 by Ben Gamari at 2020-02-14T10:17:00-05:00 Bump process submodule Folds in the second part of Phyx's Windows process exit fixes [1], hopefully finally resolving issue #17480. [1] https://github.com/haskell/process/pull/160 - - - - - 584eee71 by Tamar Christina at 2020-02-14T10:17:00-05:00 SysTools: Use "process job" when spawning processes on Windows GHC should make calls using process jobs when calling out to GCC and LD. The reason is these use the exec () family of posix functions. Window's process model doesn't allow replacement of processes so this is emulated by creating a new process and immediately exiting the old one. Because of this when using normal Windows wait functions you would return even without the child process having finished. In this case if you are depending on data from the child you will enter a race condition. The usual fix for this is to use process jobs and wait for the termination of all children that have ever been spawn by the process you called. But also waiting for the freeing of all resources. - - - - - ecabfa28 by Tamar Christina at 2020-02-14T10:17:00-05:00 Revert "compiler: Disable atomic renaming on Windows" The original reason this was disabled should be fixed by the previous commit. This reverts commit 1c1b63d63efe8b0f789aa7d5b87cfac3edd213eb. - - - - - 06d60c66 by Ben Gamari at 2020-02-14T10:17:00-05:00 Bump Cabal submodule - - - - - 8cabb384 by Ben Gamari at 2020-02-14T10:17:00-05:00 compare-flags: Fix output - - - - - 8cf646d3 by Ben Gamari at 2020-02-14T10:17:00-05:00 users-guide: Document -ddump-srts - - - - - 932307a5 by Ben Gamari at 2020-02-14T10:17:00-05:00 users-guide: Fix broken reference - - - - - e77818de by Ben Gamari at 2020-02-15T09:26:55-05:00 Accept performance changes These manifested in the integer-simple job. Metric Decrease: T12227 T5549 T14936 T4830 Conversions T5237 T8766 T4801 T10359 Metric Increase: T12234 T6048 T3294 T14683 T3064 T9872b T9872c T783 T5837 T10678 T14697 T5631 T9203 T13719 T12707 T13056 T9630 T10547 T9872d T1969 WWRec T10370 T5321FD haddock.Cabal T5642 T9872a T15263 T12425 MultiLayerModules T5205 T9233 T13379 haddock.base T9020 T13035 T12150 T9961 - - - - - 785008c1 by Ben Gamari at 2020-02-15T09:30:13-05:00 testsuite: Sort test names in expected change output - - - - - 9e851472 by Ömer Sinan Ağacan at 2020-02-16T10:38:41+03:00 Revert "users-guide: Document -ddump-srts" This reverts commit 8cf646d36b02b8ea1c289cb52781c9171853b514. The flag was removed by 16d643cf. [ci skip] - - - - - 9792c816 by Ben Gamari at 2020-02-16T09:47:08-05:00 testsuite: Probe whether symlinks are usable on Windows Closes #17706. - - - - - ee1e5342 by Vladislav Zavialov at 2020-02-16T09:47:44-05:00 Fix the "unused terminals: 2" warning in Parser.y - - - - - b4a8ce52 by Roland Senn at 2020-02-18T20:14:42-05:00 If a :reload finds syntax errors in the module graph, remove the loaded modules. (Fixes #17549) The processing in `compiler/main/GhcMake.hs` computes the ModuleGraph. If it finds errors in the module header or in the import specifications, then the new module graph is incomplete and should not be used. The code before #17549 just reported the errors and left the old ModuleGraph in place. The new code of this MR replaces the old ModuleGraph with an empty one. - - - - - d7029cc0 by Sylvain Henry at 2020-02-18T20:15:30-05:00 Hadrian: refactor GMP in-tree build support (#17756) * Hadrian doesn't use integer-gmp/config.mk file anymore to determine if building GMP in-tree is required. "config.mk" is created by Cabal when the integer-gmp package is configured and this file is still untracked by Hadrian. This led to a tricky configure "race" because "config.mk" is built by the "setup-config" rule, but this rule is also used to find dependencies, in particular the "ghc-gmp.h" header, but the creation of this file was depending (without being tracked) on "config.mk". Now Hadrian only builds in-tree GMP if `--with-intree-gmp` is passed to the top-level configure script. * in-tree GMP isn't built once for all in a fixed stage (Stage1) anymore. It is built per stage which is required if we build a cross-compiler * switching between in-tree and external GMP is now supported without having to clean the build directory first. * "wrappers.c" now includes "ghc-gmp.h" instead of "ghc.h". It helps ensuring that the build system generates "ghc-gmp.h". * build in-tree GMP in "<root>/stageN/gmp/gmpbuild" and produce useful artefacts (libgmp.a, gmp.h, objs/*.o) in "<root>/stageN/gmp" - - - - - 40d917fb by Vladislav Zavialov at 2020-02-18T20:16:07-05:00 Remove the MonadFail P instance There were two issues with this instance: * its existence meant that a pattern match failure in the P monad would produce a user-visible parse error, but the error message would not be helpful to the user * due to the MFP migration strategy, we had to use CPP in Lexer.x, and that created issues for #17750 Updates haddock submodule. - - - - - 5a1ce45d by Joshua Price at 2020-02-18T20:16:47-05:00 Fix unboxed tuple size limit (#17837) - - - - - 192caf58 by Vladislav Zavialov at 2020-02-18T20:17:24-05:00 Fix testsuite driver output (#17847) - - - - - 1500f089 by Sylvain Henry at 2020-02-18T20:18:12-05:00 Modules: Llvm (#13009) - - - - - d53e81c0 by Niklas Hambüchen at 2020-02-20T10:36:22-05:00 8.10 Release notes for atomic .o writes [skip ci] - - - - - 19680ee5 by Niklas Hambüchen at 2020-02-20T10:37:53-05:00 8.10 Release notes for --disable-delayed-os-memory-return [skip ci] - - - - - 74ad75e8 by Simon Peyton Jones at 2020-02-20T21:17:57-05:00 Re-implement unsafe coercions in terms of unsafe equality proofs (Commit message written by Omer, most of the code is written by Simon and Richard) See Note [Implementing unsafeCoerce] for how unsafe equality proofs and the new unsafeCoerce# are implemented. New notes added: - [Checking for levity polymorphism] in CoreLint.hs - [Implementing unsafeCoerce] in base/Unsafe/Coerce.hs - [Patching magic definitions] in Desugar.hs - [Wiring in unsafeCoerce#] in Desugar.hs Only breaking change in this patch is unsafeCoerce# is not exported from GHC.Exts, instead of GHC.Prim. Fixes #17443 Fixes #16893 NoFib ----- -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.1% 0.0% -0.0% -0.0% -0.0% CSD -0.1% 0.0% -0.0% -0.0% -0.0% FS -0.1% 0.0% -0.0% -0.0% -0.0% S -0.1% 0.0% -0.0% -0.0% -0.0% VS -0.1% 0.0% -0.0% -0.0% -0.0% VSD -0.1% 0.0% -0.0% -0.0% -0.1% VSM -0.1% 0.0% -0.0% -0.0% -0.0% anna -0.0% 0.0% -0.0% -0.0% -0.0% ansi -0.1% 0.0% -0.0% -0.0% -0.0% atom -0.1% 0.0% -0.0% -0.0% -0.0% awards -0.1% 0.0% -0.0% -0.0% -0.0% banner -0.1% 0.0% -0.0% -0.0% -0.0% bernouilli -0.1% 0.0% -0.0% -0.0% -0.0% binary-trees -0.1% 0.0% -0.0% -0.0% -0.0% boyer -0.1% 0.0% -0.0% -0.0% -0.0% boyer2 -0.1% 0.0% -0.0% -0.0% -0.0% bspt -0.1% 0.0% -0.0% -0.0% -0.0% cacheprof -0.1% 0.0% -0.0% -0.0% -0.0% calendar -0.1% 0.0% -0.0% -0.0% -0.0% cichelli -0.1% 0.0% -0.0% -0.0% -0.0% circsim -0.1% 0.0% -0.0% -0.0% -0.0% clausify -0.1% 0.0% -0.0% -0.0% -0.0% comp_lab_zift -0.1% 0.0% -0.0% -0.0% -0.0% compress -0.1% 0.0% -0.0% -0.0% -0.0% compress2 -0.1% 0.0% -0.0% -0.0% -0.0% constraints -0.1% 0.0% -0.0% -0.0% -0.0% cryptarithm1 -0.1% 0.0% -0.0% -0.0% -0.0% cryptarithm2 -0.1% 0.0% -0.0% -0.0% -0.0% cse -0.1% 0.0% -0.0% -0.0% -0.0% digits-of-e1 -0.1% 0.0% -0.0% -0.0% -0.0% digits-of-e2 -0.1% 0.0% -0.0% -0.0% -0.0% dom-lt -0.1% 0.0% -0.0% -0.0% -0.0% eliza -0.1% 0.0% -0.0% -0.0% -0.0% event -0.1% 0.0% -0.0% -0.0% -0.0% exact-reals -0.1% 0.0% -0.0% -0.0% -0.0% exp3_8 -0.1% 0.0% -0.0% -0.0% -0.0% expert -0.1% 0.0% -0.0% -0.0% -0.0% fannkuch-redux -0.1% 0.0% -0.0% -0.0% -0.0% fasta -0.1% 0.0% -0.5% -0.3% -0.4% fem -0.1% 0.0% -0.0% -0.0% -0.0% fft -0.1% 0.0% -0.0% -0.0% -0.0% fft2 -0.1% 0.0% -0.0% -0.0% -0.0% fibheaps -0.1% 0.0% -0.0% -0.0% -0.0% fish -0.1% 0.0% -0.0% -0.0% -0.0% fluid -0.1% 0.0% -0.0% -0.0% -0.0% fulsom -0.1% 0.0% +0.0% +0.0% +0.0% gamteb -0.1% 0.0% -0.0% -0.0% -0.0% gcd -0.1% 0.0% -0.0% -0.0% -0.0% gen_regexps -0.1% 0.0% -0.0% -0.0% -0.0% genfft -0.1% 0.0% -0.0% -0.0% -0.0% gg -0.1% 0.0% -0.0% -0.0% -0.0% grep -0.1% 0.0% -0.0% -0.0% -0.0% hidden -0.1% 0.0% -0.0% -0.0% -0.0% hpg -0.1% 0.0% -0.0% -0.0% -0.0% ida -0.1% 0.0% -0.0% -0.0% -0.0% infer -0.1% 0.0% -0.0% -0.0% -0.0% integer -0.1% 0.0% -0.0% -0.0% -0.0% integrate -0.1% 0.0% -0.0% -0.0% -0.0% k-nucleotide -0.1% 0.0% -0.0% -0.0% -0.0% kahan -0.1% 0.0% -0.0% -0.0% -0.0% knights -0.1% 0.0% -0.0% -0.0% -0.0% lambda -0.1% 0.0% -0.0% -0.0% -0.0% last-piece -0.1% 0.0% -0.0% -0.0% -0.0% lcss -0.1% 0.0% -0.0% -0.0% -0.0% life -0.1% 0.0% -0.0% -0.0% -0.0% lift -0.1% 0.0% -0.0% -0.0% -0.0% linear -0.1% 0.0% -0.0% -0.0% -0.0% listcompr -0.1% 0.0% -0.0% -0.0% -0.0% listcopy -0.1% 0.0% -0.0% -0.0% -0.0% maillist -0.1% 0.0% -0.0% -0.0% -0.0% mandel -0.1% 0.0% -0.0% -0.0% -0.0% mandel2 -0.1% 0.0% -0.0% -0.0% -0.0% mate -0.1% 0.0% -0.0% -0.0% -0.0% minimax -0.1% 0.0% -0.0% -0.0% -0.0% mkhprog -0.1% 0.0% -0.0% -0.0% -0.0% multiplier -0.1% 0.0% -0.0% -0.0% -0.0% n-body -0.1% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.1% 0.0% -0.0% -0.0% -0.0% para -0.1% 0.0% -0.0% -0.0% -0.0% paraffins -0.1% 0.0% -0.0% -0.0% -0.0% parser -0.1% 0.0% -0.0% -0.0% -0.0% parstof -0.1% 0.0% -0.0% -0.0% -0.0% pic -0.1% 0.0% -0.0% -0.0% -0.0% pidigits -0.1% 0.0% -0.0% -0.0% -0.0% power -0.1% 0.0% -0.0% -0.0% -0.0% pretty -0.1% 0.0% -0.1% -0.1% -0.1% primes -0.1% 0.0% -0.0% -0.0% -0.0% primetest -0.1% 0.0% -0.0% -0.0% -0.0% prolog -0.1% 0.0% -0.0% -0.0% -0.0% puzzle -0.1% 0.0% -0.0% -0.0% -0.0% queens -0.1% 0.0% -0.0% -0.0% -0.0% reptile -0.1% 0.0% -0.0% -0.0% -0.0% reverse-complem -0.1% 0.0% -0.0% -0.0% -0.0% rewrite -0.1% 0.0% -0.0% -0.0% -0.0% rfib -0.1% 0.0% -0.0% -0.0% -0.0% rsa -0.1% 0.0% -0.0% -0.0% -0.0% scc -0.1% 0.0% -0.1% -0.1% -0.1% sched -0.1% 0.0% -0.0% -0.0% -0.0% scs -0.1% 0.0% -0.0% -0.0% -0.0% simple -0.1% 0.0% -0.0% -0.0% -0.0% solid -0.1% 0.0% -0.0% -0.0% -0.0% sorting -0.1% 0.0% -0.0% -0.0% -0.0% spectral-norm -0.1% 0.0% -0.0% -0.0% -0.0% sphere -0.1% 0.0% -0.0% -0.0% -0.0% symalg -0.1% 0.0% -0.0% -0.0% -0.0% tak -0.1% 0.0% -0.0% -0.0% -0.0% transform -0.1% 0.0% -0.0% -0.0% -0.0% treejoin -0.1% 0.0% -0.0% -0.0% -0.0% typecheck -0.1% 0.0% -0.0% -0.0% -0.0% veritas -0.0% 0.0% -0.0% -0.0% -0.0% wang -0.1% 0.0% -0.0% -0.0% -0.0% wave4main -0.1% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 -0.1% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 -0.1% 0.0% -0.0% -0.0% -0.0% x2n1 -0.1% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.5% -0.3% -0.4% Max -0.0% 0.0% +0.0% +0.0% +0.0% Geometric Mean -0.1% -0.0% -0.0% -0.0% -0.0% Test changes ------------ - break006 is marked as broken, see #17833 - The compiler allocates less when building T14683 (an unsafeCoerce#- heavy happy-generated code) on 64-platforms. Allocates more on 32-bit platforms. - Rest of the increases are tiny amounts (still enough to pass the threshold) in micro-benchmarks. I briefly looked at each one in a profiling build: most of the increased allocations seem to be because of random changes in the generated code. Metric Decrease: T14683 Metric Increase: T12150 T12234 T12425 T13035 T14683 T5837 T6048 Co-Authored-By: Richard Eisenberg <rae at cs.brynmawr.edu> Co-Authored-By: Ömer Sinan Ağacan <omeragacan at gmail.com> - - - - - 6880d6aa by Sylvain Henry at 2020-02-20T21:18:48-05:00 Disentangle DynFlags and SDoc Remove several uses of `sdocWithDynFlags`. The remaining ones are mostly CodeGen related (e.g. depend on target platform constants) and will be fixed separately. Metric Decrease: T12425 T9961 WWRec T1969 T14683 - - - - - 70a90110 by Julien Debon at 2020-02-20T21:19:27-05:00 doc(List): Add examples to GHC.List * Add examples * Cleanup documentation * Clarify merge process and Marge bot - - - - - c8439fc7 by Peter Trommler at 2020-02-20T21:20:05-05:00 Fix testsuite on powerpc64le Remove expect broken on recomp tests, #11260 was closed by !2264 and #11323 most likely by !2264 as well. GHCi scripts tests work on GHCi but not the external interpreter, adjust test configuration accordingly. Fixes unexpected passes. Mark test requiring DWARF expect fail on powerpc64[le] for #11261. - - - - - 65b7256a by Ömer Sinan Ağacan at 2020-02-20T21:20:45-05:00 Use concatMap(M) instead of `concat . map` and the monadic variant - - - - - 8b76d457 by Roland Senn at 2020-02-20T21:21:28-05:00 Fix #17832: Weird handling of exports named main in 8.10-rc1 Switching from `lookupGlobalOccRn_maybe` to `lookupInfoOccRn` to check whether a `main` function is in scope. Unfortunately `lookupGlobalOccRn_maybe` complains if there are multiple `main` functions in scope. - - - - - 466e1ad5 by Krzysztof Gogolewski at 2020-02-20T21:22:11-05:00 Use TTG for HsSplicedT constructor The constructor HsSplicedT occurs only in the GhcTc pass. This enforces this fact statically via TTG. - - - - - 4e622fca by Alexis King at 2020-02-20T21:22:49-05:00 Normalize types when dropping absent arguments from workers fixes #17852 - - - - - a533e547 by Adam Sandberg Eriksson at 2020-02-20T21:23:31-05:00 Mention users guide and release notes in merge request template - - - - - 05251b17 by Ben Gamari at 2020-02-20T21:24:08-05:00 gitlab-ci: Fix typo in BIN_DIST_PREP_TAR_COMP variable name - - - - - f44c7e67 by Ben Gamari at 2020-02-20T21:24:46-05:00 gitlab-ci: Avoid duplicating ~/.cabal contents with every build Previously our attempt to cache the cabal store would `cp cabal-cache ~/.cabal`. However, if the latter already existed this meant that we would end up with ~/.cabal/cabal-cache. Not only would this not help caching but it would exponentially grow the size of ~/.cabal. Not good! - - - - - c5ec9965 by Ben Gamari at 2020-02-20T21:56:13-05:00 GHC.Hs.Extension: Use Type instead of * - - - - - 89cb4cc4 by Ben Gamari at 2020-02-20T21:56:13-05:00 Use Type instead of * in GHC - - - - - 04eb0d6c by Ben Gamari at 2020-02-20T21:56:13-05:00 Enable -Wstar-is-type in -Wall As noted in [proposal 0143][proposal] this is supposed to happen in 8.12. Also fix an incorrect claim in the users guide that -Wstar-is-type is enabled by default. [proposal]: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0143-remove-star-kind.rst - - - - - 6de966f1 by Andreas Klebinger at 2020-02-20T21:56:15-05:00 Fix #17724 by having occAnal preserve used bindings. It sometimes happened that occAnal would remove bindings as dead code by relying on bindings to be in dependency order. The fix was contributed by SPJ. - - - - - abd7f962 by Ben Gamari at 2020-02-20T21:56:15-05:00 users-guide: Mention dependency on `exceptions` in release notes Fixes #17845. - - - - - 58175379 by Sylvain Henry at 2020-02-20T21:56:20-05:00 Hadrian: minor GMP refactoring Somehow I forgot to totally remove `gmpContext` in d7029cc09edc052c2f97effe33233c53340fcce0. This patch fixes it and adds some additional comments. - - - - - 33fa8d94 by Ryan Scott at 2020-02-20T21:56:21-05:00 Generalize liftData to work over any Quote (#17857) The Overloaded Quotations proposal generalized the type of `lift` to work over any `Quote`, but not the type of `liftData`, leading to #17857. Thankfully, generalizing `liftData` is extremely straightforward. Fixes #17857. - - - - - 3cea6795 by Sylvain Henry at 2020-02-20T21:56:23-05:00 Make: fix sdist target (#17848) - - - - - e2cce997 by Sylvain Henry at 2020-02-20T21:56:23-05:00 Hadrian: fix source-dist target (#17849) - - - - - 0a4c89b2 by Matthew Pickering at 2020-02-21T20:44:45-05:00 Special case `mkTyConApp liftedTypeKind []` We really need to make sure that these are shared because otherwise GHC will allocate thousands of identical `TyConApp` nodes. See #17292 ------------------------- Metric Decrease: haddock.Cabal T14683 ------------------------- - - - - - 0482f58a by Matthew Pickering at 2020-02-21T20:45:21-05:00 TH: wrapGenSyns, don't split the element type too much The invariant which allowed the pervious method of splitting the type of the body to find the type of the elements didn't work in the new overloaded quotation world as the type can be something like `WriterT () m a` rather than `Q a` like before. Fixes #17839 - - - - - be7068a6 by Vladislav Zavialov at 2020-02-21T20:45:59-05:00 Parser API annotations: RealSrcLoc During parsing, GHC collects lexical information about AST nodes and stores it in a map. It is needed to faithfully restore original source code, e.g. compare these expressions: a = b a = b The position of the equality sign is not recorded in the AST, so it must be stored elsewhere. This system is described in Note [Api annotations]. Before this patch, the mapping was represented by: Map (SrcSpan, AnnKeywordId) SrcSpan After this patch, the mapping is represented by: Map (RealSrcSpan, AnnKeywordId) RealSrcSpan The motivation behind this change is to avoid using the Ord SrcSpan instance (required by Map here), as it interferes with #17632 (see the discussion there). SrcSpan is isomorphic to Either String RealSrcSpan, but we shouldn't use those strings as Map keys. Those strings are intended as hints to the user, e.g. "<interactive>" or "<compiler-generated code>", so they are not a valid way to identify nodes in the source code. - - - - - 240f5bf6 by Sylvain Henry at 2020-02-21T20:46:40-05:00 Modules: Driver (#13009) submodule updates: nofib, haddock - - - - - 9d094111 by Sylvain Henry at 2020-02-21T20:47:19-05:00 Hadrian: `docs` rule needs `configure` (#17840) - - - - - 1674353a by Ben Gamari at 2020-02-23T17:31:19-05:00 fs: Port fixes from ghc-jailbreak repository * Override rename, unlink, and remove * Factor out wchar conversion - - - - - 853210f2 by Adam Sandberg Ericsson at 2020-02-23T17:32:03-05:00 show gcc linker options in configure summary - - - - - 2831544a by Adam Sandberg Ericsson at 2020-02-23T17:32:44-05:00 hadrian: docs depend on stage1 ghc - - - - - 1d9df9e0 by Adam Sandberg Ericsson at 2020-02-23T17:33:23-05:00 ci: after 5ce63d52fed the linux bindist for doc-tarball has changed name - - - - - 26e8fff3 by Vladislav Zavialov at 2020-02-24T02:05:30-05:00 Remove Ord SrcLoc, Ord SrcSpan Before this patch, GHC relied on Ord SrcSpan to identify source elements, by using SrcSpan as Map keys: blackList :: Map SrcSpan () -- compiler/GHC/HsToCore/Coverage.hs instanceMap :: Map SrcSpan Name -- compiler/GHC/HsToCore/Docs.hs Firstly, this design is not valid in presence of UnhelpfulSpan, as it distinguishes between UnhelpfulSpan "X" and UnhelpfulSpan "Y", but those strings are messages for the user, unfit to serve as identifiers for source elements. Secondly, this design made it hard to extend SrcSpan with additional data. Recall that the definition of SrcSpan is: data SrcSpan = RealSrcSpan !RealSrcSpan | UnhelpfulSpan !FastString Say we want to extend the RealSrcSpan constructor with additional information: data SrcSpan = RealSrcSpan !RealSrcSpan !AdditionalInformation | UnhelpfulSpan !FastString getAdditionalInformation :: SrcSpan -> AdditionalInformation getAdditionalInformation (RealSrcSpan _ a) = a Now, in order for Map SrcSpan to keep working correctly, we must *ignore* additional information when comparing SrcSpan values: instance Ord SrcSpan where compare (RealSrcSpan r1 _) (RealSrcSpan r2 _) = compare r1 r2 ... However, this would violate an important law: a == b therefore f a == f b Ignoring AdditionalInformation in comparisons would mean that with f=getAdditionalInformation, the law above does not hold. A more robust design is to avoid Ord SrcSpan altogether, which is what this patch implements. The mappings are changed to use RealSrcSpan instead: blackList :: Set RealSrcSpan -- compiler/GHC/HsToCore/Coverage.hs instanceMap :: Map RealSrcSpan Name -- compiler/GHC/HsToCore/Docs.hs All SrcSpan comparisons are now done with explicit comparison strategies: SrcLoc.leftmost_smallest SrcLoc.leftmost_largest SrcLoc.rightmost_smallest These strategies are not subject to the law mentioned above and can easily discard both the string stored in UnhelpfulSpan and AdditionalInformation. Updates haddock submodule. - - - - - 5aa6c188 by Ben Gamari at 2020-02-24T02:06:09-05:00 users-guide: Shuffle text - - - - - e3f17413 by Ben Gamari at 2020-02-24T02:06:09-05:00 users-guide: Drop old release notes - - - - - 84dd9610 by Ben Gamari at 2020-02-24T02:06:09-05:00 Bump directory submodule to 1.3.6.0 - - - - - e295a024 by Stefan Pavikevik at 2020-02-24T20:53:44-05:00 check for safe arguments, raising error when invalid (fix #17720) - - - - - 354e2787 by Krzysztof Gogolewski at 2020-02-24T20:54:35-05:00 Comments, small refactor * Remove outdated Note [HsForAllTy tyvar binders] and [Context quantification]. Since the wildcard refactor 1e041b7382, HsForAllTy no longer has an flag controlling explicity. The field `hsq_implicit` is gone too. The current situation is covered by Note [HsType binders] which is already linked from LHsQTyVars. * Small refactor in CoreLint, extracting common code to a function * Remove "not so sure about WpFun" in TcEvidence, per Richard's comment https://gitlab.haskell.org/ghc/ghc/merge_requests/852#note_223226 * Use mkIfThenElse in Foreign/Call, as it does exactly what we need. - - - - - 1b1067d1 by Sylvain Henry at 2020-02-24T20:55:25-05:00 Modules: CmmToAsm (#13009) - - - - - 621468f6 by Alexis King at 2020-02-26T15:08:09-05:00 Treat coercions as arguments for floating and inlining This reverts commit 8924224ecfa065ebc67b96a90d01cf9d2edd0e77 and fixes #17787. - - - - - def486c9 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Allow libnuma library path to be specified - - - - - ed03d4e7 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Refactor gmp arguments Move the gmp configuration to its own binding. - - - - - 09b88384 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Tell Cabal about integer-gmp library location - - - - - 161e08c5 by Krzysztof Gogolewski at 2020-02-26T15:09:30-05:00 Remove dead code * FailablePattern can no longer be created since ab51bee40c82 Therefore, Opt_WarnMissingMonadFailInstances has no effect anymore. * XWrap is no longer used, it was moved to an extension field - - - - - e0d09db3 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Use 8.8.3 to bootstrap on Windows This should fix #17861. - - - - - 972bcf3a by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Fix symlink test Needs to `write` bytes, not str. - - - - - 273e60de by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Add shell subcommand for debugging within CI environment - - - - - 43b13ed3 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Fix colors on Darwin Darwin sh doesn't support \e. - - - - - 217546a7 by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Flush stdout buffers in InitEventLogging Otherwise we are sensitive to libc's buffering strategy. Similar to the issue fixed in 543dfaab166c81f46ac4af76918ce32190aaab22. - - - - - c7d4fa55 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Add run_hadrian subcommand I've ruined two trees already by failing to pass --flavour to hadrian. Let's factor this out so it can be reused during troubleshooting. - - - - - 7dc54873 by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Allow tests to be marked as broken on the command line This allows us to work-around distribution-specific breakage easily. - - - - - 25e2458e by Ben Gamari at 2020-02-26T15:10:09-05:00 hadrian: Add --broken-test flag This exposes the flag of the same name supported by the testsuite driver. - - - - - 55769996 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Mark some tests as broken on Alpine - - - - - 9ee7f87d by Ben Gamari at 2020-02-26T15:10:09-05:00 SysTools: Don't use process jobs if they are broken - - - - - bfaa3961 by Ben Gamari at 2020-02-26T15:10:09-05:00 Bump hsc2hs submodule Fixes name of C compiler. - - - - - b2b49a0a by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Make hasMetricsFile RHS more descriptive - - - - - 817f93ea by Sylvain Henry at 2020-02-26T15:10:58-05:00 Modules: Core (#13009) Update haddock submodule - - - - - 74311e10 by Sebastian Graf at 2020-02-27T16:22:45-05:00 PmCheck: Implement Long-distance information with Covered sets Consider ```hs data T = A | B | C f :: T -> Int f A = 1 f x = case x of A -> 2 B -> 3 C -> 4 ``` Clearly, the RHS returning 2 is redundant. But we don't currently see that, because our approximation to the covered set of the inner case expression just picks up the positive information from surrounding pattern matches. It lacks the context sensivity that `x` can't be `A` anymore! Therefore, we adopt the conceptually and practically superior approach of reusing the covered set of a particular GRHS from an outer pattern match. In this case, we begin checking the `case` expression with the covered set of `f`s second clause, which encodes the information that `x` can't be `A` anymore. After this MR, we will successfully warn about the RHS returning 2 being redundant. Perhaps surprisingly, this was a great simplification to the code of both the coverage checker and the desugarer. Found a redundant case alternative in `unix` submodule, so we have to bump it with a fix. Metric Decrease: T12227 - - - - - 59c023ba by Adam Sandberg Ericsson at 2020-02-27T16:23:25-05:00 configure: correctly generate LIBRARY_template_haskell_VERSION - - - - - 9be82389 by Krzysztof Gogolewski at 2020-02-28T02:35:35-05:00 boot: Remove remote origin check Previously, we used relative paths in submodules. When cloning from GitHub, they had to be manually tweaked. Since a76b233d we use absolute paths, so this workaround can be removed. - - - - - f4b6b594 by Ben Gamari at 2020-02-28T02:36:12-05:00 nonmoving: Fix marking in compact regions Previously we were tracing the object we were asked to mark, even if it lives in a compact region. However, there is no need to do this; we need only to mark the region itself as live. I have seen a segfault due to this due to the concurrent mark seeing a an object in the process of being compacted by the mutator. - - - - - f97d1fb6 by Alp Mestanogullari at 2020-02-28T02:36:59-05:00 base: use an explicit import list in System.Environment.ExecutablePath This was making -Werror builds fail on Windows (at least with Hadrian). - - - - - 66f5d6d6 by Simon Peyton Jones at 2020-02-28T22:03:23-05:00 Improve error handling for VTA + deferred type errors This fixes #17792 See Note [VTA for out-of-scope functions] in TcExpr - - - - - 37f12603 by Ilias Tsitsimpis at 2020-02-28T22:04:04-05:00 llvm-targets: Add arm-unknown-linux-gnueabi Add arm-unknown-linux-gnueabi, which is used by Debian's ARM EABI port (armel), as an LLVM target. - - - - - 327b29e1 by Vladislav Zavialov at 2020-02-29T05:06:31-05:00 Monotonic locations (#17632) When GHC is parsing a file generated by a tool, e.g. by the C preprocessor, the tool may insert #line pragmas to adjust the locations reported to the user. As the result, the locations recorded in RealSrcLoc are not monotonic. Elements that appear later in the StringBuffer are not guaranteed to have a higher line/column number. In fact, there are no guarantees whatsoever, as #line pragmas can arbitrarily modify locations. This lack of guarantees makes ideas such as #17544 infeasible. This patch adds an additional bit of information to every SrcLoc: newtype BufPos = BufPos { bufPos :: Int } A BufPos represents the location in the StringBuffer, unaffected by any pragmas. Updates haddock submodule. Metric Increase: haddock.Cabal haddock.base haddock.compiler MultiLayerModules Naperian parsing001 T12150 - - - - - 99d2de86 by Ben Gamari at 2020-02-29T05:07:10-05:00 plugins: Ensure that loadInterface plugins can see annotations loadInterface replaces the `mi_decls`, `mi_insts`, `mi_fam_insts`, `mi_rules`, `mi_anns` fields of ModIface with `undefined` before inserting the interface into the EPS. However, we still want to give loadInterface plugins access to these fields. Consequently, we want to pass the unmodified `ModIface` the plugin. - - - - - a999ee96 by Xavier Denis at 2020-02-29T05:07:50-05:00 Rename ghci.sh and build.sh to ghci and build respectively Convert hadrian buildscripts to unsuffixed, dashed form final cleanups - - - - - b5fb58fd by Ömer Sinan Ağacan at 2020-02-29T05:08:36-05:00 Document and refactor a few things around bitmap scavenging - Added a few comments in StgPAP - Added a few comments and assertions in scavenge_small_bitmap and walk_large_bitmap - Did tiny refactor in GHC.Data.Bitmap: added some comments, deleted dead code, used PlatformWordSize type. - - - - - 18757cab by Sylvain Henry at 2020-02-29T05:09:25-05:00 Refactor runtime interpreter code In #14335 we want to be able to use both the internal interpreter (for the plugins) and the external interpreter (for TH and GHCi) at the same time. This patch performs some preliminary refactoring: the `hsc_interp` field of HscEnv replaces `hsc_iserv` and is now used to indicate which interpreter (internal, external) to use to execute TH and GHCi. Opt_ExternalInterpreter flag and iserv options in DynFlags are now queried only when we set the session DynFlags. It should help making GHC multi-target in the future by selecting an interpreter according to the selected target. - - - - - b86a6395 by Adam Sandberg Ericsson at 2020-02-29T05:10:06-05:00 docs: correct relative links to haddocks from users guide (fixes #17866) - - - - - 0f55df7f by Adam Sandberg Ericsson at 2020-02-29T05:10:06-05:00 docs: correct link to th haddocks from users guide - - - - - 252e5117 by Jean-Baptiste Mazon at 2020-02-29T05:10:46-05:00 rts: enforce POSIX numeric locale for heap profiles - - - - - 34c7d230 by Sylvain Henry at 2020-02-29T05:11:27-05:00 Fix Hadrian's ``--configure`` (fix #17883) - - - - - 04d30137 by Ömer Sinan Ağacan at 2020-02-29T05:12:06-05:00 Simplify IfaceIdInfo type IfaceIdInfo type is confusing: there's practically no difference between `NoInfo` and `HasInfo []`. The comments say NoInfo is used when -fomit-interface-pragmas is enabled, but we don't need to distinguish `NoInfo` from `HasInfo []` in when reading the interface so the distinction is not important. This patch simplifies the type by removing NoInfo. When we have no info we use an empty list. With this change we no longer read the info list lazily when reading an IfaceInfoItem, but when reading an IfaceId the ifIdInfo field is read lazily, so I doubt this is going to be a problem. - - - - - 3979485b by Roland Senn at 2020-02-29T17:36:59+01:00 Show breakpoint locations of breakpoints which were ignored during :force (#2950) GHCi is split up into 2 major parts: The user-interface (UI) and the byte-code interpreter. With `-fexternal-interpreter` they even run in different processes. Communication between the UI and the Interpreter (called `iserv`) is done using messages over a pipe. This is called `Remote GHCI` and explained in the Note [Remote GHCi] in `compiler/ghci/GHCi.hs`. To process a `:force` command the UI sends a `Seq` message to the `iserv` process. Then `iserv` does the effective evaluation of the value. When during this process a breakpoint is hit, the `iserv` process has no additional information to enhance the `Ignoring breakpoint` output with the breakpoint location. To be able to print additional breakpoint information, there are 2 possible implementation choices: 1. Store the needed information in the `iserv` process. 2. Print the `Ignoring breakpoint` from the UI process. For option 1 we need to store the breakpoint info redundantely in 2 places and this is bad. Therfore option 2 was implemented in this MR: - The user enters a `force` command - The UI sends a `Seq` message to the `iserv` process. - If processing of the `Seq` message hits a breakpoint, the `iserv` process returns control to the UI process. - The UI looks up the source location of the breakpoint, and prints the enhanced `Ignoring breakpoint` output. - The UI sends a `ResumeSeq` message to the `iserv` process, to continue forcing. - - - - - 3cf7303b by Krzysztof Gogolewski at 2020-03-02T01:18:33-05:00 Remove dead code * The names in PrelName and THNames are no longer used since TH merged types and kinds, Typeable is kind-polymorphic, .net support was removed * unqualQuasiQuote no longer used since 6f8ff0bbad3b9fa3 - - - - - dbea7e9d by Ilias Tsitsimpis at 2020-03-02T01:19:12-05:00 Do not define hs_atomic{read,write}64() on non-64bit Do not define hs_atomicread64() and hs_atomicwrite64() on machines where WORD_SIZE_IN_BITS is less than 64, just like we do with the rest of the atomic functions which work on 64-bit values. Without this, compilation fails on MIPSel and PowerPC with the following error: /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicread64': atomic.c:(.text.hs_atomicread64+0x8): undefined reference to `__sync_add_and_fetch_8' /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicwrite64': atomic.c:(.text.hs_atomicwrite64+0x38): undefined reference to `__sync_bool_compare_and_swap_8' Fixes #17886. - - - - - 7c0c76fb by Roland Senn at 2020-03-02T17:13:55-05:00 Set `ImpredicativeTypes` during :print command. (#14828) If ImpredicativeTypes is not enabled, then `:print <term>` will fail if the type of <term> has nested `forall`s or `=>`s. This is because the GHCi debugger's internals will attempt to unify a metavariable with the type of <term> and then display the result, but if the type has nested `forall`s or `=>`s, then unification will fail. As a result, `:print` will bail out and the unhelpful result will be `<term> = (_t1::t1)` (where `t1` is a metavariable). Beware: <term> can have nested `forall`s even if its definition doesn't use RankNTypes! Here is an example from #14828: class Functor f where fmap :: (a -> b) -> f a -> f b Somewhat surprisingly, `:print fmap` considers the type of fmap to have nested foralls. This is because the GHCi debugger sees the type `fmap :: forall f. Functor f => forall a b. (a -> b) -> f a -> f b`. We could envision deeply instantiating this type to get the type `forall f a b. Functor f => (a -> b) -> f a -> f b`, but this trick wouldn't work for higher-rank types. Instead, we adopt a simpler fix: enable `ImpredicativeTypes` when using `:print` and friends in the GHCi debugger. This is allows metavariables to unify with types that have nested (or higher-rank) `forall`s/`=>`s, which makes `:print fmap` display as `fmap = (_t1::forall a b. Functor f => (a -> b) -> f a -> f b)`, as expected. Although ImpredicativeTypes is a somewhat unpredictable from a type inference perspective, there is no danger in using it in the GHCi debugger, since all of the terms that the GHCi debugger deals with have already been typechecked. - - - - - 2a2f51d7 by Sylvain Henry at 2020-03-02T17:14:38-05:00 Use configure script to detect that we should use in-tree GMP on Windows - - - - - 8c663c2c by Andreas Klebinger at 2020-03-04T16:12:14+01:00 Be explicit about how stack usage of mvar primops are covered. This fixes #17893 [skip-ci] - - - - - cedd6f30 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Add getCurrentThreadCPUTime helper - - - - - ace618cd by Ben Gamari at 2020-03-05T14:53:12-05:00 nonmoving-gc: Track time usage of nonmoving marking - - - - - 022b5ad5 by Ben Gamari at 2020-03-05T14:53:12-05:00 Stats: Add sync pauses to +RTS -S output - - - - - 06763234 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Report nonmoving collector statistics in machine-readable output - - - - - 70d2b995 by Ben Gamari at 2020-03-09T06:10:52-04:00 nonmoving: Fix collection of sparks Previously sparks living in the non-moving heap would be promptly GC'd by the minor collector since pruneSparkQueue uses the BF_EVACUATED flag, which non-moving heap blocks do not have set. Fix this by implementing proper support in pruneSparkQueue for determining reachability in the non-moving heap. The story is told in Note [Spark management in the nonmoving heap]. - - - - - 9668781a by Ben Gamari at 2020-03-09T06:11:30-04:00 gitlab-ci: Disable Sphinx documentation in Alpine build - - - - - 8eb2c263 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 Fix Windows breakage by not touching locales on Windows - - - - - b8dab057 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: ensure C numerics in heap profiles using Windows locales if needed - - - - - 7d95260f by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: refactor and comment profile locales - - - - - 5b627813 by Ryan Scott at 2020-03-09T16:34:14-04:00 Use InstanceSigs in GND/DerivingVia-generated code (#17899) Aside from making the generated code easier to read when `-ddump-deriv` is enabled, this makes the error message in `T15073` substantially simpler (see the updated `T15073` expected stderr). Fixes #17899. - - - - - 70b50778 by Ben Gamari at 2020-03-10T02:05:42-04:00 SysTools: Ensure that error parser can handle absolute paths on Windows This fixes #17786, where the error parser fails to correctly handle the drive name in absolute Windows paths. Unfortunately I couldn't find a satisfactory way to test this. - - - - - 85b861d8 by Ben Gamari at 2020-03-10T02:05:42-04:00 testsuite: Add test for #17786 This isn't pretty but it's perhaps better than nothing. - - - - - ee2c50cb by Sylvain Henry at 2020-03-10T02:06:33-04:00 Hadrian: track missing configure results - - - - - ca8f51d4 by Ömer Sinan Ağacan at 2020-03-10T02:07:22-04:00 Add regression test for T17904 Closes #17904 - - - - - 5fa9cb82 by Richard Eisenberg at 2020-03-10T12:29:46-04:00 anyRewritableTyVar now looks in RuntimeReps Previously, anyRewritableTyVar looked only at the arg and res of `arg -> res`, but their RuntimeReps are also subject to rewriting. Easy to fix. Test case: typecheck/should_compile/T17024 Fixes #17024. - - - - - 5ba01d83 by Ben Price at 2020-03-10T12:30:27-04:00 Clarify a Lint message When developing a plugin I had a shadowing problem, where I generated code app = \f{v r7B} x{v r7B} -> f{v r7B} x{v r7B} This is obviously wrong, since the occurrence of `f` to the right of the arrow refers to the `x` binder (they share a Unique). However, it is rather confusing when Lint reports Mismatch in type between binder and occurrence Var: x{v rB7} since it is printing the binder, rather than the occurrence. It is rather easy to read this as claiming there is something wrong with the `x` occurrence! We change the report to explicitly print both the binder and the occurrence variables. - - - - - 7b2c827b by Simon Peyton Jones at 2020-03-10T12:31:15-04:00 Comments only Clarify code added in #17852 and MR !2724 - - - - - 3300eeac by Krzysztof Gogolewski at 2020-03-10T12:31:54-04:00 Misc cleanup - Remove Note [Existentials in shift_con_pat]. The function shift_con_pat has been removed 15 years ago in 23f40f0e9be6d4. - Remove kcLookupTcTyCon - it's the same as tcLookupTcTyCon - Remove ASSERT in tyConAppArgN. It's already done by getNth, and it's the only reason getNth exists. - Remove unused function nextRole - - - - - abf5736b by Krzysztof Gogolewski at 2020-03-10T18:05:01+01:00 Typos in comments [skip ci] - - - - - bb586f89 by Ben Gamari at 2020-03-11T00:14:59-04:00 rts: Prefer darwin-specific getCurrentThreadCPUTime macOS Catalina now supports a non-POSIX-compliant version of clock_gettime which cannot use the clock_gettime codepath. Fixes #17906. - - - - - 20800b9a by Sylvain Henry at 2020-03-11T08:17:19-04:00 Split GHC.Iface.Utils module * GHC.Iface.Recomp: recompilation avoidance stuff * GHC.Iface.Make: mkIface* Moved `writeIfaceFile` into GHC.Iface.Load alongside `readIface` and renamed it `writeIface` for consistency. - - - - - 1daa2029 by Greg Steuck at 2020-03-11T08:17:56-04:00 Fixed a minor typo in codegen.rst - - - - - 0bc23338 by Ryan Scott at 2020-03-11T08:18:32-04:00 Re-quantify when generalising over rewrite rule types Previously, `tcRules` would check for naughty quantification candidates (see `Note [Naughty quantification candidates]` in `TcMType`) when generalising over the type of a rewrite rule. This caused sensible-looking rewrite rules (like those in #17710) to be rejected. A more permissing (and easier-to-implement) approach is to do what is described in `Note [Generalising in tcTyFamInstEqnGuts]` in `TcTyClsDecls`: just re-quantify all the type variable binders, regardless of the order in which the user specified them. After all, the notion of type variable specificity has no real meaning in rewrite rules, since one cannot "visibly apply" a rewrite rule. I have written up this wisdom in `Note [Re-quantify type variables in rules]` in `TcRules`. As a result of this patch, compiling the `ExplicitForAllRules1` test case now generates one fewer warning than it used to. As far as I can tell, this is benign, since the thing that the disappearing warning talked about was also mentioned in an entirely separate warning. Fixes #17710. - - - - - 336eac7e by Ben Gamari at 2020-03-11T08:19:08-04:00 testsuite: Mark ghci056 and ghcilink004 as fragile in unreg As noted in #17018. Also fix fragile declaration of T13786, which only runs in the normal way. - - - - - c61b9b02 by Simon Peyton Jones at 2020-03-11T08:19:44-04:00 Deepen call stack for isIn I see quite a few warnings like: WARNING: file compiler/utils/Util.hs, line 593 Over-long elem in unionLists But the call stack is uninformative. Better to add HasDebugCallStack to isIn. Ditto isn'tIn. - - - - - 3aa9b35f by Ömer Sinan Ağacan at 2020-03-11T08:20:27-04:00 Zero any slop after compaction in compacting GC In copying GC, with the relevant debug flags enabled, we release the old blocks after a GC, and the block allocator zeroes the space before releasing a block. This effectively zeros the old heap. In compacting GC we reuse the blocks and previously we didn't zero the unused space in a compacting generation after compaction. With this patch we zero the slop between the free pointer and the end of the block when we're done with compaction and when switching to a new block (because the current block doesn't have enough space for the next object we're shifting). - - - - - 8e6febce by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor GHC.Driver.Session (Ways and Flags) * extract flags and ways into their own modules (with some renaming) * remove one SOURCE import of GHC.Driver.Session from GHC.Driver.Phases * when GHC uses dynamic linking (WayDyn), `interpWays` was only reporting WayDyn even if the host was profiled (WayProf). Now it returns both as expected (might fix #16803). * `mkBuildTag :: [Way] -> String` wasn't reporting a canonical tag for differently ordered lists. Now we sort and nub the list to fix this. - - - - - bc41e471 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor interpreterDynamic and interpreterProfiled * `interpreterDynamic` and `interpreterProfiled` now take `Interp` parameters instead of DynFlags * slight refactoring of `ExternalInterp` so that we can read the iserv configuration (which is pure) without reading an MVar. - - - - - a6989971 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Use a Set to represent Ways Should make `member` queries faster and avoid messing up with missing `nubSort`. Metric Increase: hie002 - - - - - cb93a1a4 by Ryan Scott at 2020-03-11T20:34:14-04:00 Make DeriveFunctor-generated code require fewer beta reductions Issue #17880 demonstrates that `DeriveFunctor`-generated code is surprisingly fragile when rank-_n_ types are involved. The culprit is that `$fmap` (the algorithm used to generate `fmap` implementations) was too keen on applying arguments with rank-_n_ types to lambdas, which fail to typecheck more often than not. In this patch, I change `$fmap` (both the specification and the implementation) to produce code that avoids creating as many lambdas, avoiding problems when rank-_n_ field types arise. See the comments titled "Functor instances" in `TcGenFunctor` for a more detailed description. Not only does this fix #17880, but it also ensures that the code that `DeriveFunctor` generates will continue to work after simplified subsumption is implemented (see #17775). What is truly amazing is that #17880 is actually a regression (introduced in GHC 7.6.3) caused by commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e, the fix #7436. Prior to that commit, the version of `$fmap` that was used was almost identical to the one used in this patch! Why did that commit change `$fmap` then? It was to avoid severe performance issues that would arise for recursive `fmap` implementations, such as in the example below: ```hs data List a = Nil | Cons a (List a) deriving Functor -- ===> instance Functor List where fmap f Nil = Nil fmap f (Cons x xs) = Cons (f x) (fmap (\y -> f y) xs) ``` The fact that `\y -> f y` was eta expanded caused significant performance overheads. Commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e fixed this performance issue, but it went too far. As a result, this patch partially reverts 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e. To ensure that the performance issues pre-#7436 do not resurface, I have taken some precautionary measures: * I have added a special case to `$fmap` for situations where the last type variable in an application of some type occurs directly. If this special case fires, we avoid creating a lambda expression. This ensures that we generate `fmap f (Cons x xs) = Cons (f x) (fmap f xs)` in the derived `Functor List` instance above. For more details, see `Note [Avoid unnecessary eta expansion in derived fmap implementations]` in `TcGenFunctor`. * I have added a `T7436b` test case to ensure that the performance of this derived `Functor List`-style code does not regress. When implementing this, I discovered that `$replace`, the algorithm which generates implementations of `(<$)`, has a special case that is very similar to the `$fmap` special case described above. `$replace` marked this special case with a custom `Replacer` data type, which was a bit overkill. In order to use the same machinery for both `Functor` methods, I ripped out `Replacer` and instead implemented a simple way to detect the special case. See the updated commentary in `Note [Deriving <$]` for more details. - - - - - 1f9db3e7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Properly parenthesise LastStmt After ApplicatveDo strips the last `return` during renaming, the pretty printer has to restore it. However, if the return was followed by `$`, the dollar was stripped too and not restored. For example, the last stamement in: ``` foo = do x <- ... ... return $ f x ``` would be printed as: ``` return f x ``` This commit preserved the dolar, so it becomes: ``` return $ f x ``` - - - - - 5cb93af7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Do not print ApplicativeDo join * Do not print `join` in ApplictiveStmt, unless ppr-debug * Print parens around multiple parallel binds When ApplicativeDo is enabled, the renamer analyses the statements of a `do` block and in certain cases marks them as needing to be rewritten using `join`. For example, if you have: ``` foo = do a <- e1 b <- e2 doSomething a b ``` it will be desugared into: ``` foo = join (doSomething <$> e1 <*> e2) ``` After renaming but before desugaring the expression is stored essentially as: ``` foo = do [will need join] (a <- e1 | b <- e2) [no return] doSomething a b ``` Before this change, the pretty printer would print a call to `join`, even though it is not needed at this stage at all. The expression will be actually rewritten into one using join only at desugaring, at which point a literal call to join will be inserted. - - - - - 3a259092 by Simon Peyton Jones at 2020-03-12T09:46:29-04:00 Expose compulsory unfoldings always The unsafeCoerce# patch requires that unsafeCoerce# has a compulsory unfolding that is always available. So we have to be careful to expose compulsory unfoldings unconditionally and consistently. We didn't get this quite right: #17871. This patch fixes it. No real surprises here. See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy - - - - - 6a65b8c2 by Alp Mestanogullari at 2020-03-13T02:29:20-04:00 hadrian: improve dependency tracking for the check-* programs The code in Rules.Register responsible for finding all the build artifacts that Cabal installs when registering a library (static/shared libs, .hi files, ...) was looking in the wrong place. This patch fixes that logic and makes sure we gather all those artifacts in a list to declare that the rule for a given `.conf` file, our proxy for "Hadrian, please install this package in the package db for this stage", also produces those artifacts under the said package database. We also were completely missing some logic to declare that the check-* programs have dependencies besides their source code, at least when testing an in-tree compiler. Finally, this patch also removes redundant packages from 'testsuitePackages', since they should already be covered by the stage<N>Packages lists from Settings.Default. With this patch, after a complete build and freezing stage 1, a change to `compiler/parser/Parser.y` results in rebuilding the ghc lib, reinstalling it, and rebuilding the few programs that depend on it, _including_ `check-ppr` and `check-api-annotations` (therefore fixing #17273). - - - - - 44fad4a9 by Sylvain Henry at 2020-03-13T02:30:22-04:00 Rename isDllName I wanted to fix the dangling comment in `isDllName` ("This is the cause of #", #8696 is already mentioned earlier). I took the opportunity to change the function name to better reflect what it does. - - - - - 2f292db8 by Paavo at 2020-03-13T02:31:03-04:00 Update documentation for closureSize - - - - - f124ff0d by Ben Gamari at 2020-03-13T02:31:40-04:00 gitlab-ci: Rework triggering of release builds Use a push option instead of tagging. - - - - - 7f25557a by Ben Gamari at 2020-03-13T10:38:09-04:00 gitlab-ci: Distinguish integer-simple test envs Previously two integer-simple jobs declared the same test environment. One (the nightly job) was built in the perf way, the other in the validate way. Consequently they had appreciably different performance characteristics, causing in the nightly job to spuriously fail with performance changes. - - - - - c12a2ec5 by Simon Peyton Jones at 2020-03-14T05:25:30-04:00 Fix Lint Ticket #17590 pointed out a bug in the way the linter dealt with type lets, exposed by the new uniqAway story. The fix is described in Note [Linting type lets]. I ended up putting the in-scope Ids in a different env field, le_ids, rather than (as before) sneaking them into the TCvSubst. Surprisingly tiresome, but done. Metric Decrease: hie002 - - - - - b989845e by Sylvain Henry at 2020-03-14T05:26:11-04:00 Hadrian: fix absolute buildroot support (#17822) Shake's "**" wildcard doesn't match absolute root. We must use "//" instead. - - - - - 4f117135 by Sylvain Henry at 2020-03-14T05:26:49-04:00 Make: refactor GMP rules Document and use simpler rules for the ghc-gmp.h header. - - - - - 7432b327 by Sylvain Henry at 2020-03-14T05:27:28-04:00 Use correct option name (-opti) (fix #17314) s/pgmo/opti - - - - - 8f7dd571 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Allow overriding LD_STAGE0 and AR_STAGE0 in the configure script. Previously it was possible to override the stage0 C compiler via `CC_STAGE0`, but you couldn't override `ld` or `ar` in stage0. This change allows overriding them by setting `LD_STAGE0` or `AR_STAGE0`, respectively. Our team uses this feature internally to take more control of our GHC build and make it run more hermetically. - - - - - 7c3e39a9 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Use AC_ARG_VAR for LD_STAGE0 and AR_STAGE0. - - - - - 20d4d676 by Ben Gamari at 2020-03-14T05:28:43-04:00 nonmoving: Don't traverse filled segment list in pause The non-moving collector would previously walk the entire filled segment list during the preparatory pause. However, this is far more work than is strictly necessary. We can rather get away with merely collecting the allocators' filled segment list heads and process the lists themselves during the concurrent phase. This can significantly reduce the maximum gen1 GC pause time in programs with high rates of long-lived allocations. - - - - - fdfa2d01 by Ben Gamari at 2020-03-14T05:29:18-04:00 nonmoving: Remove redundant bitmap clearing nonmovingSweep already clears the bitmap in the sweep loop. There is no reason to do so a second time. - - - - - 2f8c7767 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Simple refactor of cheapEqExpr No change in functionality. Just seems tidier (and signficantly more efficient) to deal with ticks directly than to call stripTicksTopE. - - - - - 88f7a762 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Improve CSE.combineAlts This patch improves the way that CSE combines identical alternatives. See #17901. I'm still not happy about the duplication between CSE.combineAlts and GHC.Core.Utils.combineIdenticalAlts; see the Notes with those functions. But this patch is a step forward. Metric Decrease: T12425 T5642 - - - - - 8b95ddd3 by Ben Gamari at 2020-03-14T05:30:31-04:00 gitlab-ci: Add integer-simple release build for Windows Closes #16144. - - - - - e3c374cc by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Wrap an implication around class-sig kind errors Ticket #17841 showed that we can get a kind error in a class signature, but lack an enclosing implication that binds its skolems. This patch * Adds the wrapping implication: the new call to checkTvConstraints in tcClassDecl1 * Simplifies the API to checkTvConstraints, which was not otherwise called at all. * Simplifies TcErrors.report_unsolved by *not* initialising the TidyEnv from the typechecker lexical envt. It's enough to do so from the free vars of the unsolved constraints; and we get silly renamings if we add variables twice: once from the lexical scope and once from the implication constraint. - - - - - 73133a3b by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Refactoring in TcSMonad This patch is just refactoring: no change in behaviour. I removed the rather complicated checkConstraintsTcS checkTvConstraintsTcS in favour of simpler functions emitImplicationTcS emitTvImplicationTcS pushLevelNoWorkList The last of these is a little strange, but overall it's much better I think. - - - - - 93c88c26 by Ben Gamari at 2020-03-14T05:31:42-04:00 base: Make `open` calls interruptible As noted in #17912, `open` system calls were `safe` rather than `interruptible`. Consequently, the program could not be interrupted with SIGINT if stuck in a slow open operation. Fix this by marking `c_safe_open` as interruptible. - - - - - bee4cdad by Vladislav Zavialov at 2020-03-14T05:32:18-04:00 Remove second tcLookupTcTyCon in tcDataDefn Before this patch, tcDataDefn used to call tcLookupTcTyCon twice in a row: 1. in bindTyClTyVars itself 2. in the continuation passed to it Now bindTyClTyVars passes the TcTyCon to the continuation, making the second lookup unnecessary. - - - - - 3f116d35 by Cale Gibbard at 2020-03-14T19:34:42-04:00 Enable stage1 build of haddock The submodule has already been bumped to contain the fix. - - - - - 49e9d739 by Ömer Sinan Ağacan at 2020-03-14T19:35:24-04:00 rts: Fix printClosure when printing fwd ptrs - - - - - 1de3ab4a by Krzysztof Gogolewski at 2020-03-14T19:36:04-04:00 Remove unused field var_inline (#17915) - - - - - d30aeb4b by Krzysztof Gogolewski at 2020-03-15T03:57:41-04:00 Document restriction on SCC pragma syntax Currently, the names of cost centres must be quoted or be lowercase identifiers. Fixes #17916. - - - - - b4774598 by Brian Foley at 2020-03-15T03:58:18-04:00 Remove some dead code >From the notes.ghc.drop list found using weeder in #17713 - - - - - dd6ffe6b by Viktor Dukhovni at 2020-03-15T03:58:55-04:00 Note platform-specific Foreign.C.Types in context Also fix the markup in the general note at the top of the module. Haddock (usability trade-off), does not support multi-line emphasised text. - - - - - 2e82465f by Sylvain Henry at 2020-03-15T10:57:10-04:00 Refactor CmmToAsm (disentangle DynFlags) This patch disentangles a bit more DynFlags from the native code generator (CmmToAsm). In more details: - add a new NCGConfig datatype in GHC.CmmToAsm.Config which contains the configuration of a native code generation session - explicitly pass NCGConfig/Platform arguments when necessary - as a consequence `sdocWithPlatform` is gone and there are only a few `sdocWithDynFlags` left - remove the use of `unsafeGlobalDynFlags` from GHC.CmmToAsm.CFG - remove `sdocDebugLevel` (now we pass the debug level via NCGConfig) There are still some places where DynFlags is used, especially because of pretty-printing (CLabel), because of Cmm helpers (such as `cmmExprType`) and because of `Outputable` instance for the instructions. These are left for future refactoring as this patch is already big. - - - - - c35c545d by Judah Jacobson at 2020-03-15T10:57:48-04:00 Add a -no-haddock flag. This flag undoes the effect of a previous "-haddock" flag. Having both flags makes it easier for build systems to enable Haddock parsing in a set of global flags, but then disable it locally for specific targets (e.g., third-party packages whose comments don't pass the validation in the latest GHC). I added the flag to expected-undocumented-flags.txt since `-haddock` was alreadyin that list. - - - - - cfcc3c9a by Ömer Sinan Ağacan at 2020-03-15T10:58:27-04:00 Fix global_link of TSOs for threads reachable via dead weaks Fixes #17785 Here's how the problem occurs: - In generation 0 we have a TSO that is finished (i.e. it has no more work to do or it is killed). - The TSO only becomes reachable after collectDeadWeakPtrs(). - After collectDeadWeakPtrs() we switch to WeakDone phase where we don't move TSOs to different lists anymore (like the next gen's thread list or the resurrected_threads list). - So the TSO will never be moved to a generation's thread list, but it will be promoted to generation 1. - Generation 1 collected via mark-compact, and because the TSO is reachable it is marked, and its `global_link` field, which is bogus at this point (because the TSO is not in a list), will be threaded. - Chaos ensues. In other words, when these conditions hold: - A TSO is reachable only after collectDeadWeakPtrs() - It's finished (what_next is ThreadComplete or ThreadKilled) - It's retained by mark-compact collector (moving collector doesn't evacuate the global_list field) We end up doing random mutations on the heap because the TSO's global_list field is not valid, but it still looks like a heap pointer so we thread it during compacting GC. The fix is simple: when we traverse old_threads lists to resurrect unreachable threads the threads that won't be resurrected currently stays on the old_threads lists. Those threads will never be visited again by MarkWeak so we now reset the global_list fields. This way compacting GC does not thread pointers to nowhere. Testing ------- The reproducer in #17785 is quite large and hard to build, because of the dependencies, so I'm not adding a regression test. In my testing the reproducer would take a less than 5 seconds to run, and once in every ~5 runs would fail with a segfault or an assertion error. In other cases it also fails with a test failure. Because the tests never fail with the bug fix, assuming the code is correct, this also means that this bug can sometimes lead to incorrect runtime results. After the fix I was able to run the reproducer repeatedly for about an hour, with no runtime crashes or test failures. To run the reproducer clone the git repo: $ git clone https://github.com/osa1/streamly --branch ghc-segfault Then clone primitive and atomic-primops from their git repos and point to the clones in cabal.project.local. The project should then be buildable using GHC HEAD. Run the executable `properties` with `+RTS -c -DZ`. In addition to the reproducer above I run the test suite using: $ make slowtest EXTRA_HC_OPTS="-debug -with-rtsopts=-DS \ -with-rtsopts=-c +RTS -c -RTS" SKIPWAY='nonmoving nonmoving_thr' This enables compacting GC always in both GHC when building the test programs and when running the test programs, and also enables sanity checking when running the test programs. These set of flags are not compatible for all tests so there are some failures, but I got the same set of failures with this patch compared to GHC HEAD. - - - - - 818b3c38 by Lysxia at 2020-03-16T23:52:42-04:00 base: add strict IO functions: readFile', getContents', hGetContents' - - - - - 18a346a4 by Sylvain Henry at 2020-03-16T23:53:24-04:00 Modules: Core (#13009) Update submodule: haddock - - - - - 92327e3a by Ömer Sinan Ağacan at 2020-03-16T23:54:04-04:00 Update sanity checking for TSOs: - Remove an invalid assumption about GC checking what_next field. The GC doesn't care about what_next at all, if a TSO is reachable then all its pointers are followed (other than global_tso, which is only followed by compacting GC). - Remove checkSTACK in checkTSO: TSO stacks will be visited in checkHeapChain, or checkLargeObjects etc. - Add an assertion in checkTSO to check that the global_link field is sane. - Did some refactor to remove forward decls in checkGlobalTSOList and added braces around single-statement if statements. - - - - - e1aa4052 by PHO at 2020-03-17T07:36:09-04:00 Don't use non-portable operator "==" in configure.ac The test operator "==" is a Bash extension and produces a wrong result if /bin/sh is not Bash. - - - - - 89f034dd by Maximilian Tagher at 2020-03-17T07:36:48-04:00 Document the units of -ddump-timings Right now, in the output of -ddump-timings to a file, you can't tell what the units are: ``` CodeGen [TemplateTestImports]: alloc=22454880 time=14.597 ``` I believe bytes/milliseconds are the correct units, but confirmation would be appreciated. I'm basing it off of this snippet from `withTiming'`: ``` when (verbosity dflags >= 2 && prtimings == PrintTimings) $ liftIO $ logInfo dflags (defaultUserStyle dflags) (text "!!!" <+> what <> colon <+> text "finished in" <+> doublePrec 2 time <+> text "milliseconds" <> comma <+> text "allocated" <+> doublePrec 3 (realToFrac alloc / 1024 / 1024) <+> text "megabytes") ``` which implies time is in milliseconds, and allocations in bytes (which divided by 1024 would be KB, and again would be MB) - - - - - beffa147 by Simon Peyton Jones at 2020-03-17T07:37:25-04:00 Implement mapTyCo like foldTyCo This patch makes mapType use the successful idiom described in TyCoRep Note [Specialising foldType] I have not yet changed any functions to use mapType, though there may be some suitable candidates. This patch should be a no-op in terms of functionality but, because it inlines the mapper itself, I'm hoping that there may be some modest perf improvements. Metric Decrease: T5631 T5642 T3064 T9020 T14683 hie002 haddock.Cabal haddock.base haddock.compiler - - - - - 5800ebfe by Ömer Sinan Ağacan at 2020-03-17T07:38:08-04:00 Don't update ModDetails with CafInfos when opts are disabled This is consistent with the interface file behavior where we omit HsNoCafRefs annotations with -fomit-interface-pragmas (implied by -O0). ModDetails and ModIface are just different representations of the same thing, so they really need to be in sync. This patch does the right thing and does not need too much explanation, but here's an example of a problem not doing this causes in !2842: -- MyInteger.hs module MyInteger ( MyInteger (MyInteger) , ToMyInteger (toMyInteger) ) where newtype MyInteger = MyInteger Integer class ToMyInteger a where toMyInteger :: a -> MyInteger instance ToMyInteger Integer where toMyInteger = MyInteger {- . succ -} -- Main.hs module Main ( main ) where import MyInteger (MyInteger (MyInteger), toMyInteger) main :: IO () main = do let (MyInteger i) = (id . toMyInteger) (41 :: Integer) print i If I build this with -O0, without this fix, we generate a ModDetails with accurate LFInfo for toMyInteger (MyInteger.$fToMyIntegerInteger) which says that it's a LFReEntrant with arity 1. This means in the use site (Main) we tag the value: R3 = MyInteger.$fToMyIntegerInteger_closure + 1; R2 = GHC.Base.id_closure; R1 = GHC.Base.._closure; Sp = Sp - 16; call stg_ap_ppp_fast(R4, R3, R2, R1) args: 24, res: 0, upd: 24; Now we change the definition by uncommenting the `succ` part and it becomes a thunk: MyInteger.$fToMyIntegerInteger [InlPrag=INLINE (sat-args=0)] :: MyInteger.ToMyInteger GHC.Integer.Type.Integer [GblId[DFunId(nt)]] = {} \u [] $ctoMyInteger_rEA; and its LFInfo is now LFThunk. This change in LFInfo makes a difference in the use site: we can no longer tag it. But becuase the interface fingerprint does not change (because ModIface does not change) we don't rebuild Main and tag the thunk. (1.2% increase in allocations when building T12545 on armv7 because we generate more code without CafInfos) Metric Increase: T12545 - - - - - 5b632dad by Paavo at 2020-03-17T07:38:48-04:00 Add example for Data.Semigroup.diff - - - - - 4d85d68b by Paavo at 2020-03-17T07:38:48-04:00 Clean up - - - - - 75168d07 by Paavo at 2020-03-17T07:38:48-04:00 Make example collapsible - - - - - 53ff2cd0 by Richard Eisenberg at 2020-03-17T13:46:57+00:00 Fix #17021 by checking more return kinds All the details are in new Note [Datatype return kinds] in TcTyClsDecls. Test case: typecheck/should_fail/T17021{,b} typecheck/should_compile/T17021a Updates haddock submodule - - - - - 528df8ec by Sylvain Henry at 2020-03-18T10:06:43-04:00 Modules: Core operations (#13009) - - - - - 4e8a71c1 by Richard Eisenberg at 2020-03-18T10:07:19-04:00 Add release note about fix to #16502. We thought we needed to update the manual, but the fix for #16502 actually brings the implementation in line with the manual. So we just alert users of how to update their code. - - - - - 5cbf9934 by Andreas Klebinger at 2020-03-19T00:39:27-04:00 Update "GHC differences to the FFI Chapter" in user guide. The old entry had a heavy focus on how things had been. Which is not what I generally look for in a user guide. I also added a small section on behaviour of nested safe ffi calls. [skip-ci] - - - - - b03fd3bc by Sebastian Graf at 2020-03-19T00:40:06-04:00 PmCheck: Use ConLikeSet to model negative info In #17911, Simon recognised many warnings stemming from over-long list unions while coverage checking Cabal's `LicenseId` module. This patch introduces a new `PmAltConSet` type which uses a `UniqDSet` instead of an association list for `ConLike`s. For `PmLit`s, it will still use an assocation list, though, because a similar map data structure would entail a lot of busy work. Fixes #17911. - - - - - 64f20756 by Sylvain Henry at 2020-03-19T12:16:49-04:00 Refactoring: use Platform instead of DynFlags when possible Metric Decrease: ManyConstructors T12707 T13035 T1969 - - - - - cb1785d9 by Ömer Sinan Ağacan at 2020-03-19T12:16:54-04:00 FastString: fix eager reading of string ptr in hashStr This read causes NULL dereferencing when len is 0. Fixes #17909 In the reproducer in #17909 this bug is triggered as follows: - SimplOpt.dealWithStringLiteral is called with a single-char string ("=" in #17909) - tailFS gets called on the FastString of the single-char string. - tailFS checks the length of the string, which is 1, and calls mkFastStringByteString on the tail of the ByteString, which is an empty ByteString as the original ByteString has only one char. - ByteString's unsafeUseAsCStringLen returns (NULL, 0) for the empty ByteString, which is passed to mkFastStringWith. - mkFastStringWith gets hash of the NULL pointer via hashStr, which fails on empty strings because of this bug. - - - - - 73a7383e by Richard Eisenberg at 2020-03-20T20:42:56-04:00 Simplify treatment of heterogeneous equality Previously, if we had a [W] (a :: k1) ~ (rhs :: k2), we would spit out a [D] k1 ~ k2 and part the W as irreducible, hoping for a unification. But we needn't do this. Instead, we now spit out a [W] co :: k2 ~ k1 and then use co to cast the rhs of the original Wanted. This means that we retain the connection between the spat-out constraint and the original. The problem with this new approach is that we cannot use the casted equality for substitution; it's too like wanteds-rewriting- wanteds. So, we forbid CTyEqCans that mention coercion holes. All the details are in Note [Equalities with incompatible kinds] in TcCanonical. There are a few knock-on effects, documented where they occur. While debugging an error in this patch, Simon and I ran into infelicities in how patterns and matches are printed; we made small improvements. This patch includes mitigations for #17828, which causes spurious pattern-match warnings. When #17828 is fixed, these lines should be removed. - - - - - faa36e5b by Sylvain Henry at 2020-03-20T20:43:41-04:00 Hadrian: ignore in-tree GMP objects with ``--lint`` - - - - - 9a96ff6b by Richard Eisenberg at 2020-03-20T20:44:17-04:00 Update core spec to reflect changes to Core. Key changes: * Adds a new rule for forall-coercions over coercion variables, which was implemented but conspicuously missing from the spec. * Adds treatment for FunCo. * Adds treatment for ForAllTy over coercion variables. * Improves commentary (including restoring a Note lost in 03d4852658e1b7407abb4da84b1b03bfa6f6db3b) in the source. No changes to running code. - - - - - 7e0451c6 by Sergej Jaskiewicz at 2020-03-20T20:44:55-04:00 Fix event message in withTiming' This typo caused generating 'end' events without the corresponding 'begin' events. - - - - - 1542a626 by Ben Gamari at 2020-03-22T22:37:47-04:00 fs.h: Add missing declarations on Windows - - - - - 3bcf2ccd by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump process submodule Avoids redundant case alternative warning. - - - - - 3b363ef9 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Normalize slashes in ghc-api annotations output Enable `normalise_slashes` on `annotations`, `listcomps`, and `parseTree` to fix Windows failures. - - - - - 25fc9429 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - 7f58ec6d by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Fix TOP of T17786 - - - - - aadcd909 by GHC GitLab CI at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - dc1eb10d by GHC GitLab CI at 2020-03-22T22:37:47-04:00 hadrian: Fix executable extension passed to testsuite driver - - - - - 58f62e2c by GHC GitLab CI at 2020-03-22T22:37:47-04:00 gitlab-ci: Require that Windows-hadrian job passes - - - - - 8dd2415d by Ben Gamari at 2020-03-22T22:37:47-04:00 hadrian: Eliminate redundant .exe from GHC path Previously we were invoking: bash -c "c:/GitLabRunner/builds/eEQrxK4p/0/ghc/ghc/toolchain/bin/ghc.exe.exe testsuite/mk/ghc-config.hs -o _build/test/bin/ghc-config.exe" - - - - - 373621f6 by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump hsc2hs submodule - - - - - abc02b40 by Hécate at 2020-03-22T22:38:33-04:00 Annotate the non-total function in Data.Foldable as such - - - - - 19f12557 by Josef Svenningsson at 2020-03-23T14:05:33-04:00 Fix ApplicativeDo regression #17835 A previous fix for #15344 made sure that monadic 'fail' is used properly when translating ApplicativeDo. However, it didn't properly account for when a 'fail' will be inserted which resulted in some programs failing with a type error. - - - - - 2643ba46 by Paavo at 2020-03-24T08:31:32-04:00 Add example and doc for Arg (Fixes #17153) - - - - - 703221f4 by Roland Senn at 2020-03-25T14:45:04-04:00 Use export list of Main module in function TcRnDriver.hs:check_main (Fix #16453) - Provide the export list of the `Main` module as parameter to the `compiler/typecheck/TcRnDriver.hs:check_main` function. - Instead of `lookupOccRn_maybe` call the function `lookupInfoOccRn`. It returns the list `mains_all` of all the main functions in scope. - Select from this list `mains_all` all `main` functions that are in the export list of the `Main` module. - If this new list contains exactly one single `main` function, then typechecking continues. - Otherwise issue an appropriate error message. - - - - - 3e27205a by Sebastian Graf at 2020-03-25T14:45:40-04:00 Remove -fkill-absence and -fkill-one-shot flags They seem to be a benchmarking vestige of the Cardinality paper and probably shouldn't have been merged to HEAD in the first place. - - - - - 262e42aa by Peter Trommler at 2020-03-25T22:41:39-04:00 Do not panic on linker errors - - - - - 0de03cd7 by Sylvain Henry at 2020-03-25T22:42:02-04:00 DynFlags refactoring III Use Platform instead of DynFlags when possible: * `tARGET_MIN_INT` et al. replaced with `platformMinInt` et al. * no more DynFlags in PreRules: added a new `RuleOpts` datatype * don't use `wORD_SIZE` in the compiler * make `wordAlignment` use `Platform` * make `dOUBLE_SIZE` a constant Metric Decrease: T13035 T1969 - - - - - 7a04920b by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: fix a typo in liftA doc This change removes an extra '|' that should not be rendered in the liftA documentation. Tracking: #17929 - - - - - 1c5a15f7 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add Control.Applicative optional example This change adds an optional example. Tracking: #17929 - - - - - 6d172e63 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add markup around Except - - - - - eb2162c8 by John Ericson at 2020-03-26T12:37:08-04:00 Remove unused `ghciTablesNextToCode` from compiler proper - - - - - f51efc4b by Joachim Breitner at 2020-03-26T12:37:09-04:00 Prepare to use run-time tablesNextToCode in compiler exclusively Factor out CPP as much as possible to prepare for runtime determinattion. Progress towards #15548 - - - - - 1c446220 by Joachim Breitner at 2020-03-26T12:37:09-04:00 Use run-time tablesNextToCode in compiler exclusively (#15548) Summary: - There is no more use of the TABLES_NEXT_TO_CODE CPP macro in `compiler/`. GHCI_TABLES_NEXT_TO_CODE is also removed entirely. The field within `PlatformMisc` within `DynFlags` is used instead. - The field is still not exposed as a CLI flag. We might consider some way to ensure the right RTS / libraries are used before doing that. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082 - - - - - 1941ef4f by Sylvain Henry at 2020-03-29T17:28:51-04:00 Modules: Types (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - 1c7c6f1a by Sylvain Henry at 2020-03-29T17:28:51-04:00 Remove GHC.Types.Unique.Map module This module isn't used anywhere in GHC. - - - - - f1a6c73d by Sylvain Henry at 2020-03-29T17:28:51-04:00 Merge GHC.Types.CostCentre.Init into GHC.Driver.CodeOutput - - - - - 54250f2d by Simon Peyton Jones at 2020-03-29T17:29:30-04:00 Demand analysis: simplify the demand for a RHS Ticket #17932 showed that we were using a stupid demand for the RHS of a let-binding, when the result is a product. This was the result of a "fix" in 2013, which (happily) turns out to no longer be necessary. So I just deleted the code, which simplifies the demand analyser, and fixes #17932. That in turn uncovered that the anticipation of worker/wrapper in CPR analysis was inaccurate, hence the logic that decides whether to unbox an argument in WW was extracted into a function `wantToUnbox`, now consulted by CPR analysis. I tried nofib, and got 0.0% perf changes. All this came up when messing about with !2873 (ticket #17917), but is idependent of it. Unfortunately, this patch regresses #4267 and realised that it is now blocked on #16335. - - - - - 03060b2f by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 on Windows Fixes line ending normalization issue. - - - - - 1f7995ba by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 Fix missing quoting and expected exit code. - - - - - ef9c608e by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - e54500c1 by Sylvain Henry at 2020-03-29T17:30:47-04:00 Store ComponentId details As far as GHC is concerned, installed package components ("units") are identified by an opaque ComponentId string provided by Cabal. But we don't want to display it to users (as it contains a hash) so GHC queries the database to retrieve some infos about the original source package (name, version, component name). This patch caches these infos in the ComponentId itself so that we don't need to provide DynFlags (which contains installed package informations) to print a ComponentId. In the future we want GHC to support several independent package states (e.g. for plugins and for target code), hence we need to avoid implicitly querying a single global package state. - - - - - 7e7cb714 by Marius Bakke at 2020-03-29T17:31:27-04:00 testsuite: Remove test that dlopens a PIE object. glibc 2.30 disallowed dlopening PIE objects, so just remove the test. Fixes #17952. - - - - - 6c8f80d8 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Correct haddocks for testBit in Data.Bits It conflated the nth bit with the bit at offset n. Now we instead give the definition in terms of `bit and `.&.` on top of clearer phrasing. - - - - - c916f190 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Apply suggestion to libraries/base/Data/Bits.hs - - - - - 64bf7f51 by Ben Gamari at 2020-03-29T17:32:41-04:00 gitlab-ci: Add FreeBSD release job - - - - - a0d8e92e by Ryan Scott at 2020-03-29T17:33:20-04:00 Run checkNewDataCon before constraint-solving newtype constructors Within `checkValidDataCon`, we used to run `checkValidType` on the argument types of a newtype constructor before running `checkNewDataCon`, which ensures that the user does not attempt non-sensical things such as newtypes with multiple arguments or constraints. This works out in most situations, but this falls over on a corner case revealed in #17955: ```hs newtype T = Coercible () T => T () ``` `checkValidType`, among other things, peforms an ambiguity check on the context of a data constructor, and that it turn invokes the constraint solver. It turns out that there is a special case in the constraint solver for representational equalities (read: `Coercible` constraints) that causes newtypes to be unwrapped (see `Note [Unwrap newtypes first]` in `TcCanonical`). This special case does not know how to cope with an ill formed newtype like `T`, so it ends up panicking. The solution is surprisingly simple: just invoke `checkNewDataCon` before `checkValidType` to ensure that the illicit newtype constructor context is detected before the constraint solver can run amok with it. Fixes #17955. - - - - - 45eb9d8c by Krzysztof Gogolewski at 2020-03-29T17:33:59-04:00 Minor cleanup - Simplify mkBuildExpr, the function newTyVars was called only on a one-element list. - TTG: use noExtCon in more places. This is more future-proof. - In zonkExpr, panic instead of printing a warning. - - - - - f024b6e3 by Sylvain Henry at 2020-03-30T12:48:39+02:00 Expect T4267 to pass Since 54250f2d8de910b094070c1b48f086030df634b1 we expected T4267 to fail, but it passes on CI. - - - - - 57b888c0 by Ryan Scott at 2020-03-31T10:54:20-04:00 Require GHC 8.8 as the minimum compiler for bootstrapping This allows us to remove several bits of CPP that are either always true or no longer reachable. As an added bonus, we no longer need to worry about importing `Control.Monad.Fail.fail` qualified to avoid clashing with `Control.Monad.fail`, since the latter is now the same as the former. - - - - - 33f09551 by Ryan Scott at 2020-03-31T10:54:57-04:00 Add regression test for #17963 The panic in #17963 happened to be fixed by commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70. This patch adds a regression test to ensure that it remains fixed. Fixes #17963. - - - - - 09a36e80 by Ömer Sinan Ağacan at 2020-03-31T10:55:37-04:00 Simplify stderrSupportsAnsiColors The combinator andM is used only once, and the code is shorter and simpler if you inline it. - - - - - 95bccdd0 by Ben Gamari at 2020-03-31T10:56:19-04:00 base: Ensure that encoding global variables aren't inlined As noted in #17970, these (e.g. `getFileSystemEncoding` and `setFileSystemEncoding`) previously had unfoldings, which would break their global-ness. While not strictly necessary, I also add a NOINLINE on `initLocaleEncoding` since it is used in `System.IO`, ensuring that we only system's query the locale encoding once. Fixes #17970. - - - - - 982aaa83 by Andreas Klebinger at 2020-03-31T10:56:55-04:00 Update hadrian index revision. Required in order to build hadrian using ghc-8.10 - - - - - 4b9c5864 by Ben Gamari at 2020-03-31T10:57:32-04:00 integer-gmp: Bump version and add changelog entry - - - - - 9b39f2e6 by Ryan Scott at 2020-04-01T01:20:00-04:00 Clean up "Eta reduction for data families" Notes Before, there were two distinct Notes named "Eta reduction for data families". This renames one of them to "Implementing eta reduction for data families" to disambiguate the two and fixes references in other parts of the codebase to ensure that they are pointing to the right place. Fixes #17313. [ci skip] - - - - - 7627eab5 by Ryan Scott at 2020-04-01T01:20:38-04:00 Fix the changelog/@since information for hGetContents'/getContents'/readFile' Fixes #17979. [ci skip] - - - - - 0002db1b by Sylvain Henry at 2020-04-01T01:21:27-04:00 Kill wORDS_BIGENDIAN and replace it with platformByteOrder (#17957) Metric Decrease: T13035 T1969 - - - - - 7b217179 by Sebastian Graf at 2020-04-01T15:03:24-04:00 PmCheck: Adjust recursion depth for inhabitation test In #17977, we ran into the reduction depth limit of the typechecker. That was only a symptom of a much broader issue: The recursion depth of the coverage checker for trying to instantiate strict fields in the `nonVoid` test was far too high (100, the `defaultMaxTcBound`). As a result, we were performing quite poorly on `T17977`. Short of a proper termination analysis to prove emptyness of a type, we just arbitrarily default to a much lower recursion limit of 3. Fixes #17977. - - - - - 3c09f636 by Andreas Klebinger at 2020-04-01T15:03:59-04:00 Make hadrian pass on the no-colour setting to GHC. Fixes #17983. - - - - - b943b25d by Simon Peyton Jones at 2020-04-02T01:45:58-04:00 Re-engineer the binder-swap transformation The binder-swap transformation is implemented by the occurrence analyser -- see Note [Binder swap] in OccurAnal. However it had a very nasty corner in it, for the case where the case scrutinee was a GlobalId. This led to trouble and hacks, and ultimately to #16296. This patch re-engineers how the occurrence analyser implements the binder-swap, by actually carrying out a substitution rather than by adding a let-binding. It's all described in Note [The binder-swap substitution]. I did a few other things along the way * Fix a bug in StgCse, which could allow a loop breaker to be CSE'd away. See Note [Care with loop breakers] in StgCse. I think it can only show up if occurrence analyser sets up bad loop breakers, but still. * Better commenting in SimplUtils.prepareAlts * A little refactoring in CoreUnfold; nothing significant e.g. rename CoreUnfold.mkTopUnfolding to mkFinalUnfolding * Renamed CoreSyn.isFragileUnfolding to hasCoreUnfolding * Move mkRuleInfo to CoreFVs We observed respectively 4.6% and 5.9% allocation decreases for the following tests: Metric Decrease: T9961 haddock.base - - - - - 42d68364 by Sebastian Graf at 2020-04-02T01:46:34-04:00 Preserve precise exceptions in strictness analysis Fix #13380 and #17676 by 1. Changing `raiseIO#` to have `topDiv` instead of `botDiv` 2. Give it special treatment in `Simplifier.Util.mkArgInfo`, treating it as if it still had `botDiv`, to recover dead code elimination. This is the first commit of the plan outlined in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2525#note_260886. - - - - - 0a88dd11 by Ömer Sinan Ağacan at 2020-04-02T01:47:25-04:00 Fix a pointer format string in RTS - - - - - 5beac042 by Ömer Sinan Ağacan at 2020-04-02T01:48:05-04:00 Remove unused closure stg_IND_direct - - - - - 88f38b03 by Ben Gamari at 2020-04-02T01:48:42-04:00 Session: Memoize stderrSupportsAnsiColors Not only is this a reasonable efficiency measure but it avoids making reentrant calls into ncurses, which is not thread-safe. See #17922. - - - - - 27740f24 by Ryan Scott at 2020-04-02T01:49:21-04:00 Make Hadrian build with Cabal-3.2 GHC 8.10 ships with `Cabal-3.2.0.0`, so it would be convenient to make Hadrian supporting building against 3.2.* instead of having to rebuild the entirety of `Cabal-3.0.0.0`. There is one API change in `Cabal-3.2.*` that affects Hadrian: the `synopsis` and `description` functions now return `ShortText` instead of `String`. Since Hadrian manipulates these `String`s in various places, I found that the simplest fix was to use CPP to convert `ShortText` to `String`s where appropriate. - - - - - 49802002 by Sylvain Henry at 2020-04-02T01:50:00-04:00 Update Stack resolver for hadrian/build-stack Broken by 57b888c0e90be7189285a6b078c30b26d0923809 - - - - - 30a63e79 by Ryan Scott at 2020-04-02T01:50:36-04:00 Fix two ASSERT buglets in reifyDataCon Two `ASSERT`s in `reifyDataCon` were always using `arg_tys`, but `arg_tys` is not meaningful for GADT constructors. In fact, it's worse than non-meaningful, since using `arg_tys` when reifying a GADT constructor can lead to failed `ASSERT`ions, as #17305 demonstrates. This patch applies the simplest possible fix to the immediate problem. The `ASSERT`s now use `r_arg_tys` instead of `arg_tys`, as the former makes sure to give something meaningful for GADT constructors. This makes the panic go away at the very least. There is still an underlying issue with the way the internals of `reifyDataCon` work, as described in https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227023, but we leave that as future work, since fixing the underlying issue is much trickier (see https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227087). - - - - - ef7576c4 by Zubin Duggal at 2020-04-03T06:24:56-04:00 Add outputable instances for the types in GHC.Iface.Ext.Types, add -ddump-hie flag to dump pretty printed contents of the .hie file Metric Increase: hie002 Because of the regression on i386: compile_time/bytes allocated increased from i386-linux-deb9 baseline @ HEAD~10: Expected hie002 (normal) compile_time/bytes allocated: 583014888.0 +/-10% Lower bound hie002 (normal) compile_time/bytes allocated: 524713399 Upper bound hie002 (normal) compile_time/bytes allocated: 641316377 Actual hie002 (normal) compile_time/bytes allocated: 877986292 Deviation hie002 (normal) compile_time/bytes allocated: 50.6 % *** unexpected stat test failure for hie002(normal) - - - - - 9462452a by Andreas Klebinger at 2020-04-03T06:25:33-04:00 Improve and refactor StgToCmm codegen for DataCons. We now differentiate three cases of constructor bindings: 1)Bindings which we can "replace" with a reference to an existing closure. Reference the replacement closure when accessing the binding. 2)Bindings which we can "replace" as above. But we still generate a closure which will be referenced by modules importing this binding. 3)For any other binding generate a closure. Then reference it. Before this patch 1) did only apply to local bindings and we didn't do 2) at all. - - - - - a214d214 by Moritz Bruder at 2020-04-03T06:26:11-04:00 Add singleton to NonEmpty in libraries/base This adds a definition to construct a singleton non-empty list (Data.List.NonEmpty) according to issue #17851. - - - - - f7597aa0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Testsuite: measure compiler stats for T16190 We were mistakenly measuring program stats - - - - - a485c3c4 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Move blob handling into StgToCmm Move handling of big literal strings from CmmToAsm to StgToCmm. It avoids the use of `sdocWithDynFlags` (cf #10143). We might need to move this handling even higher in the pipeline in the future (cf #17960): this patch will make it easier. - - - - - cc2918a0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Refactor CmmStatics In !2959 we noticed that there was some redundant code (in GHC.Cmm.Utils and GHC.Cmm.StgToCmm.Utils) used to deal with `CmmStatics` datatype (before SRT generation) and `RawCmmStatics` datatype (after SRT generation). This patch removes this redundant code by using a single GADT for (Raw)CmmStatics. - - - - - 9e60273d by Maxim Koltsov at 2020-04-03T06:27:32-04:00 Fix haddock formatting in Control.Monad.ST.Lazy.Imp.hs - - - - - 1b7e8a94 by Andreas Klebinger at 2020-04-03T06:28:08-04:00 Turn newlines into spaces for hadrian/ghci. The newlines break the command on windows. - - - - - 4291bdda by Simon Peyton Jones at 2020-04-03T06:28:44-04:00 Major improvements to the specialiser This patch is joint work of Alexis King and Simon PJ. It does some significant refactoring of the type-class specialiser. Main highlights: * We can specialise functions with types like f :: Eq a => a -> Ord b => b => blah where the classes aren't all at the front (#16473). Here we can correctly specialise 'f' based on a call like f @Int @Bool dEqInt x dOrdBool This change really happened in an earlier patch commit 2d0cf6252957b8980d89481ecd0b79891da4b14b Author: Sandy Maguire <sandy at sandymaguire.me> Date: Thu May 16 12:12:10 2019 -0400 work that this new patch builds directly on that work, and refactors it a bit. * We can specialise functions with implicit parameters (#17930) g :: (?foo :: Bool, Show a) => a -> String Previously we could not, but now they behave just like a non-class argument as in 'f' above. * We can specialise under-saturated calls, where some (but not all of the dictionary arguments are provided (#17966). For example, we can specialise the above 'f' based on a call map (f @Int dEqInt) xs even though we don't (and can't) give Ord dictionary. This may sound exotic, but #17966 is a program from the wild, and showed significant perf loss for functions like f, if you need saturation of all dictionaries. * We fix a buglet in which a floated dictionary had a bogus demand (#17810), by using zapIdDemandInfo in the NonRec case of specBind. * A tiny side benefit: we can drop dead arguments to specialised functions; see Note [Drop dead args from specialisations] * Fixed a bug in deciding what dictionaries are "interesting"; see Note [Keep the old dictionaries interesting] This is all achieved by by building on Sandy Macguire's work in defining SpecArg, which mkCallUDs uses to describe the arguments of the call. Main changes: * Main work is in specHeader, which marched down the [InBndr] from the function definition and the [SpecArg] from the call site, together. * specCalls no longer has an arity check; the entire mechanism now handles unders-saturated calls fine. * mkCallUDs decides on an argument-by-argument basis whether to specialise a particular dictionary argument; this is new. See mk_spec_arg in mkCallUDs. It looks as if there are many more lines of code, but I think that all the extra lines are comments! - - - - - 40a85563 by Ömer Sinan Ağacan at 2020-04-03T18:26:19+03:00 Revert accidental change in 9462452 [ci skip] - - - - - bd75e5da by Ryan Scott at 2020-04-04T07:07:58-04:00 Enable ImpredicativeTypes internally when typechecking selector bindings This is necessary for certain record selectors with higher-rank types, such as the examples in #18005. See `Note [Impredicative record selectors]` in `TcTyDecls`. Fixes #18005. - - - - - dcfe29c8 by Ömer Sinan Ağacan at 2020-04-06T13:16:08-04:00 Don't override proc CafInfos in ticky builds Fixes #17947 When we have a ticky label for a proc, IdLabels for the ticky counter and proc entry share the same Name. This caused overriding proc CafInfos with the ticky CafInfos (i.e. NoCafRefs) during SRT analysis. We now ignore the ticky labels when building SRTMaps. This makes sense because: - When building the current module they don't need to be in SRTMaps as they're initialized as non-CAFFY (see mkRednCountsLabel), so they don't take part in the dependency analysis and they're never added to SRTs. (Reminder: a "dependency" in the SRT analysis is a CAFFY dependency, non-CAFFY uses are not considered as dependencies for the algorithm) - They don't appear in the interfaces as they're not exported, so it doesn't matter for cross-module concerns whether they're in the SRTMap or not. See also the new Note [Ticky labels in SRT analysis]. - - - - - cec2c71f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Fix an tricky specialiser loop Issue #17151 was a very tricky example of a bug in which the specialiser accidentally constructs a recurive dictionary, so that everything turns into bottom. I have fixed variants of this bug at least twice before: see Note [Avoiding loops]. It was a bit of a struggle to isolate the problem, greatly aided by the work that Alexey Kuleshevich did in distilling a test case. Once I'd understood the problem, it was not difficult to fix, though it did lead me a bit of refactoring in specImports. - - - - - e850d14f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Refactoring only This refactors DictBinds into a data type rather than a pair. No change in behaviour, just better code - - - - - f38e8d61 by Daniel Gröber at 2020-04-07T02:00:05-04:00 rts: ProfHeap: Fix memory leak when not compiled with profiling If we're doing heap profiling on an unprofiled executable we keep allocating new space in initEra via nextEra on each profiler run but we don't have a corresponding freeEra call. We do free the last era in endHeapProfiling but previous eras will have been overwritten by initEra and will never get free()ed. Metric Decrease: space_leak_001 - - - - - bcd66859 by Sebastian Graf at 2020-04-07T02:00:41-04:00 Re-export GHC.Magic.noinline from base - - - - - 3d2991f8 by Ben Gamari at 2020-04-07T18:36:09-04:00 simplifier: Kill off ufKeenessFactor We used to have another factor, ufKeenessFactor, which would scale the discounts before they were subtracted from the size. This was justified with the following comment: -- We multiple the raw discounts (args_discount and result_discount) -- ty opt_UnfoldingKeenessFactor because the former have to do with -- *size* whereas the discounts imply that there's some extra -- *efficiency* to be gained (e.g. beta reductions, case reductions) -- by inlining. However, this is highly suspect since it means that we subtract a *scaled* size from an absolute size, resulting in crazy (e.g. negative) scores in some cases (#15304). We consequently killed off ufKeenessFactor and bumped up the ufUseThreshold to compensate. Adjustment of unfolding use threshold ===================================== Since this removes a discount from our inlining heuristic, I revisited our default choice of -funfolding-use-threshold to minimize the change in overall inlining behavior. Specifically, I measured runtime allocations and executable size of nofib and the testsuite performance tests built using compilers (and core libraries) built with several values of -funfolding-use-threshold. This comes as a result of a quantitative comparison of testsuite performance and code size as a function of ufUseThreshold, comparing GHC trees using values of 50, 60, 70, 80, 90, and 100. The test set consisted of nofib and the testsuite performance tests. A full summary of these measurements are found in the description of !2608 Comparing executable sizes (relative to the base commit) across all nofib tests, we see that sizes are similar to the baseline: gmean min max median thresh 50 -6.36% -7.04% -4.82% -6.46% 60 -5.04% -5.97% -3.83% -5.11% 70 -2.90% -3.84% -2.31% -2.92% 80 -0.75% -2.16% -0.42% -0.73% 90 +0.24% -0.41% +0.55% +0.26% 100 +1.36% +0.80% +1.64% +1.37% baseline +0.00% +0.00% +0.00% +0.00% Likewise, looking at runtime allocations we see that 80 gives slightly better optimisation than the baseline: gmean min max median thresh 50 +0.16% -0.16% +4.43% +0.00% 60 +0.09% -0.00% +3.10% +0.00% 70 +0.04% -0.09% +2.29% +0.00% 80 +0.02% -1.17% +2.29% +0.00% 90 -0.02% -2.59% +1.86% +0.00% 100 +0.00% -2.59% +7.51% -0.00% baseline +0.00% +0.00% +0.00% +0.00% Finally, I had to add a NOINLINE in T4306 to ensure that `upd` is worker-wrappered as the test expects. This makes me wonder whether the inlining heuristic is now too liberal as `upd` is quite a large function. The same measure was taken in T12600. Wall clock time compiling Cabal with -O0 thresh 50 60 70 80 90 100 baseline build-Cabal 93.88 89.58 92.59 90.09 100.26 94.81 89.13 Also, this change happens to avoid the spurious test output in `plugin-recomp-change` and `plugin-recomp-change-prof` (see #17308). Metric Decrease: hie002 T12234 T13035 T13719 T14683 T4801 T5631 T5642 T9020 T9872d T9961 Metric Increase: T12150 T12425 T13701 T14697 T15426 T1969 T3064 T5837 T6048 T9203 T9872a T9872b T9872c T9872d haddock.Cabal haddock.base haddock.compiler - - - - - 255418da by Sylvain Henry at 2020-04-07T18:36:49-04:00 Modules: type-checker (#13009) Update Haddock submodule - - - - - 04b6cf94 by Ryan Scott at 2020-04-07T19:43:20-04:00 Make NoExtCon fields strict This changes every unused TTG extension constructor to be strict in its field so that the pattern-match coverage checker is smart enough any such constructors are unreachable in pattern matches. This lets us remove nearly every use of `noExtCon` in the GHC API. The only ones we cannot remove are ones underneath uses of `ghcPass`, but that is only because GHC 8.8's and 8.10's coverage checkers weren't smart enough to perform this kind of reasoning. GHC HEAD's coverage checker, on the other hand, _is_ smart enough, so we guard these uses of `noExtCon` with CPP for now. Bumps the `haddock` submodule. Fixes #17992. - - - - - 7802fa17 by Ryan Scott at 2020-04-08T16:43:44-04:00 Handle promoted data constructors in typeToLHsType correctly Instead of using `nlHsTyVar`, which hardcodes `NotPromoted`, have `typeToLHsType` pick between `Promoted` and `NotPromoted` by checking if a type constructor is promoted using `isPromotedDataCon`. Fixes #18020. - - - - - ce481361 by Ben Gamari at 2020-04-09T16:17:21-04:00 hadrian: Use --export-dynamic when linking iserv As noticed in #17962, the make build system currently does this (see 3ce0e0ba) but the change was never ported to Hadrian. - - - - - fa66f143 by Ben Gamari at 2020-04-09T16:17:21-04:00 iserv: Don't pass --export-dynamic on FreeBSD This is definitely a hack but it's probably the best we can do for now. Hadrian does the right thing here by passing --export-dynamic only to the linker. - - - - - 39075176 by Ömer Sinan Ağacan at 2020-04-09T16:18:00-04:00 Fix CNF handling in compacting GC Fixes #17937 Previously compacting GC simply ignored CNFs. This is mostly fine as most (see "What about small compacts?" below) CNF objects don't have outgoing pointers, and are "large" (allocated in large blocks) and large objects are not moved or compacted. However if we do GC *during* sharing-preserving compaction then the CNF will have a hash table mapping objects that have been moved to the CNF to their location in the CNF, to be able to preserve sharing. This case is handled in the copying collector, in `scavenge_compact`, where we evacuate hash table entries and then rehash the table. Compacting GC ignored this case. We now visit CNFs in all generations when threading pointers to the compacted heap and thread hash table keys. A visited CNF is added to the list `nfdata_chain`. After compaction is done, we re-visit the CNFs in that list and rehash the tables. The overhead is minimal: the list is static in `Compact.c`, and link field is added to `StgCompactNFData` closure. Programs that don't use CNFs should not be affected. To test this CNF tests are now also run in a new way 'compacting_gc', which just passes `-c` to the RTS, enabling compacting GC for the oldest generation. Before this patch the result would be: Unexpected failures: compact_gc.run compact_gc [bad exit code (139)] (compacting_gc) compact_huge_array.run compact_huge_array [bad exit code (1)] (compacting_gc) With this patch all tests pass. I can also pass `-c -DS` without any failures. What about small compacts? Small CNFs are still not handled by the compacting GC. However so far I'm unable to write a test that triggers a runtime panic ("update_fwd: unknown/strange object") by allocating a small CNF in a compated heap. It's possible that I'm missing something and it's not possible to have a small CNF. NoFib Results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS +0.1% 0.0% 0.0% +0.0% +0.0% CSD +0.1% 0.0% 0.0% 0.0% 0.0% FS +0.1% 0.0% 0.0% 0.0% 0.0% S +0.1% 0.0% 0.0% 0.0% 0.0% VS +0.1% 0.0% 0.0% 0.0% 0.0% VSD +0.1% 0.0% +0.0% +0.0% -0.0% VSM +0.1% 0.0% +0.0% -0.0% 0.0% anna +0.0% 0.0% -0.0% -0.0% -0.0% ansi +0.1% 0.0% +0.0% +0.0% +0.0% atom +0.1% 0.0% +0.0% +0.0% +0.0% awards +0.1% 0.0% +0.0% +0.0% +0.0% banner +0.1% 0.0% +0.0% +0.0% +0.0% bernouilli +0.1% 0.0% 0.0% -0.0% +0.0% binary-trees +0.1% 0.0% -0.0% -0.0% 0.0% boyer +0.1% 0.0% +0.0% +0.0% +0.0% boyer2 +0.1% 0.0% +0.0% +0.0% +0.0% bspt +0.1% 0.0% -0.0% -0.0% -0.0% cacheprof +0.1% 0.0% -0.0% -0.0% -0.0% calendar +0.1% 0.0% +0.0% +0.0% +0.0% cichelli +0.1% 0.0% +0.0% +0.0% +0.0% circsim +0.1% 0.0% +0.0% +0.0% +0.0% clausify +0.1% 0.0% -0.0% +0.0% +0.0% comp_lab_zift +0.1% 0.0% +0.0% +0.0% +0.0% compress +0.1% 0.0% +0.0% +0.0% 0.0% compress2 +0.1% 0.0% -0.0% 0.0% 0.0% constraints +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm1 +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm2 +0.1% 0.0% +0.0% +0.0% +0.0% cse +0.1% 0.0% +0.0% +0.0% +0.0% digits-of-e1 +0.1% 0.0% +0.0% -0.0% -0.0% digits-of-e2 +0.1% 0.0% -0.0% -0.0% -0.0% dom-lt +0.1% 0.0% +0.0% +0.0% +0.0% eliza +0.1% 0.0% +0.0% +0.0% +0.0% event +0.1% 0.0% +0.0% +0.0% +0.0% exact-reals +0.1% 0.0% +0.0% +0.0% +0.0% exp3_8 +0.1% 0.0% +0.0% -0.0% 0.0% expert +0.1% 0.0% +0.0% +0.0% +0.0% fannkuch-redux +0.1% 0.0% -0.0% 0.0% 0.0% fasta +0.1% 0.0% -0.0% +0.0% +0.0% fem +0.1% 0.0% -0.0% +0.0% 0.0% fft +0.1% 0.0% -0.0% +0.0% +0.0% fft2 +0.1% 0.0% +0.0% +0.0% +0.0% fibheaps +0.1% 0.0% +0.0% +0.0% +0.0% fish +0.1% 0.0% +0.0% +0.0% +0.0% fluid +0.0% 0.0% +0.0% +0.0% +0.0% fulsom +0.1% 0.0% -0.0% +0.0% 0.0% gamteb +0.1% 0.0% +0.0% +0.0% 0.0% gcd +0.1% 0.0% +0.0% +0.0% +0.0% gen_regexps +0.1% 0.0% -0.0% +0.0% 0.0% genfft +0.1% 0.0% +0.0% +0.0% +0.0% gg +0.1% 0.0% 0.0% +0.0% +0.0% grep +0.1% 0.0% -0.0% +0.0% +0.0% hidden +0.1% 0.0% +0.0% -0.0% 0.0% hpg +0.1% 0.0% -0.0% -0.0% -0.0% ida +0.1% 0.0% +0.0% +0.0% +0.0% infer +0.1% 0.0% +0.0% 0.0% -0.0% integer +0.1% 0.0% +0.0% +0.0% +0.0% integrate +0.1% 0.0% -0.0% -0.0% -0.0% k-nucleotide +0.1% 0.0% +0.0% +0.0% 0.0% kahan +0.1% 0.0% +0.0% +0.0% +0.0% knights +0.1% 0.0% -0.0% -0.0% -0.0% lambda +0.1% 0.0% +0.0% +0.0% -0.0% last-piece +0.1% 0.0% +0.0% 0.0% 0.0% lcss +0.1% 0.0% +0.0% +0.0% 0.0% life +0.1% 0.0% -0.0% +0.0% +0.0% lift +0.1% 0.0% +0.0% +0.0% +0.0% linear +0.1% 0.0% -0.0% +0.0% 0.0% listcompr +0.1% 0.0% +0.0% +0.0% +0.0% listcopy +0.1% 0.0% +0.0% +0.0% +0.0% maillist +0.1% 0.0% +0.0% -0.0% -0.0% mandel +0.1% 0.0% +0.0% +0.0% 0.0% mandel2 +0.1% 0.0% +0.0% +0.0% +0.0% mate +0.1% 0.0% +0.0% 0.0% +0.0% minimax +0.1% 0.0% -0.0% 0.0% -0.0% mkhprog +0.1% 0.0% +0.0% +0.0% +0.0% multiplier +0.1% 0.0% +0.0% 0.0% 0.0% n-body +0.1% 0.0% +0.0% +0.0% +0.0% nucleic2 +0.1% 0.0% +0.0% +0.0% +0.0% para +0.1% 0.0% 0.0% +0.0% +0.0% paraffins +0.1% 0.0% +0.0% -0.0% 0.0% parser +0.1% 0.0% -0.0% -0.0% -0.0% parstof +0.1% 0.0% +0.0% +0.0% +0.0% pic +0.1% 0.0% -0.0% -0.0% 0.0% pidigits +0.1% 0.0% +0.0% -0.0% -0.0% power +0.1% 0.0% +0.0% +0.0% +0.0% pretty +0.1% 0.0% -0.0% -0.0% -0.1% primes +0.1% 0.0% -0.0% -0.0% -0.0% primetest +0.1% 0.0% -0.0% -0.0% -0.0% prolog +0.1% 0.0% -0.0% -0.0% -0.0% puzzle +0.1% 0.0% -0.0% -0.0% -0.0% queens +0.1% 0.0% +0.0% +0.0% +0.0% reptile +0.1% 0.0% -0.0% -0.0% +0.0% reverse-complem +0.1% 0.0% +0.0% 0.0% -0.0% rewrite +0.1% 0.0% -0.0% -0.0% -0.0% rfib +0.1% 0.0% +0.0% +0.0% +0.0% rsa +0.1% 0.0% -0.0% +0.0% -0.0% scc +0.1% 0.0% -0.0% -0.0% -0.1% sched +0.1% 0.0% +0.0% +0.0% +0.0% scs +0.1% 0.0% +0.0% +0.0% +0.0% simple +0.1% 0.0% -0.0% -0.0% -0.0% solid +0.1% 0.0% +0.0% +0.0% +0.0% sorting +0.1% 0.0% -0.0% -0.0% -0.0% spectral-norm +0.1% 0.0% +0.0% +0.0% +0.0% sphere +0.1% 0.0% -0.0% -0.0% -0.0% symalg +0.1% 0.0% -0.0% -0.0% -0.0% tak +0.1% 0.0% +0.0% +0.0% +0.0% transform +0.1% 0.0% +0.0% +0.0% +0.0% treejoin +0.1% 0.0% +0.0% -0.0% -0.0% typecheck +0.1% 0.0% +0.0% +0.0% +0.0% veritas +0.0% 0.0% +0.0% +0.0% +0.0% wang +0.1% 0.0% 0.0% +0.0% +0.0% wave4main +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve1 +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve2 +0.1% 0.0% +0.0% +0.0% +0.0% x2n1 +0.1% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -0.0% -0.1% Max +0.1% 0.0% +0.0% +0.0% +0.0% Geometric Mean +0.1% -0.0% -0.0% -0.0% -0.0% Bumping numbers of nonsensical perf tests: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 It's simply not possible for this patch to increase allocations, and I've wasted enough time on these test in the past (see #17686). I think these tests should not be perf tests, but for now I'll bump the numbers. - - - - - dce50062 by Sylvain Henry at 2020-04-09T16:18:44-04:00 Rts: show errno on failure (#18033) - - - - - 045139f4 by Hécate at 2020-04-09T23:10:44-04:00 Add an example to liftIO and explain its purpose - - - - - 101fab6e by Sebastian Graf at 2020-04-09T23:11:21-04:00 Special case `isConstraintKindCon` on `AlgTyCon` Previously, the `tyConUnique` record selector would unfold into a huge case expression that would be inlined in all call sites, such as the `INLINE`-annotated `coreView`, see #18026. `constraintKindTyConKey` only occurs as the `Unique` of an `AlgTyCon` anyway, so we can make the code a lot more compact, but have to move it to GHC.Core.TyCon. Metric Decrease: T12150 T12234 - - - - - f5212dfc by Sebastian Graf at 2020-04-09T23:11:57-04:00 DmdAnal: No need to attach a StrictSig to DataCon workers In GHC.Types.Id.Make we were giving a strictness signature to every data constructor wrapper Id that we weren't looking at in demand analysis anyway. We used to use its CPR info, but that has its own CPR signature now. `Note [Data-con worker strictness]` then felt very out of place, so I moved it to GHC.Core.DataCon. - - - - - 75a185dc by Sylvain Henry at 2020-04-09T23:12:37-04:00 Hadrian: fix --summary - - - - - 723062ed by Ömer Sinan Ağacan at 2020-04-10T09:18:14+03:00 testsuite: Move no_lint to the top level, tweak hie002 - We don't want to benchmark linting so disable lints in hie002 perf test - Move no_lint to the top-level to be able to use it in tests other than those in `testsuite/tests/perf/compiler`. - Filter out -dstg-lint in no_lint. - hie002 allocation numbers on 32-bit are unstable, so skip it on 32-bit Metric Decrease: hie002 ManyConstructors T12150 T12234 T13035 T1969 T4801 T9233 T9961 - - - - - bcafaa82 by Peter Trommler at 2020-04-10T19:29:33-04:00 Testsuite: mark T11531 fragile The test depends on a link editor allowing undefined symbols in an ELF shared object. This is the standard but it seems some distributions patch their link editor. See the report by @hsyl20 in #11531. Fixes #11531 - - - - - 0889f5ee by Takenobu Tani at 2020-04-12T11:44:52+09:00 testsuite: Fix comment for a language extension [skip ci] - - - - - cd4f92b5 by Simon Peyton Jones at 2020-04-12T11:20:58-04:00 Significant refactor of Lint This refactoring of Lint was triggered by #17923, which is fixed by this patch. The main change is this. Instead of lintType :: Type -> LintM LintedKind we now have lintType :: Type -> LintM LintedType Previously, all of typeKind was effectively duplicate in lintType. Moreover, since we have an ambient substitution, we still had to apply the substition here and there, sometimes more than once. It was all very tricky, in the end, and made my head hurt. Now, lintType returns a fully linted type, with all substitutions performed on it. This is much simpler. The same thing is needed for Coercions. Instead of lintCoercion :: OutCoercion -> LintM (LintedKind, LintedKind, LintedType, LintedType, Role) we now have lintCoercion :: Coercion -> LintM LintedCoercion Much simpler! The code is shorter and less bug-prone. There are a lot of knock on effects. But life is now better. Metric Decrease: T1969 - - - - - 0efaf301 by Josh Meredith at 2020-04-12T11:21:34-04:00 Implement extensible interface files - - - - - 54ca66a7 by Ryan Scott at 2020-04-12T11:22:10-04:00 Use conLikeUserTyVarBinders to quantify field selector types This patch: 1. Writes up a specification for how the types of top-level field selectors should be determined in a new section of the GHC User's Guide, and 2. Makes GHC actually implement that specification by using `conLikeUserTyVarBinders` in `mkOneRecordSelector` to preserve the order and specificity of type variables written by the user. Fixes #18023. - - - - - 35799dda by Ben Gamari at 2020-04-12T11:22:50-04:00 hadrian: Don't --export-dynamic on Darwin When fixing #17962 I neglected to consider that --export-dynamic is only supported on ELF platforms. - - - - - e8029816 by Alexis King at 2020-04-12T11:23:27-04:00 Add an INLINE pragma to Control.Category.>>> This fixes #18013 by adding INLINE pragmas to both Control.Category.>>> and GHC.Desugar.>>>. The functional change in this patch is tiny (just two lines of pragmas!), but an accompanying Note explains in gory detail what’s going on. - - - - - 0da186c1 by Krzysztof Gogolewski at 2020-04-14T07:55:20-04:00 Change zipWith to zipWithEqual in a few places - - - - - 074c1ccd by Andreas Klebinger at 2020-04-14T07:55:55-04:00 Small change to the windows ticker. We already have a function to go from time to ms so use it. Also expand on the state of timer resolution. - - - - - b69cc884 by Alp Mestanogullari at 2020-04-14T07:56:38-04:00 hadrian: get rid of unnecessary levels of nesting in source-dist - - - - - d0c3b069 by Julien Debon at 2020-04-14T07:57:16-04:00 doc (Foldable): Add examples to Data.Foldable See #17929 - - - - - 5b08e0c0 by Ben Gamari at 2020-04-14T23:28:20-04:00 StgCRun: Enable unwinding only on Linux It's broken on macOS due and SmartOS due to assembler differences (#15207) so let's be conservative in enabling it. Also, refactor things to make the intent clearer. - - - - - 27cc2e7b by Ben Gamari at 2020-04-14T23:28:57-04:00 rts: Don't mark evacuate_large as inline This function has two callsites and is quite large. GCC consequently decides not to inline and warns instead. Given the situation, I can't blame it. Let's just remove the inline specifier. - - - - - 9853fc5e by Ben Gamari at 2020-04-14T23:29:48-04:00 base: Enable large file support for OFD locking impl. Not only is this a good idea in general but this should also avoid issue #17950 by ensuring that off_t is 64-bits. - - - - - 7b41f21b by Matthew Pickering at 2020-04-14T23:30:24-04:00 Hadrian: Make -i paths absolute The primary reason for this change is that ghcide does not work with relative paths. It also matches what cabal and stack do, they always pass absolute paths. - - - - - 41230e26 by Daniel Gröber at 2020-04-14T23:31:01-04:00 Zero out pinned block alignment slop when profiling The heap profiler currently cannot traverse pinned blocks because of alignment slop. This used to just be a minor annoyance as the whole block is accounted into a special cost center rather than the respective object's CCS, cf. #7275. However for the new root profiler we would like to be able to visit _every_ closure on the heap. We need to do this so we can get rid of the current 'flip' bit hack in the heap traversal code. Since info pointers are always non-zero we can in principle skip all the slop in the profiler if we can rely on it being zeroed. This assumption caused problems in the past though, commit a586b33f8e ("rts: Correct handling of LARGE ARR_WORDS in LDV profiler"), part of !1118, tried to use the same trick for BF_LARGE objects but neglected to take into account that shrink*Array# functions don't ensure that slop is zeroed when not compiling with profiling. Later, commit 0c114c6599 ("Handle large ARR_WORDS in heap census (fix as we will only be assuming slop is zeroed when profiling is on. This commit also reduces the ammount of slop we introduce in the first place by calculating the needed alignment before doing the allocation for small objects where we know the next available address. For large objects we don't know how much alignment we'll have to do yet since those details are hidden behind the allocateMightFail function so there we continue to allocate the maximum additional words we'll need to do the alignment. So we don't have to duplicate all this logic in the cmm code we pull it into the RTS allocatePinned function instead. Metric Decrease: T7257 haddock.Cabal haddock.base - - - - - 15fa9bd6 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Expand and add more notes regarding slop - - - - - caf3f444 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: allocatePinned: Fix confusion about word/byte units - - - - - c3c0f662 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Underline some Notes as is conventional - - - - - e149dea9 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Fix nomenclature in OVERWRITING_CLOSURE macros The additional commentary introduced by commit 8916e64e5437 ("Implement shrinkSmallMutableArray# and resizeSmallMutableArray#.") unfortunately got this wrong. We set 'prim' to true in overwritingClosureOfs because we _don't_ want to call LDV_recordDead(). The reason is because of this "inherently used" distinction made in the LDV profiler so I rename the variable to be more appropriate. - - - - - 1dd3d18c by Daniel Gröber at 2020-04-14T23:31:38-04:00 Remove call to LDV_RECORD_CREATE for array resizing - - - - - 19de2fb0 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Assert LDV_recordDead is not called for inherently used closures The comments make it clear LDV_recordDead should not be called for inhererently used closures, so add an assertion to codify this fact. - - - - - 0b934e30 by Ryan Scott at 2020-04-14T23:32:14-04:00 Bump template-haskell version to 2.17.0.0 This requires bumping the `exceptions` and `text` submodules to bring in commits that bump their respective upper version bounds on `template-haskell`. Fixes #17645. Fixes #17696. Note that the new `text` commit includes a fair number of additions to the Haddocks in that library. As a result, Haddock has to do more work during the `haddock.Cabal` test case, increasing the number of allocations it requires. Therefore, ------------------------- Metric Increase: haddock.Cabal ------------------------- - - - - - 22cc8e51 by Ryan Scott at 2020-04-15T17:48:47-04:00 Fix #18052 by using pprPrefixOcc in more places This fixes several small oversights in the choice of pretty-printing function to use. Fixes #18052. - - - - - ec77b2f1 by Daniel Gröber at 2020-04-15T17:49:24-04:00 rts: ProfHeap: Fix wrong time in last heap profile sample We've had this longstanding issue in the heap profiler, where the time of the last sample in the profile is sometimes way off causing the rendered graph to be quite useless for long runs. It seems to me the problem is that we use mut_user_time() for the last sample as opposed to getRTSStats(), which we use when calling heapProfile() in GC.c. The former is equivalent to getProcessCPUTime() but the latter does some additional stuff: getProcessCPUTime() - end_init_cpu - stats.gc_cpu_ns - stats.nonmoving_gc_cpu_ns So to fix this just use getRTSStats() in both places. - - - - - 85fc32f0 by Sylvain Henry at 2020-04-17T12:45:25-04:00 Hadrian: fix dyn_o/dyn_hi rule (#17534) - - - - - bfde3b76 by Ryan Scott at 2020-04-17T12:46:02-04:00 Fix #18065 by fixing an InstCo oversight in Core Lint There was a small thinko in Core Lint's treatment of `InstCo` coercions that ultimately led to #18065. The fix: add an apostrophe. That's it! Fixes #18065. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> - - - - - a05348eb by Cale Gibbard at 2020-04-17T13:08:47-04:00 Change the fail operator argument of BindStmt to be a Maybe Don't use noSyntaxExpr for it. There is no good way to defensively case on that, nor is it clear one ought to do so. - - - - - 79e27144 by John Ericson at 2020-04-17T13:08:47-04:00 Use trees that grow for rebindable operators for `<-` binds Also add more documentation. - - - - - 18bc16ed by Cale Gibbard at 2020-04-17T13:08:47-04:00 Use FailOperator in more places, define a couple datatypes (XBindStmtRn and XBindStmtTc) to help clarify the meaning of XBindStmt in the renamer and typechecker - - - - - 84cc8394 by Simon Peyton Jones at 2020-04-18T13:20:29-04:00 Add a missing zonk in tcHsPartialType I omitted a vital zonk when refactoring tcHsPartialType in commit 48fb3482f8cbc8a4b37161021e846105f980eed4 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Wed Jun 5 08:55:17 2019 +0100 Fix typechecking of partial type signatures This patch fixes it and adds commentary to explain why. Fixes #18008 - - - - - 2ee96ac1 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Bump FreeBSD bootstrap compiler to 8.10.1 - - - - - 434312e5 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Enable FreeBSD job for so-labelled MRs - - - - - ddffb227 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Use rules syntax for conditional jobs - - - - - e2586828 by Ben Gamari at 2020-04-18T13:21:05-04:00 Bump hsc2hs submodule - - - - - 15ab6cd5 by Ömer Sinan Ağacan at 2020-04-18T13:21:44-04:00 Improve prepForeignCall error reporting Show parameters and description of the error code when ffi_prep_cif fails. This may be helpful for debugging #17018. - - - - - 3ca52151 by Sylvain Henry at 2020-04-18T20:04:14+02:00 GHC.Core.Opt renaming * GHC.Core.Op => GHC.Core.Opt * GHC.Core.Opt.Simplify.Driver => GHC.Core.Opt.Driver * GHC.Core.Opt.Tidy => GHC.Core.Tidy * GHC.Core.Opt.WorkWrap.Lib => GHC.Core.Opt.WorkWrap.Utils As discussed in: * https://mail.haskell.org/pipermail/ghc-devs/2020-April/018758.html * https://gitlab.haskell.org/ghc/ghc/issues/13009#note_264650 - - - - - 15312bbb by Sylvain Henry at 2020-04-18T20:04:46+02:00 Modules (#13009) * SysTools * Parser * GHC.Builtin * GHC.Iface.Recomp * Settings Update Haddock submodule Metric Decrease: Naperian parsing001 - - - - - eaed0a32 by Alexis King at 2020-04-19T03:16:44-04:00 Add missing addInScope call for letrec binders in OccurAnal This fixes #18044, where a shadowed variable was incorrectly substituted by the binder swap on the RHS of a floated-in letrec. This can only happen when the uniques line up *just* right, so writing a regression test would be very difficult, but at least the fix is small and straightforward. - - - - - 36882493 by Shayne Fletcher at 2020-04-20T04:36:43-04:00 Derive Ord instance for Extension Metric Increase: T12150 T12234 - - - - - b43365ad by Simon Peyton Jones at 2020-04-20T04:37:20-04:00 Fix a buglet in redundant-constraint warnings Ticket #18036 pointed out that we were reporting a redundant constraint when it really really wasn't. Turned out to be a buglet in the SkolemInfo for the relevant implication constraint. Easily fixed! - - - - - d5fae7da by Ömer Sinan Ağacan at 2020-04-20T14:39:28-04:00 Mark T12010 fragile on 32-bit - - - - - bca02fca by Adam Sandberg Ericsson at 2020-04-21T06:38:45-04:00 docs: drop note about not supporting shared libraries on unix systems [skip ci] - - - - - 6655f933 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Use ParserFlags in GHC.Runtime.Eval (#17957) Instead of passing `DynFlags` to functions such as `isStmt` and `hasImport` in `GHC.Runtime.Eval` we pass `ParserFlags`. It's a much simpler structure that can be created purely with `mkParserFlags'`. - - - - - 70be0fbc by Sylvain Henry at 2020-04-21T06:39:32-04:00 GHC.Runtime: avoid DynFlags (#17957) * add `getPlatform :: TcM Platform` helper * remove unused `DynFlags` parameter from `emptyPLS` - - - - - 35e43d48 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid DynFlags in Ppr code (#17957) * replace `DynFlags` parameters with `SDocContext` parameters for a few Ppr related functions: `bufLeftRenderSDoc`, `printSDoc`, `printSDocLn`, `showSDocOneLine`. * remove the use of `pprCols :: DynFlags -> Int` in Outputable. We already have the information via `sdocLineLength :: SDocContext -> Int` - - - - - ce5c2999 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid using sdocWithDynFlags (#17957) Remove one use of `sdocWithDynFlags` from `GHC.CmmToLlvm.llvmCodeGen'` and from `GHC.Driver.CodeOutput.profilingInitCode` - - - - - f2a98996 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid `sdocWithDynFlags` in `pprCLbl` (#17957) * add a `DynFlags` parameter to `pprCLbl` * put `maybe_underscore` and `pprAsmCLbl` in a `where` clause to avoid `DynFlags` parameters - - - - - 747093b7 by Sylvain Henry at 2020-04-21T06:39:32-04:00 CmmToAsm DynFlags refactoring (#17957) * Remove `DynFlags` parameter from `isDynLinkName`: `isDynLinkName` used to test the global `ExternalDynamicRefs` flag. Now we test it outside of `isDynLinkName` * Add new fields into `NCGConfig`: current unit id, sse/bmi versions, externalDynamicRefs, etc. * Replace many uses of `DynFlags` by `NCGConfig` * Moved `BMI/SSE` datatypes into `GHC.Platform` - - - - - ffd7eef2 by Takenobu Tani at 2020-04-22T23:09:50-04:00 stg-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Stg/Syntax.hs <= stgSyn/StgSyn.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/CostCentre.hs <= profiling/CostCentre.hs This patch also updates old file path [2]: * utils/genapply/Main.hs <= utils/genapply/GenApply.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: commit 0cc4aad36f [skip ci] - - - - - e8a5d81b by Jonathan DK Gibbons at 2020-04-22T23:10:28-04:00 Refactor the `MatchResult` type in the desugarer This way, it does a better job of proving whether or not the fail operator is used. - - - - - dcb7fe5a by John Ericson at 2020-04-22T23:10:28-04:00 Remove panic in dsHandleMonadicFailure Rework dsHandleMonadicFailure to be correct by construction instead of using an unreachable panic. - - - - - cde23cd4 by John Ericson at 2020-04-22T23:10:28-04:00 Inline `adjustMatchResult` It is just `fmap` - - - - - 72cb6bcc by John Ericson at 2020-04-22T23:10:28-04:00 Generalize type of `matchCanFail` - - - - - 401f7bb3 by John Ericson at 2020-04-22T23:10:28-04:00 `MatchResult'` -> `MatchResult` Inline `MatchResult` alias accordingly. - - - - - 6c9fae23 by Alexis King at 2020-04-22T23:11:12-04:00 Mark DataCon wrappers CONLIKE Now that DataCon wrappers don’t inline until phase 0 (see commit b78cc64e923716ac0512c299f42d4d0012306c05), it’s important that case-of-known-constructor and RULE matching be able to see saturated applications of DataCon wrappers in unfoldings. Making them conlike is a natural way to do it, since they are, in fact, precisely the sort of thing the CONLIKE pragma exists to solve. Fixes #18012. This also bumps the version of the parsec submodule to incorporate a patch that avoids a metric increase on the haddock perf tests. The increase was not really a flaw in this patch, as parsec was implicitly relying on inlining heuristics. The patch to parsec just adds some INLINABLE pragmas, and we get a nice performance bump out of it (well beyond the performance we lost from this patch). Metric Decrease: T12234 WWRec haddock.Cabal haddock.base haddock.compiler - - - - - 48b8951e by Roland Senn at 2020-04-22T23:11:51-04:00 Fix tab-completion for :break (#17989) In tab-completion for the `:break` command, only those identifiers should be shown, that are accepted in the `:break` command. Hence these identifiers must be - defined in an interpreted module - top-level - currently in scope - listed in a `ModBreaks` value as a possible breakpoint. The identifiers my be qualified or unqualified. To get all possible top-level breakpoints for tab-completeion with the correct qualification do: 1. Build the list called `pifsBreaks` of all pairs of (Identifier, module-filename) from the `ModBreaks` values. Here all identifiers are unqualified. 2. Build the list called `pifInscope` of all pairs of (Identifiers, module-filename) with identifiers from the `GlobalRdrEnv`. Take only those identifiers that are in scope and have the correct prefix. Here the identifiers may be qualified. 3. From the `pifInscope` list seclect all pairs that can be found in the `pifsBreaks` list, by comparing only the unqualified part of the identifier. The remaining identifiers can be used for tab-completion. This ensures, that we show only identifiers, that can be used in a `:break` command. - - - - - 34a45ee6 by Peter Trommler at 2020-04-22T23:12:27-04:00 PPC NCG: Add DWARF constants and debug labels Fixes #11261 - - - - - ffde2348 by Simon Peyton Jones at 2020-04-22T23:13:06-04:00 Do eager instantation in terms This patch implements eager instantiation, a small but critical change to the type inference engine, #17173. The main change is this: When inferring types, always return an instantiated type (for now, deeply instantiated; in future shallowly instantiated) There is more discussion in https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html There is quite a bit of refactoring in this patch: * The ir_inst field of GHC.Tc.Utils.TcType.InferResultk has entirely gone. So tcInferInst and tcInferNoInst have collapsed into tcInfer. * Type inference of applications, via tcInferApp and tcInferAppHead, are substantially refactored, preparing the way for Quick Look impredicativity. * New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs are beatifully dual. We can see the zipper! * GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return a wrapper * In HsExpr, HsTypeApp now contains the the actual type argument, and is used in desugaring, rather than putting it in a mysterious wrapper. * I struggled a bit with good error reporting in Unify.matchActualFunTysPart. It's a little bit simpler than before, but still not great. Some smaller things * Rename tcPolyExpr --> tcCheckExpr tcMonoExpr --> tcLExpr * tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat Metric Decrease: T9961 Reduction of 1.6% in comiler allocation on T9961, I think. - - - - - 6f84aca3 by Ben Gamari at 2020-04-22T23:13:43-04:00 rts: Ensure that sigaction structs are initialized I noticed these may have uninitialized fields when looking into #18037. The reporter says that zeroing them doesn't fix the MSAN failures they observe but zeroing them is the right thing to do regardless. - - - - - c29f0fa6 by Andreas Klebinger at 2020-04-22T23:14:21-04:00 Add "ddump-cmm-opt" as alias for "ddump-opt-cmm". - - - - - 4b4a8b60 by Ben Gamari at 2020-04-22T23:14:57-04:00 llvmGen: Remove -fast-llvm flag Issue #18076 drew my attention to the undocumented `-fast-llvm` flag for the LLVM code generator introduced in 22733532171330136d87533d523f565f2a4f102f. Speaking to Moritz about this, the motivation for this flag was to avoid potential incompatibilities between LLVM and the assembler/linker toolchain by making LLVM responsible for machine-code generation. Unfortunately, this cannot possibly work: the LLVM backend's mangler performs a number of transforms on the assembler generated by LLVM that are necessary for correctness. These are currently: * mangling Haskell functions' symbol types to be `object` instead of `function` on ELF platforms (necessary for tables-next-to-code) * mangling AVX instructions to ensure that we don't assume alignment (which LLVM otherwise does) * mangling Darwin's subsections-via-symbols directives Given that these are all necessary I don't believe that we can support `-fast-llvm`. Let's rather remove it. - - - - - 831b6642 by Moritz Angermann at 2020-04-22T23:15:33-04:00 Fix build warning; add more informative information to the linker; fix linker for empty sections - - - - - c409961a by Ryan Scott at 2020-04-22T23:16:12-04:00 Update commentary and slightly refactor GHC.Tc.Deriv.Infer There was some out-of-date commentary in `GHC.Tc.Deriv.Infer` that has been modernized. Along the way, I removed the `bad` constraints in `simplifyDeriv`, which did not serve any useful purpose (besides being printed in debugging output). Fixes #18073. - - - - - 125aa2b8 by Ömer Sinan Ağacan at 2020-04-22T23:16:51-04:00 Remove leftover comment in tcRnModule', redundant bind The code for the comment was moved in dc8c03b2a5c but the comment was forgotten. - - - - - 8ea37b01 by Sylvain Henry at 2020-04-22T23:17:34-04:00 RTS: workaround a Linux kernel bug in timerfd Reading a timerfd may return 0: https://lkml.org/lkml/2019/8/16/335. This is currently undocumented behavior and documentation "won't happen anytime soon" (https://lkml.org/lkml/2020/2/13/295). With this patch, we just ignore the result instead of crashing. It may fix #18033 but we can't be sure because we don't have enough information. See also this discussion about the kernel bug: https://github.com/Azure/sonic-swss-common/pull/302/files/1f070e7920c2e5d63316c0105bf4481e73d72dc9 - - - - - cd8409c2 by Ryan Scott at 2020-04-23T11:39:24-04:00 Create di_scoped_tvs for associated data family instances properly See `Note [Associated data family instances and di_scoped_tvs]` in `GHC.Tc.TyCl.Instance`, which explains all of the moving parts. Fixes #18055. - - - - - 339e8ece by Ben Gamari at 2020-04-23T11:40:02-04:00 hadrian/ghci: Allow arguments to be passed to GHCi Previously the arguments passed to hadrian/ghci were passed both to `hadrian` and GHCi. This is rather odd given that there are essentially not arguments in the intersection of the two. Let's just pass them to GHCi; this allows `hadrian/ghci -Werror`. - - - - - 5946c85a by Ben Gamari at 2020-04-23T11:40:38-04:00 testsuite: Don't attempt to read .std{err,out} files if they don't exist Simon reports that he was previously seeing framework failures due to an attempt to read the non-existing T13456.stderr. While I don't know exactly what this is due to, it does seem like a non-existing .std{out,err} file should be equivalent to an empty file. Teach the testsuite driver to treat it as such. - - - - - c42754d5 by John Ericson at 2020-04-23T18:32:43-04:00 Trees That Grow refactor for `ConPat` and `CoPat` - `ConPat{In,Out}` -> `ConPat` - `CoPat` -> `XPat (CoPat ..)` Note that `GHC.HS.*` still uses `HsWrap`, but only when `p ~ GhcTc`. After this change, moving the type family instances out of `GHC.HS.*` is sufficient to break the cycle. Add XCollectPat class to decide how binders are collected from XXPat based on the pass. Previously we did this with IsPass, but that doesn't work for Haddock's DocNameI, and the constraint doesn't express what actual distinction is being made. Perhaps a class for collecting binders more generally is in order, but we haven't attempted this yet. Pure refactor of code around ConPat - InPat/OutPat synonyms removed - rename several identifiers - redundant constraints removed - move extension field in ConPat to be first - make ConPat use record syntax more consistently Fix T6145 (ConPatIn became ConPat) Add comments from SPJ. Add comment about haddock's use of CollectPass. Updates haddock submodule. - - - - - 72da0c29 by mniip at 2020-04-23T18:33:21-04:00 Add :doc to GHC.Prim - - - - - 2c23e2e3 by mniip at 2020-04-23T18:33:21-04:00 Include docs for non-primop entries in primops.txt as well - - - - - 0ac29c88 by mniip at 2020-04-23T18:33:21-04:00 GHC.Prim docs: note and test - - - - - b0fbfc75 by John Ericson at 2020-04-24T12:07:14-04:00 Switch order on `GhcMake.IsBoot` In !1798 we were requested to replace many `Bool`s with this data type. But those bools had `False` meaning `NotBoot`, so the `Ord` instance would be flipped if we use this data-type as-is. Since the planned formally-`Bool` occurrences vastly outnumber the current occurrences, we figured it would be better to conform the `Ord` instance to how the `Bool` is used now, fixing any issues, rather than fix them currently with the bigger refactor later in !1798. That way, !1798 can be a "pure" refactor with no behavioral changes. - - - - - af332442 by Sylvain Henry at 2020-04-26T13:55:14-04:00 Modules: Utils and Data (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - cd4434c8 by Sylvain Henry at 2020-04-26T13:55:16-04:00 Fix misleading Ptr phantom type in SerializedCompact (#15653) - - - - - 22bf5c73 by Ömer Sinan Ağacan at 2020-04-26T13:55:22-04:00 Tweak includes in non-moving GC headers We don't use hash tables in non-moving GC so remove the includes. This breaks Compact.c as existing includes no longer include Hash.h, so include Hash.h explicitly in Compact.c. - - - - - 99823ed2 by Sylvain Henry at 2020-04-27T20:24:46-04:00 TH: fix Show/Eq/Ord instances for Bytes (#16457) We shouldn't compare pointer values but the actual bytes. - - - - - c62271a2 by Alp Mestanogullari at 2020-04-27T20:25:33-04:00 hadrian: always capture both stdout and stderr when running a builder fails The idea being that when a builder('s command) fails, we quite likely want to have all the information available to figure out why. Depending on the builder _and_ the particular problem, the useful bits of information can be printed on stdout or stderr. We accomplish this by defining a simple wrapper for Shake's `cmd` function, that just _always_ captures both streams in case the command returns a non-zero exit code, and by using this wrapper everywhere in `hadrian/src/Builder.hs`. Fixes #18089. - - - - - 4b9764db by Ryan Scott at 2020-04-28T15:40:04-04:00 Define a Quote IO instance Fixes #18103. - - - - - 518a63d4 by Ryan Scott at 2020-04-28T15:40:42-04:00 Make boxed 1-tuples have known keys Unlike other tuples, which use special syntax and are "known" by way of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not use special syntax. Therefore, in order to make sure that the internals of GHC are aware of the `data Unit a = Unit a` definition in `GHC.Tuple`, we give `Unit` known keys. For the full details, see `Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)` in `GHC.Builtin.Types`. Fixes #18097. - - - - - 2cfc4ab9 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Document backpack fields in DynFlags - - - - - 10a2ba90 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo * Rename InstalledPackageInfo into GenericUnitInfo The name InstalledPackageInfo is only kept for alleged backward compatibility reason in Cabal. ghc-boot has its own stripped down copy of this datatype but it doesn't need to keep the name. Internally we already use type aliases (UnitInfo in GHC, PackageCacheFormat in ghc-pkg). * Rename UnitInfo fields: add "unit" prefix and fix misleading names * Add comments on every UnitInfo field * Rename SourcePackageId into PackageId "Package" already indicates that it's a "source package". Installed package components are called units. Update Haddock submodule - - - - - 69562e34 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Remove unused `emptyGenericUnitInfo` - - - - - 9e2c8e0e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo load/store from databases Converting between UnitInfo stored in package databases and UnitInfo as they are used in ghc-pkg and ghc was done in a very convoluted way (via BinaryStringRep and DbUnitModuleRep type classes using fun deps, etc.). It was difficult to understand and even more to modify (I wanted to try to use a GADT for UnitId but fun deps got in the way). The new code uses much more straightforward functions to convert between the different representations. Much simpler. - - - - - ea717aa4 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Factorize mungePackagePaths code This patch factorizes the duplicated code used in ghc-pkg and in GHC to munge package paths/urls. It also fixes haddock-html munging in GHC (allowed to be either a file or a url) to mimic ghc-pkg behavior. - - - - - 10d15f1e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactoring unit management code Over the years the unit management code has been modified a lot to keep up with changes in Cabal (e.g. support for several library components in the same package), to integrate BackPack, etc. I found it very hard to understand as the terminology wasn't consistent, was referring to past concepts, etc. The terminology is now explained as clearly as I could in the Note "About Units" and the code is refactored to reflect it. ------------------- Many names were misleading: UnitId is not an Id but could be a virtual unit (an indefinite one instantiated on the fly), IndefUnitId constructor may contain a definite instantiated unit, etc. * Rename IndefUnitId into InstantiatedUnit * Rename IndefModule into InstantiatedModule * Rename UnitId type into Unit * Rename IndefiniteUnitId constructor into VirtUnit * Rename DefiniteUnitId constructor into RealUnit * Rename packageConfigId into mkUnit * Rename getPackageDetails into unsafeGetUnitInfo * Rename InstalledUnitId into UnitId Remove references to misleading ComponentId: a ComponentId is just an indefinite unit-id to be instantiated. * Rename ComponentId into IndefUnitId * Rename ComponentDetails into UnitPprInfo * Fix display of UnitPprInfo with empty version: this is now used for units dynamically generated by BackPack Generalize several types (Module, Unit, etc.) so that they can be used with different unit identifier types: UnitKey, UnitId, Unit, etc. * GenModule: Module, InstantiatedModule and InstalledModule are now instances of this type * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit, PackageDatabase Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor. Add basic support for UnitKey. They should be used more in the future to avoid mixing them up with UnitId as we do now. Add many comments. Update Haddock submodule - - - - - 8bfb0219 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Unit: split and rename modules Introduce GHC.Unit.* hierarchy for everything concerning units, packages and modules. Update Haddock submodule - - - - - 71484b09 by Alexis King at 2020-04-30T01:57:35-04:00 Allow block arguments in arrow control operators Arrow control operators have their own entries in the grammar, so they did not cooperate with BlockArguments. This was just a minor oversight, so this patch adjusts the grammar to add the desired behavior. fixes #18050 - - - - - a48cd2a0 by Alexis King at 2020-04-30T01:57:35-04:00 Allow LambdaCase to be used as a command in proc notation - - - - - f4d3773c by Alexis King at 2020-04-30T01:57:35-04:00 Document BlockArguments/LambdaCase support in arrow notation - - - - - 5bdfdd13 by Simon Peyton Jones at 2020-04-30T01:58:15-04:00 Add tests for #17873 - - - - - 19b701c2 by Simon Peyton Jones at 2020-04-30T07:30:13-04:00 Mark rule args as non-tail-called This was just an omission...b I'd failed to call markAllNonTailCall on rule args. I think this bug has been here a long time, but it's quite hard to trigger. Fixes #18098 - - - - - 014ef4a3 by Matthew Pickering at 2020-04-30T07:30:50-04:00 Hadrian: Improve tool-args command to support more components There is a new command to hadrian, tool:path/to/file.hs, which returns the options needed to compile that file in GHCi. This is now used in the ghci script with argument `ghc/Main.hs` but its main purpose is to support the new multi-component branch of ghcide. - - - - - 2aa67611 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Clear bitmap after initializing block size Previously nonmovingInitSegment would clear the bitmap before initializing the segment's block size. This is broken since nonmovingClearBitmap looks at the segment's block size to determine how much bitmap to clear. - - - - - 54dad3cf by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Explicitly memoize block count A profile cast doubt on whether the compiler hoisted the bound out the loop as I would have expected here. It turns out it did but nevertheless it seems clearer to just do this manually. - - - - - 99ff8145 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Eagerly flush all capabilities' update remembered sets (cherry picked from commit 2fa79119570b358a4db61446396889b8260d7957) - - - - - 05b0a9fd by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 Remove OneShotInfo field of LFReEntrant, document OneShotInfo The field is only used in withNewTickyCounterFun and it's easier to directly pass a parameter for one-shot info to withNewTickyCounterFun instead of passing it via LFReEntrant. This also makes !2842 simpler. Other changes: - New Note (by SPJ) [OneShotInfo overview] added. - Arity argument of thunkCode removed as it's always 0. - - - - - a43620c6 by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 GHC.StgToCmm.Ticky: remove a few unused stuff - - - - - 780de9e1 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Use platform in Iface Binary - - - - - f8386c7b by Sylvain Henry at 2020-05-01T10:37:39-04:00 Refactor PprDebug handling If `-dppr-debug` is set, then PprUser and PprDump styles are silently replaced with PprDebug style. This was done in `mkUserStyle` and `mkDumpStyle` smart constructors. As a consequence they needed a DynFlags parameter. Now we keep the original PprUser and PprDump styles until they are used to create an `SDocContext`. I.e. the substitution is only performed in `initSDocContext`. - - - - - b3df9e78 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Remove PprStyle param of logging actions Use `withPprStyle` instead to apply a specific style to a SDoc. - - - - - de9fc995 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Fully remove PprDebug PprDebug was a pain to deal with consistently as it is implied by `-dppr-debug` but it isn't really a PprStyle. We remove it completely and query the appropriate SDoc flag instead (`sdocPprDebug`) via helpers (`getPprDebug` and its friends). - - - - - 8b51fcbd by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Only call checkSingle if we would report warnings - - - - - fd7ea0fe by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Pick up `EvVar`s bound in `HsWrapper`s for long-distance info `HsWrapper`s introduce evidence bindings through `WpEvLam` which the pattern-match coverage checker should be made aware of. Failing to do so caused #18049, where the resulting impreciseness of imcompleteness warnings seemingly contradicted with `-Winaccessible-code`. The solution is simple: Collect all the evidence binders of an `HsWrapper` and add it to the ambient `Deltas` before desugaring the wrapped expression. But that means we pick up many more evidence bindings, even when they wrap around code without a single pattern match to check! That regressed `T3064` by over 300%, so now we are adding long-distance info lazily through judicious use of `unsafeInterleaveIO`. Fixes #18049. - - - - - 7bfe9ac5 by Ben Gamari at 2020-05-03T04:41:33-04:00 rts: Enable tracing of nonmoving heap census with -ln Previously this was not easily available to the user. Fix this. Non-moving collection lifecycle events are now reported with -lg. - - - - - c560dd07 by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Move eventlog documentation users guide - - - - - 02543d5e by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Add documentation for non-moving GC events - - - - - b465dd45 by Alexis King at 2020-05-03T04:42:12-04:00 Flatten nested casts in the simple optimizer Normally, we aren’t supposed to generated any nested casts, since mkCast takes care to flatten them, but the simple optimizer didn’t use mkCast, so they could show up after inlining. This isn’t really a problem, since the simplifier will clean them up immediately anyway, but it can clutter the -ddump-ds output, and it’s an extremely easy fix. closes #18112 - - - - - 8bdc03d6 by Simon Peyton Jones at 2020-05-04T01:56:59-04:00 Don't return a panic in tcNestedSplice In GHC.Tc.Gen.Splice.tcNestedSplice we were returning a typechecked expression of "panic". That is usually OK, because the result is discarded. But it happens that tcApp now looks at the typechecked expression, trivially, to ask if it is tagToEnum. So being bottom is bad. Moreover a debug-trace might print it out. So better to return a civilised expression, even though it is usually discarded. - - - - - 0bf640b1 by Baldur Blöndal at 2020-05-04T01:57:36-04:00 Don't require parentheses around via type (`-XDerivingVia'). Fixes #18130". - - - - - 30272412 by Artem Pelenitsyn at 2020-05-04T13:19:59-04:00 Remove custom ExceptionMonad class (#18075) (updating haddock submodule accordingly) - - - - - b9f7c08f by jneira at 2020-05-04T13:20:37-04:00 Remove unused hs-boot file - - - - - 1d8f80cd by Sylvain Henry at 2020-05-05T03:22:46-04:00 Remove references to -package-key * remove references to `-package-key` which has been removed in 2016 (240ddd7c39536776e955e881d709bbb039b48513) * remove support for `-this-package-key` which has been deprecated at the same time - - - - - 7bc3a65b by Sylvain Henry at 2020-05-05T03:23:31-04:00 Remove SpecConstrAnnotation (#13681) This has been deprecated since 2013. Use GHC.Types.SPEC instead. Make GHC.Exts "not-home" for haddock Metric Decrease: haddock.base - - - - - 3c862f63 by DenisFrezzato at 2020-05-05T03:24:15-04:00 Fix Haskell98 short description in documentation - - - - - 2420c555 by Ryan Scott at 2020-05-05T03:24:53-04:00 Add regression tests for #16244, #16245, #16758 Commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70 ended up fixing quite a few bugs: * This commit fixes #16244 completely. A regression test has been added. * This commit fixes one program from #16245. (The program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211369 still panics, and the program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211400 still loops infinitely.) A regression test has been added for this program. * This commit fixes #16758. Accordingly, this patch removes the `expect_broken` label from the `T16758` test case, moves it from `should_compile` to `should_fail` (as it should produce an error message), and checks in the expected stderr. - - - - - 40c71c2c by Sylvain Henry at 2020-05-05T03:25:31-04:00 Fix colorized error messages (#18128) In b3df9e780fb2f5658412c644849cd0f1e6f50331 I broke colorized messages by using "dump" style instead of "user" style. This commits fixes it. - - - - - 7ab6ab09 by Richard Eisenberg at 2020-05-06T04:39:32-04:00 Refactor hole constraints. Previously, holes (both expression holes / out of scope variables and partial-type-signature wildcards) were emitted as *constraints* via the CHoleCan constructor. While this worked fine for error reporting, there was a fair amount of faff in keeping these constraints in line. In particular, and unlike other constraints, we could never change a CHoleCan to become CNonCanonical. In addition: * the "predicate" of a CHoleCan constraint was really the type of the hole, which is not a predicate at all * type-level holes (partial type signature wildcards) carried evidence, which was never used * tcNormalise (used in the pattern-match checker) had to create a hole constraint just to extract it again; it was quite messy The new approach is to record holes directly in WantedConstraints. It flows much more nicely now. Along the way, I did some cleaning up of commentary in GHC.Tc.Errors.Hole, which I had a hard time understanding. This was instigated by a future patch that will refactor the way predicates are handled. The fact that CHoleCan's "predicate" wasn't really a predicate is incompatible with that future patch. No test case, because this is meant to be purely internal. It turns out that this change improves the performance of the pattern-match checker, likely because fewer constraints are sloshing about in tcNormalise. I have not investigated deeply, but an improvement is not a surprise here: ------------------------- Metric Decrease: PmSeriesG ------------------------- - - - - - 420b957d by Ben Gamari at 2020-05-06T04:40:08-04:00 rts: Zero block flags with -DZ Block flags are very useful for determining the state of a block. However, some block allocator users don't touch them, leading to misleading values. Ensure that we zero then when zero-on-gc is set. This is safe and makes the flags more useful during debugging. - - - - - 740b3b8d by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix incorrect failed_to_evac value during deadlock gc Previously we would incorrectly set the failed_to_evac flag if we evacuated a value due to a deadlock GC. This would cause us to mark more things as dirty than strictly necessary. It also turned up a nasty but which I will fix next. - - - - - b2d72c75 by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix handling of dirty objects Previously we (incorrectly) relied on failed_to_evac to be "precise". That is, we expected it to only be true if *all* of an object's fields lived outside of the non-moving heap. However, does not match the behavior of failed_to_evac, which is true if *any* of the object's fields weren't promoted (meaning that some others *may* live in the non-moving heap). This is problematic as we skip the non-moving write barrier for dirty objects (which we can only safely do if *all* fields point outside of the non-moving heap). Clearly this arises due to a fundamental difference in the behavior expected of failed_to_evac in the moving and non-moving collector. e.g., in the moving collector it is always safe to conservatively say failed_to_evac=true whereas in the non-moving collector the safe value is false. This issue went unnoticed as I never wrote down the dirtiness invariant enforced by the non-moving collector. We now define this invariant as An object being marked as dirty implies that all of its fields are on the mark queue (or, equivalently, update remembered set). To maintain this invariant we teach nonmovingScavengeOne to push the fields of objects which we fail to evacuate to the update remembered set. This is a simple and reasonably cheap solution and avoids the complexity and fragility that other, more strict alternative invariants would require. All of this is described in a new Note, Note [Dirty flags in the non-moving collector] in NonMoving.c. - - - - - 9f3e6884 by Zubin Duggal at 2020-05-06T04:41:08-04:00 Allow atomic update of NameCache in readHieFile The situation arises in ghcide where multiple different threads may need to update the name cache, therefore with the older interface it could happen that you start reading a hie file with name cache A and produce name cache A + B, but another thread in the meantime updated the namecache to A + C. Therefore if you write the new namecache you will lose the A' updates from the second thread. Updates haddock submodule - - - - - edec6a6c by Ryan Scott at 2020-05-06T04:41:57-04:00 Make isTauTy detect higher-rank contexts Previously, `isTauTy` would only detect higher-rank `forall`s, not higher-rank contexts, which led to some minor bugs observed in #18127. Easily fixed by adding a case for `(FunTy InvisArg _ _)`. Fixes #18127. - - - - - a95e7fe0 by Ömer Sinan Ağacan at 2020-05-06T04:42:39-04:00 ELF linker: increment curSymbol after filling in fields of current entry The bug was introduced in a8b7cef4d45 which added a field to the `symbols` array elements and then updated this code incorrectly: - oc->symbols[curSymbol++] = nm; + oc->symbols[curSymbol++].name = nm; + oc->symbols[curSymbol].addr = symbol->addr; - - - - - cab1871a by Sylvain Henry at 2020-05-06T04:43:21-04:00 Move LeadingUnderscore into Platform (#17957) Avoid direct use of DynFlags to know if symbols must be prefixed by an underscore. - - - - - 94e7c563 by Sylvain Henry at 2020-05-06T04:43:21-04:00 Don't use DynFlags in showLinkerState (#17957) - - - - - 9afd9251 by Ryan Scott at 2020-05-06T04:43:58-04:00 Refactoring: Use bindSigTyVarsFV in rnMethodBinds `rnMethodBinds` was explicitly using `xoptM` to determine if `ScopedTypeVariables` is enabled before bringing type variables bound by the class/instance header into scope. However, this `xoptM` logic is already performed by the `bindSigTyVarsFV` function. This patch uses `bindSigTyVarsFV` in `rnMethodBinds` to reduce the number of places where we need to consult if `ScopedTypeVariables` is on. This is purely refactoring, and there should be no user-visible change in behavior. - - - - - 6f6d72b2 by Brian Foley at 2020-05-08T15:29:25-04:00 Remove further dead code found by a simple Python script. Avoid removing some functions that are part of an API even though they're not used in-tree at the moment. - - - - - 78bf8bf9 by Julien Debon at 2020-05-08T15:29:28-04:00 Add doc examples for Bifoldable See #17929 - - - - - 66f0a847 by Julien Debon at 2020-05-08T15:29:29-04:00 doc (Bitraversable): Add examples to Bitraversable * Add examples to Data.Bitraversable * Fix formatting for (,) in Bitraversable and Bifoldable * Fix mistake on bimapAccumR documentation See #17929 - - - - - 9749fe12 by Baldur Blöndal at 2020-05-08T15:29:32-04:00 Specify kind variables for inferred kinds in base. - - - - - 4e9aef9e by John Ericson at 2020-05-08T15:29:36-04:00 HsSigWcTypeScoping: Pull in documentation from stray location - - - - - f4d5c6df by John Ericson at 2020-05-08T15:29:36-04:00 Rename local `real_fvs` to `implicit_vs` It doesn't make sense to call the "free" variables we are about to implicitly bind the real ones. - - - - - 20570b4b by John Ericson at 2020-05-08T15:29:36-04:00 A few tiny style nits with renaming - Use case rather than guards that repeatedly scrutenize same thing. - No need for view pattern when `L` is fine. - Use type synnonym to convey the intent like elsewhere. - - - - - 09ac8de5 by John Ericson at 2020-05-08T15:29:36-04:00 Add `forAllOrNothing` function with note - - - - - bb35c0e5 by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Document lawlessness of Ap's Num instance - - - - - cdd229ff by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply suggestion to libraries/base/Data/Monoid.hs - - - - - 926d2aab by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply more suggestions from Simon Jakobi - - - - - 7a763cff by Adam Gundry at 2020-05-08T15:29:41-04:00 Reject all duplicate declarations involving DuplicateRecordFields (fixes #17965) This fixes a bug that resulted in some programs being accepted that used the same identifier as a field label and another declaration, depending on the order they appeared in the source code. - - - - - 88e3c815 by Simon Peyton Jones at 2020-05-08T15:29:41-04:00 Fix specialisation for DFuns When specialising a DFun we must take care to saturate the unfolding. See Note [Specialising DFuns] in Specialise. Fixes #18120 - - - - - 86c77b36 by Greg Steuck at 2020-05-08T15:29:45-04:00 Remove unused SEGMENT_PROT_RWX It's been unused for a year and is problematic on any OS which requires W^X for security. - - - - - 9d97f4b5 by nineonine at 2020-05-08T15:30:03-04:00 Add test for #16167 - - - - - aa318338 by Ryan Scott at 2020-05-08T15:30:04-04:00 Bump exceptions submodule so that dist-boot is .gitignore'd `exceptions` is a stage-0 boot library as of commit 30272412fa437ab8e7a8035db94a278e10513413, which means that building `exceptions` in a GHC tree will generate a `dist-boot` directory. However, this directory was not specified in `exceptions`' `.gitignore` file, which causes it to dirty up the current `git` working directory. Accordingly, this bumps the `exceptions` submodule to commit ghc/packages/exceptions at 23c0b8a50d7592af37ca09beeec16b93080df98f, which adds `dist-boot` to the `.gitignore` file. - - - - - ea86360f by Ömer Sinan Ağacan at 2020-05-08T15:30:30-04:00 Linker.c: initialize n_symbols of ObjectCode with other fields - - - - - 951c1fb0 by Sylvain Henry at 2020-05-09T21:46:38-04:00 Fix unboxed-sums GC ptr-slot rubbish value (#17791) This patch allows boot libraries to use unboxed sums without implicitly depending on `base` package because of `absentSumFieldError`. See updated Note [aBSENT_SUM_FIELD_ERROR_ID] in GHC.Core.Make - - - - - b352d63c by Ben Gamari at 2020-05-09T21:47:14-04:00 rts: Make non-existent linker search path merely a warning As noted in #18105, previously this resulted in a rather intrusive error message. This is in contrast to the general expectation that search paths are merely places to look, not places that must exist. Fixes #18105. - - - - - cf4f1e2f by Ben Gamari at 2020-05-13T02:02:33-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 - - - - - a03da9bf by Ömer Sinan Ağacan at 2020-05-13T02:03:16-04:00 Pack some of IdInfo fields into a bit field This reduces residency of compiler quite a bit on some programs. Example stats when building T10370: Before: 2,871,242,832 bytes allocated in the heap 4,693,328,008 bytes copied during GC 33,941,448 bytes maximum residency (276 sample(s)) 375,976 bytes maximum slop 83 MiB total memory in use (0 MB lost due to fragmentation) After: 2,858,897,344 bytes allocated in the heap 4,629,255,440 bytes copied during GC 32,616,624 bytes maximum residency (278 sample(s)) 314,400 bytes maximum slop 80 MiB total memory in use (0 MB lost due to fragmentation) So -3.9% residency, -1.3% bytes copied and -0.4% allocations. Fixes #17497 Metric Decrease: T9233 T9675 - - - - - 670c3e5c by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Fix base URL Revert a change previously made for testing purposes. - - - - - 8ad8dc41 by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Improve diagnostics output - - - - - 8c0740b7 by Simon Jakobi at 2020-05-13T02:04:33-04:00 docs: Add examples for Data.Semigroup.Arg{Min,Max} Context: #17153 - - - - - cb22348f by Ben Gamari at 2020-05-13T02:05:11-04:00 Add few cleanups of the CAF logic Give the NameSet of non-CAFfy names a proper newtype to distinguish it from all of the other NameSets floating about. - - - - - 90e38b81 by Emeka Nkurumeh at 2020-05-13T02:05:51-04:00 fix printf warning when using with ghc with clang on mingw - - - - - 86d8ac22 by Sebastian Graf at 2020-05-13T02:06:29-04:00 CprAnal: Don't attach CPR sigs to expandable bindings (#18154) Instead, look through expandable unfoldings in `cprTransform`. See the new Note [CPR for expandable unfoldings]: ``` Long static data structures (whether top-level or not) like xs = x1 : xs1 xs1 = x2 : xs2 xs2 = x3 : xs3 should not get CPR signatures, because they * Never get WW'd, so their CPR signature should be irrelevant after analysis (in fact the signature might even be harmful for that reason) * Would need to be inlined/expanded to see their constructed product * Recording CPR on them blows up interface file sizes and is redundant with their unfolding. In case of Nested CPR, this blow-up can be quadratic! But we can't just stop giving DataCon application bindings the CPR property, for example fac 0 = 1 fac n = n * fac (n-1) fac certainly has the CPR property and should be WW'd! But FloatOut will transform the first clause to lvl = 1 fac 0 = lvl If lvl doesn't have the CPR property, fac won't either. But lvl doesn't have a CPR signature to extrapolate into a CPR transformer ('cprTransform'). So instead we keep on cprAnal'ing through *expandable* unfoldings for these arity 0 bindings via 'cprExpandUnfolding_maybe'. In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one for each data declaration. It's wasteful to attach CPR signatures to each of them (and intractable in case of Nested CPR). ``` Fixes #18154. - - - - - e34bf656 by Ben Gamari at 2020-05-13T02:07:08-04:00 users-guide: Add discussion of shared object naming Fixes #18074. - - - - - 5d0f2445 by Ben Gamari at 2020-05-13T02:07:47-04:00 testsuite: Print sign of performance changes Executes the minor formatting change in the tabulated performance changes suggested in #18135. - - - - - 9e4b981f by Ben Gamari at 2020-05-13T02:08:24-04:00 testsuite: Add testcase for #18129 - - - - - 266310c3 by Ivan-Yudin at 2020-05-13T02:09:03-04:00 doc: Reformulate the opening paragraph of Ch. 4 in User's guide Removes mentioning of Hugs (it is not helpful for new users anymore). Changes the wording for the rest of the paragraph. Fixes #18132. - - - - - 55e35c0b by Baldur Blöndal at 2020-05-13T20:02:48-04:00 Predicate, Equivalence derive via `.. -> a -> All' - - - - - d7e0b57f by Alp Mestanogullari at 2020-05-13T20:03:30-04:00 hadrian: add a --freeze2 option to freeze stage 1 and 2 - - - - - d880d6b2 by Artem Pelenitsyn at 2020-05-13T20:04:11-04:00 Don't reload environment files on every setSessionDynFlags Makes `interpretPackageEnv` (which loads envirinment files) a part of `parseDynamicFlags` (parsing command-line arguments, which is typically done once) instead of `setSessionDynFlags` (which is typically called several times). Making several (transitive) calls to `interpretPackageEnv`, as before, caused #18125 #16318, which should be fixed now. - - - - - 102cfd67 by Ryan Scott at 2020-05-13T20:04:46-04:00 Factor out HsPatSigType for pat sigs/RULE term sigs (#16762) This implements chunks (2) and (3) of https://gitlab.haskell.org/ghc/ghc/issues/16762#note_270170. Namely, it introduces a dedicated `HsPatSigType` AST type, which represents the types that can appear in pattern signatures and term-level `RULE` binders. Previously, these were represented with `LHsSigWcType`. Although `LHsSigWcType` is isomorphic to `HsPatSigType`, the intended semantics of the two types are slightly different, as evidenced by the fact that they have different code paths in the renamer and typechecker. See also the new `Note [Pattern signature binders and scoping]` in `GHC.Hs.Types`. - - - - - b17574f7 by Hécate at 2020-05-13T20:05:28-04:00 fix(documentation): Fix the RST links to GHC.Prim - - - - - df021fb1 by Baldur Blöndal at 2020-05-13T20:06:06-04:00 Document (->) using inferred quantification for its runtime representations. Fixes #18142. - - - - - 1a93ea57 by Takenobu Tani at 2020-05-13T20:06:54-04:00 Tweak man page for ghc command This commit updates the ghc command's man page as followings: * Enable `man_show_urls` to show URL addresses in the `DESCRIPTION` section of ghc.rst, because sphinx currently removes hyperlinks for man pages. * Add a `SEE ALSO` section to point to the GHC homepage - - - - - a951e1ba by Takenobu Tani at 2020-05-13T20:07:37-04:00 GHCi: Add link to the user's guide in help message This commit adds a link to the user's guide in ghci's `:help` message. Newcomers could easily reach to details of ghci. - - - - - 404581ea by Jeff Happily at 2020-05-13T20:08:15-04:00 Handle single unused import - - - - - 1c999e5d by Ben Gamari at 2020-05-13T20:09:07-04:00 Ensure that printMinimalImports closes handle Fixes #18166. - - - - - c9f5a8f4 by Ben Gamari at 2020-05-13T20:09:51-04:00 hadrian: Tell testsuite driver about LLVM availability This reflects the logic present in the Make build system into Hadrian. Fixes #18167. - - - - - c05c0659 by Simon Jakobi at 2020-05-14T03:31:21-04:00 Improve some folds over Uniq[D]FM * Replace some non-deterministic lazy folds with strict folds. * Replace some O(n log n) folds in deterministic order with O(n) non-deterministic folds. * Replace some folds with set-operations on the underlying IntMaps. This reduces max residency when compiling `nofib/spectral/simple/Main.hs` with -O0 by about 1%. Maximum residency when compiling Cabal also seems reduced on the order of 3-9%. - - - - - 477f13bb by Simon Jakobi at 2020-05-14T03:31:58-04:00 Use Data.IntMap.disjoint Data.IntMap gained a dedicated `disjoint` function in containers-0.6.2.1. This patch applies this function where appropriate in hopes of modest compiler performance improvements. Closes #16806. - - - - - e9c0110c by Ben Gamari at 2020-05-14T12:25:53-04:00 IdInfo: Add reference to bitfield-packing ticket - - - - - 9bd20e83 by Sebastian Graf at 2020-05-15T10:42:09-04:00 DmdAnal: Improve handling of precise exceptions This patch does two things: Fix possible unsoundness in what was called the "IO hack" and implement part 2.1 of the "fixing precise exceptions" plan in https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions, which, in combination with !2956, supersedes !3014 and !2525. **IO hack** The "IO hack" (which is a fallback to preserve precise exceptions semantics and thus soundness, rather than some smart thing that increases precision) is called `exprMayThrowPreciseException` now. I came up with two testcases exemplifying possible unsoundness (if twisted enough) in the old approach: - `T13380d`: Demonstrating unsoundness of the "IO hack" when resorting to manual state token threading and direct use of primops. More details below. - `T13380e`: Demonstrating unsoundness of the "IO hack" when we have Nested CPR. Not currently relevant, as we don't have Nested CPR yet. - `T13380f`: Demonstrating unsoundness of the "IO hack" for safe FFI calls. Basically, the IO hack assumed that precise exceptions can only be thrown from a case scrutinee of type `(# State# RealWorld, _ #)`. I couldn't come up with a program using the `IO` abstraction that violates this assumption. But it's easy to do so via manual state token threading and direct use of primops, see `T13380d`. Also similar code might be generated by Nested CPR in the (hopefully not too) distant future, see `T13380e`. Hence, we now have a more careful test in `forcesRealWorld` that passes `T13380{d,e}` (and will hopefully be robust to Nested CPR). **Precise exceptions** In #13380 and #17676 we saw that we didn't preserve precise exception semantics in demand analysis. We fixed that with minimal changes in !2956, but that was terribly unprincipled. That unprincipledness resulted in a loss of precision, which is tracked by these new test cases: - `T13380b`: Regression in dead code elimination, because !2956 was too syntactic about `raiseIO#` - `T13380c`: No need to apply the "IO hack" when the IO action may not throw a precise exception (and the existing IO hack doesn't detect that) Fixing both issues in !3014 turned out to be too complicated and had the potential to regress in the future. Hence we decided to only fix `T13380b` and augment the `Divergence` lattice with a new middle-layer element, `ExnOrDiv`, which means either `Diverges` (, throws an imprecise exception) or throws a *precise* exception. See the wiki page on Step 2.1 for more implementational details: https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions#dead-code-elimination-for-raiseio-with-isdeadenddiv-introducing-exnordiv-step-21 - - - - - 568d7279 by Ben Gamari at 2020-05-15T10:42:46-04:00 GHC.Cmm.Opt: Handle MO_XX_Conv This MachOp was introduced by 2c959a1894311e59cd2fd469c1967491c1e488f3 but a wildcard match in cmmMachOpFoldM hid the fact that it wasn't handled. Ideally we would eliminate the match but this appears to be a larger task. Fixes #18141. - - - - - 5bcf8606 by Ryan Scott at 2020-05-17T08:46:38-04:00 Remove duplicate Note [When to print foralls] in GHC.Core.TyCo.Ppr There are two different Notes named `[When to print foralls]`. The most up-to-date one is in `GHC.Iface.Type`, but there is a second one in `GHC.Core.TyCo.Ppr`. The latter is less up-to-date, as it was written before GHC switched over to using ifaces to pretty-print types. I decided to just remove the latter and replace it with a reference to the former. [ci skip] - - - - - 55f0e783 by Fumiaki Kinoshita at 2020-05-21T12:10:44-04:00 base: Add Generic instances to various datatypes under GHC.* * GHC.Fingerprint.Types: Fingerprint * GHC.RTS.Flags: GiveGCStats, GCFlags, ConcFlags, DebugFlags, CCFlags, DoHeapProfile, ProfFlags, DoTrace, TraceFlags, TickyFlags, ParFlags and RTSFlags * GHC.Stats: RTSStats and GCStats * GHC.ByteOrder: ByteOrder * GHC.Unicode: GeneralCategory * GHC.Stack.Types: SrcLoc Metric Increase: haddock.base - - - - - a9311cd5 by Gert-Jan Bottu at 2020-05-21T12:11:31-04:00 Explicit Specificity Implementation for Ticket #16393. Explicit specificity allows users to manually create inferred type variables, by marking them with braces. This way, the user determines which variables can be instantiated through visible type application. The additional syntax is included in the parser, allowing users to write braces in type variable binders (type signatures, data constructors etc). This information is passed along through the renamer and verified in the type checker. The AST for type variable binders, data constructors, pattern synonyms, partial signatures and Template Haskell has been updated to include the specificity of type variables. Minor notes: - Bumps haddock submodule - Disables pattern match checking in GHC.Iface.Type with GHC 8.8 - - - - - 24e61aad by Ben Price at 2020-05-21T12:12:17-04:00 Lint should say when it is checking a rule It is rather confusing that when lint finds an error in a rule attached to a binder, it reports the error as in the RHS, not the rule: ... In the RHS of foo We add a clarifying line: ... In the RHS of foo In a rule attached to foo The implication that the rule lives inside the RHS is a bit odd, but this niggle is already present for unfoldings, whose pattern we are following. - - - - - 78c6523c by Ben Gamari at 2020-05-21T12:13:01-04:00 nonmoving: Optimise the write barrier - - - - - 13f6c9d0 by Andreas Klebinger at 2020-05-21T12:13:45-04:00 Refactor linear reg alloc to remember past assignments. When assigning registers we now first try registers we assigned to in the past, instead of picking the "first" one. This is in extremely helpful when dealing with loops for which variables are dead for part of the loop. This is important for patterns like this: foo = arg1 loop: use(foo) ... foo = getVal() goto loop; There we: * assign foo to the register of arg1. * use foo, it's dead after this use as it's overwritten after. * do other things. * look for a register to put foo in. If we pick an arbitrary one it might differ from the register the start of the loop expect's foo to be in. To fix this we simply look for past register assignments for the given variable. If we find one and the register is free we use that register. This reduces the need for fixup blocks which match the register assignment between blocks. In the example above between the end and the head of the loop. This patch also moves branch weight estimation ahead of register allocation and adds a flag to control it (cmm-static-pred). * It means the linear allocator is more likely to assign the hotter code paths first. * If it assign these first we are: + Less likely to spill on the hot path. + Less likely to introduce fixup blocks on the hot path. These two measure combined are surprisingly effective. Based on nofib we get in the mean: * -0.9% instructions executed * -0.1% reads/writes * -0.2% code size. * -0.1% compiler allocations. * -0.9% compile time. * -0.8% runtime. Most of the benefits are simply a result of removing redundant moves and spills. Reduced compiler allocations likely are the result of less code being generated. (The added lookup is mostly non-allocating). - - - - - edc2cc58 by Andreas Klebinger at 2020-05-21T12:14:25-04:00 NCG: Codelayout: Distinguish conditional and other branches. In #18053 we ended up with a suboptimal code layout because the code layout algorithm didn't distinguish between conditional and unconditional control flow. We can completely eliminate unconditional control flow instructions by placing blocks next to each other, not so much for conditionals. In terms of implementation we simply give conditional branches less weight before computing the layout. Fixes #18053 - - - - - b7a6b2f4 by Gleb Popov at 2020-05-21T12:15:26-04:00 gitlab-ci: Set locale to C.UTF-8. - - - - - a8c27cf6 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow spaces in GHCi :script file names This patch updates the user interface of GHCi so that file names passed to the ':script' command may contain spaces escaped with a backslash. For example: :script foo\ bar.script The implementation uses a modified version of 'words' that does not break on escaped spaces. Fixes #18027. - - - - - 82663959 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Add extra tests for GHCi :script syntax checks The syntax for GHCi's ":script" command allows for only a single file name to be passed as an argument. This patch adds a test for the cases in which a file name is missing or multiple file names are passed. Related to #T18027. - - - - - a0b79e1b by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow GHCi :script file names in double quotes This patch updates the user interface of GHCi so that file names passed to the ':script' command can be wrapped in double quotes. For example: :script "foo bar.script" The implementation uses a modified version of 'words' that treats character sequences enclosed in double quotes as single words. Fixes #18027. - - - - - cf566330 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Update documentation for GHCi :script This patch adds the fixes that allow for file names containing spaces to be passed to GHCi's ':script' command to the release notes for 8.12 and expands the user-guide documentation for ':script' by mentioning how such file names can be passed. Related to #18027. - - - - - 0004ccb8 by Tuan Le at 2020-05-21T12:16:46-04:00 llvmGen: Consider Relocatable read-only data as not constantReferences: #18137 - - - - - 964d3ea2 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_pat` - - - - - b797aa42 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_lpat` and `tc_lpats` - - - - - 5108e84a by John Ericson at 2020-05-21T12:17:30-04:00 More judiciously panic in `ts_pat` - - - - - 510e0451 by John Ericson at 2020-05-21T12:17:30-04:00 Put `PatEnv` first in `GHC.Tc.Gen.Pat.Checker` - - - - - cb4231db by John Ericson at 2020-05-21T12:17:30-04:00 Tiny cleaup eta-reduce away a function argument In GHC, not in the code being compiled! - - - - - 6890c38d by John Ericson at 2020-05-21T12:17:30-04:00 Use braces with do in `SplicePat` case for consistency - - - - - 3451584f by buggymcbugfix at 2020-05-21T12:18:06-04:00 Fix spelling mistakes and typos - - - - - b552e531 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Add INLINABLE pragmas to Enum list producers The INLINABLE pragmas ensure that we export stable (unoptimised) unfoldings in the interface file so we can do list fusion at usage sites. Related tickets: #15185, #8763, #18178. - - - - - e7480063 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Piggyback on Enum Word methods for Word64 If we are on a 64 bit platform, we can use the efficient Enum Word methods for the Enum Word64 instance. - - - - - 892b0c41 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Document INLINE(ABLE) pragmas that enable fusion - - - - - 2b363ebb by Richard Eisenberg at 2020-05-21T12:18:45-04:00 MR template should ask for key part - - - - - a95bbd0b by Sebastian Graf at 2020-05-21T12:19:37-04:00 Make `Int`'s `mod` and `rem` strict in their first arguments They used to be strict until 4d2ac2d (9 years ago). It's obviously better to be strict for performance reasons. It also blocks #18067. NoFib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- integer -1.1% +0.4% wheel-sieve2 +21.2% +20.7% -------------------------------------------------------------------------------- Min -1.1% -0.0% Max +21.2% +20.7% Geometric Mean +0.2% +0.2% ``` The regression in `wheel-sieve2` is due to reboxing that likely will go away with the resolution of #18067. See !3282 for details. Fixes #18187. - - - - - d3d055b8 by Galen Huntington at 2020-05-21T12:20:18-04:00 Clarify pitfalls of NegativeLiterals; see #18022. - - - - - 1b508a9e by Alexey Kuleshevich at 2020-05-21T12:21:02-04:00 Fix wording in primops documentation to reflect the correct reasoning: * Besides resizing functions, shrinking ones also mutate the size of a mutable array and because of those two `sizeofMutabeByteArray` and `sizeofSmallMutableArray` are now deprecated * Change reference in documentation to the newer functions `getSizeof*` instead of `sizeof*` for shrinking functions * Fix incorrect mention of "byte" instead of "small" - - - - - 4ca0c8a1 by Andreas Klebinger at 2020-05-21T12:21:53-04:00 Don't variable-length encode magic iface constant. We changed to use variable length encodings for many types by default, including Word32. This makes sense for numbers but not when Word32 is meant to represent four bytes. I added a FixedLengthEncoding newtype to Binary who's instances interpret their argument as a collection of bytes instead of a number. We then use this when writing/reading magic numbers to the iface file. I also took the libery to remove the dummy iface field. This fixes #18180. - - - - - a1275081 by Krzysztof Gogolewski at 2020-05-21T12:22:35-04:00 Add a regression test for #11506 The testcase works now. See explanation in https://gitlab.haskell.org/ghc/ghc/issues/11506#note_273202 - - - - - 8a816e5f by Krzysztof Gogolewski at 2020-05-21T12:23:55-04:00 Sort deterministically metric output Previously, we sorted according to the test name and way, but the metrics (max_bytes_used/peak_megabytes_allocated etc.) were appearing in nondeterministic order. - - - - - 566cc73f by Sylvain Henry at 2020-05-21T12:24:45-04:00 Move isDynLinkName into GHC.Types.Name It doesn't belong into GHC.Unit.State - - - - - d830bbc9 by Adam Sandberg Ericsson at 2020-05-23T13:36:20-04:00 docs: fix formatting and add some links [skip ci] - - - - - 49301ad6 by Andrew Martin at 2020-05-23T13:37:01-04:00 Implement cstringLength# and FinalPtr This function and its accompanying rule resolve issue #5218. A future PR to the bytestring library will make the internal Data.ByteString.Internal.unsafePackAddress compute string length with cstringLength#. This will improve the status quo because it is eligible for constant folding. Additionally, introduce a new data constructor to ForeignPtrContents named FinalPtr. This additional data constructor, when used in the IsString instance for ByteString, leads to more Core-to-Core optimization opportunities, fewer runtime allocations, and smaller binaries. Also, this commit re-exports all the functions from GHC.CString (including cstringLength#) in GHC.Exts. It also adds a new test driver. This test driver is used to perform substring matches on Core that is dumped after all the simplifier passes. In this commit, it is used to check that constant folding of cstringLength# works. - - - - - dcd6bdcc by Ben Gamari at 2020-05-23T13:37:48-04:00 simplCore: Ignore ticks in rule templates This fixes #17619, where a tick snuck in to the template of a rule, resulting in a panic during rule matching. The tick in question was introduced via post-inlining, as discussed in `Note [Simplifying rules]`. The solution we decided upon was to simply ignore ticks in the rule template, as discussed in `Note [Tick annotations in RULE matching]`. Fixes #18162. Fixes #17619. - - - - - 82cb8913 by John Ericson at 2020-05-23T13:38:32-04:00 Fix #18145 and also avoid needless work with implicit vars - `forAllOrNothing` now is monadic, so we can trace whether we bind an explicit `forall` or not. - #18145 arose because the free vars calculation was needlessly complex. It is now greatly simplified. - Replaced some other implicit var code with `filterFreeVarsToBind`. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - a60dc835 by Ben Gamari at 2020-05-23T13:39:12-04:00 Bump process submodule Fixes #17926. - - - - - 856adf54 by Ben Gamari at 2020-05-23T13:40:21-04:00 users-guide: Clarify meaning of -haddock flag Fixes #18206. - - - - - 7ae57afd by Ben Gamari at 2020-05-23T13:41:03-04:00 git: Add ignored commits file This can be used to tell git to ignore bulk renaming commits like the recently-finished module hierarchy refactoring. Configured with, git config blame.ignoreRevsFile .git-ignore-revs - - - - - 63d30e60 by jneira at 2020-05-24T01:54:42-04:00 Add hie-bios script for windows systems It is a direct translation of the sh script - - - - - 59182b88 by jneira at 2020-05-24T01:54:42-04:00 Honour previous values for CABAL and CABFLAGS The immediate goal is let the hie-bios.bat script set CABFLAGS with `-v0` and remove all cabal output except the compiler arguments - - - - - 932dc54e by jneira at 2020-05-24T01:54:42-04:00 Add specific configuration for windows in hie.yaml - - - - - e0eda070 by jneira at 2020-05-24T01:54:42-04:00 Remove not needed hie-bios output - - - - - a0ea59d6 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Move Config module into GHC.Settings - - - - - 37430251 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Core.Arity into GHC.Core.Opt.Arity - - - - - a426abb9 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Hs.Types into GHC.Hs.Type See discussion in https://gitlab.haskell.org/ghc/ghc/issues/13009#note_268610 - - - - - 1c91a7a0 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Bump haddock submodule - - - - - 66bd24d1 by Ryan Scott at 2020-05-24T01:56:03-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. - - - - - 01c43634 by Matthew Pickering at 2020-05-24T01:56:42-04:00 Remove unused hs-boot file - - - - - 7a07aa71 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix cross-compiler build (#16051) - - - - - 15ccca16 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix distDir per stage - - - - - b420fb24 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix hp2ps error during cross-compilation Fixed by @alp (see https://gitlab.haskell.org/ghc/ghc/issues/16051#note_274265) - - - - - cd339ef0 by Joshua Price at 2020-05-24T15:22:56-04:00 Make Unicode brackets opening/closing tokens (#18225) The tokens `[|`, `|]`, `(|`, and `|)` are opening/closing tokens as described in GHC Proposal #229. This commit makes the unicode variants (`⟦`, `⟧`, `⦇`, and `⦈`) act the same as their ASCII counterparts. - - - - - 013d7120 by Ben Gamari at 2020-05-25T09:48:17-04:00 Revert "Specify kind variables for inferred kinds in base." As noted in !3132, this has rather severe knock-on consequences in user-code. We'll need to revisit this before merging something along these lines. This reverts commit 9749fe1223d182b1f8e7e4f7378df661c509f396. - - - - - 4c4312ed by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Drop redundant ad-hoc boot module check To determine whether the module is a boot module Coverage.addTicksToBinds was checking for a `boot` suffix in the module source filename. This is quite ad-hoc and shouldn't be necessary; the callsite in `deSugar` already checks that the module isn't a boot module. - - - - - 1abf3c84 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make tickBoxCount strict This could otherwise easily cause a leak of (+) thunks. - - - - - b2813750 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make ccIndices strict This just seems like a good idea. - - - - - 02e278eb by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Don't produce ModBreaks if not HscInterpreted emptyModBreaks contains a bottom and consequently it's important that we don't use it unless necessary. - - - - - b8c014ce by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Factor out addMixEntry - - - - - 53814a64 by Zubin Duggal at 2020-05-26T03:03:24-04:00 Add info about typeclass evidence to .hie files See `testsuite/tests/hiefile/should_run/HieQueries.hs` and `testsuite/tests/hiefile/should_run/HieQueries.stdout` for an example of this We add two new fields, `EvidenceVarBind` and `EvidenceVarUse` to the `ContextInfo` associated with an Identifier. These are associated with the appropriate identifiers for the evidence variables collected when we come across `HsWrappers`, `TcEvBinds` and `IPBinds` while traversing the AST. Instance dictionary and superclass selector dictionaries from `tcg_insts` and classes defined in `tcg_tcs` are also recorded in the AST as originating from their definition span This allows us to save a complete picture of the evidence constructed by the constraint solver, and will let us report this to the user, enabling features like going to the instance definition from the invocation of a class method(or any other method taking a constraint) and finding all usages of a particular instance. Additionally, - Mark NodeInfo with an origin so we can differentiate between bindings origininating in the source vs those in ghc - Along with typeclass evidence info, also include information on Implicit Parameters - Add a few utility functions to HieUtils in order to query the new info Updates haddock submodule - - - - - 6604906c by Sebastian Graf at 2020-05-26T03:04:04-04:00 Make WorkWrap.Lib.isWorkerSmallEnough aware of the old arity We should allow a wrapper with up to 82 parameters when the original function had 82 parameters to begin with. I verified that this made no difference on NoFib, but then again it doesn't use huge records... Fixes #18122. - - - - - cf772f19 by Sylvain Henry at 2020-05-26T03:04:45-04:00 Enhance Note [About units] for Backpack - - - - - ede24126 by Takenobu Tani at 2020-05-27T00:13:55-04:00 core-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Core.hs <= coreSyn/CoreSyn.hs * GHC/Core/Coercion.hs <= types/Coercion.hs * GHC/Core/Coercion/Axiom.hs <= types/CoAxiom.hs * GHC/Core/Coercion/Opt.hs <= types/OptCoercion.hs * GHC/Core/DataCon.hs <= basicTypes/DataCon.hs * GHC/Core/FamInstEnv.hs <= types/FamInstEnv.hs * GHC/Core/Lint.hs <= coreSyn/CoreLint.hs * GHC/Core/Subst.hs <= coreSyn/CoreSubst.hs * GHC/Core/TyCo/Rep.hs <= types/TyCoRep.hs * GHC/Core/TyCon.hs <= types/TyCon.hs * GHC/Core/Type.hs <= types/Type.hs * GHC/Core/Unify.hs <= types/Unify.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/Var.hs <= basicTypes/Var.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [skip ci] - - - - - 04750304 by Ben Gamari at 2020-05-27T00:14:33-04:00 eventlog: Fix racy flushing Previously no attempt was made to avoid multiple threads writing their capability-local eventlog buffers to the eventlog writer simultaneously. This could result in multiple eventlog streams being interleaved. Fix this by documenting that the EventLogWriter's write() and flush() functions may be called reentrantly and fix the default writer to protect its FILE* by a mutex. Fixes #18210. - - - - - d6203f24 by Joshua Price at 2020-05-27T00:15:17-04:00 Make `identifier` parse unparenthesized `->` (#18060) - - - - - 28deee28 by Ben Gamari at 2020-05-28T16:23:21-04:00 GHC.Core.Unfold: Refactor traceInline This reduces duplication as well as fixes a bug wherein -dinlining-check would override -ddump-inlinings. Moreover, the new variant - - - - - 1f393e1e by Ben Gamari at 2020-05-28T16:23:21-04:00 Avoid unnecessary allocations due to tracing utilities While ticky-profiling the typechecker I noticed that hundreds of millions of SDocs are being allocated just in case -ddump-*-trace is enabled. This is awful. We avoid this by ensuring that the dump flag check is inlined into the call site, ensuring that the tracing document needn't be allocated unless it's actually needed. See Note [INLINE conditional tracing utilities] for details. Fixes #18168. Metric Decrease: T9961 haddock.Cabal haddock.base haddock.compiler - - - - - 5f621a78 by Vladislav Zavialov at 2020-05-28T16:23:58-04:00 Add Semigroup/Monoid for Q (#18123) - - - - - dc5f004c by Xavier Denis at 2020-05-28T16:24:37-04:00 Fix #18071 Run the core linter on candidate instances to ensure they are well-kinded. Better handle quantified constraints by using a CtWanted to avoid having unsolved constraints thrown away at the end by the solver. - - - - - 10e6982c by Sebastian Graf at 2020-05-28T16:25:14-04:00 FloatOut: Only eta-expand dead-end RHS if arity will increase (#18231) Otherwise we risk turning trivial RHS into non-trivial RHS, introducing unnecessary bindings in the next Simplifier run, resulting in more churn. Fixes #18231. - - - - - 08dab5f7 by Sebastian Graf at 2020-05-28T16:25:14-04:00 DmdAnal: Recognise precise exceptions from case alternatives (#18086) Consider ```hs m :: IO () m = do putStrLn "foo" error "bar" ``` `m` (from #18086) always throws a (precise or imprecise) exception or diverges. Yet demand analysis infers `<L,A>` as demand signature instead of `<L,A>x` for it. That's because the demand analyser sees `putStrLn` occuring in a case scrutinee and decides that it has to `deferAfterPreciseException`, because `putStrLn` throws a precise exception on some control flow paths. This will mask the `botDiv` `Divergence`of the single case alt containing `error` to `topDiv`. Since `putStrLn` has `topDiv` itself, the final `Divergence` is `topDiv`. This is easily fixed: `deferAfterPreciseException` works by `lub`ing with the demand type of a virtual case branch denoting the precise exceptional control flow. We used `nopDmdType` before, but we can be more precise and use `exnDmdType`, which is `nopDmdType` with `exnDiv`. Now the `Divergence` from the case alt will degrade `botDiv` to `exnDiv` instead of `topDiv`, which combines with the result from the scrutinee to `exnDiv`, and all is well. Fixes #18086. - - - - - aef95f11 by Ben Gamari at 2020-05-28T16:25:53-04:00 Ticky-ticky: Record DataCon name in ticker name This makes it significantly easier to spot the nature of allocations regressions and comes at a reasonably low cost. - - - - - 8f021b8c by Ben Gamari at 2020-05-28T16:26:34-04:00 hadrian: Don't track GHC's verbosity argument Teach hadrian to ignore GHC's -v argument in its recompilation check, thus fixing #18131. - - - - - 13d9380b by Ben Gamari at 2020-05-28T16:27:20-04:00 Rip out CmmStackInfo(updfr_space) As noted in #18232, this field is currently completely unused and moreover doesn't have a clear meaning. - - - - - f10d11fa by Andreas Klebinger at 2020-05-29T01:38:42-04:00 Fix "build/elem" RULE. An redundant constraint prevented the rule from matching. Fixing this allows a call to elem on a known list to be translated into a series of equality checks, and eventually a simple case expression. Surprisingly this seems to regress elem for strings. To avoid this we now also allow foldrCString to inline and add an UTF8 variant. This results in elem being compiled to a tight non-allocating loop over the primitive string literal which performs a linear search. In the process this commit adds UTF8 variants for some of the functions in GHC.CString. This is required to make this work for both ASCII and UTF8 strings. There are also small tweaks to the CString related rules. We now allow ourselfes the luxury to compare the folding function via eqExpr, which helps to ensure the rule fires before we inline foldrCString*. Together with a few changes to allow matching on both the UTF8 and ASCII variants of the CString functions. - - - - - bbeb2389 by Ben Gamari at 2020-05-29T01:39:19-04:00 CoreToStg: Add Outputable ArgInfo instance - - - - - 0e3361ca by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Make Lint check return type of a join point Consider join x = rhs in body It's important that the type of 'rhs' is the same as the type of 'body', but Lint wasn't checking that invariant. Now it does! This was exposed by investigation into !3113. - - - - - c49f7df0 by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Do not float join points in exprIsConApp_maybe We hvae been making exprIsConApp_maybe cleverer in recent times: commit b78cc64e923716ac0512c299f42d4d0012306c05 Date: Thu Nov 15 17:14:31 2018 +0100 Make constructor wrappers inline only during the final phase commit 7833cf407d1f608bebb1d38bb99d3035d8d735e6 Date: Thu Jan 24 17:58:50 2019 +0100 Look through newtype wrappers (Trac #16254) commit c25b135ff5b9c69a90df0ccf51b04952c2dc6ee1 Date: Thu Feb 21 12:03:22 2019 +0000 Fix exprIsConApp_maybe But alas there was still a bug, now immortalised in Note [Don't float join points] in SimpleOpt. It's quite hard to trigger because it requires a dead join point, but it came up when compiling Cabal Cabal.Distribution.Fields.Lexer.hs, when working on !3113. Happily, the fix is extremly easy. Finding the bug was not so easy. - - - - - 46720997 by Ben Gamari at 2020-05-29T01:39:19-04:00 Allow simplification through runRW# Because runRW# inlines so late, we were previously able to do very little simplification across it. For instance, given even a simple program like case runRW# (\s -> let n = I# 42# in n) of I# n# -> f n# we previously had no way to avoid the allocation of the I#. This patch allows the simplifier to push strict contexts into the continuation of a runRW# application, as explained in in Note [Simplification of runRW#] in GHC.CoreToStg.Prep. Fixes #15127. Metric Increase: T9961 Metric Decrease: ManyConstructors Co-Authored-By: Simon Peyton-Jone <simonpj at microsoft.com> - - - - - 277c2f26 by Ben Gamari at 2020-05-29T01:39:55-04:00 Eta expand un-saturated primops Now since we no longer try to predict CAFfyness we have no need for the solution to #16846. Eta expanding unsaturated primop applications is conceptually simpler, especially in the presence of levity polymorphism. This essentially reverts cac8dc9f51e31e4c0a6cd9bc302f7e1bc7c03beb, as suggested in #18079. Closes #18079. - - - - - f44d7ae0 by Simon Jakobi at 2020-05-29T01:40:34-04:00 base: Scrap deprecation plan for Data.Monoid.{First,Last} See the discussion on the libraries mailing list for context: https://mail.haskell.org/pipermail/libraries/2020-April/030357.html - - - - - 8b494895 by Jeremy Schlatter at 2020-05-29T01:41:12-04:00 Fix typo in documentation - - - - - 998450f4 by Gleb Popov at 2020-05-29T01:41:53-04:00 Always define USE_PTHREAD_FOR_ITIMER for FreeBSD. - - - - - f9a513e0 by Alp Mestanogullari at 2020-05-29T01:42:36-04:00 hadrian: introduce 'install' target Its logic is very simple. It `need`s the `binary-dist-dir` target and runs suitable `configure` and `make install` commands for the user. A new `--prefix` command line argument is introduced to specify where GHC should be installed. - - - - - 67738db1 by Travis Whitaker at 2020-05-29T13:34:48-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. - - - - - aac19e6c by Peter Trommler at 2020-05-29T13:35:24-04:00 PPC NCG: No per-symbol .section ".toc" directives All position independent symbols are collected during code generation and emitted in one go. Prepending each symbol with a .section ".toc" directive is redundant. This patch drops the per-symbol directives leading to smaller assembler files. Fixes #18250 - - - - - 4413828b by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Teach getNumProcessors to return available processors Previously we would report the number of physical processors, which can be quite wrong in a containerized setting. Now we rather return how many processors are in our affinity mask when possible. I also refactored the code to prefer platform-specific since this will report logical CPUs instead of physical (using `machdep.cpu.thread_count` on Darwin and `cpuset_getaffinity` on FreeBSD). Fixes #14781. - - - - - 1449435c by Ben Gamari at 2020-05-30T06:07:31-04:00 users-guide: Note change in getNumProcessors in users guide - - - - - 3d960169 by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Drop compatibility shims for Windows Vista We can now assume that the thread and processor group interfaces are available. - - - - - 7f8f948c by Peter Trommler at 2020-05-30T06:08:07-04:00 PPC NCG: Fix .size directive on powerpc64 ELF v1 Thanks to Sergei Trofimovich for pointing out the issue. Fixes #18237 - - - - - 7c555b05 by Andreas Klebinger at 2020-05-30T06:08:43-04:00 Optimize GHC.Utils.Monad. Many functions in this module are recursive and as such are marked loop breakers. Which means they are unlikely to get an unfolding. This is *bad*. We always want to specialize them to specific Monads. Which requires a visible unfolding at the use site. I rewrote the recursive ones from: foo f x = ... foo x' ... to foo f x = go x where go x = ... As well as giving some pragmas to make all of them available for specialization. The end result is a reduction of allocations of about -1.4% for nofib/spectral/simple/Main.hs when compiled with `-O`. ------------------------- Metric Decrease: T12425 T14683 T5631 T9233 T9675 T9961 WWRec ------------------------- - - - - - 8b1cb5df by Ben Gamari at 2020-05-30T06:09:20-04:00 Windows: Bump Windows toolchain to 0.2 - - - - - 6947231a by Zubin Duggal at 2020-05-30T06:10:02-04:00 Simplify contexts in GHC.Iface.Ext.Ast - - - - - 2ee4f36c by Daniel Gröber at 2020-06-01T06:32:56-04:00 Cleanup OVERWRITING_CLOSURE logic The code is just more confusing than it needs to be. We don't need to mix the threaded check with the ldv profiling check since ldv's init already checks for this. Hence they can be two separate checks. Taking the sanity checking into account is also cleaner via DebugFlags.sanity. No need for checking the DEBUG define. The ZERO_SLOP_FOR_LDV_PROF and ZERO_SLOP_FOR_SANITY_CHECK definitions the old code had also make things a lot more opaque IMO so I removed those. - - - - - 6159559b by Daniel Gröber at 2020-06-01T06:32:56-04:00 Fix OVERWRITING_CLOSURE assuming closures are not inherently used The new ASSERT in LDV_recordDead() was being tripped up by MVars when removeFromMVarBlockedQueue() calls OVERWRITING_CLOSURE() via OVERWRITE_INFO(). - - - - - 38992085 by Daniel Gröber at 2020-06-01T06:32:56-04:00 Always zero shrunk mutable array slop when profiling When shrinking arrays in the profiling way we currently don't always zero the leftover slop. This means we can't traverse such closures in the heap profiler. The old Note [zeroing slop] and #8402 have some rationale for why this is so but I belive the reasoning doesn't apply to mutable closures. There users already have to ensure multiple threads don't step on each other's toes so zeroing should be safe. - - - - - b0c1f2a6 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for #18151 - - - - - 9a99a178 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for desugaring of PostfixOperators - - - - - 2b89ca5b by Ben Gamari at 2020-06-01T06:33:37-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. - - - - - d412d7a3 by Kirill Elagin at 2020-06-01T06:34:21-04:00 Winferred-safe-imports: Do not exit with error Currently, when -Winferred-safe-imports is enabled, even when it is not turned into an error, the compiler will still exit with exit code 1 if this warning was emitted. Make sure it is really treated as a warning. - - - - - f945eea5 by Ben Gamari at 2020-06-01T06:34:58-04:00 nonmoving: Optimise log2_ceil - - - - - aab606e4 by Bodigrim at 2020-06-01T06:35:36-04:00 Clarify description of fromListN - - - - - 7e5220e2 by Bodigrim at 2020-06-01T06:35:36-04:00 Apply suggestion to libraries/base/GHC/Exts.hs - - - - - f3fb1ce9 by fendor at 2020-06-01T06:36:18-04:00 Add `isInScope` check to `lintCoercion` Mirrors the behaviour of `lintType`. - - - - - 5ac4d946 by fendor at 2020-06-01T06:36:18-04:00 Lint rhs of IfaceRule - - - - - 1cef6126 by Jeremy Schlatter at 2020-06-01T06:37:00-04:00 Fix wording in documentation The duplicate "orphan instance" phrase here doesn't make sense, and was probably an accident. - - - - - 5aaf08f2 by Takenobu Tani at 2020-06-01T06:37:43-04:00 configure: Modify aclocal.m4 according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * Rename: * compiler/GHC/Parser.hs <= compiler/parser/Parser.hs * compiler/GHC/Parser/Lexer.hs <= compiler/Parser/Lexer.hs * Add: * compiler/GHC/Cmm/Lexer.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular - - - - - 15857ad8 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Don't fail if we can't unlink __symlink_test Afterall, it's possible we were unable to create it due to lack of symlink permission. - - - - - 4a7229ef by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Refactor ghostscript detection Tamar reported that he saw crashes due to unhandled exceptions. - - - - - 2ab37eaf by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/perf_notes: Fix ill-typed assignments - - - - - e45d5b66 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/testutil: Fix bytes/str mismatch - - - - - 7002d0cb by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Work around spurious mypy failure - - - - - 11390e3a by Takenobu Tani at 2020-06-01T06:39:05-04:00 Clean up file paths for new module hierarchy This updates comments only. This patch replaces file references according to new module hierarchy. See also: * https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular * https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 8f2e5732 by Takenobu Tani at 2020-06-01T06:39:05-04:00 Modify file paths to module paths for new module hierarchy This updates comments only. This patch replaces module references according to new module hierarchy [1][2]. For files under the `compiler/` directory, I replace them as module paths instead of file paths. For instance, `GHC.Unit.State` instead of `compiler/GHC/Unit/State.hs` [3]. For current and future haddock's markup, this patch encloses the module name with "" [4]. [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 [3]: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3375#note_276613 [4]: https://haskell-haddock.readthedocs.io/en/latest/markup.html#linking-to-modules - - - - - 68b71c4a by Tom Ellis at 2020-06-01T06:39:55-04:00 Rename the singleton tuple GHC.Tuple.Unit to GHC.Tuple.Solo - - - - - 95da76c2 by Sylvain Henry at 2020-06-01T06:40:41-04:00 Hadrian: fix binary-dist target for cross-compilation - - - - - 730fcd54 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for the @-operator Since GHC diverges from the Haskell Report by allowing the user to define (@) as an infix operator, we better give a good error message when the user does so unintentionally. In general, this is rather hard to do, as some failures will be discovered only in the renamer or the type checker: x :: (Integer, Integer) x @ (a, b) = (1, 2) This patch does *not* address this general case. However, it gives much better error messages when the binding is not syntactically valid: pairs xs @ (_:xs') = zip xs xs' Before this patch, the error message was rather puzzling: <interactive>:1:1: error: Parse error in pattern: pairs After this patch, the error message includes a hint: <interactive>:1:1: error: Parse error in pattern: pairs In a function binding for the ‘@’ operator. Perhaps you meant an as-pattern, which must not be surrounded by whitespace - - - - - 0fde5377 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TypeApplications With this patch, we always parse f @t as a type application, thereby producing better error messages. This steals two syntactic forms: * Prefix form of the @-operator in expressions. Since the @-operator is a divergence from the Haskell Report anyway, this is not a major loss. * Prefix form of @-patterns. Since we are stealing loose infix form anyway, might as well sacrifice the prefix form for the sake of much better error messages. - - - - - c68e7e1e by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TemplateHaskellQuotes While [e| |], [t| |], [d| |], and so on, steal syntax from list comprehensions, [| |] and [|| ||] do not steal any syntax. Thus we can improve error messages by always accepting them in the lexer. Turns out the renamer already performs necessary validation. - - - - - 120aedbd by Ben Gamari at 2020-06-01T16:07:02-04:00 gitlab-ci: Disable use of ld.lld on ARMv7 It turns out that lld non-deterministically fails on ARMv7. I suspect this may be due to the a kernel regression as this only started happening when we upgraded to 5.4. Nevertheless, easily avoided by simply sticking with gold. Works around #18280. - - - - - d6279ff0 by Ben Gamari at 2020-06-02T13:03:30-04:00 gitlab-ci: Ensure that workaround for #18280 applies to bindisttest We need to ensure that the `configure` flags working around #18280 are propagated to the bindisttest `configure` as well. - - - - - cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00 gitlab-ci: Allow ARMv7 job to fail Due to #18298. - - - - - 32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00 Clean up boot vs non-boot disambiguating types We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule. - - - - - c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00 docs: Add more details on InterruptibleFFI. Details from https://gitlab.haskell.org/ghc/ghc/issues/8684 and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430 - - - - - 1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00 Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr. MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd. This regression did not make it into a release of GHC. Here, the original behavior is restored, and FinalPtr is given the same treatment as PlainPtr. - - - - - 2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00 Fix documentation on type families not being extracted It looks like the location of the Names used for CoAxioms on type families are now located at their type constructors. Previously, Docs.hs thought the Names were located in the RHS, so the RealSrcSpan in the instanceMap and getInstLoc didn't match up. Fixes #18241 - - - - - 6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00 GHC.Hs.Instances: Compile with -O0 This module contains exclusively Data instances, which are going to be slow no matter what we do. Furthermore, they are incredibly slow to compile with optimisation (see #9557). Consequently we compile this with -O0. See #18254. - - - - - c330331a by nineonine at 2020-06-04T04:37:59-04:00 Add test for #17669 - - - - - cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00 rts: Add Windows-specific implementation of rtsSleep Previously we would use the POSIX path, which uses `nanosleep`. However, it turns out that `nanosleep` is provided by `libpthread` on Windows. In general we don't want to incur such a dependency. Avoid this by simply using `Sleep` on Windows. Fixes #18272. - - - - - ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00 compiler: Disable use of process jobs with process < 1.6.9 Due to #17926. - - - - - 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 0a5199f2 by Matthew Pickering at 2020-07-16T14:00:55-04:00 WIP: Add test for #12561 The test still fails because it needs to filter out a line which mentions a unique. - - - - - 30 changed files: - − .circleci/config.yml - − .circleci/fetch-submodules.sh - − .circleci/prepare-system.sh - − .circleci/push-test-metrics.sh - .ghcid - + .git-ignore-revs - + .gitattributes - .gitignore - .gitlab-ci.yml - + .gitlab/ci.sh - − .gitlab/darwin-init.sh - − .gitlab/fix-submodules.py - + .gitlab/issue_templates/bug.md - + .gitlab/issue_templates/documentation_issue.md - + .gitlab/issue_templates/feature_request.md - + .gitlab/linters/check-changelogs.sh - .gitlab/linters/check-cpp.py - .gitlab/linters/check-makefiles.py - + .gitlab/linters/check-version-number.sh - .gitlab/linters/linter.py - + .gitlab/merge_request_templates/backport-for-8.8.md - .gitlab/merge_request_templates/merge-request.md - − .gitlab/push-test-metrics.sh - .gitlab/start-head.hackage.sh - + .gitlab/test-metrics.sh - − .gitlab/win32-init.sh - .gitmodules - .mailmap - − ANNOUNCE - CODEOWNERS The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6d89d7d41e25c3aa7e81ec65e9262914912bbb02...0a5199f2080c6dbd92db1baafb1fa00955973a64 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6d89d7d41e25c3aa7e81ec65e9262914912bbb02...0a5199f2080c6dbd92db1baafb1fa00955973a64 You're receiving 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 Jul 16 18:11:57 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Thu, 16 Jul 2020 14:11:57 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18432-T18455 Message-ID: <5f10986d6831c_80b3f848700d4d03532933@gitlab.haskell.org.mail> Ryan Scott pushed new branch wip/T18432-T18455 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18432-T18455 You're receiving 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 Jul 16 22:11:07 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Thu, 16 Jul 2020 18:11:07 -0400 Subject: [Git][ghc/ghc][wip/derived-refactor] More wibbling and wobbling Message-ID: <5f10d07bad265_80bda8bdb435497f9@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/derived-refactor at Glasgow Haskell Compiler / GHC Commits: f680d516 by Richard Eisenberg at 2020-07-16T23:10:34+01:00 More wibbling and wobbling - - - - - 30 changed files: - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/Bind.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/FunDeps.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/GHC/ThToHs.hs - testsuite/tests/typecheck/should_compile/FloatFDs.hs - testsuite/tests/typecheck/should_compile/FunDepOrigin1.hs - + testsuite/tests/typecheck/should_compile/ImplicitParamFDs.hs - testsuite/tests/typecheck/should_compile/T12427a.stderr - testsuite/tests/typecheck/should_compile/T13651.stderr - + testsuite/tests/typecheck/should_compile/T18398.hs - + testsuite/tests/typecheck/should_compile/T18398.stderr - + testsuite/tests/typecheck/should_compile/T18406.hs - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/FunDepOrigin1b.hs - testsuite/tests/typecheck/should_fail/FunDepOrigin1b.stderr - testsuite/tests/typecheck/should_fail/T14325.stderr - testsuite/tests/typecheck/should_fail/T5300.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f680d5169610e5487c29ef9515030b77ee47f1a4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f680d5169610e5487c29ef9515030b77ee47f1a4 You're receiving 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 Jul 17 00:13:50 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 16 Jul 2020 20:13:50 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/revert-arm-symbols Message-ID: <5f10ed3ebc91c_80b3f849c221f403553948@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/revert-arm-symbols at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/revert-arm-symbols You're receiving 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 Jul 17 02:54:43 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 16 Jul 2020 22:54:43 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f1112f382848_80b3f8486fb6f7c3565810@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2410b892 by Ben Gamari at 2020-07-16T22:54:28-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - c51b1e81 by Hécate at 2020-07-16T22:54:30-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - b46834ff by Hécate at 2020-07-16T22:54:31-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - 4111ba85 by Simon Peyton Jones at 2020-07-16T22:54:32-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - 2ffccf09 by Simon Peyton Jones at 2020-07-16T22:54:32-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - ff34ad05 by Krzysztof Gogolewski at 2020-07-16T22:54:37-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - 2e48e4f3 by Simon Peyton Jones at 2020-07-16T22:54:37-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - f97f8d32 by Chaitanya Koparkar at 2020-07-16T22:54:38-04:00 Fix minor typos in a Core.hs note - - - - - 503523bd by Stefan Schulze Frielinghaus at 2020-07-16T22:54:39-04:00 GHCi: Fix isLittleEndian - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst - hadrian/hadrian.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b6ef4d2998d9fdfcdd3bf2e3c8636e9f0014932b...503523bdf2a7f72032726513e927166fd79b939a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b6ef4d2998d9fdfcdd3bf2e3c8636e9f0014932b...503523bdf2a7f72032726513e927166fd79b939a You're receiving 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 Jul 17 03:42:24 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Thu, 16 Jul 2020 23:42:24 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] :facepalm: Message-ID: <5f111e20d4de1_80b3f848700d4d03579077@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: d1ba5a23 by Moritz Angermann at 2020-07-17T03:42:13+00:00 :facepalm: - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -1403,7 +1403,7 @@ def compile_and_run__(name: TestName, if badResult(result): return result - cmd = '$TEST_WRAPPER ./' + name; + cmd = './' + name; # we don't check the compiler's stderr for a compile-and-run test return simple_run( name, way, cmd, getTestOpts().extra_run_opts ) @@ -1652,8 +1652,8 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) -> if opts.cmd_prefix is not None: cmd = opts.cmd_prefix(cmd) - else: - # (optional) 3. prefix with TEST_WRAPPER + elif not cmd.startswith("$MAKE"): + # (optional) 3. prefix with TEST_WRAPPER, unless it's a $MAKE call. # # The test wrapper. Default to $TOP / driver / id # for the identity test-wrapper. @@ -1665,7 +1665,7 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) -> else: test_wrapper = config.test_wrapper - cmd = 'TEST_WRAPPER="{test_wrapper}" && {cmd}'.format(**locals()) + cmd = 'TEST_WRAPPER="{test_wrapper}" && $TEST_WRAPPER {cmd}'.format(**locals()) # 4. Apply cmd_wrapper if set. if opts.cmd_wrapper is not None: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1ba5a23bde487857d025d729954efe9795b01fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1ba5a23bde487857d025d729954efe9795b01fa You're receiving 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 Jul 17 06:09:41 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 17 Jul 2020 02:09:41 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] :fire: Message-ID: <5f1140a5649ce_80bda8bdb43586066@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: a7a75a37 by Moritz Angermann at 2020-07-17T06:09:28+00:00 :fire: - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -1652,8 +1652,8 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) -> if opts.cmd_prefix is not None: cmd = opts.cmd_prefix(cmd) - elif not cmd.startswith("$MAKE"): - # (optional) 3. prefix with TEST_WRAPPER, unless it's a $MAKE call. + else: + # (optional) 3. Add TEST_WRAPPER environment variable. # # The test wrapper. Default to $TOP / driver / id # for the identity test-wrapper. @@ -1665,7 +1665,15 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) -> else: test_wrapper = config.test_wrapper - cmd = 'TEST_WRAPPER="{test_wrapper}" && $TEST_WRAPPER {cmd}'.format(**locals()) + # if cmd looks like we want to execute something, run it through + # the command wrapper. + if cmd.startswith("./"): + # we don't need to prefix cmd with anything if there is no + # test wrapper. + if config.test_wrapper is not None: + cmd = "{test_wrapper} {cmd}".format(**locals()) + else: + cmd = 'TEST_WRAPPER="{test_wrapper}" && {cmd}'.format(**locals()) # 4. Apply cmd_wrapper if set. if opts.cmd_wrapper is not None: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a7a75a370c3496197aeea7ff926fa2a765791765 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a7a75a370c3496197aeea7ff926fa2a765791765 You're receiving 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 Jul 17 10:25:11 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 17 Jul 2020 06:25:11 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f117c878e24a_80bda8bdb436306a1@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5ebedd54 by Ben Gamari at 2020-07-17T06:25:01-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - d8043547 by Hécate at 2020-07-17T06:25:03-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - 8b18ad12 by Hécate at 2020-07-17T06:25:03-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - 96f8ab48 by Simon Peyton Jones at 2020-07-17T06:25:04-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - 8dc1f539 by Simon Peyton Jones at 2020-07-17T06:25:04-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 7421f3f1 by Krzysztof Gogolewski at 2020-07-17T06:25:06-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - cfd5c37a by Simon Peyton Jones at 2020-07-17T06:25:06-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - a853f4d2 by Chaitanya Koparkar at 2020-07-17T06:25:07-04:00 Fix minor typos in a Core.hs note - - - - - 3bf55ef1 by Stefan Schulze Frielinghaus at 2020-07-17T06:25:08-04:00 GHCi: Fix isLittleEndian - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst - hadrian/hadrian.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/503523bdf2a7f72032726513e927166fd79b939a...3bf55ef1d2ee6503eb1238dc2051ae7b55afca69 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/503523bdf2a7f72032726513e927166fd79b939a...3bf55ef1d2ee6503eb1238dc2051ae7b55afca69 You're receiving 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 Jul 17 10:48:30 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 17 Jul 2020 06:48:30 -0400 Subject: [Git][ghc/ghc][wip/T18126] 121 commits: Bump Cabal submodule Message-ID: <5f1181fe44afc_80b3f848700d4d0365202f@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 4d12071a by Simon Peyton Jones at 2020-07-17T11:48:07+01:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity, sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to a new module GHC.Tc.Gen.App which deals with typechecking n-ary applications. It contains a good deal of documentation. Two other loosely-related change is in this patch: * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. NB: This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just maed T7861 into expect_broken(18467) - - - - - 336abb3b by Simon Peyton Jones at 2020-07-17T11:48:07+01:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typeecheck/polykinds/T16245a - - - - - 23 changed files: - Makefile - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Info.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Hole.hs - + compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Default.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca6505d4b811b4cb95344ebdc420876000b7a518...336abb3b900b755fe2b97a48995699598547de49 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca6505d4b811b4cb95344ebdc420876000b7a518...336abb3b900b755fe2b97a48995699598547de49 You're receiving 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 Jul 17 12:26:55 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 17 Jul 2020 08:26:55 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/angerman/revert-symbols Message-ID: <5f11990f8945d_80b3f848709719436719c3@gitlab.haskell.org.mail> Moritz Angermann pushed new branch wip/angerman/revert-symbols at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/angerman/revert-symbols You're receiving 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 Jul 17 12:28:46 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Fri, 17 Jul 2020 08:28:46 -0400 Subject: [Git][ghc/ghc][wip/T18432-T18455] Clean up the inferred type variable restriction Message-ID: <5f11997ed093c_80b3f848700d4d03673524@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18432-T18455 at Glasgow Haskell Compiler / GHC Commits: 360112d8 by Ryan Scott at 2020-07-17T08:26:08-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - 14 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - + testsuite/tests/quantified-constraints/T18432.hs - testsuite/tests/quantified-constraints/all.T - testsuite/tests/typecheck/should_fail/ExplicitSpecificity4.hs → testsuite/tests/typecheck/should_compile/ExplicitSpecificity4.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T18455.hs - + testsuite/tests/typecheck/should_fail/T18455.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1628,6 +1628,12 @@ instance types, which makes things like the instance above become illegal. For the sake of consistency, we also disallow nested contexts, even though they don't have the same strange interaction with ScopedTypeVariables. +Just as we forbid nested `forall`s and contexts in normal instance +declarations, we also forbid them in SPECIALISE instance pragmas (#18455). +Unlike normal instance declarations, ScopedTypeVariables don't have any impact +on SPECIALISE instance pragmas, but we use the same validity checks for +SPECIALISE instance pragmas anyway to be consistent. + ----- -- Wrinkle: Derived instances ----- ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -43,7 +43,8 @@ import GHC.Rename.Fixity import GHC.Rename.Utils ( HsDocContext(..), mapFvRn, extendTyVarEnvFVRn , checkDupRdrNames, warnUnusedLocalBinds , checkUnusedRecordWildcard - , checkDupAndShadowedNames, bindLocalNamesFV ) + , checkDupAndShadowedNames, bindLocalNamesFV + , addNoNestedForallsContextsErr, checkInferredVars ) import GHC.Driver.Session import GHC.Unit.Module import GHC.Types.Name @@ -955,7 +956,7 @@ renameSig _ (IdSig _ x) renameSig ctxt sig@(TypeSig _ vs ty) = do { new_vs <- mapM (lookupSigOccRn ctxt sig) vs ; let doc = TypeSigCtx (ppr_sig_bndrs vs) - ; (new_ty, fvs) <- rnHsSigWcType doc Nothing ty + ; (new_ty, fvs) <- rnHsSigWcType doc ty ; return (TypeSig noExtField new_vs new_ty, fvs) } renameSig ctxt sig@(ClassOpSig _ is_deflt vs ty) @@ -963,20 +964,25 @@ renameSig ctxt sig@(ClassOpSig _ is_deflt vs ty) ; when (is_deflt && not defaultSigs_on) $ addErr (defaultSigErr sig) ; new_v <- mapM (lookupSigOccRn ctxt sig) vs - ; (new_ty, fvs) <- rnHsSigType ty_ctxt TypeLevel inf_msg ty + ; (new_ty, fvs) <- rnHsSigType ty_ctxt TypeLevel ty ; return (ClassOpSig noExtField is_deflt new_v new_ty, fvs) } where (v1:_) = vs ty_ctxt = GenericCtx (text "a class method signature for" <+> quotes (ppr v1)) - inf_msg = if is_deflt - then Just (text "A default type signature cannot contain inferred type variables") - else Nothing renameSig _ (SpecInstSig _ src ty) - = do { (new_ty, fvs) <- rnHsSigType SpecInstSigCtx TypeLevel inf_msg ty + = do { checkInferredVars doc inf_msg ty + ; (new_ty, fvs) <- rnHsSigType doc TypeLevel ty + -- Check if there are any nested `forall`s or contexts, which are + -- illegal in the type of an instance declaration (see + -- Note [No nested foralls or contexts in instance types] in + -- GHC.Hs.Type). + ; addNoNestedForallsContextsErr doc (text "SPECIALISE instance type") + (getLHsInstDeclHead new_ty) ; return (SpecInstSig noExtField src new_ty,fvs) } where + doc = SpecInstSigCtx inf_msg = Just (text "Inferred type variables are not allowed") -- {-# SPECIALISE #-} pragmas can refer to imported Ids @@ -993,7 +999,7 @@ renameSig ctxt sig@(SpecSig _ v tys inl) ty_ctxt = GenericCtx (text "a SPECIALISE signature for" <+> quotes (ppr v)) do_one (tys,fvs) ty - = do { (new_ty, fvs_ty) <- rnHsSigType ty_ctxt TypeLevel Nothing ty + = do { (new_ty, fvs_ty) <- rnHsSigType ty_ctxt TypeLevel ty ; return ( new_ty:tys, fvs_ty `plusFV` fvs) } renameSig ctxt sig@(InlineSig _ v s) @@ -1010,7 +1016,7 @@ renameSig ctxt sig@(MinimalSig _ s (L l bf)) renameSig ctxt sig@(PatSynSig _ vs ty) = do { new_vs <- mapM (lookupSigOccRn ctxt sig) vs - ; (ty', fvs) <- rnHsSigType ty_ctxt TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType ty_ctxt TypeLevel ty ; return (PatSynSig noExtField new_vs ty', fvs) } where ty_ctxt = GenericCtx (text "a pattern synonym signature for" ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -318,7 +318,7 @@ rnExpr (RecordUpd { rupd_expr = expr, rupd_flds = rbinds }) , fvExpr `plusFV` fvRbinds) } rnExpr (ExprWithTySig _ expr pty) - = do { (pty', fvTy) <- rnHsSigWcType ExprWithTySigCtx Nothing pty + = do { (pty', fvTy) <- rnHsSigWcType ExprWithTySigCtx pty ; (expr', fvExpr) <- bindSigTyVarsFV (hsWcScopedTvs pty') $ rnLExpr expr ; return (ExprWithTySig noExtField expr' pty', fvExpr `plusFV` fvTy) } ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -39,7 +39,6 @@ import GHC.Prelude import {-# SOURCE #-} GHC.Rename.Splice( rnSpliceType ) -import GHC.Core.Type import GHC.Driver.Session import GHC.Hs import GHC.Rename.Doc ( rnLHsDoc, rnMbLHsDoc ) @@ -68,7 +67,7 @@ import GHC.Data.FastString import GHC.Data.Maybe import qualified GHC.LanguageExtensions as LangExt -import Data.List ( nubBy, partition, find ) +import Data.List ( nubBy, partition ) import Control.Monad ( unless, when ) #include "HsVersions.h" @@ -124,19 +123,16 @@ data HsSigWcTypeScoping -- "GHC.Hs.Type". rnHsSigWcType :: HsDocContext - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. -> LHsSigWcType GhcPs -> RnM (LHsSigWcType GhcRn, FreeVars) -rnHsSigWcType doc inf_err (HsWC { hswc_body = HsIB { hsib_body = hs_ty }}) - = rn_hs_sig_wc_type BindUnlessForall doc inf_err hs_ty $ \nwcs imp_tvs body -> +rnHsSigWcType doc (HsWC { hswc_body = HsIB { hsib_body = hs_ty }}) + = rn_hs_sig_wc_type BindUnlessForall doc hs_ty $ \nwcs imp_tvs body -> let ib_ty = HsIB { hsib_ext = imp_tvs, hsib_body = body } wc_ty = HsWC { hswc_ext = nwcs, hswc_body = ib_ty } in pure (wc_ty, emptyFVs) rnHsPatSigType :: HsSigWcTypeScoping - -> HsDocContext -> Maybe SDoc + -> HsDocContext -> HsPatSigType GhcPs -> (HsPatSigType GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) @@ -147,10 +143,10 @@ rnHsPatSigType :: HsSigWcTypeScoping -- Wildcards are allowed -- -- See Note [Pattern signature binders and scoping] in GHC.Hs.Type -rnHsPatSigType scoping ctx inf_err sig_ty thing_inside +rnHsPatSigType scoping ctx sig_ty thing_inside = do { ty_sig_okay <- xoptM LangExt.ScopedTypeVariables ; checkErr ty_sig_okay (unexpectedPatSigTypeErr sig_ty) - ; rn_hs_sig_wc_type scoping ctx inf_err (hsPatSigType sig_ty) $ + ; rn_hs_sig_wc_type scoping ctx (hsPatSigType sig_ty) $ \nwcs imp_tvs body -> do { let sig_names = HsPSRn { hsps_nwcs = nwcs, hsps_imp_tvs = imp_tvs } sig_ty' = HsPS { hsps_ext = sig_names, hsps_body = body } @@ -158,16 +154,15 @@ rnHsPatSigType scoping ctx inf_err sig_ty thing_inside } } -- The workhorse for rnHsSigWcType and rnHsPatSigType. -rn_hs_sig_wc_type :: HsSigWcTypeScoping -> HsDocContext -> Maybe SDoc +rn_hs_sig_wc_type :: HsSigWcTypeScoping -> HsDocContext -> LHsType GhcPs -> ([Name] -- Wildcard names -> [Name] -- Implicitly bound type variable names -> LHsType GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) -rn_hs_sig_wc_type scoping ctxt inf_err hs_ty thing_inside - = do { check_inferred_vars ctxt inf_err hs_ty - ; free_vars <- filterInScopeM (extractHsTyRdrTyVars hs_ty) +rn_hs_sig_wc_type scoping ctxt hs_ty thing_inside + = do { free_vars <- filterInScopeM (extractHsTyRdrTyVars hs_ty) ; (nwc_rdrs', tv_rdrs) <- partition_nwcs free_vars ; let nwc_rdrs = nubL nwc_rdrs' ; implicit_bndrs <- case scoping of @@ -318,17 +313,13 @@ of the HsWildCardBndrs structure, and we are done. rnHsSigType :: HsDocContext -> TypeOrKind - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. -> LHsSigType GhcPs -> RnM (LHsSigType GhcRn, FreeVars) -- Used for source-language type signatures -- that cannot have wildcards -rnHsSigType ctx level inf_err (HsIB { hsib_body = hs_ty }) +rnHsSigType ctx level (HsIB { hsib_body = hs_ty }) = do { traceRn "rnHsSigType" (ppr hs_ty) ; rdr_env <- getLocalRdrEnv - ; check_inferred_vars ctx inf_err hs_ty ; vars0 <- forAllOrNothing (isLHsForAllTy hs_ty) $ filterInScope rdr_env $ extractHsTyRdrTyVars hs_ty @@ -415,26 +406,6 @@ type signature, since the type signature implicitly carries their binding sites. This is less precise, but more accurate. -} -check_inferred_vars :: HsDocContext - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. - -> LHsType GhcPs - -> RnM () -check_inferred_vars _ Nothing _ = return () -check_inferred_vars ctxt (Just msg) ty = - let bndrs = forallty_bndrs ty - in case find ((==) InferredSpec . hsTyVarBndrFlag) bndrs of - Nothing -> return () - Just _ -> addErr $ withHsDocContext ctxt msg - where - forallty_bndrs :: LHsType GhcPs -> [HsTyVarBndr Specificity GhcPs] - forallty_bndrs (L _ ty) = case ty of - HsParTy _ ty' -> forallty_bndrs ty' - HsForAllTy { hst_tele = HsForAllInvis { hsf_invis_bndrs = tvs }} - -> map unLoc tvs - _ -> [] - {- ****************************************************** * * LHsType and HsType ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -34,7 +34,8 @@ import GHC.Rename.Utils ( HsDocContext(..), mapFvRn, bindLocalNames , checkDupRdrNames, bindLocalNamesFV , checkShadowedRdrNames, warnUnusedTypePatterns , extendTyVarEnvFVRn, newLocalBndrsRn - , withHsDocContext ) + , withHsDocContext, noNestedForallsContextsErr + , addNoNestedForallsContextsErr, checkInferredVars ) import GHC.Rename.Unbound ( mkUnboundName, notInScopeErr ) import GHC.Rename.Names import GHC.Rename.Doc ( rnHsDoc, rnMbLHsDoc ) @@ -65,7 +66,6 @@ import GHC.Data.List.SetOps ( findDupsEq, removeDups, equivClasses ) import GHC.Data.Graph.Directed ( SCC, flattenSCC, flattenSCCs, Node(..) , stronglyConnCompFromEdgedVerticesUniq ) import GHC.Types.Unique.Set -import GHC.Data.Maybe ( whenIsJust ) import GHC.Data.OrdList import qualified GHC.LanguageExtensions as LangExt @@ -371,7 +371,7 @@ rnHsForeignDecl :: ForeignDecl GhcPs -> RnM (ForeignDecl GhcRn, FreeVars) rnHsForeignDecl (ForeignImport { fd_name = name, fd_sig_ty = ty, fd_fi = spec }) = do { topEnv :: HscEnv <- getTopEnv ; name' <- lookupLocatedTopBndrRn name - ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel ty -- Mark any PackageTarget style imports as coming from the current package ; let unitId = homeUnit $ hsc_dflags topEnv @@ -383,7 +383,7 @@ rnHsForeignDecl (ForeignImport { fd_name = name, fd_sig_ty = ty, fd_fi = spec }) rnHsForeignDecl (ForeignExport { fd_name = name, fd_sig_ty = ty, fd_fe = spec }) = do { name' <- lookupLocatedOccRn name - ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel ty ; return (ForeignExport { fd_e_ext = noExtField , fd_name = name', fd_sig_ty = ty' , fd_fe = spec } @@ -602,13 +602,14 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds , cid_sigs = uprags, cid_tyfam_insts = ats , cid_overlap_mode = oflag , cid_datafam_insts = adts }) - = do { (inst_ty', inst_fvs) <- rnHsSigType ctxt TypeLevel inf_err inst_ty + = do { checkInferredVars ctxt inf_err inst_ty + ; (inst_ty', inst_fvs) <- rnHsSigType ctxt TypeLevel inst_ty ; let (ktv_names, _, head_ty') = splitLHsInstDeclTy inst_ty' -- Check if there are any nested `forall`s or contexts, which are -- illegal in the type of an instance declaration (see -- Note [No nested foralls or contexts in instance types] in -- GHC.Hs.Type)... - mb_nested_msg = no_nested_foralls_contexts_err + mb_nested_msg = noNestedForallsContextsErr (text "Instance head") head_ty' -- ...then check if the instance head is actually headed by a -- class type constructor... @@ -1010,22 +1011,22 @@ rnSrcDerivDecl :: DerivDecl GhcPs -> RnM (DerivDecl GhcRn, FreeVars) rnSrcDerivDecl (DerivDecl _ ty mds overlap) = do { standalone_deriv_ok <- xoptM LangExt.StandaloneDeriving ; unless standalone_deriv_ok (addErr standaloneDerivErr) - ; (mds', ty', fvs) - <- rnLDerivStrategy ctxt mds $ rnHsSigWcType ctxt inf_err ty + ; checkInferredVars ctxt inf_err nowc_ty + ; (mds', ty', fvs) <- rnLDerivStrategy ctxt mds $ rnHsSigWcType ctxt ty -- Check if there are any nested `forall`s or contexts, which are -- illegal in the type of an instance declaration (see -- Note [No nested foralls or contexts in instance types] in -- GHC.Hs.Type). - ; whenIsJust (no_nested_foralls_contexts_err - (text "Standalone-derived instance head") - (getLHsInstDeclHead $ dropWildCards ty')) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext ctxt err_msg + ; addNoNestedForallsContextsErr ctxt + (text "Standalone-derived instance head") + (getLHsInstDeclHead $ dropWildCards ty') ; warnNoDerivStrat mds' loc ; return (DerivDecl noExtField ty' mds' overlap, fvs) } where ctxt = DerivDeclCtx inf_err = Just (text "Inferred type variables are not allowed") - loc = getLoc $ hsib_body $ hswc_body ty + loc = getLoc $ hsib_body nowc_ty + nowc_ty = dropWildCards ty standaloneDerivErr :: SDoc standaloneDerivErr @@ -1091,7 +1092,7 @@ bindRuleTmVars doc tyvs vars names thing_inside go ((L l (RuleBndrSig _ (L loc _) bsig)) : vars) (n : ns) thing_inside - = rnHsPatSigType bind_free_tvs doc Nothing bsig $ \ bsig' -> + = rnHsPatSigType bind_free_tvs doc bsig $ \ bsig' -> go vars ns $ \ vars' -> thing_inside (L l (RuleBndrSig noExtField (L loc n) bsig') : vars') @@ -1431,7 +1432,7 @@ rnStandaloneKindSignature tc_names (StandaloneKindSig _ v ki) ; unless standalone_ki_sig_ok $ addErr standaloneKiSigErr ; new_v <- lookupSigCtxtOccRn (TopSigCtxt tc_names) (text "standalone kind signature") v ; let doc = StandaloneKindSigCtx (ppr v) - ; (new_ki, fvs) <- rnHsSigType doc KindLevel Nothing ki + ; (new_ki, fvs) <- rnHsSigType doc KindLevel ki ; return (StandaloneKindSig noExtField new_v new_ki, fvs) } where @@ -1841,15 +1842,14 @@ rnLHsDerivingClause doc rn_clause_pred :: LHsSigType GhcPs -> RnM (LHsSigType GhcRn, FreeVars) rn_clause_pred pred_ty = do let inf_err = Just (text "Inferred type variables are not allowed") - ret@(pred_ty', _) <- rnHsSigType doc TypeLevel inf_err pred_ty + checkInferredVars doc inf_err pred_ty + ret@(pred_ty', _) <- rnHsSigType doc TypeLevel pred_ty -- Check if there are any nested `forall`s, which are illegal in a -- `deriving` clause. -- See Note [No nested foralls or contexts in instance types] -- (Wrinkle: Derived instances) in GHC.Hs.Type. - whenIsJust (no_nested_foralls_contexts_err - (text "Derived class type") - (getLHsInstDeclHead pred_ty')) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext doc err_msg + addNoNestedForallsContextsErr doc (text "Derived class type") + (getLHsInstDeclHead pred_ty') pure ret rnLDerivStrategy :: forall a. @@ -1883,7 +1883,8 @@ rnLDerivStrategy doc mds thing_inside AnyclassStrategy -> boring_case AnyclassStrategy NewtypeStrategy -> boring_case NewtypeStrategy ViaStrategy via_ty -> - do (via_ty', fvs1) <- rnHsSigType doc TypeLevel inf_err via_ty + do checkInferredVars doc inf_err via_ty + (via_ty', fvs1) <- rnHsSigType doc TypeLevel via_ty let HsIB { hsib_ext = via_imp_tvs , hsib_body = via_body } = via_ty' (via_exp_tv_bndrs, via_rho) = splitLHsForAllTyInvis_KP via_body @@ -1893,10 +1894,8 @@ rnLDerivStrategy doc mds thing_inside -- `via` type. -- See Note [No nested foralls or contexts in instance types] -- (Wrinkle: Derived instances) in GHC.Hs.Type. - whenIsJust (no_nested_foralls_contexts_err - (quotes (text "via") <+> text "type") - via_rho) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext doc err_msg + addNoNestedForallsContextsErr doc + (quotes (text "via") <+> text "type") via_rho (thing, fvs2) <- extendTyVarEnvFVRn via_tvs thing_inside pure (ViaStrategy via_ty', thing, fvs1 `plusFV` fvs2) @@ -2211,7 +2210,7 @@ rnConDecl (XConDecl (ConDeclGADTPrefixPs { con_gp_names = names, con_gp_ty = ty ; mb_doc' <- rnMbLHsDoc mb_doc ; let ctxt = ConDeclCtx new_names - ; (ty', fvs) <- rnHsSigType ctxt TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType ctxt TypeLevel ty ; linearTypes <- xopt LangExt.LinearTypes <$> getDynFlags -- Now that operator precedence has been resolved, we can split the @@ -2230,10 +2229,8 @@ rnConDecl (XConDecl (ConDeclGADTPrefixPs { con_gp_names = names, con_gp_ty = ty -- Ensure that there are no nested `forall`s or contexts, per -- Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts) -- in GHC.Hs.Type. - ; whenIsJust (no_nested_foralls_contexts_err - (text "GADT constructor type signature") - res_ty) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext ctxt err_msg + ; addNoNestedForallsContextsErr ctxt + (text "GADT constructor type signature") res_ty ; traceRn "rnConDecl (ConDeclGADTPrefixPs)" (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) @@ -2271,41 +2268,6 @@ rnConDeclDetails con doc (RecCon (L l fields)) -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn ; return (RecCon (L l new_fields), fvs) } --- | Examines a non-outermost type for @forall at s or contexts, which are assumed --- to be nested. Returns @'Just' err_msg@ if such a @forall@ or context is --- found, and returns @Nothing@ otherwise. --- --- This is currently used in two places: --- --- * In GADT constructor types (in 'rnConDecl'). --- See @Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts)@ --- in "GHC.Hs.Type". --- --- * In instance declaration types (in 'rnClsIntDecl' and 'rnSrcDerivDecl'). --- See @Note [No nested foralls or contexts in instance types]@ in --- "GHC.Hs.Type". -no_nested_foralls_contexts_err :: SDoc -> LHsType GhcRn -> Maybe (SrcSpan, SDoc) -no_nested_foralls_contexts_err what lty = - case ignoreParens lty of - L l (HsForAllTy { hst_tele = tele }) - | HsForAllVis{} <- tele - -- The only two places where this function is called correspond to - -- types of terms, so we give a slightly more descriptive error - -- message in the event that they contain visible dependent - -- quantification (currently only allowed in kinds). - -> Just (l, vcat [ text "Illegal visible, dependent quantification" <+> - text "in the type of a term" - , text "(GHC does not yet support this)" ]) - | HsForAllInvis{} <- tele - -> Just (l, nested_foralls_contexts_err) - L l (HsQualTy {}) - -> Just (l, nested_foralls_contexts_err) - _ -> Nothing - where - nested_foralls_contexts_err = - what <+> text "cannot contain nested" - <+> quotes forAllLit <> text "s or contexts" - ------------------------------------------------- -- | Brings pattern synonym names and also pattern synonym selectors ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -412,7 +412,7 @@ rnPatAndThen mk (SigPat x pat sig) ; return (SigPat x pat' sig' ) } where rnHsPatSigTypeAndThen :: HsPatSigType GhcPs -> CpsRn (HsPatSigType GhcRn) - rnHsPatSigTypeAndThen sig = CpsRn (rnHsPatSigType AlwaysBind PatCtx Nothing sig) + rnHsPatSigTypeAndThen sig = CpsRn (rnHsPatSigType AlwaysBind PatCtx sig) rnPatAndThen mk (LitPat x lit) | HsString src s <- lit ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -26,8 +26,10 @@ module GHC.Rename.Utils ( bindLocalNames, bindLocalNamesFV, - addNameClashErrRn, extendTyVarEnvFVRn + addNameClashErrRn, extendTyVarEnvFVRn, + checkInferredVars, + noNestedForallsContextsErr, addNoNestedForallsContextsErr ) where @@ -35,6 +37,7 @@ where import GHC.Prelude +import GHC.Core.Type import GHC.Hs import GHC.Types.Name.Reader import GHC.Driver.Types @@ -49,6 +52,7 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Types.Basic ( TopLevelFlag(..) ) import GHC.Data.List.SetOps ( removeDups ) +import GHC.Data.Maybe ( whenIsJust ) import GHC.Driver.Session import GHC.Data.FastString import Control.Monad @@ -176,6 +180,137 @@ checkShadowedOccs (global_env,local_env) get_loc_occ ns || xopt LangExt.RecordWildCards dflags) } is_shadowed_gre _other = return True +------------------------------------- +-- | Throw an error message if a user attempts to quantify an inferred type +-- variable in a place where specificity cannot be observed. +-- See @Note [Unobservably inferred type variables]@. +checkInferredVars :: HsDocContext + -> Maybe SDoc + -- ^ The error msg if the signature is not allowed to contain + -- manually written inferred variables. + -> LHsSigType GhcPs + -> RnM () +checkInferredVars _ Nothing _ = return () +checkInferredVars ctxt (Just msg) ty = + let bndrs = forallty_bndrs (hsSigType ty) + in case find ((==) InferredSpec . hsTyVarBndrFlag) bndrs of + Nothing -> return () + Just _ -> addErr $ withHsDocContext ctxt msg + where + forallty_bndrs :: LHsType GhcPs -> [HsTyVarBndr Specificity GhcPs] + forallty_bndrs (L _ ty) = case ty of + HsParTy _ ty' -> forallty_bndrs ty' + HsForAllTy { hst_tele = HsForAllInvis { hsf_invis_bndrs = tvs }} + -> map unLoc tvs + _ -> [] + +{- +Note [Unobservably inferred type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +While GHC's parser allows the use of inferred type variables +(e.g., `forall {a}. <...>`) just about anywhere that type variable binders can +appear, there are some situations where the distinction between inferred and +specified type variables cannot be observed. For example, consider this +instance declaration: + + instance forall {a}. Eq (T a) where ... + +Making {a} inferred is essentially pointless, as there is no way for user code +to "apply" an instance declaration in a way where the inferred/specified +distinction would make a difference. Anyone who writes such code is likely +confused, so in an attempt to be helpful, we throw an error message if a user +writes code like this. The checkInferredVars function is responsible for +implementing this restriction. + +It turns out to be somewhat cumbersome to enforce this restriction in certain +cases. Ultimately, nothing goes wrong if this restriction is *not* enforced (as +it is simply a suggestion to the user to think twice about how they quantify +their type variables), so we only use checkInferredVars in places where it is +feasible to do so. Two examples of places where it is *not* feasible are: + +* Quantified constraints. In the type `f :: (forall {a}. C a) => Proxy Int`, + there is no way to observe that {a} is inferred. Nevertheless, actually + rejecting this code would be tricky, as we would need to reject + `forall {a}. <...>` as a constraint but *accept* other uses of + `forall {a}. <...>` as a type (e.g., `g :: (forall {a}. a -> a) -> b -> b`). + This is quite tedious to do in practice, so we don't bother. +* Default method type signatures (#18432). These are tricky because inferred + type variables can appear nested, e.g., + + class C a where + m :: forall b. a -> b -> forall c. c -> c + default m :: forall b. a -> b -> forall {c}. c -> c + m _ _ = id + + Robustly checking for nested, inferred type variables ends up being a pain, + so we don't try to do this. + +Since nested type variables are a pain, one might wonder if they end up being +painful for other places where we *do* enforce this restriction. The answer is +"no", as it turns out. This is because in every other place where the +restriction is enforced, GHC bans the use of nested `forall`s already. For +example, GHC would not accept the following: + + instance forall a. forall {b}. Eq (Either a b) where ... + +The fact that GHC does not permit nested `forall`s there is a bit of a +coincidence (see Note [No nested foralls or contexts in instance types] in +GHC.Hs.Type). But is sure is a useful coincidence, and one that we take +advantage of. Because nested `forall`s are banned, checking for inferred +type variables in instance declarations is as simple as peeling off the +outer `forall`s and checking if any of them are inferred. +-} + +-- | Examines a non-outermost type for @forall at s or contexts, which are assumed +-- to be nested. For example, in the following declaration: +-- +-- @ +-- instance forall a. forall b. C (Either a b) +-- @ +-- +-- The outermost @forall a@ is fine, but the nested @forall b@ is not. We +-- invoke 'noNestedForallsContextsErr' on the type @forall b. C (Either a b)@ +-- to catch the nested @forall@ and create a suitable error message. +-- 'noNestedForallsContextsErr' returns @'Just' err_msg@ if such a @forall@ or +-- context is found, and returns @Nothing@ otherwise. +-- +-- This is currently used in the following places: +-- +-- * In GADT constructor types (in 'rnConDecl'). +-- See @Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts)@ +-- in "GHC.Hs.Type". +-- +-- * In instance declaration types (in 'rnClsIntDecl' and 'rnSrcDerivDecl' in +-- "GHC.Rename.Module" and 'renameSig' in "GHC.Rename.Bind"). +-- See @Note [No nested foralls or contexts in instance types]@ in +-- "GHC.Hs.Type". +noNestedForallsContextsErr :: SDoc -> LHsType GhcRn -> Maybe (SrcSpan, SDoc) +noNestedForallsContextsErr what lty = + case ignoreParens lty of + L l (HsForAllTy { hst_tele = tele }) + | HsForAllVis{} <- tele + -- The only two places where this function is called correspond to + -- types of terms, so we give a slightly more descriptive error + -- message in the event that they contain visible dependent + -- quantification (currently only allowed in kinds). + -> Just (l, vcat [ text "Illegal visible, dependent quantification" <+> + text "in the type of a term" + , text "(GHC does not yet support this)" ]) + | HsForAllInvis{} <- tele + -> Just (l, nested_foralls_contexts_err) + L l (HsQualTy {}) + -> Just (l, nested_foralls_contexts_err) + _ -> Nothing + where + nested_foralls_contexts_err = + what <+> text "cannot contain nested" + <+> quotes forAllLit <> text "s or contexts" + +-- | A common way to invoke 'noNestedForallsContextsErr'. +addNoNestedForallsContextsErr :: HsDocContext -> SDoc -> LHsType GhcRn -> RnM () +addNoNestedForallsContextsErr ctxt what lty = + whenIsJust (noNestedForallsContextsErr what lty) $ \(l, err_msg) -> + addErrAt l $ withHsDocContext ctxt err_msg {- ************************************************************************ ===================================== testsuite/tests/quantified-constraints/T18432.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE QuantifiedConstraints #-} +module Bug where + +import Data.Proxy + +class C a where + m :: Proxy a + +f :: (forall {a}. C a) => Proxy Int +f = m ===================================== testsuite/tests/quantified-constraints/all.T ===================================== @@ -29,3 +29,4 @@ test('T17267c', normal, compile_fail, ['']) test('T17267d', normal, compile_and_run, ['']) test('T17267e', normal, compile_fail, ['']) test('T17458', normal, compile_fail, ['']) +test('T18432', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/ExplicitSpecificity4.hs → testsuite/tests/typecheck/should_compile/ExplicitSpecificity4.hs ===================================== ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -712,6 +712,7 @@ test('T18129', expect_broken(18129), compile, ['']) test('T18185', normal, compile, ['']) test('ExplicitSpecificityA1', normal, compile, ['']) test('ExplicitSpecificityA2', normal, compile, ['']) +test('ExplicitSpecificity4', normal, compile, ['']) test('T17775-viewpats-a', normal, compile, ['']) test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_fail/T18455.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE RankNTypes #-} +module T18455 where + +class C a + +instance C (Either a b) where + {-# SPECIALISE instance forall a. forall b. C (Either a b) #-} ===================================== testsuite/tests/typecheck/should_fail/T18455.stderr ===================================== @@ -0,0 +1,4 @@ + +T18455.hs:7:37: error: + SPECIALISE instance type cannot contain nested ‘forall’s or contexts + In a SPECIALISE instance pragma ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -568,7 +568,6 @@ test('T18127a', normal, compile_fail, ['']) test('ExplicitSpecificity1', normal, compile_fail, ['']) test('ExplicitSpecificity2', normal, compile_fail, ['']) test('ExplicitSpecificity3', normal, compile_fail, ['']) -test('ExplicitSpecificity4', normal, compile_fail, ['']) test('ExplicitSpecificity5', normal, compile_fail, ['']) test('ExplicitSpecificity6', normal, compile_fail, ['']) test('ExplicitSpecificity7', normal, compile_fail, ['']) @@ -578,3 +577,4 @@ test('ExplicitSpecificity10', normal, compile_fail, ['']) test('T18357', normal, compile_fail, ['']) test('T18357a', normal, compile_fail, ['']) test('T18357b', normal, compile_fail, ['']) +test('T18455', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/360112d81e46d1d4bee280b281ce6742bc0db205 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/360112d81e46d1d4bee280b281ce6742bc0db205 You're receiving 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 Jul 17 15:02:13 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Fri, 17 Jul 2020 11:02:13 -0400 Subject: [Git][ghc/ghc][wip/andreask/remove_dict_field_flag] Deprecate -fdmd-tx-dict-sel. Message-ID: <5f11bd757d5e9_80b3f848e63c818369736b@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/remove_dict_field_flag at Glasgow Haskell Compiler / GHC Commits: fd6b87e5 by Andreas Klebinger at 2020-07-17T17:01:29+02:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled. - - - - - 4 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - docs/users_guide/using-optimisation.rst Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -486,8 +486,7 @@ dmdTransform env var dmd | isDataConWorkId var = dmdTransformDataConSig (idArity var) dmd -- Dictionary component selectors - | gopt Opt_DmdTxDictSel (ae_dflags env), - Just _ <- isClassOpId_maybe var + | Just _ <- isClassOpId_maybe var = dmdTransformDictSelSig (idStrictness var) dmd -- Imported functions | isGlobalId var ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -188,7 +188,8 @@ data GeneralFlag | Opt_OmitYields | Opt_FunToThunk -- allow GHC.Core.Opt.WorkWrap.Utils.mkWorkerArgs to remove all value lambdas | Opt_DictsStrict -- be strict in argument dictionaries - | Opt_DmdTxDictSel -- use a special demand transformer for dictionary selectors + | Opt_DmdTxDictSel -- ^ deprecated, no effect and behaviour is now default. + -- Allowed switching of a special demand transformer for dictionary selectors | Opt_Loopification -- See Note [Self-recursive tail calls] | Opt_CfgBlocklayout -- ^ Use the cfg based block layout algorithm. | Opt_WeightlessBlocklayout -- ^ Layout based on last instruction per block. ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3508,7 +3508,8 @@ fFlagsDeps = [ flagSpec "diagnostics-show-caret" Opt_DiagnosticsShowCaret, flagSpec "dicts-cheap" Opt_DictsCheap, flagSpec "dicts-strict" Opt_DictsStrict, - flagSpec "dmd-tx-dict-sel" Opt_DmdTxDictSel, + depFlagSpec "dmd-tx-dict-sel" + Opt_DmdTxDictSel "effect is now unconditionally enabled", flagSpec "do-eta-reduction" Opt_DoEtaReduction, flagSpec "do-lambda-eta-expansion" Opt_DoLambdaEtaExpansion, flagSpec "eager-blackholing" Opt_EagerBlackHoling, @@ -4039,7 +4040,6 @@ optLevelFlags :: [([Int], GeneralFlag)] optLevelFlags -- see Note [Documenting optimisation flags] = [ ([0,1,2], Opt_DoLambdaEtaExpansion) , ([0,1,2], Opt_DoEtaReduction) -- See Note [Eta-reduction in -O0] - , ([0,1,2], Opt_DmdTxDictSel) , ([0,1,2], Opt_LlvmTBAA) , ([0], Opt_IgnoreInterfacePragmas) ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -353,8 +353,7 @@ by saying ``-fno-wombat``. Make dictionaries strict. .. ghc-flag:: -fdmd-tx-dict-sel - :shortdesc: Use a special demand transformer for dictionary selectors. - Always enabled by default. + :shortdesc: *(deprecated)* Use a special demand transformer for dictionary selectors. :type: dynamic :reverse: -fno-dmd-tx-dict-sel :category: @@ -362,6 +361,7 @@ by saying ``-fno-wombat``. :default: on Use a special demand transformer for dictionary selectors. + Behaviour is unconditionally enabled starting with 8.14 .. ghc-flag:: -fdo-eta-reduction :shortdesc: Enable eta-reduction. Implied by :ghc-flag:`-O`. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd6b87e547f65c034c2a0d6bc36947fc2f64865b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd6b87e547f65c034c2a0d6bc36947fc2f64865b You're receiving 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 Jul 17 15:02:24 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Fri, 17 Jul 2020 11:02:24 -0400 Subject: [Git][ghc/ghc][wip/andreask/remove_dict_field_flag] 167 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f11bd804743d_80bda8bdb436978df@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/remove_dict_field_flag at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 108105f0 by Andreas Klebinger at 2020-07-17T11:02:22-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - Makefile - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd6b87e547f65c034c2a0d6bc36947fc2f64865b...108105f03ebdb3942cf4a064dad801424451cb3f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd6b87e547f65c034c2a0d6bc36947fc2f64865b...108105f03ebdb3942cf4a064dad801424451cb3f You're receiving 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 Jul 17 16:15:36 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 17 Jul 2020 12:15:36 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f11cea87d5cc_80b3f8486b77e483722720@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0bada44e by Ben Gamari at 2020-07-17T12:15:23-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 26d28c48 by Hécate at 2020-07-17T12:15:24-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - a88b23e1 by Hécate at 2020-07-17T12:15:26-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - 575c8529 by Simon Peyton Jones at 2020-07-17T12:15:26-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - 6d9a250e by Simon Peyton Jones at 2020-07-17T12:15:26-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - c5d949aa by Krzysztof Gogolewski at 2020-07-17T12:15:30-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - fb19d9b6 by Simon Peyton Jones at 2020-07-17T12:15:31-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49e461c1 by Chaitanya Koparkar at 2020-07-17T12:15:32-04:00 Fix minor typos in a Core.hs note - - - - - bd9ae48d by Stefan Schulze Frielinghaus at 2020-07-17T12:15:33-04:00 GHCi: Fix isLittleEndian - - - - - cb324e99 by Ben Gamari at 2020-07-17T12:15:33-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst - hadrian/hadrian.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3bf55ef1d2ee6503eb1238dc2051ae7b55afca69...cb324e99908f9a63bb0a2393144e89f12b3909cf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3bf55ef1d2ee6503eb1238dc2051ae7b55afca69...cb324e99908f9a63bb0a2393144e89f12b3909cf You're receiving 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 Jul 17 16:25:39 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 17 Jul 2020 12:25:39 -0400 Subject: [Git][ghc/ghc][wip/T14620] 19 commits: Use dumpStyle when printing inlinings Message-ID: <5f11d10336342_80b3f8486b77e4837382d8@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T14620 at Glasgow Haskell Compiler / GHC Commits: 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 45af3f08 by Simon Peyton Jones at 2020-07-16T15:27:20+01:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 210e018d by Sebastian Graf at 2020-07-16T18:56:40+02:00 WIP: Fix #14620 by introducing WW to detect more join points - - - - - 29f6afb5 by Sebastian Graf at 2020-07-16T18:56:40+02:00 fix - - - - - d42a2b42 by Sebastian Graf at 2020-07-17T18:23:15+02:00 Activate, detect and fix WWable situations - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.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/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/StgToCmm/CgUtils.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Tc/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c807675707d364146d1c52154a9077affd2ba17...d42a2b42a9be618f52b8bdb3c00f986d032f521a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c807675707d364146d1c52154a9077affd2ba17...d42a2b42a9be618f52b8bdb3c00f986d032f521a You're receiving 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 Jul 17 16:47:44 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Fri, 17 Jul 2020 12:47:44 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18470 Message-ID: <5f11d63072a15_80b3f8486fb6f7c3743097@gitlab.haskell.org.mail> Ryan Scott pushed new branch wip/T18470 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18470 You're receiving 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 Jul 17 17:57:36 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 17 Jul 2020 13:57:36 -0400 Subject: [Git][ghc/ghc][wip/T18126] 2 commits: Implement Quick Look impredicativity Message-ID: <5f11e690a282a_80b3f8486b77e48374609e@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: 17a17141 by Simon Peyton Jones at 2020-07-17T18:57:16+01:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity, sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to a new module GHC.Tc.Gen.App which deals with typechecking n-ary applications. It contains a good deal of documentation. Two other loosely-related change is in this patch: * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. NB: This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just maed T7861 into expect_broken(18467) - - - - - 69f79f77 by Simon Peyton Jones at 2020-07-17T18:57:16+01:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typeecheck/polykinds/T16245a - - - - - 18 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Hole.hs - + compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Default.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/336abb3b900b755fe2b97a48995699598547de49...69f79f77f2b14071abbac4b84f9fb060bfc4142f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/336abb3b900b755fe2b97a48995699598547de49...69f79f77f2b14071abbac4b84f9fb060bfc4142f You're receiving 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 Jul 17 18:13:30 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 17 Jul 2020 14:13:30 -0400 Subject: [Git][ghc/ghc][wip/revert-arm-symbols] Bump Win32 and process submodules Message-ID: <5f11ea4a9a2af_80b8e25ed4375351@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/revert-arm-symbols at Glasgow Haskell Compiler / GHC Commits: cdfc1891 by Ben Gamari at 2020-07-17T14:13:18-04:00 Bump Win32 and process submodules - - - - - 2 changed files: - libraries/Win32 - libraries/process Changes: ===================================== libraries/Win32 ===================================== @@ -1 +1 @@ -Subproject commit ca5fbc12851b98a52f96a43ea19c54c9ecf0f9e3 +Subproject commit f059037820ce68c5f524b188496cab196d979950 ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit cb1d1a6ead68f0e1b209277e79ec608980e9ac84 +Subproject commit afa1f3cd73dd3de8ef028b9dc1411f9c79583579 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdfc18918cc93970795dee7741e41400efe89cba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdfc18918cc93970795dee7741e41400efe89cba You're receiving 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 Jul 17 18:13:55 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 17 Jul 2020 14:13:55 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/bump-win32 Message-ID: <5f11ea63ce766_80b3f84870971943753785@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/bump-win32 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/bump-win32 You're receiving 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 Jul 17 22:16:01 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 17 Jul 2020 18:16:01 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f122321b5ddf_80b3f849426d9703805065@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c5d3ad2f by Ben Gamari at 2020-07-17T18:15:51-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 5b98f525 by Hécate at 2020-07-17T18:15:52-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - eeee2a7f by Hécate at 2020-07-17T18:15:53-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - 7491b731 by Simon Peyton Jones at 2020-07-17T18:15:54-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - 7e50f1da by Simon Peyton Jones at 2020-07-17T18:15:54-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 3ffa9555 by Krzysztof Gogolewski at 2020-07-17T18:15:55-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e9153aa9 by Simon Peyton Jones at 2020-07-17T18:15:56-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 9e670508 by Chaitanya Koparkar at 2020-07-17T18:15:57-04:00 Fix minor typos in a Core.hs note - - - - - 4c71c9f9 by Stefan Schulze Frielinghaus at 2020-07-17T18:15:58-04:00 GHCi: Fix isLittleEndian - - - - - 09b1e854 by Ben Gamari at 2020-07-17T18:15:58-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst - hadrian/hadrian.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb324e99908f9a63bb0a2393144e89f12b3909cf...09b1e854e27ea8f6b602112686eadc8bf0a1429f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb324e99908f9a63bb0a2393144e89f12b3909cf...09b1e854e27ea8f6b602112686eadc8bf0a1429f You're receiving 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 Jul 17 23:05:11 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 17 Jul 2020 19:05:11 -0400 Subject: [Git][ghc/ghc][wip/T18126] 2 commits: Implement Quick Look impredicativity Message-ID: <5f122ea7eaba6_80b105da72c382412@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: 950241e2 by Simon Peyton Jones at 2020-07-18T00:02:42+01:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Two other loosely-related changes are in this patch: * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - b18c7f3b by Simon Peyton Jones at 2020-07-18T00:02:42+01:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typeecheck/polykinds/T16245a - - - - - 18 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Hole.hs - + compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Default.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/69f79f77f2b14071abbac4b84f9fb060bfc4142f...b18c7f3bf5c2ec483716b913bb3ba5fd95f2de52 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/69f79f77f2b14071abbac4b84f9fb060bfc4142f...b18c7f3bf5c2ec483716b913bb3ba5fd95f2de52 You're receiving 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 Jul 18 01:44:01 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 17 Jul 2020 21:44:01 -0400 Subject: [Git][ghc/ghc] Pushed new branch ghc-8.12 Message-ID: <5f1253e11d93f_80bae68c7838324cb@gitlab.haskell.org.mail> Ben Gamari pushed new branch ghc-8.12 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-8.12 You're receiving 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 Jul 18 05:36:29 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 18 Jul 2020 01:36:29 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f128a5d89ea0_80b3f84860c282c38506fa@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6c1e71d3 by Ben Gamari at 2020-07-18T01:36:19-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - e7e00aec by Hécate at 2020-07-18T01:36:20-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - 312ad8dd by Hécate at 2020-07-18T01:36:21-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - 25fb646c by Simon Peyton Jones at 2020-07-18T01:36:22-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - ae885c1d by Simon Peyton Jones at 2020-07-18T01:36:22-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - af6b210f by Krzysztof Gogolewski at 2020-07-18T01:36:24-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - 6e114004 by Simon Peyton Jones at 2020-07-18T01:36:24-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - d920047d by Chaitanya Koparkar at 2020-07-18T01:36:25-04:00 Fix minor typos in a Core.hs note - - - - - 3344723e by Stefan Schulze Frielinghaus at 2020-07-18T01:36:26-04:00 GHCi: Fix isLittleEndian - - - - - 40fa252a by Ben Gamari at 2020-07-18T01:36:27-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst - hadrian/hadrian.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/09b1e854e27ea8f6b602112686eadc8bf0a1429f...40fa252a38115c67e9b462d07022d2329e8dcc6f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/09b1e854e27ea8f6b602112686eadc8bf0a1429f...40fa252a38115c67e9b462d07022d2329e8dcc6f You're receiving 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 Jul 18 11:26:50 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 18 Jul 2020 07:26:50 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f12dc7a9d2f2_80b3f849020d0243886157@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst - hadrian/hadrian.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/40fa252a38115c67e9b462d07022d2329e8dcc6f...c26e81d116a653b5259aeb290fb1e697efe3382a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/40fa252a38115c67e9b462d07022d2329e8dcc6f...c26e81d116a653b5259aeb290fb1e697efe3382a You're receiving 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 Jul 18 19:49:22 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Sat, 18 Jul 2020 15:49:22 -0400 Subject: [Git][ghc/ghc][wip/haddock-accum] 178 commits: Hadrian: fix PowerPC64le support (#17601) Message-ID: <5f135242be74b_80b855dedc3939773@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/haddock-accum at Glasgow Haskell Compiler / GHC Commits: 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 83c58077 by Vladislav Zavialov at 2020-07-18T22:49:14+03:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - Makefile - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a48d5b239f434a67aa7c4158c9fcb232cd13678...83c58077f65486d0ba68c98662e794ad5de22cea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a48d5b239f434a67aa7c4158c9fcb232cd13678...83c58077f65486d0ba68c98662e794ad5de22cea You're receiving 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 Jul 18 21:53:59 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Sat, 18 Jul 2020 17:53:59 -0400 Subject: [Git][ghc/ghc][wip/T18126] 2 commits: Implement Quick Look impredicativity Message-ID: <5f136f77e79e0_80b3f849248fe083945461@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: 7fc8834a by Simon Peyton Jones at 2020-07-18T22:52:50+01:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Two other loosely-related changes are in this patch: * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - e11af031 by Simon Peyton Jones at 2020-07-18T22:52:50+01:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typeecheck/polykinds/T16245a - - - - - 18 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Hole.hs - + compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Default.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b18c7f3bf5c2ec483716b913bb3ba5fd95f2de52...e11af031e4312450b14f35f531a19699cb0120b1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b18c7f3bf5c2ec483716b913bb3ba5fd95f2de52...e11af031e4312450b14f35f531a19699cb0120b1 You're receiving 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 Jul 18 22:23:13 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Sat, 18 Jul 2020 18:23:13 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18451 Message-ID: <5f13765112bc9_80b3f84901582f03951096@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T18451 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18451 You're receiving 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 Jul 18 22:33:10 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Sat, 18 Jul 2020 18:33:10 -0400 Subject: [Git][ghc/ghc][wip/T13253] 131 commits: compiler: re-engineer the treatment of rebindable if Message-ID: <5f1378a6a516f_80b1025102439528ab@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC Commits: 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - e8b04d89 by Simon Peyton Jones at 2020-07-18T23:32:12+01:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes two significant changes: 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Then in postInlineUnconditionally use that info to avoid inling something many many times. Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally See Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils 2. Change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg] Current nofib run Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- VS -0.3% +115.9% +12.1% +11.2% 0.0% boyer2 -0.3% +10.0% +3.5% +4.0% 0.0% cryptarithm2 -0.3% +39.0% +16.6% +16.1% 0.0% gamteb -0.3% +4.1% -0.0% +0.4% 0.0% last-piece -0.3% +1.4% -1.1% -0.4% 0.0% mate -0.4% -11.1% -8.5% -9.0% 0.0% multiplier -0.3% -2.2% -1.5% -1.5% 0.0% transform -0.3% +3.4% +0.5% +0.8% 0.0% -------------------------------------------------------------------------------- Min -0.8% -11.1% -8.5% -9.0% 0.0% Max -0.3% +115.9% +30.1% +26.4% 0.0% Geometric Mean -0.3% +1.0% +1.0% +1.0% -0.0% Should investigate these numbers. But the tickets are indeed cured, I think. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - Makefile - compiler/GHC/Builtin/Names.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.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/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/StgToCmm/CgUtils.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Info.hs - compiler/GHC/Tc/Gen/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dfa4a337ecb33314d8ceaef6a9266cd95005e22e...e8b04d89fd95d25c42ac81454d71d423bd81bccc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dfa4a337ecb33314d8ceaef6a9266cd95005e22e...e8b04d89fd95d25c42ac81454d71d423bd81bccc You're receiving 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 Jul 18 22:39:47 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Sat, 18 Jul 2020 18:39:47 -0400 Subject: [Git][ghc/ghc][wip/T18451] Care with occCheckExpand in kind of occurrences Message-ID: <5f137a33ae17d_80b3f84962c9cf039562db@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18451 at Glasgow Haskell Compiler / GHC Commits: bacc14ea by Simon Peyton Jones at 2020-07-18T23:39:15+01:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 10 changed files: - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Utils/Unify.hs - + testsuite/tests/polykinds/T18451.hs - + testsuite/tests/polykinds/T18451.stderr - + testsuite/tests/polykinds/T18451a.hs - + testsuite/tests/polykinds/T18451a.stderr - + testsuite/tests/polykinds/T18451b.hs - + testsuite/tests/polykinds/T18451b.stderr - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -34,10 +34,9 @@ import {-# SOURCE #-} GHC.CoreToIface , toIfaceTyCon, toIfaceTcArgs, toIfaceCoercionX ) import {-# SOURCE #-} GHC.Core.DataCon - ( dataConFullSig , dataConUserTyVarBinders - , DataCon ) + ( dataConFullSig , dataConUserTyVarBinders, DataCon ) -import GHC.Core.Type ( isLiftedTypeKind, pattern One, pattern Many ) +import GHC.Core.Type ( pickyIsLiftedTypeKind, pattern One, pattern Many ) import GHC.Core.TyCon import GHC.Core.TyCo.Rep @@ -192,11 +191,35 @@ pprTyVar :: TyVar -> SDoc -- pprIfaceTvBndr is minimal, and the loss of uniques etc in -- debug printing is disastrous pprTyVar tv - | isLiftedTypeKind kind = ppr tv - | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) + | pickyIsLiftedTypeKind kind = ppr tv -- See Note [Suppressing * kinds] + | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) where kind = tyVarKind tv +{- Note [Suppressing * kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Generally we want to print + forall a. a->a +not forall (a::*). a->a +or forall (a::Type). a->a +That is, for brevity we suppress a kind ascription of '*' (or Type). + +But what if the kind is (Const Type x)? + type Cons p q = p + +Then (Const Type x) is just a long way of saying Type. But it may be +jolly confusing to suppress the 'x'. Suppose we have (polykinds/T18451a) + foo :: forall a b (c :: Const Type b). Proxy '[a, c] + +Then this error message + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) +would be much less helpful if we suppressed the kind ascription on 'a'. + +Hence the use of pickyIsLiftedTypeKind. +-} + ----------------- debugPprType :: Type -> SDoc -- ^ debugPprType is a simple pretty printer that prints a type ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -122,7 +122,7 @@ module GHC.Core.Type ( -- *** Levity and boxity isLiftedType_maybe, - isLiftedTypeKind, isUnliftedTypeKind, + isLiftedTypeKind, isUnliftedTypeKind, pickyIsLiftedTypeKind, isLiftedRuntimeRep, isUnliftedRuntimeRep, isUnliftedType, mightBeUnliftedType, isUnboxedTupleType, isUnboxedSumType, isAlgType, isDataFamilyAppType, @@ -556,6 +556,22 @@ isLiftedTypeKind kind Just rep -> isLiftedRuntimeRep rep Nothing -> False +pickyIsLiftedTypeKind :: Kind -> Bool +-- Checks whether the kind is literally +-- TYPE LiftedRep +-- or Type +-- without expanding type synonyms or anything +-- Used only when deciding whether to suppress the ":: *" in +-- (a :: *) when printing kinded type variables +pickyIsLiftedTypeKind kind + | TyConApp tc [arg] <- kind + , tc `hasKey` tYPETyConKey + , TyConApp rr_tc [] <- arg + , rr_tc `hasKey` liftedRepDataConKey = True + | TyConApp tc [] <- kind + , tc `hasKey` liftedTypeKindTyConKey = True + | otherwise = False + isLiftedRuntimeRep :: Type -> Bool -- isLiftedRuntimeRep is true of LiftedRep :: RuntimeRep -- False of type variables (a :: RuntimeRep) @@ -2633,6 +2649,46 @@ prefer doing inner expansions first. For example, We have occCheckExpand b (F (G b)) = Just (F Char) even though we could also expand F to get rid of b. + +Note [Occurrence checking: look inside kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we are considering unifying + (alpha :: *) ~ Int -> (beta :: alpha -> alpha) +This may be an error (what is that alpha doing inside beta's kind?), +but we must not make the mistake of actually unifying or we'll +build an infinite data structure. So when looking for occurrences +of alpha in the rhs, we must look in the kinds of type variables +that occur there. + +occCheckExpand tries to expand type synonyms to remove +unnecessary occurrences of a variable, and thereby get past an +occurs-check failure. This is good; but + we can't do it in the /kind/ of a variable /occurrence/ + +For example #18451 built an infinite type: + type Const a b = a + data SameKind :: k -> k -> Type + type T (k :: Const Type a) = forall (b :: k). SameKind a b + +We have + b :: k + k :: Const Type a + a :: k (must be same as b) + +So if we aren't careful, a's kind mentions a, which is bad. +And expanding an /occurrence/ of 'a' doesn't help, because the +/binding site/ is the master copy and all the occurrences should +match it. + +Here's a related example: + f :: forall a b (c :: Const Type b). Proxy '[a, c] + +The list means that 'a' gets the same kind as 'c'; but that +kind mentions 'b', so the binders are out of order. + +Bottom line: in occCheckExpand, do not expand inside the kinds +of occurrences. See bad_var_occ in occCheckExpand. And +see #18451 for more debate. -} occCheckExpand :: [Var] -> Type -> Maybe Type @@ -2653,11 +2709,10 @@ occCheckExpand vs_to_avoid ty -- The VarSet is the set of variables we are trying to avoid -- The VarEnv carries mappings necessary -- because of kind expansion - go cxt@(as, env) (TyVarTy tv') - | tv' `elemVarSet` as = Nothing - | Just tv'' <- lookupVarEnv env tv' = return (mkTyVarTy tv'') - | otherwise = do { tv'' <- go_var cxt tv' - ; return (mkTyVarTy tv'') } + go (as, env) ty@(TyVarTy tv) + | Just tv' <- lookupVarEnv env tv = return (mkTyVarTy tv') + | bad_var_occ as tv = Nothing + | otherwise = return ty go _ ty@(LitTy {}) = return ty go cxt (AppTy ty1 ty2) = do { ty1' <- go cxt ty1 @@ -2670,7 +2725,7 @@ occCheckExpand vs_to_avoid ty ; return (ty { ft_mult = w', ft_arg = ty1', ft_res = ty2' }) } go cxt@(as, env) (ForAllTy (Bndr tv vis) body_ty) = do { ki' <- go cxt (varType tv) - ; let tv' = setVarType tv ki' + ; let tv' = setVarType tv ki' env' = extendVarEnv env tv tv' as' = as `delVarSet` tv ; body' <- go (as', env') body_ty @@ -2694,9 +2749,12 @@ occCheckExpand vs_to_avoid ty ; return (mkCoercionTy co') } ------------------ - go_var cxt v = updateVarTypeM (go cxt) v - -- Works for TyVar and CoVar - -- See Note [Occurrence checking: look inside kinds] + bad_var_occ :: VarSet -> Var -> Bool + -- Works for TyVar and CoVar + -- See Note [Occurrence checking: look inside kinds] + bad_var_occ vs_to_avoid v + = v `elemVarSet` vs_to_avoid + || tyCoVarsOfType (varType v) `intersectsVarSet` vs_to_avoid ------------------ go_mco _ MRefl = return MRefl @@ -2726,13 +2784,15 @@ occCheckExpand vs_to_avoid ty ; co2' <- go_co cxt co2 ; w' <- go_co cxt w ; return (mkFunCo r w' co1' co2') } - go_co cxt@(as,env) (CoVarCo c) - | c `elemVarSet` as = Nothing + go_co (as,env) co@(CoVarCo c) | Just c' <- lookupVarEnv env c = return (mkCoVarCo c') - | otherwise = do { c' <- go_var cxt c - ; return (mkCoVarCo c') } - go_co cxt (HoleCo h) = do { c' <- go_var cxt (ch_co_var h) - ; return (HoleCo (h { ch_co_var = c' })) } + | bad_var_occ as c = Nothing + | otherwise = return co + + go_co (as,_) co@(HoleCo h) + | bad_var_occ as (ch_co_var h) = Nothing + | otherwise = return co + go_co cxt (AxiomInstCo ax ind args) = do { args' <- mapM (go_co cxt) args ; return (mkAxiomInstCo ax ind args') } go_co cxt (UnivCo p r ty1 ty2) = do { p' <- go_prov cxt p ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -2046,21 +2046,8 @@ matchExpectedFunKind hs_ty n k = go n k ********************************************************************* -} -{- Note [Occurrence checking: look inside kinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Suppose we are considering unifying - (alpha :: *) ~ Int -> (beta :: alpha -> alpha) -This may be an error (what is that alpha doing inside beta's kind?), -but we must not make the mistake of actually unifying or we'll -build an infinite data structure. So when looking for occurrences -of alpha in the rhs, we must look in the kinds of type variables -that occur there. - -NB: we may be able to remove the problem via expansion; see - Note [Occurs check expansion]. So we have to try that. - -Note [Checking for foralls] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Checking for foralls] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unless we have -XImpredicativeTypes (which is a totally unsupported feature), we do not want to unify alpha ~ (forall a. a->a) -> Int @@ -2073,10 +2060,10 @@ Consider (alpha :: forall k. k->*) ~ (beta :: forall k. k->*) This is legal; e.g. dependent/should_compile/T11635. -We don't want to reject it because of the forall in beta's kind, -but (see Note [Occurrence checking: look inside kinds]) we do -need to look in beta's kind. So we carry a flag saying if a 'forall' -is OK, and switch the flag on when stepping inside a kind. +We don't want to reject it because of the forall in beta's kind, but +(see Note [Occurrence checking: look inside kinds] in GHC.Core.Type) +we do need to look in beta's kind. So we carry a flag saying if a +'forall' is OK, and switch the flag on when stepping inside a kind. Why is it OK? Why does it not count as impredicative polymorphism? The reason foralls are bad is because we reply on "seeing" foralls @@ -2197,6 +2184,7 @@ preCheck dflags ty_fam_ok tv ty | tv == tv' = MTVU_Occurs | otherwise = fast_check_occ (tyVarKind tv') -- See Note [Occurrence checking: look inside kinds] + -- in GHC.Core.Type fast_check (TyConApp tc tys) | bad_tc tc = MTVU_Bad ===================================== testsuite/tests/polykinds/T18451.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind + +type Const a b = a +data SameKind :: k -> k -> Type + +type T (k :: Const Type a) = forall (b :: k). SameKind a b ===================================== testsuite/tests/polykinds/T18451.stderr ===================================== @@ -0,0 +1,9 @@ + +T18451.hs:10:58: error: + • Expected kind ‘k0’, but ‘b’ has kind ‘k’ + • In the second argument of ‘SameKind’, namely ‘b’ + In the type ‘forall (b :: k). SameKind a b’ + In the type declaration for ‘T’ + • Type variable kinds: + a :: k0 + k :: Const (*) a ===================================== testsuite/tests/polykinds/T18451a.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451a.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/T18451b.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451b.stderr ===================================== @@ -0,0 +1 @@ + \ No newline at end of file ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -220,3 +220,6 @@ test('CuskFam', normal, compile, ['']) test('T17841', normal, compile_fail, ['']) test('T17963', normal, compile_fail, ['']) test('T18300', normal, compile_fail, ['']) +test('T18451', normal, compile_fail, ['']) +test('T18451a', normal, compile_fail, ['']) +test('T18451b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bacc14ea28bb75ed97bbe4b300a7870729095351 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bacc14ea28bb75ed97bbe4b300a7870729095351 You're receiving 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 Jul 19 07:17:38 2020 From: gitlab at gitlab.haskell.org (Brandon Chinn) Date: Sun, 19 Jul 2020 03:17:38 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T16341 Message-ID: <5f13f3928e6bc_80b1025102439587ad@gitlab.haskell.org.mail> Brandon Chinn pushed new branch wip/T16341 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T16341 You're receiving 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 Jul 19 07:26:43 2020 From: gitlab at gitlab.haskell.org (Brandon Chinn) Date: Sun, 19 Jul 2020 03:26:43 -0400 Subject: [Git][ghc/ghc][wip/T16341] 3 commits: Add regression test for #16341 Message-ID: <5f13f5b3ae733_80b3f84868c382839603f0@gitlab.haskell.org.mail> Brandon Chinn pushed to branch wip/T16341 at Glasgow Haskell Compiler / GHC Commits: c8017b36 by Brandon Chinn at 2020-07-19T00:26:26-07:00 Add regression test for #16341 - - - - - 6d9632b9 by Brandon Chinn at 2020-07-19T00:26:26-07:00 Pass inst_tys to more stock-deriving generation functions - - - - - 41c5d721 by Brandon Chinn at 2020-07-19T00:26:26-07:00 Filter out unreachable constructors when deriving stock instances (#16341) - - - - - 5 changed files: - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - + testsuite/tests/deriving/should_compile/T16341.hs - testsuite/tests/deriving/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/Deriv.hs ===================================== @@ -2041,6 +2041,7 @@ genDerivStuff mechanism loc clas inst_tys tyvars DerivSpecStock { dsm_stock_dit = DerivInstTys{dit_rep_tc = rep_tc} , dsm_stock_gen_fn = gen_fn } -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc inst_tys + traceTc "brandonchinn_genDerivStuff" (pprLHsBinds binds) pure (binds, [], faminsts, field_names) -- Try DeriveAnyClass ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -212,14 +212,14 @@ for the instance decl, which it probably wasn't, so the decls produced don't get through the typechecker. -} -gen_Eq_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Eq_binds loc tycon = do +gen_Eq_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Eq_binds loc tycon inst_tys = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon return (method_binds con2tag_RDR, aux_binds con2tag_RDR) where - all_cons = tyConDataCons tycon + all_cons = filter (not . dataConCannotMatch inst_tys) $ tyConDataCons tycon (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon all_cons -- If there are ten or more (arbitrary number) nullary constructors, @@ -396,8 +396,8 @@ gtResult OrdGE = true_Expr gtResult OrdGT = true_Expr ------------ -gen_Ord_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ord_binds loc tycon = do +gen_Ord_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ord_binds loc tycon inst_tys = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon @@ -432,7 +432,7 @@ gen_Ord_binds loc tycon = do -- We want *zero-based* tags, because that's what -- con2Tag returns (generated by untag_Expr)! - tycon_data_cons = tyConDataCons tycon + tycon_data_cons = filter (not . dataConCannotMatch inst_tys) $ tyConDataCons tycon single_con_type = isSingleton tycon_data_cons (first_con : _) = tycon_data_cons (last_con : _) = reverse tycon_data_cons @@ -646,8 +646,8 @@ instance ... Enum (Foo ...) where For @enumFromTo@ and @enumFromThenTo@, we use the default methods. -} -gen_Enum_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Enum_binds loc tycon = do +gen_Enum_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Enum_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -825,9 +825,9 @@ we follow the scheme given in Figure~19 of the Haskell~1.2 report (p.~147). -} -gen_Ix_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ix_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ix_binds loc tycon = do +gen_Ix_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -1028,10 +1028,10 @@ These instances are also useful for Read (Either Int Emp), where we want to be able to parse (Left 3) just fine. -} -gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Read_binds get_fixity loc tycon +gen_Read_binds get_fixity loc tycon inst_tys = (listToBag [read_prec, default_readlist, default_readlistprec], emptyBag) where ----------------------------------------------------------------------- @@ -1042,7 +1042,7 @@ gen_Read_binds get_fixity loc tycon = mkHsVarBind loc readListPrec_RDR (nlHsVar readListPrecDefault_RDR) ----------------------------------------------------------------------- - data_cons = tyConDataCons tycon + data_cons = filter (not . dataConCannotMatch inst_tys) $ tyConDataCons tycon (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon data_cons read_prec = mkHsVarBind loc readPrec_RDR rhs @@ -1212,13 +1212,13 @@ Example -- the most tightly-binding operator -} -gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Show_binds get_fixity loc tycon +gen_Show_binds get_fixity loc tycon inst_tys = (unitBag shows_prec, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = filter (not . dataConCannotMatch inst_tys) $ tyConDataCons tycon shows_prec = mkFunBindEC 2 loc showsPrec_RDR id (map pats_etc data_cons) comma_space = nlHsVar showCommaSpace_RDR @@ -1385,9 +1385,10 @@ we generate gen_Data_binds :: SrcSpan -> TyCon -- For data families, this is the -- *representation* TyCon + -> [Type] -> TcM (LHsBinds GhcPs, -- The method bindings BagDerivStuff) -- Auxiliary bindings -gen_Data_binds loc rep_tc +gen_Data_binds loc rep_tc inst_tys = do { -- See Note [Auxiliary binders] dataT_RDR <- new_dataT_rdr_name loc rep_tc ; dataC_RDRs <- traverse (new_dataC_rdr_name loc) data_cons @@ -1403,7 +1404,7 @@ gen_Data_binds loc rep_tc data_cons dataC_RDRs ) ) } where - data_cons = tyConDataCons rep_tc + data_cons = filter (not . dataConCannotMatch inst_tys) $ tyConDataCons rep_tc n_cons = length data_cons one_constr = n_cons == 1 ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -595,13 +595,13 @@ hasStockDeriving clas -- do is allocate new Uniques, which are used for generating the names of -- auxiliary bindings. -- See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate. - simpleM gen_fn loc tc _ - = do { (binds, deriv_stuff) <- gen_fn loc tc + simpleM gen_fn loc tc inst_tys + = do { (binds, deriv_stuff) <- gen_fn loc tc inst_tys ; return (binds, deriv_stuff, []) } - read_or_show gen_fn loc tc _ + read_or_show gen_fn loc tc inst_tys = do { fix_env <- getDataConFixityFun tc - ; let (binds, deriv_stuff) = gen_fn fix_env loc tc + ; let (binds, deriv_stuff) = gen_fn fix_env loc tc inst_tys field_names = all_field_names tc ; return (binds, deriv_stuff, field_names) } ===================================== testsuite/tests/deriving/should_compile/T16341.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE StandaloneDeriving #-} + +module T16341 where + +import Data.Data (Data) +import Data.Ix (Ix) + +data Foo a where + X :: Foo Int + Y :: (Bool -> Bool) -> Foo Bool + +-- These instances should work whether or not `Y` is a constructor in +-- `Foo`, because the `Foo Int` designation precludes `Y` from being +-- a reachable constructor +deriving instance Show (Foo Int) +deriving instance Read (Foo Int) +deriving instance Eq (Foo Int) +deriving instance Ord (Foo Int) +deriving instance Ix (Foo Int) +deriving instance Data (Foo Int) ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -118,6 +118,7 @@ test('T15398', normal, compile, ['']) test('T15637', normal, compile, ['']) test('T15831', normal, compile, ['']) test('T16179', normal, compile, ['']) +test('T16341', normal, compile, ['']) test('T16518', normal, compile, ['']) test('T17324', normal, compile, ['']) test('T17339', normal, compile, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1e9cde15ecb30b310dc04e0384d60c72f6626f78...41c5d721a14671474f8f76ccb15f37d1ac0e2289 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1e9cde15ecb30b310dc04e0384d60c72f6626f78...41c5d721a14671474f8f76ccb15f37d1ac0e2289 You're receiving 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 Jul 19 07:35:18 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sun, 19 Jul 2020 03:35:18 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] 164 commits: Warn about empty Char enumerations (#18402) Message-ID: <5f13f7b6c13cd_80b3f84901582f0396053f@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 21cca144 by Moritz Angermann at 2020-07-19T07:35:03+00:00 Cross Test Suite - - - - - 269193a7 by Moritz Angermann at 2020-07-19T07:35:03+00:00 platform backwards compat, until libraries are patched. - - - - - af2775d1 by Moritz Angermann at 2020-07-19T07:35:03+00:00 unbreak test.mk - - - - - 299b19ae by Moritz Angermann at 2020-07-19T07:35:03+00:00 default TEST_WRAPPER - - - - - ef9829d4 by Moritz Angermann at 2020-07-19T07:35:03+00:00 m( - - - - - 18103132 by Moritz Angermann at 2020-07-19T07:35:03+00:00 Fixup the test-suite - - - - - 6493832e by Moritz Angermann at 2020-07-19T07:35:03+00:00 Update test.mk - - - - - fa3e4c05 by Moritz Angermann at 2020-07-19T07:35:03+00:00 Fix T13350 - - - - - a1c05483 by Moritz Angermann at 2020-07-19T07:35:03+00:00 Fix T1372 - - - - - cf612449 by Moritz Angermann at 2020-07-19T07:35:03+00:00 Drop exec, use identity wrapper - - - - - a242cc01 by Moritz Angermann at 2020-07-19T07:35:03+00:00 Fix T13168 - - - - - df546d72 by Moritz Angermann at 2020-07-19T07:35:03+00:00 Fix T3007 - - - - - c00b3c5f by Moritz Angermann at 2020-07-19T07:35:04+00:00 Fix recomp007 - - - - - fad4c68b by Moritz Angermann at 2020-07-19T07:35:04+00:00 use $* - - - - - 3f6a0671 by Moritz Angermann at 2020-07-19T07:35:04+00:00 fix concio001 - - - - - ea46e1e4 by Moritz Angermann at 2020-07-19T07:35:04+00:00 disable flakey divbyzero test - - - - - 36e4bd24 by Moritz Angermann at 2020-07-19T07:35:04+00:00 add python :( - - - - - d2b71d2d by Moritz Angermann at 2020-07-19T07:35:04+00:00 ??? - - - - - 9a7bfd87 by Moritz Angermann at 2020-07-19T07:35:04+00:00 Fix T13168 - - - - - f9aae44a by Moritz Angermann at 2020-07-19T07:35:04+00:00 What is going on in CI? Why can't I reproduce this locally? - - - - - 76abfde4 by Moritz Angermann at 2020-07-19T07:35:04+00:00 Fix test-wrapper in python, so hadrian gets the benefit. - - - - - 1547a42f by Moritz Angermann at 2020-07-19T07:35:04+00:00 make it a Path! - - - - - ac73770f by Moritz Angermann at 2020-07-19T07:35:04+00:00 Drop left debug statement - - - - - 1dcc8b67 by Moritz Angermann at 2020-07-19T07:35:04+00:00 Better TEST_WRAPPER injection. - - - - - dd238d7a by Moritz Angermann at 2020-07-19T07:35:04+00:00 Split wrapper and prefix - - - - - 7456d884 by Moritz Angermann at 2020-07-19T07:35:04+00:00 Maybe the test-wrapper logic should become a cmd_prefix? - - - - - 09705e3d by Moritz Angermann at 2020-07-19T07:35:04+00:00 :facepalm: - - - - - 41e6465e by Moritz Angermann at 2020-07-19T07:35:04+00:00 :fire: - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - Makefile - compiler/GHC/Builtin/Names.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Match/Literal.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/StgToCmm/CgUtils.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Info.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Solver/Flatten.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a7a75a370c3496197aeea7ff926fa2a765791765...41e6465e2197f628287794f23ae950f1597a8480 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a7a75a370c3496197aeea7ff926fa2a765791765...41e6465e2197f628287794f23ae950f1597a8480 You're receiving 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 Jul 19 14:48:52 2020 From: gitlab at gitlab.haskell.org (Peter Trommler) Date: Sun, 19 Jul 2020 10:48:52 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/cross-ppr-floats Message-ID: <5f145d54b0a85_80b3f84925412343974175@gitlab.haskell.org.mail> Peter Trommler pushed new branch wip/cross-ppr-floats at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/cross-ppr-floats You're receiving 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 Jul 19 16:20:19 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Sun, 19 Jul 2020 12:20:19 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] 2 commits: Decode CostCentreStacks, CostCentres and InfoTables (#18405) Message-ID: <5f1472c38a397_80b114037a43979519@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: c46e93ab by Sven Tennie at 2020-07-19T11:33:34+02:00 Decode CostCentreStacks, CostCentres and InfoTables (#18405) - - - - - 1518108a by Sven Tennie at 2020-07-19T18:20:03+02:00 Use cache and loop breakers for CostCentre, CostCentreStack and IndexTable decoding (#18405) - - - - - 16 changed files: - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Runtime/Interpreter.hs - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Closures.hs - libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingDisabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/Types.hs - + libraries/ghc-heap/GHC/Exts/Heap/Ptr/Utils.hs - + libraries/ghc-heap/cbits/utils.c - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-heap/tests/all.T - + libraries/ghc-heap/tests/prof_info.hs - libraries/ghc-heap/tests/tso_and_stack_closures.hs - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/Run.hs Changes: ===================================== compiler/GHC/ByteCode/Types.hs ===================================== @@ -36,7 +36,7 @@ import Data.ByteString (ByteString) import Data.IntMap (IntMap) import qualified Data.IntMap as IntMap import Data.Maybe (catMaybes) -import GHC.Exts.Heap +import qualified GHC.Exts.Heap as Heap import GHC.Stack.CCS -- ----------------------------------------------------------------------------- @@ -71,7 +71,7 @@ type ItblEnv = NameEnv (Name, ItblPtr) -- We need the Name in the range so we know which -- elements to filter out when unloading a module -newtype ItblPtr = ItblPtr (RemotePtr StgInfoTable) +newtype ItblPtr = ItblPtr (RemotePtr Heap.StgInfoTable) deriving (Show, NFData) data UnlinkedBCO ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -93,7 +93,7 @@ import qualified Data.ByteString.Lazy as LB import Data.Array ((!)) import Data.IORef import Foreign hiding (void) -import GHC.Exts.Heap +import qualified GHC.Exts.Heap as Heap import GHC.Stack.CCS (CostCentre,CostCentreStack) import System.Exit import GHC.IO.Handle.Types (Handle) @@ -385,7 +385,7 @@ getBreakpointVar hsc_env ref ix = mb <- iservCmd hsc_env (GetBreakpointVar apStack ix) mapM (mkFinalizedHValue hsc_env) mb -getClosure :: HscEnv -> ForeignHValue -> IO (GenClosure ForeignHValue) +getClosure :: HscEnv -> ForeignHValue -> IO (Heap.GenClosure ForeignHValue) getClosure hsc_env ref = withForeignRef ref $ \hval -> do mb <- iservCmd hsc_env (GetClosure hval) ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -9,6 +9,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ExplicitForAll #-} {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE UnliftedFFITypes #-} {-| Module : GHC.Exts.Heap @@ -38,6 +39,12 @@ module GHC.Exts.Heap ( , peekItbl , pokeItbl + -- * Cost Centre (profiling) types + , StgTSOProfInfo(..) + , IndexTable(..) + , CostCentre(..) + , CostCentreStack(..) + -- * Closure inspection , getBoxedClosureData , allClosures @@ -52,9 +59,12 @@ import Prelude import GHC.Exts.Heap.Closures import GHC.Exts.Heap.ClosureTypes import GHC.Exts.Heap.Constants +import GHC.Exts.Heap.ProfInfo.Types #if defined(PROFILING) +import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled import GHC.Exts.Heap.InfoTableProf #else +import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled import GHC.Exts.Heap.InfoTable #endif import GHC.Exts.Heap.Utils @@ -71,13 +81,17 @@ import Foreign #include "ghcconfig.h" +foreign import ccall "isEndTsoQueue" isEndTsoQueue_c :: Addr# -> Bool + class HasHeapRep (a :: TYPE rep) where -- | Decode a closure to it's heap representation ('GenClosure'). -- Inside a GHC context 'b' is usually a 'GHC.Exts.Heap.Closures.Box' -- containing a thunk or an evaluated heap object. Outside it can be a -- 'Word' for "raw" usage of pointers. - getClosureDataX :: + +-- TODO: Remove Show constraint + getClosureDataX :: Show b => (forall c . c -> IO (Ptr StgInfoTable, [Word], [b])) -- ^ Helper function to get info table, memory and pointers of the -- closure. The order of @[b]@ is significant and determined by @@ -166,7 +180,9 @@ getClosureData = getClosureDataX getClosureRaw -- @collect_pointers()@ in @rts/Heap.c at . -- -- For most use cases 'getClosureData' is an easier to use alternative. -getClosureX :: forall a b. + +-- TODO: Remove Show constraint +getClosureX :: forall a b. Show b => (forall c . c -> IO (Ptr StgInfoTable, [Word], [b])) -- ^ Helper function to get info table, memory and pointers of the -- closure @@ -324,26 +340,34 @@ getClosureX get_closure_raw x = do allocaArray (length wds) (\ptr -> do pokeArray ptr wds - - fields <- FFIClosures.peekTSOFields ptr - - pure $ TSOClosure - { info = itbl - , _link = (pts !! 0) - , global_link = (pts !! 1) - , tsoStack = (pts !! 2) - , trec = (pts !! 3) - , blocked_exceptions = (pts !! 4) - , bq = (pts !! 5) - , what_next = FFIClosures.tso_what_next fields - , why_blocked = FFIClosures.tso_why_blocked fields - , flags = FFIClosures.tso_flags fields - , threadId = FFIClosures.tso_threadId fields - , saved_errno = FFIClosures.tso_saved_errno fields - , tso_dirty = FFIClosures.tso_dirty fields - , alloc_limit = FFIClosures.tso_alloc_limit fields - , tot_stack_size = FFIClosures.tso_tot_stack_size fields - } +-- TODO: remove prints + print $ "tso ptr : " ++ show ptr + print $ "tso pts : " ++ show pts + print $ "tso info table : " ++ show itbl +-- TODO: Does this work? I.e. do we emit EndTSOQueues? + if isEndTsoQueue_c (unpackPtr ptr) then + pure $ EndTSOQueue { info = itbl } + else do + fields <- FFIClosures.peekTSOFields peekStgTSOProfInfo ptr + + pure $ TSOClosure + { info = itbl + , _link = (pts !! 0) + , global_link = (pts !! 1) + , tsoStack = (pts !! 2) + , trec = (pts !! 3) + , blocked_exceptions = (pts !! 4) + , bq = (pts !! 5) + , what_next = FFIClosures.tso_what_next fields + , why_blocked = FFIClosures.tso_why_blocked fields + , flags = FFIClosures.tso_flags fields + , threadId = FFIClosures.tso_threadId fields + , saved_errno = FFIClosures.tso_saved_errno fields + , tso_dirty = FFIClosures.tso_dirty fields + , alloc_limit = FFIClosures.tso_alloc_limit fields + , tot_stack_size = FFIClosures.tso_tot_stack_size fields + , prof = FFIClosures.tso_prof fields + } ) STACK -> do unless (length pts == 1) $ @@ -372,3 +396,6 @@ getClosureX get_closure_raw x = do -- | Like 'getClosureDataX', but taking a 'Box', so it is easier to work with. getBoxedClosureData :: Box -> IO Closure getBoxedClosureData (Box a) = getClosureData a + +unpackPtr :: Ptr a -> Addr# +unpackPtr (Ptr addr) = addr ===================================== libraries/ghc-heap/GHC/Exts/Heap/Closures.hs ===================================== @@ -40,6 +40,8 @@ import GHC.Exts.Heap.InfoTable import GHC.Exts.Heap.InfoTableProf () #endif +import GHC.Exts.Heap.ProfInfo.Types + import Data.Bits import Data.Int import Data.Word @@ -281,7 +283,12 @@ data GenClosure b , tso_dirty:: Word32 -- ^ non-zero => dirty , alloc_limit :: Int64 , tot_stack_size :: Word32 + , prof :: Maybe StgTSOProfInfo } +-- | Marker for the end of TSO queues +-- Technically it has the same structure as an StgTSO, but most data isn't initialized. + | EndTSOQueue + { info :: !StgInfoTable } -- Representation of StgStack: The 'tsoStack' of a 'TSOClosure'. | StackClosure { info :: !StgInfoTable ===================================== libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hsc ===================================== @@ -5,6 +5,7 @@ module GHC.Exts.Heap.FFIClosures where import Prelude import Foreign +import GHC.Exts.Heap.ProfInfo.Types -- TODO use sum type for what_next, why_blocked, flags? @@ -18,13 +19,15 @@ data TSOFields = TSOFields { tso_saved_errno :: Word32, tso_dirty:: Word32, tso_alloc_limit :: Int64, - tso_tot_stack_size :: Word32 --- TODO StgTSOProfInfo prof is optionally included, but looks very interesting. + tso_tot_stack_size :: Word32, + tso_prof :: Maybe StgTSOProfInfo } -- | Get non-pointer fields from @StgTSO_@ (@TSO.h@) -peekTSOFields :: Ptr a -> IO TSOFields -peekTSOFields ptr = do +peekTSOFields :: (Ptr tsoPtr -> IO (Maybe StgTSOProfInfo)) + -> Ptr tsoPtr + -> IO TSOFields +peekTSOFields peekProfInfo ptr = do what_next' <- (#peek struct StgTSO_, what_next) ptr why_blocked' <- (#peek struct StgTSO_, why_blocked) ptr flags' <- (#peek struct StgTSO_, flags) ptr @@ -33,6 +36,7 @@ peekTSOFields ptr = do dirty' <- (#peek struct StgTSO_, dirty) ptr alloc_limit' <- (#peek struct StgTSO_, alloc_limit) ptr tot_stack_size' <- (#peek struct StgTSO_, tot_stack_size) ptr + tso_prof' <- peekProfInfo ptr return TSOFields { tso_what_next = what_next', @@ -42,7 +46,8 @@ peekTSOFields ptr = do tso_saved_errno = saved_errno', tso_dirty= dirty', tso_alloc_limit = alloc_limit', - tso_tot_stack_size = tot_stack_size' + tso_tot_stack_size = tot_stack_size', + tso_prof = tso_prof' } data StackFields = StackFields { ===================================== libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingDisabled.hsc ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE CPP, DeriveGeneric #-} +module GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled( + peekStgTSOProfInfo +) where + +import Prelude +import Foreign +import GHC.Exts.Heap.ProfInfo.Types + +-- | This implementation is used when PROFILING is undefined. +-- It always returns 'Nothing', because there is no profiling info available. +peekStgTSOProfInfo :: Ptr tsoPtr -> IO (Maybe StgTSOProfInfo) +peekStgTSOProfInfo _ = return Nothing ===================================== libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc ===================================== @@ -0,0 +1,180 @@ +{-# LANGUAGE CPP, DeriveGeneric #-} +module GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled( + peekStgTSOProfInfo +) where + +-- Manually defining PROFILING gives the #peek and #poke macros an accurate +-- representation of the C structures when hsc2hs runs. This is valid because +-- a non-profiling build would use +-- GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled. +#define PROFILING + +#include "Rts.h" +#include "DerivedConstants.h" + +import Prelude +import Foreign +import Foreign.C.String +import GHC.Exts.Heap.ProfInfo.Types + +import Data.IntMap.Strict (IntMap) +import qualified Data.IntMap.Strict as IntMap + +-- TODO: Use IntSet for better performance? +import Data.Set (Set) +import qualified Data.Set as Set + +import Control.Monad.Trans.State +import Control.Monad.IO.Class + +import GHC.Exts.Heap.Ptr.Utils + +-- TODO: Remove cache? Looks like it's not needed anymore due to loop breakers +data Cache = Cache { + ccCache :: IntMap CostCentre, + ccsCache :: IntMap CostCentreStack, + indexTableCache :: IntMap IndexTable +} +type DecoderMonad a = StateT Cache IO a + +peekStgTSOProfInfo :: Ptr a -> IO (Maybe StgTSOProfInfo) +#if __GLASGOW_HASKELL__ < 811 +peekStgTSOProfInfo _ = return Nothing +#else +peekStgTSOProfInfo tsoPtr = do +-- TODO: Use getCurrentCCS# ? Or GHC.Stack.CCS.getCurrentCCS ? + print $ "peekStgTSOProfInfo - tsoPtr : " ++ show tsoPtr + cccs_ptr <- peekByteOff tsoPtr cccsOffset + cccs' <- evalStateT (peekCostCentreStack Set.empty cccs_ptr) $ Cache IntMap.empty IntMap.empty IntMap.empty + + return $ Just StgTSOProfInfo { + cccs = cccs' + } + +cccsOffset :: Int +cccsOffset = (#const OFFSET_StgTSO_cccs) + (#size StgHeader) + +peekCostCentreStack :: Set (Ptr a) -> Ptr a -> DecoderMonad (Maybe CostCentreStack) +peekCostCentreStack _ ptr | ptr == nullPtr = return Nothing +peekCostCentreStack loopBreakers ptr | Set.member ptr loopBreakers = return Nothing +peekCostCentreStack loopBreakers ptr = do + cache <- get + let ptrAsInt = ptrToInt ptr + if IntMap.member ptrAsInt (ccsCache cache) then do + liftIO $ print $ "CCS Cache hit : " ++ show ptr + -- TODO: There's a IntMap function that returns a Maybe + return $ Just $ (ccsCache cache) IntMap.! ptrAsInt + else do + liftIO $ print $ "peekCostCentreStack - ptr : " ++ show ptr + ccs_ccsID' <- liftIO $ (#peek struct CostCentreStack_, ccsID) ptr + ccs_cc_ptr <- liftIO $ (#peek struct CostCentreStack_, cc) ptr + ccs_cc' <- peekCostCentre ccs_cc_ptr + ccs_prevStack_ptr <- liftIO $ (#peek struct CostCentreStack_, prevStack) ptr + -- TODO: Extract loopBreakers' to remove duplication + ccs_prevStack' <- peekCostCentreStack (Set.insert ptr loopBreakers) ccs_prevStack_ptr + -- TODO: Decide about index tables + ccs_indexTable_ptr <- liftIO $ (#peek struct CostCentreStack_, indexTable) ptr + ccs_indexTable' <- peekIndexTable (Set.insert ptr loopBreakers) ccs_indexTable_ptr + ccs_root_ptr <- liftIO $ (#peek struct CostCentreStack_, root) ptr + ccs_root' <- peekCostCentreStack (Set.insert ptr loopBreakers) ccs_root_ptr + ccs_depth' <- liftIO $ (#peek struct CostCentreStack_, depth) ptr + ccs_scc_count' <- liftIO $ (#peek struct CostCentreStack_, scc_count) ptr + ccs_selected' <- liftIO $ (#peek struct CostCentreStack_, selected) ptr + ccs_time_ticks' <- liftIO $ (#peek struct CostCentreStack_, time_ticks) ptr + ccs_mem_alloc' <- liftIO $ (#peek struct CostCentreStack_, mem_alloc) ptr + ccs_inherited_alloc' <- liftIO $ (#peek struct CostCentreStack_, inherited_alloc) ptr + ccs_inherited_ticks' <- liftIO $ (#peek struct CostCentreStack_, inherited_ticks) ptr + + let result = CostCentreStack { + ccs_ccsID = ccs_ccsID', + ccs_cc = ccs_cc', + ccs_prevStack = ccs_prevStack', + ccs_indexTable = ccs_indexTable', + ccs_root = ccs_root', + ccs_depth = ccs_depth', + ccs_scc_count = ccs_scc_count', + ccs_selected = ccs_selected', + ccs_time_ticks = ccs_time_ticks', + ccs_mem_alloc = ccs_mem_alloc', + ccs_inherited_alloc = ccs_inherited_alloc', + ccs_inherited_ticks = ccs_inherited_ticks' + } + + let updatedCCSCache = IntMap.insert ptrAsInt result (ccsCache cache) + put $ cache { ccsCache = updatedCCSCache } + + return $ Just result + +peekCostCentre :: Ptr a -> DecoderMonad CostCentre +peekCostCentre ptr = do + cache <- get + let ptrAsInt = ptrToInt ptr + if IntMap.member ptrAsInt (ccCache cache) then do + liftIO $ print $ "CC Cache hit : " ++ show ptr + return $ (ccCache cache) IntMap.! ptrAsInt + else do + cc_ccID' <- liftIO $ (#peek struct CostCentre_, ccID) ptr + cc_label_ptr <- liftIO $ (#peek struct CostCentre_, label) ptr + cc_label' <- liftIO $ peekCString cc_label_ptr + cc_module_ptr <- liftIO $ (#peek struct CostCentre_, module) ptr + cc_module' <- liftIO $ peekCString cc_module_ptr + cc_srcloc_ptr <- liftIO $ (#peek struct CostCentre_, srcloc) ptr + cc_srcloc' <- liftIO $ do + if cc_srcloc_ptr == nullPtr then + return Nothing + else + fmap Just (peekCString cc_srcloc_ptr) + cc_mem_alloc' <- liftIO $ (#peek struct CostCentre_, mem_alloc) ptr + cc_time_ticks' <- liftIO $ (#peek struct CostCentre_, time_ticks) ptr + cc_is_caf' <- liftIO $ (#peek struct CostCentre_, is_caf) ptr + cc_link_ptr <- liftIO $ (#peek struct CostCentre_, link) ptr + cc_link' <- if cc_link_ptr == nullPtr then + return Nothing + else + fmap Just (peekCostCentre cc_link_ptr) + + let result = CostCentre { + cc_ccID = cc_ccID', + cc_label = cc_label', + cc_module = cc_module', + cc_srcloc = cc_srcloc', + cc_mem_alloc = cc_mem_alloc', + cc_time_ticks = cc_time_ticks', + cc_is_caf = cc_is_caf', + cc_link = cc_link' + } + + let updatedCCCache = IntMap.insert ptrAsInt result (ccCache cache) + put $ cache { ccCache = updatedCCCache } + + return result + +peekIndexTable :: Set (Ptr costCentreStack) -> Ptr a -> DecoderMonad (Maybe IndexTable) +peekIndexTable _ ptr | ptr == nullPtr = return Nothing +peekIndexTable loopBreakers ptr = do + cache <- get + let ptrAsInt = ptrToInt ptr + if IntMap.member ptrAsInt (indexTableCache cache) then do + liftIO $ print $ "IndexTable Cache hit : " ++ show ptr + return $ Just $ (indexTableCache cache) IntMap.! ptrAsInt + else do + it_cc_ptr <- liftIO $ (#peek struct IndexTable_, cc) ptr + it_cc' <- peekCostCentre it_cc_ptr + it_ccs_ptr <- liftIO $ (#peek struct IndexTable_, ccs) ptr + it_ccs' <- peekCostCentreStack loopBreakers it_ccs_ptr + it_next_ptr <- liftIO $ (#peek struct IndexTable_, next) ptr + it_next' <- peekIndexTable loopBreakers it_next_ptr + it_back_edge' <- liftIO $ (#peek struct IndexTable_, back_edge) ptr + + let result = IndexTable { + it_cc = it_cc', + it_ccs = it_ccs', + it_next = it_next', + it_back_edge = it_back_edge' + } + + let updatedIndexTableCache = IntMap.insert ptrAsInt result (indexTableCache cache) + put $ cache { indexTableCache = updatedIndexTableCache } + + return $ Just result +#endif ===================================== libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/Types.hs ===================================== @@ -0,0 +1,44 @@ +{-# LANGUAGE DeriveGeneric #-} + +module GHC.Exts.Heap.ProfInfo.Types where + +import Prelude +import Data.Word +import GHC.Generics + +data StgTSOProfInfo = StgTSOProfInfo { + cccs :: Maybe CostCentreStack +} deriving (Show, Generic) + +data CostCentreStack = CostCentreStack { + ccs_ccsID :: Int, + ccs_cc :: CostCentre, + ccs_prevStack :: Maybe CostCentreStack, + ccs_indexTable :: Maybe IndexTable, + ccs_root :: Maybe CostCentreStack, + ccs_depth :: Word, + ccs_scc_count :: Word64, + ccs_selected :: Word, + ccs_time_ticks :: Word, + ccs_mem_alloc :: Word64, + ccs_inherited_alloc :: Word64, + ccs_inherited_ticks :: Word +} deriving (Show, Generic) + +data CostCentre = CostCentre { + cc_ccID :: Int, + cc_label :: String, + cc_module :: String, + cc_srcloc :: Maybe String, + cc_mem_alloc :: Word64, + cc_time_ticks :: Word, + cc_is_caf :: Bool, + cc_link :: Maybe CostCentre +} deriving (Show, Generic) + +data IndexTable = IndexTable { + it_cc :: CostCentre, + it_ccs :: Maybe CostCentreStack, + it_next :: Maybe IndexTable, + it_back_edge :: Bool +} deriving (Show, Generic) ===================================== libraries/ghc-heap/GHC/Exts/Heap/Ptr/Utils.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE CPP, DeriveGeneric, MagicHash #-} + +module GHC.Exts.Heap.Ptr.Utils where + +import Prelude +import GHC.Ptr +import GHC.Exts + +-- | casts a @Ptr@ to an @Int@ +ptrToInt :: Ptr a -> Int +ptrToInt (Ptr a#) = I# (addr2Int# a#) ===================================== libraries/ghc-heap/cbits/utils.c ===================================== @@ -0,0 +1,8 @@ +#include +#include "Rts.h" + +bool isEndTsoQueue(StgTSO* tso){ + errorBelch("tso: %p", tso); + errorBelch("END_TSO_QUEUE: %p", END_TSO_QUEUE); + return tso == END_TSO_QUEUE; +} ===================================== libraries/ghc-heap/ghc-heap.cabal.in ===================================== @@ -25,9 +25,12 @@ library build-depends: base >= 4.9.0 && < 5.0 , ghc-prim > 0.2 && < 0.7 , rts == 1.0.* + , containers >= 0.6.2.1 && < 0.7 + , transformers == 0.5.* ghc-options: -Wall cmm-sources: cbits/HeapPrim.cmm + c-sources: cbits/utils.c default-extensions: NoImplicitPrelude @@ -40,3 +43,6 @@ library GHC.Exts.Heap.InfoTableProf GHC.Exts.Heap.Utils GHC.Exts.Heap.FFIClosures + GHC.Exts.Heap.ProfInfo.Types + GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled + GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled ===================================== libraries/ghc-heap/tests/all.T ===================================== @@ -49,3 +49,11 @@ test('list_threads_and_misc_roots', ignore_stderr ], multi_compile_and_run, ['list_threads_and_misc_roots', [('list_threads_and_misc_roots_c.c','')], '-threaded']) + +test('prof_info', + [extra_files(['create_tso.c','create_tso.h']), + ignore_stdout, + ignore_stderr, +# only_ways(prof_ways) + ], + multi_compile_and_run, ['prof_info', [('create_tso.c','-optc=-g -opta=-g')], '-prof -debug -fprof-auto']) ===================================== libraries/ghc-heap/tests/prof_info.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface, MagicHash, CPP, BangPatterns #-} + +import Foreign +import Foreign.C.Types +import GHC.Exts.Heap +import GHC.Exts + +import GHC.Word + +#include "ghcconfig.h" +#include "rts/Constants.h" + +foreign import ccall unsafe "create_tso.h create_tso" + c_create_tso:: IO Word + +-- Invent a type to bypass the type constraints of getClosureData. +-- Infact this will be a Word#, that is directly given to unpackClosure# +-- (which is a primop that expects a pointer to a closure). +data FoolStgTSO + +-- We can make some assumptions about the - otherwise dynamic - properties of +-- StgTSO and StgStack, because a new, non-running TSO is created with +-- create_tso() (create_tso.c).create_tso +main :: IO () +main = do + tso <- createTSOClosure + +-- TODO: remove print, add assertion + print $ "tso : "++ show tso + +createTSOClosure :: IO (GenClosure Box) +createTSOClosure = do + ptr <- c_create_tso + let wPtr = unpackWord# ptr + getClosureData ((unsafeCoerce# wPtr) :: FoolStgTSO) + +unpackWord# :: Word -> Word# +unpackWord# (W# w#) = w# ===================================== libraries/ghc-heap/tests/tso_and_stack_closures.hs ===================================== @@ -28,8 +28,6 @@ main = do assertEqual (why_blocked tso) NotBlocked assertEqual (saved_errno tso) 0 - print $ "tso : "++ show tso - -- The newly created TSO should be on the end of the run queue. let !_linkBox = _link tso _linkClosure <- getBoxedClosureData _linkBox ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE GADTs, DeriveGeneric, StandaloneDeriving, ScopedTypeVariables, - GeneralizedNewtypeDeriving, ExistentialQuantification, RecordWildCards #-} + GeneralizedNewtypeDeriving, ExistentialQuantification, RecordWildCards, + CPP #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-orphans #-} -- | @@ -29,7 +30,7 @@ import GHCi.TH.Binary () -- For Binary instances import GHCi.BreakArray import GHC.LanguageExtensions -import GHC.Exts.Heap +import qualified GHC.Exts.Heap as Heap import GHC.ForeignSrcLang import GHC.Fingerprint import Control.Concurrent @@ -110,7 +111,7 @@ data Message a where -> Int -- constr tag -> Int -- pointer tag -> ByteString -- constructor desccription - -> Message (RemotePtr StgInfoTable) + -> Message (RemotePtr Heap.StgInfoTable) -- | Evaluate a statement EvalStmt @@ -211,7 +212,7 @@ data Message a where -- type reconstruction. GetClosure :: HValueRef - -> Message (GenClosure HValueRef) + -> Message (Heap.GenClosure HValueRef) -- | Evaluate something. This is used to support :force in GHCi. Seq @@ -449,10 +450,17 @@ instance Binary (FunPtr a) where get = castPtrToFunPtr <$> get -- Binary instances to support the GetClosure message -instance Binary StgInfoTable -instance Binary ClosureType -instance Binary PrimType -instance Binary a => Binary (GenClosure a) +#if MIN_VERSION_ghc_heap(8,11,0) +instance Binary Heap.StgTSOProfInfo +instance Binary Heap.CostCentreStack +instance Binary Heap.CostCentre +instance Binary Heap.IndexTable +#endif + +instance Binary Heap.StgInfoTable +instance Binary Heap.ClosureType +instance Binary Heap.PrimType +instance Binary a => Binary (Heap.GenClosure a) data Msg = forall a . (Binary a, Show a) => Msg (Message a) ===================================== libraries/ghci/GHCi/Run.hs ===================================== @@ -32,7 +32,7 @@ import Data.Binary.Get import Data.ByteString (ByteString) import qualified Data.ByteString.Unsafe as B import GHC.Exts -import GHC.Exts.Heap +import qualified GHC.Exts.Heap as Heap import GHC.Stack import Foreign hiding (void) import Foreign.C @@ -93,8 +93,8 @@ run m = case m of toRemotePtr <$> mkConInfoTable tc ptrs nptrs tag ptrtag desc StartTH -> startTH GetClosure ref -> do - clos <- getClosureData =<< localRef ref - mapM (\(Box x) -> mkRemoteRef (HValue x)) clos + clos <- Heap.getClosureData =<< localRef ref + mapM (\(Heap.Box x) -> mkRemoteRef (HValue x)) clos Seq ref -> doSeq ref ResumeSeq ref -> resumeSeq ref _other -> error "GHCi.Run.run" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6cc0baaafd69fb9f472d7d4116ad840cbdfe2efd...1518108a32231f34d2562be0d04805f7840e8298 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6cc0baaafd69fb9f472d7d4116ad840cbdfe2efd...1518108a32231f34d2562be0d04805f7840e8298 You're receiving 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 Jul 19 17:25:11 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Sun, 19 Jul 2020 13:25:11 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] 2 commits: Cleanup Message-ID: <5f1481f786085_80b3f84868c382839869ed@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: 45d8ae60 by Sven Tennie at 2020-07-19T18:58:49+02:00 Cleanup - - - - - 110384be by Sven Tennie at 2020-07-19T19:13:05+02:00 Query caches once, not twice - - - - - 2 changed files: - libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc - libraries/ghc-heap/tests/all.T Changes: ===================================== libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc ===================================== @@ -20,20 +20,25 @@ import GHC.Exts.Heap.ProfInfo.Types import Data.IntMap.Strict (IntMap) import qualified Data.IntMap.Strict as IntMap --- TODO: Use IntSet for better performance? -import Data.Set (Set) -import qualified Data.Set as Set +import Data.IntSet (IntSet) +import qualified Data.IntSet as IntSet import Control.Monad.Trans.State import Control.Monad.IO.Class import GHC.Exts.Heap.Ptr.Utils --- TODO: Remove cache? Looks like it's not needed anymore due to loop breakers +-- Use Int based containers for pointers (addresses) for better performance. +-- These will be queried a lot! +type AddressSet = IntSet +type AddressMap = IntMap + data Cache = Cache { - ccCache :: IntMap CostCentre, - ccsCache :: IntMap CostCentreStack, - indexTableCache :: IntMap IndexTable + ccCache :: AddressMap CostCentre, +-- TODO: Remove ccsCache? Looks like it's not needed anymore due to loop breakers + ccsCache :: AddressMap CostCentreStack, +-- TODO: Remove indexTableCache? Looks like it's not needed anymore due to loop breakers + indexTableCache :: AddressMap IndexTable } type DecoderMonad a = StateT Cache IO a @@ -42,10 +47,9 @@ peekStgTSOProfInfo :: Ptr a -> IO (Maybe StgTSOProfInfo) peekStgTSOProfInfo _ = return Nothing #else peekStgTSOProfInfo tsoPtr = do --- TODO: Use getCurrentCCS# ? Or GHC.Stack.CCS.getCurrentCCS ? print $ "peekStgTSOProfInfo - tsoPtr : " ++ show tsoPtr cccs_ptr <- peekByteOff tsoPtr cccsOffset - cccs' <- evalStateT (peekCostCentreStack Set.empty cccs_ptr) $ Cache IntMap.empty IntMap.empty IntMap.empty + cccs' <- evalStateT (peekCostCentreStack IntSet.empty cccs_ptr) $ Cache IntMap.empty IntMap.empty IntMap.empty return $ Just StgTSOProfInfo { cccs = cccs' @@ -54,127 +58,131 @@ peekStgTSOProfInfo tsoPtr = do cccsOffset :: Int cccsOffset = (#const OFFSET_StgTSO_cccs) + (#size StgHeader) -peekCostCentreStack :: Set (Ptr a) -> Ptr a -> DecoderMonad (Maybe CostCentreStack) +peekCostCentreStack :: AddressSet -> Ptr costCentreStack -> DecoderMonad (Maybe CostCentreStack) peekCostCentreStack _ ptr | ptr == nullPtr = return Nothing -peekCostCentreStack loopBreakers ptr | Set.member ptr loopBreakers = return Nothing +peekCostCentreStack loopBreakers ptr | IntSet.member (ptrToInt ptr) loopBreakers = return Nothing peekCostCentreStack loopBreakers ptr = do cache <- get - let ptrAsInt = ptrToInt ptr - if IntMap.member ptrAsInt (ccsCache cache) then do - liftIO $ print $ "CCS Cache hit : " ++ show ptr - -- TODO: There's a IntMap function that returns a Maybe - return $ Just $ (ccsCache cache) IntMap.! ptrAsInt - else do - liftIO $ print $ "peekCostCentreStack - ptr : " ++ show ptr - ccs_ccsID' <- liftIO $ (#peek struct CostCentreStack_, ccsID) ptr - ccs_cc_ptr <- liftIO $ (#peek struct CostCentreStack_, cc) ptr - ccs_cc' <- peekCostCentre ccs_cc_ptr - ccs_prevStack_ptr <- liftIO $ (#peek struct CostCentreStack_, prevStack) ptr - -- TODO: Extract loopBreakers' to remove duplication - ccs_prevStack' <- peekCostCentreStack (Set.insert ptr loopBreakers) ccs_prevStack_ptr - -- TODO: Decide about index tables - ccs_indexTable_ptr <- liftIO $ (#peek struct CostCentreStack_, indexTable) ptr - ccs_indexTable' <- peekIndexTable (Set.insert ptr loopBreakers) ccs_indexTable_ptr - ccs_root_ptr <- liftIO $ (#peek struct CostCentreStack_, root) ptr - ccs_root' <- peekCostCentreStack (Set.insert ptr loopBreakers) ccs_root_ptr - ccs_depth' <- liftIO $ (#peek struct CostCentreStack_, depth) ptr - ccs_scc_count' <- liftIO $ (#peek struct CostCentreStack_, scc_count) ptr - ccs_selected' <- liftIO $ (#peek struct CostCentreStack_, selected) ptr - ccs_time_ticks' <- liftIO $ (#peek struct CostCentreStack_, time_ticks) ptr - ccs_mem_alloc' <- liftIO $ (#peek struct CostCentreStack_, mem_alloc) ptr - ccs_inherited_alloc' <- liftIO $ (#peek struct CostCentreStack_, inherited_alloc) ptr - ccs_inherited_ticks' <- liftIO $ (#peek struct CostCentreStack_, inherited_ticks) ptr - - let result = CostCentreStack { - ccs_ccsID = ccs_ccsID', - ccs_cc = ccs_cc', - ccs_prevStack = ccs_prevStack', - ccs_indexTable = ccs_indexTable', - ccs_root = ccs_root', - ccs_depth = ccs_depth', - ccs_scc_count = ccs_scc_count', - ccs_selected = ccs_selected', - ccs_time_ticks = ccs_time_ticks', - ccs_mem_alloc = ccs_mem_alloc', - ccs_inherited_alloc = ccs_inherited_alloc', - ccs_inherited_ticks = ccs_inherited_ticks' - } - - let updatedCCSCache = IntMap.insert ptrAsInt result (ccsCache cache) - put $ cache { ccsCache = updatedCCSCache } - - return $ Just result - -peekCostCentre :: Ptr a -> DecoderMonad CostCentre + case IntMap.lookup ptrAsInt (ccsCache cache) of + found@(Just _) -> do + liftIO $ print $ "CCS Cache hit : " ++ show ptr + return found + Nothing -> do + liftIO $ print $ "peekCostCentreStack - ptr : " ++ show ptr + ccs_ccsID' <- liftIO $ (#peek struct CostCentreStack_, ccsID) ptr + ccs_cc_ptr <- liftIO $ (#peek struct CostCentreStack_, cc) ptr + ccs_cc' <- peekCostCentre ccs_cc_ptr + ccs_prevStack_ptr <- liftIO $ (#peek struct CostCentreStack_, prevStack) ptr + let loopBreakers' = (IntSet.insert ptrAsInt loopBreakers) + ccs_prevStack' <- peekCostCentreStack loopBreakers' ccs_prevStack_ptr + ccs_indexTable_ptr <- liftIO $ (#peek struct CostCentreStack_, indexTable) ptr + ccs_indexTable' <- peekIndexTable loopBreakers' ccs_indexTable_ptr + ccs_root_ptr <- liftIO $ (#peek struct CostCentreStack_, root) ptr + ccs_root' <- peekCostCentreStack loopBreakers' ccs_root_ptr + ccs_depth' <- liftIO $ (#peek struct CostCentreStack_, depth) ptr + ccs_scc_count' <- liftIO $ (#peek struct CostCentreStack_, scc_count) ptr + ccs_selected' <- liftIO $ (#peek struct CostCentreStack_, selected) ptr + ccs_time_ticks' <- liftIO $ (#peek struct CostCentreStack_, time_ticks) ptr + ccs_mem_alloc' <- liftIO $ (#peek struct CostCentreStack_, mem_alloc) ptr + ccs_inherited_alloc' <- liftIO $ (#peek struct CostCentreStack_, inherited_alloc) ptr + ccs_inherited_ticks' <- liftIO $ (#peek struct CostCentreStack_, inherited_ticks) ptr + + let result = CostCentreStack { + ccs_ccsID = ccs_ccsID', + ccs_cc = ccs_cc', + ccs_prevStack = ccs_prevStack', + ccs_indexTable = ccs_indexTable', + ccs_root = ccs_root', + ccs_depth = ccs_depth', + ccs_scc_count = ccs_scc_count', + ccs_selected = ccs_selected', + ccs_time_ticks = ccs_time_ticks', + ccs_mem_alloc = ccs_mem_alloc', + ccs_inherited_alloc = ccs_inherited_alloc', + ccs_inherited_ticks = ccs_inherited_ticks' + } + + let updatedCCSCache = IntMap.insert ptrAsInt result (ccsCache cache) + put $ cache { ccsCache = updatedCCSCache } + + return $ Just result + where + ptrAsInt = ptrToInt ptr + +peekCostCentre :: Ptr costCentre -> DecoderMonad CostCentre peekCostCentre ptr = do cache <- get - let ptrAsInt = ptrToInt ptr - if IntMap.member ptrAsInt (ccCache cache) then do - liftIO $ print $ "CC Cache hit : " ++ show ptr - return $ (ccCache cache) IntMap.! ptrAsInt - else do - cc_ccID' <- liftIO $ (#peek struct CostCentre_, ccID) ptr - cc_label_ptr <- liftIO $ (#peek struct CostCentre_, label) ptr - cc_label' <- liftIO $ peekCString cc_label_ptr - cc_module_ptr <- liftIO $ (#peek struct CostCentre_, module) ptr - cc_module' <- liftIO $ peekCString cc_module_ptr - cc_srcloc_ptr <- liftIO $ (#peek struct CostCentre_, srcloc) ptr - cc_srcloc' <- liftIO $ do - if cc_srcloc_ptr == nullPtr then - return Nothing - else - fmap Just (peekCString cc_srcloc_ptr) - cc_mem_alloc' <- liftIO $ (#peek struct CostCentre_, mem_alloc) ptr - cc_time_ticks' <- liftIO $ (#peek struct CostCentre_, time_ticks) ptr - cc_is_caf' <- liftIO $ (#peek struct CostCentre_, is_caf) ptr - cc_link_ptr <- liftIO $ (#peek struct CostCentre_, link) ptr - cc_link' <- if cc_link_ptr == nullPtr then - return Nothing - else - fmap Just (peekCostCentre cc_link_ptr) - - let result = CostCentre { - cc_ccID = cc_ccID', - cc_label = cc_label', - cc_module = cc_module', - cc_srcloc = cc_srcloc', - cc_mem_alloc = cc_mem_alloc', - cc_time_ticks = cc_time_ticks', - cc_is_caf = cc_is_caf', - cc_link = cc_link' - } - - let updatedCCCache = IntMap.insert ptrAsInt result (ccCache cache) - put $ cache { ccCache = updatedCCCache } - - return result - -peekIndexTable :: Set (Ptr costCentreStack) -> Ptr a -> DecoderMonad (Maybe IndexTable) + case IntMap.lookup ptrAsInt (ccCache cache) of + (Just a) -> do + liftIO $ print $ "CC Cache hit : " ++ show ptr + return a + Nothing -> do + cc_ccID' <- liftIO $ (#peek struct CostCentre_, ccID) ptr + cc_label_ptr <- liftIO $ (#peek struct CostCentre_, label) ptr + cc_label' <- liftIO $ peekCString cc_label_ptr + cc_module_ptr <- liftIO $ (#peek struct CostCentre_, module) ptr + cc_module' <- liftIO $ peekCString cc_module_ptr + cc_srcloc_ptr <- liftIO $ (#peek struct CostCentre_, srcloc) ptr + cc_srcloc' <- liftIO $ do + if cc_srcloc_ptr == nullPtr then + return Nothing + else + fmap Just (peekCString cc_srcloc_ptr) + cc_mem_alloc' <- liftIO $ (#peek struct CostCentre_, mem_alloc) ptr + cc_time_ticks' <- liftIO $ (#peek struct CostCentre_, time_ticks) ptr + cc_is_caf' <- liftIO $ (#peek struct CostCentre_, is_caf) ptr + cc_link_ptr <- liftIO $ (#peek struct CostCentre_, link) ptr + cc_link' <- if cc_link_ptr == nullPtr then + return Nothing + else + fmap Just (peekCostCentre cc_link_ptr) + + let result = CostCentre { + cc_ccID = cc_ccID', + cc_label = cc_label', + cc_module = cc_module', + cc_srcloc = cc_srcloc', + cc_mem_alloc = cc_mem_alloc', + cc_time_ticks = cc_time_ticks', + cc_is_caf = cc_is_caf', + cc_link = cc_link' + } + + let updatedCCCache = IntMap.insert ptrAsInt result (ccCache cache) + put $ cache { ccCache = updatedCCCache } + + return result + where + ptrAsInt = ptrToInt ptr + +peekIndexTable :: AddressSet -> Ptr indexTable -> DecoderMonad (Maybe IndexTable) peekIndexTable _ ptr | ptr == nullPtr = return Nothing peekIndexTable loopBreakers ptr = do cache <- get - let ptrAsInt = ptrToInt ptr - if IntMap.member ptrAsInt (indexTableCache cache) then do - liftIO $ print $ "IndexTable Cache hit : " ++ show ptr - return $ Just $ (indexTableCache cache) IntMap.! ptrAsInt - else do - it_cc_ptr <- liftIO $ (#peek struct IndexTable_, cc) ptr - it_cc' <- peekCostCentre it_cc_ptr - it_ccs_ptr <- liftIO $ (#peek struct IndexTable_, ccs) ptr - it_ccs' <- peekCostCentreStack loopBreakers it_ccs_ptr - it_next_ptr <- liftIO $ (#peek struct IndexTable_, next) ptr - it_next' <- peekIndexTable loopBreakers it_next_ptr - it_back_edge' <- liftIO $ (#peek struct IndexTable_, back_edge) ptr - - let result = IndexTable { - it_cc = it_cc', - it_ccs = it_ccs', - it_next = it_next', - it_back_edge = it_back_edge' - } - - let updatedIndexTableCache = IntMap.insert ptrAsInt result (indexTableCache cache) - put $ cache { indexTableCache = updatedIndexTableCache } - - return $ Just result + case IntMap.lookup ptrAsInt (indexTableCache cache) of + found@(Just _) -> do + liftIO $ print $ "IndexTable Cache hit : " ++ show ptr + return found + Nothing -> do + it_cc_ptr <- liftIO $ (#peek struct IndexTable_, cc) ptr + it_cc' <- peekCostCentre it_cc_ptr + it_ccs_ptr <- liftIO $ (#peek struct IndexTable_, ccs) ptr + it_ccs' <- peekCostCentreStack loopBreakers it_ccs_ptr + it_next_ptr <- liftIO $ (#peek struct IndexTable_, next) ptr + it_next' <- peekIndexTable loopBreakers it_next_ptr + it_back_edge' <- liftIO $ (#peek struct IndexTable_, back_edge) ptr + + let result = IndexTable { + it_cc = it_cc', + it_ccs = it_ccs', + it_next = it_next', + it_back_edge = it_back_edge' + } + + let updatedIndexTableCache = IntMap.insert ptrAsInt result (indexTableCache cache) + put $ cache { indexTableCache = updatedIndexTableCache } + + return $ Just result + where + ptrAsInt = ptrToInt ptr #endif ===================================== libraries/ghc-heap/tests/all.T ===================================== @@ -54,6 +54,7 @@ test('prof_info', [extra_files(['create_tso.c','create_tso.h']), ignore_stdout, ignore_stderr, +# TODO: What about this? # only_ways(prof_ways) ], multi_compile_and_run, ['prof_info', [('create_tso.c','-optc=-g -opta=-g')], '-prof -debug -fprof-auto']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1518108a32231f34d2562be0d04805f7840e8298...110384be47589ba00f8b926d13bf883605a9b20b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1518108a32231f34d2562be0d04805f7840e8298...110384be47589ba00f8b926d13bf883605a9b20b You're receiving 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 Jul 19 19:05:19 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 19 Jul 2020 15:05:19 -0400 Subject: [Git][ghc/ghc][master] 10 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f14996f8b099_80b3f84901582f039965e4@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst - hadrian/hadrian.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c0979cc53442b3a6202acab9cf164f0a4beea0b7...c26e81d116a653b5259aeb290fb1e697efe3382a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c0979cc53442b3a6202acab9cf164f0a4beea0b7...c26e81d116a653b5259aeb290fb1e697efe3382a You're receiving 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 Jul 19 22:39:55 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sun, 19 Jul 2020 18:39:55 -0400 Subject: [Git][ghc/ghc][wip/az/exactprint] 2 commits: Proof of Concept implementation of in-tree API Annotations Message-ID: <5f14cbbb812d2_80b3f849254123440405ad@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/exactprint at Glasgow Haskell Compiler / GHC Commits: bc37f9ab by Alan Zimmerman at 2020-07-14T22:29:33+01:00 Proof of Concept implementation of in-tree API Annotations This MR introduces a possible machinery to introduce API Annotations into the TTG extension points. It is intended to be a concrete example for discussion. It still needs to process comments. ---- Work in progress, adding more TTG extensions for annotations. And fixing ppr round-trip tests by being able to blank out in-tree annotations, as done with SrcSpans. This is needed for the case of class Foo a where for which current ppr does not print the "where". Rename AA to AddApiAnn and AA to AddAnn Add XConPatIn and XConPatOut Rebase ---- First pass at bringing in LocatedA for API anns in locations Treatment of ECP in parsing is provisional at this stage, leads to some horribly stuff in Parser.y and RdrHsSyn. It is an extensive but not invasive change. I think (AZ). Locally it reports some parsing tests using less memory. Add ApiAnns to the HsExpr data structure. rebase. Change HsMatchContext and HsStmtContext to use an id, not a GhcPass parameter. Add ApiAnns to Hs/Types Rebase Rebased 2020-03-25 WIP on in-tree annotations Includes updating HsModule Imports LocateA ImportDecl so we can hang AnnSemi off it A whole bunch of stuff more InjectivityAnn and FamEqn now have annotations in them Add annotations to context srcspan ---- In-tree annotations: LHsDecl and LHsBind LocatedA ---- WIP on in-tree annotations ---- in-tree annotations: LHsType is now LocatedA ---- FunDeps is now also a HS data type ---- WIP. Added LocatedA to Pat, Expr, Decl And worked some more through Parser.y ---- LStmt now Located ---- Finished working through Parser.y, tests seem ok failures relate to annotations. Adding test infrastructure for check-exact Like check-ppr, but checking for an exact reproduction of the parsed source file. Starting to work on actual exact printer Bring in ApiAnnName As an alternative for LocatedA, to be used for names only. Carrying extra name adornments, such as locations of backticks, parens, etc. Working on changing ApiAnnName to accurately reflect actual usage Get rid of AnnApiName in favour of LocatedN Working on check-exact. Making progress Working on the ghc-exact bit Progress, can reproduce the first Test.hs file. Move API Annotations out of the extensions to annotations - - - - - fdc51196 by Alan Zimmerman at 2020-07-19T23:38:49+01:00 Remove LHsLocalBinds - - - - - 20 changed files: - .gitmodules - compiler/GHC.hs - compiler/GHC/Data/BooleanFormula.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - + compiler/GHC/Hs/Exact.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Expr.hs-boot - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Stats.hs - compiler/GHC/Hs/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ab141bcc82a3c1ad5873cb22d95bc6518b057628...fdc5119622740ad6eff59bc0dd6df4c51981f294 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ab141bcc82a3c1ad5873cb22d95bc6518b057628...fdc5119622740ad6eff59bc0dd6df4c51981f294 You're receiving 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 Jul 20 02:02:13 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Sun, 19 Jul 2020 22:02:13 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] 2 commits: Fix T10955dyn? Message-ID: <5f14fb252e939_80b104edf4440433db@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 4c242580 by Moritz Angermann at 2020-07-20T01:59:06+00:00 Fix T10955dyn? - - - - - 8c0f7459 by Moritz Angermann at 2020-07-20T02:01:58+00:00 cleanup - - - - - 3 changed files: - testsuite/tests/ghci/linking/dyn/Makefile - − testsuite/tests/ghci/linking/dyn/T10955dyn.stderr - − testsuite/tests/ghci/linking/dyn/load_short_name.stderr Changes: ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -24,7 +24,7 @@ else CFLAGS = -fPIC endif -MY_TEST_HC_OPTS = $(TEST_HC_OPTS) $(CFLAGS) +MY_TEST_HC_OPTS = $(filter-out -rtsopts,$(TEST_HC_OPTS)) $(CFLAGS) # -------------------------------------------------------------- # Note: libAS.def is not used directly in these tests but is @@ -74,7 +74,7 @@ compile_libAB_dyn: '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dyn" -shared B.c -o "bin_dyn/$(call DLL,B)" -lA -L"./bin_dyn" rm -f bin_dyn/*.a '$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -v0 -o "bin_dyn/$(call EXE,T10955dyn)" -L./bin_dyn -lB -lA T10955dyn.hs -v0 - LD_LIBRARY_PATH=./bin_dyn '$(TEST_WRAPPER)' ./bin_dyn/$(call EXE,T10955dyn) + '$(TEST_WRAPPER)' LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: ===================================== testsuite/tests/ghci/linking/dyn/T10955dyn.stderr deleted ===================================== @@ -1,4 +0,0 @@ -Warning: -rtsopts and -with-rtsopts have no effect with -shared. - Call hs_init_ghc() from your main() function to set these options. -Warning: -rtsopts and -with-rtsopts have no effect with -shared. - Call hs_init_ghc() from your main() function to set these options. ===================================== testsuite/tests/ghci/linking/dyn/load_short_name.stderr deleted ===================================== @@ -1,2 +0,0 @@ -Warning: -rtsopts and -with-rtsopts have no effect with -shared. - Call hs_init_ghc() from your main() function to set these options. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/41e6465e2197f628287794f23ae950f1597a8480...8c0f74595cbb6736a934404f3b90b509b229d16a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/41e6465e2197f628287794f23ae950f1597a8480...8c0f74595cbb6736a934404f3b90b509b229d16a You're receiving 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 Jul 20 05:05:08 2020 From: gitlab at gitlab.haskell.org (Peter Trommler) Date: Mon, 20 Jul 2020 01:05:08 -0400 Subject: [Git][ghc/ghc][wip/cross-ppr-floats] 11 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f152604ceff3_80b114037a440458c4@gitlab.haskell.org.mail> Peter Trommler pushed to branch wip/cross-ppr-floats at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 180a446b by Peter Trommler at 2020-07-20T01:05:06-04:00 PPC and X86: Portable printing of IEEE floats GNU as and the AIX assembler support floating point literals. SPARC seems to have support too but I cannot test on SPARC. Curiously, `doubleToBytes` is also used in the LLVM backend. To avoid endianness issues when cross-compiling float and double literals are printed as C-style floating point values. The assembler then takes care of memory layout and endianness. This was brought up in #18431 by @hsyl20. - - - - - 30 changed files: - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/SPARC/Ppr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2b1e26e032e0407cc90558c8b2d4f5a6571547a...180a446b920bb8d0a2999d52f1fbff8068d4722c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2b1e26e032e0407cc90558c8b2d4f5a6571547a...180a446b920bb8d0a2999d52f1fbff8068d4722c You're receiving 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 Jul 20 05:43:34 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 20 Jul 2020 01:43:34 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 11 commits: Fix MO_SF_Conv Message-ID: <5f152f067c3a3_80b114037a440461c3@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 94769087 by Moritz Angermann at 2020-07-18T00:00:00+00:00 Fix MO_SF_Conv - - - - - 6138e2f1 by Moritz Angermann at 2020-07-18T00:00:00+00:00 Add Comment re MO_Memcpy - - - - - 11ee14ae by Moritz Angermann at 2020-07-18T00:00:00+00:00 Always PIC via GOT - - - - - c806f76a by Moritz Angermann at 2020-07-18T00:00:00+00:00 Fix up generated assembly. Don't generate identity moves e.g. mov x18, x18 - - - - - 1c66c543 by Moritz Angermann at 2020-07-18T00:00:00+00:00 Drop superfulous alignment generation. - - - - - b977926b by Moritz Angermann at 2020-07-18T00:00:00+00:00 Hadrian :fire: - - - - - 456f08b2 by Moritz Angermann at 2020-07-18T00:00:00+00:00 Address Tekenobus comments. Thanks! - - - - - ec2f768d by Moritz Angermann at 2020-07-19T00:00:00+00:00 Adds J to distinguish jumps from B. Maybe this would be better handled with a phantom type? - - - - - 3bf25c2b by Moritz Angermann at 2020-07-19T00:00:00+00:00 Make sp an Operand - - - - - dbcf0669 by Moritz Angermann at 2020-07-19T00:00:20+00:00 allocMoreStack This is still broken, as we can't spill into arbitrary ranges. Hence while we can allocate extra space, we can't really spill past 4096 offsets due to the immediat having to be encoded. This leaves us with a max of 512 spill slots. We *can* work around this if we change the sp though. - - - - - b765dfe4 by Moritz Angermann at 2020-07-19T00:00:00+00:00 [Spill/Reload] Spill Around :fire: - - - - - 15 changed files: - 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/Instr.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/State.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/SPARC/Instr.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - hadrian/src/Oracles/Flag.hs Changes: ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -275,7 +275,7 @@ aarch64NcgImpl config ,pprNatCmmDecl = AArch64.Ppr.pprNatCmmDecl config ,maxSpillSlots = AArch64.Instr.maxSpillSlots config ,allocatableRegs = AArch64.Regs.allocatableRegs platform - ,ncgAllocMoreStack = noAllocMoreStack + ,ncgAllocMoreStack = AArch64.Instr.noAllocMoreStack ,ncgExpandTop = id ,ncgMakeFarBranches = const id ,extractUnwindPoints = const [] ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -575,7 +575,7 @@ getRegister' config plat expr MO_S_Neg w -> return $ Any (intFormat w) (\dst -> code `snocOL` NEG (OpReg w dst) (OpReg w reg)) MO_F_Neg w -> return $ Any (floatFormat w) (\dst -> code `snocOL` NEG (OpReg w dst) (OpReg w reg)) - MO_SF_Conv from to -> return $ Any (intFormat to) (\dst -> code `snocOL` SCVTF (OpReg to dst) (OpReg from reg)) -- (Signed ConVerT Float) + MO_SF_Conv from to -> return $ Any (floatFormat to) (\dst -> code `snocOL` SCVTF (OpReg to dst) (OpReg from reg)) -- (Signed ConVerT Float) MO_FS_Conv from to -> return $ Any (intFormat to) (\dst -> code `snocOL` FCVTZS (OpReg to dst) (OpReg from reg)) -- (float convert (-> zero) signed) -- XXX this is very hacky @@ -905,7 +905,7 @@ assignReg_FltCode = assignReg_IntCode -- Jumps genJump :: CmmExpr{-the branch target-} -> [Reg] -> NatM InstrBlock genJump (CmmLit (CmmLabel lbl)) regs - = return $ unitOL (B (TLabel lbl)) + = return $ unitOL (J (TLabel lbl)) -- = return (toOL [ PUSH_STACK_FRAME -- , DELTA (-16) -- , B (TLabel lbl) @@ -913,7 +913,7 @@ genJump (CmmLit (CmmLabel lbl)) regs -- , DELTA 0] ) genJump expr regs = do (target, _format, code) <- getSomeReg expr - return (code `appOL` unitOL (ANN (text $ show expr) (B (TReg target))) + return (code `appOL` unitOL (ANN (text $ show expr) (J (TReg target))) -- toOL [ PUSH_STACK_FRAME -- , DELTA (-16) -- , B (TReg target) @@ -1204,6 +1204,11 @@ genCCall target dest_regs arg_regs bid = do -- Memory copy/set/move/cmp, with alignment for optimization + -- XXX Optimize and use e.g. quad registers to move memory around instead + -- of offloading this to memcpy. For small memcpys we can utilize + -- the 128bit quad registers in NEON to move block of bytes around. + -- Might also make sense of small memsets? Use xzr? What's the function + -- call overhead? MO_Memcpy _align -> mkCCall "memcpy" MO_Memset _align -> mkCCall "memset" MO_Memmove _align -> mkCCall "memmove" ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -127,6 +127,7 @@ aarch64_regUsageOfInstr platform instr = case instr of ROR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) TST src1 src2 -> usage (regOp src1 ++ regOp src2, []) -- 4. Branch Instructions ---------------------------------------------------- + J t -> usage (regTarget t, []) B t -> usage (regTarget t, []) BCOND _ t -> usage (regTarget t, []) BL t -> usage (regTarget t, callerSavedRegisters) @@ -252,6 +253,7 @@ aarch64_patchRegsOfInstr instr env = case instr of TST o1 o2 -> TST (patchOp o1) (patchOp o2) -- 4. Branch Instructions -------------------------------------------------- + J t -> J (patchTarget t) B t -> B (patchTarget t) BL t -> BL (patchTarget t) BCOND c t -> BCOND c (patchTarget t) @@ -298,6 +300,7 @@ aarch64_isJumpishInstr instr = case instr of ANN _ i -> aarch64_isJumpishInstr i CBZ{} -> True CBNZ{} -> True + J{} -> True B{} -> True BL{} -> True BCOND{} -> True @@ -310,6 +313,7 @@ aarch64_jumpDestsOfInstr :: Instr -> [BlockId] aarch64_jumpDestsOfInstr (ANN _ i) = aarch64_jumpDestsOfInstr i aarch64_jumpDestsOfInstr (CBZ _ t) = [ id | TBlock id <- [t]] aarch64_jumpDestsOfInstr (CBNZ _ t) = [ id | TBlock id <- [t]] +aarch64_jumpDestsOfInstr (J t) = [id | TBlock id <- [t]] aarch64_jumpDestsOfInstr (B t) = [id | TBlock id <- [t]] aarch64_jumpDestsOfInstr (BL t) = [ id | TBlock id <- [t]] aarch64_jumpDestsOfInstr (BCOND _ t) = [ id | TBlock id <- [t]] @@ -324,10 +328,11 @@ aarch64_patchJumpInstr instr patchF ANN d i -> ANN d (aarch64_patchJumpInstr i patchF) CBZ r (TBlock bid) -> CBZ r (TBlock (patchF bid)) CBNZ r (TBlock bid) -> CBNZ r (TBlock (patchF bid)) + J (TBlock bid) -> J (TBlock (patchF bid)) B (TBlock bid) -> B (TBlock (patchF bid)) BL (TBlock bid) -> BL (TBlock (patchF bid)) BCOND c (TBlock bid) -> BCOND c (TBlock (patchF bid)) - _ -> pprPanic "patchJumpInstr" (text "") + _ -> pprPanic "patchJumpInstr" (text $ show instr) -- ----------------------------------------------------------------------------- @@ -337,10 +342,28 @@ aarch64_mkSpillInstr -> Reg -- register to spill -> Int -- current stack delta -> Int -- spill slot to use - -> Instr + -> (Int, [Instr]) +-- XXX this is stupid. We essentially do sp <- sp - 4095; str xN, [sp - ...] ; sp <- sp + 4095 +aarch64_mkSpillInstr config reg delta slot | (spillSlotToOffset config slot) - delta > 4095 + = let (d, isns) = aarch64_mkSpillInstr config reg (delta + 4095) slot + in (d, SUB sp sp (OpImm (ImmInt 4095)) : isns ++ [ADD sp sp (OpImm (ImmInt 4095))]) + +aarch64_mkSpillInstr config reg delta slot | (spillSlotToOffset config slot) - delta > 255 + = let (d, isns) = aarch64_mkSpillInstr config reg (delta + delta') slot + in (d, SUB sp sp (OpImm (ImmInt delta')) : isns ++ [ADD sp sp (OpImm (ImmInt delta'))]) + where delta' = (spillSlotToOffset config slot) - delta + +aarch64_mkSpillInstr config reg delta slot | (spillSlotToOffset config slot) - delta < -4095 + = let (d, isns) = aarch64_mkSpillInstr config reg (delta - 4095) slot + in (d, ADD sp sp (OpImm (ImmInt 4095)) : isns ++ [SUB sp sp (OpImm (ImmInt 4095))]) + +aarch64_mkSpillInstr config reg delta slot | (spillSlotToOffset config slot) - delta < -256 + = let (d, isns) = aarch64_mkSpillInstr config reg (delta + delta') slot + in (d, SUB sp sp (OpImm (ImmInt delta')) : isns ++ [ADD sp sp (OpImm (ImmInt delta'))]) + where delta' = (spillSlotToOffset config slot) - delta aarch64_mkSpillInstr config reg delta slot - = ANN (text "Spill") $ STR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt $ off - delta))) + = (delta, [ANN (text "Spill") $ STR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt $ off - delta)))]) where fmt = case reg of RegReal (RealRegSingle n) | n < 32 -> II64 @@ -352,10 +375,29 @@ aarch64_mkLoadInstr -> Reg -- register to load -> Int -- current stack delta -> Int -- spill slot to use - -> Instr + -> (Int, [Instr]) +-- XXX this is stupid. We essentially do sp <- sp - 4095; str xN, [sp - ...] ; sp <- sp + 4095 +aarch64_mkLoadInstr config reg delta slot | (spillSlotToOffset config slot) - delta > 4095 + = let (d, isns) = aarch64_mkLoadInstr config reg (delta + 4095) slot + in (d, SUB sp sp (OpImm (ImmInt 4095)) : isns ++ [ADD sp sp (OpImm (ImmInt 4095))]) + +aarch64_mkLoadInstr config reg delta slot | (spillSlotToOffset config slot) - delta > 255 + = let (d, isns) = aarch64_mkLoadInstr config reg (delta + delta') slot + in (d, SUB sp sp (OpImm (ImmInt delta')) : isns ++ [ADD sp sp (OpImm (ImmInt delta'))]) + where delta' = (spillSlotToOffset config slot) - delta + +aarch64_mkLoadInstr config reg delta slot | (spillSlotToOffset config slot) - delta < -4095 + = let (d, isns) = aarch64_mkLoadInstr config reg (delta - 4096) slot + in (d, ADD sp sp (OpImm (ImmInt 4095)) : isns ++ [SUB sp sp (OpImm (ImmInt 4095))]) + +aarch64_mkLoadInstr config reg delta slot | (spillSlotToOffset config slot) - delta < -256 + = let (d, isns) = aarch64_mkLoadInstr config reg (delta + delta') slot + in (d, SUB sp sp (OpImm (ImmInt delta')) : isns ++ [ADD sp sp (OpImm (ImmInt delta'))]) + where delta' = (spillSlotToOffset config slot) - delta + aarch64_mkLoadInstr config reg delta slot - = ANN (text "Reload") $ LDR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt $ off - delta))) + = (delta, [ANN (text "Reload") $ LDR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt $ off - delta)))]) where fmt = case reg of RegReal (RealRegSingle n) | n < 32 -> II64 @@ -418,11 +460,66 @@ aarch64_mkJumpInstr :: BlockId -> [Instr] aarch64_mkJumpInstr id = [B (TBlock id)] aarch64_mkStackAllocInstr :: Platform -> Int -> [Instr] -aarch64_mkStackAllocInstr platform amount = pprPanic "mkStackAllocInstr" (ppr amount) +aarch64_mkStackAllocInstr platform n + | n == 0 = [] + | n > 0 && n < 4096 = [ SUB sp sp (OpImm (ImmInt n)) ] + | n > 0 = SUB sp sp (OpImm (ImmInt 4095)) : aarch64_mkStackAllocInstr platform (n - 4095) +aarch64_mkStackAllocInstr platform n = pprPanic "aarch64_mkStackAllocInstr" (int n) aarch64_mkStackDeallocInstr :: Platform -> Int -> [Instr] -aarch64_mkStackDeallocInstr platform amount = pprPanic "mkStackDeallocInstr" (ppr amount) +aarch64_mkStackDeallocInstr platform n + | n == 0 = [] + | n > 0 && n < 4096 = [ ADD sp sp (OpImm (ImmInt n)) ] + | n > 0 = ADD sp sp (OpImm (ImmInt 4095)) : aarch64_mkStackAllocInstr platform (n - 4095) +aarch64_mkStackDeallocInstr platform n = pprPanic "aarch64_mkStackAllocInstr" (int n) +-- +-- See note [extra spill slots] in X86/Instr.hs +-- +allocMoreStack + :: Platform + -> Int + -> NatCmmDecl statics GHC.CmmToAsm.AArch64.Instr.Instr + -> UniqSM (NatCmmDecl statics GHC.CmmToAsm.AArch64.Instr.Instr, [(BlockId,BlockId)]) + +allocMoreStack _ _ top@(CmmData _ _) = return (top,[]) +allocMoreStack platform slots proc@(CmmProc info lbl live (ListGraph code)) = do + let entries = entryBlocks proc + + uniqs <- replicateM (length entries) getUniqueM + + let + delta = ((x + stackAlign - 1) `quot` stackAlign) * stackAlign -- round up + where x = slots * spillSlotSize -- sp delta + + alloc = mkStackAllocInstr platform delta + dealloc = mkStackDeallocInstr platform delta + + retargetList = (zip entries (map mkBlockId uniqs)) + + new_blockmap :: LabelMap BlockId + new_blockmap = mapFromList retargetList + + insert_stack_insn (BasicBlock id insns) + | Just new_blockid <- mapLookup id new_blockmap + = [ BasicBlock id $ alloc ++ [ B (TBlock new_blockid) ] + , BasicBlock new_blockid block' ] + | otherwise + = [ BasicBlock id block' ] + where + block' = foldr insert_dealloc [] insns + + insert_dealloc insn r = case insn of + J _ -> dealloc ++ (insn : r) + _other | aarch64_jumpDestsOfInstr insn /= [] + -> aarch64_patchJumpInstr insn retarget : r + _other -> insn : r + + where retarget b = fromMaybe b (mapLookup b new_blockmap) + + new_code = concatMap insert_stack_insn code + -- in + return (CmmProc info lbl live (ListGraph new_code), retargetList) -- ----------------------------------------------------------------------------- -- Machine's assembly language @@ -541,6 +638,7 @@ data Instr | CBZ Operand Target -- if op == 0, then branch. | CBNZ Operand Target -- if op /= 0, then branch. -- Branching. + | J Target -- like B, but only generated from genJump. Used to distinguish genJumps from others. | B Target -- unconditional branching b/br. (To a blockid, label or register) | BL Target -- branch and link (e.g. set x30 to next pc, and branch) | BCOND Cond Target -- branch with condition. b. @@ -571,11 +669,11 @@ data Target data ExtMode = EUXTB | EUXTH | EUXTW | EUXTX | ESXTB | ESXTH | ESXTW | ESXTX - deriving Show + deriving (Eq, Show) data ShiftMode = SLSL | SLSR | SASR | SROR - deriving Show + deriving (Eq, Show) -- We can also add ExtShift to Extension. @@ -591,15 +689,16 @@ data Operand | OpImm Imm -- immediate value | OpImmShift Imm ShiftMode RegShift | OpAddr AddrMode -- memory reference - deriving Show + deriving (Eq, Show) -- Smart constructors opReg :: Width -> Reg -> Operand opReg = OpReg -xzr, wzr :: Operand +xzr, wzr, sp :: Operand xzr = OpReg W64 (RegReal (RealRegSingle (-1))) wzr = OpReg W32 (RegReal (RealRegSingle (-1))) +sp = OpReg W64 (RegReal (RealRegSingle 31)) _x :: Int -> Operand _x i = OpReg W64 (RegReal (RealRegSingle i)) ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -2,6 +2,8 @@ module GHC.CmmToAsm.AArch64.Ppr (pprNatCmmDecl) where import GHC.Prelude hiding (EQ) +import Data.List (findIndex, all) + import GHC.CmmToAsm.AArch64.Instr import GHC.CmmToAsm.AArch64.Regs import GHC.CmmToAsm.AArch64.Cond @@ -44,7 +46,8 @@ pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) = Nothing -> -- special case for code without info table: pprSectionAlign config (Section Text lbl) $$ - pprProcAlignment config $$ + -- do not + -- pprProcAlignment config $$ pprLabel platform lbl $$ -- blocks guaranteed not null, so label needed vcat (map (pprBasicBlock config top_info) blocks) $$ (if ncgDebugLevel config > 0 @@ -53,7 +56,7 @@ pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) = Just (CmmStaticsRaw info_lbl _) -> pprSectionAlign config (Section Text info_lbl) $$ - pprProcAlignment config $$ + -- pprProcAlignment config $$ (if platformHasSubsectionsViaSymbols platform then ppr (mkDeadStripPreventer info_lbl) <> char ':' else empty) $$ @@ -79,37 +82,31 @@ pprLabel platform lbl = pprAlign :: Platform -> Alignment -> SDoc pprAlign platform alignment - = text ".align " <> int (alignmentOn platform) - where - bytes = alignmentBytes alignment - alignmentOn platform = if platformOS platform == OSDarwin - then log2 bytes - else bytes - - log2 :: Int -> Int -- cache the common ones - log2 1 = 0 - log2 2 = 1 - log2 4 = 2 - log2 8 = 3 - log2 n = 1 + log2 (n `quot` 2) + = text "\t.balign " <> int (alignmentBytes alignment) -- | Print appropriate alignment for the given section type. pprAlignForSection :: Platform -> SectionType -> SDoc pprAlignForSection _platform _seg -- .balign is stable, whereas .align is platform dependent. - = text ".balign 8" -- always 8 + = text "\t.balign 8" -- always 8 instance Outputable Instr where ppr instr = sdocWithDynFlags $ \dflags -> pprInstr (targetPlatform dflags) instr -- | Print section header and appropriate alignment for that section. +-- +-- This one will emit the header: +-- +-- .section .text +-- .balign 8 +-- pprSectionAlign :: NCGConfig -> Section -> SDoc pprSectionAlign _config (Section (OtherSection _) _) = panic "AArch64.Ppr.pprSectionAlign: unknown section" pprSectionAlign config sec@(Section seg _) = - pprSectionHeader config sec $$ - pprAlignForSection (ncgPlatform config) seg + pprSectionHeader config sec + $$ pprAlignForSection (ncgPlatform config) seg -- | Output the ELF .size directive. pprSizeDecl :: Platform -> CLabel -> SDoc @@ -123,18 +120,50 @@ pprBasicBlock :: NCGConfig -> LabelMap RawCmmStatics -> NatBasicBlock Instr pprBasicBlock config info_env (BasicBlock blockid instrs) = maybe_infotable $ pprLabel platform asmLbl $$ - vcat (map (pprInstr platform) instrs) $$ + vcat (map (pprInstr platform) (detectTrivialDeadlock optInstrs)) $$ (if ncgDebugLevel config > 0 then ppr (mkAsmTempEndLabel asmLbl) <> char ':' else empty ) where + -- Filter out identity moves. E.g. mov x18, x18 will be dropped. + optInstrs = filter f instrs + where f (MOV o1 o2) | o1 == o2 = False + f _ = True + + -- XXX: put deadlock detection behind a flag. This will need to pass over + -- each emitted instruction and can thus cause a slowdown in the number of + -- instructions we generate. + -- + -- detect the trivial cases where we would need -fno-omit-yields + -- those are deadlocks where we have only an unconditional branch + -- instruction back to the block head, with no escape inbetween. + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/367 + -- This only intends to catch the very trivial case, not the more + -- compilicated cases. + detectTrivialDeadlock :: [Instr] -> [Instr] + detectTrivialDeadlock instrs = case (findIndex isSelfBranch instrs) of + Just n | all (not . aarch64_isJumpishInstr) (take n instrs) -> + pprPanic "AArch64 NCG" + $ text "Deadlock detected! Re compile with -fno-omit-yields." + $$ text "" + $$ pprLabel platform asmLbl + $$ vcat (map (pprInstr platform) (take (n + 1) instrs)) + $$ text "" + $$ text "See https://gitlab.haskell.org/ghc/ghc/-/issues/367" + -- Nothing, or there are jumpishInstructions before the self branch, + -- probably not a deadlock. + _ -> instrs + + where isSelfBranch (B (TBlock blockid')) = blockid' == blockid + isSelfBranch _ = False + asmLbl = blockLbl blockid platform = ncgPlatform config maybe_infotable c = case mapLookup blockid info_env of Nothing -> c Just (CmmStaticsRaw info_lbl info) -> - pprAlignForSection platform Text $$ + -- pprAlignForSection platform Text $$ infoTableLoc $$ vcat (map (pprData config) info) $$ pprLabel platform info_lbl $$ @@ -180,7 +209,7 @@ pprData config (CmmStaticLit lit) = pprDataItem config lit pprGloblDecl :: CLabel -> SDoc pprGloblDecl lbl | not (externallyVisibleCLabel lbl) = empty - | otherwise = text ".globl " <> ppr lbl + | otherwise = text "\t.globl " <> ppr lbl -- See discussion in X86.Ppr -- for why this is necessary. Essentially we need to ensure that we never @@ -419,6 +448,7 @@ pprInstr platform instr = case instr of TST o1 o2 -> text "\ttst" <+> pprOp o1 <> comma <+> pprOp o2 -- 4. Branch Instructions ---------------------------------------------------- + J t -> pprInstr platform (B t) B (TBlock bid) -> text "\tb" <+> ppr (mkLocalBlockLabel (getUnique bid)) B (TLabel lbl) -> text "\tb" <+> ppr lbl B (TReg r) -> text "\tbr" <+> pprReg W64 r @@ -441,7 +471,7 @@ pprInstr platform instr = case instr of CBNZ o (TBlock bid) -> text "\tcbnz" <+> pprOp o <> comma <+> ppr (mkLocalBlockLabel (getUnique bid)) CBNZ o (TLabel lbl) -> text "\tcbnz" <+> pprOp o <> comma <+> ppr lbl - CBNZ c (TReg r) -> panic "AArch64.ppr: No conditional (cbz) branching to registers!" + CBNZ c (TReg r) -> panic "AArch64.ppr: No conditional (cbnz) branching to registers!" -- 7. Load and Store Instructions -------------------------------------------- -- NOTE: GHC may do whacky things where it only load the lower part of an @@ -453,14 +483,22 @@ pprInstr platform instr = case instr of text "\tstrh" <+> pprOp o1 <> comma <+> pprOp o2 STR f o1 o2 -> text "\tstr" <+> pprOp o1 <> comma <+> pprOp o2 + -- LDR f o1 (OpImm (ImmIndex lbl off)) -> + -- text "\tadrp" <+> pprOp o1 <> comma <+> ppr lbl $$ + -- text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> text ":lo12:" <> ppr lbl $$ + -- text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> char '#' <> int off -- XXX: check that off is in 12bits. + -- always GOT loads LDR f o1 (OpImm (ImmIndex lbl off)) -> - text "\tadrp " <+> pprOp o1 <> comma <+> ppr lbl $$ - text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> text ":lo12:" <> ppr lbl $$ + text "\tadrp" <+> pprOp o1 <> comma <+> text ":got:" <> ppr lbl $$ + text "\tldr" <+> pprOp o1 <> comma <+> text "[" <> pprOp o1 <> comma <+> text":got_lo12:" <> ppr lbl <> text "]" $$ text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> char '#' <> int off -- XXX: check that off is in 12bits. + -- LDR f o1 (OpImm (ImmCLbl lbl)) -> + -- text "\tadrp" <+> pprOp o1 <> comma <+> ppr lbl $$ + -- text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> text ":lo12:" <> ppr lbl LDR f o1 (OpImm (ImmCLbl lbl)) -> - text "\tadrp" <+> pprOp o1 <> comma <+> ppr lbl $$ - text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> text ":lo12:" <> ppr lbl + text "\tadrp" <+> pprOp o1 <> comma <+> text ":got:" <> ppr lbl $$ + text "\tldr" <+> pprOp o1 <> comma <+> text "[" <> pprOp o1 <> comma <+> text":got_lo12:" <> ppr lbl <> text "]" LDR f o1@(OpReg W8 (RegReal (RealRegSingle i))) o2 | i < 32 -> text "\tldrsb" <+> pprOp o1 <> comma <+> pprOp o2 ===================================== compiler/GHC/CmmToAsm/AArch64/Regs.hs ===================================== @@ -46,8 +46,9 @@ allFpArgRegs = map regSingle [32..39] -- 22-27: R1-R6 -- 28: SpLim -sp :: Reg -sp = regSingle 20 +-- This is the STG Sp reg. +-- sp :: Reg +-- sp = regSingle 20 -- addressing modes ------------------------------------------------------------ @@ -55,7 +56,7 @@ data AddrMode = AddrRegReg Reg Reg | AddrRegImm Reg Imm | AddrReg Reg - deriving Show + deriving (Eq, Show) -- ----------------------------------------------------------------------------- -- Immediates @@ -70,11 +71,14 @@ data Imm | ImmDouble Rational | ImmConstantSum Imm Imm | ImmConstantDiff Imm Imm - deriving Show + deriving (Eq, Show) instance Show SDoc where show = showSDocUnsafe +instance Eq SDoc where + lhs == rhs = show lhs == show rhs + strImmLit :: String -> Imm strImmLit s = ImmLit (text s) ===================================== compiler/GHC/CmmToAsm/Instr.hs ===================================== @@ -141,7 +141,7 @@ class Instruction instr where -> Reg -- ^ the reg to spill -> Int -- ^ the current stack delta -> Int -- ^ spill slot to use - -> instr + -> (Int, [instr]) -- ^ (new stack delta, instruction) -- | An instruction to reload a register from a spill slot. @@ -150,7 +150,7 @@ class Instruction instr where -> Reg -- ^ the reg to reload. -> Int -- ^ the current stack delta -> Int -- ^ the spill slot to use - -> instr + -> (Int, [instr]) -- ^ (new stack delta, instruction) -- | See if this instruction is telling us the current C stack delta takeDeltaInstr ===================================== compiler/GHC/CmmToAsm/PPC/Instr.hs ===================================== @@ -541,7 +541,7 @@ ppc_mkSpillInstr -> Reg -- register to spill -> Int -- current stack delta -> Int -- spill slot to use - -> Instr + -> (Int, [Instr]) ppc_mkSpillInstr config reg delta slot = let platform = ncgPlatform config @@ -558,7 +558,7 @@ ppc_mkSpillInstr config reg delta slot Just _ -> ST Nothing -> STFAR -- pseudo instruction: 32 bit offsets - in instr fmt reg (AddrRegImm sp (ImmInt (off-delta))) + in (delta, [instr fmt reg (AddrRegImm sp (ImmInt (off-delta)))]) ppc_mkLoadInstr @@ -566,7 +566,7 @@ ppc_mkLoadInstr -> Reg -- register to load -> Int -- current stack delta -> Int -- spill slot to use - -> Instr + -> (Int, [Instr]) ppc_mkLoadInstr config reg delta slot = let platform = ncgPlatform config @@ -583,7 +583,7 @@ ppc_mkLoadInstr config reg delta slot Just _ -> LD Nothing -> LDFAR -- pseudo instruction: 32 bit offsets - in instr fmt reg (AddrRegImm sp (ImmInt (off-delta))) + in (delta, [instr fmt reg (AddrRegImm sp (ImmInt (off-delta)))]) -- | The size of a minimal stackframe header including minimal ===================================== compiler/GHC/CmmToAsm/Reg/Linear.hs ===================================== @@ -701,7 +701,7 @@ saveClobberedTemps clobbered dying let new_assign = addToUFM assig temp (InBoth reg slot) - clobber new_assign (spill : instrs) rest + clobber new_assign (spill ++ instrs) rest @@ -921,8 +921,8 @@ allocRegsAndSpill_spill reading keep spills alloc r rs assig spill_loc = do (spill_insn, slot) <- spillR (RegReal my_reg) temp_to_push_out let spill_store = (if reading then id else reverse) - [ -- COMMENT (fsLit "spill alloc") - spill_insn ] + -- COMMENT (fsLit "spill alloc"): + spill_insn -- record that this temp was spilled recordSpill (SpillAlloc temp_to_push_out) @@ -972,7 +972,7 @@ loadTemp vreg (ReadMem slot) hreg spills = do insn <- loadR (RegReal hreg) slot recordSpill (SpillLoad $ getUnique vreg) - return $ {- COMMENT (fsLit "spill load") : -} insn : spills + return $ {- COMMENT (fsLit "spill load") : -} insn ++ spills loadTemp _ _ _ spills = return spills ===================================== compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs ===================================== @@ -118,8 +118,8 @@ def CC_AArch64_GHC : CallingConv<[ getFreeRegs :: RegClass -> FreeRegs -> [RealReg] getFreeRegs cls (FreeRegs g f) - | RcFloat <- cls = [] -- go 32 f 3] - | RcDouble <- cls = go 32 f 32 + | RcFloat <- cls = [] -- go 32 f 31 + | RcDouble <- cls = go 32 f 31 | RcInteger <- cls = go 0 g 18 where go off _ i | i < 0 = [] ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -28,6 +28,8 @@ import GHC.Types.Unique import GHC.Types.Unique.FM import GHC.Types.Unique.Set +import GHC.Utils.Monad (concatMapM) + -- | For a jump instruction at the end of a block, generate fixup code so its -- vregs are in the correct regs for its destination. -- @@ -304,7 +306,7 @@ handleComponent -- go via a spill slot. -- handleComponent delta _ (AcyclicSCC (DigraphNode vreg src dsts)) - = mapM (makeMove delta vreg src) dsts + = concatMapM (makeMove delta vreg src) dsts -- Handle some cyclic moves. @@ -338,7 +340,7 @@ handleComponent delta instr -- make sure to do all the reloads after all the spills, -- so we don't end up clobbering the source values. - return ([instrSpill] ++ concat remainingFixUps ++ [instrLoad]) + return (instrSpill ++ concat remainingFixUps ++ instrLoad) handleComponent _ _ (CyclicSCC _) = panic "Register Allocator: handleComponent cyclic" @@ -352,22 +354,28 @@ makeMove -> Unique -- ^ unique of the vreg that we're moving. -> Loc -- ^ source location. -> Loc -- ^ destination location. - -> RegM freeRegs instr -- ^ move instruction. + -> RegM freeRegs [instr] -- ^ move instruction. -makeMove delta vreg src dst +makeMove _ vreg src dst = do config <- getConfig let platform = ncgPlatform config case (src, dst) of (InReg s, InReg d) -> do recordSpill (SpillJoinRR vreg) - return $ mkRegRegMoveInstr platform (RegReal s) (RegReal d) + return $ [mkRegRegMoveInstr platform (RegReal s) (RegReal d)] (InMem s, InReg d) -> do recordSpill (SpillJoinRM vreg) - return $ mkLoadInstr config (RegReal d) delta s + delta <- getDeltaR + let (new_delta, instrs) = mkLoadInstr config (RegReal d) delta s + setDeltaR new_delta + return instrs (InReg s, InMem d) -> do recordSpill (SpillJoinRM vreg) - return $ mkSpillInstr config (RegReal s) delta d + delta <- getDeltaR + let (new_delta, instrs) = mkSpillInstr config (RegReal s) delta d + setDeltaR new_delta + return instrs _ -> -- we don't handle memory to memory moves. -- they shouldn't happen because we don't share @@ -375,4 +383,3 @@ makeMove delta vreg src dst panic ("makeMove " ++ show vreg ++ " (" ++ show src ++ ") (" ++ show dst ++ ")" ++ " we don't handle mem->mem moves.") - ===================================== compiler/GHC/CmmToAsm/Reg/Linear/State.hs ===================================== @@ -127,20 +127,22 @@ makeRAStats state spillR :: Instruction instr - => Reg -> Unique -> RegM freeRegs (instr, Int) + => Reg -> Unique -> RegM freeRegs ([instr], Int) spillR reg temp = RegM $ \s -> let (stack1,slot) = getStackSlotFor (ra_stack s) temp - instr = mkSpillInstr (ra_config s) reg (ra_delta s) slot + (new_delta, instrs) = mkSpillInstr (ra_config s) reg (ra_delta s) slot in - RA_Result s{ra_stack=stack1} (instr,slot) + RA_Result s{ra_stack=stack1, ra_delta=new_delta} (instrs,slot) loadR :: Instruction instr - => Reg -> Int -> RegM freeRegs instr + => Reg -> Int -> RegM freeRegs [instr] loadR reg slot = RegM $ \s -> - RA_Result s (mkLoadInstr (ra_config s) reg (ra_delta s) slot) + let (new_delta, instrs) = mkLoadInstr (ra_config s) reg (ra_delta s) slot + in + RA_Result s{ra_delta=new_delta} instrs getFreeRegsR :: RegM freeRegs freeRegs getFreeRegsR = RegM $ \ s at RA_State{ra_freeregs = freeregs} -> ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -529,11 +529,15 @@ stripLiveBlock config (BasicBlock i lis) spillNat acc (LiveInstr (SPILL reg slot) _ : instrs) = do delta <- get - spillNat (mkSpillInstr config reg delta slot : acc) instrs + let (new_delta, instrs') = mkSpillInstr config reg delta slot + put new_delta + spillNat (instrs' ++ acc) instrs spillNat acc (LiveInstr (RELOAD slot reg) _ : instrs) = do delta <- get - spillNat (mkLoadInstr config reg delta slot : acc) instrs + let (new_delta, instrs') = mkLoadInstr config reg delta slot + put new_delta + spillNat (instrs' ++ acc) instrs spillNat acc (LiveInstr (Instr instr) _ : instrs) | Just i <- takeDeltaInstr instr ===================================== compiler/GHC/CmmToAsm/SPARC/Instr.hs ===================================== @@ -373,9 +373,9 @@ sparc_mkSpillInstr -> Reg -- ^ register to spill -> Int -- ^ current stack delta -> Int -- ^ spill slot to use - -> Instr + -> (Int, [Instr]) -sparc_mkSpillInstr config reg _ slot +sparc_mkSpillInstr config reg delta slot = let platform = ncgPlatform config off = spillSlotToOffset config slot off_w = 1 + (off `div` 4) @@ -384,7 +384,7 @@ sparc_mkSpillInstr config reg _ slot RcFloat -> FF32 RcDouble -> FF64 - in ST fmt reg (fpRel (negate off_w)) + in (delta, [ST fmt reg (fpRel (negate off_w))]) -- | Make a spill reload instruction. @@ -393,9 +393,9 @@ sparc_mkLoadInstr -> Reg -- ^ register to load into -> Int -- ^ current stack delta -> Int -- ^ spill slot to use - -> Instr + -> (Int, [Instr]) -sparc_mkLoadInstr config reg _ slot +sparc_mkLoadInstr config reg delta slot = let platform = ncgPlatform config off = spillSlotToOffset config slot off_w = 1 + (off `div` 4) @@ -404,7 +404,7 @@ sparc_mkLoadInstr config reg _ slot RcFloat -> FF32 RcDouble -> FF64 - in LD fmt (fpRel (- off_w)) reg + in (delta, [LD fmt (fpRel (- off_w)) reg]) -------------------------------------------------------------------------------- ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -668,15 +668,15 @@ x86_mkSpillInstr -> Reg -- register to spill -> Int -- current stack delta -> Int -- spill slot to use - -> Instr + -> (Int, [Instr]) x86_mkSpillInstr config reg delta slot = let off = spillSlotToOffset platform slot - delta in case targetClassOfReg platform reg of - RcInteger -> MOV (archWordFormat is32Bit) - (OpReg reg) (OpAddr (spRel platform off)) - RcDouble -> MOV FF64 (OpReg reg) (OpAddr (spRel platform off)) + RcInteger -> (delta, [MOV (archWordFormat is32Bit) + (OpReg reg) (OpAddr (spRel platform off))]) + RcDouble -> (delta, [MOV FF64 (OpReg reg) (OpAddr (spRel platform off))]) _ -> panic "X86.mkSpillInstr: no match" where platform = ncgPlatform config is32Bit = target32Bit platform @@ -687,15 +687,15 @@ x86_mkLoadInstr -> Reg -- register to load -> Int -- current stack delta -> Int -- spill slot to use - -> Instr + -> (Int, [Instr]) x86_mkLoadInstr config reg delta slot = let off = spillSlotToOffset platform slot - delta in case targetClassOfReg platform reg of - RcInteger -> MOV (archWordFormat is32Bit) - (OpAddr (spRel platform off)) (OpReg reg) - RcDouble -> MOV FF64 (OpAddr (spRel platform off)) (OpReg reg) + RcInteger -> (delta, [MOV (archWordFormat is32Bit) + (OpAddr (spRel platform off)) (OpReg reg)]) + RcDouble -> (delta, [MOV FF64 (OpAddr (spRel platform off)) (OpReg reg)]) _ -> panic "X86.x86_mkLoadInstr" where platform = ncgPlatform config is32Bit = target32Bit platform ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -80,7 +80,7 @@ targetSupportsSMP = do ghcWithNativeCodeGen :: Action Bool ghcWithNativeCodeGen = do - goodArch <- anyTargetArch ["i386", "x86_64", "sparc", "powerpc"] - badOs <- anyTargetOs ["ios", "aix"] + goodArch <- anyTargetArch ["i386", "x86_64", "sparc", "powerpc", "aarch64"] + badOs <- anyTargetOs ["aix"] ghcUnreg <- flag GhcUnregisterised return $ goodArch && not badOs && not ghcUnreg View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fe3aeaff2444881ef30adb9a82870f81a8880e7e...b765dfe4ad8d5b74e007553b684394e136bab5b3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fe3aeaff2444881ef30adb9a82870f81a8880e7e...b765dfe4ad8d5b74e007553b684394e136bab5b3 You're receiving 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 Jul 20 05:58:41 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 20 Jul 2020 01:58:41 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] 41 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f153291ab563_80b104edf444051830@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 3cac2f19 by Moritz Angermann at 2020-07-20T05:58:17+00:00 Cross Test Suite - - - - - 765fba24 by Moritz Angermann at 2020-07-20T05:58:17+00:00 platform backwards compat, until libraries are patched. - - - - - 0e93f6de by Moritz Angermann at 2020-07-20T05:58:17+00:00 unbreak test.mk - - - - - 0ccbe046 by Moritz Angermann at 2020-07-20T05:58:17+00:00 default TEST_WRAPPER - - - - - ee89eeeb by Moritz Angermann at 2020-07-20T05:58:17+00:00 m( - - - - - 3e89688e by Moritz Angermann at 2020-07-20T05:58:17+00:00 Fixup the test-suite - - - - - 0ee10fcb by Moritz Angermann at 2020-07-20T05:58:17+00:00 Update test.mk - - - - - 9bb42ad9 by Moritz Angermann at 2020-07-20T05:58:17+00:00 Fix T13350 - - - - - 5661cef1 by Moritz Angermann at 2020-07-20T05:58:17+00:00 Fix T1372 - - - - - a890136f by Moritz Angermann at 2020-07-20T05:58:17+00:00 Drop exec, use identity wrapper - - - - - 6156f026 by Moritz Angermann at 2020-07-20T05:58:17+00:00 Fix T13168 - - - - - 63efbc3e by Moritz Angermann at 2020-07-20T05:58:17+00:00 Fix T3007 - - - - - 77dbd03b by Moritz Angermann at 2020-07-20T05:58:17+00:00 Fix recomp007 - - - - - 329b74f4 by Moritz Angermann at 2020-07-20T05:58:17+00:00 use $* - - - - - 52e3795c by Moritz Angermann at 2020-07-20T05:58:17+00:00 fix concio001 - - - - - e3c42375 by Moritz Angermann at 2020-07-20T05:58:17+00:00 disable flakey divbyzero test - - - - - e2c9d6d3 by Moritz Angermann at 2020-07-20T05:58:17+00:00 add python :( - - - - - f243b697 by Moritz Angermann at 2020-07-20T05:58:17+00:00 ??? - - - - - aacd4e4a by Moritz Angermann at 2020-07-20T05:58:17+00:00 Fix T13168 - - - - - 9df028a7 by Moritz Angermann at 2020-07-20T05:58:17+00:00 What is going on in CI? Why can't I reproduce this locally? - - - - - 722c5a1a by Moritz Angermann at 2020-07-20T05:58:17+00:00 Fix test-wrapper in python, so hadrian gets the benefit. - - - - - 6ef8da1d by Moritz Angermann at 2020-07-20T05:58:17+00:00 make it a Path! - - - - - 743f889f by Moritz Angermann at 2020-07-20T05:58:17+00:00 Drop left debug statement - - - - - eee5e711 by Moritz Angermann at 2020-07-20T05:58:17+00:00 Better TEST_WRAPPER injection. - - - - - d3b647b4 by Moritz Angermann at 2020-07-20T05:58:17+00:00 Split wrapper and prefix - - - - - 8bfd7958 by Moritz Angermann at 2020-07-20T05:58:17+00:00 Maybe the test-wrapper logic should become a cmd_prefix? - - - - - 2890438a by Moritz Angermann at 2020-07-20T05:58:17+00:00 :facepalm: - - - - - 07c60e6d by Moritz Angermann at 2020-07-20T05:58:17+00:00 :fire: - - - - - c47be726 by Moritz Angermann at 2020-07-20T05:58:17+00:00 Fix T10955dyn? - - - - - a62ee549 by Moritz Angermann at 2020-07-20T05:58:17+00:00 cleanup - - - - - 3d146019 by Moritz Angermann at 2020-07-20T05:58:17+00:00 Revert "Fix T10955dyn?" This reverts commit 4c242580a429fd1942a9a982fd2b4a3abe113d6d. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst - hadrian/hadrian.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8c0f74595cbb6736a934404f3b90b509b229d16a...3d146019b5141e19da41efd7a0a124cafb0dbcd6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8c0f74595cbb6736a934404f3b90b509b229d16a...3d146019b5141e19da41efd7a0a124cafb0dbcd6 You're receiving 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 Jul 20 07:48:20 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 20 Jul 2020 03:48:20 -0400 Subject: [Git][ghc/ghc][wip/T18451] Care with occCheckExpand in kind of occurrences Message-ID: <5f154c4456168_80b114037a44056565@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18451 at Glasgow Haskell Compiler / GHC Commits: 911e0c4e by Simon Peyton Jones at 2020-07-20T08:47:51+01:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 10 changed files: - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Utils/Unify.hs - + testsuite/tests/polykinds/T18451.hs - + testsuite/tests/polykinds/T18451.stderr - + testsuite/tests/polykinds/T18451a.hs - + testsuite/tests/polykinds/T18451a.stderr - + testsuite/tests/polykinds/T18451b.hs - + testsuite/tests/polykinds/T18451b.stderr - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -34,10 +34,9 @@ import {-# SOURCE #-} GHC.CoreToIface , toIfaceTyCon, toIfaceTcArgs, toIfaceCoercionX ) import {-# SOURCE #-} GHC.Core.DataCon - ( dataConFullSig , dataConUserTyVarBinders - , DataCon ) + ( dataConFullSig , dataConUserTyVarBinders, DataCon ) -import GHC.Core.Type ( isLiftedTypeKind, pattern One, pattern Many ) +import GHC.Core.Type ( pickyIsLiftedTypeKind, pattern One, pattern Many ) import GHC.Core.TyCon import GHC.Core.TyCo.Rep @@ -192,11 +191,35 @@ pprTyVar :: TyVar -> SDoc -- pprIfaceTvBndr is minimal, and the loss of uniques etc in -- debug printing is disastrous pprTyVar tv - | isLiftedTypeKind kind = ppr tv - | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) + | pickyIsLiftedTypeKind kind = ppr tv -- See Note [Suppressing * kinds] + | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) where kind = tyVarKind tv +{- Note [Suppressing * kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Generally we want to print + forall a. a->a +not forall (a::*). a->a +or forall (a::Type). a->a +That is, for brevity we suppress a kind ascription of '*' (or Type). + +But what if the kind is (Const Type x)? + type Cons p q = p + +Then (Const Type x) is just a long way of saying Type. But it may be +jolly confusing to suppress the 'x'. Suppose we have (polykinds/T18451a) + foo :: forall a b (c :: Const Type b). Proxy '[a, c] + +Then this error message + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) +would be much less helpful if we suppressed the kind ascription on 'a'. + +Hence the use of pickyIsLiftedTypeKind. +-} + ----------------- debugPprType :: Type -> SDoc -- ^ debugPprType is a simple pretty printer that prints a type ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -122,7 +122,7 @@ module GHC.Core.Type ( -- *** Levity and boxity isLiftedType_maybe, - isLiftedTypeKind, isUnliftedTypeKind, + isLiftedTypeKind, isUnliftedTypeKind, pickyIsLiftedTypeKind, isLiftedRuntimeRep, isUnliftedRuntimeRep, isUnliftedType, mightBeUnliftedType, isUnboxedTupleType, isUnboxedSumType, isAlgType, isDataFamilyAppType, @@ -556,6 +556,22 @@ isLiftedTypeKind kind Just rep -> isLiftedRuntimeRep rep Nothing -> False +pickyIsLiftedTypeKind :: Kind -> Bool +-- Checks whether the kind is literally +-- TYPE LiftedRep +-- or Type +-- without expanding type synonyms or anything +-- Used only when deciding whether to suppress the ":: *" in +-- (a :: *) when printing kinded type variables +pickyIsLiftedTypeKind kind + | TyConApp tc [arg] <- kind + , tc `hasKey` tYPETyConKey + , TyConApp rr_tc [] <- arg + , rr_tc `hasKey` liftedRepDataConKey = True + | TyConApp tc [] <- kind + , tc `hasKey` liftedTypeKindTyConKey = True + | otherwise = False + isLiftedRuntimeRep :: Type -> Bool -- isLiftedRuntimeRep is true of LiftedRep :: RuntimeRep -- False of type variables (a :: RuntimeRep) @@ -2633,6 +2649,46 @@ prefer doing inner expansions first. For example, We have occCheckExpand b (F (G b)) = Just (F Char) even though we could also expand F to get rid of b. + +Note [Occurrence checking: look inside kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we are considering unifying + (alpha :: *) ~ Int -> (beta :: alpha -> alpha) +This may be an error (what is that alpha doing inside beta's kind?), +but we must not make the mistake of actually unifying or we'll +build an infinite data structure. So when looking for occurrences +of alpha in the rhs, we must look in the kinds of type variables +that occur there. + +occCheckExpand tries to expand type synonyms to remove +unnecessary occurrences of a variable, and thereby get past an +occurs-check failure. This is good; but + we can't do it in the /kind/ of a variable /occurrence/ + +For example #18451 built an infinite type: + type Const a b = a + data SameKind :: k -> k -> Type + type T (k :: Const Type a) = forall (b :: k). SameKind a b + +We have + b :: k + k :: Const Type a + a :: k (must be same as b) + +So if we aren't careful, a's kind mentions a, which is bad. +And expanding an /occurrence/ of 'a' doesn't help, because the +/binding site/ is the master copy and all the occurrences should +match it. + +Here's a related example: + f :: forall a b (c :: Const Type b). Proxy '[a, c] + +The list means that 'a' gets the same kind as 'c'; but that +kind mentions 'b', so the binders are out of order. + +Bottom line: in occCheckExpand, do not expand inside the kinds +of occurrences. See bad_var_occ in occCheckExpand. And +see #18451 for more debate. -} occCheckExpand :: [Var] -> Type -> Maybe Type @@ -2653,11 +2709,10 @@ occCheckExpand vs_to_avoid ty -- The VarSet is the set of variables we are trying to avoid -- The VarEnv carries mappings necessary -- because of kind expansion - go cxt@(as, env) (TyVarTy tv') - | tv' `elemVarSet` as = Nothing - | Just tv'' <- lookupVarEnv env tv' = return (mkTyVarTy tv'') - | otherwise = do { tv'' <- go_var cxt tv' - ; return (mkTyVarTy tv'') } + go (as, env) ty@(TyVarTy tv) + | Just tv' <- lookupVarEnv env tv = return (mkTyVarTy tv') + | bad_var_occ as tv = Nothing + | otherwise = return ty go _ ty@(LitTy {}) = return ty go cxt (AppTy ty1 ty2) = do { ty1' <- go cxt ty1 @@ -2670,7 +2725,7 @@ occCheckExpand vs_to_avoid ty ; return (ty { ft_mult = w', ft_arg = ty1', ft_res = ty2' }) } go cxt@(as, env) (ForAllTy (Bndr tv vis) body_ty) = do { ki' <- go cxt (varType tv) - ; let tv' = setVarType tv ki' + ; let tv' = setVarType tv ki' env' = extendVarEnv env tv tv' as' = as `delVarSet` tv ; body' <- go (as', env') body_ty @@ -2694,9 +2749,12 @@ occCheckExpand vs_to_avoid ty ; return (mkCoercionTy co') } ------------------ - go_var cxt v = updateVarTypeM (go cxt) v - -- Works for TyVar and CoVar - -- See Note [Occurrence checking: look inside kinds] + bad_var_occ :: VarSet -> Var -> Bool + -- Works for TyVar and CoVar + -- See Note [Occurrence checking: look inside kinds] + bad_var_occ vs_to_avoid v + = v `elemVarSet` vs_to_avoid + || tyCoVarsOfType (varType v) `intersectsVarSet` vs_to_avoid ------------------ go_mco _ MRefl = return MRefl @@ -2726,13 +2784,15 @@ occCheckExpand vs_to_avoid ty ; co2' <- go_co cxt co2 ; w' <- go_co cxt w ; return (mkFunCo r w' co1' co2') } - go_co cxt@(as,env) (CoVarCo c) - | c `elemVarSet` as = Nothing + go_co (as,env) co@(CoVarCo c) | Just c' <- lookupVarEnv env c = return (mkCoVarCo c') - | otherwise = do { c' <- go_var cxt c - ; return (mkCoVarCo c') } - go_co cxt (HoleCo h) = do { c' <- go_var cxt (ch_co_var h) - ; return (HoleCo (h { ch_co_var = c' })) } + | bad_var_occ as c = Nothing + | otherwise = return co + + go_co (as,_) co@(HoleCo h) + | bad_var_occ as (ch_co_var h) = Nothing + | otherwise = return co + go_co cxt (AxiomInstCo ax ind args) = do { args' <- mapM (go_co cxt) args ; return (mkAxiomInstCo ax ind args') } go_co cxt (UnivCo p r ty1 ty2) = do { p' <- go_prov cxt p ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -2046,21 +2046,8 @@ matchExpectedFunKind hs_ty n k = go n k ********************************************************************* -} -{- Note [Occurrence checking: look inside kinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Suppose we are considering unifying - (alpha :: *) ~ Int -> (beta :: alpha -> alpha) -This may be an error (what is that alpha doing inside beta's kind?), -but we must not make the mistake of actually unifying or we'll -build an infinite data structure. So when looking for occurrences -of alpha in the rhs, we must look in the kinds of type variables -that occur there. - -NB: we may be able to remove the problem via expansion; see - Note [Occurs check expansion]. So we have to try that. - -Note [Checking for foralls] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Checking for foralls] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unless we have -XImpredicativeTypes (which is a totally unsupported feature), we do not want to unify alpha ~ (forall a. a->a) -> Int @@ -2073,10 +2060,10 @@ Consider (alpha :: forall k. k->*) ~ (beta :: forall k. k->*) This is legal; e.g. dependent/should_compile/T11635. -We don't want to reject it because of the forall in beta's kind, -but (see Note [Occurrence checking: look inside kinds]) we do -need to look in beta's kind. So we carry a flag saying if a 'forall' -is OK, and switch the flag on when stepping inside a kind. +We don't want to reject it because of the forall in beta's kind, but +(see Note [Occurrence checking: look inside kinds] in GHC.Core.Type) +we do need to look in beta's kind. So we carry a flag saying if a +'forall' is OK, and switch the flag on when stepping inside a kind. Why is it OK? Why does it not count as impredicative polymorphism? The reason foralls are bad is because we reply on "seeing" foralls @@ -2197,6 +2184,7 @@ preCheck dflags ty_fam_ok tv ty | tv == tv' = MTVU_Occurs | otherwise = fast_check_occ (tyVarKind tv') -- See Note [Occurrence checking: look inside kinds] + -- in GHC.Core.Type fast_check (TyConApp tc tys) | bad_tc tc = MTVU_Bad ===================================== testsuite/tests/polykinds/T18451.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind + +type Const a b = a +data SameKind :: k -> k -> Type + +type T (k :: Const Type a) = forall (b :: k). SameKind a b ===================================== testsuite/tests/polykinds/T18451.stderr ===================================== @@ -0,0 +1,9 @@ + +T18451.hs:10:58: error: + • Expected kind ‘k0’, but ‘b’ has kind ‘k’ + • In the second argument of ‘SameKind’, namely ‘b’ + In the type ‘forall (b :: k). SameKind a b’ + In the type declaration for ‘T’ + • Type variable kinds: + a :: k0 + k :: Const (*) a ===================================== testsuite/tests/polykinds/T18451a.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451a.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/T18451b.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451b.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451b.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -220,3 +220,6 @@ test('CuskFam', normal, compile, ['']) test('T17841', normal, compile_fail, ['']) test('T17963', normal, compile_fail, ['']) test('T18300', normal, compile_fail, ['']) +test('T18451', normal, compile_fail, ['']) +test('T18451a', normal, compile_fail, ['']) +test('T18451b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/911e0c4eafeaddf0eb9e42391b71e14f78fc8e30 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/911e0c4eafeaddf0eb9e42391b71e14f78fc8e30 You're receiving 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 Jul 20 07:51:33 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 20 Jul 2020 03:51:33 -0400 Subject: [Git][ghc/ghc][wip/T18451] Care with occCheckExpand in kind of occurrences Message-ID: <5f154d052d466_80b3f849248fe08405729a@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18451 at Glasgow Haskell Compiler / GHC Commits: 0320af67 by Simon Peyton Jones at 2020-07-20T08:51:02+01:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 10 changed files: - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Utils/Unify.hs - + testsuite/tests/polykinds/T18451.hs - + testsuite/tests/polykinds/T18451.stderr - + testsuite/tests/polykinds/T18451a.hs - + testsuite/tests/polykinds/T18451a.stderr - + testsuite/tests/polykinds/T18451b.hs - + testsuite/tests/polykinds/T18451b.stderr - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -34,10 +34,9 @@ import {-# SOURCE #-} GHC.CoreToIface , toIfaceTyCon, toIfaceTcArgs, toIfaceCoercionX ) import {-# SOURCE #-} GHC.Core.DataCon - ( dataConFullSig , dataConUserTyVarBinders - , DataCon ) + ( dataConFullSig , dataConUserTyVarBinders, DataCon ) -import GHC.Core.Type ( isLiftedTypeKind, pattern One, pattern Many ) +import GHC.Core.Type ( pickyIsLiftedTypeKind, pattern One, pattern Many ) import GHC.Core.TyCon import GHC.Core.TyCo.Rep @@ -192,11 +191,35 @@ pprTyVar :: TyVar -> SDoc -- pprIfaceTvBndr is minimal, and the loss of uniques etc in -- debug printing is disastrous pprTyVar tv - | isLiftedTypeKind kind = ppr tv - | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) + | pickyIsLiftedTypeKind kind = ppr tv -- See Note [Suppressing * kinds] + | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) where kind = tyVarKind tv +{- Note [Suppressing * kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Generally we want to print + forall a. a->a +not forall (a::*). a->a +or forall (a::Type). a->a +That is, for brevity we suppress a kind ascription of '*' (or Type). + +But what if the kind is (Const Type x)? + type Const p q = p + +Then (Const Type x) is just a long way of saying Type. But it may be +jolly confusing to suppress the 'x'. Suppose we have (polykinds/T18451a) + foo :: forall a b (c :: Const Type b). Proxy '[a, c] + +Then this error message + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) +would be much less helpful if we suppressed the kind ascription on 'a'. + +Hence the use of pickyIsLiftedTypeKind. +-} + ----------------- debugPprType :: Type -> SDoc -- ^ debugPprType is a simple pretty printer that prints a type ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -122,7 +122,7 @@ module GHC.Core.Type ( -- *** Levity and boxity isLiftedType_maybe, - isLiftedTypeKind, isUnliftedTypeKind, + isLiftedTypeKind, isUnliftedTypeKind, pickyIsLiftedTypeKind, isLiftedRuntimeRep, isUnliftedRuntimeRep, isUnliftedType, mightBeUnliftedType, isUnboxedTupleType, isUnboxedSumType, isAlgType, isDataFamilyAppType, @@ -556,6 +556,22 @@ isLiftedTypeKind kind Just rep -> isLiftedRuntimeRep rep Nothing -> False +pickyIsLiftedTypeKind :: Kind -> Bool +-- Checks whether the kind is literally +-- TYPE LiftedRep +-- or Type +-- without expanding type synonyms or anything +-- Used only when deciding whether to suppress the ":: *" in +-- (a :: *) when printing kinded type variables +pickyIsLiftedTypeKind kind + | TyConApp tc [arg] <- kind + , tc `hasKey` tYPETyConKey + , TyConApp rr_tc [] <- arg + , rr_tc `hasKey` liftedRepDataConKey = True + | TyConApp tc [] <- kind + , tc `hasKey` liftedTypeKindTyConKey = True + | otherwise = False + isLiftedRuntimeRep :: Type -> Bool -- isLiftedRuntimeRep is true of LiftedRep :: RuntimeRep -- False of type variables (a :: RuntimeRep) @@ -2633,6 +2649,46 @@ prefer doing inner expansions first. For example, We have occCheckExpand b (F (G b)) = Just (F Char) even though we could also expand F to get rid of b. + +Note [Occurrence checking: look inside kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we are considering unifying + (alpha :: *) ~ Int -> (beta :: alpha -> alpha) +This may be an error (what is that alpha doing inside beta's kind?), +but we must not make the mistake of actually unifying or we'll +build an infinite data structure. So when looking for occurrences +of alpha in the rhs, we must look in the kinds of type variables +that occur there. + +occCheckExpand tries to expand type synonyms to remove +unnecessary occurrences of a variable, and thereby get past an +occurs-check failure. This is good; but + we can't do it in the /kind/ of a variable /occurrence/ + +For example #18451 built an infinite type: + type Const a b = a + data SameKind :: k -> k -> Type + type T (k :: Const Type a) = forall (b :: k). SameKind a b + +We have + b :: k + k :: Const Type a + a :: k (must be same as b) + +So if we aren't careful, a's kind mentions a, which is bad. +And expanding an /occurrence/ of 'a' doesn't help, because the +/binding site/ is the master copy and all the occurrences should +match it. + +Here's a related example: + f :: forall a b (c :: Const Type b). Proxy '[a, c] + +The list means that 'a' gets the same kind as 'c'; but that +kind mentions 'b', so the binders are out of order. + +Bottom line: in occCheckExpand, do not expand inside the kinds +of occurrences. See bad_var_occ in occCheckExpand. And +see #18451 for more debate. -} occCheckExpand :: [Var] -> Type -> Maybe Type @@ -2653,11 +2709,10 @@ occCheckExpand vs_to_avoid ty -- The VarSet is the set of variables we are trying to avoid -- The VarEnv carries mappings necessary -- because of kind expansion - go cxt@(as, env) (TyVarTy tv') - | tv' `elemVarSet` as = Nothing - | Just tv'' <- lookupVarEnv env tv' = return (mkTyVarTy tv'') - | otherwise = do { tv'' <- go_var cxt tv' - ; return (mkTyVarTy tv'') } + go (as, env) ty@(TyVarTy tv) + | Just tv' <- lookupVarEnv env tv = return (mkTyVarTy tv') + | bad_var_occ as tv = Nothing + | otherwise = return ty go _ ty@(LitTy {}) = return ty go cxt (AppTy ty1 ty2) = do { ty1' <- go cxt ty1 @@ -2670,7 +2725,7 @@ occCheckExpand vs_to_avoid ty ; return (ty { ft_mult = w', ft_arg = ty1', ft_res = ty2' }) } go cxt@(as, env) (ForAllTy (Bndr tv vis) body_ty) = do { ki' <- go cxt (varType tv) - ; let tv' = setVarType tv ki' + ; let tv' = setVarType tv ki' env' = extendVarEnv env tv tv' as' = as `delVarSet` tv ; body' <- go (as', env') body_ty @@ -2694,9 +2749,12 @@ occCheckExpand vs_to_avoid ty ; return (mkCoercionTy co') } ------------------ - go_var cxt v = updateVarTypeM (go cxt) v - -- Works for TyVar and CoVar - -- See Note [Occurrence checking: look inside kinds] + bad_var_occ :: VarSet -> Var -> Bool + -- Works for TyVar and CoVar + -- See Note [Occurrence checking: look inside kinds] + bad_var_occ vs_to_avoid v + = v `elemVarSet` vs_to_avoid + || tyCoVarsOfType (varType v) `intersectsVarSet` vs_to_avoid ------------------ go_mco _ MRefl = return MRefl @@ -2726,13 +2784,15 @@ occCheckExpand vs_to_avoid ty ; co2' <- go_co cxt co2 ; w' <- go_co cxt w ; return (mkFunCo r w' co1' co2') } - go_co cxt@(as,env) (CoVarCo c) - | c `elemVarSet` as = Nothing + go_co (as,env) co@(CoVarCo c) | Just c' <- lookupVarEnv env c = return (mkCoVarCo c') - | otherwise = do { c' <- go_var cxt c - ; return (mkCoVarCo c') } - go_co cxt (HoleCo h) = do { c' <- go_var cxt (ch_co_var h) - ; return (HoleCo (h { ch_co_var = c' })) } + | bad_var_occ as c = Nothing + | otherwise = return co + + go_co (as,_) co@(HoleCo h) + | bad_var_occ as (ch_co_var h) = Nothing + | otherwise = return co + go_co cxt (AxiomInstCo ax ind args) = do { args' <- mapM (go_co cxt) args ; return (mkAxiomInstCo ax ind args') } go_co cxt (UnivCo p r ty1 ty2) = do { p' <- go_prov cxt p ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -2046,21 +2046,8 @@ matchExpectedFunKind hs_ty n k = go n k ********************************************************************* -} -{- Note [Occurrence checking: look inside kinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Suppose we are considering unifying - (alpha :: *) ~ Int -> (beta :: alpha -> alpha) -This may be an error (what is that alpha doing inside beta's kind?), -but we must not make the mistake of actually unifying or we'll -build an infinite data structure. So when looking for occurrences -of alpha in the rhs, we must look in the kinds of type variables -that occur there. - -NB: we may be able to remove the problem via expansion; see - Note [Occurs check expansion]. So we have to try that. - -Note [Checking for foralls] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Checking for foralls] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unless we have -XImpredicativeTypes (which is a totally unsupported feature), we do not want to unify alpha ~ (forall a. a->a) -> Int @@ -2073,10 +2060,10 @@ Consider (alpha :: forall k. k->*) ~ (beta :: forall k. k->*) This is legal; e.g. dependent/should_compile/T11635. -We don't want to reject it because of the forall in beta's kind, -but (see Note [Occurrence checking: look inside kinds]) we do -need to look in beta's kind. So we carry a flag saying if a 'forall' -is OK, and switch the flag on when stepping inside a kind. +We don't want to reject it because of the forall in beta's kind, but +(see Note [Occurrence checking: look inside kinds] in GHC.Core.Type) +we do need to look in beta's kind. So we carry a flag saying if a +'forall' is OK, and switch the flag on when stepping inside a kind. Why is it OK? Why does it not count as impredicative polymorphism? The reason foralls are bad is because we reply on "seeing" foralls @@ -2197,6 +2184,7 @@ preCheck dflags ty_fam_ok tv ty | tv == tv' = MTVU_Occurs | otherwise = fast_check_occ (tyVarKind tv') -- See Note [Occurrence checking: look inside kinds] + -- in GHC.Core.Type fast_check (TyConApp tc tys) | bad_tc tc = MTVU_Bad ===================================== testsuite/tests/polykinds/T18451.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind + +type Const a b = a +data SameKind :: k -> k -> Type + +type T (k :: Const Type a) = forall (b :: k). SameKind a b ===================================== testsuite/tests/polykinds/T18451.stderr ===================================== @@ -0,0 +1,9 @@ + +T18451.hs:10:58: error: + • Expected kind ‘k0’, but ‘b’ has kind ‘k’ + • In the second argument of ‘SameKind’, namely ‘b’ + In the type ‘forall (b :: k). SameKind a b’ + In the type declaration for ‘T’ + • Type variable kinds: + a :: k0 + k :: Const (*) a ===================================== testsuite/tests/polykinds/T18451a.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451a.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/T18451b.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451b.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451b.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -220,3 +220,6 @@ test('CuskFam', normal, compile, ['']) test('T17841', normal, compile_fail, ['']) test('T17963', normal, compile_fail, ['']) test('T18300', normal, compile_fail, ['']) +test('T18451', normal, compile_fail, ['']) +test('T18451a', normal, compile_fail, ['']) +test('T18451b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0320af67bacdbd7917b5d901d5a1b02266b793fb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0320af67bacdbd7917b5d901d5a1b02266b793fb You're receiving 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 Jul 20 08:21:55 2020 From: gitlab at gitlab.haskell.org (Sylvain Henry) Date: Mon, 20 Jul 2020 04:21:55 -0400 Subject: [Git][ghc/ghc][wip/proposal-195] Use a newtype `Code` for the return type of typed quotations (Proposal #195) Message-ID: <5f1554232a797_80b3f84901582f040632c8@gitlab.haskell.org.mail> Sylvain Henry pushed to branch wip/proposal-195 at Glasgow Haskell Compiler / GHC Commits: f07a8c8c by Matthew Pickering at 2020-07-20T10:20:01+02:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Splice.hs - docs/users_guide/exts/deriving_extra.rst - docs/users_guide/exts/template_haskell.rst - libraries/template-haskell/Language/Haskell/TH.hs - + libraries/template-haskell/Language/Haskell/TH/CodeDo.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - libraries/template-haskell/template-haskell.cabal.in - libraries/text - testsuite/tests/deriving/should_compile/drv-empty-data.stderr - testsuite/tests/parser/should_compile/Proposal229f_instances.hs - testsuite/tests/partial-sigs/should_compile/TypedSplice.hs - testsuite/tests/partial-sigs/should_compile/TypedSplice.stderr - testsuite/tests/quotes/T17857.hs - testsuite/tests/th/T10945.stderr - testsuite/tests/th/T11452.stderr - testsuite/tests/th/T15471A.hs - testsuite/tests/th/T15843.hs - testsuite/tests/th/T16195A.hs - testsuite/tests/th/T18121.hs - testsuite/tests/th/T8577.stderr - testsuite/tests/th/T8577a.hs - testsuite/tests/th/TH_StringLift.hs - testsuite/tests/th/TH_reifyLocalDefs.hs - testsuite/tests/th/overloaded/T17839.hs - testsuite/tests/th/overloaded/TH_overloaded_constraints.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f07a8c8c462b9a7cf2221223c543055193d8a653 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f07a8c8c462b9a7cf2221223c543055193d8a653 You're receiving 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 Jul 20 08:30:40 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 20 Jul 2020 04:30:40 -0400 Subject: [Git][ghc/ghc][wip/angerman/revert-symbols] 14 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f1556304f3cd_80b3f84962c9cf04066254@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/revert-symbols at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst - hadrian/hadrian.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/71a94d5f2c16cbc1d770f7bf11b5d70f22a83edd...0dd405529f0f17cd9a5b299e7ae5539a885b4b5a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/71a94d5f2c16cbc1d770f7bf11b5d70f22a83edd...0dd405529f0f17cd9a5b299e7ae5539a885b4b5a You're receiving 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 Jul 20 09:10:50 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Mon, 20 Jul 2020 05:10:50 -0400 Subject: [Git][ghc/ghc][wip/haddock-accum] 11 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f155f9a3fb78_80b3f84868c382840739d3@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/haddock-accum at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 4bda699c by Vladislav Zavialov at 2020-07-20T12:10:03+03:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 23 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Stats.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/83c58077f65486d0ba68c98662e794ad5de22cea...4bda699ce3a3f86486409b3f45f1eb761e3b8265 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/83c58077f65486d0ba68c98662e794ad5de22cea...4bda699ce3a3f86486409b3f45f1eb761e3b8265 You're receiving 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 Jul 20 09:14:44 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Mon, 20 Jul 2020 05:14:44 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] Fix Haddock for EndTSOQueue Message-ID: <5f156084d98be_80b3f84925412344075575@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: 737bf2e0 by Sven Tennie at 2020-07-20T11:14:32+02:00 Fix Haddock for EndTSOQueue - - - - - 1 changed file: - libraries/ghc-heap/GHC/Exts/Heap/Closures.hs Changes: ===================================== libraries/ghc-heap/GHC/Exts/Heap/Closures.hs ===================================== @@ -285,8 +285,8 @@ data GenClosure b , tot_stack_size :: Word32 , prof :: Maybe StgTSOProfInfo } --- | Marker for the end of TSO queues --- Technically it has the same structure as an StgTSO, but most data isn't initialized. + -- | Marker for the end of TSO queues + -- Technically it has the same structure as an StgTSO, but most data isn't initialized. | EndTSOQueue { info :: !StgInfoTable } -- Representation of StgStack: The 'tsoStack' of a 'TSOClosure'. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/737bf2e083cfe55a329e5d29292fb3b311e36518 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/737bf2e083cfe55a329e5d29292fb3b311e36518 You're receiving 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 Jul 20 10:18:20 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Mon, 20 Jul 2020 06:18:20 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18478 Message-ID: <5f156f6c493e4_80bd68a9b8408138b@gitlab.haskell.org.mail> Sebastian Graf pushed new branch wip/T18478 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18478 You're receiving 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 Jul 20 11:09:47 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Mon, 20 Jul 2020 07:09:47 -0400 Subject: [Git][ghc/ghc][wip/T18478] Add regression test for #18478 Message-ID: <5f157b7b630d5_80b3f84868c382840864d5@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18478 at Glasgow Haskell Compiler / GHC Commits: a59bd6c9 by Sebastian Graf at 2020-07-20T13:09:07+02:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 2 changed files: - + testsuite/tests/pmcheck/should_compile/T18478.hs - testsuite/tests/pmcheck/should_compile/all.T Changes: ===================================== testsuite/tests/pmcheck/should_compile/T18478.hs ===================================== @@ -0,0 +1,951 @@ +{-# LANGUAGE UndecidableSuperClasses, FunctionalDependencies, RoleAnnotations, ExplicitNamespaces, TypeFamilies, RankNTypes, TypeApplications, LambdaCase, DerivingStrategies, ScopedTypeVariables, TypeOperators, DataKinds, PolyKinds, GADTs, TypeFamilyDependencies, ConstraintKinds, UndecidableInstances, TypeSynonymInstances, FlexibleInstances, DeriveGeneric, AllowAmbiguousTypes, StrictData #-} +{-# OPTIONS_GHC -Wno-redundant-constraints -fforce-recomp -Wincomplete-patterns #-} + +{- | Module, containing restrictions imposed by instruction or value scope. + +Michelson have multiple restrictions on values, examples: +* @operation@ type cannot appear in parameter. +* @big_map@ type cannot appear in @PUSH at -able constants. +* @contract@ type cannot appear in type we @UNPACK@ to. + +Thus we declare multiple "scopes" - constraints applied in corresponding +situations, for instance +* 'ParameterScope'; +* 'StorageScope'; +* 'ConstantScope'. + +Also we separate multiple "classes" of scope-related constraints. + +* 'ParameterScope' and similar ones are used within Michelson engine, +they are understandable by GHC but produce not very clarifying errors. + +* 'ProperParameterBetterErrors' and similar ones are middle-layer constraints, +they produce human-readable errors but GHC cannot make conclusions from them. +They are supposed to be used only by eDSLs to define their own high-level +constraints. + +* Lorentz and other eDSLs may declare their own constraints, in most cases +you should use them. For example see 'Lorentz.Constraints' module. + +-} + +module T18478 + ( -- * Scopes + ConstantScope + , StorageScope + , PackedValScope + , ParameterScope + , PrintedValScope + , UnpackedValScope + + , ProperParameterBetterErrors + , ProperStorageBetterErrors + , ProperConstantBetterErrors + , ProperPackedValBetterErrors + , ProperUnpackedValBetterErrors + , ProperPrintedValBetterErrors + + , properParameterEvi + , properStorageEvi + , properConstantEvi + , properPackedValEvi + , properUnpackedValEvi + , properPrintedValEvi + , (:-)(..) + + , BadTypeForScope (..) + , CheckScope (..) + + -- * Implementation internals + , HasNoBigMap + , HasNoNestedBigMaps + , HasNoOp + , HasNoContract + , ContainsBigMap + , ContainsNestedBigMaps + + , ForbidOp + , ForbidContract + , ForbidBigMap + , ForbidNestedBigMaps + , FailOnBigMapFound + , FailOnNestedBigMapsFound + , FailOnOperationFound + + , OpPresence (..) + , ContractPresence (..) + , BigMapPresence (..) + , NestedBigMapsPresence (..) + , checkOpPresence + , checkContractTypePresence + , checkBigMapPresence + , checkNestedBigMapsPresence + , opAbsense + , contractTypeAbsense + , bigMapAbsense + , nestedBigMapsAbsense + , forbiddenOp + , forbiddenContractType + , forbiddenBigMap + , forbiddenNestedBigMaps + + -- * Re-exports + , withDict + , SingI (..) + ) where + +import Data.Type.Bool (type (||)) +import Data.Type.Coercion +import GHC.TypeLits (ErrorMessage(..), TypeError) +import Data.Typeable +import GHC.Generics +import GHC.Exts +import Data.Kind + +data T = + TKey + | TUnit + | TSignature + | TChainId + | TOption T + | TList T + | TSet T + | TOperation + | TContract T + | TPair T T + | TOr T T + | TLambda T T + | TMap T T + | TBigMap T T + | TInt + | TNat + | TString + | TBytes + | TMutez + | TBool + | TKeyHash + | TTimestamp + | TAddress + deriving stock (Eq, Show) + +type family Sing :: k -> Type + +class SingI a where + sing :: Sing a + +class SingKind (k :: Type) where + -- | Get a base type from the promoted kind. For example, + -- @Demote Bool@ will be the type @Bool at . Rarely, the type and kind do not + -- match. For example, @Demote Nat@ is @Natural at . + type Demote k = (r :: Type) | r -> k + + -- | Convert a singleton to its unrefined version. + fromSing :: Sing (a :: k) -> Demote k + + -- | Convert an unrefined type to an existentially-quantified singleton type. + toSing :: Demote k -> SomeSing k + +data SomeSing (k :: Type) :: Type where + SomeSing :: Sing (a :: k) -> SomeSing k + + +-- | Instance of data family 'Sing' for 'T'. +-- Custom instance is implemented in order to inject 'Typeable' +-- constraint for some of constructors. +data SingT :: T -> Type where + STKey :: SingT 'TKey + STUnit :: SingT 'TUnit + STSignature :: SingT 'TSignature + STChainId :: SingT 'TChainId + STOption :: (SingI a, Typeable a) => Sing a -> SingT ( 'TOption a) + STList :: (SingI a, Typeable a) => Sing a -> SingT ( 'TList a ) + STSet :: (SingI a, Typeable a) => Sing a -> SingT ( 'TSet a ) + STOperation :: SingT 'TOperation + STContract :: (SingI a, Typeable a) + => Sing a -> SingT ( 'TContract a ) + STPair :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TPair a b) + STOr :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TOr a b) + STLambda :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TLambda a b) + STMap :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TMap a b) + STBigMap :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TBigMap a b) + STInt :: SingT 'TInt + STNat :: SingT 'TNat + STString :: SingT 'TString + STBytes :: SingT 'TBytes + STMutez :: SingT 'TMutez + STBool :: SingT 'TBool + STKeyHash :: SingT 'TKeyHash + STTimestamp :: SingT 'TTimestamp + STAddress :: SingT 'TAddress + +type instance Sing = SingT + +--------------------------------------------- +-- Singleton-related helpers for T +-------------------------------------------- + +-- | Version of 'SomeSing' with 'Typeable' constraint, +-- specialized for use with 'T' kind. +data SomeSingT where + SomeSingT :: forall (a :: T). (Typeable a, SingI a) + => Sing a -> SomeSingT + +-- | Version of 'withSomeSing' with 'Typeable' constraint +-- provided to processing function. +-- +-- Required for not to erase these useful constraints when doing +-- conversion from value of type 'T' to its singleton representation. +withSomeSingT + :: T + -> (forall (a :: T). (Typeable a, SingI a) => Sing a -> r) + -> r +withSomeSingT t f = (\(SomeSingT s) -> f s) (toSingT t) + +-- | Version of 'fromSing' specialized for use with +-- @data instance Sing :: T -> Type@ which requires 'Typeable' +-- constraint for some of its constructors +fromSingT :: Sing (a :: T) -> T +fromSingT = \case + STKey -> TKey + STUnit -> TUnit + STSignature -> TSignature + STChainId -> TChainId + STOption t -> TOption (fromSingT t) + STList t -> TList (fromSingT t) + STSet t -> TSet (fromSingT t) + STOperation -> TOperation + STContract t -> TContract (fromSingT t) + STPair a b -> TPair (fromSingT a) (fromSingT b) + STOr a b -> TOr (fromSingT a) (fromSingT b) + STLambda a b -> TLambda (fromSingT a) (fromSingT b) + STMap a b -> TMap (fromSingT a) (fromSingT b) + STBigMap a b -> TBigMap (fromSingT a) (fromSingT b) + STInt -> TInt + STNat -> TNat + STString -> TString + STBytes -> TBytes + STMutez -> TMutez + STBool -> TBool + STKeyHash -> TKeyHash + STTimestamp -> TTimestamp + STAddress -> TAddress + +-- | Version of 'toSing' which creates 'SomeSingT'. +toSingT :: T -> SomeSingT +toSingT = \case + TKey -> SomeSingT STKey + TUnit -> SomeSingT STUnit + TSignature -> SomeSingT STSignature + TChainId -> SomeSingT STChainId + TOption t -> withSomeSingT t $ \tSing -> SomeSingT $ STOption tSing + TList t -> withSomeSingT t $ \tSing -> SomeSingT $ STList tSing + TSet ct -> withSomeSingT ct $ \ctSing -> SomeSingT $ STSet ctSing + TOperation -> SomeSingT STOperation + TContract t -> withSomeSingT t $ \tSing -> SomeSingT $ STContract tSing + TPair l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STPair lSing rSing + TOr l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STOr lSing rSing + TLambda l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STLambda lSing rSing + TMap l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STMap lSing rSing + TBigMap l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STBigMap lSing rSing + TInt -> SomeSingT STInt + TNat -> SomeSingT STNat + TString -> SomeSingT STString + TBytes -> SomeSingT STBytes + TMutez -> SomeSingT STMutez + TBool -> SomeSingT STBool + TKeyHash -> SomeSingT STKeyHash + TTimestamp -> SomeSingT STTimestamp + TAddress -> SomeSingT STAddress + +instance SingKind T where + type Demote T = T + fromSing = fromSingT + toSing t = case toSingT t of SomeSingT s -> SomeSing s + +instance SingI 'TKey where + sing = STKey +instance SingI 'TUnit where + sing = STUnit +instance SingI 'TSignature where + sing = STSignature +instance SingI 'TChainId where + sing = STChainId +instance (SingI a, Typeable a) => SingI ( 'TOption (a :: T)) where + sing = STOption sing +instance (SingI a, Typeable a) => SingI ( 'TList (a :: T)) where + sing = STList sing +instance (SingI a, Typeable a) => SingI ( 'TSet (a :: T)) where + sing = STSet sing +instance SingI 'TOperation where + sing = STOperation +instance (SingI a, Typeable a) => + SingI ( 'TContract (a :: T)) where + sing = STContract sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TPair a b) where + sing = STPair sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TOr a b) where + sing = STOr sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TLambda a b) where + sing = STLambda sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TMap a b) where + sing = STMap sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TBigMap a b) where + sing = STBigMap sing sing +instance SingI 'TInt where + sing = STInt +instance SingI 'TNat where + sing = STNat +instance SingI 'TString where + sing = STString +instance SingI 'TBytes where + sing = STBytes +instance SingI 'TMutez where + sing = STMutez +instance SingI 'TBool where + sing = STBool +instance SingI 'TKeyHash where + sing = STKeyHash +instance SingI 'TTimestamp where + sing = STTimestamp +instance SingI 'TAddress where + sing = STAddress + +data Dict :: Constraint -> * where + Dict :: a => Dict a + deriving Typeable + +withDict :: HasDict c e => e -> (c => r) -> r +withDict d r = case evidence d of + Dict -> r + +class HasDict c e | e -> c where + evidence :: e -> Dict c + +instance HasDict a (Dict a) where + evidence = Prelude.id + +instance a => HasDict b (a :- b) where + evidence (Sub x) = x + +instance HasDict (Coercible a b) (Coercion a b) where + evidence Coercion = Dict + +instance HasDict (a ~ b) (a :~: b) where + evidence Refl = Dict + +infixl 1 \\ -- required comment + +(\\) :: HasDict c e => (c => r) -> e -> r +r \\ d = withDict d r +infixr 9 :- +newtype a :- b = Sub (a => Dict b) + deriving Typeable +type role (:-) nominal nominal +(***) :: (a :- b) -> (c :- d) -> (a, c) :- (b, d) +f *** g = Sub $ Dict \\ f \\ g + +type f $ a = f a +infixr 2 $ + +maybeToRight a Nothing = Left a +maybeToRight _ (Just a) = Right a + +---------------------------------------------------------------------------- +-- Constraints +---------------------------------------------------------------------------- +-- | Whether this type contains 'TOperation' type. +-- +-- In some scopes (constants, parameters, storage) appearing for operation type +-- is prohibited. +-- Operations in input/output of lambdas are allowed without limits though. +type family ContainsOp (t :: T) :: Bool where + ContainsOp 'TKey = 'False + ContainsOp 'TUnit = 'False + ContainsOp 'TSignature = 'False + ContainsOp 'TChainId = 'False + ContainsOp ('TOption t) = ContainsOp t + ContainsOp ('TList t) = ContainsOp t + ContainsOp ('TSet t) = ContainsOp t + ContainsOp 'TOperation = 'True + ContainsOp ('TContract t) = ContainsOp t + ContainsOp ('TPair a b) = ContainsOp a || ContainsOp b + ContainsOp ('TOr a b) = ContainsOp a || ContainsOp b + ContainsOp ('TLambda _ _) = 'False + ContainsOp ('TMap k v) = ContainsOp k || ContainsOp v + ContainsOp ('TBigMap k v) = ContainsOp k || ContainsOp v + ContainsOp _ = 'False + +-- | Whether this type contains 'TContract' type. +-- +-- In some scopes (constants, storage) appearing for contract type +-- is prohibited. +-- Contracts in input/output of lambdas are allowed without limits though. +type family ContainsContract (t :: T) :: Bool where + ContainsContract 'TKey = 'False + ContainsContract 'TUnit = 'False + ContainsContract 'TSignature = 'False + ContainsContract 'TChainId = 'False + ContainsContract ('TOption t) = ContainsContract t + ContainsContract ('TList t) = ContainsContract t + ContainsContract ('TSet _) = 'False + ContainsContract 'TOperation = 'False + ContainsContract ('TContract _) = 'True + ContainsContract ('TPair a b) = ContainsContract a || ContainsContract b + ContainsContract ('TOr a b) = ContainsContract a || ContainsContract b + ContainsContract ('TLambda _ _) = 'False + ContainsContract ('TMap _ v) = ContainsContract v + ContainsContract ('TBigMap _ v) = ContainsContract v + ContainsContract _ = 'False + +-- | Whether this type contains 'TBigMap' type. +type family ContainsBigMap (t :: T) :: Bool where + ContainsBigMap 'TKey = 'False + ContainsBigMap 'TUnit = 'False + ContainsBigMap 'TSignature = 'False + ContainsBigMap 'TChainId = 'False + ContainsBigMap ('TOption t) = ContainsBigMap t + ContainsBigMap ('TList t) = ContainsBigMap t + ContainsBigMap ('TSet _) = 'False + ContainsBigMap 'TOperation = 'False + ContainsBigMap ('TContract t) = ContainsBigMap t + ContainsBigMap ('TPair a b) = ContainsBigMap a || ContainsBigMap b + ContainsBigMap ('TOr a b) = ContainsBigMap a || ContainsBigMap b + ContainsBigMap ('TLambda _ _) = 'False + ContainsBigMap ('TMap _ v) = ContainsBigMap v + ContainsBigMap ('TBigMap _ _) = 'True + ContainsBigMap _ = 'False + +-- | Whether this type contains a type with nested 'TBigMap's . +-- +-- Nested big_maps (i.e. big_map which contains another big_map inside of it's value type). Are +-- prohibited in all contexts. Some context such as PUSH, APPLY, PACK/UNPACK instructions are more +-- strict because they doesn't work with big_map at all. +type family ContainsNestedBigMaps (t :: T) :: Bool where + ContainsNestedBigMaps 'TKey = 'False + ContainsNestedBigMaps 'TUnit = 'False + ContainsNestedBigMaps 'TSignature = 'False + ContainsNestedBigMaps 'TChainId = 'False + ContainsNestedBigMaps ('TOption t) = ContainsNestedBigMaps t + ContainsNestedBigMaps ('TList t) = ContainsNestedBigMaps t + ContainsNestedBigMaps ('TSet _) = 'False + ContainsNestedBigMaps 'TOperation = 'False + ContainsNestedBigMaps ('TContract t) = ContainsNestedBigMaps t + ContainsNestedBigMaps ('TPair a b) = ContainsNestedBigMaps a || ContainsNestedBigMaps b + ContainsNestedBigMaps ('TOr a b) = ContainsNestedBigMaps a || ContainsNestedBigMaps b + ContainsNestedBigMaps ('TLambda _ _) = 'False + ContainsNestedBigMaps ('TMap _ v) = ContainsNestedBigMaps v + ContainsNestedBigMaps ('TBigMap _ v) = ContainsBigMap v + ContainsNestedBigMaps _ = 'False + +-- | Constraint which ensures that operation type does not appear in a given type. +-- +-- Not just a type alias in order to be able to partially apply it +-- (e.g. in 'Each'). +class (ContainsOp t ~ 'False) => HasNoOp t +instance (ContainsOp t ~ 'False) => HasNoOp t + +-- | Constraint which ensures that contract type does not appear in a given type. +class (ContainsContract t ~ 'False) => HasNoContract t +instance (ContainsContract t ~ 'False) => HasNoContract t + +-- | Constraint which ensures that bigmap does not appear in a given type. +class (ContainsBigMap t ~ 'False) => HasNoBigMap t +instance (ContainsBigMap t ~ 'False) => HasNoBigMap t + +-- | Constraint which ensures that there are no nested bigmaps. +class (ContainsNestedBigMaps t ~ 'False) => HasNoNestedBigMaps t +instance (ContainsNestedBigMaps t ~ 'False) => HasNoNestedBigMaps t + +-- | Report a human-readable error about 'TOperation' at a wrong place. +type family FailOnOperationFound (enabled :: Bool) :: Constraint where + FailOnOperationFound 'True = + TypeError ('Text "Operations are not allowed in this scope") + FailOnOperationFound 'False = () + +-- | Report a human-readable error about 'TContract' at a wrong place. +type family FailOnContractFound (enabled :: Bool) :: Constraint where + FailOnContractFound 'True = + TypeError ('Text "Type `contract` is not allowed in this scope") + FailOnContractFound 'False = () + +-- | Report a human-readable error about 'TBigMap' at a wrong place. +type family FailOnBigMapFound (enabled :: Bool) :: Constraint where + FailOnBigMapFound 'True = + TypeError ('Text "BigMaps are not allowed in this scope") + FailOnBigMapFound 'False = () + +-- | Report a human-readable error that 'TBigMap' contains another 'TBigMap' +type family FailOnNestedBigMapsFound (enabled :: Bool) :: Constraint where + FailOnNestedBigMapsFound 'True = + TypeError ('Text "Nested BigMaps are not allowed") + FailOnNestedBigMapsFound 'False = () + +-- | This is like 'HasNoOp', it raises a more human-readable error +-- when @t@ type is concrete, but GHC cannot make any conclusions +-- from such constraint as it can for 'HasNoOp'. +-- Though, hopefully, it will someday: +-- . +-- +-- Use this constraint in our eDSL. +type ForbidOp t = FailOnOperationFound (ContainsOp t) + +type ForbidContract t = FailOnContractFound (ContainsContract t) + +type ForbidBigMap t = FailOnBigMapFound (ContainsBigMap t) + +type ForbidNestedBigMaps t = FailOnNestedBigMapsFound (ContainsNestedBigMaps t) + +-- | Evidence of that 'HasNoOp' is deducable from 'ForbidOp'. +forbiddenOpEvi :: forall t. (SingI t, ForbidOp t) :- HasNoOp t +forbiddenOpEvi = Sub $ + -- It's not clear now to proof GHC that @HasNoOp t@ is implication of + -- @ForbidOp t@, so we use @error@ below and also disable + -- "-Wredundant-constraints" extension. + case checkOpPresence (sing @t) of + OpAbsent -> Dict + OpPresent -> error "impossible" + +-- | Reify 'HasNoOp' contraint from 'ForbidOp'. +-- +-- Left for backward compatibility. +forbiddenOp + :: forall t a. + (SingI t, ForbidOp t) + => (HasNoOp t => a) + -> a +forbiddenOp = withDict $ forbiddenOpEvi @t + +forbiddenBigMapEvi :: forall t. (SingI t, ForbidBigMap t) :- HasNoBigMap t +forbiddenBigMapEvi = Sub $ + case checkBigMapPresence (sing @t) of + BigMapAbsent -> Dict + BigMapPresent -> error "impossible" + +forbiddenNestedBigMapsEvi :: forall t. (SingI t, ForbidNestedBigMaps t) :- HasNoNestedBigMaps t +forbiddenNestedBigMapsEvi = Sub $ + case checkNestedBigMapsPresence (sing @t) of + NestedBigMapsAbsent -> Dict + NestedBigMapsPresent -> error "impossible" + +forbiddenBigMap + :: forall t a. + (SingI t, ForbidBigMap t) + => (HasNoBigMap t => a) + -> a +forbiddenBigMap = withDict $ forbiddenBigMapEvi @t + +forbiddenNestedBigMaps + :: forall t a. + (SingI t, ForbidNestedBigMaps t) + => (HasNoNestedBigMaps t => a) + -> a +forbiddenNestedBigMaps = withDict $ forbiddenNestedBigMapsEvi @t + +-- | Reify 'HasNoContract' contraint from 'ForbidContract'. +forbiddenContractTypeEvi + :: forall t. (SingI t, ForbidContract t) :- HasNoContract t +forbiddenContractTypeEvi = Sub $ + case checkContractTypePresence (sing @t) of + ContractAbsent -> Dict + ContractPresent -> error "impossible" + +-- | Reify 'HasNoContract' contraint from 'ForbidContract'. +forbiddenContractType + :: forall t a. + (SingI t, ForbidContract t) + => (HasNoContract t => a) + -> a +forbiddenContractType = withDict $ forbiddenContractTypeEvi @t + +-- | Whether the type contains 'TOperation', with proof. +data OpPresence (t :: T) + = ContainsOp t ~ 'True => OpPresent + | ContainsOp t ~ 'False => OpAbsent + +data ContractPresence (t :: T) + = ContainsContract t ~ 'True => ContractPresent + | ContainsContract t ~ 'False => ContractAbsent + +data BigMapPresence (t :: T) + = ContainsBigMap t ~ 'True => BigMapPresent + | ContainsBigMap t ~ 'False => BigMapAbsent + +data NestedBigMapsPresence (t :: T) + = ContainsNestedBigMaps t ~ 'True => NestedBigMapsPresent + | ContainsNestedBigMaps t ~ 'False => NestedBigMapsAbsent + +-- @rvem: IMO, generalization of OpPresence and BigMapPresence to +-- TPresence is not worth it, due to the fact that +-- it will require more boilerplate in checkTPresence implementation +-- than it is already done in checkOpPresence and checkBigMapPresence + +-- | Check at runtime whether the given type contains 'TOperation'. +checkOpPresence :: Sing (ty :: T) -> OpPresence ty +checkOpPresence = \case + -- This is a sad amount of boilerplate, but at least + -- there is no chance to make a mistake in it. + -- We can't do in a simpler way while requiring only @Sing ty@ / @SingI ty@, + -- and a more complex constraint would be too unpleasant and confusing to + -- propagate everywhere. + STKey -> OpAbsent + STSignature -> OpAbsent + STChainId -> OpAbsent + STUnit -> OpAbsent + STOption t -> case checkOpPresence t of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STList t -> case checkOpPresence t of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STSet a -> case checkOpPresence a of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STOperation -> OpPresent + STContract t -> case checkOpPresence t of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STPair a b -> case (checkOpPresence a, checkOpPresence b) of + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + (OpAbsent, OpAbsent) -> OpAbsent + STOr a b -> case (checkOpPresence a, checkOpPresence b) of + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + (OpAbsent, OpAbsent) -> OpAbsent + STLambda _ _ -> OpAbsent + STMap k v -> case (checkOpPresence k, checkOpPresence v) of + (OpAbsent, OpAbsent) -> OpAbsent + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + STBigMap k v -> case (checkOpPresence k, checkOpPresence v) of + (OpAbsent, OpAbsent) -> OpAbsent + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + STInt -> OpAbsent + STNat -> OpAbsent + STString -> OpAbsent + STBytes -> OpAbsent + STMutez -> OpAbsent + STBool -> OpAbsent + STKeyHash -> OpAbsent + STTimestamp -> OpAbsent + STAddress -> OpAbsent + +-- | Check at runtime whether the given type contains 'TContract'. +checkContractTypePresence :: Sing (ty :: T) -> ContractPresence ty +checkContractTypePresence = \case + STKey -> ContractAbsent + STSignature -> ContractAbsent + STChainId -> ContractAbsent + STUnit -> ContractAbsent + STOption t -> case checkContractTypePresence t of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STList t -> case checkContractTypePresence t of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STSet _ -> ContractAbsent + STOperation -> ContractAbsent + STContract _ -> ContractPresent + STPair a b -> case (checkContractTypePresence a, checkContractTypePresence b) of + (ContractPresent, _) -> ContractPresent + (_, ContractPresent) -> ContractPresent + (ContractAbsent, ContractAbsent) -> ContractAbsent + STOr a b -> case (checkContractTypePresence a, checkContractTypePresence b) of + (ContractPresent, _) -> ContractPresent + (_, ContractPresent) -> ContractPresent + (ContractAbsent, ContractAbsent) -> ContractAbsent + STLambda _ _ -> ContractAbsent + STMap _ v -> case checkContractTypePresence v of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STBigMap _ v -> case checkContractTypePresence v of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STInt -> ContractAbsent + STNat -> ContractAbsent + STString -> ContractAbsent + STBytes -> ContractAbsent + STMutez -> ContractAbsent + STBool -> ContractAbsent + STKeyHash -> ContractAbsent + STTimestamp -> ContractAbsent + STAddress -> ContractAbsent + +-- | Check at runtime whether the given type contains 'TBigMap'. +checkBigMapPresence :: Sing (ty :: T) -> BigMapPresence ty +checkBigMapPresence = \case + -- More boilerplate to boilerplate god. + STKey -> BigMapAbsent + STSignature -> BigMapAbsent + STChainId -> BigMapAbsent + STUnit -> BigMapAbsent + STOption t -> case checkBigMapPresence t of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STList t -> case checkBigMapPresence t of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STSet _ -> BigMapAbsent + STOperation -> BigMapAbsent + STContract t -> case checkBigMapPresence t of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STPair a b -> case (checkBigMapPresence a, checkBigMapPresence b) of + (BigMapPresent, _) -> BigMapPresent + (_, BigMapPresent) -> BigMapPresent + (BigMapAbsent, BigMapAbsent) -> BigMapAbsent + STOr a b -> case (checkBigMapPresence a, checkBigMapPresence b) of + (BigMapPresent, _) -> BigMapPresent + (_, BigMapPresent) -> BigMapPresent + (BigMapAbsent, BigMapAbsent) -> BigMapAbsent + STLambda _ _ -> BigMapAbsent + STMap _ v -> case checkBigMapPresence v of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STBigMap _ _ -> + BigMapPresent + STInt -> BigMapAbsent + STNat -> BigMapAbsent + STString -> BigMapAbsent + STBytes -> BigMapAbsent + STMutez -> BigMapAbsent + STBool -> BigMapAbsent + STKeyHash -> BigMapAbsent + STTimestamp -> BigMapAbsent + STAddress -> BigMapAbsent + +-- | Check at runtime whether the given type contains 'TBigMap'. +checkNestedBigMapsPresence :: Sing (ty :: T) -> NestedBigMapsPresence ty +checkNestedBigMapsPresence = \case + -- More boilerplate to boilerplate god. + STKey -> NestedBigMapsAbsent + STSignature -> NestedBigMapsAbsent + STChainId -> NestedBigMapsAbsent + STUnit -> NestedBigMapsAbsent + STOption t -> case checkNestedBigMapsPresence t of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STList t -> case checkNestedBigMapsPresence t of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STSet _ -> NestedBigMapsAbsent + STOperation -> NestedBigMapsAbsent + STContract t -> case checkNestedBigMapsPresence t of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STPair a b -> case (checkNestedBigMapsPresence a, checkNestedBigMapsPresence b) of + (NestedBigMapsPresent, _) -> NestedBigMapsPresent + (_, NestedBigMapsPresent) -> NestedBigMapsPresent + (NestedBigMapsAbsent, NestedBigMapsAbsent) -> NestedBigMapsAbsent + STOr a b -> case (checkNestedBigMapsPresence a, checkNestedBigMapsPresence b) of + (NestedBigMapsPresent, _) -> NestedBigMapsPresent + (_, NestedBigMapsPresent) -> NestedBigMapsPresent + (NestedBigMapsAbsent, NestedBigMapsAbsent) -> NestedBigMapsAbsent + STLambda _ _ -> NestedBigMapsAbsent + STMap _ v -> case checkNestedBigMapsPresence v of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STBigMap _ v -> case checkBigMapPresence v of + BigMapPresent -> NestedBigMapsPresent + BigMapAbsent -> NestedBigMapsAbsent + STInt -> NestedBigMapsAbsent + STNat -> NestedBigMapsAbsent + STString -> NestedBigMapsAbsent + STBytes -> NestedBigMapsAbsent + STMutez -> NestedBigMapsAbsent + STBool -> NestedBigMapsAbsent + STKeyHash -> NestedBigMapsAbsent + STTimestamp -> NestedBigMapsAbsent + STAddress -> NestedBigMapsAbsent + +-- | Check at runtime that the given type does not contain 'TOperation'. +opAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoOp t) +opAbsense s = case checkOpPresence s of + OpPresent -> Nothing + OpAbsent -> Just Dict + +-- | Check at runtime that the given type does not contain 'TContract'. +contractTypeAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoContract t) +contractTypeAbsense s = case checkContractTypePresence s of + ContractPresent -> Nothing + ContractAbsent -> Just Dict + +-- | Check at runtime that the given type does not containt 'TBigMap' +bigMapAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoBigMap t) +bigMapAbsense s = case checkBigMapPresence s of + BigMapPresent -> Nothing + BigMapAbsent -> Just Dict + +-- | Check at runtime that the given type does not contain nested 'TBigMap' +nestedBigMapsAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoNestedBigMaps t) +nestedBigMapsAbsense s = case checkNestedBigMapsPresence s of + NestedBigMapsPresent -> Nothing + NestedBigMapsAbsent -> Just Dict + +---------------------------------------------------------------------------- +-- Scopes +---------------------------------------------------------------------------- + +data BadTypeForScope + = BtNotComparable + | BtIsOperation + | BtHasBigMap + | BtHasNestedBigMap + | BtHasContract + deriving stock (Show, Eq, Generic) + +-- | Alias for constraints which Michelson applies to parameter. +type ParameterScope t = + (Typeable t, SingI t, HasNoOp t, HasNoNestedBigMaps t) + +-- | Alias for constraints which Michelson applies to contract storage. +type StorageScope t = + (Typeable t, SingI t, HasNoOp t, HasNoNestedBigMaps t, HasNoContract t) + +-- | Alias for constraints which Michelson applies to pushed constants. +type ConstantScope t = + (SingI t, HasNoOp t, HasNoBigMap t, HasNoContract t) + +-- | Alias for constraints which Michelson applies to packed values. +type PackedValScope t = + (SingI t, HasNoOp t, HasNoBigMap t) + +-- | Alias for constraints which Michelson applies to unpacked values. +-- +-- It is different from 'PackedValScope', e.g. @contract@ type cannot appear +-- in a value we unpack to. +type UnpackedValScope t = + (PackedValScope t, ConstantScope t) + +-- | Alias for constraints which are required for printing. +type PrintedValScope t = (SingI t, HasNoOp t) + +---------------------------------------------------------------------------- +-- Conveniences +---------------------------------------------------------------------------- + +-- | Should be present for common scopes. +class CheckScope (c :: Constraint) where + -- | Check that constraint hold for a given type. + checkScope :: Either BadTypeForScope (Dict c) + +instance SingI t => CheckScope (HasNoOp t) where + checkScope = maybeToRight BtIsOperation $ opAbsense sing +instance SingI t => CheckScope (HasNoBigMap t) where + checkScope = maybeToRight BtHasBigMap $ bigMapAbsense sing +instance SingI t => CheckScope (HasNoNestedBigMaps t) where + checkScope = maybeToRight BtHasNestedBigMap $ nestedBigMapsAbsense sing +instance SingI t => CheckScope (HasNoContract t) where + checkScope = maybeToRight BtHasContract $ contractTypeAbsense sing + +instance (Typeable t, SingI t) => CheckScope (ParameterScope t) where + checkScope = + (\Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoNestedBigMaps t) + +instance (Typeable t, SingI t) => CheckScope (StorageScope t) where + checkScope = + (\Dict Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoNestedBigMaps t) + <*> checkScope @(HasNoContract t) + +instance (Typeable t, SingI t) => CheckScope (ConstantScope t) where + checkScope = + (\Dict Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoBigMap t) + <*> checkScope @(HasNoContract t) + +instance (Typeable t, SingI t) => CheckScope (PackedValScope t) where + checkScope = + (\Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoBigMap t) + +instance (Typeable t, SingI t) => CheckScope (UnpackedValScope t) where + checkScope = + (\Dict Dict -> Dict) + <$> checkScope @(PackedValScope t) + <*> checkScope @(ConstantScope t) + +-- Versions for eDSL +---------------------------------------------------------------------------- + +{- These constraints are supposed to be used only in eDSL code and eDSL should +define its own wrapers over it. +-} + +type ProperParameterBetterErrors t = + (Typeable t, SingI t, ForbidOp t, ForbidNestedBigMaps t) + +type ProperStorageBetterErrors t = + (Typeable t, SingI t, ForbidOp t, ForbidNestedBigMaps t, ForbidContract t) + +type ProperConstantBetterErrors t = + (SingI t, ForbidOp t, ForbidBigMap t, ForbidContract t) + +type ProperPackedValBetterErrors t = + (SingI t, ForbidOp t, ForbidBigMap t) + +type ProperUnpackedValBetterErrors t = + (ProperPackedValBetterErrors t, ProperConstantBetterErrors t) + +type ProperPrintedValBetterErrors t = + (SingI t, ForbidOp t) + +properParameterEvi :: forall t. ProperParameterBetterErrors t :- ParameterScope t +properParameterEvi = Sub $ + Dict \\ forbiddenOpEvi @t \\ forbiddenNestedBigMapsEvi @t + +properStorageEvi :: forall t. ProperStorageBetterErrors t :- StorageScope t +properStorageEvi = Sub $ + Dict \\ forbiddenOpEvi @t + \\ forbiddenContractTypeEvi @t + \\ forbiddenNestedBigMapsEvi @t + \\ forbiddenContractTypeEvi @t + +properConstantEvi :: forall t. ProperConstantBetterErrors t :- ConstantScope t +properConstantEvi = Sub $ + Dict \\ forbiddenOpEvi @t + \\ forbiddenBigMapEvi @t + \\ forbiddenContractTypeEvi @t + +properPackedValEvi :: forall t. ProperPackedValBetterErrors t :- PackedValScope t +properPackedValEvi = Sub $ + Dict \\ forbiddenOpEvi @t + \\ forbiddenBigMapEvi @t + +properUnpackedValEvi :: forall t. ProperUnpackedValBetterErrors t :- UnpackedValScope t +properUnpackedValEvi = properPackedValEvi @t *** properConstantEvi @t + +properPrintedValEvi :: forall t. ProperPrintedValBetterErrors t :- PrintedValScope t +properPrintedValEvi = Sub $ + Dict \\ forbiddenOpEvi @t ===================================== testsuite/tests/pmcheck/should_compile/all.T ===================================== @@ -120,6 +120,8 @@ test('T17977b', collect_compiler_stats('bytes allocated',10), compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T18049', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T18478', collect_compiler_stats('bytes allocated',10), compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) # Other tests test('pmc001', [], compile, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a59bd6c95b7c6481c09b727ffd59112b0e9f1593 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a59bd6c95b7c6481c09b727ffd59112b0e9f1593 You're receiving 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 Jul 20 12:37:22 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 20 Jul 2020 08:37:22 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] Address Takenobus observations! Message-ID: <5f159002e30c5_80b3f84901582f040923f4@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 65b942b0 by Moritz Angermann at 2020-07-20T12:37:09+00:00 Address Takenobus observations! Thanks! - - - - - 2 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -583,7 +583,7 @@ getRegister' config plat expr -- UBFM will set the high bits to 0. SBFM will copy the sign (sign extend). MO_UU_Conv from to -> return $ Any (intFormat to) (\dst -> code `snocOL` UBFM (OpReg (max from to) dst) (OpReg (max from to) reg) (OpImm (ImmInt 0)) (toImm (min from to))) MO_SS_Conv from to -> return $ Any (intFormat to) (\dst -> code `snocOL` SBFM (OpReg (max from to) dst) (OpReg (max from to) reg) (OpImm (ImmInt 0)) (toImm (min from to))) - MO_FF_Conv from to -> return $ Any (intFormat to) (\dst -> code `snocOL` FCVT (OpReg to dst) (OpReg from reg)) + MO_FF_Conv from to -> return $ Any (floatFormat to) (\dst -> code `snocOL` FCVT (OpReg to dst) (OpReg from reg)) -- Conversions MO_XX_Conv from to -> swizzleRegisterRep (intFormat to) <$> getRegister e ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -387,7 +387,7 @@ aarch64_mkLoadInstr config reg delta slot | (spillSlotToOffset config slot) - de where delta' = (spillSlotToOffset config slot) - delta aarch64_mkLoadInstr config reg delta slot | (spillSlotToOffset config slot) - delta < -4095 - = let (d, isns) = aarch64_mkLoadInstr config reg (delta - 4096) slot + = let (d, isns) = aarch64_mkLoadInstr config reg (delta - 4095) slot in (d, ADD sp sp (OpImm (ImmInt 4095)) : isns ++ [SUB sp sp (OpImm (ImmInt 4095))]) aarch64_mkLoadInstr config reg delta slot | (spillSlotToOffset config slot) - delta < -256 @@ -470,8 +470,8 @@ aarch64_mkStackDeallocInstr :: Platform -> Int -> [Instr] aarch64_mkStackDeallocInstr platform n | n == 0 = [] | n > 0 && n < 4096 = [ ADD sp sp (OpImm (ImmInt n)) ] - | n > 0 = ADD sp sp (OpImm (ImmInt 4095)) : aarch64_mkStackAllocInstr platform (n - 4095) -aarch64_mkStackDeallocInstr platform n = pprPanic "aarch64_mkStackAllocInstr" (int n) + | n > 0 = ADD sp sp (OpImm (ImmInt 4095)) : aarch64_mkStackDeallocInstr platform (n + 4095) +aarch64_mkStackDeallocInstr platform n = pprPanic "aarch64_mkStackDeallocInstr" (int n) -- -- See note [extra spill slots] in X86/Instr.hs View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65b942b00339f3eb7ba85d0d8dd8bf650f71c9b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65b942b00339f3eb7ba85d0d8dd8bf650f71c9b7 You're receiving 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 Jul 20 12:39:24 2020 From: gitlab at gitlab.haskell.org (Sylvain Henry) Date: Mon, 20 Jul 2020 08:39:24 -0400 Subject: [Git][ghc/ghc][wip/int64-everywhere] ghc-bignum: add support for Word64#/Int64# on 64-bit arch Message-ID: <5f15907cbbd6_80b3f849c40b20c409305f@gitlab.haskell.org.mail> Sylvain Henry pushed to branch wip/int64-everywhere at Glasgow Haskell Compiler / GHC Commits: 280b3843 by Sylvain Henry at 2020-07-20T14:38:08+02:00 ghc-bignum: add support for Word64#/Int64# on 64-bit arch - - - - - 2 changed files: - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs Changes: ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -254,23 +254,31 @@ bigNatToInt# a bigNatToInt :: BigNat# -> Int bigNatToInt bn = I# (bigNatToInt# bn) --- | Convert a Word64# into a BigNat on 32-bit architectures +-- | Convert a Word64# into a BigNat bigNatFromWord64# :: Word64# -> BigNat# +#if WORD_SIZE_IN_BITS == 32 bigNatFromWord64# w64 = bigNatFromWord2# wh# wl# where wh# = word64ToWord# (uncheckedShiftRL64# w64 32#) wl# = word64ToWord# w64 +#else +bigNatFromWord64# w64 = bigNatFromWord# (word64ToWord# w64) +#endif --- | Convert a BigNat into a Word64# on 32-bit architectures +-- | Convert a BigNat into a Word64# bigNatToWord64# :: BigNat# -> Word64# bigNatToWord64# b | bigNatIsZero b = wordToWord64# 0## +#if WORD_SIZE_IN_BITS == 32 | wl <- wordToWord64# (bigNatToWord# b) = if isTrue# (bigNatSize# b ># 1#) then let wh = wordToWord64# (bigNatIndex# b 1#) in uncheckedShiftL64# wh 32# `or64#` wl else wl +#else + | True = wordToWord64# (bigNatToWord# b) +#endif -- | Encode (# BigNat mantissa, Int# exponent #) into a Double# bigNatEncodeDouble# :: BigNat# -> Int# -> Double# ===================================== libraries/ghc-bignum/src/GHC/Num/Integer.hs ===================================== @@ -970,12 +970,12 @@ integerIsPowerOf2# (IS i) integerIsPowerOf2# (IN _) = (# () | #) integerIsPowerOf2# (IP w) = bigNatIsPowerOf2# w --- | Convert an Int64# into an Integer on 32-bit architectures +-- | Convert an Int64# into an Integer integerFromInt64# :: Int64# -> Integer {-# NOINLINE integerFromInt64# #-} integerFromInt64# !i - | isTrue# ((i `leInt64#` intToInt64# 0x7FFFFFFF#) - &&# (i `geInt64#` intToInt64# -0x80000000#)) + | isTrue# ((i `leInt64#` intToInt64# INT_MAXBOUND#) + &&# (i `geInt64#` intToInt64# INT_MINBOUND#)) = IS (int64ToInt# i) | isTrue# (i `geInt64#` intToInt64# 0#) @@ -984,23 +984,23 @@ integerFromInt64# !i | True = IN (bigNatFromWord64# (int64ToWord64# (negateInt64# i))) --- | Convert a Word64# into an Integer on 32-bit architectures +-- | Convert a Word64# into an Integer integerFromWord64# :: Word64# -> Integer {-# NOINLINE integerFromWord64# #-} integerFromWord64# !w - | isTrue# (w `leWord64#` wordToWord64# 0x7FFFFFFF##) + | isTrue# (w `leWord64#` wordToWord64# INT_MAXBOUND##) = IS (int64ToInt# (word64ToInt64# w)) | True = IP (bigNatFromWord64# w) --- | Convert an Integer into an Int64# on 32-bit architectures +-- | Convert an Integer into an Int64# integerToInt64# :: Integer -> Int64# {-# NOINLINE integerToInt64# #-} integerToInt64# (IS i) = intToInt64# i integerToInt64# (IP b) = word64ToInt64# (bigNatToWord64# b) integerToInt64# (IN b) = negateInt64# (word64ToInt64# (bigNatToWord64# b)) --- | Convert an Integer into a Word64# on 32-bit architectures +-- | Convert an Integer into a Word64# integerToWord64# :: Integer -> Word64# {-# NOINLINE integerToWord64# #-} integerToWord64# (IS i) = int64ToWord64# (intToInt64# i) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/280b3843169580261f3816cf182d204476d20b0c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/280b3843169580261f3816cf182d204476d20b0c You're receiving 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 Jul 20 12:53:25 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 20 Jul 2020 08:53:25 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] :sob: Message-ID: <5f1593c577fe6_80b1025102440947b4@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 46fba2c9 by Moritz Angermann at 2020-07-20T12:53:13+00:00 :sob: - - - - - 1 changed file: - compiler/GHC/CmmToAsm.hs Changes: ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -275,7 +275,7 @@ aarch64NcgImpl config ,pprNatCmmDecl = AArch64.Ppr.pprNatCmmDecl config ,maxSpillSlots = AArch64.Instr.maxSpillSlots config ,allocatableRegs = AArch64.Regs.allocatableRegs platform - ,ncgAllocMoreStack = AArch64.Instr.noAllocMoreStack + ,ncgAllocMoreStack = AArch64.Instr.allocMoreStack platform ,ncgExpandTop = id ,ncgMakeFarBranches = const id ,extractUnwindPoints = const [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46fba2c91e1c4d23d46fa2d9b18dcd000c80363d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46fba2c91e1c4d23d46fa2d9b18dcd000c80363d You're receiving 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 Jul 20 13:01:30 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 20 Jul 2020 09:01:30 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18458 Message-ID: <5f1595aaaa1ac_80b102510244097468@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T18458 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18458 You're receiving 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 Jul 20 13:37:11 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Mon, 20 Jul 2020 09:37:11 -0400 Subject: [Git][ghc/ghc][wip/T18478] Add regression test for #18478 Message-ID: <5f159e07552ab_80b3f8492541234410174a@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18478 at Glasgow Haskell Compiler / GHC Commits: 39a5ed5e by Sebastian Graf at 2020-07-20T15:37:00+02:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 2 changed files: - + testsuite/tests/pmcheck/should_compile/T18478.hs - testsuite/tests/pmcheck/should_compile/all.T Changes: ===================================== testsuite/tests/pmcheck/should_compile/T18478.hs ===================================== @@ -0,0 +1,951 @@ +{-# LANGUAGE UndecidableSuperClasses, FunctionalDependencies, RoleAnnotations, ExplicitNamespaces, TypeFamilies, RankNTypes, TypeApplications, LambdaCase, DerivingStrategies, ScopedTypeVariables, TypeOperators, DataKinds, PolyKinds, GADTs, TypeFamilyDependencies, ConstraintKinds, UndecidableInstances, TypeSynonymInstances, FlexibleInstances, DeriveGeneric, AllowAmbiguousTypes, StrictData #-} +{-# OPTIONS_GHC -Wno-redundant-constraints -fforce-recomp -Wincomplete-patterns #-} + +{- | Module, containing restrictions imposed by instruction or value scope. + +Michelson have multiple restrictions on values, examples: +* @operation@ type cannot appear in parameter. +* @big_map@ type cannot appear in @PUSH at -able constants. +* @contract@ type cannot appear in type we @UNPACK@ to. + +Thus we declare multiple "scopes" - constraints applied in corresponding +situations, for instance +* 'ParameterScope'; +* 'StorageScope'; +* 'ConstantScope'. + +Also we separate multiple "classes" of scope-related constraints. + +* 'ParameterScope' and similar ones are used within Michelson engine, +they are understandable by GHC but produce not very clarifying errors. + +* 'ProperParameterBetterErrors' and similar ones are middle-layer constraints, +they produce human-readable errors but GHC cannot make conclusions from them. +They are supposed to be used only by eDSLs to define their own high-level +constraints. + +* Lorentz and other eDSLs may declare their own constraints, in most cases +you should use them. For example see 'Lorentz.Constraints' module. + +-} + +module T18478 + ( -- * Scopes + ConstantScope + , StorageScope + , PackedValScope + , ParameterScope + , PrintedValScope + , UnpackedValScope + + , ProperParameterBetterErrors + , ProperStorageBetterErrors + , ProperConstantBetterErrors + , ProperPackedValBetterErrors + , ProperUnpackedValBetterErrors + , ProperPrintedValBetterErrors + + , properParameterEvi + , properStorageEvi + , properConstantEvi + , properPackedValEvi + , properUnpackedValEvi + , properPrintedValEvi + , (:-)(..) + + , BadTypeForScope (..) + , CheckScope (..) + + -- * Implementation internals + , HasNoBigMap + , HasNoNestedBigMaps + , HasNoOp + , HasNoContract + , ContainsBigMap + , ContainsNestedBigMaps + + , ForbidOp + , ForbidContract + , ForbidBigMap + , ForbidNestedBigMaps + , FailOnBigMapFound + , FailOnNestedBigMapsFound + , FailOnOperationFound + + , OpPresence (..) + , ContractPresence (..) + , BigMapPresence (..) + , NestedBigMapsPresence (..) + , checkOpPresence + , checkContractTypePresence + , checkBigMapPresence + , checkNestedBigMapsPresence + , opAbsense + , contractTypeAbsense + , bigMapAbsense + , nestedBigMapsAbsense + , forbiddenOp + , forbiddenContractType + , forbiddenBigMap + , forbiddenNestedBigMaps + + -- * Re-exports + , withDict + , SingI (..) + ) where + +import Data.Type.Bool (type (||)) +import Data.Type.Coercion +import GHC.TypeLits (ErrorMessage(..), TypeError) +import Data.Typeable +import GHC.Generics +import GHC.Exts +import Data.Kind + +data T = + TKey + | TUnit + | TSignature + | TChainId + | TOption T + | TList T + | TSet T + | TOperation + | TContract T + | TPair T T + | TOr T T + | TLambda T T + | TMap T T + | TBigMap T T + | TInt + | TNat + | TString + | TBytes + | TMutez + | TBool + | TKeyHash + | TTimestamp + | TAddress + deriving stock (Eq, Show) + +type family Sing :: k -> Type + +class SingI a where + sing :: Sing a + +class SingKind (k :: Type) where + -- | Get a base type from the promoted kind. For example, + -- @Demote Bool@ will be the type @Bool at . Rarely, the type and kind do not + -- match. For example, @Demote Nat@ is @Natural at . + type Demote k = (r :: Type) | r -> k + + -- | Convert a singleton to its unrefined version. + fromSing :: Sing (a :: k) -> Demote k + + -- | Convert an unrefined type to an existentially-quantified singleton type. + toSing :: Demote k -> SomeSing k + +data SomeSing (k :: Type) :: Type where + SomeSing :: Sing (a :: k) -> SomeSing k + + +-- | Instance of data family 'Sing' for 'T'. +-- Custom instance is implemented in order to inject 'Typeable' +-- constraint for some of constructors. +data SingT :: T -> Type where + STKey :: SingT 'TKey + STUnit :: SingT 'TUnit + STSignature :: SingT 'TSignature + STChainId :: SingT 'TChainId + STOption :: (SingI a, Typeable a) => Sing a -> SingT ( 'TOption a) + STList :: (SingI a, Typeable a) => Sing a -> SingT ( 'TList a ) + STSet :: (SingI a, Typeable a) => Sing a -> SingT ( 'TSet a ) + STOperation :: SingT 'TOperation + STContract :: (SingI a, Typeable a) + => Sing a -> SingT ( 'TContract a ) + STPair :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TPair a b) + STOr :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TOr a b) + STLambda :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TLambda a b) + STMap :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TMap a b) + STBigMap :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TBigMap a b) + STInt :: SingT 'TInt + STNat :: SingT 'TNat + STString :: SingT 'TString + STBytes :: SingT 'TBytes + STMutez :: SingT 'TMutez + STBool :: SingT 'TBool + STKeyHash :: SingT 'TKeyHash + STTimestamp :: SingT 'TTimestamp + STAddress :: SingT 'TAddress + +type instance Sing = SingT + +--------------------------------------------- +-- Singleton-related helpers for T +-------------------------------------------- + +-- | Version of 'SomeSing' with 'Typeable' constraint, +-- specialized for use with 'T' kind. +data SomeSingT where + SomeSingT :: forall (a :: T). (Typeable a, SingI a) + => Sing a -> SomeSingT + +-- | Version of 'withSomeSing' with 'Typeable' constraint +-- provided to processing function. +-- +-- Required for not to erase these useful constraints when doing +-- conversion from value of type 'T' to its singleton representation. +withSomeSingT + :: T + -> (forall (a :: T). (Typeable a, SingI a) => Sing a -> r) + -> r +withSomeSingT t f = (\(SomeSingT s) -> f s) (toSingT t) + +-- | Version of 'fromSing' specialized for use with +-- @data instance Sing :: T -> Type@ which requires 'Typeable' +-- constraint for some of its constructors +fromSingT :: Sing (a :: T) -> T +fromSingT = \case + STKey -> TKey + STUnit -> TUnit + STSignature -> TSignature + STChainId -> TChainId + STOption t -> TOption (fromSingT t) + STList t -> TList (fromSingT t) + STSet t -> TSet (fromSingT t) + STOperation -> TOperation + STContract t -> TContract (fromSingT t) + STPair a b -> TPair (fromSingT a) (fromSingT b) + STOr a b -> TOr (fromSingT a) (fromSingT b) + STLambda a b -> TLambda (fromSingT a) (fromSingT b) + STMap a b -> TMap (fromSingT a) (fromSingT b) + STBigMap a b -> TBigMap (fromSingT a) (fromSingT b) + STInt -> TInt + STNat -> TNat + STString -> TString + STBytes -> TBytes + STMutez -> TMutez + STBool -> TBool + STKeyHash -> TKeyHash + STTimestamp -> TTimestamp + STAddress -> TAddress + +-- | Version of 'toSing' which creates 'SomeSingT'. +toSingT :: T -> SomeSingT +toSingT = \case + TKey -> SomeSingT STKey + TUnit -> SomeSingT STUnit + TSignature -> SomeSingT STSignature + TChainId -> SomeSingT STChainId + TOption t -> withSomeSingT t $ \tSing -> SomeSingT $ STOption tSing + TList t -> withSomeSingT t $ \tSing -> SomeSingT $ STList tSing + TSet ct -> withSomeSingT ct $ \ctSing -> SomeSingT $ STSet ctSing + TOperation -> SomeSingT STOperation + TContract t -> withSomeSingT t $ \tSing -> SomeSingT $ STContract tSing + TPair l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STPair lSing rSing + TOr l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STOr lSing rSing + TLambda l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STLambda lSing rSing + TMap l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STMap lSing rSing + TBigMap l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STBigMap lSing rSing + TInt -> SomeSingT STInt + TNat -> SomeSingT STNat + TString -> SomeSingT STString + TBytes -> SomeSingT STBytes + TMutez -> SomeSingT STMutez + TBool -> SomeSingT STBool + TKeyHash -> SomeSingT STKeyHash + TTimestamp -> SomeSingT STTimestamp + TAddress -> SomeSingT STAddress + +instance SingKind T where + type Demote T = T + fromSing = fromSingT + toSing t = case toSingT t of SomeSingT s -> SomeSing s + +instance SingI 'TKey where + sing = STKey +instance SingI 'TUnit where + sing = STUnit +instance SingI 'TSignature where + sing = STSignature +instance SingI 'TChainId where + sing = STChainId +instance (SingI a, Typeable a) => SingI ( 'TOption (a :: T)) where + sing = STOption sing +instance (SingI a, Typeable a) => SingI ( 'TList (a :: T)) where + sing = STList sing +instance (SingI a, Typeable a) => SingI ( 'TSet (a :: T)) where + sing = STSet sing +instance SingI 'TOperation where + sing = STOperation +instance (SingI a, Typeable a) => + SingI ( 'TContract (a :: T)) where + sing = STContract sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TPair a b) where + sing = STPair sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TOr a b) where + sing = STOr sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TLambda a b) where + sing = STLambda sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TMap a b) where + sing = STMap sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TBigMap a b) where + sing = STBigMap sing sing +instance SingI 'TInt where + sing = STInt +instance SingI 'TNat where + sing = STNat +instance SingI 'TString where + sing = STString +instance SingI 'TBytes where + sing = STBytes +instance SingI 'TMutez where + sing = STMutez +instance SingI 'TBool where + sing = STBool +instance SingI 'TKeyHash where + sing = STKeyHash +instance SingI 'TTimestamp where + sing = STTimestamp +instance SingI 'TAddress where + sing = STAddress + +data Dict :: Constraint -> Type where + Dict :: a => Dict a + deriving Typeable + +withDict :: HasDict c e => e -> (c => r) -> r +withDict d r = case evidence d of + Dict -> r + +class HasDict c e | e -> c where + evidence :: e -> Dict c + +instance HasDict a (Dict a) where + evidence = Prelude.id + +instance a => HasDict b (a :- b) where + evidence (Sub x) = x + +instance HasDict (Coercible a b) (Coercion a b) where + evidence Coercion = Dict + +instance HasDict (a ~ b) (a :~: b) where + evidence Refl = Dict + +infixl 1 \\ -- required comment + +(\\) :: HasDict c e => (c => r) -> e -> r +r \\ d = withDict d r +infixr 9 :- +newtype a :- b = Sub (a => Dict b) + deriving Typeable +type role (:-) nominal nominal +(***) :: (a :- b) -> (c :- d) -> (a, c) :- (b, d) +f *** g = Sub $ Dict \\ f \\ g + +type f $ a = f a +infixr 2 $ + +maybeToRight a Nothing = Left a +maybeToRight _ (Just a) = Right a + +---------------------------------------------------------------------------- +-- Constraints +---------------------------------------------------------------------------- +-- | Whether this type contains 'TOperation' type. +-- +-- In some scopes (constants, parameters, storage) appearing for operation type +-- is prohibited. +-- Operations in input/output of lambdas are allowed without limits though. +type family ContainsOp (t :: T) :: Bool where + ContainsOp 'TKey = 'False + ContainsOp 'TUnit = 'False + ContainsOp 'TSignature = 'False + ContainsOp 'TChainId = 'False + ContainsOp ('TOption t) = ContainsOp t + ContainsOp ('TList t) = ContainsOp t + ContainsOp ('TSet t) = ContainsOp t + ContainsOp 'TOperation = 'True + ContainsOp ('TContract t) = ContainsOp t + ContainsOp ('TPair a b) = ContainsOp a || ContainsOp b + ContainsOp ('TOr a b) = ContainsOp a || ContainsOp b + ContainsOp ('TLambda _ _) = 'False + ContainsOp ('TMap k v) = ContainsOp k || ContainsOp v + ContainsOp ('TBigMap k v) = ContainsOp k || ContainsOp v + ContainsOp _ = 'False + +-- | Whether this type contains 'TContract' type. +-- +-- In some scopes (constants, storage) appearing for contract type +-- is prohibited. +-- Contracts in input/output of lambdas are allowed without limits though. +type family ContainsContract (t :: T) :: Bool where + ContainsContract 'TKey = 'False + ContainsContract 'TUnit = 'False + ContainsContract 'TSignature = 'False + ContainsContract 'TChainId = 'False + ContainsContract ('TOption t) = ContainsContract t + ContainsContract ('TList t) = ContainsContract t + ContainsContract ('TSet _) = 'False + ContainsContract 'TOperation = 'False + ContainsContract ('TContract _) = 'True + ContainsContract ('TPair a b) = ContainsContract a || ContainsContract b + ContainsContract ('TOr a b) = ContainsContract a || ContainsContract b + ContainsContract ('TLambda _ _) = 'False + ContainsContract ('TMap _ v) = ContainsContract v + ContainsContract ('TBigMap _ v) = ContainsContract v + ContainsContract _ = 'False + +-- | Whether this type contains 'TBigMap' type. +type family ContainsBigMap (t :: T) :: Bool where + ContainsBigMap 'TKey = 'False + ContainsBigMap 'TUnit = 'False + ContainsBigMap 'TSignature = 'False + ContainsBigMap 'TChainId = 'False + ContainsBigMap ('TOption t) = ContainsBigMap t + ContainsBigMap ('TList t) = ContainsBigMap t + ContainsBigMap ('TSet _) = 'False + ContainsBigMap 'TOperation = 'False + ContainsBigMap ('TContract t) = ContainsBigMap t + ContainsBigMap ('TPair a b) = ContainsBigMap a || ContainsBigMap b + ContainsBigMap ('TOr a b) = ContainsBigMap a || ContainsBigMap b + ContainsBigMap ('TLambda _ _) = 'False + ContainsBigMap ('TMap _ v) = ContainsBigMap v + ContainsBigMap ('TBigMap _ _) = 'True + ContainsBigMap _ = 'False + +-- | Whether this type contains a type with nested 'TBigMap's . +-- +-- Nested big_maps (i.e. big_map which contains another big_map inside of it's value type). Are +-- prohibited in all contexts. Some context such as PUSH, APPLY, PACK/UNPACK instructions are more +-- strict because they doesn't work with big_map at all. +type family ContainsNestedBigMaps (t :: T) :: Bool where + ContainsNestedBigMaps 'TKey = 'False + ContainsNestedBigMaps 'TUnit = 'False + ContainsNestedBigMaps 'TSignature = 'False + ContainsNestedBigMaps 'TChainId = 'False + ContainsNestedBigMaps ('TOption t) = ContainsNestedBigMaps t + ContainsNestedBigMaps ('TList t) = ContainsNestedBigMaps t + ContainsNestedBigMaps ('TSet _) = 'False + ContainsNestedBigMaps 'TOperation = 'False + ContainsNestedBigMaps ('TContract t) = ContainsNestedBigMaps t + ContainsNestedBigMaps ('TPair a b) = ContainsNestedBigMaps a || ContainsNestedBigMaps b + ContainsNestedBigMaps ('TOr a b) = ContainsNestedBigMaps a || ContainsNestedBigMaps b + ContainsNestedBigMaps ('TLambda _ _) = 'False + ContainsNestedBigMaps ('TMap _ v) = ContainsNestedBigMaps v + ContainsNestedBigMaps ('TBigMap _ v) = ContainsBigMap v + ContainsNestedBigMaps _ = 'False + +-- | Constraint which ensures that operation type does not appear in a given type. +-- +-- Not just a type alias in order to be able to partially apply it +-- (e.g. in 'Each'). +class (ContainsOp t ~ 'False) => HasNoOp t +instance (ContainsOp t ~ 'False) => HasNoOp t + +-- | Constraint which ensures that contract type does not appear in a given type. +class (ContainsContract t ~ 'False) => HasNoContract t +instance (ContainsContract t ~ 'False) => HasNoContract t + +-- | Constraint which ensures that bigmap does not appear in a given type. +class (ContainsBigMap t ~ 'False) => HasNoBigMap t +instance (ContainsBigMap t ~ 'False) => HasNoBigMap t + +-- | Constraint which ensures that there are no nested bigmaps. +class (ContainsNestedBigMaps t ~ 'False) => HasNoNestedBigMaps t +instance (ContainsNestedBigMaps t ~ 'False) => HasNoNestedBigMaps t + +-- | Report a human-readable error about 'TOperation' at a wrong place. +type family FailOnOperationFound (enabled :: Bool) :: Constraint where + FailOnOperationFound 'True = + TypeError ('Text "Operations are not allowed in this scope") + FailOnOperationFound 'False = () + +-- | Report a human-readable error about 'TContract' at a wrong place. +type family FailOnContractFound (enabled :: Bool) :: Constraint where + FailOnContractFound 'True = + TypeError ('Text "Type `contract` is not allowed in this scope") + FailOnContractFound 'False = () + +-- | Report a human-readable error about 'TBigMap' at a wrong place. +type family FailOnBigMapFound (enabled :: Bool) :: Constraint where + FailOnBigMapFound 'True = + TypeError ('Text "BigMaps are not allowed in this scope") + FailOnBigMapFound 'False = () + +-- | Report a human-readable error that 'TBigMap' contains another 'TBigMap' +type family FailOnNestedBigMapsFound (enabled :: Bool) :: Constraint where + FailOnNestedBigMapsFound 'True = + TypeError ('Text "Nested BigMaps are not allowed") + FailOnNestedBigMapsFound 'False = () + +-- | This is like 'HasNoOp', it raises a more human-readable error +-- when @t@ type is concrete, but GHC cannot make any conclusions +-- from such constraint as it can for 'HasNoOp'. +-- Though, hopefully, it will someday: +-- . +-- +-- Use this constraint in our eDSL. +type ForbidOp t = FailOnOperationFound (ContainsOp t) + +type ForbidContract t = FailOnContractFound (ContainsContract t) + +type ForbidBigMap t = FailOnBigMapFound (ContainsBigMap t) + +type ForbidNestedBigMaps t = FailOnNestedBigMapsFound (ContainsNestedBigMaps t) + +-- | Evidence of that 'HasNoOp' is deducable from 'ForbidOp'. +forbiddenOpEvi :: forall t. (SingI t, ForbidOp t) :- HasNoOp t +forbiddenOpEvi = Sub $ + -- It's not clear now to proof GHC that @HasNoOp t@ is implication of + -- @ForbidOp t@, so we use @error@ below and also disable + -- "-Wredundant-constraints" extension. + case checkOpPresence (sing @t) of + OpAbsent -> Dict + OpPresent -> error "impossible" + +-- | Reify 'HasNoOp' contraint from 'ForbidOp'. +-- +-- Left for backward compatibility. +forbiddenOp + :: forall t a. + (SingI t, ForbidOp t) + => (HasNoOp t => a) + -> a +forbiddenOp = withDict $ forbiddenOpEvi @t + +forbiddenBigMapEvi :: forall t. (SingI t, ForbidBigMap t) :- HasNoBigMap t +forbiddenBigMapEvi = Sub $ + case checkBigMapPresence (sing @t) of + BigMapAbsent -> Dict + BigMapPresent -> error "impossible" + +forbiddenNestedBigMapsEvi :: forall t. (SingI t, ForbidNestedBigMaps t) :- HasNoNestedBigMaps t +forbiddenNestedBigMapsEvi = Sub $ + case checkNestedBigMapsPresence (sing @t) of + NestedBigMapsAbsent -> Dict + NestedBigMapsPresent -> error "impossible" + +forbiddenBigMap + :: forall t a. + (SingI t, ForbidBigMap t) + => (HasNoBigMap t => a) + -> a +forbiddenBigMap = withDict $ forbiddenBigMapEvi @t + +forbiddenNestedBigMaps + :: forall t a. + (SingI t, ForbidNestedBigMaps t) + => (HasNoNestedBigMaps t => a) + -> a +forbiddenNestedBigMaps = withDict $ forbiddenNestedBigMapsEvi @t + +-- | Reify 'HasNoContract' contraint from 'ForbidContract'. +forbiddenContractTypeEvi + :: forall t. (SingI t, ForbidContract t) :- HasNoContract t +forbiddenContractTypeEvi = Sub $ + case checkContractTypePresence (sing @t) of + ContractAbsent -> Dict + ContractPresent -> error "impossible" + +-- | Reify 'HasNoContract' contraint from 'ForbidContract'. +forbiddenContractType + :: forall t a. + (SingI t, ForbidContract t) + => (HasNoContract t => a) + -> a +forbiddenContractType = withDict $ forbiddenContractTypeEvi @t + +-- | Whether the type contains 'TOperation', with proof. +data OpPresence (t :: T) + = ContainsOp t ~ 'True => OpPresent + | ContainsOp t ~ 'False => OpAbsent + +data ContractPresence (t :: T) + = ContainsContract t ~ 'True => ContractPresent + | ContainsContract t ~ 'False => ContractAbsent + +data BigMapPresence (t :: T) + = ContainsBigMap t ~ 'True => BigMapPresent + | ContainsBigMap t ~ 'False => BigMapAbsent + +data NestedBigMapsPresence (t :: T) + = ContainsNestedBigMaps t ~ 'True => NestedBigMapsPresent + | ContainsNestedBigMaps t ~ 'False => NestedBigMapsAbsent + +-- @rvem: IMO, generalization of OpPresence and BigMapPresence to +-- TPresence is not worth it, due to the fact that +-- it will require more boilerplate in checkTPresence implementation +-- than it is already done in checkOpPresence and checkBigMapPresence + +-- | Check at runtime whether the given type contains 'TOperation'. +checkOpPresence :: Sing (ty :: T) -> OpPresence ty +checkOpPresence = \case + -- This is a sad amount of boilerplate, but at least + -- there is no chance to make a mistake in it. + -- We can't do in a simpler way while requiring only @Sing ty@ / @SingI ty@, + -- and a more complex constraint would be too unpleasant and confusing to + -- propagate everywhere. + STKey -> OpAbsent + STSignature -> OpAbsent + STChainId -> OpAbsent + STUnit -> OpAbsent + STOption t -> case checkOpPresence t of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STList t -> case checkOpPresence t of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STSet a -> case checkOpPresence a of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STOperation -> OpPresent + STContract t -> case checkOpPresence t of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STPair a b -> case (checkOpPresence a, checkOpPresence b) of + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + (OpAbsent, OpAbsent) -> OpAbsent + STOr a b -> case (checkOpPresence a, checkOpPresence b) of + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + (OpAbsent, OpAbsent) -> OpAbsent + STLambda _ _ -> OpAbsent + STMap k v -> case (checkOpPresence k, checkOpPresence v) of + (OpAbsent, OpAbsent) -> OpAbsent + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + STBigMap k v -> case (checkOpPresence k, checkOpPresence v) of + (OpAbsent, OpAbsent) -> OpAbsent + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + STInt -> OpAbsent + STNat -> OpAbsent + STString -> OpAbsent + STBytes -> OpAbsent + STMutez -> OpAbsent + STBool -> OpAbsent + STKeyHash -> OpAbsent + STTimestamp -> OpAbsent + STAddress -> OpAbsent + +-- | Check at runtime whether the given type contains 'TContract'. +checkContractTypePresence :: Sing (ty :: T) -> ContractPresence ty +checkContractTypePresence = \case + STKey -> ContractAbsent + STSignature -> ContractAbsent + STChainId -> ContractAbsent + STUnit -> ContractAbsent + STOption t -> case checkContractTypePresence t of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STList t -> case checkContractTypePresence t of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STSet _ -> ContractAbsent + STOperation -> ContractAbsent + STContract _ -> ContractPresent + STPair a b -> case (checkContractTypePresence a, checkContractTypePresence b) of + (ContractPresent, _) -> ContractPresent + (_, ContractPresent) -> ContractPresent + (ContractAbsent, ContractAbsent) -> ContractAbsent + STOr a b -> case (checkContractTypePresence a, checkContractTypePresence b) of + (ContractPresent, _) -> ContractPresent + (_, ContractPresent) -> ContractPresent + (ContractAbsent, ContractAbsent) -> ContractAbsent + STLambda _ _ -> ContractAbsent + STMap _ v -> case checkContractTypePresence v of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STBigMap _ v -> case checkContractTypePresence v of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STInt -> ContractAbsent + STNat -> ContractAbsent + STString -> ContractAbsent + STBytes -> ContractAbsent + STMutez -> ContractAbsent + STBool -> ContractAbsent + STKeyHash -> ContractAbsent + STTimestamp -> ContractAbsent + STAddress -> ContractAbsent + +-- | Check at runtime whether the given type contains 'TBigMap'. +checkBigMapPresence :: Sing (ty :: T) -> BigMapPresence ty +checkBigMapPresence = \case + -- More boilerplate to boilerplate god. + STKey -> BigMapAbsent + STSignature -> BigMapAbsent + STChainId -> BigMapAbsent + STUnit -> BigMapAbsent + STOption t -> case checkBigMapPresence t of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STList t -> case checkBigMapPresence t of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STSet _ -> BigMapAbsent + STOperation -> BigMapAbsent + STContract t -> case checkBigMapPresence t of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STPair a b -> case (checkBigMapPresence a, checkBigMapPresence b) of + (BigMapPresent, _) -> BigMapPresent + (_, BigMapPresent) -> BigMapPresent + (BigMapAbsent, BigMapAbsent) -> BigMapAbsent + STOr a b -> case (checkBigMapPresence a, checkBigMapPresence b) of + (BigMapPresent, _) -> BigMapPresent + (_, BigMapPresent) -> BigMapPresent + (BigMapAbsent, BigMapAbsent) -> BigMapAbsent + STLambda _ _ -> BigMapAbsent + STMap _ v -> case checkBigMapPresence v of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STBigMap _ _ -> + BigMapPresent + STInt -> BigMapAbsent + STNat -> BigMapAbsent + STString -> BigMapAbsent + STBytes -> BigMapAbsent + STMutez -> BigMapAbsent + STBool -> BigMapAbsent + STKeyHash -> BigMapAbsent + STTimestamp -> BigMapAbsent + STAddress -> BigMapAbsent + +-- | Check at runtime whether the given type contains 'TBigMap'. +checkNestedBigMapsPresence :: Sing (ty :: T) -> NestedBigMapsPresence ty +checkNestedBigMapsPresence = \case + -- More boilerplate to boilerplate god. + STKey -> NestedBigMapsAbsent + STSignature -> NestedBigMapsAbsent + STChainId -> NestedBigMapsAbsent + STUnit -> NestedBigMapsAbsent + STOption t -> case checkNestedBigMapsPresence t of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STList t -> case checkNestedBigMapsPresence t of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STSet _ -> NestedBigMapsAbsent + STOperation -> NestedBigMapsAbsent + STContract t -> case checkNestedBigMapsPresence t of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STPair a b -> case (checkNestedBigMapsPresence a, checkNestedBigMapsPresence b) of + (NestedBigMapsPresent, _) -> NestedBigMapsPresent + (_, NestedBigMapsPresent) -> NestedBigMapsPresent + (NestedBigMapsAbsent, NestedBigMapsAbsent) -> NestedBigMapsAbsent + STOr a b -> case (checkNestedBigMapsPresence a, checkNestedBigMapsPresence b) of + (NestedBigMapsPresent, _) -> NestedBigMapsPresent + (_, NestedBigMapsPresent) -> NestedBigMapsPresent + (NestedBigMapsAbsent, NestedBigMapsAbsent) -> NestedBigMapsAbsent + STLambda _ _ -> NestedBigMapsAbsent + STMap _ v -> case checkNestedBigMapsPresence v of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STBigMap _ v -> case checkBigMapPresence v of + BigMapPresent -> NestedBigMapsPresent + BigMapAbsent -> NestedBigMapsAbsent + STInt -> NestedBigMapsAbsent + STNat -> NestedBigMapsAbsent + STString -> NestedBigMapsAbsent + STBytes -> NestedBigMapsAbsent + STMutez -> NestedBigMapsAbsent + STBool -> NestedBigMapsAbsent + STKeyHash -> NestedBigMapsAbsent + STTimestamp -> NestedBigMapsAbsent + STAddress -> NestedBigMapsAbsent + +-- | Check at runtime that the given type does not contain 'TOperation'. +opAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoOp t) +opAbsense s = case checkOpPresence s of + OpPresent -> Nothing + OpAbsent -> Just Dict + +-- | Check at runtime that the given type does not contain 'TContract'. +contractTypeAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoContract t) +contractTypeAbsense s = case checkContractTypePresence s of + ContractPresent -> Nothing + ContractAbsent -> Just Dict + +-- | Check at runtime that the given type does not containt 'TBigMap' +bigMapAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoBigMap t) +bigMapAbsense s = case checkBigMapPresence s of + BigMapPresent -> Nothing + BigMapAbsent -> Just Dict + +-- | Check at runtime that the given type does not contain nested 'TBigMap' +nestedBigMapsAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoNestedBigMaps t) +nestedBigMapsAbsense s = case checkNestedBigMapsPresence s of + NestedBigMapsPresent -> Nothing + NestedBigMapsAbsent -> Just Dict + +---------------------------------------------------------------------------- +-- Scopes +---------------------------------------------------------------------------- + +data BadTypeForScope + = BtNotComparable + | BtIsOperation + | BtHasBigMap + | BtHasNestedBigMap + | BtHasContract + deriving stock (Show, Eq, Generic) + +-- | Alias for constraints which Michelson applies to parameter. +type ParameterScope t = + (Typeable t, SingI t, HasNoOp t, HasNoNestedBigMaps t) + +-- | Alias for constraints which Michelson applies to contract storage. +type StorageScope t = + (Typeable t, SingI t, HasNoOp t, HasNoNestedBigMaps t, HasNoContract t) + +-- | Alias for constraints which Michelson applies to pushed constants. +type ConstantScope t = + (SingI t, HasNoOp t, HasNoBigMap t, HasNoContract t) + +-- | Alias for constraints which Michelson applies to packed values. +type PackedValScope t = + (SingI t, HasNoOp t, HasNoBigMap t) + +-- | Alias for constraints which Michelson applies to unpacked values. +-- +-- It is different from 'PackedValScope', e.g. @contract@ type cannot appear +-- in a value we unpack to. +type UnpackedValScope t = + (PackedValScope t, ConstantScope t) + +-- | Alias for constraints which are required for printing. +type PrintedValScope t = (SingI t, HasNoOp t) + +---------------------------------------------------------------------------- +-- Conveniences +---------------------------------------------------------------------------- + +-- | Should be present for common scopes. +class CheckScope (c :: Constraint) where + -- | Check that constraint hold for a given type. + checkScope :: Either BadTypeForScope (Dict c) + +instance SingI t => CheckScope (HasNoOp t) where + checkScope = maybeToRight BtIsOperation $ opAbsense sing +instance SingI t => CheckScope (HasNoBigMap t) where + checkScope = maybeToRight BtHasBigMap $ bigMapAbsense sing +instance SingI t => CheckScope (HasNoNestedBigMaps t) where + checkScope = maybeToRight BtHasNestedBigMap $ nestedBigMapsAbsense sing +instance SingI t => CheckScope (HasNoContract t) where + checkScope = maybeToRight BtHasContract $ contractTypeAbsense sing + +instance (Typeable t, SingI t) => CheckScope (ParameterScope t) where + checkScope = + (\Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoNestedBigMaps t) + +instance (Typeable t, SingI t) => CheckScope (StorageScope t) where + checkScope = + (\Dict Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoNestedBigMaps t) + <*> checkScope @(HasNoContract t) + +instance (Typeable t, SingI t) => CheckScope (ConstantScope t) where + checkScope = + (\Dict Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoBigMap t) + <*> checkScope @(HasNoContract t) + +instance (Typeable t, SingI t) => CheckScope (PackedValScope t) where + checkScope = + (\Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoBigMap t) + +instance (Typeable t, SingI t) => CheckScope (UnpackedValScope t) where + checkScope = + (\Dict Dict -> Dict) + <$> checkScope @(PackedValScope t) + <*> checkScope @(ConstantScope t) + +-- Versions for eDSL +---------------------------------------------------------------------------- + +{- These constraints are supposed to be used only in eDSL code and eDSL should +define its own wrapers over it. +-} + +type ProperParameterBetterErrors t = + (Typeable t, SingI t, ForbidOp t, ForbidNestedBigMaps t) + +type ProperStorageBetterErrors t = + (Typeable t, SingI t, ForbidOp t, ForbidNestedBigMaps t, ForbidContract t) + +type ProperConstantBetterErrors t = + (SingI t, ForbidOp t, ForbidBigMap t, ForbidContract t) + +type ProperPackedValBetterErrors t = + (SingI t, ForbidOp t, ForbidBigMap t) + +type ProperUnpackedValBetterErrors t = + (ProperPackedValBetterErrors t, ProperConstantBetterErrors t) + +type ProperPrintedValBetterErrors t = + (SingI t, ForbidOp t) + +properParameterEvi :: forall t. ProperParameterBetterErrors t :- ParameterScope t +properParameterEvi = Sub $ + Dict \\ forbiddenOpEvi @t \\ forbiddenNestedBigMapsEvi @t + +properStorageEvi :: forall t. ProperStorageBetterErrors t :- StorageScope t +properStorageEvi = Sub $ + Dict \\ forbiddenOpEvi @t + \\ forbiddenContractTypeEvi @t + \\ forbiddenNestedBigMapsEvi @t + \\ forbiddenContractTypeEvi @t + +properConstantEvi :: forall t. ProperConstantBetterErrors t :- ConstantScope t +properConstantEvi = Sub $ + Dict \\ forbiddenOpEvi @t + \\ forbiddenBigMapEvi @t + \\ forbiddenContractTypeEvi @t + +properPackedValEvi :: forall t. ProperPackedValBetterErrors t :- PackedValScope t +properPackedValEvi = Sub $ + Dict \\ forbiddenOpEvi @t + \\ forbiddenBigMapEvi @t + +properUnpackedValEvi :: forall t. ProperUnpackedValBetterErrors t :- UnpackedValScope t +properUnpackedValEvi = properPackedValEvi @t *** properConstantEvi @t + +properPrintedValEvi :: forall t. ProperPrintedValBetterErrors t :- PrintedValScope t +properPrintedValEvi = Sub $ + Dict \\ forbiddenOpEvi @t ===================================== testsuite/tests/pmcheck/should_compile/all.T ===================================== @@ -120,6 +120,8 @@ test('T17977b', collect_compiler_stats('bytes allocated',10), compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T18049', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T18478', collect_compiler_stats('bytes allocated',10), compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) # Other tests test('pmc001', [], compile, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39a5ed5e2fb0cf042365814a03822491e61af463 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39a5ed5e2fb0cf042365814a03822491e61af463 You're receiving 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 Jul 20 14:20:39 2020 From: gitlab at gitlab.haskell.org (Sylvain Henry) Date: Mon, 20 Jul 2020 10:20:39 -0400 Subject: [Git][ghc/ghc][wip/int64-everywhere] 159 commits: hadrian: add flag to skip rebuilding dependency information #17636 Message-ID: <5f15a837a435_80b114037a4411230@gitlab.haskell.org.mail> Sylvain Henry pushed to branch wip/int64-everywhere at Glasgow Haskell Compiler / GHC Commits: 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 840bbfc3 by John Ericson at 2020-07-20T14:39:40+02:00 Make fixed-size `Int32#` and `Int64#` The boxed Int64 uses Int64#, but Int32# still uses Int#. The 32-bit case is less pressing to change because it is not a source of brittle CPP---it is the same thing on all platforms. We need Int64/Word64 constant folding to avoid the let/app restriction on Core, so that is implemented now. 32-bit constant unfolding and 32-bit literals are left as follow-up. This is the bulk of #11953 - - - - - d6574966 by John Ericson at 2020-07-20T14:39:40+02:00 Inline INT64 and WORD64 macros in primops.txt.pp The definition is now unconditional so there is no reason for that CPP. - - - - - 0298108e by Sylvain Henry at 2020-07-20T14:39:40+02:00 ghc-bignum: add support for Word64#/Int64# on 64-bit arch - - - - - f20f7005 by Sylvain Henry at 2020-07-20T16:19:03+02:00 Fix fingerprint Core generation - - - - - 7889c584 by Sylvain Henry at 2020-07-20T16:19:23+02:00 Fix some tests - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - Makefile - compiler/GHC/Builtin/Names.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/280b3843169580261f3816cf182d204476d20b0c...7889c584da61dd9da81e7df24d54fd8855e8ee68 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/280b3843169580261f3816cf182d204476d20b0c...7889c584da61dd9da81e7df24d54fd8855e8ee68 You're receiving 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 Jul 20 15:27:26 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 20 Jul 2020 11:27:26 -0400 Subject: [Git][ghc/ghc][wip/T18451] 11 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f15b7de4bfc7_80b3f84925412344131054@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18451 at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 1388b52c by Simon Peyton Jones at 2020-07-20T16:26:26+01:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0320af67bacdbd7917b5d901d5a1b02266b793fb...1388b52c7edc7588c28f41a1e5f707be950ab6a9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0320af67bacdbd7917b5d901d5a1b02266b793fb...1388b52c7edc7588c28f41a1e5f707be950ab6a9 You're receiving 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 Jul 20 15:55:04 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 20 Jul 2020 11:55:04 -0400 Subject: [Git][ghc/ghc][wip/andreask/remove_dict_field_flag] 11 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f15be5858a8b_80b3f849248fe084153073@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/andreask/remove_dict_field_flag at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 7cdd38a7 by Andreas Klebinger at 2020-07-20T11:55:02-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/108105f03ebdb3942cf4a064dad801424451cb3f...7cdd38a7d542d6a9c42198df13aa2fb9f02d3e9b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/108105f03ebdb3942cf4a064dad801424451cb3f...7cdd38a7d542d6a9c42198df13aa2fb9f02d3e9b You're receiving 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 Jul 20 16:39:46 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 20 Jul 2020 12:39:46 -0400 Subject: [Git][ghc/ghc][wip/T18126] 12 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f15c8d2a6529_80b3f849254123441668b1@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - ed8c31bc by Simon Peyton Jones at 2020-07-20T17:39:12+01:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) point (2) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - c846d4a0 by Simon Peyton Jones at 2020-07-20T17:39:12+01:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typeecheck/polykinds/T16245a - - - - - 28 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Hole.hs - + compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Default.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e11af031e4312450b14f35f531a19699cb0120b1...c846d4a0bff54bdd58fb1f188d0001eeddf96369 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e11af031e4312450b14f35f531a19699cb0120b1...c846d4a0bff54bdd58fb1f188d0001eeddf96369 You're receiving 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 Jul 20 17:20:31 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Mon, 20 Jul 2020 13:20:31 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] Run prof_info test only in prof_ways (#18405) Message-ID: <5f15d25f9b538_80b3f849c40b20c4169471@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: ba3bed40 by Sven Tennie at 2020-07-20T19:20:18+02:00 Run prof_info test only in prof_ways (#18405) That's the required way for collecting PROFILING data (e.g. CostCentres). - - - - - 1 changed file: - libraries/ghc-heap/tests/all.T Changes: ===================================== libraries/ghc-heap/tests/all.T ===================================== @@ -54,7 +54,7 @@ test('prof_info', [extra_files(['create_tso.c','create_tso.h']), ignore_stdout, ignore_stderr, -# TODO: What about this? -# only_ways(prof_ways) + extra_ways(['prof']), + only_ways(prof_ways) ], - multi_compile_and_run, ['prof_info', [('create_tso.c','-optc=-g -opta=-g')], '-prof -debug -fprof-auto']) + multi_compile_and_run, ['prof_info', [('create_tso.c','-optc=-g -opta=-g')], '-prof']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ba3bed407d9e7d57b937c015ed022b808f63f33d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ba3bed407d9e7d57b937c015ed022b808f63f33d You're receiving 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 Jul 20 19:36:59 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 20 Jul 2020 15:36:59 -0400 Subject: [Git][ghc/ghc][wip/T18126] 2 commits: Implement Quick Look impredicativity Message-ID: <5f15f25b86ac4_80b102510244188330@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: 5e0a1a60 by Simon Peyton Jones at 2020-07-20T20:36:35+01:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) point (2) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 8cf7b275 by Simon Peyton Jones at 2020-07-20T20:36:35+01:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typeecheck/polykinds/T16245a - - - - - 18 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Hole.hs - + compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Default.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c846d4a0bff54bdd58fb1f188d0001eeddf96369...8cf7b275dc21c0f96c31e8348c1777b769d30766 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c846d4a0bff54bdd58fb1f188d0001eeddf96369...8cf7b275dc21c0f96c31e8348c1777b769d30766 You're receiving 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 Jul 20 19:48:04 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 20 Jul 2020 15:48:04 -0400 Subject: [Git][ghc/ghc][wip/T18126] 2 commits: Implement Quick Look impredicativity Message-ID: <5f15f4f4b8338_80b3f849254123441896a5@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: ecde8584 by Simon Peyton Jones at 2020-07-20T20:47:07+01:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) point (2) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 91c68504 by Simon Peyton Jones at 2020-07-20T20:47:07+01:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typeecheck/polykinds/T16245a - - - - - 18 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Hole.hs - + compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Default.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8cf7b275dc21c0f96c31e8348c1777b769d30766...91c6850416ea62b7685b88c1d1655afcf4aee4e6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8cf7b275dc21c0f96c31e8348c1777b769d30766...91c6850416ea62b7685b88c1d1655afcf4aee4e6 You're receiving 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 Jul 20 22:37:46 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 20 Jul 2020 18:37:46 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Use a newtype `Code` for the return type of typed quotations (Proposal #195) Message-ID: <5f161cbac697_80bd68a9b8419655f@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 21cd7709 by Matthew Pickering at 2020-07-20T18:37:43-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 2201250a by Moritz Angermann at 2020-07-20T18:37:44-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 6b47534d by Moritz Angermann at 2020-07-20T18:37:44-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 00f2aa19 by Moritz Angermann at 2020-07-20T18:37:44-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - d114cd47 by Moritz Angermann at 2020-07-20T18:37:44-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Splice.hs - docs/users_guide/exts/deriving_extra.rst - docs/users_guide/exts/template_haskell.rst - libraries/template-haskell/Language/Haskell/TH.hs - + libraries/template-haskell/Language/Haskell/TH/CodeDo.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - libraries/template-haskell/template-haskell.cabal.in - libraries/text - rts/RtsSymbols.c - testsuite/tests/deriving/should_compile/drv-empty-data.stderr - testsuite/tests/parser/should_compile/Proposal229f_instances.hs - testsuite/tests/partial-sigs/should_compile/TypedSplice.hs - testsuite/tests/partial-sigs/should_compile/TypedSplice.stderr - testsuite/tests/quotes/T17857.hs - testsuite/tests/th/T10945.stderr - testsuite/tests/th/T11452.stderr - testsuite/tests/th/T15471A.hs - testsuite/tests/th/T15843.hs - testsuite/tests/th/T16195A.hs - testsuite/tests/th/T18121.hs - testsuite/tests/th/T8577.stderr - testsuite/tests/th/T8577a.hs - testsuite/tests/th/TH_StringLift.hs - testsuite/tests/th/TH_reifyLocalDefs.hs - testsuite/tests/th/overloaded/T17839.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c26e81d116a653b5259aeb290fb1e697efe3382a...d114cd4737b90cf4152662df008ec443955f19b5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c26e81d116a653b5259aeb290fb1e697efe3382a...d114cd4737b90cf4152662df008ec443955f19b5 You're receiving 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 Jul 20 23:58:21 2020 From: gitlab at gitlab.haskell.org (Brandon Chinn) Date: Mon, 20 Jul 2020 19:58:21 -0400 Subject: [Git][ghc/ghc][wip/T16341] 2 commits: Pass inst_tys to more stock-deriving generation functions Message-ID: <5f162f9ddf556_80b1025102442046e2@gitlab.haskell.org.mail> Brandon Chinn pushed to branch wip/T16341 at Glasgow Haskell Compiler / GHC Commits: 1d2a829b by Brandon Chinn at 2020-07-20T16:00:51-07:00 Pass inst_tys to more stock-deriving generation functions - - - - - 130146ce by Brandon Chinn at 2020-07-20T16:04:12-07:00 Filter out unreachable constructors when deriving stock instances (#16341) - - - - - 2 changed files: - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs Changes: ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -212,14 +212,20 @@ for the instance decl, which it probably wasn't, so the decls produced don't get through the typechecker. -} -gen_Eq_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Eq_binds loc tycon = do +gen_Eq_binds :: SrcSpan + -> TyCon + -> Type -- ^ The type being derived + -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Eq_binds loc tycon ty = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon return (method_binds con2tag_RDR, aux_binds con2tag_RDR) where - all_cons = tyConDataCons tycon + filterImpossibleDataCons = case splitTyConApp_maybe ty of + Just (_, inst_tys) -> filter (not . dataConCannotMatch inst_tys) + _ -> id + all_cons = filterImpossibleDataCons $ tyConDataCons tycon (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon all_cons -- If there are ten or more (arbitrary number) nullary constructors, @@ -396,8 +402,11 @@ gtResult OrdGE = true_Expr gtResult OrdGT = true_Expr ------------ -gen_Ord_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ord_binds loc tycon = do +gen_Ord_binds :: SrcSpan + -> TyCon + -> Type -- ^ The type being derived + -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ord_binds loc tycon ty = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon @@ -432,7 +441,10 @@ gen_Ord_binds loc tycon = do -- We want *zero-based* tags, because that's what -- con2Tag returns (generated by untag_Expr)! - tycon_data_cons = tyConDataCons tycon + filterImpossibleDataCons = case splitTyConApp_maybe ty of + Just (_, inst_tys) -> filter (not . dataConCannotMatch inst_tys) + _ -> id + tycon_data_cons = filterImpossibleDataCons $ tyConDataCons tycon single_con_type = isSingleton tycon_data_cons (first_con : _) = tycon_data_cons (last_con : _) = reverse tycon_data_cons @@ -646,8 +658,11 @@ instance ... Enum (Foo ...) where For @enumFromTo@ and @enumFromThenTo@, we use the default methods. -} -gen_Enum_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Enum_binds loc tycon = do +gen_Enum_binds :: SrcSpan + -> TyCon + -> Type -- ^ The type being derived + -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Enum_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -825,9 +840,12 @@ we follow the scheme given in Figure~19 of the Haskell~1.2 report (p.~147). -} -gen_Ix_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ix_binds :: SrcSpan + -> TyCon + -> Type -- ^ The type being derived + -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ix_binds loc tycon = do +gen_Ix_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -1028,10 +1046,13 @@ These instances are also useful for Read (Either Int Emp), where we want to be able to parse (Left 3) just fine. -} -gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Read_binds :: (Name -> Fixity) + -> SrcSpan + -> TyCon + -> Type -- ^ The type being derived -> (LHsBinds GhcPs, BagDerivStuff) -gen_Read_binds get_fixity loc tycon +gen_Read_binds get_fixity loc tycon ty = (listToBag [read_prec, default_readlist, default_readlistprec], emptyBag) where ----------------------------------------------------------------------- @@ -1042,7 +1063,10 @@ gen_Read_binds get_fixity loc tycon = mkHsVarBind loc readListPrec_RDR (nlHsVar readListPrecDefault_RDR) ----------------------------------------------------------------------- - data_cons = tyConDataCons tycon + filterImpossibleDataCons = case splitTyConApp_maybe ty of + Just (_, inst_tys) -> filter (not . dataConCannotMatch inst_tys) + _ -> id + data_cons = filterImpossibleDataCons $ tyConDataCons tycon (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon data_cons read_prec = mkHsVarBind loc readPrec_RDR rhs @@ -1212,13 +1236,19 @@ Example -- the most tightly-binding operator -} -gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Show_binds :: (Name -> Fixity) + -> SrcSpan + -> TyCon + -> Type -- ^ The type being derived -> (LHsBinds GhcPs, BagDerivStuff) -gen_Show_binds get_fixity loc tycon +gen_Show_binds get_fixity loc tycon ty = (unitBag shows_prec, emptyBag) where - data_cons = tyConDataCons tycon + filterImpossibleDataCons = case splitTyConApp_maybe ty of + Just (_, inst_tys) -> filter (not . dataConCannotMatch inst_tys) + _ -> id + data_cons = filterImpossibleDataCons $ tyConDataCons tycon shows_prec = mkFunBindEC 2 loc showsPrec_RDR id (map pats_etc data_cons) comma_space = nlHsVar showCommaSpace_RDR @@ -1385,9 +1415,10 @@ we generate gen_Data_binds :: SrcSpan -> TyCon -- For data families, this is the -- *representation* TyCon + -> Type -- ^ The type being derived -> TcM (LHsBinds GhcPs, -- The method bindings BagDerivStuff) -- Auxiliary bindings -gen_Data_binds loc rep_tc +gen_Data_binds loc rep_tc ty = do { -- See Note [Auxiliary binders] dataT_RDR <- new_dataT_rdr_name loc rep_tc ; dataC_RDRs <- traverse (new_dataC_rdr_name loc) data_cons @@ -1403,7 +1434,10 @@ gen_Data_binds loc rep_tc data_cons dataC_RDRs ) ) } where - data_cons = tyConDataCons rep_tc + filterImpossibleDataCons = case splitTyConApp_maybe ty of + Just (_, inst_tys) -> filter (not . dataConCannotMatch inst_tys) + _ -> id + data_cons = filterImpossibleDataCons $ tyConDataCons rep_tc n_cons = length data_cons one_constr = n_cons == 1 ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -595,13 +595,23 @@ hasStockDeriving clas -- do is allocate new Uniques, which are used for generating the names of -- auxiliary bindings. -- See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate. - simpleM gen_fn loc tc _ - = do { (binds, deriv_stuff) <- gen_fn loc tc + simpleM gen_fn loc tc inst_tys + = do { let inst_ty = case inst_tys of + [ty] -> ty + -- should not happen, since simpleM is only derived for + -- classes with a single type parameter + _ -> pprPanic "hasStockDeriving.simpleM" (ppr inst_tys) + ; (binds, deriv_stuff) <- gen_fn loc tc inst_ty ; return (binds, deriv_stuff, []) } - read_or_show gen_fn loc tc _ - = do { fix_env <- getDataConFixityFun tc - ; let (binds, deriv_stuff) = gen_fn fix_env loc tc + read_or_show gen_fn loc tc inst_tys + = do { let inst_ty = case inst_tys of + [ty] -> ty + -- should not happen, since Read and Show only have a + -- single type parameter + _ -> pprPanic "hasStockDeriving.read_or_show" (ppr inst_tys) + ; fix_env <- getDataConFixityFun tc + ; let (binds, deriv_stuff) = gen_fn fix_env loc tc inst_ty field_names = all_field_names tc ; return (binds, deriv_stuff, field_names) } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/41c5d721a14671474f8f76ccb15f37d1ac0e2289...130146cec83f1e1ba1ba695081e21f4de827e64f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/41c5d721a14671474f8f76ccb15f37d1ac0e2289...130146cec83f1e1ba1ba695081e21f4de827e64f You're receiving 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 Jul 20 23:59:43 2020 From: gitlab at gitlab.haskell.org (Brandon Chinn) Date: Mon, 20 Jul 2020 19:59:43 -0400 Subject: [Git][ghc/ghc][wip/T16341] 3 commits: Add regression test for #16341 Message-ID: <5f162fef8a20b_80b114037a442048da@gitlab.haskell.org.mail> Brandon Chinn pushed to branch wip/T16341 at Glasgow Haskell Compiler / GHC Commits: d9da1e86 by Brandon Chinn at 2020-07-20T16:59:29-07:00 Add regression test for #16341 - - - - - c6a411ae by Brandon Chinn at 2020-07-20T16:59:35-07:00 Pass inst_tys to more stock-deriving generation functions - - - - - fd5e1083 by Brandon Chinn at 2020-07-20T16:59:35-07:00 Filter out unreachable constructors when deriving stock instances (#16341) - - - - - 4 changed files: - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - + testsuite/tests/deriving/should_compile/T16341.hs - testsuite/tests/deriving/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -212,14 +212,20 @@ for the instance decl, which it probably wasn't, so the decls produced don't get through the typechecker. -} -gen_Eq_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Eq_binds loc tycon = do +gen_Eq_binds :: SrcSpan + -> TyCon + -> Type -- ^ The type being derived + -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Eq_binds loc tycon ty = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon return (method_binds con2tag_RDR, aux_binds con2tag_RDR) where - all_cons = tyConDataCons tycon + filterImpossibleDataCons = case splitTyConApp_maybe ty of + Just (_, inst_tys) -> filter (not . dataConCannotMatch inst_tys) + _ -> id + all_cons = filterImpossibleDataCons $ tyConDataCons tycon (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon all_cons -- If there are ten or more (arbitrary number) nullary constructors, @@ -396,8 +402,11 @@ gtResult OrdGE = true_Expr gtResult OrdGT = true_Expr ------------ -gen_Ord_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ord_binds loc tycon = do +gen_Ord_binds :: SrcSpan + -> TyCon + -> Type -- ^ The type being derived + -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ord_binds loc tycon ty = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon @@ -432,7 +441,10 @@ gen_Ord_binds loc tycon = do -- We want *zero-based* tags, because that's what -- con2Tag returns (generated by untag_Expr)! - tycon_data_cons = tyConDataCons tycon + filterImpossibleDataCons = case splitTyConApp_maybe ty of + Just (_, inst_tys) -> filter (not . dataConCannotMatch inst_tys) + _ -> id + tycon_data_cons = filterImpossibleDataCons $ tyConDataCons tycon single_con_type = isSingleton tycon_data_cons (first_con : _) = tycon_data_cons (last_con : _) = reverse tycon_data_cons @@ -646,8 +658,11 @@ instance ... Enum (Foo ...) where For @enumFromTo@ and @enumFromThenTo@, we use the default methods. -} -gen_Enum_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Enum_binds loc tycon = do +gen_Enum_binds :: SrcSpan + -> TyCon + -> Type -- ^ The type being derived + -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Enum_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -825,9 +840,12 @@ we follow the scheme given in Figure~19 of the Haskell~1.2 report (p.~147). -} -gen_Ix_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ix_binds :: SrcSpan + -> TyCon + -> Type -- ^ The type being derived + -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ix_binds loc tycon = do +gen_Ix_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -1028,10 +1046,13 @@ These instances are also useful for Read (Either Int Emp), where we want to be able to parse (Left 3) just fine. -} -gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Read_binds :: (Name -> Fixity) + -> SrcSpan + -> TyCon + -> Type -- ^ The type being derived -> (LHsBinds GhcPs, BagDerivStuff) -gen_Read_binds get_fixity loc tycon +gen_Read_binds get_fixity loc tycon ty = (listToBag [read_prec, default_readlist, default_readlistprec], emptyBag) where ----------------------------------------------------------------------- @@ -1042,7 +1063,10 @@ gen_Read_binds get_fixity loc tycon = mkHsVarBind loc readListPrec_RDR (nlHsVar readListPrecDefault_RDR) ----------------------------------------------------------------------- - data_cons = tyConDataCons tycon + filterImpossibleDataCons = case splitTyConApp_maybe ty of + Just (_, inst_tys) -> filter (not . dataConCannotMatch inst_tys) + _ -> id + data_cons = filterImpossibleDataCons $ tyConDataCons tycon (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon data_cons read_prec = mkHsVarBind loc readPrec_RDR rhs @@ -1212,13 +1236,19 @@ Example -- the most tightly-binding operator -} -gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Show_binds :: (Name -> Fixity) + -> SrcSpan + -> TyCon + -> Type -- ^ The type being derived -> (LHsBinds GhcPs, BagDerivStuff) -gen_Show_binds get_fixity loc tycon +gen_Show_binds get_fixity loc tycon ty = (unitBag shows_prec, emptyBag) where - data_cons = tyConDataCons tycon + filterImpossibleDataCons = case splitTyConApp_maybe ty of + Just (_, inst_tys) -> filter (not . dataConCannotMatch inst_tys) + _ -> id + data_cons = filterImpossibleDataCons $ tyConDataCons tycon shows_prec = mkFunBindEC 2 loc showsPrec_RDR id (map pats_etc data_cons) comma_space = nlHsVar showCommaSpace_RDR @@ -1385,9 +1415,10 @@ we generate gen_Data_binds :: SrcSpan -> TyCon -- For data families, this is the -- *representation* TyCon + -> Type -- ^ The type being derived -> TcM (LHsBinds GhcPs, -- The method bindings BagDerivStuff) -- Auxiliary bindings -gen_Data_binds loc rep_tc +gen_Data_binds loc rep_tc ty = do { -- See Note [Auxiliary binders] dataT_RDR <- new_dataT_rdr_name loc rep_tc ; dataC_RDRs <- traverse (new_dataC_rdr_name loc) data_cons @@ -1403,7 +1434,10 @@ gen_Data_binds loc rep_tc data_cons dataC_RDRs ) ) } where - data_cons = tyConDataCons rep_tc + filterImpossibleDataCons = case splitTyConApp_maybe ty of + Just (_, inst_tys) -> filter (not . dataConCannotMatch inst_tys) + _ -> id + data_cons = filterImpossibleDataCons $ tyConDataCons rep_tc n_cons = length data_cons one_constr = n_cons == 1 ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -595,13 +595,23 @@ hasStockDeriving clas -- do is allocate new Uniques, which are used for generating the names of -- auxiliary bindings. -- See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate. - simpleM gen_fn loc tc _ - = do { (binds, deriv_stuff) <- gen_fn loc tc + simpleM gen_fn loc tc inst_tys + = do { let inst_ty = case inst_tys of + [ty] -> ty + -- should not happen, since simpleM is only derived for + -- classes with a single type parameter + _ -> pprPanic "hasStockDeriving.simpleM" (ppr inst_tys) + ; (binds, deriv_stuff) <- gen_fn loc tc inst_ty ; return (binds, deriv_stuff, []) } - read_or_show gen_fn loc tc _ - = do { fix_env <- getDataConFixityFun tc - ; let (binds, deriv_stuff) = gen_fn fix_env loc tc + read_or_show gen_fn loc tc inst_tys + = do { let inst_ty = case inst_tys of + [ty] -> ty + -- should not happen, since Read and Show only have a + -- single type parameter + _ -> pprPanic "hasStockDeriving.read_or_show" (ppr inst_tys) + ; fix_env <- getDataConFixityFun tc + ; let (binds, deriv_stuff) = gen_fn fix_env loc tc inst_ty field_names = all_field_names tc ; return (binds, deriv_stuff, field_names) } ===================================== testsuite/tests/deriving/should_compile/T16341.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE StandaloneDeriving #-} + +module T16341 where + +import Data.Data (Data) +import Data.Ix (Ix) + +data Foo a where + X :: Foo Int + Y :: (Bool -> Bool) -> Foo Bool + +-- These instances should work whether or not `Y` is a constructor in +-- `Foo`, because the `Foo Int` designation precludes `Y` from being +-- a reachable constructor +deriving instance Show (Foo Int) +deriving instance Read (Foo Int) +deriving instance Eq (Foo Int) +deriving instance Ord (Foo Int) +deriving instance Ix (Foo Int) +deriving instance Data (Foo Int) ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -118,6 +118,7 @@ test('T15398', normal, compile, ['']) test('T15637', normal, compile, ['']) test('T15831', normal, compile, ['']) test('T16179', normal, compile, ['']) +test('T16341', normal, compile, ['']) test('T16518', normal, compile, ['']) test('T17324', normal, compile, ['']) test('T17339', normal, compile, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/130146cec83f1e1ba1ba695081e21f4de827e64f...fd5e1083d65d9259ab9c389b3404f5a60a55a5bc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/130146cec83f1e1ba1ba695081e21f4de827e64f...fd5e1083d65d9259ab9c389b3404f5a60a55a5bc You're receiving 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 Jul 21 00:22:09 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Mon, 20 Jul 2020 20:22:09 -0400 Subject: [Git][ghc/ghc][wip/T18470] 11 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f1635312bdd1_80b3f849c40b20c42080ee@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18470 at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 67302db1 by Ryan Scott at 2020-07-20T20:19:29-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/791e5887b4fef96e11780de9b96b9ce60dcccb61...67302db115045321d31951a8afe9136440de1e58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/791e5887b4fef96e11780de9b96b9ce60dcccb61...67302db115045321d31951a8afe9136440de1e58 You're receiving 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 Jul 21 01:03:39 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Mon, 20 Jul 2020 21:03:39 -0400 Subject: [Git][ghc/ghc][wip/T18432-T18455] 11 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f163eeb9b133_80b3f849c40b20c42126f8@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18432-T18455 at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - a939e8cf by Ryan Scott at 2020-07-20T21:03:12-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/360112d81e46d1d4bee280b281ce6742bc0db205...a939e8cf4c60b3edbe0dcc5b5d47c68d36e75ade -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/360112d81e46d1d4bee280b281ce6742bc0db205...a939e8cf4c60b3edbe0dcc5b5d47c68d36e75ade You're receiving 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 Jul 21 03:50:37 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 20 Jul 2020 23:50:37 -0400 Subject: [Git][ghc/ghc][master] 4 commits: Revert "AArch32 symbols only on aarch32." Message-ID: <5f16660d6d81e_80b3f849248fe08422601f@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 1 changed file: - rts/RtsSymbols.c Changes: ===================================== rts/RtsSymbols.c ===================================== @@ -59,6 +59,7 @@ SymI_HasProto(signal_handlers) \ SymI_HasProto(stg_sig_install) \ SymI_HasProto(rtsTimerSignal) \ + SymI_HasProto(atexit) \ SymI_NeedsDataProto(nocldstop) #endif @@ -993,213 +994,29 @@ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS + // 64-bit support functions in libgcc.a -// See https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc -#define RTS_LIBGCC_SYMBOLS_32 \ - SymI_NeedsProto(__fixunsdfdi) \ - /* 4 The GCC low-level runtime library */\ - /* 4.1.1 Arithmetic functions */\ - /* SymI_NeedsProto(__ashlsi3) */\ - SymI_NeedsProto(__ashldi3) \ - /* SymI_NeedsProto(__ashlti3) */\ - /* These functions return the result of shifting a left by b bits. */\ - /* SymI_NeedsProto(__ashrsi3) */\ - SymI_NeedsProto(__ashrdi3) \ - /* SymI_NeedsProto(__ashrti3) */\ - /* These functions return the result of arithmetically shifting a right by b bits. */\ - /* SymI_NeedsProto(__divsi3) */\ - SymI_NeedsProto(__divdi3) \ - /* SymI_NeedsProto(__divti3) */\ - /* These functions return the quotient of the signed division of a and b. */\ - /* SymI_NeedsProto(__lshrsi3) */ \ - SymI_NeedsProto(__lshrdi3) \ - /* SymI_NeedsProto(__lshrti3) */ \ - /* These functions return the result of logically shifting a right by b bits. */\ - /* SymI_NeedsProto(__modsi3) */ \ - SymI_NeedsProto(__moddi3) \ - /* SymI_NeedsProto(__modti3) */ \ - /* These functions return the remainder of the signed division of a and b. */\ - /* SymI_NeedsProto(__mulsi3) */ \ - SymI_NeedsProto(__muldi3) \ - /* SymI_NeedsProto(__multi3) */ \ - /* These functions return the product of a and b. */\ - SymI_NeedsProto(__negdi2) \ - /* SymI_NeedsProto(__negti2) */ \ - /* These functions return the negation of a. */\ - /* SymI_NeedsProto(__udivsi3) */ \ - SymI_NeedsProto(__udivdi3) \ - /* SymI_NeedsProto(__udivti3) */ \ - /* These functions return the quotient of the unsigned division of a and b. */\ - SymI_NeedsProto(__udivmoddi4) \ - /* SymI_NeedsProto(__udivmodti4) */ \ - /* These functions calculate both the quotient and remainder of the unsigned division of a and b. The return value is the quotient, and the remainder is placed in variable pointed to by c. */\ - /* SymI_NeedsProto(__umodsi3) */ \ - SymI_NeedsProto(__umoddi3) \ - /* SymI_NeedsProto(__umodti3) */ \ - /* These functions return the remainder of the unsigned division of a and b. */\ - /* 4.1.2 Comparison functions */\ - /* The following functions implement integral comparisons. These functions implement a low-level compare, upon which the higher level comparison operators (such as less than and greater than or equal to) can be constructed. The returned values lie in the range zero to two, to allow the high-level operators to be implemented by testing the returned result using either signed or unsigned comparison. */\ - SymI_NeedsProto(__cmpdi2) \ - /* SymI_NeedsProto(__cmpti2) */ \ - /* These functions perform a signed comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\ - SymI_NeedsProto(__ucmpdi2) \ - /* SymI_NeedsProto(__ucmpti2) */ \ - /* These functions perform an unsigned comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\ - /* 4.1.3 Trapping arithmetic functions */\ - /* The following functions implement trapping arithmetic. These functions call the libc function abort upon signed arithmetic overflow. */\ - SymI_NeedsProto(__absvsi2) \ - SymI_NeedsProto(__absvdi2) \ - /* These functions return the absolute value of a. */\ - /* SymI_NeedsProto(__addvsi3) */ \ - SymI_NeedsProto(__addvdi3) \ - /* These functions return the sum of a and b; that is a + b. */\ - /* SymI_NeedsProto(__mulvsi3) */ \ - SymI_NeedsProto(__mulvdi3) \ - /* The functions return the product of a and b; that is a * b. */\ - SymI_NeedsProto(__negvsi2) \ - SymI_NeedsProto(__negvdi2) \ - /* These functions return the negation of a; that is -a. */\ - /* SymI_NeedsProto(__subvsi3) */ \ - SymI_NeedsProto(__subvdi3) \ - /* These functions return the difference between b and a; that is a - b. */\ - /* 4.1.4 Bit operations */\ - SymI_NeedsProto(__clzsi2) \ - SymI_NeedsProto(__clzdi2) \ - /* SymI_NeedsProto(__clzti2) */ \ - /* These functions return the number of leading 0-bits in a, starting at the most significant bit position. If a is zero, the result is undefined. */\ - SymI_NeedsProto(__ctzsi2) \ - SymI_NeedsProto(__ctzdi2) \ - /* SymI_NeedsProto(__ctzti2) */ \ - /* These functions return the number of trailing 0-bits in a, starting at the least significant bit position. If a is zero, the result is undefined. */\ - SymI_NeedsProto(__ffsdi2) \ - /* SymI_NeedsProto(__ffsti2) */ \ - /* These functions return the index of the least significant 1-bit in a, or the value zero if a is zero. The least significant bit is index one. */\ - SymI_NeedsProto(__paritysi2) \ - SymI_NeedsProto(__paritydi2) \ - /* SymI_NeedsProto(__parityti2) */\ - /* These functions return the value zero if the number of bits set in a is even, and the value one otherwise. */\ - SymI_NeedsProto(__popcountsi2) \ - SymI_NeedsProto(__popcountdi2) \ - /* SymI_NeedsProto(__popcountti2) */ \ - /* These functions return the number of bits set in a. */\ - SymI_NeedsProto(__bswapsi2) \ - SymI_NeedsProto(__bswapdi2) -#define RTS_LIBGCC_SYMBOLS_aarch32 \ - /* armv6l */\ - /* TODO: should check for __ARM_EABI__ */\ - SymI_NeedsProto(__aeabi_d2f) \ - SymI_NeedsProto(__aeabi_d2iz) \ - SymI_NeedsProto(__aeabi_d2lz) \ - SymI_NeedsProto(__aeabi_d2uiz) \ - SymI_NeedsProto(__aeabi_d2ulz) \ - SymI_NeedsProto(__aeabi_dadd) \ - SymI_NeedsProto(__aeabi_dcmpeq) \ - SymI_NeedsProto(__aeabi_dcmpge) \ - SymI_NeedsProto(__aeabi_dcmpgt) \ - SymI_NeedsProto(__aeabi_dcmple) \ - SymI_NeedsProto(__aeabi_dcmplt) \ - SymI_NeedsProto(__aeabi_dcmpun) \ - SymI_NeedsProto(__aeabi_ddiv) \ - SymI_NeedsProto(__aeabi_dmul) \ - SymI_NeedsProto(__aeabi_dneg) \ - SymI_NeedsProto(__aeabi_dsub) \ - SymI_NeedsProto(__aeabi_f2d) \ - SymI_NeedsProto(__aeabi_f2iz) \ - SymI_NeedsProto(__aeabi_f2lz) \ - SymI_NeedsProto(__aeabi_f2uiz) \ - SymI_NeedsProto(__aeabi_f2ulz) \ - SymI_NeedsProto(__aeabi_fadd) \ - SymI_NeedsProto(__aeabi_fcmpeq) \ - SymI_NeedsProto(__aeabi_fcmpge) \ - SymI_NeedsProto(__aeabi_fcmpgt) \ - SymI_NeedsProto(__aeabi_fcmple) \ - SymI_NeedsProto(__aeabi_fcmplt) \ - SymI_NeedsProto(__aeabi_fcmpun) \ - SymI_NeedsProto(__aeabi_fdiv) \ - SymI_NeedsProto(__aeabi_fmul) \ - SymI_NeedsProto(__aeabi_fneg) \ - SymI_NeedsProto(__aeabi_fsub) \ - SymI_NeedsProto(__aeabi_i2d) \ - SymI_NeedsProto(__aeabi_i2f) \ - SymI_NeedsProto(__aeabi_idiv) \ - SymI_NeedsProto(__aeabi_idivmod) \ - SymI_NeedsProto(__aeabi_l2d) \ - SymI_NeedsProto(__aeabi_l2f) \ - SymI_NeedsProto(__aeabi_lasr) \ - SymI_NeedsProto(__aeabi_lcmp) \ - SymI_NeedsProto(__aeabi_ldivmod) \ - SymI_NeedsProto(__aeabi_llsl) \ - SymI_NeedsProto(__aeabi_llsr) \ - SymI_NeedsProto(__aeabi_lmul) \ - SymI_NeedsProto(__aeabi_ui2d) \ - SymI_NeedsProto(__aeabi_ui2f) \ - SymI_NeedsProto(__aeabi_uidiv) \ - SymI_NeedsProto(__aeabi_uidivmod) \ - SymI_NeedsProto(__aeabi_ul2d) \ - SymI_NeedsProto(__aeabi_ul2f) \ - SymI_NeedsProto(__aeabi_ulcmp) \ - SymI_NeedsProto(__aeabi_uldivmod) -#define RTS_LIBGCC_SYMBOLS_64 \ +#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) +#define RTS_LIBGCC_SYMBOLS \ + SymI_NeedsProto(__divdi3) \ + SymI_NeedsProto(__udivdi3) \ + SymI_NeedsProto(__moddi3) \ + SymI_NeedsProto(__umoddi3) \ + SymI_NeedsProto(__muldi3) \ + SymI_NeedsProto(__ashldi3) \ + SymI_NeedsProto(__ashrdi3) \ + SymI_NeedsProto(__lshrdi3) \ + SymI_NeedsProto(__fixunsdfdi) +#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 +#define RTS_LIBGCC_SYMBOLS \ SymI_NeedsProto(__udivti3) \ SymI_NeedsProto(__umodti3) - -/* for aarch64 */ -#define RTS_LIBGCC_SYMBOLS_aarch64 \ - SymI_NeedsProto(__netf2) \ - SymI_NeedsProto(__addtf3) \ - SymI_NeedsProto(__subtf3) \ - SymI_NeedsProto(__multf3) \ - SymI_NeedsProto(__extenddftf2) \ - SymI_NeedsProto(__fixtfsi) \ - SymI_NeedsProto(__fixunstfsi) \ - SymI_NeedsProto(__floatsitf) \ - SymI_NeedsProto(__floatunsitf) - -#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && defined(arm_HOST_OS) -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 RTS_LIBGCC_SYMBOLS_aarch32 -#elif defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 -#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 && defined(aarch64_HOST_OS) -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 RTS_LIBGCC_SYMBOLS_aarch64 -#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 #else #define RTS_LIBGCC_SYMBOLS #endif -#if !defined(mingw32_HOST_OS) && !defined(DYNAMIC) && (defined(_FORTIFY_SOURCE) || defined(__SSP__)) -#define RTS_SSP_SYMBOLS \ - SymI_NeedsProto(__stack_chk_guard) \ - SymI_NeedsProto(__stack_chk_fail) -#else -#define RTS_SSP_SYMBOLS -#endif -#if !defined(DYNAMIC) && defined(linux_HOST_OS) -// we need these for static musl builds. However when -// linking shared objects (DLLs) this will fail, hence -// we do not include them when building with -DDYNAMIC -#define RTS_LINKER_SYMBOLS \ - SymI_NeedsProto(__fini_array_start) \ - SymI_NeedsProto(__fini_array_end) -#else -#define RTS_LINKER_SYMBOLS -#endif - -#if defined(darwin_HOST_OS) && defined(powerpc_HOST_ARCH) - // Symbols that don't have a leading underscore - // on Mac OS X. They have to receive special treatment, - // see machoInitSymbolsWithoutUnderscore() -#define RTS_MACHO_NOUNDERLINE_SYMBOLS \ - SymI_NeedsProto(saveFP) \ - SymI_NeedsProto(restFP) -#endif - /* entirely bogus claims about types of these symbols */ -/* to prevent a bit of define expansion, SymI_NeedsProto is a variadic - * macro. And we'll concat vvv with the __VA_ARGS__. This prevents - * vvv from getting macro expanded. - */ -#define SymI_NeedsProto(vvv,...) extern void vvv ## __VA_ARGS__ (void); +#define SymI_NeedsProto(vvv) extern void vvv(void); #define SymI_NeedsDataProto(vvv) extern StgWord vvv[]; #if defined(COMPILING_WINDOWS_DLL) #define SymE_HasProto(vvv) SymE_HasProto(vvv); @@ -1226,8 +1043,6 @@ RTS_DARWIN_ONLY_SYMBOLS RTS_OPENBSD_ONLY_SYMBOLS RTS_LIBGCC_SYMBOLS RTS_LIBFFI_SYMBOLS -RTS_SSP_SYMBOLS -RTS_LINKER_SYMBOLS #undef SymI_NeedsProto #undef SymI_NeedsDataProto #undef SymI_HasProto @@ -1247,7 +1062,7 @@ RTS_LINKER_SYMBOLS #define SymE_HasDataProto(vvv) \ SymE_HasProto(vvv) -#define SymI_NeedsProto(vvv,...) SymI_HasProto(vvv ## __VA_ARGS__) +#define SymI_NeedsProto(vvv) SymI_HasProto(vvv) #define SymI_NeedsDataProto(vvv) SymI_HasDataProto(vvv) #define SymE_NeedsProto(vvv) SymE_HasProto(vvv) #define SymE_NeedsDataProto(vvv) SymE_HasDataProto(vvv) @@ -1268,8 +1083,6 @@ RTS_LINKER_SYMBOLS #define SymI_HasProto_deprecated(vvv) \ { #vvv, (void*)0xBAADF00D, true }, -void *RTS_DYNAMIC = NULL; - RtsSymbolVal rtsSyms[] = { RTS_SYMBOLS RTS_RET_SYMBOLS @@ -1281,14 +1094,11 @@ RtsSymbolVal rtsSyms[] = { RTS_LIBGCC_SYMBOLS RTS_LIBFFI_SYMBOLS SymI_HasDataProto(nonmoving_write_barrier_enabled) - RTS_SSP_SYMBOLS - RTS_LINKER_SYMBOLS #if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH) // dyld stub code contains references to this, // but it should never be called because we treat // lazy pointers as nonlazy. { "dyld_stub_binding_helper", (void*)0xDEADBEEF, false }, #endif - { "_DYNAMIC", (void*)(&RTS_DYNAMIC), false }, { 0, 0, false } /* sentinel */ }; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c26e81d116a653b5259aeb290fb1e697efe3382a...0dd405529f0f17cd9a5b299e7ae5539a885b4b5a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c26e81d116a653b5259aeb290fb1e697efe3382a...0dd405529f0f17cd9a5b299e7ae5539a885b4b5a You're receiving 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 Jul 21 03:54:16 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 20 Jul 2020 23:54:16 -0400 Subject: [Git][ghc/ghc][wip/proposal-195] 154 commits: Fix GHCi :print on big-endian platforms Message-ID: <5f1666e8dfbc7_80b3f84901582f04226230@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/proposal-195 at Glasgow Haskell Compiler / GHC Commits: b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 7d443d7c by Matthew Pickering at 2020-07-20T23:53:58-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - Makefile - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f07a8c8c462b9a7cf2221223c543055193d8a653...7d443d7cab8fb936f2f77dd3810d322a1e874dcf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f07a8c8c462b9a7cf2221223c543055193d8a653...7d443d7cab8fb936f2f77dd3810d322a1e874dcf You're receiving 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 Jul 21 03:54:32 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 20 Jul 2020 23:54:32 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] Disable T10955dyn when cross testing. Can't get the TEST_WRAPPER to work on macOS. Message-ID: <5f1666f8864be_80b104edf44422734c@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 9e305d5e by Moritz Angermann at 2020-07-21T11:49:15+08:00 Disable T10955dyn when cross testing. Can't get the TEST_WRAPPER to work on macOS. - - - - - 2 changed files: - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/ghci/linking/dyn/all.T Changes: ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -74,7 +74,7 @@ compile_libAB_dyn: '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dyn" -shared B.c -o "bin_dyn/$(call DLL,B)" -lA -L"./bin_dyn" rm -f bin_dyn/*.a '$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -v0 -o "bin_dyn/$(call EXE,T10955dyn)" -L./bin_dyn -lB -lA T10955dyn.hs -v0 - LD_LIBRARY_PATH=./bin_dyn '$(TEST_WRAPPER)' ./bin_dyn/$(call EXE,T10955dyn) + LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -23,7 +23,10 @@ test('T10955', extra_hc_opts('-L. -L./bin_dep')], ghci_script, ['T10955.script']) -test('T10955dyn', [extra_files(['A.c', 'B.c'])], makefile_test, ['compile_libAB_dyn']) +test('T10955dyn', + [when(cross(), skip), # can't get this to work properly without sacrificing darwin tests. + extra_files(['A.c', 'B.c'])], + makefile_test, ['compile_libAB_dyn']) test('T10458', [extra_files(['A.c']), View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e305d5e37a15caa974db02f9eae5591a4bd15cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e305d5e37a15caa974db02f9eae5591a4bd15cb You're receiving 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 Jul 21 06:04:25 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 21 Jul 2020 02:04:25 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] 36 commits: Revert "AArch32 symbols only on aarch32." Message-ID: <5f16856982322_80b3f84962c9cf04232699@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - ef7dc0fe by Moritz Angermann at 2020-07-21T02:04:23-04:00 Cross Test Suite - - - - - 5f14e3db by Moritz Angermann at 2020-07-21T02:04:23-04:00 platform backwards compat, until libraries are patched. - - - - - ed1b668d by Moritz Angermann at 2020-07-21T02:04:23-04:00 unbreak test.mk - - - - - 4c697c52 by Moritz Angermann at 2020-07-21T02:04:23-04:00 default TEST_WRAPPER - - - - - fec54f4c by Moritz Angermann at 2020-07-21T02:04:23-04:00 m( - - - - - 543cb86e by Moritz Angermann at 2020-07-21T02:04:23-04:00 Fixup the test-suite - - - - - 30d11270 by Moritz Angermann at 2020-07-21T02:04:23-04:00 Update test.mk - - - - - c003ceda by Moritz Angermann at 2020-07-21T02:04:23-04:00 Fix T13350 - - - - - 3839df3c by Moritz Angermann at 2020-07-21T02:04:23-04:00 Fix T1372 - - - - - 19c2926c by Moritz Angermann at 2020-07-21T02:04:23-04:00 Drop exec, use identity wrapper - - - - - cbeacd8e by Moritz Angermann at 2020-07-21T02:04:23-04:00 Fix T13168 - - - - - 9b62c5b9 by Moritz Angermann at 2020-07-21T02:04:23-04:00 Fix T3007 - - - - - 7e11d5b1 by Moritz Angermann at 2020-07-21T02:04:23-04:00 Fix recomp007 - - - - - 1189fe2c by Moritz Angermann at 2020-07-21T02:04:23-04:00 use $* - - - - - 1f901b1b by Moritz Angermann at 2020-07-21T02:04:23-04:00 fix concio001 - - - - - f813ee28 by Moritz Angermann at 2020-07-21T02:04:23-04:00 disable flakey divbyzero test - - - - - 117d60fd by Moritz Angermann at 2020-07-21T02:04:23-04:00 add python :( - - - - - e621a607 by Moritz Angermann at 2020-07-21T02:04:23-04:00 ??? - - - - - 7f752c1e by Moritz Angermann at 2020-07-21T02:04:23-04:00 Fix T13168 - - - - - 04e36891 by Moritz Angermann at 2020-07-21T02:04:23-04:00 What is going on in CI? Why can't I reproduce this locally? - - - - - e38eb5ab by Moritz Angermann at 2020-07-21T02:04:23-04:00 Fix test-wrapper in python, so hadrian gets the benefit. - - - - - 1e1429b7 by Moritz Angermann at 2020-07-21T02:04:23-04:00 make it a Path! - - - - - cf84eb05 by Moritz Angermann at 2020-07-21T02:04:23-04:00 Drop left debug statement - - - - - 127e5fb6 by Moritz Angermann at 2020-07-21T02:04:23-04:00 Better TEST_WRAPPER injection. - - - - - 787b0c1e by Moritz Angermann at 2020-07-21T02:04:23-04:00 Split wrapper and prefix - - - - - 62b6adfd by Moritz Angermann at 2020-07-21T02:04:23-04:00 Maybe the test-wrapper logic should become a cmd_prefix? - - - - - 6fafdcc9 by Moritz Angermann at 2020-07-21T02:04:23-04:00 :facepalm: - - - - - b4eb6d9f by Moritz Angermann at 2020-07-21T02:04:23-04:00 :fire: - - - - - c4898aa2 by Moritz Angermann at 2020-07-21T02:04:23-04:00 Fix T10955dyn? - - - - - af714cc2 by Moritz Angermann at 2020-07-21T02:04:23-04:00 cleanup - - - - - 91a8406c by Moritz Angermann at 2020-07-21T02:04:23-04:00 Revert "Fix T10955dyn?" This reverts commit 4c242580a429fd1942a9a982fd2b4a3abe113d6d. - - - - - a1d83e5d by Moritz Angermann at 2020-07-21T02:04:23-04:00 Disable T10955dyn when cross testing. Can't get the TEST_WRAPPER to work on macOS. - - - - - 30 changed files: - libraries/base/tests/IO/Makefile - libraries/base/tests/IO/T12010/Makefile - libraries/base/tests/Numeric/all.T - libraries/base/tests/all.T - rts/RtsSymbols.c - testsuite/config/ghc - + testsuite/driver/id - testsuite/driver/runtests.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/mk/boilerplate.mk - testsuite/mk/ghc-config.hs - testsuite/mk/test.mk - testsuite/tests/annotations/should_fail/all.T - testsuite/tests/annotations/should_run/all.T - testsuite/tests/backpack/cabal/T14304/Makefile - testsuite/tests/backpack/cabal/T15594/Makefile - testsuite/tests/backpack/cabal/T16219/Makefile - testsuite/tests/backpack/cabal/bkpcabal01/Makefile - testsuite/tests/backpack/cabal/bkpcabal02/Makefile - testsuite/tests/backpack/cabal/bkpcabal03/Makefile - testsuite/tests/backpack/cabal/bkpcabal04/Makefile - testsuite/tests/backpack/cabal/bkpcabal05/Makefile - testsuite/tests/backpack/cabal/bkpcabal06/Makefile - testsuite/tests/backpack/cabal/bkpcabal07/Makefile - testsuite/tests/cabal/T12733/Makefile - testsuite/tests/cabal/cabal01/Makefile - testsuite/tests/cabal/cabal01/all.T - testsuite/tests/cabal/cabal03/Makefile - testsuite/tests/cabal/cabal04/Makefile The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e305d5e37a15caa974db02f9eae5591a4bd15cb...a1d83e5d2bda1dc53731b1ae5327076036a86950 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e305d5e37a15caa974db02f9eae5591a4bd15cb...a1d83e5d2bda1dc53731b1ae5327076036a86950 You're receiving 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 Jul 21 06:48:52 2020 From: gitlab at gitlab.haskell.org (Sylvain Henry) Date: Tue, 21 Jul 2020 02:48:52 -0400 Subject: [Git][ghc/ghc][wip/proposal-195] Use a newtype `Code` for the return type of typed quotations (Proposal #195) Message-ID: <5f168fd434461_80bd68a9b8423595a@gitlab.haskell.org.mail> Sylvain Henry pushed to branch wip/proposal-195 at Glasgow Haskell Compiler / GHC Commits: e2d5d80d by Matthew Pickering at 2020-07-21T08:48:20+02:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Splice.hs - docs/users_guide/exts/deriving_extra.rst - docs/users_guide/exts/template_haskell.rst - libraries/template-haskell/Language/Haskell/TH.hs - + libraries/template-haskell/Language/Haskell/TH/CodeDo.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - libraries/template-haskell/template-haskell.cabal.in - libraries/text - testsuite/tests/deriving/should_compile/drv-empty-data.stderr - testsuite/tests/parser/should_compile/Proposal229f_instances.hs - testsuite/tests/partial-sigs/should_compile/TypedSplice.hs - testsuite/tests/partial-sigs/should_compile/TypedSplice.stderr - testsuite/tests/quotes/T17857.hs - testsuite/tests/th/T10945.stderr - testsuite/tests/th/T11452.stderr - testsuite/tests/th/T15471A.hs - testsuite/tests/th/T15843.hs - testsuite/tests/th/T16195A.hs - testsuite/tests/th/T18102b_aux.hs - testsuite/tests/th/T18121.hs - testsuite/tests/th/T8577.stderr - testsuite/tests/th/T8577a.hs - testsuite/tests/th/TH_StringLift.hs - testsuite/tests/th/TH_reifyLocalDefs.hs - testsuite/tests/th/overloaded/T17839.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e2d5d80d24a931e5351e64017694ab8aa84c6c1d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e2d5d80d24a931e5351e64017694ab8aa84c6c1d You're receiving 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 Jul 21 08:15:50 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 21 Jul 2020 04:15:50 -0400 Subject: [Git][ghc/ghc][wip/T18126] 6 commits: Revert "AArch32 symbols only on aarch32." Message-ID: <5f16a436d5cd2_80bd68a9b84245830@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18126 at Glasgow Haskell Compiler / GHC Commits: 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c60e4c5a by Simon Peyton Jones at 2020-07-21T09:15:04+01:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) point (2) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 29962b14 by Simon Peyton Jones at 2020-07-21T09:15:04+01:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typeecheck/polykinds/T16245a - - - - - 18 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Hole.hs - + compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Default.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91c6850416ea62b7685b88c1d1655afcf4aee4e6...29962b14c720698dba888b6d62ad3d80d65eeb29 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91c6850416ea62b7685b88c1d1655afcf4aee4e6...29962b14c720698dba888b6d62ad3d80d65eeb29 You're receiving 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 Jul 21 10:39:40 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 21 Jul 2020 06:39:40 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Revert "AArch32 symbols only on aarch32." Message-ID: <5f16c5ec2d2c6_80bd68a9b842612b3@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 10 changed files: - compiler/GHC/CoreToStg.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Stg/DepAnal.hs - compiler/GHC/Stg/Lift.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/Stg/Pipeline.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - docs/users_guide/exts/existential_quantification.rst - rts/RtsSymbols.c Changes: ===================================== compiler/GHC/CoreToStg.hs ===================================== @@ -445,7 +445,7 @@ coreToStgExpr e0@(Case scrut bndr _ alts) = do _ -> pprPanic "coreToStgExpr" $ text "Unexpected unsafe equality case expression:" $$ ppr e0 $$ - text "STG:" $$ ppr stg + text "STG:" $$ pprStgExpr panicStgPprOpts stg _ -> return stg where vars_alt :: (AltCon, [Var], CoreExpr) -> CtsM (AltCon, [Var], StgExpr) ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -1551,7 +1551,7 @@ doCodeGen hsc_env this_mod data_tycons let stg_binds_w_fvs = annTopBindingsFreeVars stg_binds - dumpIfSet_dyn dflags Opt_D_dump_stg_final "Final STG:" FormatSTG (pprGenStgTopBindings stg_binds_w_fvs) + dumpIfSet_dyn dflags Opt_D_dump_stg_final "Final STG:" FormatSTG (pprGenStgTopBindings (initStgPprOpts dflags) stg_binds_w_fvs) let cmm_stream :: Stream IO CmmGroup ModuleLFInfos -- See Note [Forcing of stg_binds] ===================================== compiler/GHC/Stg/DepAnal.hs ===================================== @@ -14,6 +14,7 @@ import GHC.Types.Var.Set import GHC.Unit.Module (Module) import Data.Graph (SCC (..)) +import Data.Bifunctor (first) -------------------------------------------------------------------------------- -- * Dependency analysis @@ -90,7 +91,7 @@ annTopBindingsDeps this_mod bs = zip bs (map top_bind bs) expr bounds (StgOpApp _ as _) = args bounds as expr _ lam at StgLam{} = - pprPanic "annTopBindingsDeps" (text "Found lambda:" $$ ppr lam) + pprPanic "annTopBindingsDeps" (text "Found lambda:" $$ pprStgExpr panicStgPprOpts lam) expr bounds (StgCase scrut scrut_bndr _ as) = expr bounds scrut `unionVarSet` alts (extendVarSet bounds scrut_bndr) as @@ -141,4 +142,6 @@ depSort = concatMap get_binds . depAnal defs uses get_binds (AcyclicSCC bind) = [bind] get_binds (CyclicSCC binds) = - pprPanic "depSortStgBinds" (text "Found cyclic SCC:" $$ ppr binds) + pprPanic "depSortStgBinds" + (text "Found cyclic SCC:" + $$ ppr (map (first (pprStgTopBinding panicStgPprOpts)) binds)) ===================================== compiler/GHC/Stg/Lift.hs ===================================== @@ -199,7 +199,7 @@ liftRhs -> LlStgRhs -> LiftM OutStgRhs liftRhs mb_former_fvs rhs@(StgRhsCon ccs con args) - = ASSERT2(isNothing mb_former_fvs, text "Should never lift a constructor" $$ ppr rhs) + = ASSERT2(isNothing mb_former_fvs, text "Should never lift a constructor" $$ pprStgRhs panicStgPprOpts rhs) StgRhsCon ccs con <$> traverse liftArgs args liftRhs Nothing (StgRhsClosure _ ccs upd infos body) = do -- This RHS wasn't lifted. ===================================== compiler/GHC/Stg/Lint.hs ===================================== @@ -70,7 +70,7 @@ lintStgTopBindings :: forall a . (OutputablePass a, BinderP a ~ Id) lintStgTopBindings dflags this_mod unarised whodunnit binds = {-# SCC "StgLint" #-} - case initL this_mod unarised top_level_binds (lint_binds binds) of + case initL this_mod unarised opts top_level_binds (lint_binds binds) of Nothing -> return () Just msg -> do @@ -80,10 +80,11 @@ lintStgTopBindings dflags this_mod unarised whodunnit binds text whodunnit <+> text "***", msg, text "*** Offending Program ***", - pprGenStgTopBindings binds, + pprGenStgTopBindings opts binds, text "*** End of Offense ***"]) Err.ghcExit dflags 1 where + opts = initStgPprOpts dflags -- Bring all top-level binds into scope because CoreToStg does not generate -- bindings in dependency order (so we may see a use before its definition). top_level_binds = mkVarSet (bindersOfTopBinds binds) @@ -129,9 +130,10 @@ lint_binds_help top_lvl (binder, rhs) = addLoc (RhsOf binder) $ do when (isTopLevel top_lvl) (checkNoCurrentCCS rhs) lintStgRhs rhs + opts <- getStgPprOpts -- Check binder doesn't have unlifted type or it's a join point checkL (isJoinId binder || not (isUnliftedType (idType binder))) - (mkUnliftedTyMsg binder rhs) + (mkUnliftedTyMsg opts binder rhs) -- | Top-level bindings can't inherit the cost centre stack from their -- (static) allocation site. @@ -139,14 +141,17 @@ checkNoCurrentCCS :: (OutputablePass a, BinderP a ~ Id) => GenStgRhs a -> LintM () -checkNoCurrentCCS rhs@(StgRhsClosure _ ccs _ _ _) - | isCurrentCCS ccs - = addErrL (text "Top-level StgRhsClosure with CurrentCCS" $$ ppr rhs) -checkNoCurrentCCS rhs@(StgRhsCon ccs _ _) - | isCurrentCCS ccs - = addErrL (text "Top-level StgRhsCon with CurrentCCS" $$ ppr rhs) -checkNoCurrentCCS _ - = return () +checkNoCurrentCCS rhs = do + opts <- getStgPprOpts + let rhs' = pprStgRhs opts rhs + case rhs of + StgRhsClosure _ ccs _ _ _ + | isCurrentCCS ccs + -> addErrL (text "Top-level StgRhsClosure with CurrentCCS" $$ rhs') + StgRhsCon ccs _ _ + | isCurrentCCS ccs + -> addErrL (text "Top-level StgRhsCon with CurrentCCS" $$ rhs') + _ -> return () lintStgRhs :: (OutputablePass a, BinderP a ~ Id) => GenStgRhs a -> LintM () @@ -159,9 +164,10 @@ lintStgRhs (StgRhsClosure _ _ _ binders expr) lintStgExpr expr lintStgRhs rhs@(StgRhsCon _ con args) = do - when (isUnboxedTupleCon con || isUnboxedSumCon con) $ + when (isUnboxedTupleCon con || isUnboxedSumCon con) $ do + opts <- getStgPprOpts addErrL (text "StgRhsCon is an unboxed tuple or sum application" $$ - ppr rhs) + pprStgRhs opts rhs) mapM_ lintStgArg args mapM_ checkPostUnariseConArg args @@ -176,17 +182,19 @@ lintStgExpr (StgApp fun args) = do lintStgExpr app@(StgConApp con args _arg_tys) = do -- unboxed sums should vanish during unarise lf <- getLintFlags - when (lf_unarised lf && isUnboxedSumCon con) $ + when (lf_unarised lf && isUnboxedSumCon con) $ do + opts <- getStgPprOpts addErrL (text "Unboxed sum after unarise:" $$ - ppr app) + pprStgExpr opts app) mapM_ lintStgArg args mapM_ checkPostUnariseConArg args lintStgExpr (StgOpApp _ args _) = mapM_ lintStgArg args -lintStgExpr lam@(StgLam _ _) = - addErrL (text "Unexpected StgLam" <+> ppr lam) +lintStgExpr lam@(StgLam _ _) = do + opts <- getStgPprOpts + addErrL (text "Unexpected StgLam" <+> pprStgExpr opts lam) lintStgExpr (StgLet _ binds body) = do binders <- lintStgBinds NotTopLevel binds @@ -235,6 +243,7 @@ The Lint monad newtype LintM a = LintM { unLintM :: Module -> LintFlags + -> StgPprOpts -- Pretty-printing options -> [LintLocInfo] -- Locations -> IdSet -- Local vars in scope -> Bag MsgDoc -- Error messages so far @@ -268,16 +277,16 @@ pp_binders bs pp_binder b = hsep [ppr b, dcolon, ppr (idType b)] -initL :: Module -> Bool -> IdSet -> LintM a -> Maybe MsgDoc -initL this_mod unarised locals (LintM m) = do - let (_, errs) = m this_mod (LintFlags unarised) [] locals emptyBag +initL :: Module -> Bool -> StgPprOpts -> IdSet -> LintM a -> Maybe MsgDoc +initL this_mod unarised opts locals (LintM m) = do + let (_, errs) = m this_mod (LintFlags unarised) opts [] locals emptyBag if isEmptyBag errs then Nothing else Just (vcat (punctuate blankLine (bagToList errs))) instance Applicative LintM where - pure a = LintM $ \_mod _lf _loc _scope errs -> (a, errs) + pure a = LintM $ \_mod _lf _opts _loc _scope errs -> (a, errs) (<*>) = ap (*>) = thenL_ @@ -286,14 +295,14 @@ instance Monad LintM where (>>) = (*>) thenL :: LintM a -> (a -> LintM b) -> LintM b -thenL m k = LintM $ \mod lf loc scope errs - -> case unLintM m mod lf loc scope errs of - (r, errs') -> unLintM (k r) mod lf loc scope errs' +thenL m k = LintM $ \mod lf opts loc scope errs + -> case unLintM m mod lf opts loc scope errs of + (r, errs') -> unLintM (k r) mod lf opts loc scope errs' thenL_ :: LintM a -> LintM b -> LintM b -thenL_ m k = LintM $ \mod lf loc scope errs - -> case unLintM m mod lf loc scope errs of - (_, errs') -> unLintM k mod lf loc scope errs' +thenL_ m k = LintM $ \mod lf opts loc scope errs + -> case unLintM m mod lf opts loc scope errs of + (_, errs') -> unLintM k mod lf opts loc scope errs' checkL :: Bool -> MsgDoc -> LintM () checkL True _ = return () @@ -338,7 +347,7 @@ checkPostUnariseId id = is_sum <|> is_tuple <|> is_void addErrL :: MsgDoc -> LintM () -addErrL msg = LintM $ \_mod _lf loc _scope errs -> ((), addErr errs msg loc) +addErrL msg = LintM $ \_mod _lf _opts loc _scope errs -> ((), addErr errs msg loc) addErr :: Bag MsgDoc -> MsgDoc -> [LintLocInfo] -> Bag MsgDoc addErr errs_so_far msg locs @@ -349,29 +358,32 @@ addErr errs_so_far msg locs mk_msg [] = msg addLoc :: LintLocInfo -> LintM a -> LintM a -addLoc extra_loc m = LintM $ \mod lf loc scope errs - -> unLintM m mod lf (extra_loc:loc) scope errs +addLoc extra_loc m = LintM $ \mod lf opts loc scope errs + -> unLintM m mod lf opts (extra_loc:loc) scope errs addInScopeVars :: [Id] -> LintM a -> LintM a -addInScopeVars ids m = LintM $ \mod lf loc scope errs +addInScopeVars ids m = LintM $ \mod lf opts loc scope errs -> let new_set = mkVarSet ids - in unLintM m mod lf loc (scope `unionVarSet` new_set) errs + in unLintM m mod lf opts loc (scope `unionVarSet` new_set) errs getLintFlags :: LintM LintFlags -getLintFlags = LintM $ \_mod lf _loc _scope errs -> (lf, errs) +getLintFlags = LintM $ \_mod lf _opts _loc _scope errs -> (lf, errs) + +getStgPprOpts :: LintM StgPprOpts +getStgPprOpts = LintM $ \_mod _lf opts _loc _scope errs -> (opts, errs) checkInScope :: Id -> LintM () -checkInScope id = LintM $ \mod _lf loc scope errs +checkInScope id = LintM $ \mod _lf _opts loc scope errs -> if nameIsLocalOrFrom mod (idName id) && not (id `elemVarSet` scope) then ((), addErr errs (hsep [ppr id, dcolon, ppr (idType id), text "is out of scope"]) loc) else ((), errs) -mkUnliftedTyMsg :: OutputablePass a => Id -> GenStgRhs a -> SDoc -mkUnliftedTyMsg binder rhs +mkUnliftedTyMsg :: OutputablePass a => StgPprOpts -> Id -> GenStgRhs a -> SDoc +mkUnliftedTyMsg opts binder rhs = (text "Let(rec) binder" <+> quotes (ppr binder) <+> text "has unlifted type" <+> quotes (ppr (idType binder))) $$ - (text "RHS:" <+> ppr rhs) + (text "RHS:" <+> pprStgRhs opts rhs) ===================================== compiler/GHC/Stg/Pipeline.hs ===================================== @@ -103,13 +103,14 @@ stg2stg dflags this_mod binds liftIO (stg_linter True "Unarise" binds') return binds' + opts = initStgPprOpts dflags dump_when flag header binds - = dumpIfSet_dyn dflags flag header FormatSTG (pprStgTopBindings binds) + = dumpIfSet_dyn dflags flag header FormatSTG (pprStgTopBindings opts binds) end_pass what binds2 = liftIO $ do -- report verbosely, if required dumpIfSet_dyn dflags Opt_D_verbose_stg2stg what - FormatSTG (vcat (map ppr binds2)) + FormatSTG (vcat (map (pprStgTopBinding opts) binds2)) stg_linter False what binds2 return binds2 ===================================== compiler/GHC/Stg/Syntax.hs ===================================== @@ -56,7 +56,11 @@ module GHC.Stg.Syntax ( stgCaseBndrInScope, bindersOf, bindersOfTop, bindersOfTopBinds, - pprStgBinding, pprGenStgTopBindings, pprStgTopBindings + -- ppr + StgPprOpts(..), initStgPprOpts, panicStgPprOpts, + pprStgArg, pprStgExpr, pprStgRhs, pprStgBinding, + pprGenStgTopBinding, pprStgTopBinding, + pprGenStgTopBindings, pprStgTopBindings ) where #include "HsVersions.h" @@ -643,79 +647,73 @@ type OutputablePass pass = , OutputableBndr (BinderP pass) ) -pprGenStgTopBinding - :: OutputablePass pass => GenStgTopBinding pass -> SDoc -pprGenStgTopBinding (StgTopStringLit bndr str) - = hang (hsep [pprBndr LetBind bndr, equals]) - 4 (pprHsBytes str <> semi) -pprGenStgTopBinding (StgTopLifted bind) - = pprGenStgBinding bind - -pprGenStgBinding - :: OutputablePass pass => GenStgBinding pass -> SDoc - -pprGenStgBinding (StgNonRec bndr rhs) - = hang (hsep [pprBndr LetBind bndr, equals]) - 4 (ppr rhs <> semi) - -pprGenStgBinding (StgRec pairs) - = vcat [ text "Rec {" - , vcat (intersperse blankLine (map ppr_bind pairs)) - , text "end Rec }" ] - where - ppr_bind (bndr, expr) - = hang (hsep [pprBndr LetBind bndr, equals]) - 4 (ppr expr <> semi) +-- | STG pretty-printing options +data StgPprOpts = StgPprOpts + { stgSccEnabled :: !Bool -- ^ Enable cost-centres + } + +-- | Initialize STG pretty-printing options from DynFlags +initStgPprOpts :: DynFlags -> StgPprOpts +initStgPprOpts dflags = StgPprOpts + { stgSccEnabled = sccProfilingEnabled dflags + } -pprGenStgTopBindings - :: (OutputablePass pass) => [GenStgTopBinding pass] -> SDoc -pprGenStgTopBindings binds - = vcat $ intersperse blankLine (map pprGenStgTopBinding binds) +-- | STG pretty-printing options used for panic messages +panicStgPprOpts :: StgPprOpts +panicStgPprOpts = StgPprOpts + { stgSccEnabled = True + } -pprStgBinding :: StgBinding -> SDoc +pprGenStgTopBinding + :: OutputablePass pass => StgPprOpts -> GenStgTopBinding pass -> SDoc +pprGenStgTopBinding opts b = case b of + StgTopStringLit bndr str -> hang (hsep [pprBndr LetBind bndr, equals]) 4 (pprHsBytes str <> semi) + StgTopLifted bind -> pprGenStgBinding opts bind + +pprGenStgBinding :: OutputablePass pass => StgPprOpts -> GenStgBinding pass -> SDoc +pprGenStgBinding opts b = case b of + StgNonRec bndr rhs -> hang (hsep [pprBndr LetBind bndr, equals]) 4 (pprStgRhs opts rhs <> semi) + StgRec pairs -> vcat [ text "Rec {" + , vcat (intersperse blankLine (map ppr_bind pairs)) + , text "end Rec }" ] + where + ppr_bind (bndr, expr) + = hang (hsep [pprBndr LetBind bndr, equals]) + 4 (pprStgRhs opts expr <> semi) + +pprGenStgTopBindings :: (OutputablePass pass) => StgPprOpts -> [GenStgTopBinding pass] -> SDoc +pprGenStgTopBindings opts binds + = vcat $ intersperse blankLine (map (pprGenStgTopBinding opts) binds) + +pprStgBinding :: StgPprOpts -> StgBinding -> SDoc pprStgBinding = pprGenStgBinding -pprStgTopBindings :: [StgTopBinding] -> SDoc +pprStgTopBinding :: StgPprOpts -> StgTopBinding -> SDoc +pprStgTopBinding = pprGenStgTopBinding + +pprStgTopBindings :: StgPprOpts -> [StgTopBinding] -> SDoc pprStgTopBindings = pprGenStgTopBindings instance Outputable StgArg where - ppr = pprStgArg - -instance OutputablePass pass => Outputable (GenStgTopBinding pass) where - ppr = pprGenStgTopBinding - -instance OutputablePass pass => Outputable (GenStgBinding pass) where - ppr = pprGenStgBinding - -instance OutputablePass pass => Outputable (GenStgExpr pass) where - ppr = pprStgExpr - -instance OutputablePass pass => Outputable (GenStgRhs pass) where - ppr rhs = pprStgRhs rhs + ppr = pprStgArg pprStgArg :: StgArg -> SDoc pprStgArg (StgVarArg var) = ppr var pprStgArg (StgLitArg con) = ppr con -pprStgExpr :: OutputablePass pass => GenStgExpr pass -> SDoc --- special case -pprStgExpr (StgLit lit) = ppr lit - --- general case -pprStgExpr (StgApp func args) - = hang (ppr func) 4 (sep (map (ppr) args)) - -pprStgExpr (StgConApp con args _) - = hsep [ ppr con, brackets (interppSP args) ] - -pprStgExpr (StgOpApp op args _) - = hsep [ pprStgOp op, brackets (interppSP args)] - -pprStgExpr (StgLam bndrs body) - = sep [ char '\\' <+> ppr_list (map (pprBndr LambdaBind) (toList bndrs)) - <+> text "->", - pprStgExpr body ] - where ppr_list = brackets . fsep . punctuate comma +pprStgExpr :: OutputablePass pass => StgPprOpts -> GenStgExpr pass -> SDoc +pprStgExpr opts e = case e of + -- special case + StgLit lit -> ppr lit + -- general case + StgApp func args -> hang (ppr func) 4 (interppSP args) + StgConApp con args _ -> hsep [ ppr con, brackets (interppSP args) ] + StgOpApp op args _ -> hsep [ pprStgOp op, brackets (interppSP args)] + StgLam bndrs body -> let ppr_list = brackets . fsep . punctuate comma + in sep [ char '\\' <+> ppr_list (map (pprBndr LambdaBind) (toList bndrs)) + <+> text "->" + , pprStgExpr opts body + ] -- special case: let v = -- in @@ -726,9 +724,9 @@ pprStgExpr (StgLam bndrs body) -- Very special! Suspicious! (SLPJ) {- -pprStgExpr (StgLet srt (StgNonRec bndr (StgRhsClosure cc bi free_vars upd_flag args rhs)) + StgLet srt (StgNonRec bndr (StgRhsClosure cc bi free_vars upd_flag args rhs)) expr@(StgLet _ _)) - = ($$) + -> ($$) (hang (hcat [text "let { ", ppr bndr, ptext (sLit " = "), ppr cc, pp_binder_info bi, @@ -739,53 +737,60 @@ pprStgExpr (StgLet srt (StgNonRec bndr (StgRhsClosure cc bi free_vars upd_flag a (ppr expr) -} --- special case: let ... in let ... - -pprStgExpr (StgLet ext bind expr at StgLet{}) - = ($$) + -- special case: let ... in let ... + StgLet ext bind expr at StgLet{} -> ($$) (sep [hang (text "let" <+> ppr ext <+> text "{") - 2 (hsep [pprGenStgBinding bind, text "} in"])]) - (ppr expr) - --- general case -pprStgExpr (StgLet ext bind expr) - = sep [hang (text "let" <+> ppr ext <+> text "{") 2 (pprGenStgBinding bind), - hang (text "} in ") 2 (ppr expr)] - -pprStgExpr (StgLetNoEscape ext bind expr) - = sep [hang (text "let-no-escape" <+> ppr ext <+> text "{") - 2 (pprGenStgBinding bind), - hang (text "} in ") - 2 (ppr expr)] - -pprStgExpr (StgTick tickish expr) - = sdocOption sdocSuppressTicks $ \case - True -> pprStgExpr expr - False -> sep [ ppr tickish, pprStgExpr expr ] - - --- Don't indent for a single case alternative. -pprStgExpr (StgCase expr bndr alt_type [alt]) - = sep [sep [text "case", - nest 4 (hsep [pprStgExpr expr, - whenPprDebug (dcolon <+> ppr alt_type)]), - text "of", pprBndr CaseBind bndr, char '{'], - pprStgAlt False alt, - char '}'] - -pprStgExpr (StgCase expr bndr alt_type alts) - = sep [sep [text "case", - nest 4 (hsep [pprStgExpr expr, - whenPprDebug (dcolon <+> ppr alt_type)]), - text "of", pprBndr CaseBind bndr, char '{'], - nest 2 (vcat (map (pprStgAlt True) alts)), - char '}'] - - -pprStgAlt :: OutputablePass pass => Bool -> GenStgAlt pass -> SDoc -pprStgAlt indent (con, params, expr) - | indent = hang altPattern 4 (ppr expr <> semi) - | otherwise = sep [altPattern, ppr expr <> semi] + 2 (hsep [pprGenStgBinding opts bind, text "} in"])]) + (pprStgExpr opts expr) + + -- general case + StgLet ext bind expr + -> sep [ hang (text "let" <+> ppr ext <+> text "{") + 2 (pprGenStgBinding opts bind) + , hang (text "} in ") 2 (pprStgExpr opts expr) + ] + + StgLetNoEscape ext bind expr + -> sep [ hang (text "let-no-escape" <+> ppr ext <+> text "{") + 2 (pprGenStgBinding opts bind) + , hang (text "} in ") 2 (pprStgExpr opts expr) + ] + + StgTick tickish expr -> sdocOption sdocSuppressTicks $ \case + True -> pprStgExpr opts expr + False -> sep [ ppr tickish, pprStgExpr opts expr ] + + -- Don't indent for a single case alternative. + StgCase expr bndr alt_type [alt] + -> sep [ sep [ text "case" + , nest 4 (hsep [ pprStgExpr opts expr + , whenPprDebug (dcolon <+> ppr alt_type) + ]) + , text "of" + , pprBndr CaseBind bndr + , char '{' + ] + , pprStgAlt opts False alt + , char '}' + ] + + StgCase expr bndr alt_type alts + -> sep [ sep [ text "case" + , nest 4 (hsep [ pprStgExpr opts expr + , whenPprDebug (dcolon <+> ppr alt_type) + ]) + , text "of" + , pprBndr CaseBind bndr, char '{' + ] + , nest 2 (vcat (map (pprStgAlt opts True) alts)) + , char '}' + ] + + +pprStgAlt :: OutputablePass pass => StgPprOpts -> Bool -> GenStgAlt pass -> SDoc +pprStgAlt opts indent (con, params, expr) + | indent = hang altPattern 4 (pprStgExpr opts expr <> semi) + | otherwise = sep [altPattern, pprStgExpr opts expr <> semi] where altPattern = (hsep [ppr con, sep (map (pprBndr CasePatBind) params), text "->"]) @@ -801,15 +806,14 @@ instance Outputable AltType where ppr (AlgAlt tc) = text "Alg" <+> ppr tc ppr (PrimAlt tc) = text "Prim" <+> ppr tc -pprStgRhs :: OutputablePass pass => GenStgRhs pass -> SDoc - -pprStgRhs (StgRhsClosure ext cc upd_flag args body) - = sdocWithDynFlags $ \dflags -> - hang (hsep [if sccProfilingEnabled dflags then ppr cc else empty, - ppUnlessOption sdocSuppressStgExts (ppr ext), - char '\\' <> ppr upd_flag, brackets (interppSP args)]) - 4 (ppr body) - -pprStgRhs (StgRhsCon cc con args) - = hcat [ ppr cc, - space, ppr con, text "! ", brackets (interppSP args)] +pprStgRhs :: OutputablePass pass => StgPprOpts -> GenStgRhs pass -> SDoc +pprStgRhs opts rhs = case rhs of + StgRhsClosure ext cc upd_flag args body + -> hang (hsep [ if stgSccEnabled opts then ppr cc else empty + , ppUnlessOption sdocSuppressStgExts (ppr ext) + , char '\\' <> ppr upd_flag, brackets (interppSP args) + ]) + 4 (pprStgExpr opts body) + + StgRhsCon cc con args + -> hcat [ ppr cc, space, ppr con, text "! ", brackets (sep (map pprStgArg args))] ===================================== compiler/GHC/Stg/Unarise.hs ===================================== @@ -1,3 +1,5 @@ +{-# LANGUAGE FlexibleContexts #-} + {- (c) The GRASP/AQUA Project, Glasgow University, 1992-2012 @@ -315,7 +317,7 @@ unariseExpr rho e@(StgApp f args) f' = case lookupVarEnv rho f of Just (UnaryVal (StgVarArg f')) -> f' Nothing -> f - err -> pprPanic "unariseExpr - app2" (ppr e $$ ppr err) + err -> pprPanic "unariseExpr - app2" (pprStgExpr panicStgPprOpts e $$ ppr err) -- Can't happen because 'args' is non-empty, and -- a tuple or sum cannot be applied to anything @@ -334,7 +336,7 @@ unariseExpr rho (StgOpApp op args ty) = return (StgOpApp op (unariseFunArgs rho args) ty) unariseExpr _ e at StgLam{} - = pprPanic "unariseExpr: found lambda" (ppr e) + = pprPanic "unariseExpr: found lambda" (pprStgExpr panicStgPprOpts e) unariseExpr rho (StgCase scrut bndr alt_ty alts) -- tuple/sum binders in the scrutinee can always be eliminated @@ -412,7 +414,7 @@ elimCase rho args bndr (MultiValAlt _) alts elimCase _ args bndr alt_ty alts = pprPanic "elimCase - unhandled case" - (ppr args <+> ppr bndr <+> ppr alt_ty $$ ppr alts) + (ppr args <+> ppr bndr <+> ppr alt_ty $$ pprPanicAlts alts) -------------------------------------------------------------------------------- @@ -433,7 +435,7 @@ unariseAlts rho (MultiValAlt n) bndr [(DataAlt _, ys, e)] unariseAlts _ (MultiValAlt _) bndr alts | isUnboxedTupleBndr bndr - = pprPanic "unariseExpr: strange multi val alts" (ppr alts) + = pprPanic "unariseExpr: strange multi val alts" (pprPanicAlts alts) -- In this case we don't need to scrutinize the tag bit unariseAlts rho (MultiValAlt _) bndr [(DEFAULT, _, rhs)] @@ -484,7 +486,7 @@ unariseSumAlt rho args (DataAlt sumCon, bs, e) return ( LitAlt (LitNumber LitNumInt (fromIntegral (dataConTag sumCon))), [], e' ) unariseSumAlt _ scrt alt - = pprPanic "unariseSumAlt" (ppr scrt $$ ppr alt) + = pprPanic "unariseSumAlt" (ppr scrt $$ pprPanicAlt alt) -------------------------------------------------------------------------------- @@ -776,4 +778,10 @@ mkDefaultLitAlt :: [StgAlt] -> [StgAlt] mkDefaultLitAlt [] = pprPanic "elimUbxSumExpr.mkDefaultAlt" (text "Empty alts") mkDefaultLitAlt alts@((DEFAULT, _, _) : _) = alts mkDefaultLitAlt ((LitAlt{}, [], rhs) : alts) = (DEFAULT, [], rhs) : alts -mkDefaultLitAlt alts = pprPanic "mkDefaultLitAlt" (text "Not a lit alt:" <+> ppr alts) +mkDefaultLitAlt alts = pprPanic "mkDefaultLitAlt" (text "Not a lit alt:" <+> pprPanicAlts alts) + +pprPanicAlts :: (Outputable a, Outputable b, OutputablePass pass) => [(a,b,GenStgExpr pass)] -> SDoc +pprPanicAlts alts = ppr (map pprPanicAlt alts) + +pprPanicAlt :: (Outputable a, Outputable b, OutputablePass pass) => (a,b,GenStgExpr pass) -> SDoc +pprPanicAlt (c,b,e) = ppr (c,b,pprStgExpr panicStgPprOpts e) ===================================== docs/users_guide/exts/existential_quantification.rst ===================================== @@ -173,7 +173,7 @@ For example: :: data G a b where { G1 { g1::a, g2::c } :: G a [c] } upd3 g x = g { g1=x } -- OK: upd3 :: G a b -> c -> G c b - upd4 g x = g { g2=x } -- BAD (f2's type mentions c, which is not a simple + upd4 g x = g { g2=x } -- BAD (g2's type mentions c, which is not a simple -- type-variable argument in G1's result type) Restrictions ===================================== rts/RtsSymbols.c ===================================== @@ -59,6 +59,7 @@ SymI_HasProto(signal_handlers) \ SymI_HasProto(stg_sig_install) \ SymI_HasProto(rtsTimerSignal) \ + SymI_HasProto(atexit) \ SymI_NeedsDataProto(nocldstop) #endif @@ -993,213 +994,29 @@ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS + // 64-bit support functions in libgcc.a -// See https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc -#define RTS_LIBGCC_SYMBOLS_32 \ - SymI_NeedsProto(__fixunsdfdi) \ - /* 4 The GCC low-level runtime library */\ - /* 4.1.1 Arithmetic functions */\ - /* SymI_NeedsProto(__ashlsi3) */\ - SymI_NeedsProto(__ashldi3) \ - /* SymI_NeedsProto(__ashlti3) */\ - /* These functions return the result of shifting a left by b bits. */\ - /* SymI_NeedsProto(__ashrsi3) */\ - SymI_NeedsProto(__ashrdi3) \ - /* SymI_NeedsProto(__ashrti3) */\ - /* These functions return the result of arithmetically shifting a right by b bits. */\ - /* SymI_NeedsProto(__divsi3) */\ - SymI_NeedsProto(__divdi3) \ - /* SymI_NeedsProto(__divti3) */\ - /* These functions return the quotient of the signed division of a and b. */\ - /* SymI_NeedsProto(__lshrsi3) */ \ - SymI_NeedsProto(__lshrdi3) \ - /* SymI_NeedsProto(__lshrti3) */ \ - /* These functions return the result of logically shifting a right by b bits. */\ - /* SymI_NeedsProto(__modsi3) */ \ - SymI_NeedsProto(__moddi3) \ - /* SymI_NeedsProto(__modti3) */ \ - /* These functions return the remainder of the signed division of a and b. */\ - /* SymI_NeedsProto(__mulsi3) */ \ - SymI_NeedsProto(__muldi3) \ - /* SymI_NeedsProto(__multi3) */ \ - /* These functions return the product of a and b. */\ - SymI_NeedsProto(__negdi2) \ - /* SymI_NeedsProto(__negti2) */ \ - /* These functions return the negation of a. */\ - /* SymI_NeedsProto(__udivsi3) */ \ - SymI_NeedsProto(__udivdi3) \ - /* SymI_NeedsProto(__udivti3) */ \ - /* These functions return the quotient of the unsigned division of a and b. */\ - SymI_NeedsProto(__udivmoddi4) \ - /* SymI_NeedsProto(__udivmodti4) */ \ - /* These functions calculate both the quotient and remainder of the unsigned division of a and b. The return value is the quotient, and the remainder is placed in variable pointed to by c. */\ - /* SymI_NeedsProto(__umodsi3) */ \ - SymI_NeedsProto(__umoddi3) \ - /* SymI_NeedsProto(__umodti3) */ \ - /* These functions return the remainder of the unsigned division of a and b. */\ - /* 4.1.2 Comparison functions */\ - /* The following functions implement integral comparisons. These functions implement a low-level compare, upon which the higher level comparison operators (such as less than and greater than or equal to) can be constructed. The returned values lie in the range zero to two, to allow the high-level operators to be implemented by testing the returned result using either signed or unsigned comparison. */\ - SymI_NeedsProto(__cmpdi2) \ - /* SymI_NeedsProto(__cmpti2) */ \ - /* These functions perform a signed comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\ - SymI_NeedsProto(__ucmpdi2) \ - /* SymI_NeedsProto(__ucmpti2) */ \ - /* These functions perform an unsigned comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\ - /* 4.1.3 Trapping arithmetic functions */\ - /* The following functions implement trapping arithmetic. These functions call the libc function abort upon signed arithmetic overflow. */\ - SymI_NeedsProto(__absvsi2) \ - SymI_NeedsProto(__absvdi2) \ - /* These functions return the absolute value of a. */\ - /* SymI_NeedsProto(__addvsi3) */ \ - SymI_NeedsProto(__addvdi3) \ - /* These functions return the sum of a and b; that is a + b. */\ - /* SymI_NeedsProto(__mulvsi3) */ \ - SymI_NeedsProto(__mulvdi3) \ - /* The functions return the product of a and b; that is a * b. */\ - SymI_NeedsProto(__negvsi2) \ - SymI_NeedsProto(__negvdi2) \ - /* These functions return the negation of a; that is -a. */\ - /* SymI_NeedsProto(__subvsi3) */ \ - SymI_NeedsProto(__subvdi3) \ - /* These functions return the difference between b and a; that is a - b. */\ - /* 4.1.4 Bit operations */\ - SymI_NeedsProto(__clzsi2) \ - SymI_NeedsProto(__clzdi2) \ - /* SymI_NeedsProto(__clzti2) */ \ - /* These functions return the number of leading 0-bits in a, starting at the most significant bit position. If a is zero, the result is undefined. */\ - SymI_NeedsProto(__ctzsi2) \ - SymI_NeedsProto(__ctzdi2) \ - /* SymI_NeedsProto(__ctzti2) */ \ - /* These functions return the number of trailing 0-bits in a, starting at the least significant bit position. If a is zero, the result is undefined. */\ - SymI_NeedsProto(__ffsdi2) \ - /* SymI_NeedsProto(__ffsti2) */ \ - /* These functions return the index of the least significant 1-bit in a, or the value zero if a is zero. The least significant bit is index one. */\ - SymI_NeedsProto(__paritysi2) \ - SymI_NeedsProto(__paritydi2) \ - /* SymI_NeedsProto(__parityti2) */\ - /* These functions return the value zero if the number of bits set in a is even, and the value one otherwise. */\ - SymI_NeedsProto(__popcountsi2) \ - SymI_NeedsProto(__popcountdi2) \ - /* SymI_NeedsProto(__popcountti2) */ \ - /* These functions return the number of bits set in a. */\ - SymI_NeedsProto(__bswapsi2) \ - SymI_NeedsProto(__bswapdi2) -#define RTS_LIBGCC_SYMBOLS_aarch32 \ - /* armv6l */\ - /* TODO: should check for __ARM_EABI__ */\ - SymI_NeedsProto(__aeabi_d2f) \ - SymI_NeedsProto(__aeabi_d2iz) \ - SymI_NeedsProto(__aeabi_d2lz) \ - SymI_NeedsProto(__aeabi_d2uiz) \ - SymI_NeedsProto(__aeabi_d2ulz) \ - SymI_NeedsProto(__aeabi_dadd) \ - SymI_NeedsProto(__aeabi_dcmpeq) \ - SymI_NeedsProto(__aeabi_dcmpge) \ - SymI_NeedsProto(__aeabi_dcmpgt) \ - SymI_NeedsProto(__aeabi_dcmple) \ - SymI_NeedsProto(__aeabi_dcmplt) \ - SymI_NeedsProto(__aeabi_dcmpun) \ - SymI_NeedsProto(__aeabi_ddiv) \ - SymI_NeedsProto(__aeabi_dmul) \ - SymI_NeedsProto(__aeabi_dneg) \ - SymI_NeedsProto(__aeabi_dsub) \ - SymI_NeedsProto(__aeabi_f2d) \ - SymI_NeedsProto(__aeabi_f2iz) \ - SymI_NeedsProto(__aeabi_f2lz) \ - SymI_NeedsProto(__aeabi_f2uiz) \ - SymI_NeedsProto(__aeabi_f2ulz) \ - SymI_NeedsProto(__aeabi_fadd) \ - SymI_NeedsProto(__aeabi_fcmpeq) \ - SymI_NeedsProto(__aeabi_fcmpge) \ - SymI_NeedsProto(__aeabi_fcmpgt) \ - SymI_NeedsProto(__aeabi_fcmple) \ - SymI_NeedsProto(__aeabi_fcmplt) \ - SymI_NeedsProto(__aeabi_fcmpun) \ - SymI_NeedsProto(__aeabi_fdiv) \ - SymI_NeedsProto(__aeabi_fmul) \ - SymI_NeedsProto(__aeabi_fneg) \ - SymI_NeedsProto(__aeabi_fsub) \ - SymI_NeedsProto(__aeabi_i2d) \ - SymI_NeedsProto(__aeabi_i2f) \ - SymI_NeedsProto(__aeabi_idiv) \ - SymI_NeedsProto(__aeabi_idivmod) \ - SymI_NeedsProto(__aeabi_l2d) \ - SymI_NeedsProto(__aeabi_l2f) \ - SymI_NeedsProto(__aeabi_lasr) \ - SymI_NeedsProto(__aeabi_lcmp) \ - SymI_NeedsProto(__aeabi_ldivmod) \ - SymI_NeedsProto(__aeabi_llsl) \ - SymI_NeedsProto(__aeabi_llsr) \ - SymI_NeedsProto(__aeabi_lmul) \ - SymI_NeedsProto(__aeabi_ui2d) \ - SymI_NeedsProto(__aeabi_ui2f) \ - SymI_NeedsProto(__aeabi_uidiv) \ - SymI_NeedsProto(__aeabi_uidivmod) \ - SymI_NeedsProto(__aeabi_ul2d) \ - SymI_NeedsProto(__aeabi_ul2f) \ - SymI_NeedsProto(__aeabi_ulcmp) \ - SymI_NeedsProto(__aeabi_uldivmod) -#define RTS_LIBGCC_SYMBOLS_64 \ +#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) +#define RTS_LIBGCC_SYMBOLS \ + SymI_NeedsProto(__divdi3) \ + SymI_NeedsProto(__udivdi3) \ + SymI_NeedsProto(__moddi3) \ + SymI_NeedsProto(__umoddi3) \ + SymI_NeedsProto(__muldi3) \ + SymI_NeedsProto(__ashldi3) \ + SymI_NeedsProto(__ashrdi3) \ + SymI_NeedsProto(__lshrdi3) \ + SymI_NeedsProto(__fixunsdfdi) +#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 +#define RTS_LIBGCC_SYMBOLS \ SymI_NeedsProto(__udivti3) \ SymI_NeedsProto(__umodti3) - -/* for aarch64 */ -#define RTS_LIBGCC_SYMBOLS_aarch64 \ - SymI_NeedsProto(__netf2) \ - SymI_NeedsProto(__addtf3) \ - SymI_NeedsProto(__subtf3) \ - SymI_NeedsProto(__multf3) \ - SymI_NeedsProto(__extenddftf2) \ - SymI_NeedsProto(__fixtfsi) \ - SymI_NeedsProto(__fixunstfsi) \ - SymI_NeedsProto(__floatsitf) \ - SymI_NeedsProto(__floatunsitf) - -#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && defined(arm_HOST_OS) -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 RTS_LIBGCC_SYMBOLS_aarch32 -#elif defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 -#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 && defined(aarch64_HOST_OS) -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 RTS_LIBGCC_SYMBOLS_aarch64 -#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 #else #define RTS_LIBGCC_SYMBOLS #endif -#if !defined(mingw32_HOST_OS) && !defined(DYNAMIC) && (defined(_FORTIFY_SOURCE) || defined(__SSP__)) -#define RTS_SSP_SYMBOLS \ - SymI_NeedsProto(__stack_chk_guard) \ - SymI_NeedsProto(__stack_chk_fail) -#else -#define RTS_SSP_SYMBOLS -#endif -#if !defined(DYNAMIC) && defined(linux_HOST_OS) -// we need these for static musl builds. However when -// linking shared objects (DLLs) this will fail, hence -// we do not include them when building with -DDYNAMIC -#define RTS_LINKER_SYMBOLS \ - SymI_NeedsProto(__fini_array_start) \ - SymI_NeedsProto(__fini_array_end) -#else -#define RTS_LINKER_SYMBOLS -#endif - -#if defined(darwin_HOST_OS) && defined(powerpc_HOST_ARCH) - // Symbols that don't have a leading underscore - // on Mac OS X. They have to receive special treatment, - // see machoInitSymbolsWithoutUnderscore() -#define RTS_MACHO_NOUNDERLINE_SYMBOLS \ - SymI_NeedsProto(saveFP) \ - SymI_NeedsProto(restFP) -#endif - /* entirely bogus claims about types of these symbols */ -/* to prevent a bit of define expansion, SymI_NeedsProto is a variadic - * macro. And we'll concat vvv with the __VA_ARGS__. This prevents - * vvv from getting macro expanded. - */ -#define SymI_NeedsProto(vvv,...) extern void vvv ## __VA_ARGS__ (void); +#define SymI_NeedsProto(vvv) extern void vvv(void); #define SymI_NeedsDataProto(vvv) extern StgWord vvv[]; #if defined(COMPILING_WINDOWS_DLL) #define SymE_HasProto(vvv) SymE_HasProto(vvv); @@ -1226,8 +1043,6 @@ RTS_DARWIN_ONLY_SYMBOLS RTS_OPENBSD_ONLY_SYMBOLS RTS_LIBGCC_SYMBOLS RTS_LIBFFI_SYMBOLS -RTS_SSP_SYMBOLS -RTS_LINKER_SYMBOLS #undef SymI_NeedsProto #undef SymI_NeedsDataProto #undef SymI_HasProto @@ -1247,7 +1062,7 @@ RTS_LINKER_SYMBOLS #define SymE_HasDataProto(vvv) \ SymE_HasProto(vvv) -#define SymI_NeedsProto(vvv,...) SymI_HasProto(vvv ## __VA_ARGS__) +#define SymI_NeedsProto(vvv) SymI_HasProto(vvv) #define SymI_NeedsDataProto(vvv) SymI_HasDataProto(vvv) #define SymE_NeedsProto(vvv) SymE_HasProto(vvv) #define SymE_NeedsDataProto(vvv) SymE_HasDataProto(vvv) @@ -1268,8 +1083,6 @@ RTS_LINKER_SYMBOLS #define SymI_HasProto_deprecated(vvv) \ { #vvv, (void*)0xBAADF00D, true }, -void *RTS_DYNAMIC = NULL; - RtsSymbolVal rtsSyms[] = { RTS_SYMBOLS RTS_RET_SYMBOLS @@ -1281,14 +1094,11 @@ RtsSymbolVal rtsSyms[] = { RTS_LIBGCC_SYMBOLS RTS_LIBFFI_SYMBOLS SymI_HasDataProto(nonmoving_write_barrier_enabled) - RTS_SSP_SYMBOLS - RTS_LINKER_SYMBOLS #if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH) // dyld stub code contains references to this, // but it should never be called because we treat // lazy pointers as nonlazy. { "dyld_stub_binding_helper", (void*)0xDEADBEEF, false }, #endif - { "_DYNAMIC", (void*)(&RTS_DYNAMIC), false }, { 0, 0, false } /* sentinel */ }; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d114cd4737b90cf4152662df008ec443955f19b5...863c544c9849e49872acac64b8faea56a3311564 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d114cd4737b90cf4152662df008ec443955f19b5...863c544c9849e49872acac64b8faea56a3311564 You're receiving 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 Jul 21 12:52:51 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Tue, 21 Jul 2020 08:52:51 -0400 Subject: [Git][ghc/ghc][wip/T18478] 15 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f16e52356e8_80b3f84901582f04284211@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18478 at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - af5dd3e1 by Sebastian Graf at 2020-07-21T08:52:49-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/phases.rst - docs/users_guide/runtime_control.rst - hadrian/hadrian.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39a5ed5e2fb0cf042365814a03822491e61af463...af5dd3e15364cede906b316159edc5c9341321cf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39a5ed5e2fb0cf042365814a03822491e61af463...af5dd3e15364cede906b316159edc5c9341321cf You're receiving 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 Jul 21 13:19:37 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Tue, 21 Jul 2020 09:19:37 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] Skip WIP test Message-ID: <5f16eb6993e43_80b3f84901582f04286734@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: b1f64575 by Sven Tennie at 2020-07-21T15:19:25+02:00 Skip WIP test (Red on CI) - - - - - 1 changed file: - libraries/ghc-heap/tests/all.T Changes: ===================================== libraries/ghc-heap/tests/all.T ===================================== @@ -54,7 +54,10 @@ test('prof_info', [extra_files(['create_tso.c','create_tso.h']), ignore_stdout, ignore_stderr, +# TODO: Fix the test + skip, extra_ways(['prof']), only_ways(prof_ways) ], +# TODO: Remove DWARF flags multi_compile_and_run, ['prof_info', [('create_tso.c','-optc=-g -opta=-g')], '-prof']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b1f645755a391686da8b0278664dafbdd3e613ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b1f645755a391686da8b0278664dafbdd3e613ba You're receiving 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 Jul 21 13:53:48 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 21 Jul 2020 09:53:48 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] Cross Test Suite Message-ID: <5f16f36c6a651_80b3f849c40b20c4295457@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 3e387045 by Moritz Angermann at 2020-07-21T21:35:55+08:00 Cross Test Suite This introduces the ability to test cross compilers agains the testsuite as well. This is achieved by disabling some tests that make no sense in a cross compilation setting, or simply can not be made to cross compile proplery. The fundamental idea is that we can run produced binaries through a TEST_WRAPPER, if provided. This could be qemu in user mode, or wine, or nodejs, or anything that could transparrently run the executable build product on the build machine. - - - - - 30 changed files: - libraries/base/tests/IO/Makefile - libraries/base/tests/IO/T12010/Makefile - libraries/base/tests/Numeric/all.T - libraries/base/tests/all.T - testsuite/config/ghc - + testsuite/driver/id - testsuite/driver/runtests.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/mk/boilerplate.mk - testsuite/mk/ghc-config.hs - testsuite/mk/test.mk - testsuite/tests/annotations/should_fail/all.T - testsuite/tests/annotations/should_run/all.T - testsuite/tests/backpack/cabal/T14304/Makefile - testsuite/tests/backpack/cabal/T15594/Makefile - testsuite/tests/backpack/cabal/T16219/Makefile - testsuite/tests/backpack/cabal/bkpcabal01/Makefile - testsuite/tests/backpack/cabal/bkpcabal02/Makefile - testsuite/tests/backpack/cabal/bkpcabal03/Makefile - testsuite/tests/backpack/cabal/bkpcabal04/Makefile - testsuite/tests/backpack/cabal/bkpcabal05/Makefile - testsuite/tests/backpack/cabal/bkpcabal06/Makefile - testsuite/tests/backpack/cabal/bkpcabal07/Makefile - testsuite/tests/cabal/T12733/Makefile - testsuite/tests/cabal/cabal01/Makefile - testsuite/tests/cabal/cabal01/all.T - testsuite/tests/cabal/cabal03/Makefile - testsuite/tests/cabal/cabal04/Makefile - testsuite/tests/cabal/cabal04/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e3870455683fe98f4155404f4fb95e04b9f9620 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e3870455683fe98f4155404f4fb95e04b9f9620 You're receiving 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 Jul 21 15:37:36 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Tue, 21 Jul 2020 11:37:36 -0400 Subject: [Git][ghc/ghc][wip/andreask/remove_dict_field_flag] 5 commits: Revert "AArch32 symbols only on aarch32." Message-ID: <5f170bc0822e1_80bd68a9b84319236@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/remove_dict_field_flag at Glasgow Haskell Compiler / GHC Commits: 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - dc67f215 by Andreas Klebinger at 2020-07-21T17:37:23+02:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - docs/users_guide/using-optimisation.rst - rts/RtsSymbols.c Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -486,8 +486,9 @@ dmdTransform env var dmd | isDataConWorkId var = dmdTransformDataConSig (idArity var) dmd -- Dictionary component selectors - | gopt Opt_DmdTxDictSel (ae_dflags env), - Just _ <- isClassOpId_maybe var + -- Used to be controlled by a flag. + -- See #18429 for some perf measurements. + | Just _ <- isClassOpId_maybe var = dmdTransformDictSelSig (idStrictness var) dmd -- Imported functions | isGlobalId var ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -188,7 +188,8 @@ data GeneralFlag | Opt_OmitYields | Opt_FunToThunk -- allow GHC.Core.Opt.WorkWrap.Utils.mkWorkerArgs to remove all value lambdas | Opt_DictsStrict -- be strict in argument dictionaries - | Opt_DmdTxDictSel -- use a special demand transformer for dictionary selectors + | Opt_DmdTxDictSel -- ^ deprecated, no effect and behaviour is now default. + -- Allowed switching of a special demand transformer for dictionary selectors | Opt_Loopification -- See Note [Self-recursive tail calls] | Opt_CfgBlocklayout -- ^ Use the cfg based block layout algorithm. | Opt_WeightlessBlocklayout -- ^ Layout based on last instruction per block. ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3513,7 +3513,8 @@ fFlagsDeps = [ flagSpec "diagnostics-show-caret" Opt_DiagnosticsShowCaret, flagSpec "dicts-cheap" Opt_DictsCheap, flagSpec "dicts-strict" Opt_DictsStrict, - flagSpec "dmd-tx-dict-sel" Opt_DmdTxDictSel, + depFlagSpec "dmd-tx-dict-sel" + Opt_DmdTxDictSel "effect is now unconditionally enabled", flagSpec "do-eta-reduction" Opt_DoEtaReduction, flagSpec "do-lambda-eta-expansion" Opt_DoLambdaEtaExpansion, flagSpec "eager-blackholing" Opt_EagerBlackHoling, @@ -4045,7 +4046,6 @@ optLevelFlags :: [([Int], GeneralFlag)] optLevelFlags -- see Note [Documenting optimisation flags] = [ ([0,1,2], Opt_DoLambdaEtaExpansion) , ([0,1,2], Opt_DoEtaReduction) -- See Note [Eta-reduction in -O0] - , ([0,1,2], Opt_DmdTxDictSel) , ([0,1,2], Opt_LlvmTBAA) , ([0], Opt_IgnoreInterfacePragmas) ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -353,8 +353,7 @@ by saying ``-fno-wombat``. Make dictionaries strict. .. ghc-flag:: -fdmd-tx-dict-sel - :shortdesc: Use a special demand transformer for dictionary selectors. - Always enabled by default. + :shortdesc: *(deprecated)* Use a special demand transformer for dictionary selectors. :type: dynamic :reverse: -fno-dmd-tx-dict-sel :category: @@ -362,6 +361,7 @@ by saying ``-fno-wombat``. :default: on Use a special demand transformer for dictionary selectors. + Behaviour is unconditionally enabled starting with 8.14 .. ghc-flag:: -fdo-eta-reduction :shortdesc: Enable eta-reduction. Implied by :ghc-flag:`-O`. ===================================== rts/RtsSymbols.c ===================================== @@ -59,6 +59,7 @@ SymI_HasProto(signal_handlers) \ SymI_HasProto(stg_sig_install) \ SymI_HasProto(rtsTimerSignal) \ + SymI_HasProto(atexit) \ SymI_NeedsDataProto(nocldstop) #endif @@ -993,213 +994,29 @@ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS + // 64-bit support functions in libgcc.a -// See https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc -#define RTS_LIBGCC_SYMBOLS_32 \ - SymI_NeedsProto(__fixunsdfdi) \ - /* 4 The GCC low-level runtime library */\ - /* 4.1.1 Arithmetic functions */\ - /* SymI_NeedsProto(__ashlsi3) */\ - SymI_NeedsProto(__ashldi3) \ - /* SymI_NeedsProto(__ashlti3) */\ - /* These functions return the result of shifting a left by b bits. */\ - /* SymI_NeedsProto(__ashrsi3) */\ - SymI_NeedsProto(__ashrdi3) \ - /* SymI_NeedsProto(__ashrti3) */\ - /* These functions return the result of arithmetically shifting a right by b bits. */\ - /* SymI_NeedsProto(__divsi3) */\ - SymI_NeedsProto(__divdi3) \ - /* SymI_NeedsProto(__divti3) */\ - /* These functions return the quotient of the signed division of a and b. */\ - /* SymI_NeedsProto(__lshrsi3) */ \ - SymI_NeedsProto(__lshrdi3) \ - /* SymI_NeedsProto(__lshrti3) */ \ - /* These functions return the result of logically shifting a right by b bits. */\ - /* SymI_NeedsProto(__modsi3) */ \ - SymI_NeedsProto(__moddi3) \ - /* SymI_NeedsProto(__modti3) */ \ - /* These functions return the remainder of the signed division of a and b. */\ - /* SymI_NeedsProto(__mulsi3) */ \ - SymI_NeedsProto(__muldi3) \ - /* SymI_NeedsProto(__multi3) */ \ - /* These functions return the product of a and b. */\ - SymI_NeedsProto(__negdi2) \ - /* SymI_NeedsProto(__negti2) */ \ - /* These functions return the negation of a. */\ - /* SymI_NeedsProto(__udivsi3) */ \ - SymI_NeedsProto(__udivdi3) \ - /* SymI_NeedsProto(__udivti3) */ \ - /* These functions return the quotient of the unsigned division of a and b. */\ - SymI_NeedsProto(__udivmoddi4) \ - /* SymI_NeedsProto(__udivmodti4) */ \ - /* These functions calculate both the quotient and remainder of the unsigned division of a and b. The return value is the quotient, and the remainder is placed in variable pointed to by c. */\ - /* SymI_NeedsProto(__umodsi3) */ \ - SymI_NeedsProto(__umoddi3) \ - /* SymI_NeedsProto(__umodti3) */ \ - /* These functions return the remainder of the unsigned division of a and b. */\ - /* 4.1.2 Comparison functions */\ - /* The following functions implement integral comparisons. These functions implement a low-level compare, upon which the higher level comparison operators (such as less than and greater than or equal to) can be constructed. The returned values lie in the range zero to two, to allow the high-level operators to be implemented by testing the returned result using either signed or unsigned comparison. */\ - SymI_NeedsProto(__cmpdi2) \ - /* SymI_NeedsProto(__cmpti2) */ \ - /* These functions perform a signed comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\ - SymI_NeedsProto(__ucmpdi2) \ - /* SymI_NeedsProto(__ucmpti2) */ \ - /* These functions perform an unsigned comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\ - /* 4.1.3 Trapping arithmetic functions */\ - /* The following functions implement trapping arithmetic. These functions call the libc function abort upon signed arithmetic overflow. */\ - SymI_NeedsProto(__absvsi2) \ - SymI_NeedsProto(__absvdi2) \ - /* These functions return the absolute value of a. */\ - /* SymI_NeedsProto(__addvsi3) */ \ - SymI_NeedsProto(__addvdi3) \ - /* These functions return the sum of a and b; that is a + b. */\ - /* SymI_NeedsProto(__mulvsi3) */ \ - SymI_NeedsProto(__mulvdi3) \ - /* The functions return the product of a and b; that is a * b. */\ - SymI_NeedsProto(__negvsi2) \ - SymI_NeedsProto(__negvdi2) \ - /* These functions return the negation of a; that is -a. */\ - /* SymI_NeedsProto(__subvsi3) */ \ - SymI_NeedsProto(__subvdi3) \ - /* These functions return the difference between b and a; that is a - b. */\ - /* 4.1.4 Bit operations */\ - SymI_NeedsProto(__clzsi2) \ - SymI_NeedsProto(__clzdi2) \ - /* SymI_NeedsProto(__clzti2) */ \ - /* These functions return the number of leading 0-bits in a, starting at the most significant bit position. If a is zero, the result is undefined. */\ - SymI_NeedsProto(__ctzsi2) \ - SymI_NeedsProto(__ctzdi2) \ - /* SymI_NeedsProto(__ctzti2) */ \ - /* These functions return the number of trailing 0-bits in a, starting at the least significant bit position. If a is zero, the result is undefined. */\ - SymI_NeedsProto(__ffsdi2) \ - /* SymI_NeedsProto(__ffsti2) */ \ - /* These functions return the index of the least significant 1-bit in a, or the value zero if a is zero. The least significant bit is index one. */\ - SymI_NeedsProto(__paritysi2) \ - SymI_NeedsProto(__paritydi2) \ - /* SymI_NeedsProto(__parityti2) */\ - /* These functions return the value zero if the number of bits set in a is even, and the value one otherwise. */\ - SymI_NeedsProto(__popcountsi2) \ - SymI_NeedsProto(__popcountdi2) \ - /* SymI_NeedsProto(__popcountti2) */ \ - /* These functions return the number of bits set in a. */\ - SymI_NeedsProto(__bswapsi2) \ - SymI_NeedsProto(__bswapdi2) -#define RTS_LIBGCC_SYMBOLS_aarch32 \ - /* armv6l */\ - /* TODO: should check for __ARM_EABI__ */\ - SymI_NeedsProto(__aeabi_d2f) \ - SymI_NeedsProto(__aeabi_d2iz) \ - SymI_NeedsProto(__aeabi_d2lz) \ - SymI_NeedsProto(__aeabi_d2uiz) \ - SymI_NeedsProto(__aeabi_d2ulz) \ - SymI_NeedsProto(__aeabi_dadd) \ - SymI_NeedsProto(__aeabi_dcmpeq) \ - SymI_NeedsProto(__aeabi_dcmpge) \ - SymI_NeedsProto(__aeabi_dcmpgt) \ - SymI_NeedsProto(__aeabi_dcmple) \ - SymI_NeedsProto(__aeabi_dcmplt) \ - SymI_NeedsProto(__aeabi_dcmpun) \ - SymI_NeedsProto(__aeabi_ddiv) \ - SymI_NeedsProto(__aeabi_dmul) \ - SymI_NeedsProto(__aeabi_dneg) \ - SymI_NeedsProto(__aeabi_dsub) \ - SymI_NeedsProto(__aeabi_f2d) \ - SymI_NeedsProto(__aeabi_f2iz) \ - SymI_NeedsProto(__aeabi_f2lz) \ - SymI_NeedsProto(__aeabi_f2uiz) \ - SymI_NeedsProto(__aeabi_f2ulz) \ - SymI_NeedsProto(__aeabi_fadd) \ - SymI_NeedsProto(__aeabi_fcmpeq) \ - SymI_NeedsProto(__aeabi_fcmpge) \ - SymI_NeedsProto(__aeabi_fcmpgt) \ - SymI_NeedsProto(__aeabi_fcmple) \ - SymI_NeedsProto(__aeabi_fcmplt) \ - SymI_NeedsProto(__aeabi_fcmpun) \ - SymI_NeedsProto(__aeabi_fdiv) \ - SymI_NeedsProto(__aeabi_fmul) \ - SymI_NeedsProto(__aeabi_fneg) \ - SymI_NeedsProto(__aeabi_fsub) \ - SymI_NeedsProto(__aeabi_i2d) \ - SymI_NeedsProto(__aeabi_i2f) \ - SymI_NeedsProto(__aeabi_idiv) \ - SymI_NeedsProto(__aeabi_idivmod) \ - SymI_NeedsProto(__aeabi_l2d) \ - SymI_NeedsProto(__aeabi_l2f) \ - SymI_NeedsProto(__aeabi_lasr) \ - SymI_NeedsProto(__aeabi_lcmp) \ - SymI_NeedsProto(__aeabi_ldivmod) \ - SymI_NeedsProto(__aeabi_llsl) \ - SymI_NeedsProto(__aeabi_llsr) \ - SymI_NeedsProto(__aeabi_lmul) \ - SymI_NeedsProto(__aeabi_ui2d) \ - SymI_NeedsProto(__aeabi_ui2f) \ - SymI_NeedsProto(__aeabi_uidiv) \ - SymI_NeedsProto(__aeabi_uidivmod) \ - SymI_NeedsProto(__aeabi_ul2d) \ - SymI_NeedsProto(__aeabi_ul2f) \ - SymI_NeedsProto(__aeabi_ulcmp) \ - SymI_NeedsProto(__aeabi_uldivmod) -#define RTS_LIBGCC_SYMBOLS_64 \ +#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) +#define RTS_LIBGCC_SYMBOLS \ + SymI_NeedsProto(__divdi3) \ + SymI_NeedsProto(__udivdi3) \ + SymI_NeedsProto(__moddi3) \ + SymI_NeedsProto(__umoddi3) \ + SymI_NeedsProto(__muldi3) \ + SymI_NeedsProto(__ashldi3) \ + SymI_NeedsProto(__ashrdi3) \ + SymI_NeedsProto(__lshrdi3) \ + SymI_NeedsProto(__fixunsdfdi) +#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 +#define RTS_LIBGCC_SYMBOLS \ SymI_NeedsProto(__udivti3) \ SymI_NeedsProto(__umodti3) - -/* for aarch64 */ -#define RTS_LIBGCC_SYMBOLS_aarch64 \ - SymI_NeedsProto(__netf2) \ - SymI_NeedsProto(__addtf3) \ - SymI_NeedsProto(__subtf3) \ - SymI_NeedsProto(__multf3) \ - SymI_NeedsProto(__extenddftf2) \ - SymI_NeedsProto(__fixtfsi) \ - SymI_NeedsProto(__fixunstfsi) \ - SymI_NeedsProto(__floatsitf) \ - SymI_NeedsProto(__floatunsitf) - -#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && defined(arm_HOST_OS) -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 RTS_LIBGCC_SYMBOLS_aarch32 -#elif defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 -#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 && defined(aarch64_HOST_OS) -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 RTS_LIBGCC_SYMBOLS_aarch64 -#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 -#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 #else #define RTS_LIBGCC_SYMBOLS #endif -#if !defined(mingw32_HOST_OS) && !defined(DYNAMIC) && (defined(_FORTIFY_SOURCE) || defined(__SSP__)) -#define RTS_SSP_SYMBOLS \ - SymI_NeedsProto(__stack_chk_guard) \ - SymI_NeedsProto(__stack_chk_fail) -#else -#define RTS_SSP_SYMBOLS -#endif -#if !defined(DYNAMIC) && defined(linux_HOST_OS) -// we need these for static musl builds. However when -// linking shared objects (DLLs) this will fail, hence -// we do not include them when building with -DDYNAMIC -#define RTS_LINKER_SYMBOLS \ - SymI_NeedsProto(__fini_array_start) \ - SymI_NeedsProto(__fini_array_end) -#else -#define RTS_LINKER_SYMBOLS -#endif - -#if defined(darwin_HOST_OS) && defined(powerpc_HOST_ARCH) - // Symbols that don't have a leading underscore - // on Mac OS X. They have to receive special treatment, - // see machoInitSymbolsWithoutUnderscore() -#define RTS_MACHO_NOUNDERLINE_SYMBOLS \ - SymI_NeedsProto(saveFP) \ - SymI_NeedsProto(restFP) -#endif - /* entirely bogus claims about types of these symbols */ -/* to prevent a bit of define expansion, SymI_NeedsProto is a variadic - * macro. And we'll concat vvv with the __VA_ARGS__. This prevents - * vvv from getting macro expanded. - */ -#define SymI_NeedsProto(vvv,...) extern void vvv ## __VA_ARGS__ (void); +#define SymI_NeedsProto(vvv) extern void vvv(void); #define SymI_NeedsDataProto(vvv) extern StgWord vvv[]; #if defined(COMPILING_WINDOWS_DLL) #define SymE_HasProto(vvv) SymE_HasProto(vvv); @@ -1226,8 +1043,6 @@ RTS_DARWIN_ONLY_SYMBOLS RTS_OPENBSD_ONLY_SYMBOLS RTS_LIBGCC_SYMBOLS RTS_LIBFFI_SYMBOLS -RTS_SSP_SYMBOLS -RTS_LINKER_SYMBOLS #undef SymI_NeedsProto #undef SymI_NeedsDataProto #undef SymI_HasProto @@ -1247,7 +1062,7 @@ RTS_LINKER_SYMBOLS #define SymE_HasDataProto(vvv) \ SymE_HasProto(vvv) -#define SymI_NeedsProto(vvv,...) SymI_HasProto(vvv ## __VA_ARGS__) +#define SymI_NeedsProto(vvv) SymI_HasProto(vvv) #define SymI_NeedsDataProto(vvv) SymI_HasDataProto(vvv) #define SymE_NeedsProto(vvv) SymE_HasProto(vvv) #define SymE_NeedsDataProto(vvv) SymE_HasDataProto(vvv) @@ -1268,8 +1083,6 @@ RTS_LINKER_SYMBOLS #define SymI_HasProto_deprecated(vvv) \ { #vvv, (void*)0xBAADF00D, true }, -void *RTS_DYNAMIC = NULL; - RtsSymbolVal rtsSyms[] = { RTS_SYMBOLS RTS_RET_SYMBOLS @@ -1281,14 +1094,11 @@ RtsSymbolVal rtsSyms[] = { RTS_LIBGCC_SYMBOLS RTS_LIBFFI_SYMBOLS SymI_HasDataProto(nonmoving_write_barrier_enabled) - RTS_SSP_SYMBOLS - RTS_LINKER_SYMBOLS #if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH) // dyld stub code contains references to this, // but it should never be called because we treat // lazy pointers as nonlazy. { "dyld_stub_binding_helper", (void*)0xDEADBEEF, false }, #endif - { "_DYNAMIC", (void*)(&RTS_DYNAMIC), false }, { 0, 0, false } /* sentinel */ }; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7cdd38a7d542d6a9c42198df13aa2fb9f02d3e9b...dc67f215de1a74c5127af4828828ed1823dc1299 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7cdd38a7d542d6a9c42198df13aa2fb9f02d3e9b...dc67f215de1a74c5127af4828828ed1823dc1299 You're receiving 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 Jul 21 15:53:53 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 21 Jul 2020 11:53:53 -0400 Subject: [Git][ghc/ghc][wip/T18272] 383 commits: Cleanup OVERWRITING_CLOSURE logic Message-ID: <5f170f911d9e6_80b3f8492541234433205c@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18272 at Glasgow Haskell Compiler / GHC Commits: 2ee4f36c by Daniel Gröber at 2020-06-01T06:32:56-04:00 Cleanup OVERWRITING_CLOSURE logic The code is just more confusing than it needs to be. We don't need to mix the threaded check with the ldv profiling check since ldv's init already checks for this. Hence they can be two separate checks. Taking the sanity checking into account is also cleaner via DebugFlags.sanity. No need for checking the DEBUG define. The ZERO_SLOP_FOR_LDV_PROF and ZERO_SLOP_FOR_SANITY_CHECK definitions the old code had also make things a lot more opaque IMO so I removed those. - - - - - 6159559b by Daniel Gröber at 2020-06-01T06:32:56-04:00 Fix OVERWRITING_CLOSURE assuming closures are not inherently used The new ASSERT in LDV_recordDead() was being tripped up by MVars when removeFromMVarBlockedQueue() calls OVERWRITING_CLOSURE() via OVERWRITE_INFO(). - - - - - 38992085 by Daniel Gröber at 2020-06-01T06:32:56-04:00 Always zero shrunk mutable array slop when profiling When shrinking arrays in the profiling way we currently don't always zero the leftover slop. This means we can't traverse such closures in the heap profiler. The old Note [zeroing slop] and #8402 have some rationale for why this is so but I belive the reasoning doesn't apply to mutable closures. There users already have to ensure multiple threads don't step on each other's toes so zeroing should be safe. - - - - - b0c1f2a6 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for #18151 - - - - - 9a99a178 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for desugaring of PostfixOperators - - - - - 2b89ca5b by Ben Gamari at 2020-06-01T06:33:37-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. - - - - - d412d7a3 by Kirill Elagin at 2020-06-01T06:34:21-04:00 Winferred-safe-imports: Do not exit with error Currently, when -Winferred-safe-imports is enabled, even when it is not turned into an error, the compiler will still exit with exit code 1 if this warning was emitted. Make sure it is really treated as a warning. - - - - - f945eea5 by Ben Gamari at 2020-06-01T06:34:58-04:00 nonmoving: Optimise log2_ceil - - - - - aab606e4 by Bodigrim at 2020-06-01T06:35:36-04:00 Clarify description of fromListN - - - - - 7e5220e2 by Bodigrim at 2020-06-01T06:35:36-04:00 Apply suggestion to libraries/base/GHC/Exts.hs - - - - - f3fb1ce9 by fendor at 2020-06-01T06:36:18-04:00 Add `isInScope` check to `lintCoercion` Mirrors the behaviour of `lintType`. - - - - - 5ac4d946 by fendor at 2020-06-01T06:36:18-04:00 Lint rhs of IfaceRule - - - - - 1cef6126 by Jeremy Schlatter at 2020-06-01T06:37:00-04:00 Fix wording in documentation The duplicate "orphan instance" phrase here doesn't make sense, and was probably an accident. - - - - - 5aaf08f2 by Takenobu Tani at 2020-06-01T06:37:43-04:00 configure: Modify aclocal.m4 according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * Rename: * compiler/GHC/Parser.hs <= compiler/parser/Parser.hs * compiler/GHC/Parser/Lexer.hs <= compiler/Parser/Lexer.hs * Add: * compiler/GHC/Cmm/Lexer.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular - - - - - 15857ad8 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Don't fail if we can't unlink __symlink_test Afterall, it's possible we were unable to create it due to lack of symlink permission. - - - - - 4a7229ef by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Refactor ghostscript detection Tamar reported that he saw crashes due to unhandled exceptions. - - - - - 2ab37eaf by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/perf_notes: Fix ill-typed assignments - - - - - e45d5b66 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/testutil: Fix bytes/str mismatch - - - - - 7002d0cb by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Work around spurious mypy failure - - - - - 11390e3a by Takenobu Tani at 2020-06-01T06:39:05-04:00 Clean up file paths for new module hierarchy This updates comments only. This patch replaces file references according to new module hierarchy. See also: * https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular * https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 8f2e5732 by Takenobu Tani at 2020-06-01T06:39:05-04:00 Modify file paths to module paths for new module hierarchy This updates comments only. This patch replaces module references according to new module hierarchy [1][2]. For files under the `compiler/` directory, I replace them as module paths instead of file paths. For instance, `GHC.Unit.State` instead of `compiler/GHC/Unit/State.hs` [3]. For current and future haddock's markup, this patch encloses the module name with "" [4]. [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 [3]: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3375#note_276613 [4]: https://haskell-haddock.readthedocs.io/en/latest/markup.html#linking-to-modules - - - - - 68b71c4a by Tom Ellis at 2020-06-01T06:39:55-04:00 Rename the singleton tuple GHC.Tuple.Unit to GHC.Tuple.Solo - - - - - 95da76c2 by Sylvain Henry at 2020-06-01T06:40:41-04:00 Hadrian: fix binary-dist target for cross-compilation - - - - - 730fcd54 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for the @-operator Since GHC diverges from the Haskell Report by allowing the user to define (@) as an infix operator, we better give a good error message when the user does so unintentionally. In general, this is rather hard to do, as some failures will be discovered only in the renamer or the type checker: x :: (Integer, Integer) x @ (a, b) = (1, 2) This patch does *not* address this general case. However, it gives much better error messages when the binding is not syntactically valid: pairs xs @ (_:xs') = zip xs xs' Before this patch, the error message was rather puzzling: <interactive>:1:1: error: Parse error in pattern: pairs After this patch, the error message includes a hint: <interactive>:1:1: error: Parse error in pattern: pairs In a function binding for the ‘@’ operator. Perhaps you meant an as-pattern, which must not be surrounded by whitespace - - - - - 0fde5377 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TypeApplications With this patch, we always parse f @t as a type application, thereby producing better error messages. This steals two syntactic forms: * Prefix form of the @-operator in expressions. Since the @-operator is a divergence from the Haskell Report anyway, this is not a major loss. * Prefix form of @-patterns. Since we are stealing loose infix form anyway, might as well sacrifice the prefix form for the sake of much better error messages. - - - - - c68e7e1e by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TemplateHaskellQuotes While [e| |], [t| |], [d| |], and so on, steal syntax from list comprehensions, [| |] and [|| ||] do not steal any syntax. Thus we can improve error messages by always accepting them in the lexer. Turns out the renamer already performs necessary validation. - - - - - 120aedbd by Ben Gamari at 2020-06-01T16:07:02-04:00 gitlab-ci: Disable use of ld.lld on ARMv7 It turns out that lld non-deterministically fails on ARMv7. I suspect this may be due to the a kernel regression as this only started happening when we upgraded to 5.4. Nevertheless, easily avoided by simply sticking with gold. Works around #18280. - - - - - d6279ff0 by Ben Gamari at 2020-06-02T13:03:30-04:00 gitlab-ci: Ensure that workaround for #18280 applies to bindisttest We need to ensure that the `configure` flags working around #18280 are propagated to the bindisttest `configure` as well. - - - - - cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00 gitlab-ci: Allow ARMv7 job to fail Due to #18298. - - - - - 32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00 Clean up boot vs non-boot disambiguating types We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule. - - - - - c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00 docs: Add more details on InterruptibleFFI. Details from https://gitlab.haskell.org/ghc/ghc/issues/8684 and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430 - - - - - 1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00 Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr. MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd. This regression did not make it into a release of GHC. Here, the original behavior is restored, and FinalPtr is given the same treatment as PlainPtr. - - - - - 2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00 Fix documentation on type families not being extracted It looks like the location of the Names used for CoAxioms on type families are now located at their type constructors. Previously, Docs.hs thought the Names were located in the RHS, so the RealSrcSpan in the instanceMap and getInstLoc didn't match up. Fixes #18241 - - - - - 6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00 GHC.Hs.Instances: Compile with -O0 This module contains exclusively Data instances, which are going to be slow no matter what we do. Furthermore, they are incredibly slow to compile with optimisation (see #9557). Consequently we compile this with -O0. See #18254. - - - - - c330331a by nineonine at 2020-06-04T04:37:59-04:00 Add test for #17669 - - - - - cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00 rts: Add Windows-specific implementation of rtsSleep Previously we would use the POSIX path, which uses `nanosleep`. However, it turns out that `nanosleep` is provided by `libpthread` on Windows. In general we don't want to incur such a dependency. Avoid this by simply using `Sleep` on Windows. Fixes #18272. - - - - - ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00 compiler: Disable use of process jobs with process < 1.6.9 Due to #17926. - - - - - 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/test-metrics.sh - .gitmodules - Makefile - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Node.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/58fad7d43479766f3a66dd1ef9cc4edbe84ff372...0dd405529f0f17cd9a5b299e7ae5539a885b4b5a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/58fad7d43479766f3a66dd1ef9cc4edbe84ff372...0dd405529f0f17cd9a5b299e7ae5539a885b4b5a You're receiving 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 Jul 21 15:55:54 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Tue, 21 Jul 2020 11:55:54 -0400 Subject: [Git][ghc/ghc][wip/andreask/strict_dicts] 181 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f17100acc469_80b104edf444332781@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/strict_dicts at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - b8c212b9 by Andreas Klebinger at 2020-07-21T17:53:46+02:00 Enable strict dicts by default at -O2. In the common case this is a straight performance win at a compile time cost so we enable it at -O2. In rare cases it can lead to compile time regressions because of changed inlining behaviour. Which can very rarely also affect runtime performance. Increasing the inlining threshold can help to avoid this which is documented in the user guide. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - Makefile - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3a60e34a0a78f6917b03d960f3393058cbb83b7f...b8c212b98fe949feccbc4788cabedd3562fec842 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3a60e34a0a78f6917b03d960f3393058cbb83b7f...b8c212b98fe949feccbc4788cabedd3562fec842 You're receiving 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 Jul 21 18:02:13 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Tue, 21 Jul 2020 14:02:13 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] Add missing module to ghc-heap.cabal Message-ID: <5f172da536d7c_80b104edf4443656c@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: 78805aaf by Sven Tennie at 2020-07-21T20:01:58+02:00 Add missing module to ghc-heap.cabal - - - - - 1 changed file: - libraries/ghc-heap/ghc-heap.cabal.in Changes: ===================================== libraries/ghc-heap/ghc-heap.cabal.in ===================================== @@ -46,3 +46,4 @@ library GHC.Exts.Heap.ProfInfo.Types GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled + GHC.Exts.Heap.Ptr.Utils View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/78805aafece551dd06387b7a93a507a268fed3a4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/78805aafece551dd06387b7a93a507a268fed3a4 You're receiving 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 Jul 21 18:48:03 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 21 Jul 2020 14:48:03 -0400 Subject: [Git][ghc/ghc][master] 5 commits: DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) Message-ID: <5f173863837a8_80b3f84868c3828437704e@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Stg/DepAnal.hs - compiler/GHC/Stg/Lift.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/Stg/Pipeline.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Splice.hs - docs/users_guide/8.12.1-notes.rst - docs/users_guide/exts/deriving_extra.rst - docs/users_guide/exts/existential_quantification.rst - docs/users_guide/exts/template_haskell.rst - docs/users_guide/runtime_control.rst - libraries/template-haskell/Language/Haskell/TH.hs - + libraries/template-haskell/Language/Haskell/TH/CodeDo.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - libraries/template-haskell/template-haskell.cabal.in - libraries/text - testsuite/tests/deriving/should_compile/drv-empty-data.stderr - testsuite/tests/parser/should_compile/Proposal229f_instances.hs - testsuite/tests/partial-sigs/should_compile/TypedSplice.hs - testsuite/tests/partial-sigs/should_compile/TypedSplice.stderr - testsuite/tests/quotes/T17857.hs - testsuite/tests/th/T10945.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0dd405529f0f17cd9a5b299e7ae5539a885b4b5a...58235d46bd4e9fbf69bd82969b29cd9c6ab051e1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0dd405529f0f17cd9a5b299e7ae5539a885b4b5a...58235d46bd4e9fbf69bd82969b29cd9c6ab051e1 You're receiving 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 Jul 21 18:50:11 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 21 Jul 2020 14:50:11 -0400 Subject: [Git][ghc/ghc][master] Accumulate Haddock comments in P (#17544, #17561, #8944) Message-ID: <5f1738e32f9e5_80b3f84868c38284385136@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 23 changed files: - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/Stats.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Utils/Misc.hs - docs/users_guide/8.12.1-notes.rst - docs/users_guide/using-warnings.rst - testsuite/tests/ghc-api/T11579.hs - testsuite/tests/ghc-api/T11579.stdout - testsuite/tests/ghc-api/annotations/comments.stdout - testsuite/tests/haddock/should_compile_flag_haddock/T11768.hs - testsuite/tests/haddock/should_compile_flag_haddock/T11768.stderr - + testsuite/tests/haddock/should_compile_flag_haddock/T17544.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/19e80b9af252eee760dc047765a9930ef00067ec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/19e80b9af252eee760dc047765a9930ef00067ec You're receiving 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 Jul 21 18:52:20 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 21 Jul 2020 14:52:20 -0400 Subject: [Git][ghc/ghc][wip/win32-missing-tarball] 21 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f17396432962_80b3f84868c38284392761@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/win32-missing-tarball at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 8b9a4a1f by Ben Gamari at 2020-07-21T14:52:18-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 24 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Stats.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - 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/08b9ece7275f27d64ecd2d2a9efa69c9e6b6385b...8b9a4a1f458b17b0a7d830ec47a711bd2de498c8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/08b9ece7275f27d64ecd2d2a9efa69c9e6b6385b...8b9a4a1f458b17b0a7d830ec47a711bd2de498c8 You're receiving 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 Jul 21 18:59:06 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 21 Jul 2020 14:59:06 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/drop-win32 Message-ID: <5f173afa29c6e_80b114037a44407568@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/drop-win32 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/drop-win32 You're receiving 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 Jul 21 19:23:51 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 21 Jul 2020 15:23:51 -0400 Subject: [Git][ghc/ghc][ghc-8.12] 20 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f1740c7402c3_80b3f84962c9cf0441661a@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.12 at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 24 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Stats.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - 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/c0979cc53442b3a6202acab9cf164f0a4beea0b7...19e80b9af252eee760dc047765a9930ef00067ec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c0979cc53442b3a6202acab9cf164f0a4beea0b7...19e80b9af252eee760dc047765a9930ef00067ec You're receiving 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 Jul 21 19:25:07 2020 From: gitlab at gitlab.haskell.org (Brandon Chinn) Date: Tue, 21 Jul 2020 15:25:07 -0400 Subject: [Git][ghc/ghc][wip/T16341] 4 commits: Add regression test for #16341 Message-ID: <5f174113ef99_80bd68a9b844182f5@gitlab.haskell.org.mail> Brandon Chinn pushed to branch wip/T16341 at Glasgow Haskell Compiler / GHC Commits: 556f3cb7 by Brandon Chinn at 2020-07-21T12:24:59-07:00 Add regression test for #16341 - - - - - ce5eb2e5 by Brandon Chinn at 2020-07-21T12:24:59-07:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - 2b16976f by Brandon Chinn at 2020-07-21T12:24:59-07:00 Pass tc_args to gen_fn - - - - - decaba57 by Brandon Chinn at 2020-07-21T12:24:59-07:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - 5 changed files: - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - + testsuite/tests/deriving/should_compile/T16341.hs - testsuite/tests/deriving/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/Deriv.hs ===================================== @@ -2038,9 +2038,12 @@ genDerivStuff mechanism loc clas inst_tys tyvars -> gen_newtype_or_via rhs_ty -- Try a stock deriver - DerivSpecStock { dsm_stock_dit = DerivInstTys{dit_rep_tc = rep_tc} + DerivSpecStock { dsm_stock_dit = DerivInstTys + { dit_rep_tc = rep_tc + , dit_rep_tc_args = rep_tc_args + } , dsm_stock_gen_fn = gen_fn } - -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc inst_tys + -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc rep_tc_args inst_tys pure (binds, [], faminsts, field_names) -- Try DeriveAnyClass ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -212,14 +212,14 @@ for the instance decl, which it probably wasn't, so the decls produced don't get through the typechecker. -} -gen_Eq_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Eq_binds loc tycon = do +gen_Eq_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Eq_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon return (method_binds con2tag_RDR, aux_binds con2tag_RDR) where - all_cons = tyConDataCons tycon + all_cons = filter (not . dataConCannotMatch tycon_args) $ tyConDataCons tycon (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon all_cons -- If there are ten or more (arbitrary number) nullary constructors, @@ -396,8 +396,8 @@ gtResult OrdGE = true_Expr gtResult OrdGT = true_Expr ------------ -gen_Ord_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ord_binds loc tycon = do +gen_Ord_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ord_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon @@ -432,7 +432,7 @@ gen_Ord_binds loc tycon = do -- We want *zero-based* tags, because that's what -- con2Tag returns (generated by untag_Expr)! - tycon_data_cons = tyConDataCons tycon + tycon_data_cons = filter (not . dataConCannotMatch tycon_args) $ tyConDataCons tycon single_con_type = isSingleton tycon_data_cons (first_con : _) = tycon_data_cons (last_con : _) = reverse tycon_data_cons @@ -646,8 +646,8 @@ instance ... Enum (Foo ...) where For @enumFromTo@ and @enumFromThenTo@, we use the default methods. -} -gen_Enum_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Enum_binds loc tycon = do +gen_Enum_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Enum_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -825,9 +825,9 @@ we follow the scheme given in Figure~19 of the Haskell~1.2 report (p.~147). -} -gen_Ix_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ix_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ix_binds loc tycon = do +gen_Ix_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -1028,10 +1028,10 @@ These instances are also useful for Read (Either Int Emp), where we want to be able to parse (Left 3) just fine. -} -gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Read_binds get_fixity loc tycon +gen_Read_binds get_fixity loc tycon tycon_args = (listToBag [read_prec, default_readlist, default_readlistprec], emptyBag) where ----------------------------------------------------------------------- @@ -1042,7 +1042,7 @@ gen_Read_binds get_fixity loc tycon = mkHsVarBind loc readListPrec_RDR (nlHsVar readListPrecDefault_RDR) ----------------------------------------------------------------------- - data_cons = tyConDataCons tycon + data_cons = filter (not . dataConCannotMatch tycon_args) $ tyConDataCons tycon (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon data_cons read_prec = mkHsVarBind loc readPrec_RDR rhs @@ -1212,13 +1212,13 @@ Example -- the most tightly-binding operator -} -gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Show_binds get_fixity loc tycon +gen_Show_binds get_fixity loc tycon tycon_args = (unitBag shows_prec, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = filter (not . dataConCannotMatch tycon_args) $ tyConDataCons tycon shows_prec = mkFunBindEC 2 loc showsPrec_RDR id (map pats_etc data_cons) comma_space = nlHsVar showCommaSpace_RDR @@ -1385,9 +1385,10 @@ we generate gen_Data_binds :: SrcSpan -> TyCon -- For data families, this is the -- *representation* TyCon + -> [Type] -> TcM (LHsBinds GhcPs, -- The method bindings BagDerivStuff) -- Auxiliary bindings -gen_Data_binds loc rep_tc +gen_Data_binds loc rep_tc rep_tc_args = do { -- See Note [Auxiliary binders] dataT_RDR <- new_dataT_rdr_name loc rep_tc ; dataC_RDRs <- traverse (new_dataC_rdr_name loc) data_cons @@ -1403,7 +1404,7 @@ gen_Data_binds loc rep_tc data_cons dataC_RDRs ) ) } where - data_cons = tyConDataCons rep_tc + data_cons = filter (not . dataConCannotMatch rep_tc_args) $ tyConDataCons rep_tc n_cons = length data_cons one_constr = n_cons == 1 ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -218,8 +218,9 @@ data DerivSpecMechanism -- instance, including what type constructor the last argument is -- headed by. See @Note [DerivEnv and DerivSpecMechanism]@. , dsm_stock_gen_fn :: - SrcSpan -> TyCon - -> [Type] + SrcSpan -> TyCon -- dit_rep_tc + -> [Type] -- dit_rep_tc_args + -> [Type] -- inst_tys -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]) -- ^ This function returns three things: -- @@ -424,7 +425,7 @@ instance Outputable DerivContext where -- See @Note [Deriving strategies]@ in "GHC.Tc.Deriv". data OriginativeDerivStatus = CanDeriveStock -- Stock class, can derive - (SrcSpan -> TyCon -> [Type] + (SrcSpan -> TyCon -> [Type] -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) | StockClassError SDoc -- Stock class, but can't do it | CanDeriveAnyClass -- See Note [Deriving any class] @@ -563,6 +564,7 @@ hasStockDeriving :: Class -> Maybe (SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) hasStockDeriving clas = assocMaybe gen_list (getUnique clas) @@ -571,6 +573,7 @@ hasStockDeriving clas :: [(Unique, SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))] gen_list = [ (eqClassKey, simpleM gen_Eq_binds) , (ordClassKey, simpleM gen_Ord_binds) @@ -587,7 +590,7 @@ hasStockDeriving clas , (genClassKey, generic (gen_Generic_binds Gen0)) , (gen1ClassKey, generic (gen_Generic_binds Gen1)) ] - simple gen_fn loc tc _ + simple gen_fn loc tc _ _ = let (binds, deriv_stuff) = gen_fn loc tc in return (binds, deriv_stuff, []) @@ -595,17 +598,17 @@ hasStockDeriving clas -- do is allocate new Uniques, which are used for generating the names of -- auxiliary bindings. -- See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate. - simpleM gen_fn loc tc _ - = do { (binds, deriv_stuff) <- gen_fn loc tc + simpleM gen_fn loc tc tc_args _ + = do { (binds, deriv_stuff) <- gen_fn loc tc tc_args ; return (binds, deriv_stuff, []) } - read_or_show gen_fn loc tc _ + read_or_show gen_fn loc tc tc_args _ = do { fix_env <- getDataConFixityFun tc - ; let (binds, deriv_stuff) = gen_fn fix_env loc tc + ; let (binds, deriv_stuff) = gen_fn fix_env loc tc tc_args field_names = all_field_names tc ; return (binds, deriv_stuff, field_names) } - generic gen_fn _ tc inst_tys + generic gen_fn _ tc _ inst_tys = do { (binds, faminst) <- gen_fn tc inst_tys ; let field_names = all_field_names tc ; return (binds, unitBag (DerivFamInst faminst), field_names) } ===================================== testsuite/tests/deriving/should_compile/T16341.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE StandaloneDeriving #-} + +module T16341 where + +import Data.Data (Data) + +data Foo a where + X :: Foo Int + Y :: (Bool -> Bool) -> Foo Bool + +-- These instances should work whether or not `Y` is a constructor in +-- `Foo`, because the `Foo Int` designation precludes `Y` from being +-- a reachable constructor +deriving instance Show (Foo Int) +deriving instance Read (Foo Int) +deriving instance Eq (Foo Int) +deriving instance Ord (Foo Int) +deriving instance Data (Foo Int) ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -118,6 +118,7 @@ test('T15398', normal, compile, ['']) test('T15637', normal, compile, ['']) test('T15831', normal, compile, ['']) test('T16179', normal, compile, ['']) +test('T16341', normal, compile, ['']) test('T16518', normal, compile, ['']) test('T17324', normal, compile, ['']) test('T17339', normal, compile, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd5e1083d65d9259ab9c389b3404f5a60a55a5bc...decaba57ace9365947e8d3c3cc5c483adc86b456 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd5e1083d65d9259ab9c389b3404f5a60a55a5bc...decaba57ace9365947e8d3c3cc5c483adc86b456 You're receiving 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 Jul 22 01:23:28 2020 From: gitlab at gitlab.haskell.org (Brandon Chinn) Date: Tue, 21 Jul 2020 21:23:28 -0400 Subject: [Git][ghc/ghc][wip/T16341] 24 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f179510ad89c_80b3f84901582f044805c9@gitlab.haskell.org.mail> Brandon Chinn pushed to branch wip/T16341 at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - a8c2d9b5 by Brandon Chinn at 2020-07-21T18:23:23-07:00 Add regression test for #16341 - - - - - 6fc2ece2 by Brandon Chinn at 2020-07-21T18:23:23-07:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - 270ed393 by Brandon Chinn at 2020-07-21T18:23:23-07:00 Pass tc_args to gen_fn - - - - - df96714f by Brandon Chinn at 2020-07-21T18:23:23-07:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - 24 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Stats.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - 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/decaba57ace9365947e8d3c3cc5c483adc86b456...df96714fc1b997dc52166d04b12a3226327c54d4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/decaba57ace9365947e8d3c3cc5c483adc86b456...df96714fc1b997dc52166d04b12a3226327c54d4 You're receiving 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 Jul 22 16:17:32 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 22 Jul 2020 12:17:32 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 27 commits: Add release notes entry for #17816 Message-ID: <5f18669ca7173_80b114037a445149ba@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - eb4c66f3 by David Binder at 2020-07-22T12:17:11-04:00 Fix dead link to haskell prime discussion - - - - - 5ba46417 by BinderDavid at 2020-07-22T12:17:11-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 3537c647 by Daniel Gröber at 2020-07-22T12:17:12-04:00 Remove length field from FastString - - - - - 4e2218fe by Daniel Gröber at 2020-07-22T12:17:12-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - a03cf346 by Daniel Gröber at 2020-07-22T12:17:12-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 2e5a985e by Daniel Gröber at 2020-07-22T12:17:12-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 9f8acb2b by Daniel Gröber at 2020-07-22T12:17:12-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 853d0ec6 by Daniel Gröber at 2020-07-22T12:17:12-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - bb1cb881 by Daniel Gröber at 2020-07-22T12:17:12-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - eb880bc7 by Daniel Gröber at 2020-07-22T12:17:12-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - 70eeb593 by Ben Gamari at 2020-07-22T12:17:12-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 587d256e by Andreas Klebinger at 2020-07-22T12:17:13-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 4ad8dc33 by Sylvain Henry at 2020-07-22T12:17:16-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - 53a7555e by Sylvain Henry at 2020-07-22T12:17:16-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 367c9574 by Sylvain Henry at 2020-07-22T12:17:16-04:00 Remove unused sGhcWithNativeCodeGen - - - - - d72e2cbc by Sylvain Henry at 2020-07-22T12:17:16-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 302b1d83 by Sylvain Henry at 2020-07-22T12:17:16-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - 5a591e5d by Sylvain Henry at 2020-07-22T12:17:16-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 34161fd3 by Andreas Klebinger at 2020-07-22T12:17:17-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - a8de5005 by Sylvain Henry at 2020-07-22T12:17:20-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - 86048883 by Krzysztof Gogolewski at 2020-07-22T12:17:24-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 11c278ab by Sebastian Graf at 2020-07-22T12:17:25-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 607d0d90 by Sylvain Henry at 2020-07-22T12:17:26-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/StringBuffer.hs - + compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Doc.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/863c544c9849e49872acac64b8faea56a3311564...607d0d90da96d0762461d04125d2e94c63a249f5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/863c544c9849e49872acac64b8faea56a3311564...607d0d90da96d0762461d04125d2e94c63a249f5 You're receiving 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 Jul 22 21:12:16 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 22 Jul 2020 17:12:16 -0400 Subject: [Git][ghc/ghc][ghc-8.8] add "ac_cv_func_clock_gettime=no" to darwin CI build flavors Message-ID: <5f18abb081696_80b3f84962c9cf04546083@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC Commits: 27ddc306 by Carter Schonwald at 2020-07-22T17:11:55-04:00 add "ac_cv_func_clock_gettime=no" to darwin CI build flavors (cherry picked from commit ca750bf52293644b9c7732f47d934ef6413f247f) - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -222,6 +222,8 @@ validate-x86_64-darwin: MACOSX_DEPLOYMENT_TARGET: "10.7" # Only Sierra and onwards supports clock_gettime. See #12858 ac_cv_func_clock_gettime: "no" + # Only Mojave and onwards supports utimensat. See #17895 + ac_cv_func_utimensat: "no" LANG: "en_US.UTF-8" CONFIGURE_ARGS: --with-intree-gmp TEST_ENV: "x86_64-darwin" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/27ddc306f26d981bb7de1abbf63b36b16a6302dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/27ddc306f26d981bb7de1abbf63b36b16a6302dd You're receiving 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 Jul 22 23:38:47 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 22 Jul 2020 19:38:47 -0400 Subject: [Git][ghc/ghc][wip/drop-win32] Drop 32-bit Windows support Message-ID: <5f18ce073fd27_80b3f84901582f04556576@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/drop-win32 at Glasgow Haskell Compiler / GHC Commits: f8e23a10 by Ben Gamari at 2020-07-22T19:38:21-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 2 changed files: - .gitlab-ci.yml - docs/users_guide/8.12.1-notes.rst Changes: ===================================== .gitlab-ci.yml ===================================== @@ -817,15 +817,6 @@ validate-x86_64-windows-hadrian: cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows-hadrian: - <<: *nightly - extends: .build-windows-hadrian - variables: - MSYSTEM: MINGW32 - TEST_ENV: "i386-windows-hadrian" - cache: - key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" - .build-windows-make: extends: .build-windows stage: full-build @@ -882,34 +873,6 @@ release-x86_64-windows-integer-simple: BIGNUM_BACKEND: native BUILD_FLAVOUR: "perf" - -.build-i386-windows-make: - extends: .build-windows-make - variables: - MSYSTEM: MINGW32 - # Due to #15934 - BUILD_PROF_LIBS: "NO" - TEST_ENV: "i386-windows" - # Due to #17736 - allow_failure: true - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" - -validate-i386-windows: - extends: .build-i386-windows-make - variables: - BUILD_FLAVOUR: "perf" - -release-i386-windows: - <<: *release - extends: .build-i386-windows-make - variables: - BUILD_FLAVOUR: "perf" - -nightly-i386-windows: - <<: *nightly - extends: .build-i386-windows-make - ############################################################ # Cleanup ############################################################ ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -79,6 +79,11 @@ Highlights $(return []) instance C Bool where foo = True + * Support for 32-bit Windows has officially been dropped as Microsoft has + formally discontinued new 32-bit Windows 10 releases in 2020. See + :ghc-ticket:`18487` for details. + + Full details ------------ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8e23a101c5b57606b5650f32c36a88fcd290f96 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8e23a101c5b57606b5650f32c36a88fcd290f96 You're receiving 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 Jul 23 00:17:38 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 22 Jul 2020 20:17:38 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Fix dead link to haskell prime discussion Message-ID: <5f18d7221539d_80b3f84901582f04592312@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 3 changed files: - docs/users_guide/exts/monadfail_desugaring.rst - docs/users_guide/exts/strict.rst - docs/users_guide/using-warnings.rst Changes: ===================================== docs/users_guide/exts/monadfail_desugaring.rst ===================================== @@ -16,7 +16,7 @@ The ``-XMonadFailDesugaring`` extension switches the desugaring of This extension is enabled by default since GHC 8.6.1, under the `MonadFail Proposal (MFP) -`__. +`__. This extension is temporary, and will be deprecated in a future release. ===================================== docs/users_guide/exts/strict.rst ===================================== @@ -46,7 +46,7 @@ Bang patterns GHC supports an extension of pattern matching called *bang patterns*, written ``!pat``. Bang patterns are under consideration for Haskell Prime. The `Haskell prime feature -description `__ +description `__ contains more discussion and examples than the material below. The main idea is to add a single new production to the syntax of ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -548,7 +548,7 @@ of ``-W(no-)*``. Being part of the :ghc-flag:`-Wcompat` option group, this warning is off by default, but will be switched on in a future GHC release, as part of the `MonadFail Proposal (MFP) - `__. + `__. .. ghc-flag:: -Wsemigroup :shortdesc: warn when a ``Monoid`` is not ``Semigroup``, and on non- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/19e80b9af252eee760dc047765a9930ef00067ec...f2f817e4c547657c25bb110199f6f0b6014f843b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/19e80b9af252eee760dc047765a9930ef00067ec...f2f817e4c547657c25bb110199f6f0b6014f843b You're receiving 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 Jul 23 00:18:19 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 22 Jul 2020 20:18:19 -0400 Subject: [Git][ghc/ghc][master] 8 commits: Remove length field from FastString Message-ID: <5f18d74b2a9e5_80b3f849248fe0845976da@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - 5 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/StringBuffer.hs - compiler/GHC/Utils/Encoding.hs Changes: ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -1453,11 +1453,14 @@ dataConRepArgTys (MkData { dcRep = rep dataConIdentity :: DataCon -> ByteString -- We want this string to be UTF-8, so we get the bytes directly from the FastStrings. dataConIdentity dc = LBS.toStrict $ BSB.toLazyByteString $ mconcat - [ BSB.byteString $ bytesFS (unitFS (moduleUnit mod)) + [ BSB.shortByteString $ fastStringToShortByteString $ + unitFS $ moduleUnit mod , BSB.int8 $ fromIntegral (ord ':') - , BSB.byteString $ bytesFS (moduleNameFS (moduleName mod)) + , BSB.shortByteString $ fastStringToShortByteString $ + moduleNameFS $ moduleName mod , BSB.int8 $ fromIntegral (ord '.') - , BSB.byteString $ bytesFS (occNameFS (nameOccName name)) + , BSB.shortByteString $ fastStringToShortByteString $ + occNameFS $ nameOccName name ] where name = dataConName dc mod = ASSERT( isExternalName name ) nameModule name ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -1212,7 +1212,7 @@ dealWithStringLiteral fun str co = let strFS = mkFastStringByteString str char = mkConApp charDataCon [mkCharLit (headFS strFS)] - charTail = bytesFS (tailFS strFS) + charTail = BS.tail (bytesFS strFS) -- In singleton strings, just add [] instead of unpackCstring# ""#. rest = if BS.null charTail ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -32,12 +32,16 @@ module GHC.Data.FastString ( -- * ByteString - bytesFS, -- :: FastString -> ByteString - fastStringToByteString, -- = bytesFS (kept for haddock) + bytesFS, + fastStringToByteString, mkFastStringByteString, fastZStringToByteString, unsafeMkByteString, + -- * ShortByteString + fastStringToShortByteString, + mkFastStringShortByteString, + -- * FastZString FastZString, hPutFZS, @@ -52,7 +56,6 @@ module GHC.Data.FastString mkFastString, mkFastStringBytes, mkFastStringByteList, - mkFastStringForeignPtr, mkFastString#, -- ** Deconstruction @@ -67,7 +70,6 @@ module GHC.Data.FastString nullFS, appendFS, headFS, - tailFS, concatFS, consFS, nilFS, @@ -108,20 +110,19 @@ import Control.Concurrent.MVar import Control.DeepSeq import Control.Monad import Data.ByteString (ByteString) +import Data.ByteString.Short (ShortByteString) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BSC -import qualified Data.ByteString.Internal as BS import qualified Data.ByteString.Unsafe as BS +import qualified Data.ByteString.Short as SBS +import qualified Data.ByteString.Short.Internal as SBS import Foreign.C -import GHC.Exts import System.IO import Data.Data import Data.IORef import Data.Char import Data.Semigroup as Semi -import GHC.IO - import Foreign #if GHC_STAGE >= 2 @@ -131,14 +132,18 @@ import GHC.Conc.Sync (sharedCAF) #if __GLASGOW_HASKELL__ < 811 import GHC.Base (unpackCString#,unpackNBytes#) #endif +import GHC.Exts +import GHC.IO -- | Gives the UTF-8 encoded bytes corresponding to a 'FastString' -bytesFS :: FastString -> ByteString -bytesFS f = fs_bs f +bytesFS, fastStringToByteString :: FastString -> ByteString +bytesFS = fastStringToByteString {-# DEPRECATED fastStringToByteString "Use `bytesFS` instead" #-} -fastStringToByteString :: FastString -> ByteString -fastStringToByteString = bytesFS +fastStringToByteString f = SBS.fromShort $ fs_sbs f + +fastStringToShortByteString :: FastString -> ShortByteString +fastStringToShortByteString = fs_sbs fastZStringToByteString :: FastZString -> ByteString fastZStringToByteString (FastZString bs) = bs @@ -148,9 +153,7 @@ unsafeMkByteString :: String -> ByteString unsafeMkByteString = BSC.pack hashFastString :: FastString -> Int -hashFastString (FastString _ _ bs _) - = inlinePerformIO $ BS.unsafeUseAsCStringLen bs $ \(ptr, len) -> - return $ hashStr (castPtr ptr) len +hashFastString fs = hashStr $ fs_sbs fs -- ----------------------------------------------------------------------------- @@ -182,7 +185,7 @@ of this string which is used by the compiler internally. data FastString = FastString { uniq :: {-# UNPACK #-} !Int, -- unique id n_chars :: {-# UNPACK #-} !Int, -- number of chars - fs_bs :: {-# UNPACK #-} !ByteString, + fs_sbs :: {-# UNPACK #-} !ShortByteString, fs_zenc :: FastZString -- ^ Lazily computed z-encoding of this string. -- @@ -229,12 +232,9 @@ instance NFData FastString where rnf fs = seq fs () cmpFS :: FastString -> FastString -> Ordering -cmpFS f1@(FastString u1 _ _ _) f2@(FastString u2 _ _ _) = - if u1 == u2 then EQ else - compare (bytesFS f1) (bytesFS f2) - -foreign import ccall unsafe "memcmp" - memcmp :: Ptr a -> Ptr b -> Int -> IO Int +cmpFS fs1 fs2 = + if uniq fs1 == uniq fs2 then EQ else + compare (fs_sbs fs1) (fs_sbs fs2) -- ----------------------------------------------------------------------------- -- Construction @@ -405,12 +405,12 @@ The procedure goes like this: -} mkFastStringWith - :: (Int -> IORef Int-> IO FastString) -> Ptr Word8 -> Int -> IO FastString -mkFastStringWith mk_fs !ptr !len = do + :: (Int -> IORef Int-> IO FastString) -> ShortByteString -> IO FastString +mkFastStringWith mk_fs sbs = do FastStringTableSegment lock _ buckets# <- readIORef segmentRef let idx# = hashToIndex# buckets# hash# bucket <- IO $ readArray# buckets# idx# - res <- bucket_match bucket len ptr + res <- bucket_match bucket sbs case res of Just found -> return found Nothing -> do @@ -424,13 +424,13 @@ mkFastStringWith mk_fs !ptr !len = do !(FastStringTable uid n_zencs segments#) = stringTable get_uid = atomicModifyIORef' uid $ \n -> (n+1,n) - !(I# hash#) = hashStr ptr len + !(I# hash#) = hashStr sbs (# segmentRef #) = indexArray# segments# (hashToSegment# hash#) insert fs = do FastStringTableSegment _ counter buckets# <- maybeResizeSegment segmentRef let idx# = hashToIndex# buckets# hash# bucket <- IO $ readArray# buckets# idx# - res <- bucket_match bucket len ptr + res <- bucket_match bucket sbs case res of -- The FastString was added by another thread after previous read and -- before we acquired the write lock. @@ -442,100 +442,71 @@ mkFastStringWith mk_fs !ptr !len = do modifyIORef' counter succ return fs -bucket_match :: [FastString] -> Int -> Ptr Word8 -> IO (Maybe FastString) -bucket_match [] _ _ = return Nothing -bucket_match (v@(FastString _ _ bs _):ls) len ptr - | len == BS.length bs = do - b <- BS.unsafeUseAsCString bs $ \buf -> - cmpStringPrefix ptr (castPtr buf) len - if b then return (Just v) - else bucket_match ls len ptr - | otherwise = - bucket_match ls len ptr +bucket_match :: [FastString] -> ShortByteString -> IO (Maybe FastString) +bucket_match [] _ = return Nothing +bucket_match (fs@(FastString {fs_sbs=fs_sbs}) : ls) sbs + | fs_sbs == sbs = return (Just fs) + | otherwise = bucket_match ls sbs mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = -- NB: Might as well use unsafeDupablePerformIO, since mkFastStringWith is -- idempotent. - unsafeDupablePerformIO $ - mkFastStringWith (copyNewFastString ptr len) ptr len - --- | Create a 'FastString' from an existing 'ForeignPtr'; the difference --- between this and 'mkFastStringBytes' is that we don't have to copy --- the bytes if the string is new to the table. -mkFastStringForeignPtr :: Ptr Word8 -> ForeignPtr Word8 -> Int -> IO FastString -mkFastStringForeignPtr ptr !fp len - = mkFastStringWith (mkNewFastString fp ptr len) ptr len - --- | Create a 'FastString' from an existing 'ForeignPtr'; the difference --- between this and 'mkFastStringBytes' is that we don't have to copy --- the bytes if the string is new to the table. + unsafeDupablePerformIO $ do + sbs <- newSBSFromPtr ptr len + mkFastStringWith (mkNewFastStringShortByteString sbs) sbs + +newSBSFromPtr :: Ptr a -> Int -> IO ShortByteString +newSBSFromPtr (Ptr src#) (I# len#) = do + IO $ \s -> + case newByteArray# len# s of { (# s, dst# #) -> + case copyAddrToByteArray# src# dst# 0# len# s of { s -> + case unsafeFreezeByteArray# dst# s of { (# s, ba# #) -> + (# s, SBS.SBS ba# #) }}} + +-- | Create a 'FastString' by copying an existing 'ByteString' mkFastStringByteString :: ByteString -> FastString mkFastStringByteString bs = - inlinePerformIO $ - BS.unsafeUseAsCStringLen bs $ \(ptr, len) -> do - let ptr' = castPtr ptr - mkFastStringWith (mkNewFastStringByteString bs ptr' len) ptr' len + let sbs = SBS.toShort bs in + inlinePerformIO $ + mkFastStringWith (mkNewFastStringShortByteString sbs) sbs + +-- | Create a 'FastString' from an existing 'ShortByteString' without +-- copying. +mkFastStringShortByteString :: ShortByteString -> FastString +mkFastStringShortByteString sbs = + inlinePerformIO $ mkFastStringWith (mkNewFastStringShortByteString sbs) sbs -- | Creates a UTF-8 encoded 'FastString' from a 'String' mkFastString :: String -> FastString mkFastString str = inlinePerformIO $ do - let l = utf8EncodedLength str - buf <- mallocForeignPtrBytes l - withForeignPtr buf $ \ptr -> do - utf8EncodeString ptr str - mkFastStringForeignPtr ptr buf l + sbs <- utf8EncodeShortByteString str + mkFastStringWith (mkNewFastStringShortByteString sbs) sbs -- | Creates a 'FastString' from a UTF-8 encoded @[Word8]@ mkFastStringByteList :: [Word8] -> FastString -mkFastStringByteList str = mkFastStringByteString (BS.pack str) +mkFastStringByteList str = mkFastStringShortByteString (SBS.pack str) --- | Creates a (lazy) Z-encoded 'FastString' from a 'String' and account --- the number of forced z-strings into the passed 'IORef'. -mkZFastString :: IORef Int -> ByteString -> FastZString -mkZFastString n_zencs bs = unsafePerformIO $ do +-- | Creates a (lazy) Z-encoded 'FastString' from a 'ShortByteString' and +-- account the number of forced z-strings into the passed 'IORef'. +mkZFastString :: IORef Int -> ShortByteString -> FastZString +mkZFastString n_zencs sbs = unsafePerformIO $ do atomicModifyIORef' n_zencs $ \n -> (n+1, ()) - return $ mkFastZStringString (zEncodeString (utf8DecodeByteString bs)) - -mkNewFastString :: ForeignPtr Word8 -> Ptr Word8 -> Int -> Int - -> IORef Int -> IO FastString -mkNewFastString fp ptr len uid n_zencs = do - let bs = BS.fromForeignPtr fp 0 len - zstr = mkZFastString n_zencs bs - n_chars <- countUTF8Chars ptr len - return (FastString uid n_chars bs zstr) - -mkNewFastStringByteString :: ByteString -> Ptr Word8 -> Int -> Int - -> IORef Int -> IO FastString -mkNewFastStringByteString bs ptr len uid n_zencs = do - let zstr = mkZFastString n_zencs bs - n_chars <- countUTF8Chars ptr len - return (FastString uid n_chars bs zstr) - -copyNewFastString :: Ptr Word8 -> Int -> Int -> IORef Int -> IO FastString -copyNewFastString ptr len uid n_zencs = do - fp <- copyBytesToForeignPtr ptr len - let bs = BS.fromForeignPtr fp 0 len - zstr = mkZFastString n_zencs bs - n_chars <- countUTF8Chars ptr len - return (FastString uid n_chars bs zstr) - -copyBytesToForeignPtr :: Ptr Word8 -> Int -> IO (ForeignPtr Word8) -copyBytesToForeignPtr ptr len = do - fp <- mallocForeignPtrBytes len - withForeignPtr fp $ \ptr' -> copyBytes ptr' ptr len - return fp - -cmpStringPrefix :: Ptr Word8 -> Ptr Word8 -> Int -> IO Bool -cmpStringPrefix ptr1 ptr2 len = - do r <- memcmp ptr1 ptr2 len - return (r == 0) - -hashStr :: Ptr Word8 -> Int -> Int - -- use the Addr to produce a hash value between 0 & m (inclusive) -hashStr (Ptr a#) (I# len#) = loop 0# 0# - where + return $ mkFastZStringString (zEncodeString (utf8DecodeShortByteString sbs)) + +mkNewFastStringShortByteString :: ShortByteString -> Int + -> IORef Int -> IO FastString +mkNewFastStringShortByteString sbs uid n_zencs = do + let zstr = mkZFastString n_zencs sbs + chars <- countUTF8Chars sbs + return (FastString uid chars sbs zstr) + +hashStr :: ShortByteString -> Int + -- produce a hash value between 0 & m (inclusive) +hashStr sbs@(SBS.SBS ba#) = loop 0# 0# + where + !(I# len#) = SBS.length sbs loop h n = if isTrue# (n ==# len#) then I# h @@ -544,7 +515,7 @@ hashStr (Ptr a#) (I# len#) = loop 0# 0# -- DO NOT move this let binding! indexCharOffAddr# reads from the -- pointer so we need to evaluate this based on the length check -- above. Not doing this right caused #17909. - !c = ord# (indexCharOffAddr# a# n) + !c = indexInt8Array# ba# n !h2 = (h *# 16777619#) `xorI#` c in loop h2 (n +# 1#) @@ -554,15 +525,15 @@ hashStr (Ptr a#) (I# len#) = loop 0# 0# -- | Returns the length of the 'FastString' in characters lengthFS :: FastString -> Int -lengthFS f = n_chars f +lengthFS fs = n_chars fs -- | Returns @True@ if the 'FastString' is empty nullFS :: FastString -> Bool -nullFS f = BS.null (fs_bs f) +nullFS fs = SBS.null $ fs_sbs fs -- | Unpacks and decodes the FastString unpackFS :: FastString -> String -unpackFS (FastString _ _ bs _) = utf8DecodeByteString bs +unpackFS fs = utf8DecodeShortByteString $ fs_sbs fs -- | Returns a Z-encoded version of a 'FastString'. This might be the -- original, if it was already Z-encoded. The first time this @@ -570,33 +541,25 @@ unpackFS (FastString _ _ bs _) = utf8DecodeByteString bs -- memoized. -- zEncodeFS :: FastString -> FastZString -zEncodeFS (FastString _ _ _ ref) = ref +zEncodeFS fs = fs_zenc fs appendFS :: FastString -> FastString -> FastString appendFS fs1 fs2 = mkFastStringByteString $ BS.append (bytesFS fs1) (bytesFS fs2) concatFS :: [FastString] -> FastString -concatFS = mkFastStringByteString . BS.concat . map fs_bs +concatFS = mkFastStringShortByteString . mconcat . map fs_sbs headFS :: FastString -> Char -headFS (FastString _ 0 _ _) = panic "headFS: Empty FastString" -headFS (FastString _ _ bs _) = - inlinePerformIO $ BS.unsafeUseAsCString bs $ \ptr -> - return (fst (utf8DecodeChar (castPtr ptr))) - -tailFS :: FastString -> FastString -tailFS (FastString _ 0 _ _) = panic "tailFS: Empty FastString" -tailFS (FastString _ _ bs _) = - inlinePerformIO $ BS.unsafeUseAsCString bs $ \ptr -> - do let (_, n) = utf8DecodeChar (castPtr ptr) - return $! mkFastStringByteString (BS.drop n bs) +headFS fs + | SBS.null $ fs_sbs fs = panic "headFS: Empty FastString" +headFS fs = head $ unpackFS fs consFS :: Char -> FastString -> FastString consFS c fs = mkFastString (c : unpackFS fs) uniqueOfFS :: FastString -> Int -uniqueOfFS (FastString u _ _ _) = u +uniqueOfFS fs = uniq fs nilFS :: FastString nilFS = mkFastString "" ===================================== compiler/GHC/Data/StringBuffer.hs ===================================== @@ -200,7 +200,7 @@ nextChar (StringBuffer buf len (I# cur#)) = -- Getting our fingers dirty a little here, but this is performance-critical inlinePerformIO $ do withForeignPtr buf $ \(Ptr a#) -> do - case utf8DecodeChar# (a# `plusAddr#` cur#) of + case utf8DecodeCharAddr# (a# `plusAddr#` cur#) 0# of (# c#, nBytes# #) -> let cur' = I# (cur# +# nBytes#) in return (C# c#, StringBuffer buf len cur') ===================================== compiler/GHC/Utils/Encoding.hs ===================================== @@ -13,14 +13,16 @@ module GHC.Utils.Encoding ( -- * UTF-8 - utf8DecodeChar#, + utf8DecodeCharAddr#, utf8PrevChar, utf8CharStart, utf8DecodeChar, utf8DecodeByteString, + utf8DecodeShortByteString, utf8DecodeStringLazy, utf8EncodeChar, utf8EncodeString, + utf8EncodeShortByteString, utf8EncodedLength, countUTF8Chars, @@ -36,14 +38,16 @@ module GHC.Utils.Encoding ( import GHC.Prelude import Foreign -import Foreign.ForeignPtr.Unsafe +import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) import Data.Char import qualified Data.Char as Char import Numeric import GHC.IO +import GHC.ST import Data.ByteString (ByteString) import qualified Data.ByteString.Internal as BS +import Data.ByteString.Short.Internal (ShortByteString(..)) import GHC.Exts @@ -60,23 +64,23 @@ import GHC.Exts -- before decoding them (see "GHC.Data.StringBuffer"). {-# INLINE utf8DecodeChar# #-} -utf8DecodeChar# :: Addr# -> (# Char#, Int# #) -utf8DecodeChar# a# = - let !ch0 = word2Int# (indexWord8OffAddr# a# 0#) in +utf8DecodeChar# :: (Int# -> Word#) -> (# Char#, Int# #) +utf8DecodeChar# indexWord8# = + let !ch0 = word2Int# (indexWord8# 0#) in case () of _ | isTrue# (ch0 <=# 0x7F#) -> (# chr# ch0, 1# #) | isTrue# ((ch0 >=# 0xC0#) `andI#` (ch0 <=# 0xDF#)) -> - let !ch1 = word2Int# (indexWord8OffAddr# a# 1#) in + let !ch1 = word2Int# (indexWord8# 1#) in if isTrue# ((ch1 <# 0x80#) `orI#` (ch1 >=# 0xC0#)) then fail 1# else (# chr# (((ch0 -# 0xC0#) `uncheckedIShiftL#` 6#) +# (ch1 -# 0x80#)), 2# #) | isTrue# ((ch0 >=# 0xE0#) `andI#` (ch0 <=# 0xEF#)) -> - let !ch1 = word2Int# (indexWord8OffAddr# a# 1#) in + let !ch1 = word2Int# (indexWord8# 1#) in if isTrue# ((ch1 <# 0x80#) `orI#` (ch1 >=# 0xC0#)) then fail 1# else - let !ch2 = word2Int# (indexWord8OffAddr# a# 2#) in + let !ch2 = word2Int# (indexWord8# 2#) in if isTrue# ((ch2 <# 0x80#) `orI#` (ch2 >=# 0xC0#)) then fail 2# else (# chr# (((ch0 -# 0xE0#) `uncheckedIShiftL#` 12#) +# ((ch1 -# 0x80#) `uncheckedIShiftL#` 6#) +# @@ -84,11 +88,11 @@ utf8DecodeChar# a# = 3# #) | isTrue# ((ch0 >=# 0xF0#) `andI#` (ch0 <=# 0xF8#)) -> - let !ch1 = word2Int# (indexWord8OffAddr# a# 1#) in + let !ch1 = word2Int# (indexWord8# 1#) in if isTrue# ((ch1 <# 0x80#) `orI#` (ch1 >=# 0xC0#)) then fail 1# else - let !ch2 = word2Int# (indexWord8OffAddr# a# 2#) in + let !ch2 = word2Int# (indexWord8# 2#) in if isTrue# ((ch2 <# 0x80#) `orI#` (ch2 >=# 0xC0#)) then fail 2# else - let !ch3 = word2Int# (indexWord8OffAddr# a# 3#) in + let !ch3 = word2Int# (indexWord8# 3#) in if isTrue# ((ch3 <# 0x80#) `orI#` (ch3 >=# 0xC0#)) then fail 3# else (# chr# (((ch0 -# 0xF0#) `uncheckedIShiftL#` 18#) +# ((ch1 -# 0x80#) `uncheckedIShiftL#` 12#) +# @@ -106,9 +110,18 @@ utf8DecodeChar# a# = -- confusing parse error later on. Instead we use '\0' which -- will signal a lexer error immediately. +utf8DecodeCharAddr# :: Addr# -> Int# -> (# Char#, Int# #) +utf8DecodeCharAddr# a# off# = + utf8DecodeChar# (\i# -> indexWord8OffAddr# a# (i# +# off#)) + +utf8DecodeCharByteArray# :: ByteArray# -> Int# -> (# Char#, Int# #) +utf8DecodeCharByteArray# ba# off# = + utf8DecodeChar# (\i# -> indexWord8Array# ba# (i# +# off#)) + utf8DecodeChar :: Ptr Word8 -> (Char, Int) -utf8DecodeChar (Ptr a#) = - case utf8DecodeChar# a# of (# c#, nBytes# #) -> ( C# c#, I# nBytes# ) +utf8DecodeChar !(Ptr a#) = + case utf8DecodeCharAddr# a# 0# of + (# c#, nBytes# #) -> ( C# c#, I# nBytes# ) -- UTF-8 is cleverly designed so that we can always figure out where -- the start of the current character is, given any position in a @@ -124,73 +137,102 @@ utf8CharStart p = go p then go (p `plusPtr` (-1)) else return p -utf8DecodeByteString :: ByteString -> [Char] -utf8DecodeByteString (BS.PS ptr offset len) - = utf8DecodeStringLazy ptr offset len - -utf8DecodeStringLazy :: ForeignPtr Word8 -> Int -> Int -> [Char] -utf8DecodeStringLazy fptr offset len - = unsafeDupablePerformIO $ unpack start +{-# INLINE utf8DecodeLazy# #-} +utf8DecodeLazy# :: (IO ()) -> (Int# -> (# Char#, Int# #)) -> Int# -> IO [Char] +utf8DecodeLazy# retain decodeChar# len# + = unpack 0# where - !start = unsafeForeignPtrToPtr fptr `plusPtr` offset - !end = start `plusPtr` len - - unpack p - | p >= end = touchForeignPtr fptr >> return [] + unpack i# + | isTrue# (i# >=# len#) = retain >> return [] | otherwise = - case utf8DecodeChar# (unPtr p) of - (# c#, nBytes# #) -> do - rest <- unsafeDupableInterleaveIO $ unpack (p `plusPtr#` nBytes#) - return (C# c# : rest) - -countUTF8Chars :: Ptr Word8 -> Int -> IO Int -countUTF8Chars ptr len = go ptr 0 - where - !end = ptr `plusPtr` len + case decodeChar# i# of + (# c#, nBytes# #) -> do + rest <- unsafeDupableInterleaveIO $ unpack (i# +# nBytes#) + return (C# c# : rest) - go p !n - | p >= end = return n - | otherwise = do - case utf8DecodeChar# (unPtr p) of - (# _, nBytes# #) -> go (p `plusPtr#` nBytes#) (n+1) - -unPtr :: Ptr a -> Addr# -unPtr (Ptr a) = a - -plusPtr# :: Ptr a -> Int# -> Ptr a -plusPtr# ptr nBytes# = ptr `plusPtr` (I# nBytes#) +utf8DecodeByteString :: ByteString -> [Char] +utf8DecodeByteString (BS.PS fptr offset len) + = utf8DecodeStringLazy fptr offset len -utf8EncodeChar :: Char -> Ptr Word8 -> IO (Ptr Word8) -utf8EncodeChar c ptr = +utf8DecodeStringLazy :: ForeignPtr Word8 -> Int -> Int -> [Char] +utf8DecodeStringLazy fp offset (I# len#) + = unsafeDupablePerformIO $ do + let !(Ptr a#) = unsafeForeignPtrToPtr fp `plusPtr` offset + utf8DecodeLazy# (touchForeignPtr fp) (utf8DecodeCharAddr# a#) len# +-- Note that since utf8DecodeLazy# returns a thunk the lifetime of the +-- ForeignPtr actually needs to be longer than the lexical lifetime +-- withForeignPtr would provide here. That's why we use touchForeignPtr to +-- keep the fp alive until the last character has actually been decoded. + +utf8DecodeShortByteString :: ShortByteString -> [Char] +utf8DecodeShortByteString (SBS ba#) + = unsafeDupablePerformIO $ + let len# = sizeofByteArray# ba# in + utf8DecodeLazy# (return ()) (utf8DecodeCharByteArray# ba#) len# + +countUTF8Chars :: ShortByteString -> IO Int +countUTF8Chars (SBS ba) = go 0# 0# + where + len# = sizeofByteArray# ba + go i# n# + | isTrue# (i# >=# len#) = + return (I# n#) + | otherwise = do + case utf8DecodeCharByteArray# ba i# of + (# _, nBytes# #) -> go (i# +# nBytes#) (n# +# 1#) + +{-# INLINE utf8EncodeChar #-} +utf8EncodeChar :: (Int# -> Word# -> State# s -> State# s) + -> Char -> ST s Int +utf8EncodeChar write# c = let x = ord c in case () of _ | x > 0 && x <= 0x007f -> do - poke ptr (fromIntegral x) - return (ptr `plusPtr` 1) + write 0 x + return 1 -- NB. '\0' is encoded as '\xC0\x80', not '\0'. This is so that we -- can have 0-terminated UTF-8 strings (see GHC.Base.unpackCStringUtf8). | x <= 0x07ff -> do - poke ptr (fromIntegral (0xC0 .|. ((x `shiftR` 6) .&. 0x1F))) - pokeElemOff ptr 1 (fromIntegral (0x80 .|. (x .&. 0x3F))) - return (ptr `plusPtr` 2) + write 0 (0xC0 .|. ((x `shiftR` 6) .&. 0x1F)) + write 1 (0x80 .|. (x .&. 0x3F)) + return 2 | x <= 0xffff -> do - poke ptr (fromIntegral (0xE0 .|. (x `shiftR` 12) .&. 0x0F)) - pokeElemOff ptr 1 (fromIntegral (0x80 .|. (x `shiftR` 6) .&. 0x3F)) - pokeElemOff ptr 2 (fromIntegral (0x80 .|. (x .&. 0x3F))) - return (ptr `plusPtr` 3) + write 0 (0xE0 .|. (x `shiftR` 12) .&. 0x0F) + write 1 (0x80 .|. (x `shiftR` 6) .&. 0x3F) + write 2 (0x80 .|. (x .&. 0x3F)) + return 3 | otherwise -> do - poke ptr (fromIntegral (0xF0 .|. (x `shiftR` 18))) - pokeElemOff ptr 1 (fromIntegral (0x80 .|. ((x `shiftR` 12) .&. 0x3F))) - pokeElemOff ptr 2 (fromIntegral (0x80 .|. ((x `shiftR` 6) .&. 0x3F))) - pokeElemOff ptr 3 (fromIntegral (0x80 .|. (x .&. 0x3F))) - return (ptr `plusPtr` 4) + write 0 (0xF0 .|. (x `shiftR` 18)) + write 1 (0x80 .|. ((x `shiftR` 12) .&. 0x3F)) + write 2 (0x80 .|. ((x `shiftR` 6) .&. 0x3F)) + write 3 (0x80 .|. (x .&. 0x3F)) + return 4 + where + {-# INLINE write #-} + write (I# off#) (I# c#) = ST $ \s -> + case write# off# (int2Word# c#) s of + s -> (# s, () #) utf8EncodeString :: Ptr Word8 -> String -> IO () -utf8EncodeString ptr str = go ptr str - where go !_ [] = return () - go ptr (c:cs) = do - ptr' <- utf8EncodeChar c ptr - go ptr' cs +utf8EncodeString (Ptr a#) str = go a# str + where go !_ [] = return () + go a# (c:cs) = do + I# off# <- stToIO $ utf8EncodeChar (writeWord8OffAddr# a#) c + go (a# `plusAddr#` off#) cs + +utf8EncodeShortByteString :: String -> IO ShortByteString +utf8EncodeShortByteString str = IO $ \s -> + case utf8EncodedLength str of { I# len# -> + case newByteArray# len# s of { (# s, mba# #) -> + case go mba# 0# str of { ST f_go -> + case f_go s of { (# s, () #) -> + case unsafeFreezeByteArray# mba# s of { (# s, ba# #) -> + (# s, SBS ba# #) }}}}} + where + go _ _ [] = return () + go mba# i# (c:cs) = do + I# off# <- utf8EncodeChar (\j# -> writeWord8Array# mba# (i# +# j#)) c + go mba# (i# +# off#) cs utf8EncodedLength :: String -> Int utf8EncodedLength str = go 0 str View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f2f817e4c547657c25bb110199f6f0b6014f843b...9ddf161492194edb321b87b1977eda8264df35aa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f2f817e4c547657c25bb110199f6f0b6014f843b...9ddf161492194edb321b87b1977eda8264df35aa You're receiving 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 Jul 23 00:18:51 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 22 Jul 2020 20:18:51 -0400 Subject: [Git][ghc/ghc][master] get-win32-tarballs: Fix detection of missing tarballs Message-ID: <5f18d76b70dcd_80b1025102445997d7@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 1 changed file: - mk/get-win32-tarballs.py Changes: ===================================== mk/get-win32-tarballs.py ===================================== @@ -5,6 +5,7 @@ from pathlib import Path import urllib.request import subprocess import argparse +import sys from sys import stderr TARBALL_VERSION = '0.2' @@ -39,7 +40,8 @@ def fetch_arch(arch: str): def verify(arch: str): if not Path(DEST / arch / "SHA256SUMS").is_file(): - raise IOError("SHA256SUMS doesn't exist; have you fetched?") + print("SHA256SUMS doesn't exist; have you fetched?", file=stderr) + sys.exit(2) cmd = ['sha256sum', '--quiet', '--check', '--ignore-missing', 'SHA256SUMS'] subprocess.check_call(cmd, cwd=DEST / arch) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9491668640227a7ae7f6d0506d36af3a10cdd49 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9491668640227a7ae7f6d0506d36af3a10cdd49 You're receiving 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 Jul 23 00:19:28 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 22 Jul 2020 20:19:28 -0400 Subject: [Git][ghc/ghc][master] Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. Message-ID: <5f18d7907f9fd_80bd68a9b84605864@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 3 changed files: - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -97,7 +97,6 @@ Library CPP-Options: -DCAN_LOAD_DLL Other-Extensions: - BangPatterns CPP DataKinds DeriveDataTypeable @@ -116,7 +115,6 @@ Library NondecreasingIndentation RankNTypes RecordWildCards - ScopedTypeVariables StandaloneDeriving Trustworthy TupleSections @@ -153,6 +151,8 @@ Library -- we use an explicit Prelude Default-Extensions: NoImplicitPrelude + ,BangPatterns + ,ScopedTypeVariables Exposed-Modules: GHC.Iface.Ext.Types ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -74,7 +74,6 @@ Executable ghc GHCi.UI.Tags GHCi.Util Other-Extensions: - BangPatterns FlexibleInstances LambdaCase MagicHash @@ -102,3 +101,5 @@ Executable ghc -- GHCi can be used to load it all at once. Default-Extensions: NoImplicitPrelude + , ScopedTypeVariables + , BangPatterns \ No newline at end of file ===================================== hadrian/hadrian.cabal ===================================== @@ -131,6 +131,7 @@ executable hadrian , RecordWildCards , ScopedTypeVariables , TupleSections + , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies build-depends: Cabal >= 3.0 && < 3.3 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f3ff8fd24b94c9d4a221e6aba3e21de42b0f02c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f3ff8fd24b94c9d4a221e6aba3e21de42b0f02c You're receiving 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 Jul 23 00:20:06 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 22 Jul 2020 20:20:06 -0400 Subject: [Git][ghc/ghc][master] 6 commits: Remove unused "ncg" flag Message-ID: <5f18d7b68cf92_80b102510244612232@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - + compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Linker/Types.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/StgToCmm.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Gen/Foreign.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/ghc.cabal.in - compiler/ghc.mk - distrib/cross-port The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9f3ff8fd24b94c9d4a221e6aba3e21de42b0f02c...f7cc431341e5b5b31758eecc8504cae8b2390c10 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9f3ff8fd24b94c9d4a221e6aba3e21de42b0f02c...f7cc431341e5b5b31758eecc8504cae8b2390c10 You're receiving 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 Jul 23 00:20:42 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 22 Jul 2020 20:20:42 -0400 Subject: [Git][ghc/ghc][master] Deprecate -fdmd-tx-dict-sel. Message-ID: <5f18d7daf3f11_80b1025102446167e7@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - 4 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - docs/users_guide/using-optimisation.rst Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -486,8 +486,9 @@ dmdTransform env var dmd | isDataConWorkId var = dmdTransformDataConSig (idArity var) dmd -- Dictionary component selectors - | gopt Opt_DmdTxDictSel (ae_dflags env), - Just _ <- isClassOpId_maybe var + -- Used to be controlled by a flag. + -- See #18429 for some perf measurements. + | Just _ <- isClassOpId_maybe var = dmdTransformDictSelSig (idStrictness var) dmd -- Imported functions | isGlobalId var ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -188,7 +188,8 @@ data GeneralFlag | Opt_OmitYields | Opt_FunToThunk -- allow GHC.Core.Opt.WorkWrap.Utils.mkWorkerArgs to remove all value lambdas | Opt_DictsStrict -- be strict in argument dictionaries - | Opt_DmdTxDictSel -- use a special demand transformer for dictionary selectors + | Opt_DmdTxDictSel -- ^ deprecated, no effect and behaviour is now default. + -- Allowed switching of a special demand transformer for dictionary selectors | Opt_Loopification -- See Note [Self-recursive tail calls] | Opt_CfgBlocklayout -- ^ Use the cfg based block layout algorithm. | Opt_WeightlessBlocklayout -- ^ Layout based on last instruction per block. ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3472,7 +3472,8 @@ fFlagsDeps = [ flagSpec "diagnostics-show-caret" Opt_DiagnosticsShowCaret, flagSpec "dicts-cheap" Opt_DictsCheap, flagSpec "dicts-strict" Opt_DictsStrict, - flagSpec "dmd-tx-dict-sel" Opt_DmdTxDictSel, + depFlagSpec "dmd-tx-dict-sel" + Opt_DmdTxDictSel "effect is now unconditionally enabled", flagSpec "do-eta-reduction" Opt_DoEtaReduction, flagSpec "do-lambda-eta-expansion" Opt_DoLambdaEtaExpansion, flagSpec "eager-blackholing" Opt_EagerBlackHoling, @@ -4004,7 +4005,6 @@ optLevelFlags :: [([Int], GeneralFlag)] optLevelFlags -- see Note [Documenting optimisation flags] = [ ([0,1,2], Opt_DoLambdaEtaExpansion) , ([0,1,2], Opt_DoEtaReduction) -- See Note [Eta-reduction in -O0] - , ([0,1,2], Opt_DmdTxDictSel) , ([0,1,2], Opt_LlvmTBAA) , ([0], Opt_IgnoreInterfacePragmas) ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -353,8 +353,7 @@ by saying ``-fno-wombat``. Make dictionaries strict. .. ghc-flag:: -fdmd-tx-dict-sel - :shortdesc: Use a special demand transformer for dictionary selectors. - Always enabled by default. + :shortdesc: *(deprecated)* Use a special demand transformer for dictionary selectors. :type: dynamic :reverse: -fno-dmd-tx-dict-sel :category: @@ -362,6 +361,7 @@ by saying ``-fno-wombat``. :default: on Use a special demand transformer for dictionary selectors. + Behaviour is unconditionally enabled starting with 8.14 .. ghc-flag:: -fdo-eta-reduction :shortdesc: Enable eta-reduction. Implied by :ghc-flag:`-O`. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15ce1804d2b87ac7bd55632957a4cb897decbbee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15ce1804d2b87ac7bd55632957a4cb897decbbee You're receiving 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 Jul 23 00:21:18 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 22 Jul 2020 20:21:18 -0400 Subject: [Git][ghc/ghc][master] Add test for #18064 Message-ID: <5f18d7fe4b495_80b3f849c40b20c4619236@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - 8 changed files: - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/mk/ghc-config.hs - testsuite/mk/test.mk - + testsuite/tests/ghci/should_run/T18064.script - + testsuite/tests/ghci/should_run/T18064.stderr - + testsuite/tests/ghci/should_run/T18064.stdout - testsuite/tests/ghci/should_run/all.T Changes: ===================================== testsuite/driver/testglobals.py ===================================== @@ -148,6 +148,9 @@ class TestConfig: # Is the compiler dynamically linked? self.ghc_dynamic = False + # Do symbols use leading underscores? + self.leading_underscore = False + # the timeout program self.timeout_prog = '' self.timeout = 300 ===================================== testsuite/driver/testlib.py ===================================== @@ -501,6 +501,11 @@ def doing_ghci() -> bool: def ghc_dynamic() -> bool: return config.ghc_dynamic +# Symbols have a leading underscore +def leading_underscore() -> bool: + return config.leading_underscore + + def fast() -> bool: return config.speed == 2 ===================================== testsuite/mk/ghc-config.hs ===================================== @@ -23,6 +23,7 @@ main = do getGhcFieldOrFail fields "GhcUnregisterised" "Unregisterised" getGhcFieldOrFail fields "GhcWithSMP" "Support SMP" getGhcFieldOrFail fields "GhcRTSWays" "RTS ways" + getGhcFieldOrFail fields "GhcLeadingUnderscore" "Leading underscore" getGhcFieldOrDefault fields "GhcDynamicByDefault" "Dynamic by default" "NO" getGhcFieldOrDefault fields "GhcDynamic" "GHC Dynamic" "NO" getGhcFieldOrDefault fields "GhcProfiled" "GHC Profiled" "NO" ===================================== testsuite/mk/test.mk ===================================== @@ -93,6 +93,12 @@ else RUNTEST_OPTS += -e ghc_with_native_codegen=False endif +ifeq "$(GhcLeadingUnderscore)" "YES" +RUNTEST_OPTS += -e "config.leading_underscore=True" +else +RUNTEST_OPTS += -e "config.leading_underscore=False" +endif + GHC_PRIM_LIBDIR := $(subst library-dirs: ,,$(shell "$(GHC_PKG)" field ghc-prim library-dirs --simple-output)) HAVE_VANILLA := $(shell if [ -f $(subst \,/,$(GHC_PRIM_LIBDIR))/GHC/PrimopWrappers.hi ]; then echo YES; else echo NO; fi) HAVE_DYNAMIC := $(shell if [ -f $(subst \,/,$(GHC_PRIM_LIBDIR))/GHC/PrimopWrappers.dyn_hi ]; then echo YES; else echo NO; fi) ===================================== testsuite/tests/ghci/should_run/T18064.script ===================================== @@ -0,0 +1,2 @@ +import GHCi.ObjLink +lookupClosure "blah" ===================================== testsuite/tests/ghci/should_run/T18064.stderr ===================================== @@ -0,0 +1,2 @@ +: ^^ Could not load 'blah', dependency unresolved. See top entry above. + ===================================== testsuite/tests/ghci/should_run/T18064.stdout ===================================== @@ -0,0 +1 @@ +Nothing ===================================== testsuite/tests/ghci/should_run/all.T ===================================== @@ -66,3 +66,12 @@ test('T16012', just_ghci, ghci_script, ['T16012.script']) test('T16096', just_ghci, ghci_script, ['T16096.script']) test('T507', just_ghci, ghci_script, ['T507.script']) test('T18027', just_ghci, ghci_script, ['T18027.script']) +test('T18064', + [just_ghci, + when(leading_underscore(),skip) + # we need to skip otherwise the test fails on platforms prepending leading + # underscores to symbols (we get "Could not load '_blah'" instead of "Could + # not load 'blah'). + ], + ghci_script, + ['T18064.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ff1b7710c9975a3cc1025cb5b9d29197a5f1a98a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ff1b7710c9975a3cc1025cb5b9d29197a5f1a98a You're receiving 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 Jul 23 00:21:59 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 22 Jul 2020 20:21:59 -0400 Subject: [Git][ghc/ghc][master] Define type Void# = (# #) (#18441) Message-ID: <5f18d827cc465_80b3f849248fe084622521@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 26 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Tc/TyCl/Build.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/8.12.1-notes.rst - libraries/base/GHC/Exts.hs - libraries/base/tests/isValidNatural.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-bignum/src/GHC/Num/BigNat/Check.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs - libraries/ghc-bignum/src/GHC/Num/Primitives.hs - libraries/ghc-prim/GHC/Prim/Exception.hs - libraries/ghc-prim/GHC/Prim/Panic.hs - libraries/ghc-prim/GHC/Types.hs - testsuite/tests/codeGen/should_compile/T12115.hs - testsuite/tests/printer/T18052a.stderr - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/unboxedsums/ffi1.hs - utils/genprimopcode/Main.hs Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -1802,7 +1802,7 @@ statePrimTyConKey, stableNamePrimTyConKey, stableNameTyConKey, liftedConKey, unliftedConKey, anyBoxConKey, kindConKey, boxityConKey, typeConKey, threadIdPrimTyConKey, bcoPrimTyConKey, ptrTyConKey, funPtrTyConKey, tVarPrimTyConKey, eqPrimTyConKey, - eqReprPrimTyConKey, eqPhantPrimTyConKey, voidPrimTyConKey, + eqReprPrimTyConKey, eqPhantPrimTyConKey, compactPrimTyConKey :: Unique statePrimTyConKey = mkPreludeTyConUnique 50 stableNamePrimTyConKey = mkPreludeTyConUnique 51 @@ -1812,7 +1812,6 @@ eqReprPrimTyConKey = mkPreludeTyConUnique 54 eqPhantPrimTyConKey = mkPreludeTyConUnique 55 mutVarPrimTyConKey = mkPreludeTyConUnique 56 ioTyConKey = mkPreludeTyConUnique 57 -voidPrimTyConKey = mkPreludeTyConUnique 58 wordPrimTyConKey = mkPreludeTyConUnique 59 wordTyConKey = mkPreludeTyConUnique 60 word8PrimTyConKey = mkPreludeTyConUnique 61 ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -75,6 +75,7 @@ module GHC.Builtin.Types ( promotedTupleDataCon, unitTyCon, unitDataCon, unitDataConId, unitTy, unitTyConKey, pairTyCon, + unboxedUnitTy, unboxedUnitTyCon, unboxedUnitDataCon, unboxedTupleKind, unboxedSumKind, @@ -1053,6 +1054,9 @@ unitDataConId = dataConWorkId unitDataCon pairTyCon :: TyCon pairTyCon = tupleTyCon Boxed 2 +unboxedUnitTy :: Type +unboxedUnitTy = mkTyConApp unboxedUnitTyCon [] + unboxedUnitTyCon :: TyCon unboxedUnitTyCon = tupleTyCon Unboxed 0 ===================================== compiler/GHC/Builtin/Types/Prim.hs ===================================== @@ -45,7 +45,6 @@ module GHC.Builtin.Types.Prim( floatPrimTyCon, floatPrimTy, floatPrimTyConName, doublePrimTyCon, doublePrimTy, doublePrimTyConName, - voidPrimTyCon, voidPrimTy, statePrimTyCon, mkStatePrimTy, realWorldTyCon, realWorldTy, realWorldStatePrimTy, @@ -180,7 +179,6 @@ exposedPrimTyCons , stableNamePrimTyCon , compactPrimTyCon , statePrimTyCon - , voidPrimTyCon , proxyPrimTyCon , threadIdPrimTyCon , wordPrimTyCon @@ -209,7 +207,7 @@ mkBuiltInPrimTc fs unique tycon BuiltInSyntax -charPrimTyConName, intPrimTyConName, int8PrimTyConName, int16PrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word8PrimTyConName, word16PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, proxyPrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, smallArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, ioPortPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName, voidPrimTyConName :: Name +charPrimTyConName, intPrimTyConName, int8PrimTyConName, int16PrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word8PrimTyConName, word16PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, proxyPrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, smallArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, ioPortPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName :: Name charPrimTyConName = mkPrimTc (fsLit "Char#") charPrimTyConKey charPrimTyCon intPrimTyConName = mkPrimTc (fsLit "Int#") intPrimTyConKey intPrimTyCon int8PrimTyConName = mkPrimTc (fsLit "Int8#") int8PrimTyConKey int8PrimTyCon @@ -225,7 +223,6 @@ addrPrimTyConName = mkPrimTc (fsLit "Addr#") addrPrimTyConKey addrPr floatPrimTyConName = mkPrimTc (fsLit "Float#") floatPrimTyConKey floatPrimTyCon doublePrimTyConName = mkPrimTc (fsLit "Double#") doublePrimTyConKey doublePrimTyCon statePrimTyConName = mkPrimTc (fsLit "State#") statePrimTyConKey statePrimTyCon -voidPrimTyConName = mkPrimTc (fsLit "Void#") voidPrimTyConKey voidPrimTyCon proxyPrimTyConName = mkPrimTc (fsLit "Proxy#") proxyPrimTyConKey proxyPrimTyCon eqPrimTyConName = mkPrimTc (fsLit "~#") eqPrimTyConKey eqPrimTyCon eqReprPrimTyConName = mkBuiltInPrimTc (fsLit "~R#") eqReprPrimTyConKey eqReprPrimTyCon @@ -897,12 +894,6 @@ realWorldStatePrimTy = mkStatePrimTy realWorldTy -- State# RealWorld -- so they are defined in \tr{GHC.Builtin.Types}, not here. -voidPrimTy :: Type -voidPrimTy = TyConApp voidPrimTyCon [] - -voidPrimTyCon :: TyCon -voidPrimTyCon = pcPrimTyCon voidPrimTyConName [] VoidRep - mkProxyPrimTy :: Type -> Type -> Type mkProxyPrimTy k ty = TyConApp proxyPrimTyCon [k, ty] ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3355,8 +3355,6 @@ section "Misc" {These aren't nearly as wired in as Etc...} ------------------------------------------------------------------------ -primtype Void# - primop GetCCSOfOp "getCCSOf#" GenPrimOp a -> State# s -> (# State# s, Addr# #) ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -39,7 +39,7 @@ import GHC.Core.Opt.Arity ( etaExpandToJoinPointRule ) import GHC.Types.Unique.Supply import GHC.Types.Name import GHC.Types.Id.Make ( voidArgId, voidPrimId ) -import GHC.Builtin.Types.Prim ( voidPrimTy ) +import GHC.Builtin.Types ( unboxedUnitTy ) import GHC.Data.Maybe ( mapMaybe, maybeToList, isJust ) import GHC.Utils.Monad ( foldlM ) import GHC.Types.Basic @@ -1427,7 +1427,7 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs (spec_bndrs, spec_rhs, spec_fn_ty) | add_void_arg = ( voidPrimId : spec_bndrs1 , Lam voidArgId spec_rhs1 - , mkVisFunTyMany voidPrimTy spec_fn_ty1) + , mkVisFunTyMany unboxedUnitTy spec_fn_ty1) | otherwise = (spec_bndrs1, spec_rhs1, spec_fn_ty1) join_arity_decr = length rule_lhs_args - length spec_bndrs ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -28,8 +28,7 @@ import GHC.Types.Cpr import GHC.Core.Make ( mkAbsentErrorApp, mkCoreUbxTup , mkCoreApp, mkCoreLet ) import GHC.Types.Id.Make ( voidArgId, voidPrimId ) -import GHC.Builtin.Types ( tupleDataCon ) -import GHC.Builtin.Types.Prim ( voidPrimTy ) +import GHC.Builtin.Types ( tupleDataCon, unboxedUnitTy ) import GHC.Types.Literal ( absentLiteralOf, rubbishLit ) import GHC.Types.Var.Env ( mkInScopeSet ) import GHC.Types.Var.Set ( VarSet ) @@ -1256,7 +1255,7 @@ mk_absent_let dflags fam_envs arg | Just tc <- tyConAppTyCon_maybe nty , Just lit <- absentLiteralOf tc = Just (Let (NonRec arg (Lit lit `mkCast` mkSymCo co))) - | nty `eqType` voidPrimTy + | nty `eqType` unboxedUnitTy = Just (Let (NonRec arg (Var voidPrimId `mkCast` mkSymCo co))) | otherwise = WARN( True, text "No absent value for" <+> ppr arg_ty ) ===================================== compiler/GHC/CoreToByteCode.hs ===================================== @@ -43,6 +43,7 @@ import GHC.Core.DataCon import GHC.Core.TyCon import GHC.Utils.Misc import GHC.Types.Var.Set +import GHC.Builtin.Types ( unboxedUnitTy ) import GHC.Builtin.Types.Prim import GHC.Core.TyCo.Ppr ( pprType ) import GHC.Utils.Error @@ -673,7 +674,7 @@ schemeE d s p (AnnCase scrut bndr _ alt@[(DEFAULT, [], _)]) | isUnboxedTupleType (idType bndr) , Just ty <- case typePrimRep (idType bndr) of [_] -> Just (unwrapType (idType bndr)) - [] -> Just voidPrimTy + [] -> Just unboxedUnitTy _ -> Nothing -- handles any pattern with a single non-void binder; in particular I/O -- monad returns (# RealWorld#, a #) @@ -708,7 +709,7 @@ protectNNLJoinPointBind x rhs@(fvs, _) protectNNLJoinPointId :: Id -> Id protectNNLJoinPointId x = ASSERT( isNNLJoinPoint x ) - updateIdTypeButNotMult (voidPrimTy `mkVisFunTyMany`) x + updateIdTypeButNotMult (unboxedUnitTy `mkVisFunTyMany`) x {- Ticked Expressions @@ -743,8 +744,8 @@ isUnliftedType check in the AnnVar case of schemeE.) Here is the strategy: 1. Detect NNLJPs. This is done in isNNLJoinPoint. -2. When binding an NNLJP, add a `\ (_ :: Void#) ->` to its RHS, and modify the - type to tack on a `Void# ->`. (Void# is written voidPrimTy within GHC.) +2. When binding an NNLJP, add a `\ (_ :: (# #)) ->` to its RHS, and modify the + type to tack on a `(# #) ->`. Note that functions are never levity-polymorphic, so this transformation changes an NNLJP to a non-levity-polymorphic join point. This is done in protectNNLJoinPointBind, called from the AnnLet case of schemeE. ===================================== compiler/GHC/HsToCore/Utils.hs ===================================== @@ -67,7 +67,6 @@ import GHC.Core.DataCon import GHC.Core.PatSyn import GHC.Core.Type import GHC.Core.Coercion -import GHC.Builtin.Types.Prim import GHC.Builtin.Types import GHC.Types.Basic import GHC.Core.ConLike @@ -853,8 +852,8 @@ mkFailurePair :: CoreExpr -- Result type of the whole case expression CoreExpr) -- Fail variable applied to realWorld# -- See Note [Failure thunks and CPR] mkFailurePair expr - = do { fail_fun_var <- newFailLocalDs Many (voidPrimTy `mkVisFunTyMany` ty) - ; fail_fun_arg <- newSysLocalDs Many voidPrimTy + = do { fail_fun_var <- newFailLocalDs Many (unboxedUnitTy `mkVisFunTyMany` ty) + ; fail_fun_arg <- newSysLocalDs Many unboxedUnitTy ; let real_arg = setOneShotLambda fail_fun_arg ; return (NonRec fail_fun_var (Lam real_arg expr), App (Var fail_fun_var) (Var voidPrimId)) } ===================================== compiler/GHC/Tc/TyCl/Build.hs ===================================== @@ -21,8 +21,7 @@ import GHC.Prelude import GHC.Iface.Env import GHC.Core.FamInstEnv( FamInstEnvs, mkNewTypeCoAxiom ) -import GHC.Builtin.Types( isCTupleTyConName ) -import GHC.Builtin.Types.Prim ( voidPrimTy ) +import GHC.Builtin.Types( isCTupleTyConName, unboxedUnitTy ) import GHC.Core.DataCon import GHC.Core.PatSyn import GHC.Types.Var @@ -209,11 +208,11 @@ buildPatSyn src_name declared_infix matcher@(matcher_id,_) builder subst = zipTvSubst (univ_tvs1 ++ ex_tvs1) (mkTyVarTys (binderVars (univ_tvs ++ ex_tvs))) - -- For a nullary pattern synonym we add a single void argument to the + -- For a nullary pattern synonym we add a single (# #) argument to the -- matcher to preserve laziness in the case of unlifted types. -- See #12746 compareArgTys :: [Type] -> [Type] -> Bool - compareArgTys [] [x] = x `eqType` voidPrimTy + compareArgTys [] [x] = x `eqType` unboxedUnitTy compareArgTys arg_tys matcher_arg_tys = arg_tys `eqTypes` matcher_arg_tys ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -698,12 +698,12 @@ tcPatSynMatcher (L loc name) lpat res_ty = mkTyVarTy res_tv is_unlifted = null args && null prov_dicts (cont_args, cont_arg_tys) - | is_unlifted = ([nlHsVar voidPrimId], [voidPrimTy]) + | is_unlifted = ([nlHsVar voidPrimId], [unboxedUnitTy]) | otherwise = (args, arg_tys) cont_ty = mkInfSigmaTy ex_tvs prov_theta $ mkVisFunTysMany cont_arg_tys res_ty - fail_ty = mkVisFunTyMany voidPrimTy res_ty + fail_ty = mkVisFunTyMany unboxedUnitTy res_ty ; matcher_name <- newImplicitBinder name mkMatcherOcc ; scrutinee <- newSysLocalId (fsLit "scrut") Many pat_ty @@ -905,7 +905,7 @@ tcPatSynBuilderOcc ps add_void :: Bool -> Type -> Type add_void need_dummy_arg ty - | need_dummy_arg = mkVisFunTyMany voidPrimTy ty + | need_dummy_arg = mkVisFunTyMany unboxedUnitTy ty | otherwise = ty tcPatToExpr :: Name -> [Located Name] -> LPat GhcRn ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -121,7 +121,7 @@ The ghcPrimIds but have perfectly reasonable unfoldings in Core * Either have a CompulsoryUnfolding (hence always inlined), or - of an EvaldUnfolding and void representation (e.g. void#) + of an EvaldUnfolding and void representation (e.g. realWorldPrimId) * Are (or should be) defined in primops.txt.pp as 'pseudoop' Reason: that's how we generate documentation for them @@ -1760,12 +1760,19 @@ realWorldPrimId = pcMiscPrelId realWorldName realWorldStatePrimTy `setNeverLevPoly` realWorldStatePrimTy) voidPrimId :: Id -- Global constant :: Void# -voidPrimId = pcMiscPrelId voidPrimIdName voidPrimTy - (noCafIdInfo `setUnfoldingInfo` evaldUnfolding -- Note [evaldUnfoldings] - `setNeverLevPoly` voidPrimTy) + -- The type Void# is now the same as (# #) (ticket #18441), + -- this identifier just signifies the (# #) datacon + -- and is kept for backwards compatibility. + -- We cannot define it in normal Haskell, since it's + -- a top-level unlifted value. +voidPrimId = pcMiscPrelId voidPrimIdName unboxedUnitTy + (noCafIdInfo `setUnfoldingInfo` mkCompulsoryUnfolding rhs + `setNeverLevPoly` unboxedUnitTy) + where rhs = Var (dataConWorkId unboxedUnitDataCon) + voidArgId :: Id -- Local lambda-bound :: Void# -voidArgId = mkSysLocal (fsLit "void") voidArgIdKey Many voidPrimTy +voidArgId = mkSysLocal (fsLit "void") voidArgIdKey Many unboxedUnitTy coercionTokenId :: Id -- :: () ~ () coercionTokenId -- See Note [Coercion tokens] in "GHC.CoreToStg" ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -336,6 +336,9 @@ Haddock - Add a known-key ``cstringLength#`` to ``GHC.CString`` that is eligible for constant folding by a built-in rule. +- ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. + Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. + ``ghc`` library ~~~~~~~~~~~~~~~ ===================================== libraries/base/GHC/Exts.hs ===================================== @@ -37,6 +37,7 @@ module GHC.Exts uncheckedShiftL64#, uncheckedShiftRL64#, uncheckedIShiftL64#, uncheckedIShiftRA64#, isTrue#, + Void#, -- Previously exported by GHC.Prim -- * Compat wrapper atomicModifyMutVar#, ===================================== libraries/base/tests/isValidNatural.hs ===================================== @@ -1,4 +1,4 @@ -{-# language MagicHash #-} +{-# language MagicHash, UnboxedTuples #-} import GHC.Num.Natural import GHC.Num.BigNat @@ -7,4 +7,4 @@ import GHC.Exts main = print $ map naturalCheck [0, 1, maxWord, maxWord + 1, invalid] where maxWord = fromIntegral (maxBound :: Word) - invalid = NB (bigNatOne# void#) -- 1 would fit into the NS constructor. + invalid = NB (bigNatOne# (# #)) -- 1 would fit into the NS constructor. ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -68,11 +68,11 @@ type BigNat# = WordArray# -- As a consequence, zero is represented with a WordArray# whose size is 0. data BigNat = BN# { unBigNat :: BigNat# } --- Note [Why Void#?] +-- Note [Why (# #)?] -- ~~~~~~~~~~~~~~~~~ -- -- We can't have top-level BigNat# for now because they are unlifted ByteArray# --- (see #17521). So we use functions that take an empty argument Void# that +-- (see #17521). So we use functions that take an empty argument (# #) that -- will be discarded at compile time. @@ -104,18 +104,18 @@ bigNatOne :: BigNat bigNatOne = BN# (bigNatFromWord# 1##) -- | BigNat Zero -bigNatZero# :: Void# -> BigNat# -- cf Note [Why Void#?] +bigNatZero# :: (# #) -> BigNat# -- cf Note [Why (# #)?] bigNatZero# _ = case bigNatZero of BN# w -> w -- | BigNat one -bigNatOne# :: Void# -> BigNat# -- cf Note [Why Void#?] +bigNatOne# :: (# #) -> BigNat# -- cf Note [Why (# #)?] bigNatOne# _ = case bigNatOne of BN# w -> w -raiseDivZero_BigNat :: Void# -> BigNat# +raiseDivZero_BigNat :: (# #) -> BigNat# raiseDivZero_BigNat _ = case raiseDivZero of - !_ -> bigNatZero# void# + !_ -> bigNatZero# (# #) -- see Note [ghc-bignum exceptions] in GHC.Num.Primitives -- | Indicate if a bigNat is zero @@ -184,7 +184,7 @@ bigNatFromWord (W# w) = bigNatFromWord# w -- | Create a BigNat from a Word bigNatFromWord# :: Word# -> BigNat# -bigNatFromWord# 0## = bigNatZero# void# +bigNatFromWord# 0## = bigNatZero# (# #) bigNatFromWord# w = wordArrayFromWord# w -- | Convert a list of non-zero Words (most-significant first) into a BigNat @@ -204,7 +204,7 @@ bigNatFromAbsInt# i = bigNatFromWord# (wordFromAbsInt# i) -- | Convert a list of non-zero Words (most-significant first) into a BigNat. -- Don't remove most-significant zero words bigNatFromWordListUnsafe :: [Word] -> BigNat# -bigNatFromWordListUnsafe [] = bigNatZero# void# +bigNatFromWordListUnsafe [] = bigNatZero# (# #) bigNatFromWordListUnsafe xs = let length i [] = i @@ -227,7 +227,7 @@ bigNatToWordList bn = go (bigNatSize# bn) -- | Convert two Word# (most-significant first) into a BigNat bigNatFromWord2# :: Word# -> Word# -> BigNat# -bigNatFromWord2# 0## 0## = bigNatZero# void# +bigNatFromWord2# 0## 0## = bigNatZero# (# #) bigNatFromWord2# 0## n = bigNatFromWord# n bigNatFromWord2# w1 w2 = wordArrayFromWord2# w1 w2 @@ -415,9 +415,9 @@ bigNatAdd a b -- | Multiply a BigNat by a Word# bigNatMulWord# :: BigNat# -> Word# -> BigNat# bigNatMulWord# a w - | 0## <- w = bigNatZero# void# + | 0## <- w = bigNatZero# (# #) | 1## <- w = a - | bigNatIsZero a = bigNatZero# void# + | bigNatIsZero a = bigNatZero# (# #) | bigNatIsOne a = bigNatFromWord# w | isTrue# (bigNatSize# a ==# 1#) = case timesWord2# (bigNatIndex# a 0#) w of @@ -531,7 +531,7 @@ bigNatSub a b bigNatQuotWord# :: BigNat# -> Word# -> BigNat# bigNatQuotWord# a b | 1## <- b = a - | 0## <- b = raiseDivZero_BigNat void# + | 0## <- b = raiseDivZero_BigNat (# #) | True = let sz = wordArraySize# a @@ -551,7 +551,7 @@ bigNatQuotWord a (W# b) = bigNatQuotWord# a b -- b /= 0 bigNatRemWord# :: BigNat# -> Word# -> Word# bigNatRemWord# a b - | 0## <- b = raiseDivZero_Word# void# + | 0## <- b = raiseDivZero_Word# (# #) | 1## <- b = 0## | bigNatIsZero a = 0## | True = inline bignat_rem_word a b @@ -570,14 +570,14 @@ bigNatRemWord a (W# b) = W# (bigNatRemWord# a b) bigNatQuotRemWord# :: BigNat# -> Word# -> (# BigNat#, Word# #) bigNatQuotRemWord# a b | 0## <- b = case raiseDivZero of - !_ -> (# bigNatZero# void#, 0## #) + !_ -> (# bigNatZero# (# #), 0## #) -- see Note [ghc-bignum exceptions] in GHC.Num.Primitives | 1## <- b = (# a, 0## #) | isTrue# (bigNatSize# a ==# 1#) , a0 <- indexWordArray# a 0# = case compareWord# a0 b of - LT -> (# bigNatZero# void#, a0 #) - EQ -> (# bigNatOne# void#, 0## #) + LT -> (# bigNatZero# (# #), a0 #) + EQ -> (# bigNatOne# (# #), 0## #) GT -> case quotRemWord# a0 b of (# q, r #) -> (# bigNatFromWord# q, r #) | True = @@ -598,12 +598,12 @@ bigNatQuotRemWord# a b bigNatQuotRem# :: BigNat# -> BigNat# -> (# BigNat#, BigNat# #) bigNatQuotRem# a b | bigNatIsZero b = case raiseDivZero of - !_ -> (# bigNatZero# void#, bigNatZero# void# #) + !_ -> (# bigNatZero# (# #), bigNatZero# (# #) #) -- see Note [ghc-bignum exceptions] in GHC.Num.Primitives - | bigNatIsZero a = (# bigNatZero# void#, bigNatZero# void# #) - | bigNatIsOne b = (# a , bigNatZero# void# #) - | LT <- cmp = (# bigNatZero# void#, a #) - | EQ <- cmp = (# bigNatOne# void#, bigNatZero# void# #) + | bigNatIsZero a = (# bigNatZero# (# #), bigNatZero# (# #) #) + | bigNatIsOne b = (# a , bigNatZero# (# #) #) + | LT <- cmp = (# bigNatZero# (# #), a #) + | EQ <- cmp = (# bigNatOne# (# #), bigNatZero# (# #) #) | isTrue# (szB ==# 1#) = case bigNatQuotRemWord# a (bigNatIndex# b 0#) of (# q, r #) -> (# q, bigNatFromWord# r #) @@ -620,11 +620,11 @@ bigNatQuotRem# a b -- | BigNat division returning quotient bigNatQuot :: BigNat# -> BigNat# -> BigNat# bigNatQuot a b - | bigNatIsZero b = raiseDivZero_BigNat void# - | bigNatIsZero a = bigNatZero# void# + | bigNatIsZero b = raiseDivZero_BigNat (# #) + | bigNatIsZero a = bigNatZero# (# #) | bigNatIsOne b = a - | LT <- cmp = bigNatZero# void# - | EQ <- cmp = bigNatOne# void# + | LT <- cmp = bigNatZero# (# #) + | EQ <- cmp = bigNatOne# (# #) | isTrue# (szB ==# 1#) = bigNatQuotWord# a (bigNatIndex# b 0#) | True = withNewWordArrayTrimed# szQ \mwq s -> inline bignat_quot mwq a b s @@ -637,11 +637,11 @@ bigNatQuot a b -- | BigNat division returning remainder bigNatRem :: BigNat# -> BigNat# -> BigNat# bigNatRem a b - | bigNatIsZero b = raiseDivZero_BigNat void# - | bigNatIsZero a = bigNatZero# void# - | bigNatIsOne b = bigNatZero# void# + | bigNatIsZero b = raiseDivZero_BigNat (# #) + | bigNatIsZero a = bigNatZero# (# #) + | bigNatIsOne b = bigNatZero# (# #) | LT <- cmp = a - | EQ <- cmp = bigNatZero# void# + | EQ <- cmp = bigNatZero# (# #) | isTrue# (szB ==# 1#) = case bigNatRemWord# a (bigNatIndex# b 0#) of r -> bigNatFromWord# r | True = withNewWordArrayTrimed# szR \mwr s -> @@ -719,8 +719,8 @@ bigNatGcdWord# a b -- | Least common multiple bigNatLcm :: BigNat# -> BigNat# -> BigNat# bigNatLcm a b - | bigNatIsZero a = bigNatZero# void# - | bigNatIsZero b = bigNatZero# void# + | bigNatIsZero a = bigNatZero# (# #) + | bigNatIsZero b = bigNatZero# (# #) | bigNatIsOne a = b | bigNatIsOne b = a | True @@ -734,8 +734,8 @@ bigNatLcm a b -- | Least common multiple with a Word# bigNatLcmWord# :: BigNat# -> Word# -> BigNat# bigNatLcmWord# a b - | bigNatIsZero a = bigNatZero# void# - | 0## <- b = bigNatZero# void# + | bigNatIsZero a = bigNatZero# (# #) + | 0## <- b = bigNatZero# (# #) | bigNatIsOne a = bigNatFromWord# b | 1## <- b = a | 1# <- bigNatSize# a = bigNatLcmWordWord# (bigNatIndex# a 0#) b @@ -746,8 +746,8 @@ bigNatLcmWord# a b -- | Least common multiple between two Word# bigNatLcmWordWord# :: Word# -> Word# -> BigNat# bigNatLcmWordWord# a b - | 0## <- a = bigNatZero# void# - | 0## <- b = bigNatZero# void# + | 0## <- a = bigNatZero# (# #) + | 0## <- b = bigNatZero# (# #) | 1## <- a = bigNatFromWord# b | 1## <- b = bigNatFromWord# a | True = case (a `quotWord#` (a `gcdWord#` b)) `timesWord2#` b of @@ -879,7 +879,7 @@ bigNatShiftR# a n | nw <- word2Int# (n `uncheckedShiftRL#` WORD_SIZE_BITS_SHIFT#) , isTrue# (nw >=# wordArraySize# a) - = bigNatZero# void# + = bigNatZero# (# #) | True = let @@ -900,7 +900,7 @@ bigNatShiftRNeg# a n | nw <- word2Int# (n `uncheckedShiftRL#` WORD_SIZE_BITS_SHIFT#) , isTrue# (nw >=# wordArraySize# a) - = bigNatZero# void# + = bigNatZero# (# #) | True = let @@ -961,7 +961,7 @@ bigNatTestBit a (W# n) = isTrue# (bigNatTestBit# a n) -- bigNatBit# :: Word# -> BigNat# bigNatBit# i - | 0## <- i = bigNatOne# void# + | 0## <- i = bigNatOne# (# #) | True = let !nw = word2Int# (i `uncheckedShiftRL#` WORD_SIZE_BITS_SHIFT#) @@ -1000,7 +1000,7 @@ bigNatClearBit# a n | 0## <- nv , isTrue# (nw +# 1# ==# sz) -> case sz -# (waClzAt a (sz -# 2#) +# 1#) of - 0# -> bigNatZero# void# + 0# -> bigNatZero# (# #) nsz -> withNewWordArray# nsz \mwa s -> mwaArrayCopy# mwa 0# a 0# nsz s @@ -1060,7 +1060,7 @@ bigNatLog2 a = W# (bigNatLog2# a) bigNatLogBase# :: BigNat# -> BigNat# -> Word# bigNatLogBase# base a | bigNatIsZero base || bigNatIsOne base - = unexpectedValue_Word# void# + = unexpectedValue_Word# (# #) | 1# <- bigNatSize# base , 2## <- bigNatIndex# base 0# @@ -1086,8 +1086,8 @@ bigNatLogBase base a = W# (bigNatLogBase# base a) -- | Logarithm for an arbitrary base bigNatLogBaseWord# :: Word# -> BigNat# -> Word# bigNatLogBaseWord# base a - | 0## <- base = unexpectedValue_Word# void# - | 1## <- base = unexpectedValue_Word# void# + | 0## <- base = unexpectedValue_Word# (# #) + | 1## <- base = unexpectedValue_Word# (# #) | 2## <- base = bigNatLog2# a -- TODO: optimize log base power of 2 (256, etc.) | True = bigNatLogBase# (bigNatFromWord# base) a @@ -1106,7 +1106,7 @@ bigNatLogBaseWord (W# base) a = W# (bigNatLogBaseWord# base a) bigNatSizeInBase# :: Word# -> BigNat# -> Word# bigNatSizeInBase# base a | isTrue# (base `leWord#` 1##) - = unexpectedValue_Word# void# + = unexpectedValue_Word# (# #) | bigNatIsZero a = 0## @@ -1135,7 +1135,7 @@ powModWord# = bignat_powmod_words -- | \"@'bigNatPowModWord#' /b/ /e/ /m/@\" computes base @/b/@ raised to -- exponent @/e/@ modulo @/m/@. bigNatPowModWord# :: BigNat# -> BigNat# -> Word# -> Word# -bigNatPowModWord# !_ !_ 0## = raiseDivZero_Word# void# +bigNatPowModWord# !_ !_ 0## = raiseDivZero_Word# (# #) bigNatPowModWord# _ _ 1## = 0## bigNatPowModWord# b e m | bigNatIsZero e = 1## @@ -1149,7 +1149,7 @@ bigNatPowMod :: BigNat# -> BigNat# -> BigNat# -> BigNat# bigNatPowMod !b !e !m | (# m' | #) <- bigNatToWordMaybe# m = bigNatFromWord# (bigNatPowModWord# b e m') - | bigNatIsZero m = raiseDivZero_BigNat void# + | bigNatIsZero m = raiseDivZero_BigNat (# #) | bigNatIsOne m = bigNatFromWord# 0## | bigNatIsZero e = bigNatFromWord# 1## | bigNatIsZero b = bigNatFromWord# 0## @@ -1293,7 +1293,7 @@ bigNatToAddr a addr e = IO \s -> case bigNatToAddr# a addr e s of -- -- Higher limbs equal to 0 are automatically trimed. bigNatFromAddrLE# :: Word# -> Addr# -> State# s -> (# State# s, BigNat# #) -bigNatFromAddrLE# 0## _ s = (# s, bigNatZero# void# #) +bigNatFromAddrLE# 0## _ s = (# s, bigNatZero# (# #) #) bigNatFromAddrLE# sz addr s = let !nw = sz `uncheckedShiftRL#` WORD_SIZE_BYTES_SHIFT# @@ -1328,7 +1328,7 @@ bigNatFromAddrLE# sz addr s = -- -- Null higher limbs are automatically trimed. bigNatFromAddrBE# :: Word# -> Addr# -> State# s -> (# State# s, BigNat# #) -bigNatFromAddrBE# 0## _ s = (# s, bigNatZero# void# #) +bigNatFromAddrBE# 0## _ s = (# s, bigNatZero# (# #) #) bigNatFromAddrBE# sz addr s = let !nw = word2Int# (sz `uncheckedShiftRL#` WORD_SIZE_BYTES_SHIFT#) @@ -1454,7 +1454,7 @@ bigNatToMutableByteArray# a mba off _ s = bigNatToMutableByteArrayBE# a mba off -- -- Null higher limbs are automatically trimed. bigNatFromByteArrayLE# :: Word# -> ByteArray# -> Word# -> State# s -> (# State# s, BigNat# #) -bigNatFromByteArrayLE# 0## _ _ s = (# s, bigNatZero# void# #) +bigNatFromByteArrayLE# 0## _ _ s = (# s, bigNatZero# (# #) #) bigNatFromByteArrayLE# sz ba moff s = let !nw = sz `uncheckedShiftRL#` WORD_SIZE_BYTES_SHIFT# @@ -1489,7 +1489,7 @@ bigNatFromByteArrayLE# sz ba moff s = -- -- Null higher limbs are automatically trimed. bigNatFromByteArrayBE# :: Word# -> ByteArray# -> Word# -> State# s -> (# State# s, BigNat# #) -bigNatFromByteArrayBE# 0## _ _ s = (# s, bigNatZero# void# #) +bigNatFromByteArrayBE# 0## _ _ s = (# s, bigNatZero# (# #) #) bigNatFromByteArrayBE# sz ba moff s = let !nw = sz `uncheckedShiftRL#` WORD_SIZE_BYTES_SHIFT# ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat/Check.hs ===================================== @@ -42,7 +42,7 @@ bignat_compare a b = gr = Other.bignat_compare a b nr = Native.bignat_compare a b in case gr ==# nr of - 0# -> unexpectedValue_Int# void# + 0# -> unexpectedValue_Int# (# #) _ -> gr mwaCompare @@ -380,7 +380,7 @@ bignat_rem_word wa b = nr = Native.bignat_rem_word wa b in case gr `eqWord#` nr of 1# -> gr - _ -> unexpectedValue_Word# void# + _ -> unexpectedValue_Word# (# #) bignat_gcd :: MutableWordArray# RealWorld @@ -403,7 +403,7 @@ bignat_gcd_word wa b = nr = Native.bignat_gcd_word wa b in case gr `eqWord#` nr of 1# -> gr - _ -> unexpectedValue_Word# void# + _ -> unexpectedValue_Word# (# #) bignat_gcd_word_word :: Word# @@ -415,7 +415,7 @@ bignat_gcd_word_word a b = nr = Native.bignat_gcd_word_word a b in case gr `eqWord#` nr of 1# -> gr - _ -> unexpectedValue_Word# void# + _ -> unexpectedValue_Word# (# #) bignat_encode_double :: WordArray# -> Int# -> Double# bignat_encode_double a e = @@ -435,7 +435,7 @@ bignat_powmod_word b e m = nr = Native.bignat_powmod_word b e m in case gr `eqWord#` nr of 1# -> gr - _ -> unexpectedValue_Word# void# + _ -> unexpectedValue_Word# (# #) bignat_powmod :: MutableWordArray# RealWorld @@ -460,4 +460,4 @@ bignat_powmod_words b e m = nr = Native.bignat_powmod_words b e m in case gr `eqWord#` nr of 1# -> gr - _ -> unexpectedValue_Word# void# + _ -> unexpectedValue_Word# (# #) ===================================== libraries/ghc-bignum/src/GHC/Num/Integer.hs ===================================== @@ -120,7 +120,7 @@ integerToBigNatClamp# :: Integer -> BigNat# integerToBigNatClamp# (IP x) = x integerToBigNatClamp# (IS x) | isTrue# (x >=# 0#) = bigNatFromWord# (int2Word# x) -integerToBigNatClamp# _ = bigNatZero# void# +integerToBigNatClamp# _ = bigNatZero# (# #) -- | Create an Integer from an Int# integerFromInt# :: Int# -> Integer ===================================== libraries/ghc-bignum/src/GHC/Num/Primitives.hs ===================================== @@ -247,7 +247,7 @@ wordLog2# w = (WORD_SIZE_IN_BITS## `minusWord#` 1##) `minusWord#` (clz# w) wordLogBase# :: Word# -> Word# -> Word# wordLogBase# base a | isTrue# (base `leWord#` 1##) - = unexpectedValue_Word# void# + = unexpectedValue_Word# (# #) | 2## <- base = wordLog2# a @@ -616,19 +616,19 @@ ioBool (IO io) s = case io s of -- -- 0## is a dummy value (unreachable code) -- -unexpectedValue_Int# :: Void# -> Int# +unexpectedValue_Int# :: (# #) -> Int# unexpectedValue_Int# _ = case unexpectedValue of !_ -> 0# -- see Note [ghc-bignum exceptions] -unexpectedValue_Word# :: Void# -> Word# +unexpectedValue_Word# :: (# #) -> Word# unexpectedValue_Word# _ = case unexpectedValue of !_ -> 0## -- see Note [ghc-bignum exceptions] -raiseDivZero_Word# :: Void# -> Word# +raiseDivZero_Word# :: (# #) -> Word# raiseDivZero_Word# _ = case raiseDivZero of !_ -> 0## -- see Note [ghc-bignum exceptions] -raiseUnderflow_Word# :: Void# -> Word# +raiseUnderflow_Word# :: (# #) -> Word# raiseUnderflow_Word# _ = case raiseUnderflow of !_ -> 0## -- see Note [ghc-bignum exceptions] ===================================== libraries/ghc-prim/GHC/Prim/Exception.hs ===================================== @@ -28,9 +28,9 @@ default () -- Double and Integer aren't available yet -- raise exceptions in a normal way because it would create a dependency -- cycle (base <-> bignum package). See #14664 -foreign import prim "stg_raiseOverflowzh" raiseOverflow# :: State# RealWorld -> (# State# RealWorld, Void# #) -foreign import prim "stg_raiseUnderflowzh" raiseUnderflow# :: State# RealWorld -> (# State# RealWorld, Void# #) -foreign import prim "stg_raiseDivZZerozh" raiseDivZero# :: State# RealWorld -> (# State# RealWorld, Void# #) +foreign import prim "stg_raiseOverflowzh" raiseOverflow# :: State# RealWorld -> (# State# RealWorld, (# #) #) +foreign import prim "stg_raiseUnderflowzh" raiseUnderflow# :: State# RealWorld -> (# State# RealWorld, (# #) #) +foreign import prim "stg_raiseDivZZerozh" raiseDivZero# :: State# RealWorld -> (# State# RealWorld, (# #) #) -- We give a bottoming demand signature to 'raiseOverflow', 'raiseUnderflow' and -- 'raiseDivZero' in "GHC.Core.Make". NOINLINE pragmas are necessary because if ===================================== libraries/ghc-prim/GHC/Prim/Panic.hs ===================================== @@ -18,8 +18,8 @@ import GHC.Magic default () -- Double and Integer aren't available yet -- `stg_panic#` never returns but it can't just return `State# RealWorld` so we --- indicate that it returns `Void#` too to make the compiler happy. -foreign import prim "stg_paniczh" panic# :: Addr# -> State# RealWorld -> (# State# RealWorld, Void# #) +-- indicate that it returns `(# #)` too to make the compiler happy. +foreign import prim "stg_paniczh" panic# :: Addr# -> State# RealWorld -> (# State# RealWorld, (# #) #) -- | Display the CString whose address is given as an argument and exit. panicError :: Addr# -> a ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -38,6 +38,7 @@ module GHC.Types ( -- `type *`, without the parentheses. But that's a true -- pain to parse, and for little gain. VecCount(..), VecElem(..), + Void#, -- * Runtime type representation Module(..), TrName(..), TyCon(..), TypeLitSort(..), @@ -462,6 +463,9 @@ data VecElem = Int8ElemRep | DoubleElemRep -- Enum, Bounded instances in GHC.Enum +{-# DEPRECATED Void# "Void# is now an alias for the unboxed tuple (# #)." #-} +type Void# = (# #) + {- ********************************************************************* * * Runtime representation of TyCon ===================================== testsuite/tests/codeGen/should_compile/T12115.hs ===================================== @@ -5,5 +5,5 @@ module T12115 where import GHC.Prim import GHC.Types -f :: (# Void#, (# #) #) -> String +f :: (# (# #), (# #) #) -> String f = f ===================================== testsuite/tests/printer/T18052a.stderr ===================================== @@ -25,7 +25,7 @@ T18052a.$b:||: = \ (@a) (@b) (x :: a) (y :: b) -> (x, y) -- RHS size: {terms: 13, types: 20, coercions: 0, joins: 0/0} T18052a.$m:||: :: forall {rep :: GHC.Types.RuntimeRep} {r :: TYPE rep} {a} {b}. - (a, b) -> (a -> b -> r) -> (GHC.Prim.Void# -> r) -> r + (a, b) -> (a -> b -> r) -> ((# #) -> r) -> r [GblId, Arity=3, Unf=OtherCon []] T18052a.$m:||: = \ (@(rep :: GHC.Types.RuntimeRep)) ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -6,9 +6,9 @@ Result size of Tidy Core Rec { -- RHS size: {terms: 4, types: 4, coercions: 0, joins: 0/0} T13143.$wf [InlPrag=NOINLINE, Occ=LoopBreaker] - :: forall {a}. GHC.Prim.Void# -> a + :: forall {a}. (# #) -> a [GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] -T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.void# +T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) end Rec } -- RHS size: {terms: 4, types: 4, coercions: 0, joins: 0/0} @@ -20,8 +20,8 @@ f [InlPrag=NOUSERINLINE[final]] :: forall a. Int -> a Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True) - Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.void#}] -f = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.void# + Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##)}] +f = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T13143.$trModule4 :: GHC.Prim.Addr# @@ -62,7 +62,7 @@ T13143.$trModule -- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} lvl :: Int [GblId, Str=b, Cpr=b] -lvl = T13143.$wf @Int GHC.Prim.void# +lvl = T13143.$wf @Int GHC.Prim.(##) Rec { -- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0} ===================================== testsuite/tests/unboxedsums/ffi1.hs ===================================== @@ -2,7 +2,7 @@ module Lib where -import GHC.Prim +import GHC.Exts -- Can't unboxed tuples and sums to FFI, we should fail appropriately. ===================================== utils/genprimopcode/Main.hs ===================================== @@ -923,8 +923,6 @@ ppType (TyApp (TyCon "IOPort#") [x,y]) = "mkIOPortPrimTy " ++ ppType x ++ " " ++ ppType y ppType (TyApp (TyCon "TVar#") [x,y]) = "mkTVarPrimTy " ++ ppType x ++ " " ++ ppType y -ppType (TyApp (TyCon "Void#") []) = "voidPrimTy" - ppType (TyApp (VecTyCon _ pptc) []) = pptc ppType (TyUTup ts) = "(mkTupleTy Unboxed " View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cfa89149b55837f822ba619b797781813fdcdabc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cfa89149b55837f822ba619b797781813fdcdabc You're receiving 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 Jul 23 00:22:32 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 22 Jul 2020 20:22:32 -0400 Subject: [Git][ghc/ghc][master] Add regression test for #18478 Message-ID: <5f18d8487e1d4_80bd68a9b8462704b@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 2 changed files: - + testsuite/tests/pmcheck/should_compile/T18478.hs - testsuite/tests/pmcheck/should_compile/all.T Changes: ===================================== testsuite/tests/pmcheck/should_compile/T18478.hs ===================================== @@ -0,0 +1,951 @@ +{-# LANGUAGE UndecidableSuperClasses, FunctionalDependencies, RoleAnnotations, ExplicitNamespaces, TypeFamilies, RankNTypes, TypeApplications, LambdaCase, DerivingStrategies, ScopedTypeVariables, TypeOperators, DataKinds, PolyKinds, GADTs, TypeFamilyDependencies, ConstraintKinds, UndecidableInstances, TypeSynonymInstances, FlexibleInstances, DeriveGeneric, AllowAmbiguousTypes, StrictData #-} +{-# OPTIONS_GHC -Wno-redundant-constraints -fforce-recomp -Wincomplete-patterns #-} + +{- | Module, containing restrictions imposed by instruction or value scope. + +Michelson have multiple restrictions on values, examples: +* @operation@ type cannot appear in parameter. +* @big_map@ type cannot appear in @PUSH at -able constants. +* @contract@ type cannot appear in type we @UNPACK@ to. + +Thus we declare multiple "scopes" - constraints applied in corresponding +situations, for instance +* 'ParameterScope'; +* 'StorageScope'; +* 'ConstantScope'. + +Also we separate multiple "classes" of scope-related constraints. + +* 'ParameterScope' and similar ones are used within Michelson engine, +they are understandable by GHC but produce not very clarifying errors. + +* 'ProperParameterBetterErrors' and similar ones are middle-layer constraints, +they produce human-readable errors but GHC cannot make conclusions from them. +They are supposed to be used only by eDSLs to define their own high-level +constraints. + +* Lorentz and other eDSLs may declare their own constraints, in most cases +you should use them. For example see 'Lorentz.Constraints' module. + +-} + +module T18478 + ( -- * Scopes + ConstantScope + , StorageScope + , PackedValScope + , ParameterScope + , PrintedValScope + , UnpackedValScope + + , ProperParameterBetterErrors + , ProperStorageBetterErrors + , ProperConstantBetterErrors + , ProperPackedValBetterErrors + , ProperUnpackedValBetterErrors + , ProperPrintedValBetterErrors + + , properParameterEvi + , properStorageEvi + , properConstantEvi + , properPackedValEvi + , properUnpackedValEvi + , properPrintedValEvi + , (:-)(..) + + , BadTypeForScope (..) + , CheckScope (..) + + -- * Implementation internals + , HasNoBigMap + , HasNoNestedBigMaps + , HasNoOp + , HasNoContract + , ContainsBigMap + , ContainsNestedBigMaps + + , ForbidOp + , ForbidContract + , ForbidBigMap + , ForbidNestedBigMaps + , FailOnBigMapFound + , FailOnNestedBigMapsFound + , FailOnOperationFound + + , OpPresence (..) + , ContractPresence (..) + , BigMapPresence (..) + , NestedBigMapsPresence (..) + , checkOpPresence + , checkContractTypePresence + , checkBigMapPresence + , checkNestedBigMapsPresence + , opAbsense + , contractTypeAbsense + , bigMapAbsense + , nestedBigMapsAbsense + , forbiddenOp + , forbiddenContractType + , forbiddenBigMap + , forbiddenNestedBigMaps + + -- * Re-exports + , withDict + , SingI (..) + ) where + +import Data.Type.Bool (type (||)) +import Data.Type.Coercion +import GHC.TypeLits (ErrorMessage(..), TypeError) +import Data.Typeable +import GHC.Generics +import GHC.Exts +import Data.Kind + +data T = + TKey + | TUnit + | TSignature + | TChainId + | TOption T + | TList T + | TSet T + | TOperation + | TContract T + | TPair T T + | TOr T T + | TLambda T T + | TMap T T + | TBigMap T T + | TInt + | TNat + | TString + | TBytes + | TMutez + | TBool + | TKeyHash + | TTimestamp + | TAddress + deriving stock (Eq, Show) + +type family Sing :: k -> Type + +class SingI a where + sing :: Sing a + +class SingKind (k :: Type) where + -- | Get a base type from the promoted kind. For example, + -- @Demote Bool@ will be the type @Bool at . Rarely, the type and kind do not + -- match. For example, @Demote Nat@ is @Natural at . + type Demote k = (r :: Type) | r -> k + + -- | Convert a singleton to its unrefined version. + fromSing :: Sing (a :: k) -> Demote k + + -- | Convert an unrefined type to an existentially-quantified singleton type. + toSing :: Demote k -> SomeSing k + +data SomeSing (k :: Type) :: Type where + SomeSing :: Sing (a :: k) -> SomeSing k + + +-- | Instance of data family 'Sing' for 'T'. +-- Custom instance is implemented in order to inject 'Typeable' +-- constraint for some of constructors. +data SingT :: T -> Type where + STKey :: SingT 'TKey + STUnit :: SingT 'TUnit + STSignature :: SingT 'TSignature + STChainId :: SingT 'TChainId + STOption :: (SingI a, Typeable a) => Sing a -> SingT ( 'TOption a) + STList :: (SingI a, Typeable a) => Sing a -> SingT ( 'TList a ) + STSet :: (SingI a, Typeable a) => Sing a -> SingT ( 'TSet a ) + STOperation :: SingT 'TOperation + STContract :: (SingI a, Typeable a) + => Sing a -> SingT ( 'TContract a ) + STPair :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TPair a b) + STOr :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TOr a b) + STLambda :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TLambda a b) + STMap :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TMap a b) + STBigMap :: (SingI a, SingI b, Typeable a, Typeable b) + => Sing a -> Sing b -> SingT ('TBigMap a b) + STInt :: SingT 'TInt + STNat :: SingT 'TNat + STString :: SingT 'TString + STBytes :: SingT 'TBytes + STMutez :: SingT 'TMutez + STBool :: SingT 'TBool + STKeyHash :: SingT 'TKeyHash + STTimestamp :: SingT 'TTimestamp + STAddress :: SingT 'TAddress + +type instance Sing = SingT + +--------------------------------------------- +-- Singleton-related helpers for T +-------------------------------------------- + +-- | Version of 'SomeSing' with 'Typeable' constraint, +-- specialized for use with 'T' kind. +data SomeSingT where + SomeSingT :: forall (a :: T). (Typeable a, SingI a) + => Sing a -> SomeSingT + +-- | Version of 'withSomeSing' with 'Typeable' constraint +-- provided to processing function. +-- +-- Required for not to erase these useful constraints when doing +-- conversion from value of type 'T' to its singleton representation. +withSomeSingT + :: T + -> (forall (a :: T). (Typeable a, SingI a) => Sing a -> r) + -> r +withSomeSingT t f = (\(SomeSingT s) -> f s) (toSingT t) + +-- | Version of 'fromSing' specialized for use with +-- @data instance Sing :: T -> Type@ which requires 'Typeable' +-- constraint for some of its constructors +fromSingT :: Sing (a :: T) -> T +fromSingT = \case + STKey -> TKey + STUnit -> TUnit + STSignature -> TSignature + STChainId -> TChainId + STOption t -> TOption (fromSingT t) + STList t -> TList (fromSingT t) + STSet t -> TSet (fromSingT t) + STOperation -> TOperation + STContract t -> TContract (fromSingT t) + STPair a b -> TPair (fromSingT a) (fromSingT b) + STOr a b -> TOr (fromSingT a) (fromSingT b) + STLambda a b -> TLambda (fromSingT a) (fromSingT b) + STMap a b -> TMap (fromSingT a) (fromSingT b) + STBigMap a b -> TBigMap (fromSingT a) (fromSingT b) + STInt -> TInt + STNat -> TNat + STString -> TString + STBytes -> TBytes + STMutez -> TMutez + STBool -> TBool + STKeyHash -> TKeyHash + STTimestamp -> TTimestamp + STAddress -> TAddress + +-- | Version of 'toSing' which creates 'SomeSingT'. +toSingT :: T -> SomeSingT +toSingT = \case + TKey -> SomeSingT STKey + TUnit -> SomeSingT STUnit + TSignature -> SomeSingT STSignature + TChainId -> SomeSingT STChainId + TOption t -> withSomeSingT t $ \tSing -> SomeSingT $ STOption tSing + TList t -> withSomeSingT t $ \tSing -> SomeSingT $ STList tSing + TSet ct -> withSomeSingT ct $ \ctSing -> SomeSingT $ STSet ctSing + TOperation -> SomeSingT STOperation + TContract t -> withSomeSingT t $ \tSing -> SomeSingT $ STContract tSing + TPair l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STPair lSing rSing + TOr l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STOr lSing rSing + TLambda l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STLambda lSing rSing + TMap l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STMap lSing rSing + TBigMap l r -> + withSomeSingT l $ \lSing -> + withSomeSingT r $ \rSing -> + SomeSingT $ STBigMap lSing rSing + TInt -> SomeSingT STInt + TNat -> SomeSingT STNat + TString -> SomeSingT STString + TBytes -> SomeSingT STBytes + TMutez -> SomeSingT STMutez + TBool -> SomeSingT STBool + TKeyHash -> SomeSingT STKeyHash + TTimestamp -> SomeSingT STTimestamp + TAddress -> SomeSingT STAddress + +instance SingKind T where + type Demote T = T + fromSing = fromSingT + toSing t = case toSingT t of SomeSingT s -> SomeSing s + +instance SingI 'TKey where + sing = STKey +instance SingI 'TUnit where + sing = STUnit +instance SingI 'TSignature where + sing = STSignature +instance SingI 'TChainId where + sing = STChainId +instance (SingI a, Typeable a) => SingI ( 'TOption (a :: T)) where + sing = STOption sing +instance (SingI a, Typeable a) => SingI ( 'TList (a :: T)) where + sing = STList sing +instance (SingI a, Typeable a) => SingI ( 'TSet (a :: T)) where + sing = STSet sing +instance SingI 'TOperation where + sing = STOperation +instance (SingI a, Typeable a) => + SingI ( 'TContract (a :: T)) where + sing = STContract sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TPair a b) where + sing = STPair sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TOr a b) where + sing = STOr sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TLambda a b) where + sing = STLambda sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TMap a b) where + sing = STMap sing sing +instance (SingI a, Typeable a, Typeable b, SingI b) => + SingI ( 'TBigMap a b) where + sing = STBigMap sing sing +instance SingI 'TInt where + sing = STInt +instance SingI 'TNat where + sing = STNat +instance SingI 'TString where + sing = STString +instance SingI 'TBytes where + sing = STBytes +instance SingI 'TMutez where + sing = STMutez +instance SingI 'TBool where + sing = STBool +instance SingI 'TKeyHash where + sing = STKeyHash +instance SingI 'TTimestamp where + sing = STTimestamp +instance SingI 'TAddress where + sing = STAddress + +data Dict :: Constraint -> Type where + Dict :: a => Dict a + deriving Typeable + +withDict :: HasDict c e => e -> (c => r) -> r +withDict d r = case evidence d of + Dict -> r + +class HasDict c e | e -> c where + evidence :: e -> Dict c + +instance HasDict a (Dict a) where + evidence = Prelude.id + +instance a => HasDict b (a :- b) where + evidence (Sub x) = x + +instance HasDict (Coercible a b) (Coercion a b) where + evidence Coercion = Dict + +instance HasDict (a ~ b) (a :~: b) where + evidence Refl = Dict + +infixl 1 \\ -- required comment + +(\\) :: HasDict c e => (c => r) -> e -> r +r \\ d = withDict d r +infixr 9 :- +newtype a :- b = Sub (a => Dict b) + deriving Typeable +type role (:-) nominal nominal +(***) :: (a :- b) -> (c :- d) -> (a, c) :- (b, d) +f *** g = Sub $ Dict \\ f \\ g + +type f $ a = f a +infixr 2 $ + +maybeToRight a Nothing = Left a +maybeToRight _ (Just a) = Right a + +---------------------------------------------------------------------------- +-- Constraints +---------------------------------------------------------------------------- +-- | Whether this type contains 'TOperation' type. +-- +-- In some scopes (constants, parameters, storage) appearing for operation type +-- is prohibited. +-- Operations in input/output of lambdas are allowed without limits though. +type family ContainsOp (t :: T) :: Bool where + ContainsOp 'TKey = 'False + ContainsOp 'TUnit = 'False + ContainsOp 'TSignature = 'False + ContainsOp 'TChainId = 'False + ContainsOp ('TOption t) = ContainsOp t + ContainsOp ('TList t) = ContainsOp t + ContainsOp ('TSet t) = ContainsOp t + ContainsOp 'TOperation = 'True + ContainsOp ('TContract t) = ContainsOp t + ContainsOp ('TPair a b) = ContainsOp a || ContainsOp b + ContainsOp ('TOr a b) = ContainsOp a || ContainsOp b + ContainsOp ('TLambda _ _) = 'False + ContainsOp ('TMap k v) = ContainsOp k || ContainsOp v + ContainsOp ('TBigMap k v) = ContainsOp k || ContainsOp v + ContainsOp _ = 'False + +-- | Whether this type contains 'TContract' type. +-- +-- In some scopes (constants, storage) appearing for contract type +-- is prohibited. +-- Contracts in input/output of lambdas are allowed without limits though. +type family ContainsContract (t :: T) :: Bool where + ContainsContract 'TKey = 'False + ContainsContract 'TUnit = 'False + ContainsContract 'TSignature = 'False + ContainsContract 'TChainId = 'False + ContainsContract ('TOption t) = ContainsContract t + ContainsContract ('TList t) = ContainsContract t + ContainsContract ('TSet _) = 'False + ContainsContract 'TOperation = 'False + ContainsContract ('TContract _) = 'True + ContainsContract ('TPair a b) = ContainsContract a || ContainsContract b + ContainsContract ('TOr a b) = ContainsContract a || ContainsContract b + ContainsContract ('TLambda _ _) = 'False + ContainsContract ('TMap _ v) = ContainsContract v + ContainsContract ('TBigMap _ v) = ContainsContract v + ContainsContract _ = 'False + +-- | Whether this type contains 'TBigMap' type. +type family ContainsBigMap (t :: T) :: Bool where + ContainsBigMap 'TKey = 'False + ContainsBigMap 'TUnit = 'False + ContainsBigMap 'TSignature = 'False + ContainsBigMap 'TChainId = 'False + ContainsBigMap ('TOption t) = ContainsBigMap t + ContainsBigMap ('TList t) = ContainsBigMap t + ContainsBigMap ('TSet _) = 'False + ContainsBigMap 'TOperation = 'False + ContainsBigMap ('TContract t) = ContainsBigMap t + ContainsBigMap ('TPair a b) = ContainsBigMap a || ContainsBigMap b + ContainsBigMap ('TOr a b) = ContainsBigMap a || ContainsBigMap b + ContainsBigMap ('TLambda _ _) = 'False + ContainsBigMap ('TMap _ v) = ContainsBigMap v + ContainsBigMap ('TBigMap _ _) = 'True + ContainsBigMap _ = 'False + +-- | Whether this type contains a type with nested 'TBigMap's . +-- +-- Nested big_maps (i.e. big_map which contains another big_map inside of it's value type). Are +-- prohibited in all contexts. Some context such as PUSH, APPLY, PACK/UNPACK instructions are more +-- strict because they doesn't work with big_map at all. +type family ContainsNestedBigMaps (t :: T) :: Bool where + ContainsNestedBigMaps 'TKey = 'False + ContainsNestedBigMaps 'TUnit = 'False + ContainsNestedBigMaps 'TSignature = 'False + ContainsNestedBigMaps 'TChainId = 'False + ContainsNestedBigMaps ('TOption t) = ContainsNestedBigMaps t + ContainsNestedBigMaps ('TList t) = ContainsNestedBigMaps t + ContainsNestedBigMaps ('TSet _) = 'False + ContainsNestedBigMaps 'TOperation = 'False + ContainsNestedBigMaps ('TContract t) = ContainsNestedBigMaps t + ContainsNestedBigMaps ('TPair a b) = ContainsNestedBigMaps a || ContainsNestedBigMaps b + ContainsNestedBigMaps ('TOr a b) = ContainsNestedBigMaps a || ContainsNestedBigMaps b + ContainsNestedBigMaps ('TLambda _ _) = 'False + ContainsNestedBigMaps ('TMap _ v) = ContainsNestedBigMaps v + ContainsNestedBigMaps ('TBigMap _ v) = ContainsBigMap v + ContainsNestedBigMaps _ = 'False + +-- | Constraint which ensures that operation type does not appear in a given type. +-- +-- Not just a type alias in order to be able to partially apply it +-- (e.g. in 'Each'). +class (ContainsOp t ~ 'False) => HasNoOp t +instance (ContainsOp t ~ 'False) => HasNoOp t + +-- | Constraint which ensures that contract type does not appear in a given type. +class (ContainsContract t ~ 'False) => HasNoContract t +instance (ContainsContract t ~ 'False) => HasNoContract t + +-- | Constraint which ensures that bigmap does not appear in a given type. +class (ContainsBigMap t ~ 'False) => HasNoBigMap t +instance (ContainsBigMap t ~ 'False) => HasNoBigMap t + +-- | Constraint which ensures that there are no nested bigmaps. +class (ContainsNestedBigMaps t ~ 'False) => HasNoNestedBigMaps t +instance (ContainsNestedBigMaps t ~ 'False) => HasNoNestedBigMaps t + +-- | Report a human-readable error about 'TOperation' at a wrong place. +type family FailOnOperationFound (enabled :: Bool) :: Constraint where + FailOnOperationFound 'True = + TypeError ('Text "Operations are not allowed in this scope") + FailOnOperationFound 'False = () + +-- | Report a human-readable error about 'TContract' at a wrong place. +type family FailOnContractFound (enabled :: Bool) :: Constraint where + FailOnContractFound 'True = + TypeError ('Text "Type `contract` is not allowed in this scope") + FailOnContractFound 'False = () + +-- | Report a human-readable error about 'TBigMap' at a wrong place. +type family FailOnBigMapFound (enabled :: Bool) :: Constraint where + FailOnBigMapFound 'True = + TypeError ('Text "BigMaps are not allowed in this scope") + FailOnBigMapFound 'False = () + +-- | Report a human-readable error that 'TBigMap' contains another 'TBigMap' +type family FailOnNestedBigMapsFound (enabled :: Bool) :: Constraint where + FailOnNestedBigMapsFound 'True = + TypeError ('Text "Nested BigMaps are not allowed") + FailOnNestedBigMapsFound 'False = () + +-- | This is like 'HasNoOp', it raises a more human-readable error +-- when @t@ type is concrete, but GHC cannot make any conclusions +-- from such constraint as it can for 'HasNoOp'. +-- Though, hopefully, it will someday: +-- . +-- +-- Use this constraint in our eDSL. +type ForbidOp t = FailOnOperationFound (ContainsOp t) + +type ForbidContract t = FailOnContractFound (ContainsContract t) + +type ForbidBigMap t = FailOnBigMapFound (ContainsBigMap t) + +type ForbidNestedBigMaps t = FailOnNestedBigMapsFound (ContainsNestedBigMaps t) + +-- | Evidence of that 'HasNoOp' is deducable from 'ForbidOp'. +forbiddenOpEvi :: forall t. (SingI t, ForbidOp t) :- HasNoOp t +forbiddenOpEvi = Sub $ + -- It's not clear now to proof GHC that @HasNoOp t@ is implication of + -- @ForbidOp t@, so we use @error@ below and also disable + -- "-Wredundant-constraints" extension. + case checkOpPresence (sing @t) of + OpAbsent -> Dict + OpPresent -> error "impossible" + +-- | Reify 'HasNoOp' contraint from 'ForbidOp'. +-- +-- Left for backward compatibility. +forbiddenOp + :: forall t a. + (SingI t, ForbidOp t) + => (HasNoOp t => a) + -> a +forbiddenOp = withDict $ forbiddenOpEvi @t + +forbiddenBigMapEvi :: forall t. (SingI t, ForbidBigMap t) :- HasNoBigMap t +forbiddenBigMapEvi = Sub $ + case checkBigMapPresence (sing @t) of + BigMapAbsent -> Dict + BigMapPresent -> error "impossible" + +forbiddenNestedBigMapsEvi :: forall t. (SingI t, ForbidNestedBigMaps t) :- HasNoNestedBigMaps t +forbiddenNestedBigMapsEvi = Sub $ + case checkNestedBigMapsPresence (sing @t) of + NestedBigMapsAbsent -> Dict + NestedBigMapsPresent -> error "impossible" + +forbiddenBigMap + :: forall t a. + (SingI t, ForbidBigMap t) + => (HasNoBigMap t => a) + -> a +forbiddenBigMap = withDict $ forbiddenBigMapEvi @t + +forbiddenNestedBigMaps + :: forall t a. + (SingI t, ForbidNestedBigMaps t) + => (HasNoNestedBigMaps t => a) + -> a +forbiddenNestedBigMaps = withDict $ forbiddenNestedBigMapsEvi @t + +-- | Reify 'HasNoContract' contraint from 'ForbidContract'. +forbiddenContractTypeEvi + :: forall t. (SingI t, ForbidContract t) :- HasNoContract t +forbiddenContractTypeEvi = Sub $ + case checkContractTypePresence (sing @t) of + ContractAbsent -> Dict + ContractPresent -> error "impossible" + +-- | Reify 'HasNoContract' contraint from 'ForbidContract'. +forbiddenContractType + :: forall t a. + (SingI t, ForbidContract t) + => (HasNoContract t => a) + -> a +forbiddenContractType = withDict $ forbiddenContractTypeEvi @t + +-- | Whether the type contains 'TOperation', with proof. +data OpPresence (t :: T) + = ContainsOp t ~ 'True => OpPresent + | ContainsOp t ~ 'False => OpAbsent + +data ContractPresence (t :: T) + = ContainsContract t ~ 'True => ContractPresent + | ContainsContract t ~ 'False => ContractAbsent + +data BigMapPresence (t :: T) + = ContainsBigMap t ~ 'True => BigMapPresent + | ContainsBigMap t ~ 'False => BigMapAbsent + +data NestedBigMapsPresence (t :: T) + = ContainsNestedBigMaps t ~ 'True => NestedBigMapsPresent + | ContainsNestedBigMaps t ~ 'False => NestedBigMapsAbsent + +-- @rvem: IMO, generalization of OpPresence and BigMapPresence to +-- TPresence is not worth it, due to the fact that +-- it will require more boilerplate in checkTPresence implementation +-- than it is already done in checkOpPresence and checkBigMapPresence + +-- | Check at runtime whether the given type contains 'TOperation'. +checkOpPresence :: Sing (ty :: T) -> OpPresence ty +checkOpPresence = \case + -- This is a sad amount of boilerplate, but at least + -- there is no chance to make a mistake in it. + -- We can't do in a simpler way while requiring only @Sing ty@ / @SingI ty@, + -- and a more complex constraint would be too unpleasant and confusing to + -- propagate everywhere. + STKey -> OpAbsent + STSignature -> OpAbsent + STChainId -> OpAbsent + STUnit -> OpAbsent + STOption t -> case checkOpPresence t of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STList t -> case checkOpPresence t of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STSet a -> case checkOpPresence a of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STOperation -> OpPresent + STContract t -> case checkOpPresence t of + OpPresent -> OpPresent + OpAbsent -> OpAbsent + STPair a b -> case (checkOpPresence a, checkOpPresence b) of + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + (OpAbsent, OpAbsent) -> OpAbsent + STOr a b -> case (checkOpPresence a, checkOpPresence b) of + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + (OpAbsent, OpAbsent) -> OpAbsent + STLambda _ _ -> OpAbsent + STMap k v -> case (checkOpPresence k, checkOpPresence v) of + (OpAbsent, OpAbsent) -> OpAbsent + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + STBigMap k v -> case (checkOpPresence k, checkOpPresence v) of + (OpAbsent, OpAbsent) -> OpAbsent + (OpPresent, _) -> OpPresent + (_, OpPresent) -> OpPresent + STInt -> OpAbsent + STNat -> OpAbsent + STString -> OpAbsent + STBytes -> OpAbsent + STMutez -> OpAbsent + STBool -> OpAbsent + STKeyHash -> OpAbsent + STTimestamp -> OpAbsent + STAddress -> OpAbsent + +-- | Check at runtime whether the given type contains 'TContract'. +checkContractTypePresence :: Sing (ty :: T) -> ContractPresence ty +checkContractTypePresence = \case + STKey -> ContractAbsent + STSignature -> ContractAbsent + STChainId -> ContractAbsent + STUnit -> ContractAbsent + STOption t -> case checkContractTypePresence t of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STList t -> case checkContractTypePresence t of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STSet _ -> ContractAbsent + STOperation -> ContractAbsent + STContract _ -> ContractPresent + STPair a b -> case (checkContractTypePresence a, checkContractTypePresence b) of + (ContractPresent, _) -> ContractPresent + (_, ContractPresent) -> ContractPresent + (ContractAbsent, ContractAbsent) -> ContractAbsent + STOr a b -> case (checkContractTypePresence a, checkContractTypePresence b) of + (ContractPresent, _) -> ContractPresent + (_, ContractPresent) -> ContractPresent + (ContractAbsent, ContractAbsent) -> ContractAbsent + STLambda _ _ -> ContractAbsent + STMap _ v -> case checkContractTypePresence v of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STBigMap _ v -> case checkContractTypePresence v of + ContractPresent -> ContractPresent + ContractAbsent -> ContractAbsent + STInt -> ContractAbsent + STNat -> ContractAbsent + STString -> ContractAbsent + STBytes -> ContractAbsent + STMutez -> ContractAbsent + STBool -> ContractAbsent + STKeyHash -> ContractAbsent + STTimestamp -> ContractAbsent + STAddress -> ContractAbsent + +-- | Check at runtime whether the given type contains 'TBigMap'. +checkBigMapPresence :: Sing (ty :: T) -> BigMapPresence ty +checkBigMapPresence = \case + -- More boilerplate to boilerplate god. + STKey -> BigMapAbsent + STSignature -> BigMapAbsent + STChainId -> BigMapAbsent + STUnit -> BigMapAbsent + STOption t -> case checkBigMapPresence t of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STList t -> case checkBigMapPresence t of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STSet _ -> BigMapAbsent + STOperation -> BigMapAbsent + STContract t -> case checkBigMapPresence t of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STPair a b -> case (checkBigMapPresence a, checkBigMapPresence b) of + (BigMapPresent, _) -> BigMapPresent + (_, BigMapPresent) -> BigMapPresent + (BigMapAbsent, BigMapAbsent) -> BigMapAbsent + STOr a b -> case (checkBigMapPresence a, checkBigMapPresence b) of + (BigMapPresent, _) -> BigMapPresent + (_, BigMapPresent) -> BigMapPresent + (BigMapAbsent, BigMapAbsent) -> BigMapAbsent + STLambda _ _ -> BigMapAbsent + STMap _ v -> case checkBigMapPresence v of + BigMapPresent -> BigMapPresent + BigMapAbsent -> BigMapAbsent + STBigMap _ _ -> + BigMapPresent + STInt -> BigMapAbsent + STNat -> BigMapAbsent + STString -> BigMapAbsent + STBytes -> BigMapAbsent + STMutez -> BigMapAbsent + STBool -> BigMapAbsent + STKeyHash -> BigMapAbsent + STTimestamp -> BigMapAbsent + STAddress -> BigMapAbsent + +-- | Check at runtime whether the given type contains 'TBigMap'. +checkNestedBigMapsPresence :: Sing (ty :: T) -> NestedBigMapsPresence ty +checkNestedBigMapsPresence = \case + -- More boilerplate to boilerplate god. + STKey -> NestedBigMapsAbsent + STSignature -> NestedBigMapsAbsent + STChainId -> NestedBigMapsAbsent + STUnit -> NestedBigMapsAbsent + STOption t -> case checkNestedBigMapsPresence t of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STList t -> case checkNestedBigMapsPresence t of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STSet _ -> NestedBigMapsAbsent + STOperation -> NestedBigMapsAbsent + STContract t -> case checkNestedBigMapsPresence t of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STPair a b -> case (checkNestedBigMapsPresence a, checkNestedBigMapsPresence b) of + (NestedBigMapsPresent, _) -> NestedBigMapsPresent + (_, NestedBigMapsPresent) -> NestedBigMapsPresent + (NestedBigMapsAbsent, NestedBigMapsAbsent) -> NestedBigMapsAbsent + STOr a b -> case (checkNestedBigMapsPresence a, checkNestedBigMapsPresence b) of + (NestedBigMapsPresent, _) -> NestedBigMapsPresent + (_, NestedBigMapsPresent) -> NestedBigMapsPresent + (NestedBigMapsAbsent, NestedBigMapsAbsent) -> NestedBigMapsAbsent + STLambda _ _ -> NestedBigMapsAbsent + STMap _ v -> case checkNestedBigMapsPresence v of + NestedBigMapsPresent -> NestedBigMapsPresent + NestedBigMapsAbsent -> NestedBigMapsAbsent + STBigMap _ v -> case checkBigMapPresence v of + BigMapPresent -> NestedBigMapsPresent + BigMapAbsent -> NestedBigMapsAbsent + STInt -> NestedBigMapsAbsent + STNat -> NestedBigMapsAbsent + STString -> NestedBigMapsAbsent + STBytes -> NestedBigMapsAbsent + STMutez -> NestedBigMapsAbsent + STBool -> NestedBigMapsAbsent + STKeyHash -> NestedBigMapsAbsent + STTimestamp -> NestedBigMapsAbsent + STAddress -> NestedBigMapsAbsent + +-- | Check at runtime that the given type does not contain 'TOperation'. +opAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoOp t) +opAbsense s = case checkOpPresence s of + OpPresent -> Nothing + OpAbsent -> Just Dict + +-- | Check at runtime that the given type does not contain 'TContract'. +contractTypeAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoContract t) +contractTypeAbsense s = case checkContractTypePresence s of + ContractPresent -> Nothing + ContractAbsent -> Just Dict + +-- | Check at runtime that the given type does not containt 'TBigMap' +bigMapAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoBigMap t) +bigMapAbsense s = case checkBigMapPresence s of + BigMapPresent -> Nothing + BigMapAbsent -> Just Dict + +-- | Check at runtime that the given type does not contain nested 'TBigMap' +nestedBigMapsAbsense :: Sing (t :: T) -> Maybe (Dict $ HasNoNestedBigMaps t) +nestedBigMapsAbsense s = case checkNestedBigMapsPresence s of + NestedBigMapsPresent -> Nothing + NestedBigMapsAbsent -> Just Dict + +---------------------------------------------------------------------------- +-- Scopes +---------------------------------------------------------------------------- + +data BadTypeForScope + = BtNotComparable + | BtIsOperation + | BtHasBigMap + | BtHasNestedBigMap + | BtHasContract + deriving stock (Show, Eq, Generic) + +-- | Alias for constraints which Michelson applies to parameter. +type ParameterScope t = + (Typeable t, SingI t, HasNoOp t, HasNoNestedBigMaps t) + +-- | Alias for constraints which Michelson applies to contract storage. +type StorageScope t = + (Typeable t, SingI t, HasNoOp t, HasNoNestedBigMaps t, HasNoContract t) + +-- | Alias for constraints which Michelson applies to pushed constants. +type ConstantScope t = + (SingI t, HasNoOp t, HasNoBigMap t, HasNoContract t) + +-- | Alias for constraints which Michelson applies to packed values. +type PackedValScope t = + (SingI t, HasNoOp t, HasNoBigMap t) + +-- | Alias for constraints which Michelson applies to unpacked values. +-- +-- It is different from 'PackedValScope', e.g. @contract@ type cannot appear +-- in a value we unpack to. +type UnpackedValScope t = + (PackedValScope t, ConstantScope t) + +-- | Alias for constraints which are required for printing. +type PrintedValScope t = (SingI t, HasNoOp t) + +---------------------------------------------------------------------------- +-- Conveniences +---------------------------------------------------------------------------- + +-- | Should be present for common scopes. +class CheckScope (c :: Constraint) where + -- | Check that constraint hold for a given type. + checkScope :: Either BadTypeForScope (Dict c) + +instance SingI t => CheckScope (HasNoOp t) where + checkScope = maybeToRight BtIsOperation $ opAbsense sing +instance SingI t => CheckScope (HasNoBigMap t) where + checkScope = maybeToRight BtHasBigMap $ bigMapAbsense sing +instance SingI t => CheckScope (HasNoNestedBigMaps t) where + checkScope = maybeToRight BtHasNestedBigMap $ nestedBigMapsAbsense sing +instance SingI t => CheckScope (HasNoContract t) where + checkScope = maybeToRight BtHasContract $ contractTypeAbsense sing + +instance (Typeable t, SingI t) => CheckScope (ParameterScope t) where + checkScope = + (\Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoNestedBigMaps t) + +instance (Typeable t, SingI t) => CheckScope (StorageScope t) where + checkScope = + (\Dict Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoNestedBigMaps t) + <*> checkScope @(HasNoContract t) + +instance (Typeable t, SingI t) => CheckScope (ConstantScope t) where + checkScope = + (\Dict Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoBigMap t) + <*> checkScope @(HasNoContract t) + +instance (Typeable t, SingI t) => CheckScope (PackedValScope t) where + checkScope = + (\Dict Dict -> Dict) + <$> checkScope @(HasNoOp t) + <*> checkScope @(HasNoBigMap t) + +instance (Typeable t, SingI t) => CheckScope (UnpackedValScope t) where + checkScope = + (\Dict Dict -> Dict) + <$> checkScope @(PackedValScope t) + <*> checkScope @(ConstantScope t) + +-- Versions for eDSL +---------------------------------------------------------------------------- + +{- These constraints are supposed to be used only in eDSL code and eDSL should +define its own wrapers over it. +-} + +type ProperParameterBetterErrors t = + (Typeable t, SingI t, ForbidOp t, ForbidNestedBigMaps t) + +type ProperStorageBetterErrors t = + (Typeable t, SingI t, ForbidOp t, ForbidNestedBigMaps t, ForbidContract t) + +type ProperConstantBetterErrors t = + (SingI t, ForbidOp t, ForbidBigMap t, ForbidContract t) + +type ProperPackedValBetterErrors t = + (SingI t, ForbidOp t, ForbidBigMap t) + +type ProperUnpackedValBetterErrors t = + (ProperPackedValBetterErrors t, ProperConstantBetterErrors t) + +type ProperPrintedValBetterErrors t = + (SingI t, ForbidOp t) + +properParameterEvi :: forall t. ProperParameterBetterErrors t :- ParameterScope t +properParameterEvi = Sub $ + Dict \\ forbiddenOpEvi @t \\ forbiddenNestedBigMapsEvi @t + +properStorageEvi :: forall t. ProperStorageBetterErrors t :- StorageScope t +properStorageEvi = Sub $ + Dict \\ forbiddenOpEvi @t + \\ forbiddenContractTypeEvi @t + \\ forbiddenNestedBigMapsEvi @t + \\ forbiddenContractTypeEvi @t + +properConstantEvi :: forall t. ProperConstantBetterErrors t :- ConstantScope t +properConstantEvi = Sub $ + Dict \\ forbiddenOpEvi @t + \\ forbiddenBigMapEvi @t + \\ forbiddenContractTypeEvi @t + +properPackedValEvi :: forall t. ProperPackedValBetterErrors t :- PackedValScope t +properPackedValEvi = Sub $ + Dict \\ forbiddenOpEvi @t + \\ forbiddenBigMapEvi @t + +properUnpackedValEvi :: forall t. ProperUnpackedValBetterErrors t :- UnpackedValScope t +properUnpackedValEvi = properPackedValEvi @t *** properConstantEvi @t + +properPrintedValEvi :: forall t. ProperPrintedValBetterErrors t :- PrintedValScope t +properPrintedValEvi = Sub $ + Dict \\ forbiddenOpEvi @t ===================================== testsuite/tests/pmcheck/should_compile/all.T ===================================== @@ -120,6 +120,8 @@ test('T17977b', collect_compiler_stats('bytes allocated',10), compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T18049', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T18478', collect_compiler_stats('bytes allocated',10), compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) # Other tests test('pmc001', [], compile, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/02f40b0da2eadbf8a0e2930b95d4cef686acd92f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/02f40b0da2eadbf8a0e2930b95d4cef686acd92f You're receiving 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 Jul 23 00:23:06 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 22 Jul 2020 20:23:06 -0400 Subject: [Git][ghc/ghc][master] Minor refactoring of Unit display Message-ID: <5f18d86a83b67_80b104edf444628090@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - 7 changed files: - compiler/GHC/Runtime/Linker.hs - compiler/GHC/Unit/Info.hs - compiler/GHC/Unit/Ppr.hs - compiler/GHC/Unit/State.hs - compiler/GHC/Unit/State.hs-boot - compiler/GHC/Unit/Types.hs - testsuite/tests/backpack/cabal/bkpcabal06/bkpcabal06.stderr Changes: ===================================== compiler/GHC/Runtime/Linker.hs ===================================== @@ -1323,8 +1323,8 @@ linkPackage hsc_env pkg all_paths_env <- addEnvPaths "LD_LIBRARY_PATH" all_paths pathCache <- mapM (addLibrarySearchPath hsc_env) all_paths_env - maybePutStr dflags - ("Loading package " ++ unitPackageIdString pkg ++ " ... ") + maybePutSDoc dflags + (text "Loading unit " <> pprUnitInfoForUser pkg <> text " ... ") -- See comments with partOfGHCi #if defined(CAN_LOAD_DLL) @@ -1354,9 +1354,9 @@ linkPackage hsc_env pkg if succeeded ok then maybePutStrLn dflags "done." - else let errmsg = "unable to load package `" - ++ unitPackageIdString pkg ++ "'" - in throwGhcExceptionIO (InstallationError errmsg) + else let errmsg = text "unable to load unit `" + <> pprUnitInfoForUser pkg <> text "'" + in throwGhcExceptionIO (InstallationError (showSDoc dflags errmsg)) {- Note [Crash early load_dyn and locateLib] @@ -1731,14 +1731,17 @@ loadFramework hsc_env extraPaths rootname ********************************************************************* -} -maybePutStr :: DynFlags -> String -> IO () -maybePutStr dflags s +maybePutSDoc :: DynFlags -> SDoc -> IO () +maybePutSDoc dflags s = when (verbosity dflags > 1) $ putLogMsg dflags NoReason SevInteractive noSrcSpan - $ withPprStyle defaultUserStyle (text s) + $ withPprStyle defaultUserStyle s + +maybePutStr :: DynFlags -> String -> IO () +maybePutStr dflags s = maybePutSDoc dflags (text s) maybePutStrLn :: DynFlags -> String -> IO () maybePutStrLn dflags s = maybePutStr dflags (s ++ "\n") ===================================== compiler/GHC/Unit/Info.hs ===================================== @@ -168,8 +168,9 @@ mkUnit p | otherwise = RealUnit (Definite (unitId p)) -- | Create a UnitPprInfo from a UnitInfo -mkUnitPprInfo :: GenUnitInfo u -> UnitPprInfo -mkUnitPprInfo i = UnitPprInfo +mkUnitPprInfo :: (u -> FastString) -> GenUnitInfo u -> UnitPprInfo +mkUnitPprInfo ufs i = UnitPprInfo + (ufs (unitId i)) (unitPackageNameString i) (unitPackageVersion i) ((unpackFS . unPackageName) <$> unitComponentName i) ===================================== compiler/GHC/Unit/Ppr.hs ===================================== @@ -5,6 +5,7 @@ module GHC.Unit.Ppr where import GHC.Prelude +import GHC.Data.FastString import GHC.Utils.Outputable import Data.Version @@ -14,18 +15,22 @@ import Data.Version -- package-version:componentname -- data UnitPprInfo = UnitPprInfo - { unitPprPackageName :: String -- ^ Source package name + { unitPprId :: FastString -- ^ Identifier + , unitPprPackageName :: String -- ^ Source package name , unitPprPackageVersion :: Version -- ^ Source package version , unitPprComponentName :: Maybe String -- ^ Component name } instance Outputable UnitPprInfo where - ppr pprinfo = text $ mconcat - [ unitPprPackageName pprinfo - , case unitPprPackageVersion pprinfo of - Version [] [] -> "" - version -> "-" ++ showVersion version - , case unitPprComponentName pprinfo of - Nothing -> "" - Just cname -> ":" ++ cname - ] + ppr pprinfo = getPprDebug $ \debug -> + if debug + then ftext (unitPprId pprinfo) + else text $ mconcat + [ unitPprPackageName pprinfo + , case unitPprPackageVersion pprinfo of + Version [] [] -> "" + version -> "-" ++ showVersion version + , case unitPprComponentName pprinfo of + Nothing -> "" + Just cname -> ":" ++ cname + ] ===================================== compiler/GHC/Unit/State.hs ===================================== @@ -28,7 +28,6 @@ module GHC.Unit.State ( lookupPackageName, improveUnit, searchPackageId, - displayUnitId, listVisibleModuleNames, lookupModuleInAllUnits, lookupModuleWithSuggestions, @@ -61,14 +60,18 @@ module GHC.Unit.State ( instUnitToUnit, instModuleToModule, - -- * Utils - mkIndefUnitId, - updateIndefUnitId, - unwireUnit, + -- * Pretty-printing pprFlag, pprUnits, pprUnitsSimple, + pprUnitIdForUser, + pprUnitInfoForUser, pprModuleMap, + + -- * Utils + mkIndefUnitId, + updateIndefUnitId, + unwireUnit, homeUnitIsIndefinite, homeUnitIsDefinite, ) @@ -81,6 +84,7 @@ import GHC.Prelude import GHC.Platform import GHC.Unit.Database import GHC.Unit.Info +import GHC.Unit.Ppr import GHC.Unit.Types import GHC.Unit.Module import GHC.Driver.Session @@ -887,7 +891,7 @@ findPackages prec_map pkg_map closure arg pkgs unusable else Right (sortByPreference prec_map ps) where finder (PackageArg str) p - = if str == unitPackageIdString p || str == unitPackageNameString p + = if matchingStr str p then Just p else Nothing finder (UnitIdArg uid) p @@ -2100,6 +2104,8 @@ add_unit pkg_map ps (p, mb_parent) -- ----------------------------------------------------------------------------- +-- | Pretty-print a UnitId for the user. +-- -- Cabal packages may contain several components (programs, libraries, etc.). -- As far as GHC is concerned, installed package components ("units") are -- identified by an opaque IndefUnitId string provided by Cabal. As the string @@ -2111,26 +2117,30 @@ add_unit pkg_map ps (p, mb_parent) -- -- Component name is only displayed if it isn't the default library -- --- To do this we need to query the database (cached in DynFlags). We cache --- these details in the IndefUnitId itself because we don't want to query --- DynFlags each time we pretty-print the IndefUnitId --- +-- To do this we need to query a unit database. +pprUnitIdForUser :: UnitState -> UnitId -> SDoc +pprUnitIdForUser state uid@(UnitId fs) = + case lookupUnitPprInfo state uid of + Nothing -> ftext fs -- we didn't find the unit at all + Just i -> ppr i + +pprUnitInfoForUser :: UnitInfo -> SDoc +pprUnitInfoForUser info = ppr (mkUnitPprInfo unitIdFS info) + +lookupUnitPprInfo :: UnitState -> UnitId -> Maybe UnitPprInfo +lookupUnitPprInfo state uid = fmap (mkUnitPprInfo unitIdFS) (lookupUnitId state uid) + +-- | Create a IndefUnitId. mkIndefUnitId :: UnitState -> FastString -> IndefUnitId -mkIndefUnitId pkgstate raw = +mkIndefUnitId state raw = let uid = UnitId raw - in case lookupUnitId pkgstate uid of - Nothing -> Indefinite uid Nothing -- we didn't find the unit at all - Just c -> Indefinite uid $ Just $ mkUnitPprInfo c + in Indefinite uid $! lookupUnitPprInfo state uid -- | Update component ID details from the database updateIndefUnitId :: UnitState -> IndefUnitId -> IndefUnitId updateIndefUnitId pkgstate uid = mkIndefUnitId pkgstate (unitIdFS (indefUnit uid)) -displayUnitId :: UnitState -> UnitId -> Maybe String -displayUnitId pkgstate uid = - fmap unitPackageIdString (lookupUnitId pkgstate uid) - -- ----------------------------------------------------------------------------- -- Displaying packages ===================================== compiler/GHC/Unit/State.hs-boot ===================================== @@ -1,7 +1,7 @@ module GHC.Unit.State where -import GHC.Prelude import GHC.Data.FastString +import {-# SOURCE #-} GHC.Utils.Outputable import {-# SOURCE #-} GHC.Unit.Types (IndefUnitId, UnitId) data UnitState @@ -9,5 +9,5 @@ data UnitDatabase unit emptyUnitState :: UnitState mkIndefUnitId :: UnitState -> FastString -> IndefUnitId -displayUnitId :: UnitState -> UnitId -> Maybe String +pprUnitIdForUser :: UnitState -> UnitId -> SDoc updateIndefUnitId :: UnitState -> IndefUnitId -> IndefUnitId ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -103,7 +103,7 @@ import Data.Bifunctor import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BS.Char8 -import {-# SOURCE #-} GHC.Unit.State (UnitState,displayUnitId) +import {-# SOURCE #-} GHC.Unit.State (pprUnitIdForUser) import {-# SOURCE #-} GHC.Driver.Session (unitState) --------------------------------------------------------------------- @@ -508,19 +508,7 @@ instance Uniquable UnitId where getUnique = getUnique . unitIdFS instance Outputable UnitId where - ppr uid = sdocWithDynFlags $ \dflags -> pprUnitId (unitState dflags) uid - --- | Pretty-print a UnitId --- --- In non-debug mode, query the given database to try to print --- "package-version:component" instead of the raw UnitId -pprUnitId :: UnitState -> UnitId -> SDoc -pprUnitId state uid@(UnitId fs) = getPprDebug $ \debug -> - if debug - then ftext fs - else case displayUnitId state uid of - Just str -> text str - _ -> ftext fs + ppr uid = sdocWithDynFlags $ \dflags -> pprUnitIdForUser (unitState dflags) uid -- | A 'DefUnitId' is an 'UnitId' with the invariant that -- it only refers to a definite library; i.e., one we have generated ===================================== testsuite/tests/backpack/cabal/bkpcabal06/bkpcabal06.stderr ===================================== @@ -1,4 +1,4 @@ sig/P.hsig:1:1: error: - • ‘p’ is exported by the hsig file, but not exported by the implementing module ‘bkpcabal06-0.1.0.0:P’ - • while checking that bkpcabal06-0.1.0.0:P implements signature P in bkpcabal06-0.1.0.0:sig[P=bkpcabal06-0.1.0.0:P] + • ‘p’ is exported by the hsig file, but not exported by the implementing module ‘bkpcabal06-0.1.0.0:impl:P’ + • while checking that bkpcabal06-0.1.0.0:impl:P implements signature P in bkpcabal06-0.1.0.0:sig[P=bkpcabal06-0.1.0.0:impl:P] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f44df1ec6df2b02be83e41cec4dc3b5f7f540f0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f44df1ec6df2b02be83e41cec4dc3b5f7f540f0 You're receiving 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 Jul 23 01:29:25 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 22 Jul 2020 21:29:25 -0400 Subject: [Git][ghc/ghc][wip/backports] 15 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f18e7f5c5bff_80b3f84925412344634881@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: 96a16275 by Ben Gamari at 2020-07-22T19:56:38-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. (cherry picked from commit 750a1595ef31cdc335f3bab045b2f19a9c43ff93) - - - - - 29d24d10 by Moritz Angermann at 2020-07-22T19:59:40-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. (cherry picked from commit aef523ea1254e8bb9e4143ad8f5994ca89ea9d2d) - - - - - 9ab76ca5 by Sylvain Henry at 2020-07-22T20:47:38-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. (cherry picked from commit 54b595c1b91ad9e686b5baf7640177becb372336) - - - - - 4e088f69 by Sylvain Henry at 2020-07-22T20:47:38-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). (cherry picked from commit 499f3a2829d7c5a047c2ee87377d71ab2ea8c6d9) - - - - - a81e831b by Sylvain Henry at 2020-07-22T20:47:38-04:00 LLVM: refactor and comment register padding code (#17920) (cherry picked from commit 9bdc2a056f459b0e05ddbc49d978dfed547ecc13) - - - - - 94035da1 by Sylvain Henry at 2020-07-22T20:47:38-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 (cherry picked from commit aa54d1a2b2d2c89107cfa77d8c14a50d6ee9c140) - - - - - 1a0ae8d1 by Ben Gamari at 2020-07-22T20:48:40-04:00 Fix GhcThreaded setting This adopts a patch from NetBSD's packaging fixing the `GhcThreaded` option of the make build system. In addition we introduce a `ghcThreaded` option in hadrian's `Flavour` type. Also fix Hadrian's treatment of the `Use Threaded` entry in `settings`. Previously it would incorrectly claim `Use Threaded = True` if we were building the `threaded` runtime way. However, this is inconsistent with the `make` build system, which defines it to be whether the `ghc` executable is linked against the threaded runtime. Fixes #17692. - - - - - 8b48e999 by Travis Whitaker at 2020-07-22T20:49:10-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. (cherry picked from commit 67738db10010fd28a8e997b5c8f83ea591b88a0e) (cherry picked from commit a228d0a83db06fbe81b1c74fe3b1aea3133cee50) - - - - - e0043d69 by Ben Gamari at 2020-07-22T21:18:28-04:00 CLabel - - - - - 692cf1b0 by Ben Gamari at 2020-07-22T21:18:34-04:00 Llvm - - - - - e4ab0824 by Joshua Price at 2020-07-22T21:19:35-04:00 Make `identifier` parse unparenthesized `->` (#18060) (cherry picked from commit d6203f24cf421749616a247c047a9b44192f963a) - - - - - 10743e2a by Simon Peyton Jones at 2020-07-22T21:24:39-04:00 Wrap an implication around class-sig kind errors Ticket #17841 showed that we can get a kind error in a class signature, but lack an enclosing implication that binds its skolems. This patch * Adds the wrapping implication: the new call to checkTvConstraints in tcClassDecl1 * Simplifies the API to checkTvConstraints, which was not otherwise called at all. * Simplifies TcErrors.report_unsolved by *not* initialising the TidyEnv from the typechecker lexical envt. It's enough to do so from the free vars of the unsolved constraints; and we get silly renamings if we add variables twice: once from the lexical scope and once from the implication constraint. (cherry picked from commit 3f431587c2db712136a3b5a353758ca63e1a5fd8) - - - - - 78488dd5 by Simon Peyton Jones at 2020-07-22T21:24:45-04:00 Refactoring in TcSMonad This patch is just refactoring: no change in behaviour. I removed the rather complicated checkConstraintsTcS checkTvConstraintsTcS in favour of simpler functions emitImplicationTcS emitTvImplicationTcS pushLevelNoWorkList The last of these is a little strange, but overall it's much better I think. (cherry picked from commit 9d87ced6832e75fce1e01b67bc6b7d9d1cf31efb) - - - - - 72b078e5 by Simon Peyton Jones at 2020-07-22T21:29:12-04:00 Major improvements to the specialiser This patch is joint work of Alexis King and Simon PJ. It does some significant refactoring of the type-class specialiser. Main highlights: * We can specialise functions with types like f :: Eq a => a -> Ord b => b => blah where the classes aren't all at the front (#16473). Here we can correctly specialise 'f' based on a call like f @Int @Bool dEqInt x dOrdBool This change really happened in an earlier patch commit 2d0cf6252957b8980d89481ecd0b79891da4b14b Author: Sandy Maguire <sandy at sandymaguire.me> Date: Thu May 16 12:12:10 2019 -0400 work that this new patch builds directly on that work, and refactors it a bit. * We can specialise functions with implicit parameters (#17930) g :: (?foo :: Bool, Show a) => a -> String Previously we could not, but now they behave just like a non-class argument as in 'f' above. * We can specialise under-saturated calls, where some (but not all of the dictionary arguments are provided (#17966). For example, we can specialise the above 'f' based on a call map (f @Int dEqInt) xs even though we don't (and can't) give Ord dictionary. This may sound exotic, but #17966 is a program from the wild, and showed significant perf loss for functions like f, if you need saturation of all dictionaries. * We fix a buglet in which a floated dictionary had a bogus demand (#17810), by using zapIdDemandInfo in the NonRec case of specBind. * A tiny side benefit: we can drop dead arguments to specialised functions; see Note [Drop dead args from specialisations] * Fixed a bug in deciding what dictionaries are "interesting"; see Note [Keep the old dictionaries interesting] This is all achieved by by building on Sandy Macguire's work in defining SpecArg, which mkCallUDs uses to describe the arguments of the call. Main changes: * Main work is in specHeader, which marched down the [InBndr] from the function definition and the [SpecArg] from the call site, together. * specCalls no longer has an arity check; the entire mechanism now handles unders-saturated calls fine. * mkCallUDs decides on an argument-by-argument basis whether to specialise a particular dictionary argument; this is new. See mk_spec_arg in mkCallUDs. It looks as if there are many more lines of code, but I think that all the extra lines are comments! (cherry picked from commit 7052d7c7ce3418db9e66ad6ff31e80b2a2c724bb) - - - - - fc6c41d2 by Moritz Angermann at 2020-07-22T21:29:12-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. (cherry picked from commit aedfeb0b2b22172a0dfca0fe0c020ac80539d6ae) - - - - - 30 changed files: - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/StgToCmm/Prof.hs - compiler/GHC/StgToCmm/Ticky.hs - compiler/GHC/StgToCmm/Utils.hs - compiler/cmm/CLabel.hs - compiler/cmm/CmmCallConv.hs - compiler/cmm/CmmParse.y - compiler/coreSyn/CoreSubst.hs - compiler/coreSyn/CoreUnfold.hs - compiler/deSugar/DsBinds.hs - compiler/ghc.cabal.in - compiler/ghc.mk - compiler/ghci/Linker.hs - compiler/llvmGen/LlvmCodeGen/Base.hs - compiler/llvmGen/LlvmCodeGen/CodeGen.hs - compiler/parser/Parser.y - compiler/specialise/Specialise.hs - compiler/typecheck/TcCanonical.hs - compiler/typecheck/TcClassDcl.hs - compiler/typecheck/TcErrors.hs - compiler/typecheck/TcEvidence.hs - compiler/typecheck/TcSMonad.hs - compiler/typecheck/TcTyClsDecls.hs - compiler/typecheck/TcUnify.hs - configure.ac - docs/users_guide/runtime_control.rst - ghc/ghc.mk - hadrian/cfg/system.config.in - hadrian/doc/user-settings.md - 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/cc8800f9f482460ceb2d450137766e0350551740...fc6c41d2801d9ba5b7b64e13d0ed7bd6e74e0a15 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc8800f9f482460ceb2d450137766e0350551740...fc6c41d2801d9ba5b7b64e13d0ed7bd6e74e0a15 You're receiving 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 Jul 23 02:09:07 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 22 Jul 2020 22:09:07 -0400 Subject: [Git][ghc/ghc][wip/angerman/cross-test-suite] 30 commits: DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) Message-ID: <5f18f143189df_80bd68a9b8463922f@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/cross-test-suite at Glasgow Haskell Compiler / GHC Commits: 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - ff0f3737 by Moritz Angermann at 2020-07-23T10:08:30+08:00 Cross Test Suite This introduces the ability to test cross compilers agains the testsuite as well. This is achieved by disabling some tests that make no sense in a cross compilation setting, or simply can not be made to cross compile proplery. The fundamental idea is that we can run produced binaries through a TEST_WRAPPER, if provided. This could be qemu in user mode, or wine, or nodejs, or anything that could transparrently run the executable build product on the build machine. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/StringBuffer.hs - + compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3e3870455683fe98f4155404f4fb95e04b9f9620...ff0f3737d334f845e64c1cd89b2cbcdbf6935fb9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3e3870455683fe98f4155404f4fb95e04b9f9620...ff0f3737d334f845e64c1cd89b2cbcdbf6935fb9 You're receiving 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 Jul 23 02:57:18 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 22 Jul 2020 22:57:18 -0400 Subject: [Git][ghc/ghc][wip/backports] 10 commits: CmmToC: don't add extern decl to parsed Cmm data Message-ID: <5f18fc8e39d60_80b3f849248fe084641352@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: e447bd2c by Sylvain Henry at 2020-07-22T22:57:09-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). (cherry picked from commit 499f3a2829d7c5a047c2ee87377d71ab2ea8c6d9) - - - - - f96a4b2c by Sylvain Henry at 2020-07-22T22:57:09-04:00 LLVM: refactor and comment register padding code (#17920) (cherry picked from commit 9bdc2a056f459b0e05ddbc49d978dfed547ecc13) - - - - - 36656d70 by Sylvain Henry at 2020-07-22T22:57:10-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 (cherry picked from commit aa54d1a2b2d2c89107cfa77d8c14a50d6ee9c140) - - - - - b7c216cb by Ben Gamari at 2020-07-22T22:57:10-04:00 Fix GhcThreaded setting This adopts a patch from NetBSD's packaging fixing the `GhcThreaded` option of the make build system. In addition we introduce a `ghcThreaded` option in hadrian's `Flavour` type. Also fix Hadrian's treatment of the `Use Threaded` entry in `settings`. Previously it would incorrectly claim `Use Threaded = True` if we were building the `threaded` runtime way. However, this is inconsistent with the `make` build system, which defines it to be whether the `ghc` executable is linked against the threaded runtime. Fixes #17692. - - - - - 55fac768 by Travis Whitaker at 2020-07-22T22:57:10-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. (cherry picked from commit 67738db10010fd28a8e997b5c8f83ea591b88a0e) (cherry picked from commit a228d0a83db06fbe81b1c74fe3b1aea3133cee50) - - - - - bcf316aa by Joshua Price at 2020-07-22T22:57:10-04:00 Make `identifier` parse unparenthesized `->` (#18060) (cherry picked from commit d6203f24cf421749616a247c047a9b44192f963a) - - - - - 77dae8ae by Simon Peyton Jones at 2020-07-22T22:57:10-04:00 Wrap an implication around class-sig kind errors Ticket #17841 showed that we can get a kind error in a class signature, but lack an enclosing implication that binds its skolems. This patch * Adds the wrapping implication: the new call to checkTvConstraints in tcClassDecl1 * Simplifies the API to checkTvConstraints, which was not otherwise called at all. * Simplifies TcErrors.report_unsolved by *not* initialising the TidyEnv from the typechecker lexical envt. It's enough to do so from the free vars of the unsolved constraints; and we get silly renamings if we add variables twice: once from the lexical scope and once from the implication constraint. (cherry picked from commit 3f431587c2db712136a3b5a353758ca63e1a5fd8) - - - - - b7c154c5 by Simon Peyton Jones at 2020-07-22T22:57:10-04:00 Refactoring in TcSMonad This patch is just refactoring: no change in behaviour. I removed the rather complicated checkConstraintsTcS checkTvConstraintsTcS in favour of simpler functions emitImplicationTcS emitTvImplicationTcS pushLevelNoWorkList The last of these is a little strange, but overall it's much better I think. (cherry picked from commit 9d87ced6832e75fce1e01b67bc6b7d9d1cf31efb) - - - - - 2e90dd15 by Simon Peyton Jones at 2020-07-22T22:57:10-04:00 Major improvements to the specialiser This patch is joint work of Alexis King and Simon PJ. It does some significant refactoring of the type-class specialiser. Main highlights: * We can specialise functions with types like f :: Eq a => a -> Ord b => b => blah where the classes aren't all at the front (#16473). Here we can correctly specialise 'f' based on a call like f @Int @Bool dEqInt x dOrdBool This change really happened in an earlier patch commit 2d0cf6252957b8980d89481ecd0b79891da4b14b Author: Sandy Maguire <sandy at sandymaguire.me> Date: Thu May 16 12:12:10 2019 -0400 work that this new patch builds directly on that work, and refactors it a bit. * We can specialise functions with implicit parameters (#17930) g :: (?foo :: Bool, Show a) => a -> String Previously we could not, but now they behave just like a non-class argument as in 'f' above. * We can specialise under-saturated calls, where some (but not all of the dictionary arguments are provided (#17966). For example, we can specialise the above 'f' based on a call map (f @Int dEqInt) xs even though we don't (and can't) give Ord dictionary. This may sound exotic, but #17966 is a program from the wild, and showed significant perf loss for functions like f, if you need saturation of all dictionaries. * We fix a buglet in which a floated dictionary had a bogus demand (#17810), by using zapIdDemandInfo in the NonRec case of specBind. * A tiny side benefit: we can drop dead arguments to specialised functions; see Note [Drop dead args from specialisations] * Fixed a bug in deciding what dictionaries are "interesting"; see Note [Keep the old dictionaries interesting] This is all achieved by by building on Sandy Macguire's work in defining SpecArg, which mkCallUDs uses to describe the arguments of the call. Main changes: * Main work is in specHeader, which marched down the [InBndr] from the function definition and the [SpecArg] from the call site, together. * specCalls no longer has an arity check; the entire mechanism now handles unders-saturated calls fine. * mkCallUDs decides on an argument-by-argument basis whether to specialise a particular dictionary argument; this is new. See mk_spec_arg in mkCallUDs. It looks as if there are many more lines of code, but I think that all the extra lines are comments! (cherry picked from commit 7052d7c7ce3418db9e66ad6ff31e80b2a2c724bb) - - - - - 3e452a33 by Moritz Angermann at 2020-07-22T22:57:10-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. (cherry picked from commit aedfeb0b2b22172a0dfca0fe0c020ac80539d6ae) - - - - - 30 changed files: - compiler/GHC/StgToCmm/Prof.hs - compiler/GHC/StgToCmm/Ticky.hs - compiler/cmm/CLabel.hs - compiler/cmm/CmmParse.y - compiler/coreSyn/CoreSubst.hs - compiler/coreSyn/CoreUnfold.hs - compiler/deSugar/DsBinds.hs - compiler/ghc.mk - compiler/llvmGen/LlvmCodeGen/Base.hs - compiler/llvmGen/LlvmCodeGen/CodeGen.hs - compiler/parser/Parser.y - compiler/specialise/Specialise.hs - compiler/typecheck/TcCanonical.hs - compiler/typecheck/TcClassDcl.hs - compiler/typecheck/TcErrors.hs - compiler/typecheck/TcEvidence.hs - compiler/typecheck/TcSMonad.hs - compiler/typecheck/TcTyClsDecls.hs - compiler/typecheck/TcUnify.hs - configure.ac - ghc/ghc.mk - hadrian/cfg/system.config.in - hadrian/doc/user-settings.md - hadrian/src/Expression.hs - hadrian/src/Flavour.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Packages.hs - mk/config.mk.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc6c41d2801d9ba5b7b64e13d0ed7bd6e74e0a15...3e452a33ac81dd39e4fdf64a8a5a4f33e8c025f1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc6c41d2801d9ba5b7b64e13d0ed7bd6e74e0a15...3e452a33ac81dd39e4fdf64a8a5a4f33e8c025f1 You're receiving 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 Jul 23 05:55:28 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 23 Jul 2020 01:55:28 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 25 commits: Fix dead link to haskell prime discussion Message-ID: <5f1926501b2e_80b3f84868c3828464611@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - 583e4621 by Moritz Angermann at 2020-07-23T01:55:22-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - 86291737 by Sergei Trofimovich at 2020-07-23T01:55:25-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent haskell libraries unconditionally. The change avoid building such libraries. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/StringBuffer.hs - + compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Load.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/607d0d90da96d0762461d04125d2e94c63a249f5...862917378d92e19ba36af986d6f30d0af1dcd572 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/607d0d90da96d0762461d04125d2e94c63a249f5...862917378d92e19ba36af986d6f30d0af1dcd572 You're receiving 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 Jul 23 11:55:35 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 23 Jul 2020 07:55:35 -0400 Subject: [Git][ghc/ghc][master] [linker] Fix out of range relocations. Message-ID: <5f197ab7c0f10_80b3f849254123446746ee@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - 8 changed files: - rts/Linker.c - rts/LinkerInternals.h - rts/linker/Elf.c - rts/linker/LoadArchive.c - rts/linker/M32Alloc.c - rts/linker/MachO.c - rts/linker/SymbolExtras.c - rts/linker/elf_got.c Changes: ===================================== rts/Linker.c ===================================== @@ -188,7 +188,7 @@ int ocTryLoad( ObjectCode* oc ); * * MAP_32BIT not available on OpenBSD/amd64 */ -#if defined(MAP_32BIT) && defined(x86_64_HOST_ARCH) +#if defined(MAP_32BIT) && (defined(x86_64_HOST_ARCH) || (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH))) #define MAP_LOW_MEM #define TRY_MAP_32BIT MAP_32BIT #else @@ -214,10 +214,22 @@ int ocTryLoad( ObjectCode* oc ); * systems, we have to pick a base address in the low 2Gb of the address space * and try to allocate memory from there. * + * The same holds for aarch64, where the default, even with PIC, model + * is 4GB. The linker is free to emit AARCH64_ADR_PREL_PG_HI21 + * relocations. + * * We pick a default address based on the OS, but also make this * configurable via an RTS flag (+RTS -xm) */ -#if defined(MAP_32BIT) || DEFAULT_LINKER_ALWAYS_PIC + +#if (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH)) +// Try to use stg_upd_frame_info as the base. We need to be within +-4GB of that +// address, otherwise we violate the aarch64 memory model. Any object we load +// can potentially reference any of the ones we bake into the binary (and list) +// in RtsSymbols. Thus we'll need to be within +-4GB of those, +// stg_upd_frame_info is a good candidate as it's referenced often. +#define MMAP_32BIT_BASE_DEFAULT (void*)&stg_upd_frame_info; +#elif defined(MAP_32BIT) || DEFAULT_LINKER_ALWAYS_PIC // Try to use MAP_32BIT #define MMAP_32BIT_BASE_DEFAULT 0 #else @@ -1040,11 +1052,47 @@ resolveSymbolAddr (pathchar* buffer, int size, } #if RTS_LINKER_USE_MMAP + +/* ----------------------------------------------------------------------------- + Occationally we depend on mmap'd region being close to already mmap'd regions. + + Our static in-memory linker may be restricted by the architectures relocation + range. E.g. aarch64 has a +-4GB range for PIC code, thus we'd preferrably + get memory for the linker close to existing mappings. mmap on it's own is + free to return any memory location, independent of what the preferred + location argument indicates. + + For example mmap (via qemu) might give you addresses all over the available + memory range if the requested location is already occupied. + + mmap_next will do a linear search from the start page upwards to find a + suitable location that is as close as possible to the locations (proivded + via the first argument). + -------------------------------------------------------------------------- */ + +void* +mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { + if(addr == NULL) return mmap(addr, length, prot, flags, fd, offset); + // we are going to look for up to pageSize * 1024 * 1024 (4GB) from the + // address. + size_t pageSize = getPageSize(); + for(int i = (uintptr_t)addr & (pageSize-1) ? 1 : 0; i < 1024*1024; i++) { + void *target = (void*)(((uintptr_t)addr & ~(pageSize-1))+(i*pageSize)); + void *mem = mmap(target, length, prot, flags, fd, offset); + if(mem == NULL) return mem; + if(mem == target) return mem; + munmap(mem, length); + IF_DEBUG(linker && (i % 1024 == 0), + debugBelch("mmap_next failed to find suitable space in %p - %p\n", addr, target)); + } + return NULL; +} + // // Returns NULL on failure. // void * -mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset) +mmapForLinker (size_t bytes, uint32_t prot, uint32_t flags, int fd, int offset) { void *map_addr = NULL; void *result; @@ -1065,15 +1113,14 @@ mmap_again: map_addr = mmap_32bit_base; } - const int prot = PROT_READ | PROT_WRITE; IF_DEBUG(linker, debugBelch("mmapForLinker: \tprotection %#0x\n", prot)); IF_DEBUG(linker, debugBelch("mmapForLinker: \tflags %#0x\n", MAP_PRIVATE | tryMap32Bit | fixed | flags)); - result = mmap(map_addr, size, prot, - MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); + result = mmap_next(map_addr, size, prot, + MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); if (result == MAP_FAILED) { sysErrorBelch("mmap %" FMT_Word " bytes at %p",(W_)size,map_addr); @@ -1126,6 +1173,28 @@ mmap_again: goto mmap_again; } } +#elif (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH)) + // for aarch64 we need to make sure we stay within 4GB of the + // mmap_32bit_base, and we also do not want to update it. +// if (mmap_32bit_base != (void*)&stg_upd_frame_info) { + if (result == map_addr) { + mmap_32bit_base = (void*)((uintptr_t)map_addr + size); + } else { + // upper limit 4GB - size of the object file - 1mb wiggle room. + if(llabs((uintptr_t)result - (uintptr_t)&stg_upd_frame_info) > (2<<32) - size - (2<<20)) { + // not within range :( + debugTrace(DEBUG_linker, + "MAP_32BIT didn't work; gave us %lu bytes at 0x%p", + bytes, result); + munmap(result, size); + // TODO: some abort/mmap_32bit_base recomputation based on + // if mmap_32bit_base is changed, or still at stg_upd_frame_info + goto mmap_again; + } else { + mmap_32bit_base = (void*)((uintptr_t)result + size); + } + } +// } #endif IF_DEBUG(linker, @@ -1454,9 +1523,9 @@ preloadObjectFile (pathchar *path) * See also the misalignment logic for darwin below. */ #if defined(ios_HOST_OS) - image = mmap(NULL, fileSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); + image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); #else - image = mmap(NULL, fileSize, PROT_READ|PROT_WRITE|PROT_EXEC, + image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, fd, 0); #endif ===================================== rts/LinkerInternals.h ===================================== @@ -14,6 +14,7 @@ #if RTS_LINKER_USE_MMAP #include +void* mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset); #endif void printLoadedObjects(void); @@ -293,7 +294,7 @@ void exitLinker( void ); void freeObjectCode (ObjectCode *oc); SymbolAddr* loadSymbol(SymbolName *lbl, RtsSymbolInfo *pinfo); -void *mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset); +void *mmapForLinker (size_t bytes, uint32_t prot, uint32_t flags, int fd, int offset); void mmapForLinkerMarkExecutable (void *start, size_t len); void addProddableBlock ( ObjectCode* oc, void* start, int size ); ===================================== rts/linker/Elf.c ===================================== @@ -637,7 +637,7 @@ mapObjectFileSection (int fd, Elf_Word offset, Elf_Word size, pageOffset = roundDownToPage(offset); pageSize = roundUpToPage(offset-pageOffset+size); - p = mmapForLinker(pageSize, 0, fd, pageOffset); + p = mmapForLinker(pageSize, PROT_READ | PROT_WRITE, 0, fd, pageOffset); if (p == NULL) return NULL; *mapped_size = pageSize; *mapped_offset = pageOffset; @@ -709,7 +709,7 @@ ocGetNames_ELF ( ObjectCode* oc ) * address might be out of range for sections that are mmaped. */ alloc = SECTION_MMAP; - start = mmapForLinker(size, MAP_ANONYMOUS, -1, 0); + start = mmapForLinker(size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); mapped_start = start; mapped_offset = 0; mapped_size = roundUpToPage(size); @@ -751,8 +751,9 @@ ocGetNames_ELF ( ObjectCode* oc ) unsigned nstubs = numberOfStubsForSection(oc, i); unsigned stub_space = STUB_SIZE * nstubs; - void * mem = mmapForLinker(size+stub_space, MAP_ANON, -1, 0); - if( mem == NULL ) { + void * mem = mmapForLinker(size+stub_space, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + + if( mem == MAP_FAILED ) { barf("failed to mmap allocated memory to load section %d. " "errno = %d", i, errno); } @@ -841,6 +842,26 @@ ocGetNames_ELF ( ObjectCode* oc ) unsigned curSymbol = 0; + unsigned long common_size = 0; + unsigned long common_used = 0; + for(ElfSymbolTable *symTab = oc->info->symbolTables; + symTab != NULL; symTab = symTab->next) { + for (size_t j = 0; j < symTab->n_symbols; j++) { + ElfSymbol *symbol = &symTab->symbols[j]; + if (SHN_COMMON == symTab->symbols[j].elf_sym->st_shndx) { + common_size += symbol->elf_sym->st_size; + } + } + } + void * common_mem = NULL; + if(common_size > 0) { + common_mem = mmapForLinker(common_size, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, + -1, 0); + ASSERT(common_mem != NULL); + } + //TODO: we ignore local symbols anyway right? So we can use the // shdr[i].sh_info to get the index of the first non-local symbol // ie we should use j = shdr[i].sh_info @@ -876,12 +897,15 @@ ocGetNames_ELF ( ObjectCode* oc ) if (shndx == SHN_COMMON) { isLocal = false; - symbol->addr = stgCallocBytes(1, symbol->elf_sym->st_size, - "ocGetNames_ELF(COMMON)"); - /* - debugBelch("COMMON symbol, size %d name %s\n", - stab[j].st_size, nm); - */ + ASSERT(common_used < common_size); + ASSERT(common_mem); + symbol->addr = (void*)((uintptr_t)common_mem + common_used); + common_used += symbol->elf_sym->st_size; + ASSERT(common_used <= common_size); + + debugBelch("COMMON symbol, size %ld name %s allocated at %p\n", + symbol->elf_sym->st_size, nm, symbol->addr); + /* Pointless to do addProddableBlock() for this area, since the linker should never poke around in it. */ } else if ((ELF_ST_BIND(symbol->elf_sym->st_info) == STB_GLOBAL ===================================== rts/linker/LoadArchive.c ===================================== @@ -489,7 +489,7 @@ static HsInt loadArchive_ (pathchar *path) #if defined(darwin_HOST_OS) || defined(ios_HOST_OS) if (RTS_LINKER_USE_MMAP) - image = mmapForLinker(memberSize, MAP_ANONYMOUS, -1, 0); + image = mmapForLinker(memberSize, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); else { /* See loadObj() */ misalignment = machoGetMisalignment(f); @@ -548,7 +548,7 @@ while reading filename from `%" PATH_FMT "'", path); } DEBUG_LOG("Found GNU-variant file index\n"); #if RTS_LINKER_USE_MMAP - gnuFileIndex = mmapForLinker(memberSize + 1, MAP_ANONYMOUS, -1, 0); + gnuFileIndex = mmapForLinker(memberSize + 1, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); #else gnuFileIndex = stgMallocBytes(memberSize + 1, "loadArchive(image)"); #endif ===================================== rts/linker/M32Alloc.c ===================================== @@ -256,7 +256,7 @@ m32_alloc_page(void) m32_free_page_pool_size --; return page; } else { - struct m32_page_t *page = mmapForLinker(getPageSize(),MAP_ANONYMOUS,-1,0); + struct m32_page_t *page = mmapForLinker(getPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); if (page > (struct m32_page_t *) 0xffffffff) { barf("m32_alloc_page: failed to get allocation in lower 32-bits"); } @@ -280,7 +280,7 @@ m32_allocator_new(bool executable) // Preallocate the initial M32_MAX_PAGES to ensure that they don't // fragment the memory. size_t pgsz = getPageSize(); - char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES,MAP_ANONYMOUS,-1,0); + char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,-1,0); if (bigchunk == NULL) barf("m32_allocator_init: Failed to map"); @@ -396,7 +396,7 @@ m32_alloc(struct m32_allocator_t *alloc, size_t size, size_t alignment) if (m32_is_large_object(size,alignment)) { // large object size_t alsize = ROUND_UP(sizeof(struct m32_page_t), alignment); - struct m32_page_t *page = mmapForLinker(alsize+size,MAP_ANONYMOUS,-1,0); + struct m32_page_t *page = mmapForLinker(alsize+size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,-1,0); page->filled_page.size = alsize + size; m32_allocator_push_filled_list(&alloc->unprotected_list, (struct m32_page_t *) page); return (char*) page + alsize; ===================================== rts/linker/MachO.c ===================================== @@ -508,7 +508,7 @@ makeGot(ObjectCode * oc) { if(got_slots > 0) { oc->info->got_size = got_slots * sizeof(void*); - oc->info->got_start = mmap(NULL, oc->info->got_size, + oc->info->got_start = mmapForLinker(oc->info->got_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); @@ -1114,7 +1114,7 @@ ocBuildSegments_MachO(ObjectCode *oc) return 1; } - mem = mmapForLinker(size_compound, MAP_ANON, -1, 0); + mem = mmapForLinker(size_compound, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); if (NULL == mem) return 0; IF_DEBUG(linker, debugBelch("ocBuildSegments: allocating %d segments\n", n_activeSegments)); ===================================== rts/linker/SymbolExtras.c ===================================== @@ -79,7 +79,7 @@ int ocAllocateExtras(ObjectCode* oc, int count, int first, int bssSize) size_t n = roundUpToPage(oc->fileSize); bssSize = roundUpToAlign(bssSize, 8); size_t allocated_size = n + bssSize + extras_size; - void *new = mmapForLinker(allocated_size, MAP_ANONYMOUS, -1, 0); + void *new = mmapForLinker(allocated_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); if (new) { memcpy(new, oc->image, oc->fileSize); if (oc->imageMapped) { ===================================== rts/linker/elf_got.c ===================================== @@ -48,7 +48,7 @@ makeGot(ObjectCode * oc) { } if(got_slots > 0) { oc->info->got_size = got_slots * sizeof(void *); - void * mem = mmap(NULL, oc->info->got_size, + void * mem = mmapForLinker(oc->info->got_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dff1cb3d9c111808fec60190747272b973547c52 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dff1cb3d9c111808fec60190747272b973547c52 You're receiving 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 Jul 23 11:59:51 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Thu, 23 Jul 2020 07:59:51 -0400 Subject: [Git][ghc/ghc][wip/spj-wibbles] 827 commits: Be explicit about how stack usage of mvar primops are covered. Message-ID: <5f197bb7cfcca_80b3f84868c382846773bf@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/spj-wibbles at Glasgow Haskell Compiler / GHC Commits: 8c663c2c by Andreas Klebinger at 2020-03-04T16:12:14+01:00 Be explicit about how stack usage of mvar primops are covered. This fixes #17893 [skip-ci] - - - - - cedd6f30 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Add getCurrentThreadCPUTime helper - - - - - ace618cd by Ben Gamari at 2020-03-05T14:53:12-05:00 nonmoving-gc: Track time usage of nonmoving marking - - - - - 022b5ad5 by Ben Gamari at 2020-03-05T14:53:12-05:00 Stats: Add sync pauses to +RTS -S output - - - - - 06763234 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Report nonmoving collector statistics in machine-readable output - - - - - 70d2b995 by Ben Gamari at 2020-03-09T06:10:52-04:00 nonmoving: Fix collection of sparks Previously sparks living in the non-moving heap would be promptly GC'd by the minor collector since pruneSparkQueue uses the BF_EVACUATED flag, which non-moving heap blocks do not have set. Fix this by implementing proper support in pruneSparkQueue for determining reachability in the non-moving heap. The story is told in Note [Spark management in the nonmoving heap]. - - - - - 9668781a by Ben Gamari at 2020-03-09T06:11:30-04:00 gitlab-ci: Disable Sphinx documentation in Alpine build - - - - - 8eb2c263 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 Fix Windows breakage by not touching locales on Windows - - - - - b8dab057 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: ensure C numerics in heap profiles using Windows locales if needed - - - - - 7d95260f by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: refactor and comment profile locales - - - - - 5b627813 by Ryan Scott at 2020-03-09T16:34:14-04:00 Use InstanceSigs in GND/DerivingVia-generated code (#17899) Aside from making the generated code easier to read when `-ddump-deriv` is enabled, this makes the error message in `T15073` substantially simpler (see the updated `T15073` expected stderr). Fixes #17899. - - - - - 70b50778 by Ben Gamari at 2020-03-10T02:05:42-04:00 SysTools: Ensure that error parser can handle absolute paths on Windows This fixes #17786, where the error parser fails to correctly handle the drive name in absolute Windows paths. Unfortunately I couldn't find a satisfactory way to test this. - - - - - 85b861d8 by Ben Gamari at 2020-03-10T02:05:42-04:00 testsuite: Add test for #17786 This isn't pretty but it's perhaps better than nothing. - - - - - ee2c50cb by Sylvain Henry at 2020-03-10T02:06:33-04:00 Hadrian: track missing configure results - - - - - ca8f51d4 by Ömer Sinan Ağacan at 2020-03-10T02:07:22-04:00 Add regression test for T17904 Closes #17904 - - - - - 5fa9cb82 by Richard Eisenberg at 2020-03-10T12:29:46-04:00 anyRewritableTyVar now looks in RuntimeReps Previously, anyRewritableTyVar looked only at the arg and res of `arg -> res`, but their RuntimeReps are also subject to rewriting. Easy to fix. Test case: typecheck/should_compile/T17024 Fixes #17024. - - - - - 5ba01d83 by Ben Price at 2020-03-10T12:30:27-04:00 Clarify a Lint message When developing a plugin I had a shadowing problem, where I generated code app = \f{v r7B} x{v r7B} -> f{v r7B} x{v r7B} This is obviously wrong, since the occurrence of `f` to the right of the arrow refers to the `x` binder (they share a Unique). However, it is rather confusing when Lint reports Mismatch in type between binder and occurrence Var: x{v rB7} since it is printing the binder, rather than the occurrence. It is rather easy to read this as claiming there is something wrong with the `x` occurrence! We change the report to explicitly print both the binder and the occurrence variables. - - - - - 7b2c827b by Simon Peyton Jones at 2020-03-10T12:31:15-04:00 Comments only Clarify code added in #17852 and MR !2724 - - - - - 3300eeac by Krzysztof Gogolewski at 2020-03-10T12:31:54-04:00 Misc cleanup - Remove Note [Existentials in shift_con_pat]. The function shift_con_pat has been removed 15 years ago in 23f40f0e9be6d4. - Remove kcLookupTcTyCon - it's the same as tcLookupTcTyCon - Remove ASSERT in tyConAppArgN. It's already done by getNth, and it's the only reason getNth exists. - Remove unused function nextRole - - - - - abf5736b by Krzysztof Gogolewski at 2020-03-10T18:05:01+01:00 Typos in comments [skip ci] - - - - - bb586f89 by Ben Gamari at 2020-03-11T00:14:59-04:00 rts: Prefer darwin-specific getCurrentThreadCPUTime macOS Catalina now supports a non-POSIX-compliant version of clock_gettime which cannot use the clock_gettime codepath. Fixes #17906. - - - - - 20800b9a by Sylvain Henry at 2020-03-11T08:17:19-04:00 Split GHC.Iface.Utils module * GHC.Iface.Recomp: recompilation avoidance stuff * GHC.Iface.Make: mkIface* Moved `writeIfaceFile` into GHC.Iface.Load alongside `readIface` and renamed it `writeIface` for consistency. - - - - - 1daa2029 by Greg Steuck at 2020-03-11T08:17:56-04:00 Fixed a minor typo in codegen.rst - - - - - 0bc23338 by Ryan Scott at 2020-03-11T08:18:32-04:00 Re-quantify when generalising over rewrite rule types Previously, `tcRules` would check for naughty quantification candidates (see `Note [Naughty quantification candidates]` in `TcMType`) when generalising over the type of a rewrite rule. This caused sensible-looking rewrite rules (like those in #17710) to be rejected. A more permissing (and easier-to-implement) approach is to do what is described in `Note [Generalising in tcTyFamInstEqnGuts]` in `TcTyClsDecls`: just re-quantify all the type variable binders, regardless of the order in which the user specified them. After all, the notion of type variable specificity has no real meaning in rewrite rules, since one cannot "visibly apply" a rewrite rule. I have written up this wisdom in `Note [Re-quantify type variables in rules]` in `TcRules`. As a result of this patch, compiling the `ExplicitForAllRules1` test case now generates one fewer warning than it used to. As far as I can tell, this is benign, since the thing that the disappearing warning talked about was also mentioned in an entirely separate warning. Fixes #17710. - - - - - 336eac7e by Ben Gamari at 2020-03-11T08:19:08-04:00 testsuite: Mark ghci056 and ghcilink004 as fragile in unreg As noted in #17018. Also fix fragile declaration of T13786, which only runs in the normal way. - - - - - c61b9b02 by Simon Peyton Jones at 2020-03-11T08:19:44-04:00 Deepen call stack for isIn I see quite a few warnings like: WARNING: file compiler/utils/Util.hs, line 593 Over-long elem in unionLists But the call stack is uninformative. Better to add HasDebugCallStack to isIn. Ditto isn'tIn. - - - - - 3aa9b35f by Ömer Sinan Ağacan at 2020-03-11T08:20:27-04:00 Zero any slop after compaction in compacting GC In copying GC, with the relevant debug flags enabled, we release the old blocks after a GC, and the block allocator zeroes the space before releasing a block. This effectively zeros the old heap. In compacting GC we reuse the blocks and previously we didn't zero the unused space in a compacting generation after compaction. With this patch we zero the slop between the free pointer and the end of the block when we're done with compaction and when switching to a new block (because the current block doesn't have enough space for the next object we're shifting). - - - - - 8e6febce by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor GHC.Driver.Session (Ways and Flags) * extract flags and ways into their own modules (with some renaming) * remove one SOURCE import of GHC.Driver.Session from GHC.Driver.Phases * when GHC uses dynamic linking (WayDyn), `interpWays` was only reporting WayDyn even if the host was profiled (WayProf). Now it returns both as expected (might fix #16803). * `mkBuildTag :: [Way] -> String` wasn't reporting a canonical tag for differently ordered lists. Now we sort and nub the list to fix this. - - - - - bc41e471 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor interpreterDynamic and interpreterProfiled * `interpreterDynamic` and `interpreterProfiled` now take `Interp` parameters instead of DynFlags * slight refactoring of `ExternalInterp` so that we can read the iserv configuration (which is pure) without reading an MVar. - - - - - a6989971 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Use a Set to represent Ways Should make `member` queries faster and avoid messing up with missing `nubSort`. Metric Increase: hie002 - - - - - cb93a1a4 by Ryan Scott at 2020-03-11T20:34:14-04:00 Make DeriveFunctor-generated code require fewer beta reductions Issue #17880 demonstrates that `DeriveFunctor`-generated code is surprisingly fragile when rank-_n_ types are involved. The culprit is that `$fmap` (the algorithm used to generate `fmap` implementations) was too keen on applying arguments with rank-_n_ types to lambdas, which fail to typecheck more often than not. In this patch, I change `$fmap` (both the specification and the implementation) to produce code that avoids creating as many lambdas, avoiding problems when rank-_n_ field types arise. See the comments titled "Functor instances" in `TcGenFunctor` for a more detailed description. Not only does this fix #17880, but it also ensures that the code that `DeriveFunctor` generates will continue to work after simplified subsumption is implemented (see #17775). What is truly amazing is that #17880 is actually a regression (introduced in GHC 7.6.3) caused by commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e, the fix #7436. Prior to that commit, the version of `$fmap` that was used was almost identical to the one used in this patch! Why did that commit change `$fmap` then? It was to avoid severe performance issues that would arise for recursive `fmap` implementations, such as in the example below: ```hs data List a = Nil | Cons a (List a) deriving Functor -- ===> instance Functor List where fmap f Nil = Nil fmap f (Cons x xs) = Cons (f x) (fmap (\y -> f y) xs) ``` The fact that `\y -> f y` was eta expanded caused significant performance overheads. Commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e fixed this performance issue, but it went too far. As a result, this patch partially reverts 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e. To ensure that the performance issues pre-#7436 do not resurface, I have taken some precautionary measures: * I have added a special case to `$fmap` for situations where the last type variable in an application of some type occurs directly. If this special case fires, we avoid creating a lambda expression. This ensures that we generate `fmap f (Cons x xs) = Cons (f x) (fmap f xs)` in the derived `Functor List` instance above. For more details, see `Note [Avoid unnecessary eta expansion in derived fmap implementations]` in `TcGenFunctor`. * I have added a `T7436b` test case to ensure that the performance of this derived `Functor List`-style code does not regress. When implementing this, I discovered that `$replace`, the algorithm which generates implementations of `(<$)`, has a special case that is very similar to the `$fmap` special case described above. `$replace` marked this special case with a custom `Replacer` data type, which was a bit overkill. In order to use the same machinery for both `Functor` methods, I ripped out `Replacer` and instead implemented a simple way to detect the special case. See the updated commentary in `Note [Deriving <$]` for more details. - - - - - 1f9db3e7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Properly parenthesise LastStmt After ApplicatveDo strips the last `return` during renaming, the pretty printer has to restore it. However, if the return was followed by `$`, the dollar was stripped too and not restored. For example, the last stamement in: ``` foo = do x <- ... ... return $ f x ``` would be printed as: ``` return f x ``` This commit preserved the dolar, so it becomes: ``` return $ f x ``` - - - - - 5cb93af7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Do not print ApplicativeDo join * Do not print `join` in ApplictiveStmt, unless ppr-debug * Print parens around multiple parallel binds When ApplicativeDo is enabled, the renamer analyses the statements of a `do` block and in certain cases marks them as needing to be rewritten using `join`. For example, if you have: ``` foo = do a <- e1 b <- e2 doSomething a b ``` it will be desugared into: ``` foo = join (doSomething <$> e1 <*> e2) ``` After renaming but before desugaring the expression is stored essentially as: ``` foo = do [will need join] (a <- e1 | b <- e2) [no return] doSomething a b ``` Before this change, the pretty printer would print a call to `join`, even though it is not needed at this stage at all. The expression will be actually rewritten into one using join only at desugaring, at which point a literal call to join will be inserted. - - - - - 3a259092 by Simon Peyton Jones at 2020-03-12T09:46:29-04:00 Expose compulsory unfoldings always The unsafeCoerce# patch requires that unsafeCoerce# has a compulsory unfolding that is always available. So we have to be careful to expose compulsory unfoldings unconditionally and consistently. We didn't get this quite right: #17871. This patch fixes it. No real surprises here. See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy - - - - - 6a65b8c2 by Alp Mestanogullari at 2020-03-13T02:29:20-04:00 hadrian: improve dependency tracking for the check-* programs The code in Rules.Register responsible for finding all the build artifacts that Cabal installs when registering a library (static/shared libs, .hi files, ...) was looking in the wrong place. This patch fixes that logic and makes sure we gather all those artifacts in a list to declare that the rule for a given `.conf` file, our proxy for "Hadrian, please install this package in the package db for this stage", also produces those artifacts under the said package database. We also were completely missing some logic to declare that the check-* programs have dependencies besides their source code, at least when testing an in-tree compiler. Finally, this patch also removes redundant packages from 'testsuitePackages', since they should already be covered by the stage<N>Packages lists from Settings.Default. With this patch, after a complete build and freezing stage 1, a change to `compiler/parser/Parser.y` results in rebuilding the ghc lib, reinstalling it, and rebuilding the few programs that depend on it, _including_ `check-ppr` and `check-api-annotations` (therefore fixing #17273). - - - - - 44fad4a9 by Sylvain Henry at 2020-03-13T02:30:22-04:00 Rename isDllName I wanted to fix the dangling comment in `isDllName` ("This is the cause of #", #8696 is already mentioned earlier). I took the opportunity to change the function name to better reflect what it does. - - - - - 2f292db8 by Paavo at 2020-03-13T02:31:03-04:00 Update documentation for closureSize - - - - - f124ff0d by Ben Gamari at 2020-03-13T02:31:40-04:00 gitlab-ci: Rework triggering of release builds Use a push option instead of tagging. - - - - - 7f25557a by Ben Gamari at 2020-03-13T10:38:09-04:00 gitlab-ci: Distinguish integer-simple test envs Previously two integer-simple jobs declared the same test environment. One (the nightly job) was built in the perf way, the other in the validate way. Consequently they had appreciably different performance characteristics, causing in the nightly job to spuriously fail with performance changes. - - - - - c12a2ec5 by Simon Peyton Jones at 2020-03-14T05:25:30-04:00 Fix Lint Ticket #17590 pointed out a bug in the way the linter dealt with type lets, exposed by the new uniqAway story. The fix is described in Note [Linting type lets]. I ended up putting the in-scope Ids in a different env field, le_ids, rather than (as before) sneaking them into the TCvSubst. Surprisingly tiresome, but done. Metric Decrease: hie002 - - - - - b989845e by Sylvain Henry at 2020-03-14T05:26:11-04:00 Hadrian: fix absolute buildroot support (#17822) Shake's "**" wildcard doesn't match absolute root. We must use "//" instead. - - - - - 4f117135 by Sylvain Henry at 2020-03-14T05:26:49-04:00 Make: refactor GMP rules Document and use simpler rules for the ghc-gmp.h header. - - - - - 7432b327 by Sylvain Henry at 2020-03-14T05:27:28-04:00 Use correct option name (-opti) (fix #17314) s/pgmo/opti - - - - - 8f7dd571 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Allow overriding LD_STAGE0 and AR_STAGE0 in the configure script. Previously it was possible to override the stage0 C compiler via `CC_STAGE0`, but you couldn't override `ld` or `ar` in stage0. This change allows overriding them by setting `LD_STAGE0` or `AR_STAGE0`, respectively. Our team uses this feature internally to take more control of our GHC build and make it run more hermetically. - - - - - 7c3e39a9 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Use AC_ARG_VAR for LD_STAGE0 and AR_STAGE0. - - - - - 20d4d676 by Ben Gamari at 2020-03-14T05:28:43-04:00 nonmoving: Don't traverse filled segment list in pause The non-moving collector would previously walk the entire filled segment list during the preparatory pause. However, this is far more work than is strictly necessary. We can rather get away with merely collecting the allocators' filled segment list heads and process the lists themselves during the concurrent phase. This can significantly reduce the maximum gen1 GC pause time in programs with high rates of long-lived allocations. - - - - - fdfa2d01 by Ben Gamari at 2020-03-14T05:29:18-04:00 nonmoving: Remove redundant bitmap clearing nonmovingSweep already clears the bitmap in the sweep loop. There is no reason to do so a second time. - - - - - 2f8c7767 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Simple refactor of cheapEqExpr No change in functionality. Just seems tidier (and signficantly more efficient) to deal with ticks directly than to call stripTicksTopE. - - - - - 88f7a762 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Improve CSE.combineAlts This patch improves the way that CSE combines identical alternatives. See #17901. I'm still not happy about the duplication between CSE.combineAlts and GHC.Core.Utils.combineIdenticalAlts; see the Notes with those functions. But this patch is a step forward. Metric Decrease: T12425 T5642 - - - - - 8b95ddd3 by Ben Gamari at 2020-03-14T05:30:31-04:00 gitlab-ci: Add integer-simple release build for Windows Closes #16144. - - - - - e3c374cc by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Wrap an implication around class-sig kind errors Ticket #17841 showed that we can get a kind error in a class signature, but lack an enclosing implication that binds its skolems. This patch * Adds the wrapping implication: the new call to checkTvConstraints in tcClassDecl1 * Simplifies the API to checkTvConstraints, which was not otherwise called at all. * Simplifies TcErrors.report_unsolved by *not* initialising the TidyEnv from the typechecker lexical envt. It's enough to do so from the free vars of the unsolved constraints; and we get silly renamings if we add variables twice: once from the lexical scope and once from the implication constraint. - - - - - 73133a3b by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Refactoring in TcSMonad This patch is just refactoring: no change in behaviour. I removed the rather complicated checkConstraintsTcS checkTvConstraintsTcS in favour of simpler functions emitImplicationTcS emitTvImplicationTcS pushLevelNoWorkList The last of these is a little strange, but overall it's much better I think. - - - - - 93c88c26 by Ben Gamari at 2020-03-14T05:31:42-04:00 base: Make `open` calls interruptible As noted in #17912, `open` system calls were `safe` rather than `interruptible`. Consequently, the program could not be interrupted with SIGINT if stuck in a slow open operation. Fix this by marking `c_safe_open` as interruptible. - - - - - bee4cdad by Vladislav Zavialov at 2020-03-14T05:32:18-04:00 Remove second tcLookupTcTyCon in tcDataDefn Before this patch, tcDataDefn used to call tcLookupTcTyCon twice in a row: 1. in bindTyClTyVars itself 2. in the continuation passed to it Now bindTyClTyVars passes the TcTyCon to the continuation, making the second lookup unnecessary. - - - - - 3f116d35 by Cale Gibbard at 2020-03-14T19:34:42-04:00 Enable stage1 build of haddock The submodule has already been bumped to contain the fix. - - - - - 49e9d739 by Ömer Sinan Ağacan at 2020-03-14T19:35:24-04:00 rts: Fix printClosure when printing fwd ptrs - - - - - 1de3ab4a by Krzysztof Gogolewski at 2020-03-14T19:36:04-04:00 Remove unused field var_inline (#17915) - - - - - d30aeb4b by Krzysztof Gogolewski at 2020-03-15T03:57:41-04:00 Document restriction on SCC pragma syntax Currently, the names of cost centres must be quoted or be lowercase identifiers. Fixes #17916. - - - - - b4774598 by Brian Foley at 2020-03-15T03:58:18-04:00 Remove some dead code >From the notes.ghc.drop list found using weeder in #17713 - - - - - dd6ffe6b by Viktor Dukhovni at 2020-03-15T03:58:55-04:00 Note platform-specific Foreign.C.Types in context Also fix the markup in the general note at the top of the module. Haddock (usability trade-off), does not support multi-line emphasised text. - - - - - 2e82465f by Sylvain Henry at 2020-03-15T10:57:10-04:00 Refactor CmmToAsm (disentangle DynFlags) This patch disentangles a bit more DynFlags from the native code generator (CmmToAsm). In more details: - add a new NCGConfig datatype in GHC.CmmToAsm.Config which contains the configuration of a native code generation session - explicitly pass NCGConfig/Platform arguments when necessary - as a consequence `sdocWithPlatform` is gone and there are only a few `sdocWithDynFlags` left - remove the use of `unsafeGlobalDynFlags` from GHC.CmmToAsm.CFG - remove `sdocDebugLevel` (now we pass the debug level via NCGConfig) There are still some places where DynFlags is used, especially because of pretty-printing (CLabel), because of Cmm helpers (such as `cmmExprType`) and because of `Outputable` instance for the instructions. These are left for future refactoring as this patch is already big. - - - - - c35c545d by Judah Jacobson at 2020-03-15T10:57:48-04:00 Add a -no-haddock flag. This flag undoes the effect of a previous "-haddock" flag. Having both flags makes it easier for build systems to enable Haddock parsing in a set of global flags, but then disable it locally for specific targets (e.g., third-party packages whose comments don't pass the validation in the latest GHC). I added the flag to expected-undocumented-flags.txt since `-haddock` was alreadyin that list. - - - - - cfcc3c9a by Ömer Sinan Ağacan at 2020-03-15T10:58:27-04:00 Fix global_link of TSOs for threads reachable via dead weaks Fixes #17785 Here's how the problem occurs: - In generation 0 we have a TSO that is finished (i.e. it has no more work to do or it is killed). - The TSO only becomes reachable after collectDeadWeakPtrs(). - After collectDeadWeakPtrs() we switch to WeakDone phase where we don't move TSOs to different lists anymore (like the next gen's thread list or the resurrected_threads list). - So the TSO will never be moved to a generation's thread list, but it will be promoted to generation 1. - Generation 1 collected via mark-compact, and because the TSO is reachable it is marked, and its `global_link` field, which is bogus at this point (because the TSO is not in a list), will be threaded. - Chaos ensues. In other words, when these conditions hold: - A TSO is reachable only after collectDeadWeakPtrs() - It's finished (what_next is ThreadComplete or ThreadKilled) - It's retained by mark-compact collector (moving collector doesn't evacuate the global_list field) We end up doing random mutations on the heap because the TSO's global_list field is not valid, but it still looks like a heap pointer so we thread it during compacting GC. The fix is simple: when we traverse old_threads lists to resurrect unreachable threads the threads that won't be resurrected currently stays on the old_threads lists. Those threads will never be visited again by MarkWeak so we now reset the global_list fields. This way compacting GC does not thread pointers to nowhere. Testing ------- The reproducer in #17785 is quite large and hard to build, because of the dependencies, so I'm not adding a regression test. In my testing the reproducer would take a less than 5 seconds to run, and once in every ~5 runs would fail with a segfault or an assertion error. In other cases it also fails with a test failure. Because the tests never fail with the bug fix, assuming the code is correct, this also means that this bug can sometimes lead to incorrect runtime results. After the fix I was able to run the reproducer repeatedly for about an hour, with no runtime crashes or test failures. To run the reproducer clone the git repo: $ git clone https://github.com/osa1/streamly --branch ghc-segfault Then clone primitive and atomic-primops from their git repos and point to the clones in cabal.project.local. The project should then be buildable using GHC HEAD. Run the executable `properties` with `+RTS -c -DZ`. In addition to the reproducer above I run the test suite using: $ make slowtest EXTRA_HC_OPTS="-debug -with-rtsopts=-DS \ -with-rtsopts=-c +RTS -c -RTS" SKIPWAY='nonmoving nonmoving_thr' This enables compacting GC always in both GHC when building the test programs and when running the test programs, and also enables sanity checking when running the test programs. These set of flags are not compatible for all tests so there are some failures, but I got the same set of failures with this patch compared to GHC HEAD. - - - - - 818b3c38 by Lysxia at 2020-03-16T23:52:42-04:00 base: add strict IO functions: readFile', getContents', hGetContents' - - - - - 18a346a4 by Sylvain Henry at 2020-03-16T23:53:24-04:00 Modules: Core (#13009) Update submodule: haddock - - - - - 92327e3a by Ömer Sinan Ağacan at 2020-03-16T23:54:04-04:00 Update sanity checking for TSOs: - Remove an invalid assumption about GC checking what_next field. The GC doesn't care about what_next at all, if a TSO is reachable then all its pointers are followed (other than global_tso, which is only followed by compacting GC). - Remove checkSTACK in checkTSO: TSO stacks will be visited in checkHeapChain, or checkLargeObjects etc. - Add an assertion in checkTSO to check that the global_link field is sane. - Did some refactor to remove forward decls in checkGlobalTSOList and added braces around single-statement if statements. - - - - - e1aa4052 by PHO at 2020-03-17T07:36:09-04:00 Don't use non-portable operator "==" in configure.ac The test operator "==" is a Bash extension and produces a wrong result if /bin/sh is not Bash. - - - - - 89f034dd by Maximilian Tagher at 2020-03-17T07:36:48-04:00 Document the units of -ddump-timings Right now, in the output of -ddump-timings to a file, you can't tell what the units are: ``` CodeGen [TemplateTestImports]: alloc=22454880 time=14.597 ``` I believe bytes/milliseconds are the correct units, but confirmation would be appreciated. I'm basing it off of this snippet from `withTiming'`: ``` when (verbosity dflags >= 2 && prtimings == PrintTimings) $ liftIO $ logInfo dflags (defaultUserStyle dflags) (text "!!!" <+> what <> colon <+> text "finished in" <+> doublePrec 2 time <+> text "milliseconds" <> comma <+> text "allocated" <+> doublePrec 3 (realToFrac alloc / 1024 / 1024) <+> text "megabytes") ``` which implies time is in milliseconds, and allocations in bytes (which divided by 1024 would be KB, and again would be MB) - - - - - beffa147 by Simon Peyton Jones at 2020-03-17T07:37:25-04:00 Implement mapTyCo like foldTyCo This patch makes mapType use the successful idiom described in TyCoRep Note [Specialising foldType] I have not yet changed any functions to use mapType, though there may be some suitable candidates. This patch should be a no-op in terms of functionality but, because it inlines the mapper itself, I'm hoping that there may be some modest perf improvements. Metric Decrease: T5631 T5642 T3064 T9020 T14683 hie002 haddock.Cabal haddock.base haddock.compiler - - - - - 5800ebfe by Ömer Sinan Ağacan at 2020-03-17T07:38:08-04:00 Don't update ModDetails with CafInfos when opts are disabled This is consistent with the interface file behavior where we omit HsNoCafRefs annotations with -fomit-interface-pragmas (implied by -O0). ModDetails and ModIface are just different representations of the same thing, so they really need to be in sync. This patch does the right thing and does not need too much explanation, but here's an example of a problem not doing this causes in !2842: -- MyInteger.hs module MyInteger ( MyInteger (MyInteger) , ToMyInteger (toMyInteger) ) where newtype MyInteger = MyInteger Integer class ToMyInteger a where toMyInteger :: a -> MyInteger instance ToMyInteger Integer where toMyInteger = MyInteger {- . succ -} -- Main.hs module Main ( main ) where import MyInteger (MyInteger (MyInteger), toMyInteger) main :: IO () main = do let (MyInteger i) = (id . toMyInteger) (41 :: Integer) print i If I build this with -O0, without this fix, we generate a ModDetails with accurate LFInfo for toMyInteger (MyInteger.$fToMyIntegerInteger) which says that it's a LFReEntrant with arity 1. This means in the use site (Main) we tag the value: R3 = MyInteger.$fToMyIntegerInteger_closure + 1; R2 = GHC.Base.id_closure; R1 = GHC.Base.._closure; Sp = Sp - 16; call stg_ap_ppp_fast(R4, R3, R2, R1) args: 24, res: 0, upd: 24; Now we change the definition by uncommenting the `succ` part and it becomes a thunk: MyInteger.$fToMyIntegerInteger [InlPrag=INLINE (sat-args=0)] :: MyInteger.ToMyInteger GHC.Integer.Type.Integer [GblId[DFunId(nt)]] = {} \u [] $ctoMyInteger_rEA; and its LFInfo is now LFThunk. This change in LFInfo makes a difference in the use site: we can no longer tag it. But becuase the interface fingerprint does not change (because ModIface does not change) we don't rebuild Main and tag the thunk. (1.2% increase in allocations when building T12545 on armv7 because we generate more code without CafInfos) Metric Increase: T12545 - - - - - 5b632dad by Paavo at 2020-03-17T07:38:48-04:00 Add example for Data.Semigroup.diff - - - - - 4d85d68b by Paavo at 2020-03-17T07:38:48-04:00 Clean up - - - - - 75168d07 by Paavo at 2020-03-17T07:38:48-04:00 Make example collapsible - - - - - 53ff2cd0 by Richard Eisenberg at 2020-03-17T13:46:57+00:00 Fix #17021 by checking more return kinds All the details are in new Note [Datatype return kinds] in TcTyClsDecls. Test case: typecheck/should_fail/T17021{,b} typecheck/should_compile/T17021a Updates haddock submodule - - - - - 528df8ec by Sylvain Henry at 2020-03-18T10:06:43-04:00 Modules: Core operations (#13009) - - - - - 4e8a71c1 by Richard Eisenberg at 2020-03-18T10:07:19-04:00 Add release note about fix to #16502. We thought we needed to update the manual, but the fix for #16502 actually brings the implementation in line with the manual. So we just alert users of how to update their code. - - - - - 5cbf9934 by Andreas Klebinger at 2020-03-19T00:39:27-04:00 Update "GHC differences to the FFI Chapter" in user guide. The old entry had a heavy focus on how things had been. Which is not what I generally look for in a user guide. I also added a small section on behaviour of nested safe ffi calls. [skip-ci] - - - - - b03fd3bc by Sebastian Graf at 2020-03-19T00:40:06-04:00 PmCheck: Use ConLikeSet to model negative info In #17911, Simon recognised many warnings stemming from over-long list unions while coverage checking Cabal's `LicenseId` module. This patch introduces a new `PmAltConSet` type which uses a `UniqDSet` instead of an association list for `ConLike`s. For `PmLit`s, it will still use an assocation list, though, because a similar map data structure would entail a lot of busy work. Fixes #17911. - - - - - 64f20756 by Sylvain Henry at 2020-03-19T12:16:49-04:00 Refactoring: use Platform instead of DynFlags when possible Metric Decrease: ManyConstructors T12707 T13035 T1969 - - - - - cb1785d9 by Ömer Sinan Ağacan at 2020-03-19T12:16:54-04:00 FastString: fix eager reading of string ptr in hashStr This read causes NULL dereferencing when len is 0. Fixes #17909 In the reproducer in #17909 this bug is triggered as follows: - SimplOpt.dealWithStringLiteral is called with a single-char string ("=" in #17909) - tailFS gets called on the FastString of the single-char string. - tailFS checks the length of the string, which is 1, and calls mkFastStringByteString on the tail of the ByteString, which is an empty ByteString as the original ByteString has only one char. - ByteString's unsafeUseAsCStringLen returns (NULL, 0) for the empty ByteString, which is passed to mkFastStringWith. - mkFastStringWith gets hash of the NULL pointer via hashStr, which fails on empty strings because of this bug. - - - - - 73a7383e by Richard Eisenberg at 2020-03-20T20:42:56-04:00 Simplify treatment of heterogeneous equality Previously, if we had a [W] (a :: k1) ~ (rhs :: k2), we would spit out a [D] k1 ~ k2 and part the W as irreducible, hoping for a unification. But we needn't do this. Instead, we now spit out a [W] co :: k2 ~ k1 and then use co to cast the rhs of the original Wanted. This means that we retain the connection between the spat-out constraint and the original. The problem with this new approach is that we cannot use the casted equality for substitution; it's too like wanteds-rewriting- wanteds. So, we forbid CTyEqCans that mention coercion holes. All the details are in Note [Equalities with incompatible kinds] in TcCanonical. There are a few knock-on effects, documented where they occur. While debugging an error in this patch, Simon and I ran into infelicities in how patterns and matches are printed; we made small improvements. This patch includes mitigations for #17828, which causes spurious pattern-match warnings. When #17828 is fixed, these lines should be removed. - - - - - faa36e5b by Sylvain Henry at 2020-03-20T20:43:41-04:00 Hadrian: ignore in-tree GMP objects with ``--lint`` - - - - - 9a96ff6b by Richard Eisenberg at 2020-03-20T20:44:17-04:00 Update core spec to reflect changes to Core. Key changes: * Adds a new rule for forall-coercions over coercion variables, which was implemented but conspicuously missing from the spec. * Adds treatment for FunCo. * Adds treatment for ForAllTy over coercion variables. * Improves commentary (including restoring a Note lost in 03d4852658e1b7407abb4da84b1b03bfa6f6db3b) in the source. No changes to running code. - - - - - 7e0451c6 by Sergej Jaskiewicz at 2020-03-20T20:44:55-04:00 Fix event message in withTiming' This typo caused generating 'end' events without the corresponding 'begin' events. - - - - - 1542a626 by Ben Gamari at 2020-03-22T22:37:47-04:00 fs.h: Add missing declarations on Windows - - - - - 3bcf2ccd by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump process submodule Avoids redundant case alternative warning. - - - - - 3b363ef9 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Normalize slashes in ghc-api annotations output Enable `normalise_slashes` on `annotations`, `listcomps`, and `parseTree` to fix Windows failures. - - - - - 25fc9429 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - 7f58ec6d by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Fix TOP of T17786 - - - - - aadcd909 by GHC GitLab CI at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - dc1eb10d by GHC GitLab CI at 2020-03-22T22:37:47-04:00 hadrian: Fix executable extension passed to testsuite driver - - - - - 58f62e2c by GHC GitLab CI at 2020-03-22T22:37:47-04:00 gitlab-ci: Require that Windows-hadrian job passes - - - - - 8dd2415d by Ben Gamari at 2020-03-22T22:37:47-04:00 hadrian: Eliminate redundant .exe from GHC path Previously we were invoking: bash -c "c:/GitLabRunner/builds/eEQrxK4p/0/ghc/ghc/toolchain/bin/ghc.exe.exe testsuite/mk/ghc-config.hs -o _build/test/bin/ghc-config.exe" - - - - - 373621f6 by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump hsc2hs submodule - - - - - abc02b40 by Hécate at 2020-03-22T22:38:33-04:00 Annotate the non-total function in Data.Foldable as such - - - - - 19f12557 by Josef Svenningsson at 2020-03-23T14:05:33-04:00 Fix ApplicativeDo regression #17835 A previous fix for #15344 made sure that monadic 'fail' is used properly when translating ApplicativeDo. However, it didn't properly account for when a 'fail' will be inserted which resulted in some programs failing with a type error. - - - - - 2643ba46 by Paavo at 2020-03-24T08:31:32-04:00 Add example and doc for Arg (Fixes #17153) - - - - - 703221f4 by Roland Senn at 2020-03-25T14:45:04-04:00 Use export list of Main module in function TcRnDriver.hs:check_main (Fix #16453) - Provide the export list of the `Main` module as parameter to the `compiler/typecheck/TcRnDriver.hs:check_main` function. - Instead of `lookupOccRn_maybe` call the function `lookupInfoOccRn`. It returns the list `mains_all` of all the main functions in scope. - Select from this list `mains_all` all `main` functions that are in the export list of the `Main` module. - If this new list contains exactly one single `main` function, then typechecking continues. - Otherwise issue an appropriate error message. - - - - - 3e27205a by Sebastian Graf at 2020-03-25T14:45:40-04:00 Remove -fkill-absence and -fkill-one-shot flags They seem to be a benchmarking vestige of the Cardinality paper and probably shouldn't have been merged to HEAD in the first place. - - - - - 262e42aa by Peter Trommler at 2020-03-25T22:41:39-04:00 Do not panic on linker errors - - - - - 0de03cd7 by Sylvain Henry at 2020-03-25T22:42:02-04:00 DynFlags refactoring III Use Platform instead of DynFlags when possible: * `tARGET_MIN_INT` et al. replaced with `platformMinInt` et al. * no more DynFlags in PreRules: added a new `RuleOpts` datatype * don't use `wORD_SIZE` in the compiler * make `wordAlignment` use `Platform` * make `dOUBLE_SIZE` a constant Metric Decrease: T13035 T1969 - - - - - 7a04920b by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: fix a typo in liftA doc This change removes an extra '|' that should not be rendered in the liftA documentation. Tracking: #17929 - - - - - 1c5a15f7 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add Control.Applicative optional example This change adds an optional example. Tracking: #17929 - - - - - 6d172e63 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add markup around Except - - - - - eb2162c8 by John Ericson at 2020-03-26T12:37:08-04:00 Remove unused `ghciTablesNextToCode` from compiler proper - - - - - f51efc4b by Joachim Breitner at 2020-03-26T12:37:09-04:00 Prepare to use run-time tablesNextToCode in compiler exclusively Factor out CPP as much as possible to prepare for runtime determinattion. Progress towards #15548 - - - - - 1c446220 by Joachim Breitner at 2020-03-26T12:37:09-04:00 Use run-time tablesNextToCode in compiler exclusively (#15548) Summary: - There is no more use of the TABLES_NEXT_TO_CODE CPP macro in `compiler/`. GHCI_TABLES_NEXT_TO_CODE is also removed entirely. The field within `PlatformMisc` within `DynFlags` is used instead. - The field is still not exposed as a CLI flag. We might consider some way to ensure the right RTS / libraries are used before doing that. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082 - - - - - 1941ef4f by Sylvain Henry at 2020-03-29T17:28:51-04:00 Modules: Types (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - 1c7c6f1a by Sylvain Henry at 2020-03-29T17:28:51-04:00 Remove GHC.Types.Unique.Map module This module isn't used anywhere in GHC. - - - - - f1a6c73d by Sylvain Henry at 2020-03-29T17:28:51-04:00 Merge GHC.Types.CostCentre.Init into GHC.Driver.CodeOutput - - - - - 54250f2d by Simon Peyton Jones at 2020-03-29T17:29:30-04:00 Demand analysis: simplify the demand for a RHS Ticket #17932 showed that we were using a stupid demand for the RHS of a let-binding, when the result is a product. This was the result of a "fix" in 2013, which (happily) turns out to no longer be necessary. So I just deleted the code, which simplifies the demand analyser, and fixes #17932. That in turn uncovered that the anticipation of worker/wrapper in CPR analysis was inaccurate, hence the logic that decides whether to unbox an argument in WW was extracted into a function `wantToUnbox`, now consulted by CPR analysis. I tried nofib, and got 0.0% perf changes. All this came up when messing about with !2873 (ticket #17917), but is idependent of it. Unfortunately, this patch regresses #4267 and realised that it is now blocked on #16335. - - - - - 03060b2f by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 on Windows Fixes line ending normalization issue. - - - - - 1f7995ba by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 Fix missing quoting and expected exit code. - - - - - ef9c608e by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - e54500c1 by Sylvain Henry at 2020-03-29T17:30:47-04:00 Store ComponentId details As far as GHC is concerned, installed package components ("units") are identified by an opaque ComponentId string provided by Cabal. But we don't want to display it to users (as it contains a hash) so GHC queries the database to retrieve some infos about the original source package (name, version, component name). This patch caches these infos in the ComponentId itself so that we don't need to provide DynFlags (which contains installed package informations) to print a ComponentId. In the future we want GHC to support several independent package states (e.g. for plugins and for target code), hence we need to avoid implicitly querying a single global package state. - - - - - 7e7cb714 by Marius Bakke at 2020-03-29T17:31:27-04:00 testsuite: Remove test that dlopens a PIE object. glibc 2.30 disallowed dlopening PIE objects, so just remove the test. Fixes #17952. - - - - - 6c8f80d8 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Correct haddocks for testBit in Data.Bits It conflated the nth bit with the bit at offset n. Now we instead give the definition in terms of `bit and `.&.` on top of clearer phrasing. - - - - - c916f190 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Apply suggestion to libraries/base/Data/Bits.hs - - - - - 64bf7f51 by Ben Gamari at 2020-03-29T17:32:41-04:00 gitlab-ci: Add FreeBSD release job - - - - - a0d8e92e by Ryan Scott at 2020-03-29T17:33:20-04:00 Run checkNewDataCon before constraint-solving newtype constructors Within `checkValidDataCon`, we used to run `checkValidType` on the argument types of a newtype constructor before running `checkNewDataCon`, which ensures that the user does not attempt non-sensical things such as newtypes with multiple arguments or constraints. This works out in most situations, but this falls over on a corner case revealed in #17955: ```hs newtype T = Coercible () T => T () ``` `checkValidType`, among other things, peforms an ambiguity check on the context of a data constructor, and that it turn invokes the constraint solver. It turns out that there is a special case in the constraint solver for representational equalities (read: `Coercible` constraints) that causes newtypes to be unwrapped (see `Note [Unwrap newtypes first]` in `TcCanonical`). This special case does not know how to cope with an ill formed newtype like `T`, so it ends up panicking. The solution is surprisingly simple: just invoke `checkNewDataCon` before `checkValidType` to ensure that the illicit newtype constructor context is detected before the constraint solver can run amok with it. Fixes #17955. - - - - - 45eb9d8c by Krzysztof Gogolewski at 2020-03-29T17:33:59-04:00 Minor cleanup - Simplify mkBuildExpr, the function newTyVars was called only on a one-element list. - TTG: use noExtCon in more places. This is more future-proof. - In zonkExpr, panic instead of printing a warning. - - - - - f024b6e3 by Sylvain Henry at 2020-03-30T12:48:39+02:00 Expect T4267 to pass Since 54250f2d8de910b094070c1b48f086030df634b1 we expected T4267 to fail, but it passes on CI. - - - - - 57b888c0 by Ryan Scott at 2020-03-31T10:54:20-04:00 Require GHC 8.8 as the minimum compiler for bootstrapping This allows us to remove several bits of CPP that are either always true or no longer reachable. As an added bonus, we no longer need to worry about importing `Control.Monad.Fail.fail` qualified to avoid clashing with `Control.Monad.fail`, since the latter is now the same as the former. - - - - - 33f09551 by Ryan Scott at 2020-03-31T10:54:57-04:00 Add regression test for #17963 The panic in #17963 happened to be fixed by commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70. This patch adds a regression test to ensure that it remains fixed. Fixes #17963. - - - - - 09a36e80 by Ömer Sinan Ağacan at 2020-03-31T10:55:37-04:00 Simplify stderrSupportsAnsiColors The combinator andM is used only once, and the code is shorter and simpler if you inline it. - - - - - 95bccdd0 by Ben Gamari at 2020-03-31T10:56:19-04:00 base: Ensure that encoding global variables aren't inlined As noted in #17970, these (e.g. `getFileSystemEncoding` and `setFileSystemEncoding`) previously had unfoldings, which would break their global-ness. While not strictly necessary, I also add a NOINLINE on `initLocaleEncoding` since it is used in `System.IO`, ensuring that we only system's query the locale encoding once. Fixes #17970. - - - - - 982aaa83 by Andreas Klebinger at 2020-03-31T10:56:55-04:00 Update hadrian index revision. Required in order to build hadrian using ghc-8.10 - - - - - 4b9c5864 by Ben Gamari at 2020-03-31T10:57:32-04:00 integer-gmp: Bump version and add changelog entry - - - - - 9b39f2e6 by Ryan Scott at 2020-04-01T01:20:00-04:00 Clean up "Eta reduction for data families" Notes Before, there were two distinct Notes named "Eta reduction for data families". This renames one of them to "Implementing eta reduction for data families" to disambiguate the two and fixes references in other parts of the codebase to ensure that they are pointing to the right place. Fixes #17313. [ci skip] - - - - - 7627eab5 by Ryan Scott at 2020-04-01T01:20:38-04:00 Fix the changelog/@since information for hGetContents'/getContents'/readFile' Fixes #17979. [ci skip] - - - - - 0002db1b by Sylvain Henry at 2020-04-01T01:21:27-04:00 Kill wORDS_BIGENDIAN and replace it with platformByteOrder (#17957) Metric Decrease: T13035 T1969 - - - - - 7b217179 by Sebastian Graf at 2020-04-01T15:03:24-04:00 PmCheck: Adjust recursion depth for inhabitation test In #17977, we ran into the reduction depth limit of the typechecker. That was only a symptom of a much broader issue: The recursion depth of the coverage checker for trying to instantiate strict fields in the `nonVoid` test was far too high (100, the `defaultMaxTcBound`). As a result, we were performing quite poorly on `T17977`. Short of a proper termination analysis to prove emptyness of a type, we just arbitrarily default to a much lower recursion limit of 3. Fixes #17977. - - - - - 3c09f636 by Andreas Klebinger at 2020-04-01T15:03:59-04:00 Make hadrian pass on the no-colour setting to GHC. Fixes #17983. - - - - - b943b25d by Simon Peyton Jones at 2020-04-02T01:45:58-04:00 Re-engineer the binder-swap transformation The binder-swap transformation is implemented by the occurrence analyser -- see Note [Binder swap] in OccurAnal. However it had a very nasty corner in it, for the case where the case scrutinee was a GlobalId. This led to trouble and hacks, and ultimately to #16296. This patch re-engineers how the occurrence analyser implements the binder-swap, by actually carrying out a substitution rather than by adding a let-binding. It's all described in Note [The binder-swap substitution]. I did a few other things along the way * Fix a bug in StgCse, which could allow a loop breaker to be CSE'd away. See Note [Care with loop breakers] in StgCse. I think it can only show up if occurrence analyser sets up bad loop breakers, but still. * Better commenting in SimplUtils.prepareAlts * A little refactoring in CoreUnfold; nothing significant e.g. rename CoreUnfold.mkTopUnfolding to mkFinalUnfolding * Renamed CoreSyn.isFragileUnfolding to hasCoreUnfolding * Move mkRuleInfo to CoreFVs We observed respectively 4.6% and 5.9% allocation decreases for the following tests: Metric Decrease: T9961 haddock.base - - - - - 42d68364 by Sebastian Graf at 2020-04-02T01:46:34-04:00 Preserve precise exceptions in strictness analysis Fix #13380 and #17676 by 1. Changing `raiseIO#` to have `topDiv` instead of `botDiv` 2. Give it special treatment in `Simplifier.Util.mkArgInfo`, treating it as if it still had `botDiv`, to recover dead code elimination. This is the first commit of the plan outlined in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2525#note_260886. - - - - - 0a88dd11 by Ömer Sinan Ağacan at 2020-04-02T01:47:25-04:00 Fix a pointer format string in RTS - - - - - 5beac042 by Ömer Sinan Ağacan at 2020-04-02T01:48:05-04:00 Remove unused closure stg_IND_direct - - - - - 88f38b03 by Ben Gamari at 2020-04-02T01:48:42-04:00 Session: Memoize stderrSupportsAnsiColors Not only is this a reasonable efficiency measure but it avoids making reentrant calls into ncurses, which is not thread-safe. See #17922. - - - - - 27740f24 by Ryan Scott at 2020-04-02T01:49:21-04:00 Make Hadrian build with Cabal-3.2 GHC 8.10 ships with `Cabal-3.2.0.0`, so it would be convenient to make Hadrian supporting building against 3.2.* instead of having to rebuild the entirety of `Cabal-3.0.0.0`. There is one API change in `Cabal-3.2.*` that affects Hadrian: the `synopsis` and `description` functions now return `ShortText` instead of `String`. Since Hadrian manipulates these `String`s in various places, I found that the simplest fix was to use CPP to convert `ShortText` to `String`s where appropriate. - - - - - 49802002 by Sylvain Henry at 2020-04-02T01:50:00-04:00 Update Stack resolver for hadrian/build-stack Broken by 57b888c0e90be7189285a6b078c30b26d0923809 - - - - - 30a63e79 by Ryan Scott at 2020-04-02T01:50:36-04:00 Fix two ASSERT buglets in reifyDataCon Two `ASSERT`s in `reifyDataCon` were always using `arg_tys`, but `arg_tys` is not meaningful for GADT constructors. In fact, it's worse than non-meaningful, since using `arg_tys` when reifying a GADT constructor can lead to failed `ASSERT`ions, as #17305 demonstrates. This patch applies the simplest possible fix to the immediate problem. The `ASSERT`s now use `r_arg_tys` instead of `arg_tys`, as the former makes sure to give something meaningful for GADT constructors. This makes the panic go away at the very least. There is still an underlying issue with the way the internals of `reifyDataCon` work, as described in https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227023, but we leave that as future work, since fixing the underlying issue is much trickier (see https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227087). - - - - - ef7576c4 by Zubin Duggal at 2020-04-03T06:24:56-04:00 Add outputable instances for the types in GHC.Iface.Ext.Types, add -ddump-hie flag to dump pretty printed contents of the .hie file Metric Increase: hie002 Because of the regression on i386: compile_time/bytes allocated increased from i386-linux-deb9 baseline @ HEAD~10: Expected hie002 (normal) compile_time/bytes allocated: 583014888.0 +/-10% Lower bound hie002 (normal) compile_time/bytes allocated: 524713399 Upper bound hie002 (normal) compile_time/bytes allocated: 641316377 Actual hie002 (normal) compile_time/bytes allocated: 877986292 Deviation hie002 (normal) compile_time/bytes allocated: 50.6 % *** unexpected stat test failure for hie002(normal) - - - - - 9462452a by Andreas Klebinger at 2020-04-03T06:25:33-04:00 Improve and refactor StgToCmm codegen for DataCons. We now differentiate three cases of constructor bindings: 1)Bindings which we can "replace" with a reference to an existing closure. Reference the replacement closure when accessing the binding. 2)Bindings which we can "replace" as above. But we still generate a closure which will be referenced by modules importing this binding. 3)For any other binding generate a closure. Then reference it. Before this patch 1) did only apply to local bindings and we didn't do 2) at all. - - - - - a214d214 by Moritz Bruder at 2020-04-03T06:26:11-04:00 Add singleton to NonEmpty in libraries/base This adds a definition to construct a singleton non-empty list (Data.List.NonEmpty) according to issue #17851. - - - - - f7597aa0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Testsuite: measure compiler stats for T16190 We were mistakenly measuring program stats - - - - - a485c3c4 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Move blob handling into StgToCmm Move handling of big literal strings from CmmToAsm to StgToCmm. It avoids the use of `sdocWithDynFlags` (cf #10143). We might need to move this handling even higher in the pipeline in the future (cf #17960): this patch will make it easier. - - - - - cc2918a0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Refactor CmmStatics In !2959 we noticed that there was some redundant code (in GHC.Cmm.Utils and GHC.Cmm.StgToCmm.Utils) used to deal with `CmmStatics` datatype (before SRT generation) and `RawCmmStatics` datatype (after SRT generation). This patch removes this redundant code by using a single GADT for (Raw)CmmStatics. - - - - - 9e60273d by Maxim Koltsov at 2020-04-03T06:27:32-04:00 Fix haddock formatting in Control.Monad.ST.Lazy.Imp.hs - - - - - 1b7e8a94 by Andreas Klebinger at 2020-04-03T06:28:08-04:00 Turn newlines into spaces for hadrian/ghci. The newlines break the command on windows. - - - - - 4291bdda by Simon Peyton Jones at 2020-04-03T06:28:44-04:00 Major improvements to the specialiser This patch is joint work of Alexis King and Simon PJ. It does some significant refactoring of the type-class specialiser. Main highlights: * We can specialise functions with types like f :: Eq a => a -> Ord b => b => blah where the classes aren't all at the front (#16473). Here we can correctly specialise 'f' based on a call like f @Int @Bool dEqInt x dOrdBool This change really happened in an earlier patch commit 2d0cf6252957b8980d89481ecd0b79891da4b14b Author: Sandy Maguire <sandy at sandymaguire.me> Date: Thu May 16 12:12:10 2019 -0400 work that this new patch builds directly on that work, and refactors it a bit. * We can specialise functions with implicit parameters (#17930) g :: (?foo :: Bool, Show a) => a -> String Previously we could not, but now they behave just like a non-class argument as in 'f' above. * We can specialise under-saturated calls, where some (but not all of the dictionary arguments are provided (#17966). For example, we can specialise the above 'f' based on a call map (f @Int dEqInt) xs even though we don't (and can't) give Ord dictionary. This may sound exotic, but #17966 is a program from the wild, and showed significant perf loss for functions like f, if you need saturation of all dictionaries. * We fix a buglet in which a floated dictionary had a bogus demand (#17810), by using zapIdDemandInfo in the NonRec case of specBind. * A tiny side benefit: we can drop dead arguments to specialised functions; see Note [Drop dead args from specialisations] * Fixed a bug in deciding what dictionaries are "interesting"; see Note [Keep the old dictionaries interesting] This is all achieved by by building on Sandy Macguire's work in defining SpecArg, which mkCallUDs uses to describe the arguments of the call. Main changes: * Main work is in specHeader, which marched down the [InBndr] from the function definition and the [SpecArg] from the call site, together. * specCalls no longer has an arity check; the entire mechanism now handles unders-saturated calls fine. * mkCallUDs decides on an argument-by-argument basis whether to specialise a particular dictionary argument; this is new. See mk_spec_arg in mkCallUDs. It looks as if there are many more lines of code, but I think that all the extra lines are comments! - - - - - 40a85563 by Ömer Sinan Ağacan at 2020-04-03T18:26:19+03:00 Revert accidental change in 9462452 [ci skip] - - - - - bd75e5da by Ryan Scott at 2020-04-04T07:07:58-04:00 Enable ImpredicativeTypes internally when typechecking selector bindings This is necessary for certain record selectors with higher-rank types, such as the examples in #18005. See `Note [Impredicative record selectors]` in `TcTyDecls`. Fixes #18005. - - - - - dcfe29c8 by Ömer Sinan Ağacan at 2020-04-06T13:16:08-04:00 Don't override proc CafInfos in ticky builds Fixes #17947 When we have a ticky label for a proc, IdLabels for the ticky counter and proc entry share the same Name. This caused overriding proc CafInfos with the ticky CafInfos (i.e. NoCafRefs) during SRT analysis. We now ignore the ticky labels when building SRTMaps. This makes sense because: - When building the current module they don't need to be in SRTMaps as they're initialized as non-CAFFY (see mkRednCountsLabel), so they don't take part in the dependency analysis and they're never added to SRTs. (Reminder: a "dependency" in the SRT analysis is a CAFFY dependency, non-CAFFY uses are not considered as dependencies for the algorithm) - They don't appear in the interfaces as they're not exported, so it doesn't matter for cross-module concerns whether they're in the SRTMap or not. See also the new Note [Ticky labels in SRT analysis]. - - - - - cec2c71f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Fix an tricky specialiser loop Issue #17151 was a very tricky example of a bug in which the specialiser accidentally constructs a recurive dictionary, so that everything turns into bottom. I have fixed variants of this bug at least twice before: see Note [Avoiding loops]. It was a bit of a struggle to isolate the problem, greatly aided by the work that Alexey Kuleshevich did in distilling a test case. Once I'd understood the problem, it was not difficult to fix, though it did lead me a bit of refactoring in specImports. - - - - - e850d14f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Refactoring only This refactors DictBinds into a data type rather than a pair. No change in behaviour, just better code - - - - - f38e8d61 by Daniel Gröber at 2020-04-07T02:00:05-04:00 rts: ProfHeap: Fix memory leak when not compiled with profiling If we're doing heap profiling on an unprofiled executable we keep allocating new space in initEra via nextEra on each profiler run but we don't have a corresponding freeEra call. We do free the last era in endHeapProfiling but previous eras will have been overwritten by initEra and will never get free()ed. Metric Decrease: space_leak_001 - - - - - bcd66859 by Sebastian Graf at 2020-04-07T02:00:41-04:00 Re-export GHC.Magic.noinline from base - - - - - 3d2991f8 by Ben Gamari at 2020-04-07T18:36:09-04:00 simplifier: Kill off ufKeenessFactor We used to have another factor, ufKeenessFactor, which would scale the discounts before they were subtracted from the size. This was justified with the following comment: -- We multiple the raw discounts (args_discount and result_discount) -- ty opt_UnfoldingKeenessFactor because the former have to do with -- *size* whereas the discounts imply that there's some extra -- *efficiency* to be gained (e.g. beta reductions, case reductions) -- by inlining. However, this is highly suspect since it means that we subtract a *scaled* size from an absolute size, resulting in crazy (e.g. negative) scores in some cases (#15304). We consequently killed off ufKeenessFactor and bumped up the ufUseThreshold to compensate. Adjustment of unfolding use threshold ===================================== Since this removes a discount from our inlining heuristic, I revisited our default choice of -funfolding-use-threshold to minimize the change in overall inlining behavior. Specifically, I measured runtime allocations and executable size of nofib and the testsuite performance tests built using compilers (and core libraries) built with several values of -funfolding-use-threshold. This comes as a result of a quantitative comparison of testsuite performance and code size as a function of ufUseThreshold, comparing GHC trees using values of 50, 60, 70, 80, 90, and 100. The test set consisted of nofib and the testsuite performance tests. A full summary of these measurements are found in the description of !2608 Comparing executable sizes (relative to the base commit) across all nofib tests, we see that sizes are similar to the baseline: gmean min max median thresh 50 -6.36% -7.04% -4.82% -6.46% 60 -5.04% -5.97% -3.83% -5.11% 70 -2.90% -3.84% -2.31% -2.92% 80 -0.75% -2.16% -0.42% -0.73% 90 +0.24% -0.41% +0.55% +0.26% 100 +1.36% +0.80% +1.64% +1.37% baseline +0.00% +0.00% +0.00% +0.00% Likewise, looking at runtime allocations we see that 80 gives slightly better optimisation than the baseline: gmean min max median thresh 50 +0.16% -0.16% +4.43% +0.00% 60 +0.09% -0.00% +3.10% +0.00% 70 +0.04% -0.09% +2.29% +0.00% 80 +0.02% -1.17% +2.29% +0.00% 90 -0.02% -2.59% +1.86% +0.00% 100 +0.00% -2.59% +7.51% -0.00% baseline +0.00% +0.00% +0.00% +0.00% Finally, I had to add a NOINLINE in T4306 to ensure that `upd` is worker-wrappered as the test expects. This makes me wonder whether the inlining heuristic is now too liberal as `upd` is quite a large function. The same measure was taken in T12600. Wall clock time compiling Cabal with -O0 thresh 50 60 70 80 90 100 baseline build-Cabal 93.88 89.58 92.59 90.09 100.26 94.81 89.13 Also, this change happens to avoid the spurious test output in `plugin-recomp-change` and `plugin-recomp-change-prof` (see #17308). Metric Decrease: hie002 T12234 T13035 T13719 T14683 T4801 T5631 T5642 T9020 T9872d T9961 Metric Increase: T12150 T12425 T13701 T14697 T15426 T1969 T3064 T5837 T6048 T9203 T9872a T9872b T9872c T9872d haddock.Cabal haddock.base haddock.compiler - - - - - 255418da by Sylvain Henry at 2020-04-07T18:36:49-04:00 Modules: type-checker (#13009) Update Haddock submodule - - - - - 04b6cf94 by Ryan Scott at 2020-04-07T19:43:20-04:00 Make NoExtCon fields strict This changes every unused TTG extension constructor to be strict in its field so that the pattern-match coverage checker is smart enough any such constructors are unreachable in pattern matches. This lets us remove nearly every use of `noExtCon` in the GHC API. The only ones we cannot remove are ones underneath uses of `ghcPass`, but that is only because GHC 8.8's and 8.10's coverage checkers weren't smart enough to perform this kind of reasoning. GHC HEAD's coverage checker, on the other hand, _is_ smart enough, so we guard these uses of `noExtCon` with CPP for now. Bumps the `haddock` submodule. Fixes #17992. - - - - - 7802fa17 by Ryan Scott at 2020-04-08T16:43:44-04:00 Handle promoted data constructors in typeToLHsType correctly Instead of using `nlHsTyVar`, which hardcodes `NotPromoted`, have `typeToLHsType` pick between `Promoted` and `NotPromoted` by checking if a type constructor is promoted using `isPromotedDataCon`. Fixes #18020. - - - - - ce481361 by Ben Gamari at 2020-04-09T16:17:21-04:00 hadrian: Use --export-dynamic when linking iserv As noticed in #17962, the make build system currently does this (see 3ce0e0ba) but the change was never ported to Hadrian. - - - - - fa66f143 by Ben Gamari at 2020-04-09T16:17:21-04:00 iserv: Don't pass --export-dynamic on FreeBSD This is definitely a hack but it's probably the best we can do for now. Hadrian does the right thing here by passing --export-dynamic only to the linker. - - - - - 39075176 by Ömer Sinan Ağacan at 2020-04-09T16:18:00-04:00 Fix CNF handling in compacting GC Fixes #17937 Previously compacting GC simply ignored CNFs. This is mostly fine as most (see "What about small compacts?" below) CNF objects don't have outgoing pointers, and are "large" (allocated in large blocks) and large objects are not moved or compacted. However if we do GC *during* sharing-preserving compaction then the CNF will have a hash table mapping objects that have been moved to the CNF to their location in the CNF, to be able to preserve sharing. This case is handled in the copying collector, in `scavenge_compact`, where we evacuate hash table entries and then rehash the table. Compacting GC ignored this case. We now visit CNFs in all generations when threading pointers to the compacted heap and thread hash table keys. A visited CNF is added to the list `nfdata_chain`. After compaction is done, we re-visit the CNFs in that list and rehash the tables. The overhead is minimal: the list is static in `Compact.c`, and link field is added to `StgCompactNFData` closure. Programs that don't use CNFs should not be affected. To test this CNF tests are now also run in a new way 'compacting_gc', which just passes `-c` to the RTS, enabling compacting GC for the oldest generation. Before this patch the result would be: Unexpected failures: compact_gc.run compact_gc [bad exit code (139)] (compacting_gc) compact_huge_array.run compact_huge_array [bad exit code (1)] (compacting_gc) With this patch all tests pass. I can also pass `-c -DS` without any failures. What about small compacts? Small CNFs are still not handled by the compacting GC. However so far I'm unable to write a test that triggers a runtime panic ("update_fwd: unknown/strange object") by allocating a small CNF in a compated heap. It's possible that I'm missing something and it's not possible to have a small CNF. NoFib Results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS +0.1% 0.0% 0.0% +0.0% +0.0% CSD +0.1% 0.0% 0.0% 0.0% 0.0% FS +0.1% 0.0% 0.0% 0.0% 0.0% S +0.1% 0.0% 0.0% 0.0% 0.0% VS +0.1% 0.0% 0.0% 0.0% 0.0% VSD +0.1% 0.0% +0.0% +0.0% -0.0% VSM +0.1% 0.0% +0.0% -0.0% 0.0% anna +0.0% 0.0% -0.0% -0.0% -0.0% ansi +0.1% 0.0% +0.0% +0.0% +0.0% atom +0.1% 0.0% +0.0% +0.0% +0.0% awards +0.1% 0.0% +0.0% +0.0% +0.0% banner +0.1% 0.0% +0.0% +0.0% +0.0% bernouilli +0.1% 0.0% 0.0% -0.0% +0.0% binary-trees +0.1% 0.0% -0.0% -0.0% 0.0% boyer +0.1% 0.0% +0.0% +0.0% +0.0% boyer2 +0.1% 0.0% +0.0% +0.0% +0.0% bspt +0.1% 0.0% -0.0% -0.0% -0.0% cacheprof +0.1% 0.0% -0.0% -0.0% -0.0% calendar +0.1% 0.0% +0.0% +0.0% +0.0% cichelli +0.1% 0.0% +0.0% +0.0% +0.0% circsim +0.1% 0.0% +0.0% +0.0% +0.0% clausify +0.1% 0.0% -0.0% +0.0% +0.0% comp_lab_zift +0.1% 0.0% +0.0% +0.0% +0.0% compress +0.1% 0.0% +0.0% +0.0% 0.0% compress2 +0.1% 0.0% -0.0% 0.0% 0.0% constraints +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm1 +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm2 +0.1% 0.0% +0.0% +0.0% +0.0% cse +0.1% 0.0% +0.0% +0.0% +0.0% digits-of-e1 +0.1% 0.0% +0.0% -0.0% -0.0% digits-of-e2 +0.1% 0.0% -0.0% -0.0% -0.0% dom-lt +0.1% 0.0% +0.0% +0.0% +0.0% eliza +0.1% 0.0% +0.0% +0.0% +0.0% event +0.1% 0.0% +0.0% +0.0% +0.0% exact-reals +0.1% 0.0% +0.0% +0.0% +0.0% exp3_8 +0.1% 0.0% +0.0% -0.0% 0.0% expert +0.1% 0.0% +0.0% +0.0% +0.0% fannkuch-redux +0.1% 0.0% -0.0% 0.0% 0.0% fasta +0.1% 0.0% -0.0% +0.0% +0.0% fem +0.1% 0.0% -0.0% +0.0% 0.0% fft +0.1% 0.0% -0.0% +0.0% +0.0% fft2 +0.1% 0.0% +0.0% +0.0% +0.0% fibheaps +0.1% 0.0% +0.0% +0.0% +0.0% fish +0.1% 0.0% +0.0% +0.0% +0.0% fluid +0.0% 0.0% +0.0% +0.0% +0.0% fulsom +0.1% 0.0% -0.0% +0.0% 0.0% gamteb +0.1% 0.0% +0.0% +0.0% 0.0% gcd +0.1% 0.0% +0.0% +0.0% +0.0% gen_regexps +0.1% 0.0% -0.0% +0.0% 0.0% genfft +0.1% 0.0% +0.0% +0.0% +0.0% gg +0.1% 0.0% 0.0% +0.0% +0.0% grep +0.1% 0.0% -0.0% +0.0% +0.0% hidden +0.1% 0.0% +0.0% -0.0% 0.0% hpg +0.1% 0.0% -0.0% -0.0% -0.0% ida +0.1% 0.0% +0.0% +0.0% +0.0% infer +0.1% 0.0% +0.0% 0.0% -0.0% integer +0.1% 0.0% +0.0% +0.0% +0.0% integrate +0.1% 0.0% -0.0% -0.0% -0.0% k-nucleotide +0.1% 0.0% +0.0% +0.0% 0.0% kahan +0.1% 0.0% +0.0% +0.0% +0.0% knights +0.1% 0.0% -0.0% -0.0% -0.0% lambda +0.1% 0.0% +0.0% +0.0% -0.0% last-piece +0.1% 0.0% +0.0% 0.0% 0.0% lcss +0.1% 0.0% +0.0% +0.0% 0.0% life +0.1% 0.0% -0.0% +0.0% +0.0% lift +0.1% 0.0% +0.0% +0.0% +0.0% linear +0.1% 0.0% -0.0% +0.0% 0.0% listcompr +0.1% 0.0% +0.0% +0.0% +0.0% listcopy +0.1% 0.0% +0.0% +0.0% +0.0% maillist +0.1% 0.0% +0.0% -0.0% -0.0% mandel +0.1% 0.0% +0.0% +0.0% 0.0% mandel2 +0.1% 0.0% +0.0% +0.0% +0.0% mate +0.1% 0.0% +0.0% 0.0% +0.0% minimax +0.1% 0.0% -0.0% 0.0% -0.0% mkhprog +0.1% 0.0% +0.0% +0.0% +0.0% multiplier +0.1% 0.0% +0.0% 0.0% 0.0% n-body +0.1% 0.0% +0.0% +0.0% +0.0% nucleic2 +0.1% 0.0% +0.0% +0.0% +0.0% para +0.1% 0.0% 0.0% +0.0% +0.0% paraffins +0.1% 0.0% +0.0% -0.0% 0.0% parser +0.1% 0.0% -0.0% -0.0% -0.0% parstof +0.1% 0.0% +0.0% +0.0% +0.0% pic +0.1% 0.0% -0.0% -0.0% 0.0% pidigits +0.1% 0.0% +0.0% -0.0% -0.0% power +0.1% 0.0% +0.0% +0.0% +0.0% pretty +0.1% 0.0% -0.0% -0.0% -0.1% primes +0.1% 0.0% -0.0% -0.0% -0.0% primetest +0.1% 0.0% -0.0% -0.0% -0.0% prolog +0.1% 0.0% -0.0% -0.0% -0.0% puzzle +0.1% 0.0% -0.0% -0.0% -0.0% queens +0.1% 0.0% +0.0% +0.0% +0.0% reptile +0.1% 0.0% -0.0% -0.0% +0.0% reverse-complem +0.1% 0.0% +0.0% 0.0% -0.0% rewrite +0.1% 0.0% -0.0% -0.0% -0.0% rfib +0.1% 0.0% +0.0% +0.0% +0.0% rsa +0.1% 0.0% -0.0% +0.0% -0.0% scc +0.1% 0.0% -0.0% -0.0% -0.1% sched +0.1% 0.0% +0.0% +0.0% +0.0% scs +0.1% 0.0% +0.0% +0.0% +0.0% simple +0.1% 0.0% -0.0% -0.0% -0.0% solid +0.1% 0.0% +0.0% +0.0% +0.0% sorting +0.1% 0.0% -0.0% -0.0% -0.0% spectral-norm +0.1% 0.0% +0.0% +0.0% +0.0% sphere +0.1% 0.0% -0.0% -0.0% -0.0% symalg +0.1% 0.0% -0.0% -0.0% -0.0% tak +0.1% 0.0% +0.0% +0.0% +0.0% transform +0.1% 0.0% +0.0% +0.0% +0.0% treejoin +0.1% 0.0% +0.0% -0.0% -0.0% typecheck +0.1% 0.0% +0.0% +0.0% +0.0% veritas +0.0% 0.0% +0.0% +0.0% +0.0% wang +0.1% 0.0% 0.0% +0.0% +0.0% wave4main +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve1 +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve2 +0.1% 0.0% +0.0% +0.0% +0.0% x2n1 +0.1% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -0.0% -0.1% Max +0.1% 0.0% +0.0% +0.0% +0.0% Geometric Mean +0.1% -0.0% -0.0% -0.0% -0.0% Bumping numbers of nonsensical perf tests: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 It's simply not possible for this patch to increase allocations, and I've wasted enough time on these test in the past (see #17686). I think these tests should not be perf tests, but for now I'll bump the numbers. - - - - - dce50062 by Sylvain Henry at 2020-04-09T16:18:44-04:00 Rts: show errno on failure (#18033) - - - - - 045139f4 by Hécate at 2020-04-09T23:10:44-04:00 Add an example to liftIO and explain its purpose - - - - - 101fab6e by Sebastian Graf at 2020-04-09T23:11:21-04:00 Special case `isConstraintKindCon` on `AlgTyCon` Previously, the `tyConUnique` record selector would unfold into a huge case expression that would be inlined in all call sites, such as the `INLINE`-annotated `coreView`, see #18026. `constraintKindTyConKey` only occurs as the `Unique` of an `AlgTyCon` anyway, so we can make the code a lot more compact, but have to move it to GHC.Core.TyCon. Metric Decrease: T12150 T12234 - - - - - f5212dfc by Sebastian Graf at 2020-04-09T23:11:57-04:00 DmdAnal: No need to attach a StrictSig to DataCon workers In GHC.Types.Id.Make we were giving a strictness signature to every data constructor wrapper Id that we weren't looking at in demand analysis anyway. We used to use its CPR info, but that has its own CPR signature now. `Note [Data-con worker strictness]` then felt very out of place, so I moved it to GHC.Core.DataCon. - - - - - 75a185dc by Sylvain Henry at 2020-04-09T23:12:37-04:00 Hadrian: fix --summary - - - - - 723062ed by Ömer Sinan Ağacan at 2020-04-10T09:18:14+03:00 testsuite: Move no_lint to the top level, tweak hie002 - We don't want to benchmark linting so disable lints in hie002 perf test - Move no_lint to the top-level to be able to use it in tests other than those in `testsuite/tests/perf/compiler`. - Filter out -dstg-lint in no_lint. - hie002 allocation numbers on 32-bit are unstable, so skip it on 32-bit Metric Decrease: hie002 ManyConstructors T12150 T12234 T13035 T1969 T4801 T9233 T9961 - - - - - bcafaa82 by Peter Trommler at 2020-04-10T19:29:33-04:00 Testsuite: mark T11531 fragile The test depends on a link editor allowing undefined symbols in an ELF shared object. This is the standard but it seems some distributions patch their link editor. See the report by @hsyl20 in #11531. Fixes #11531 - - - - - 0889f5ee by Takenobu Tani at 2020-04-12T11:44:52+09:00 testsuite: Fix comment for a language extension [skip ci] - - - - - cd4f92b5 by Simon Peyton Jones at 2020-04-12T11:20:58-04:00 Significant refactor of Lint This refactoring of Lint was triggered by #17923, which is fixed by this patch. The main change is this. Instead of lintType :: Type -> LintM LintedKind we now have lintType :: Type -> LintM LintedType Previously, all of typeKind was effectively duplicate in lintType. Moreover, since we have an ambient substitution, we still had to apply the substition here and there, sometimes more than once. It was all very tricky, in the end, and made my head hurt. Now, lintType returns a fully linted type, with all substitutions performed on it. This is much simpler. The same thing is needed for Coercions. Instead of lintCoercion :: OutCoercion -> LintM (LintedKind, LintedKind, LintedType, LintedType, Role) we now have lintCoercion :: Coercion -> LintM LintedCoercion Much simpler! The code is shorter and less bug-prone. There are a lot of knock on effects. But life is now better. Metric Decrease: T1969 - - - - - 0efaf301 by Josh Meredith at 2020-04-12T11:21:34-04:00 Implement extensible interface files - - - - - 54ca66a7 by Ryan Scott at 2020-04-12T11:22:10-04:00 Use conLikeUserTyVarBinders to quantify field selector types This patch: 1. Writes up a specification for how the types of top-level field selectors should be determined in a new section of the GHC User's Guide, and 2. Makes GHC actually implement that specification by using `conLikeUserTyVarBinders` in `mkOneRecordSelector` to preserve the order and specificity of type variables written by the user. Fixes #18023. - - - - - 35799dda by Ben Gamari at 2020-04-12T11:22:50-04:00 hadrian: Don't --export-dynamic on Darwin When fixing #17962 I neglected to consider that --export-dynamic is only supported on ELF platforms. - - - - - e8029816 by Alexis King at 2020-04-12T11:23:27-04:00 Add an INLINE pragma to Control.Category.>>> This fixes #18013 by adding INLINE pragmas to both Control.Category.>>> and GHC.Desugar.>>>. The functional change in this patch is tiny (just two lines of pragmas!), but an accompanying Note explains in gory detail what’s going on. - - - - - 0da186c1 by Krzysztof Gogolewski at 2020-04-14T07:55:20-04:00 Change zipWith to zipWithEqual in a few places - - - - - 074c1ccd by Andreas Klebinger at 2020-04-14T07:55:55-04:00 Small change to the windows ticker. We already have a function to go from time to ms so use it. Also expand on the state of timer resolution. - - - - - b69cc884 by Alp Mestanogullari at 2020-04-14T07:56:38-04:00 hadrian: get rid of unnecessary levels of nesting in source-dist - - - - - d0c3b069 by Julien Debon at 2020-04-14T07:57:16-04:00 doc (Foldable): Add examples to Data.Foldable See #17929 - - - - - 5b08e0c0 by Ben Gamari at 2020-04-14T23:28:20-04:00 StgCRun: Enable unwinding only on Linux It's broken on macOS due and SmartOS due to assembler differences (#15207) so let's be conservative in enabling it. Also, refactor things to make the intent clearer. - - - - - 27cc2e7b by Ben Gamari at 2020-04-14T23:28:57-04:00 rts: Don't mark evacuate_large as inline This function has two callsites and is quite large. GCC consequently decides not to inline and warns instead. Given the situation, I can't blame it. Let's just remove the inline specifier. - - - - - 9853fc5e by Ben Gamari at 2020-04-14T23:29:48-04:00 base: Enable large file support for OFD locking impl. Not only is this a good idea in general but this should also avoid issue #17950 by ensuring that off_t is 64-bits. - - - - - 7b41f21b by Matthew Pickering at 2020-04-14T23:30:24-04:00 Hadrian: Make -i paths absolute The primary reason for this change is that ghcide does not work with relative paths. It also matches what cabal and stack do, they always pass absolute paths. - - - - - 41230e26 by Daniel Gröber at 2020-04-14T23:31:01-04:00 Zero out pinned block alignment slop when profiling The heap profiler currently cannot traverse pinned blocks because of alignment slop. This used to just be a minor annoyance as the whole block is accounted into a special cost center rather than the respective object's CCS, cf. #7275. However for the new root profiler we would like to be able to visit _every_ closure on the heap. We need to do this so we can get rid of the current 'flip' bit hack in the heap traversal code. Since info pointers are always non-zero we can in principle skip all the slop in the profiler if we can rely on it being zeroed. This assumption caused problems in the past though, commit a586b33f8e ("rts: Correct handling of LARGE ARR_WORDS in LDV profiler"), part of !1118, tried to use the same trick for BF_LARGE objects but neglected to take into account that shrink*Array# functions don't ensure that slop is zeroed when not compiling with profiling. Later, commit 0c114c6599 ("Handle large ARR_WORDS in heap census (fix as we will only be assuming slop is zeroed when profiling is on. This commit also reduces the ammount of slop we introduce in the first place by calculating the needed alignment before doing the allocation for small objects where we know the next available address. For large objects we don't know how much alignment we'll have to do yet since those details are hidden behind the allocateMightFail function so there we continue to allocate the maximum additional words we'll need to do the alignment. So we don't have to duplicate all this logic in the cmm code we pull it into the RTS allocatePinned function instead. Metric Decrease: T7257 haddock.Cabal haddock.base - - - - - 15fa9bd6 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Expand and add more notes regarding slop - - - - - caf3f444 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: allocatePinned: Fix confusion about word/byte units - - - - - c3c0f662 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Underline some Notes as is conventional - - - - - e149dea9 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Fix nomenclature in OVERWRITING_CLOSURE macros The additional commentary introduced by commit 8916e64e5437 ("Implement shrinkSmallMutableArray# and resizeSmallMutableArray#.") unfortunately got this wrong. We set 'prim' to true in overwritingClosureOfs because we _don't_ want to call LDV_recordDead(). The reason is because of this "inherently used" distinction made in the LDV profiler so I rename the variable to be more appropriate. - - - - - 1dd3d18c by Daniel Gröber at 2020-04-14T23:31:38-04:00 Remove call to LDV_RECORD_CREATE for array resizing - - - - - 19de2fb0 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Assert LDV_recordDead is not called for inherently used closures The comments make it clear LDV_recordDead should not be called for inhererently used closures, so add an assertion to codify this fact. - - - - - 0b934e30 by Ryan Scott at 2020-04-14T23:32:14-04:00 Bump template-haskell version to 2.17.0.0 This requires bumping the `exceptions` and `text` submodules to bring in commits that bump their respective upper version bounds on `template-haskell`. Fixes #17645. Fixes #17696. Note that the new `text` commit includes a fair number of additions to the Haddocks in that library. As a result, Haddock has to do more work during the `haddock.Cabal` test case, increasing the number of allocations it requires. Therefore, ------------------------- Metric Increase: haddock.Cabal ------------------------- - - - - - 22cc8e51 by Ryan Scott at 2020-04-15T17:48:47-04:00 Fix #18052 by using pprPrefixOcc in more places This fixes several small oversights in the choice of pretty-printing function to use. Fixes #18052. - - - - - ec77b2f1 by Daniel Gröber at 2020-04-15T17:49:24-04:00 rts: ProfHeap: Fix wrong time in last heap profile sample We've had this longstanding issue in the heap profiler, where the time of the last sample in the profile is sometimes way off causing the rendered graph to be quite useless for long runs. It seems to me the problem is that we use mut_user_time() for the last sample as opposed to getRTSStats(), which we use when calling heapProfile() in GC.c. The former is equivalent to getProcessCPUTime() but the latter does some additional stuff: getProcessCPUTime() - end_init_cpu - stats.gc_cpu_ns - stats.nonmoving_gc_cpu_ns So to fix this just use getRTSStats() in both places. - - - - - 85fc32f0 by Sylvain Henry at 2020-04-17T12:45:25-04:00 Hadrian: fix dyn_o/dyn_hi rule (#17534) - - - - - bfde3b76 by Ryan Scott at 2020-04-17T12:46:02-04:00 Fix #18065 by fixing an InstCo oversight in Core Lint There was a small thinko in Core Lint's treatment of `InstCo` coercions that ultimately led to #18065. The fix: add an apostrophe. That's it! Fixes #18065. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> - - - - - a05348eb by Cale Gibbard at 2020-04-17T13:08:47-04:00 Change the fail operator argument of BindStmt to be a Maybe Don't use noSyntaxExpr for it. There is no good way to defensively case on that, nor is it clear one ought to do so. - - - - - 79e27144 by John Ericson at 2020-04-17T13:08:47-04:00 Use trees that grow for rebindable operators for `<-` binds Also add more documentation. - - - - - 18bc16ed by Cale Gibbard at 2020-04-17T13:08:47-04:00 Use FailOperator in more places, define a couple datatypes (XBindStmtRn and XBindStmtTc) to help clarify the meaning of XBindStmt in the renamer and typechecker - - - - - 84cc8394 by Simon Peyton Jones at 2020-04-18T13:20:29-04:00 Add a missing zonk in tcHsPartialType I omitted a vital zonk when refactoring tcHsPartialType in commit 48fb3482f8cbc8a4b37161021e846105f980eed4 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Wed Jun 5 08:55:17 2019 +0100 Fix typechecking of partial type signatures This patch fixes it and adds commentary to explain why. Fixes #18008 - - - - - 2ee96ac1 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Bump FreeBSD bootstrap compiler to 8.10.1 - - - - - 434312e5 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Enable FreeBSD job for so-labelled MRs - - - - - ddffb227 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Use rules syntax for conditional jobs - - - - - e2586828 by Ben Gamari at 2020-04-18T13:21:05-04:00 Bump hsc2hs submodule - - - - - 15ab6cd5 by Ömer Sinan Ağacan at 2020-04-18T13:21:44-04:00 Improve prepForeignCall error reporting Show parameters and description of the error code when ffi_prep_cif fails. This may be helpful for debugging #17018. - - - - - 3ca52151 by Sylvain Henry at 2020-04-18T20:04:14+02:00 GHC.Core.Opt renaming * GHC.Core.Op => GHC.Core.Opt * GHC.Core.Opt.Simplify.Driver => GHC.Core.Opt.Driver * GHC.Core.Opt.Tidy => GHC.Core.Tidy * GHC.Core.Opt.WorkWrap.Lib => GHC.Core.Opt.WorkWrap.Utils As discussed in: * https://mail.haskell.org/pipermail/ghc-devs/2020-April/018758.html * https://gitlab.haskell.org/ghc/ghc/issues/13009#note_264650 - - - - - 15312bbb by Sylvain Henry at 2020-04-18T20:04:46+02:00 Modules (#13009) * SysTools * Parser * GHC.Builtin * GHC.Iface.Recomp * Settings Update Haddock submodule Metric Decrease: Naperian parsing001 - - - - - eaed0a32 by Alexis King at 2020-04-19T03:16:44-04:00 Add missing addInScope call for letrec binders in OccurAnal This fixes #18044, where a shadowed variable was incorrectly substituted by the binder swap on the RHS of a floated-in letrec. This can only happen when the uniques line up *just* right, so writing a regression test would be very difficult, but at least the fix is small and straightforward. - - - - - 36882493 by Shayne Fletcher at 2020-04-20T04:36:43-04:00 Derive Ord instance for Extension Metric Increase: T12150 T12234 - - - - - b43365ad by Simon Peyton Jones at 2020-04-20T04:37:20-04:00 Fix a buglet in redundant-constraint warnings Ticket #18036 pointed out that we were reporting a redundant constraint when it really really wasn't. Turned out to be a buglet in the SkolemInfo for the relevant implication constraint. Easily fixed! - - - - - d5fae7da by Ömer Sinan Ağacan at 2020-04-20T14:39:28-04:00 Mark T12010 fragile on 32-bit - - - - - bca02fca by Adam Sandberg Ericsson at 2020-04-21T06:38:45-04:00 docs: drop note about not supporting shared libraries on unix systems [skip ci] - - - - - 6655f933 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Use ParserFlags in GHC.Runtime.Eval (#17957) Instead of passing `DynFlags` to functions such as `isStmt` and `hasImport` in `GHC.Runtime.Eval` we pass `ParserFlags`. It's a much simpler structure that can be created purely with `mkParserFlags'`. - - - - - 70be0fbc by Sylvain Henry at 2020-04-21T06:39:32-04:00 GHC.Runtime: avoid DynFlags (#17957) * add `getPlatform :: TcM Platform` helper * remove unused `DynFlags` parameter from `emptyPLS` - - - - - 35e43d48 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid DynFlags in Ppr code (#17957) * replace `DynFlags` parameters with `SDocContext` parameters for a few Ppr related functions: `bufLeftRenderSDoc`, `printSDoc`, `printSDocLn`, `showSDocOneLine`. * remove the use of `pprCols :: DynFlags -> Int` in Outputable. We already have the information via `sdocLineLength :: SDocContext -> Int` - - - - - ce5c2999 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid using sdocWithDynFlags (#17957) Remove one use of `sdocWithDynFlags` from `GHC.CmmToLlvm.llvmCodeGen'` and from `GHC.Driver.CodeOutput.profilingInitCode` - - - - - f2a98996 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid `sdocWithDynFlags` in `pprCLbl` (#17957) * add a `DynFlags` parameter to `pprCLbl` * put `maybe_underscore` and `pprAsmCLbl` in a `where` clause to avoid `DynFlags` parameters - - - - - 747093b7 by Sylvain Henry at 2020-04-21T06:39:32-04:00 CmmToAsm DynFlags refactoring (#17957) * Remove `DynFlags` parameter from `isDynLinkName`: `isDynLinkName` used to test the global `ExternalDynamicRefs` flag. Now we test it outside of `isDynLinkName` * Add new fields into `NCGConfig`: current unit id, sse/bmi versions, externalDynamicRefs, etc. * Replace many uses of `DynFlags` by `NCGConfig` * Moved `BMI/SSE` datatypes into `GHC.Platform` - - - - - ffd7eef2 by Takenobu Tani at 2020-04-22T23:09:50-04:00 stg-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Stg/Syntax.hs <= stgSyn/StgSyn.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/CostCentre.hs <= profiling/CostCentre.hs This patch also updates old file path [2]: * utils/genapply/Main.hs <= utils/genapply/GenApply.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: commit 0cc4aad36f [skip ci] - - - - - e8a5d81b by Jonathan DK Gibbons at 2020-04-22T23:10:28-04:00 Refactor the `MatchResult` type in the desugarer This way, it does a better job of proving whether or not the fail operator is used. - - - - - dcb7fe5a by John Ericson at 2020-04-22T23:10:28-04:00 Remove panic in dsHandleMonadicFailure Rework dsHandleMonadicFailure to be correct by construction instead of using an unreachable panic. - - - - - cde23cd4 by John Ericson at 2020-04-22T23:10:28-04:00 Inline `adjustMatchResult` It is just `fmap` - - - - - 72cb6bcc by John Ericson at 2020-04-22T23:10:28-04:00 Generalize type of `matchCanFail` - - - - - 401f7bb3 by John Ericson at 2020-04-22T23:10:28-04:00 `MatchResult'` -> `MatchResult` Inline `MatchResult` alias accordingly. - - - - - 6c9fae23 by Alexis King at 2020-04-22T23:11:12-04:00 Mark DataCon wrappers CONLIKE Now that DataCon wrappers don’t inline until phase 0 (see commit b78cc64e923716ac0512c299f42d4d0012306c05), it’s important that case-of-known-constructor and RULE matching be able to see saturated applications of DataCon wrappers in unfoldings. Making them conlike is a natural way to do it, since they are, in fact, precisely the sort of thing the CONLIKE pragma exists to solve. Fixes #18012. This also bumps the version of the parsec submodule to incorporate a patch that avoids a metric increase on the haddock perf tests. The increase was not really a flaw in this patch, as parsec was implicitly relying on inlining heuristics. The patch to parsec just adds some INLINABLE pragmas, and we get a nice performance bump out of it (well beyond the performance we lost from this patch). Metric Decrease: T12234 WWRec haddock.Cabal haddock.base haddock.compiler - - - - - 48b8951e by Roland Senn at 2020-04-22T23:11:51-04:00 Fix tab-completion for :break (#17989) In tab-completion for the `:break` command, only those identifiers should be shown, that are accepted in the `:break` command. Hence these identifiers must be - defined in an interpreted module - top-level - currently in scope - listed in a `ModBreaks` value as a possible breakpoint. The identifiers my be qualified or unqualified. To get all possible top-level breakpoints for tab-completeion with the correct qualification do: 1. Build the list called `pifsBreaks` of all pairs of (Identifier, module-filename) from the `ModBreaks` values. Here all identifiers are unqualified. 2. Build the list called `pifInscope` of all pairs of (Identifiers, module-filename) with identifiers from the `GlobalRdrEnv`. Take only those identifiers that are in scope and have the correct prefix. Here the identifiers may be qualified. 3. From the `pifInscope` list seclect all pairs that can be found in the `pifsBreaks` list, by comparing only the unqualified part of the identifier. The remaining identifiers can be used for tab-completion. This ensures, that we show only identifiers, that can be used in a `:break` command. - - - - - 34a45ee6 by Peter Trommler at 2020-04-22T23:12:27-04:00 PPC NCG: Add DWARF constants and debug labels Fixes #11261 - - - - - ffde2348 by Simon Peyton Jones at 2020-04-22T23:13:06-04:00 Do eager instantation in terms This patch implements eager instantiation, a small but critical change to the type inference engine, #17173. The main change is this: When inferring types, always return an instantiated type (for now, deeply instantiated; in future shallowly instantiated) There is more discussion in https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html There is quite a bit of refactoring in this patch: * The ir_inst field of GHC.Tc.Utils.TcType.InferResultk has entirely gone. So tcInferInst and tcInferNoInst have collapsed into tcInfer. * Type inference of applications, via tcInferApp and tcInferAppHead, are substantially refactored, preparing the way for Quick Look impredicativity. * New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs are beatifully dual. We can see the zipper! * GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return a wrapper * In HsExpr, HsTypeApp now contains the the actual type argument, and is used in desugaring, rather than putting it in a mysterious wrapper. * I struggled a bit with good error reporting in Unify.matchActualFunTysPart. It's a little bit simpler than before, but still not great. Some smaller things * Rename tcPolyExpr --> tcCheckExpr tcMonoExpr --> tcLExpr * tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat Metric Decrease: T9961 Reduction of 1.6% in comiler allocation on T9961, I think. - - - - - 6f84aca3 by Ben Gamari at 2020-04-22T23:13:43-04:00 rts: Ensure that sigaction structs are initialized I noticed these may have uninitialized fields when looking into #18037. The reporter says that zeroing them doesn't fix the MSAN failures they observe but zeroing them is the right thing to do regardless. - - - - - c29f0fa6 by Andreas Klebinger at 2020-04-22T23:14:21-04:00 Add "ddump-cmm-opt" as alias for "ddump-opt-cmm". - - - - - 4b4a8b60 by Ben Gamari at 2020-04-22T23:14:57-04:00 llvmGen: Remove -fast-llvm flag Issue #18076 drew my attention to the undocumented `-fast-llvm` flag for the LLVM code generator introduced in 22733532171330136d87533d523f565f2a4f102f. Speaking to Moritz about this, the motivation for this flag was to avoid potential incompatibilities between LLVM and the assembler/linker toolchain by making LLVM responsible for machine-code generation. Unfortunately, this cannot possibly work: the LLVM backend's mangler performs a number of transforms on the assembler generated by LLVM that are necessary for correctness. These are currently: * mangling Haskell functions' symbol types to be `object` instead of `function` on ELF platforms (necessary for tables-next-to-code) * mangling AVX instructions to ensure that we don't assume alignment (which LLVM otherwise does) * mangling Darwin's subsections-via-symbols directives Given that these are all necessary I don't believe that we can support `-fast-llvm`. Let's rather remove it. - - - - - 831b6642 by Moritz Angermann at 2020-04-22T23:15:33-04:00 Fix build warning; add more informative information to the linker; fix linker for empty sections - - - - - c409961a by Ryan Scott at 2020-04-22T23:16:12-04:00 Update commentary and slightly refactor GHC.Tc.Deriv.Infer There was some out-of-date commentary in `GHC.Tc.Deriv.Infer` that has been modernized. Along the way, I removed the `bad` constraints in `simplifyDeriv`, which did not serve any useful purpose (besides being printed in debugging output). Fixes #18073. - - - - - 125aa2b8 by Ömer Sinan Ağacan at 2020-04-22T23:16:51-04:00 Remove leftover comment in tcRnModule', redundant bind The code for the comment was moved in dc8c03b2a5c but the comment was forgotten. - - - - - 8ea37b01 by Sylvain Henry at 2020-04-22T23:17:34-04:00 RTS: workaround a Linux kernel bug in timerfd Reading a timerfd may return 0: https://lkml.org/lkml/2019/8/16/335. This is currently undocumented behavior and documentation "won't happen anytime soon" (https://lkml.org/lkml/2020/2/13/295). With this patch, we just ignore the result instead of crashing. It may fix #18033 but we can't be sure because we don't have enough information. See also this discussion about the kernel bug: https://github.com/Azure/sonic-swss-common/pull/302/files/1f070e7920c2e5d63316c0105bf4481e73d72dc9 - - - - - cd8409c2 by Ryan Scott at 2020-04-23T11:39:24-04:00 Create di_scoped_tvs for associated data family instances properly See `Note [Associated data family instances and di_scoped_tvs]` in `GHC.Tc.TyCl.Instance`, which explains all of the moving parts. Fixes #18055. - - - - - 339e8ece by Ben Gamari at 2020-04-23T11:40:02-04:00 hadrian/ghci: Allow arguments to be passed to GHCi Previously the arguments passed to hadrian/ghci were passed both to `hadrian` and GHCi. This is rather odd given that there are essentially not arguments in the intersection of the two. Let's just pass them to GHCi; this allows `hadrian/ghci -Werror`. - - - - - 5946c85a by Ben Gamari at 2020-04-23T11:40:38-04:00 testsuite: Don't attempt to read .std{err,out} files if they don't exist Simon reports that he was previously seeing framework failures due to an attempt to read the non-existing T13456.stderr. While I don't know exactly what this is due to, it does seem like a non-existing .std{out,err} file should be equivalent to an empty file. Teach the testsuite driver to treat it as such. - - - - - c42754d5 by John Ericson at 2020-04-23T18:32:43-04:00 Trees That Grow refactor for `ConPat` and `CoPat` - `ConPat{In,Out}` -> `ConPat` - `CoPat` -> `XPat (CoPat ..)` Note that `GHC.HS.*` still uses `HsWrap`, but only when `p ~ GhcTc`. After this change, moving the type family instances out of `GHC.HS.*` is sufficient to break the cycle. Add XCollectPat class to decide how binders are collected from XXPat based on the pass. Previously we did this with IsPass, but that doesn't work for Haddock's DocNameI, and the constraint doesn't express what actual distinction is being made. Perhaps a class for collecting binders more generally is in order, but we haven't attempted this yet. Pure refactor of code around ConPat - InPat/OutPat synonyms removed - rename several identifiers - redundant constraints removed - move extension field in ConPat to be first - make ConPat use record syntax more consistently Fix T6145 (ConPatIn became ConPat) Add comments from SPJ. Add comment about haddock's use of CollectPass. Updates haddock submodule. - - - - - 72da0c29 by mniip at 2020-04-23T18:33:21-04:00 Add :doc to GHC.Prim - - - - - 2c23e2e3 by mniip at 2020-04-23T18:33:21-04:00 Include docs for non-primop entries in primops.txt as well - - - - - 0ac29c88 by mniip at 2020-04-23T18:33:21-04:00 GHC.Prim docs: note and test - - - - - b0fbfc75 by John Ericson at 2020-04-24T12:07:14-04:00 Switch order on `GhcMake.IsBoot` In !1798 we were requested to replace many `Bool`s with this data type. But those bools had `False` meaning `NotBoot`, so the `Ord` instance would be flipped if we use this data-type as-is. Since the planned formally-`Bool` occurrences vastly outnumber the current occurrences, we figured it would be better to conform the `Ord` instance to how the `Bool` is used now, fixing any issues, rather than fix them currently with the bigger refactor later in !1798. That way, !1798 can be a "pure" refactor with no behavioral changes. - - - - - af332442 by Sylvain Henry at 2020-04-26T13:55:14-04:00 Modules: Utils and Data (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - cd4434c8 by Sylvain Henry at 2020-04-26T13:55:16-04:00 Fix misleading Ptr phantom type in SerializedCompact (#15653) - - - - - 22bf5c73 by Ömer Sinan Ağacan at 2020-04-26T13:55:22-04:00 Tweak includes in non-moving GC headers We don't use hash tables in non-moving GC so remove the includes. This breaks Compact.c as existing includes no longer include Hash.h, so include Hash.h explicitly in Compact.c. - - - - - 99823ed2 by Sylvain Henry at 2020-04-27T20:24:46-04:00 TH: fix Show/Eq/Ord instances for Bytes (#16457) We shouldn't compare pointer values but the actual bytes. - - - - - c62271a2 by Alp Mestanogullari at 2020-04-27T20:25:33-04:00 hadrian: always capture both stdout and stderr when running a builder fails The idea being that when a builder('s command) fails, we quite likely want to have all the information available to figure out why. Depending on the builder _and_ the particular problem, the useful bits of information can be printed on stdout or stderr. We accomplish this by defining a simple wrapper for Shake's `cmd` function, that just _always_ captures both streams in case the command returns a non-zero exit code, and by using this wrapper everywhere in `hadrian/src/Builder.hs`. Fixes #18089. - - - - - 4b9764db by Ryan Scott at 2020-04-28T15:40:04-04:00 Define a Quote IO instance Fixes #18103. - - - - - 518a63d4 by Ryan Scott at 2020-04-28T15:40:42-04:00 Make boxed 1-tuples have known keys Unlike other tuples, which use special syntax and are "known" by way of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not use special syntax. Therefore, in order to make sure that the internals of GHC are aware of the `data Unit a = Unit a` definition in `GHC.Tuple`, we give `Unit` known keys. For the full details, see `Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)` in `GHC.Builtin.Types`. Fixes #18097. - - - - - 2cfc4ab9 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Document backpack fields in DynFlags - - - - - 10a2ba90 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo * Rename InstalledPackageInfo into GenericUnitInfo The name InstalledPackageInfo is only kept for alleged backward compatibility reason in Cabal. ghc-boot has its own stripped down copy of this datatype but it doesn't need to keep the name. Internally we already use type aliases (UnitInfo in GHC, PackageCacheFormat in ghc-pkg). * Rename UnitInfo fields: add "unit" prefix and fix misleading names * Add comments on every UnitInfo field * Rename SourcePackageId into PackageId "Package" already indicates that it's a "source package". Installed package components are called units. Update Haddock submodule - - - - - 69562e34 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Remove unused `emptyGenericUnitInfo` - - - - - 9e2c8e0e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo load/store from databases Converting between UnitInfo stored in package databases and UnitInfo as they are used in ghc-pkg and ghc was done in a very convoluted way (via BinaryStringRep and DbUnitModuleRep type classes using fun deps, etc.). It was difficult to understand and even more to modify (I wanted to try to use a GADT for UnitId but fun deps got in the way). The new code uses much more straightforward functions to convert between the different representations. Much simpler. - - - - - ea717aa4 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Factorize mungePackagePaths code This patch factorizes the duplicated code used in ghc-pkg and in GHC to munge package paths/urls. It also fixes haddock-html munging in GHC (allowed to be either a file or a url) to mimic ghc-pkg behavior. - - - - - 10d15f1e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactoring unit management code Over the years the unit management code has been modified a lot to keep up with changes in Cabal (e.g. support for several library components in the same package), to integrate BackPack, etc. I found it very hard to understand as the terminology wasn't consistent, was referring to past concepts, etc. The terminology is now explained as clearly as I could in the Note "About Units" and the code is refactored to reflect it. ------------------- Many names were misleading: UnitId is not an Id but could be a virtual unit (an indefinite one instantiated on the fly), IndefUnitId constructor may contain a definite instantiated unit, etc. * Rename IndefUnitId into InstantiatedUnit * Rename IndefModule into InstantiatedModule * Rename UnitId type into Unit * Rename IndefiniteUnitId constructor into VirtUnit * Rename DefiniteUnitId constructor into RealUnit * Rename packageConfigId into mkUnit * Rename getPackageDetails into unsafeGetUnitInfo * Rename InstalledUnitId into UnitId Remove references to misleading ComponentId: a ComponentId is just an indefinite unit-id to be instantiated. * Rename ComponentId into IndefUnitId * Rename ComponentDetails into UnitPprInfo * Fix display of UnitPprInfo with empty version: this is now used for units dynamically generated by BackPack Generalize several types (Module, Unit, etc.) so that they can be used with different unit identifier types: UnitKey, UnitId, Unit, etc. * GenModule: Module, InstantiatedModule and InstalledModule are now instances of this type * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit, PackageDatabase Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor. Add basic support for UnitKey. They should be used more in the future to avoid mixing them up with UnitId as we do now. Add many comments. Update Haddock submodule - - - - - 8bfb0219 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Unit: split and rename modules Introduce GHC.Unit.* hierarchy for everything concerning units, packages and modules. Update Haddock submodule - - - - - 71484b09 by Alexis King at 2020-04-30T01:57:35-04:00 Allow block arguments in arrow control operators Arrow control operators have their own entries in the grammar, so they did not cooperate with BlockArguments. This was just a minor oversight, so this patch adjusts the grammar to add the desired behavior. fixes #18050 - - - - - a48cd2a0 by Alexis King at 2020-04-30T01:57:35-04:00 Allow LambdaCase to be used as a command in proc notation - - - - - f4d3773c by Alexis King at 2020-04-30T01:57:35-04:00 Document BlockArguments/LambdaCase support in arrow notation - - - - - 5bdfdd13 by Simon Peyton Jones at 2020-04-30T01:58:15-04:00 Add tests for #17873 - - - - - 19b701c2 by Simon Peyton Jones at 2020-04-30T07:30:13-04:00 Mark rule args as non-tail-called This was just an omission...b I'd failed to call markAllNonTailCall on rule args. I think this bug has been here a long time, but it's quite hard to trigger. Fixes #18098 - - - - - 014ef4a3 by Matthew Pickering at 2020-04-30T07:30:50-04:00 Hadrian: Improve tool-args command to support more components There is a new command to hadrian, tool:path/to/file.hs, which returns the options needed to compile that file in GHCi. This is now used in the ghci script with argument `ghc/Main.hs` but its main purpose is to support the new multi-component branch of ghcide. - - - - - 2aa67611 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Clear bitmap after initializing block size Previously nonmovingInitSegment would clear the bitmap before initializing the segment's block size. This is broken since nonmovingClearBitmap looks at the segment's block size to determine how much bitmap to clear. - - - - - 54dad3cf by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Explicitly memoize block count A profile cast doubt on whether the compiler hoisted the bound out the loop as I would have expected here. It turns out it did but nevertheless it seems clearer to just do this manually. - - - - - 99ff8145 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Eagerly flush all capabilities' update remembered sets (cherry picked from commit 2fa79119570b358a4db61446396889b8260d7957) - - - - - 05b0a9fd by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 Remove OneShotInfo field of LFReEntrant, document OneShotInfo The field is only used in withNewTickyCounterFun and it's easier to directly pass a parameter for one-shot info to withNewTickyCounterFun instead of passing it via LFReEntrant. This also makes !2842 simpler. Other changes: - New Note (by SPJ) [OneShotInfo overview] added. - Arity argument of thunkCode removed as it's always 0. - - - - - a43620c6 by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 GHC.StgToCmm.Ticky: remove a few unused stuff - - - - - 780de9e1 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Use platform in Iface Binary - - - - - f8386c7b by Sylvain Henry at 2020-05-01T10:37:39-04:00 Refactor PprDebug handling If `-dppr-debug` is set, then PprUser and PprDump styles are silently replaced with PprDebug style. This was done in `mkUserStyle` and `mkDumpStyle` smart constructors. As a consequence they needed a DynFlags parameter. Now we keep the original PprUser and PprDump styles until they are used to create an `SDocContext`. I.e. the substitution is only performed in `initSDocContext`. - - - - - b3df9e78 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Remove PprStyle param of logging actions Use `withPprStyle` instead to apply a specific style to a SDoc. - - - - - de9fc995 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Fully remove PprDebug PprDebug was a pain to deal with consistently as it is implied by `-dppr-debug` but it isn't really a PprStyle. We remove it completely and query the appropriate SDoc flag instead (`sdocPprDebug`) via helpers (`getPprDebug` and its friends). - - - - - 8b51fcbd by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Only call checkSingle if we would report warnings - - - - - fd7ea0fe by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Pick up `EvVar`s bound in `HsWrapper`s for long-distance info `HsWrapper`s introduce evidence bindings through `WpEvLam` which the pattern-match coverage checker should be made aware of. Failing to do so caused #18049, where the resulting impreciseness of imcompleteness warnings seemingly contradicted with `-Winaccessible-code`. The solution is simple: Collect all the evidence binders of an `HsWrapper` and add it to the ambient `Deltas` before desugaring the wrapped expression. But that means we pick up many more evidence bindings, even when they wrap around code without a single pattern match to check! That regressed `T3064` by over 300%, so now we are adding long-distance info lazily through judicious use of `unsafeInterleaveIO`. Fixes #18049. - - - - - 7bfe9ac5 by Ben Gamari at 2020-05-03T04:41:33-04:00 rts: Enable tracing of nonmoving heap census with -ln Previously this was not easily available to the user. Fix this. Non-moving collection lifecycle events are now reported with -lg. - - - - - c560dd07 by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Move eventlog documentation users guide - - - - - 02543d5e by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Add documentation for non-moving GC events - - - - - b465dd45 by Alexis King at 2020-05-03T04:42:12-04:00 Flatten nested casts in the simple optimizer Normally, we aren’t supposed to generated any nested casts, since mkCast takes care to flatten them, but the simple optimizer didn’t use mkCast, so they could show up after inlining. This isn’t really a problem, since the simplifier will clean them up immediately anyway, but it can clutter the -ddump-ds output, and it’s an extremely easy fix. closes #18112 - - - - - 8bdc03d6 by Simon Peyton Jones at 2020-05-04T01:56:59-04:00 Don't return a panic in tcNestedSplice In GHC.Tc.Gen.Splice.tcNestedSplice we were returning a typechecked expression of "panic". That is usually OK, because the result is discarded. But it happens that tcApp now looks at the typechecked expression, trivially, to ask if it is tagToEnum. So being bottom is bad. Moreover a debug-trace might print it out. So better to return a civilised expression, even though it is usually discarded. - - - - - 0bf640b1 by Baldur Blöndal at 2020-05-04T01:57:36-04:00 Don't require parentheses around via type (`-XDerivingVia'). Fixes #18130". - - - - - 30272412 by Artem Pelenitsyn at 2020-05-04T13:19:59-04:00 Remove custom ExceptionMonad class (#18075) (updating haddock submodule accordingly) - - - - - b9f7c08f by jneira at 2020-05-04T13:20:37-04:00 Remove unused hs-boot file - - - - - 1d8f80cd by Sylvain Henry at 2020-05-05T03:22:46-04:00 Remove references to -package-key * remove references to `-package-key` which has been removed in 2016 (240ddd7c39536776e955e881d709bbb039b48513) * remove support for `-this-package-key` which has been deprecated at the same time - - - - - 7bc3a65b by Sylvain Henry at 2020-05-05T03:23:31-04:00 Remove SpecConstrAnnotation (#13681) This has been deprecated since 2013. Use GHC.Types.SPEC instead. Make GHC.Exts "not-home" for haddock Metric Decrease: haddock.base - - - - - 3c862f63 by DenisFrezzato at 2020-05-05T03:24:15-04:00 Fix Haskell98 short description in documentation - - - - - 2420c555 by Ryan Scott at 2020-05-05T03:24:53-04:00 Add regression tests for #16244, #16245, #16758 Commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70 ended up fixing quite a few bugs: * This commit fixes #16244 completely. A regression test has been added. * This commit fixes one program from #16245. (The program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211369 still panics, and the program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211400 still loops infinitely.) A regression test has been added for this program. * This commit fixes #16758. Accordingly, this patch removes the `expect_broken` label from the `T16758` test case, moves it from `should_compile` to `should_fail` (as it should produce an error message), and checks in the expected stderr. - - - - - 40c71c2c by Sylvain Henry at 2020-05-05T03:25:31-04:00 Fix colorized error messages (#18128) In b3df9e780fb2f5658412c644849cd0f1e6f50331 I broke colorized messages by using "dump" style instead of "user" style. This commits fixes it. - - - - - 7ab6ab09 by Richard Eisenberg at 2020-05-06T04:39:32-04:00 Refactor hole constraints. Previously, holes (both expression holes / out of scope variables and partial-type-signature wildcards) were emitted as *constraints* via the CHoleCan constructor. While this worked fine for error reporting, there was a fair amount of faff in keeping these constraints in line. In particular, and unlike other constraints, we could never change a CHoleCan to become CNonCanonical. In addition: * the "predicate" of a CHoleCan constraint was really the type of the hole, which is not a predicate at all * type-level holes (partial type signature wildcards) carried evidence, which was never used * tcNormalise (used in the pattern-match checker) had to create a hole constraint just to extract it again; it was quite messy The new approach is to record holes directly in WantedConstraints. It flows much more nicely now. Along the way, I did some cleaning up of commentary in GHC.Tc.Errors.Hole, which I had a hard time understanding. This was instigated by a future patch that will refactor the way predicates are handled. The fact that CHoleCan's "predicate" wasn't really a predicate is incompatible with that future patch. No test case, because this is meant to be purely internal. It turns out that this change improves the performance of the pattern-match checker, likely because fewer constraints are sloshing about in tcNormalise. I have not investigated deeply, but an improvement is not a surprise here: ------------------------- Metric Decrease: PmSeriesG ------------------------- - - - - - 420b957d by Ben Gamari at 2020-05-06T04:40:08-04:00 rts: Zero block flags with -DZ Block flags are very useful for determining the state of a block. However, some block allocator users don't touch them, leading to misleading values. Ensure that we zero then when zero-on-gc is set. This is safe and makes the flags more useful during debugging. - - - - - 740b3b8d by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix incorrect failed_to_evac value during deadlock gc Previously we would incorrectly set the failed_to_evac flag if we evacuated a value due to a deadlock GC. This would cause us to mark more things as dirty than strictly necessary. It also turned up a nasty but which I will fix next. - - - - - b2d72c75 by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix handling of dirty objects Previously we (incorrectly) relied on failed_to_evac to be "precise". That is, we expected it to only be true if *all* of an object's fields lived outside of the non-moving heap. However, does not match the behavior of failed_to_evac, which is true if *any* of the object's fields weren't promoted (meaning that some others *may* live in the non-moving heap). This is problematic as we skip the non-moving write barrier for dirty objects (which we can only safely do if *all* fields point outside of the non-moving heap). Clearly this arises due to a fundamental difference in the behavior expected of failed_to_evac in the moving and non-moving collector. e.g., in the moving collector it is always safe to conservatively say failed_to_evac=true whereas in the non-moving collector the safe value is false. This issue went unnoticed as I never wrote down the dirtiness invariant enforced by the non-moving collector. We now define this invariant as An object being marked as dirty implies that all of its fields are on the mark queue (or, equivalently, update remembered set). To maintain this invariant we teach nonmovingScavengeOne to push the fields of objects which we fail to evacuate to the update remembered set. This is a simple and reasonably cheap solution and avoids the complexity and fragility that other, more strict alternative invariants would require. All of this is described in a new Note, Note [Dirty flags in the non-moving collector] in NonMoving.c. - - - - - 9f3e6884 by Zubin Duggal at 2020-05-06T04:41:08-04:00 Allow atomic update of NameCache in readHieFile The situation arises in ghcide where multiple different threads may need to update the name cache, therefore with the older interface it could happen that you start reading a hie file with name cache A and produce name cache A + B, but another thread in the meantime updated the namecache to A + C. Therefore if you write the new namecache you will lose the A' updates from the second thread. Updates haddock submodule - - - - - edec6a6c by Ryan Scott at 2020-05-06T04:41:57-04:00 Make isTauTy detect higher-rank contexts Previously, `isTauTy` would only detect higher-rank `forall`s, not higher-rank contexts, which led to some minor bugs observed in #18127. Easily fixed by adding a case for `(FunTy InvisArg _ _)`. Fixes #18127. - - - - - a95e7fe0 by Ömer Sinan Ağacan at 2020-05-06T04:42:39-04:00 ELF linker: increment curSymbol after filling in fields of current entry The bug was introduced in a8b7cef4d45 which added a field to the `symbols` array elements and then updated this code incorrectly: - oc->symbols[curSymbol++] = nm; + oc->symbols[curSymbol++].name = nm; + oc->symbols[curSymbol].addr = symbol->addr; - - - - - cab1871a by Sylvain Henry at 2020-05-06T04:43:21-04:00 Move LeadingUnderscore into Platform (#17957) Avoid direct use of DynFlags to know if symbols must be prefixed by an underscore. - - - - - 94e7c563 by Sylvain Henry at 2020-05-06T04:43:21-04:00 Don't use DynFlags in showLinkerState (#17957) - - - - - 9afd9251 by Ryan Scott at 2020-05-06T04:43:58-04:00 Refactoring: Use bindSigTyVarsFV in rnMethodBinds `rnMethodBinds` was explicitly using `xoptM` to determine if `ScopedTypeVariables` is enabled before bringing type variables bound by the class/instance header into scope. However, this `xoptM` logic is already performed by the `bindSigTyVarsFV` function. This patch uses `bindSigTyVarsFV` in `rnMethodBinds` to reduce the number of places where we need to consult if `ScopedTypeVariables` is on. This is purely refactoring, and there should be no user-visible change in behavior. - - - - - 6f6d72b2 by Brian Foley at 2020-05-08T15:29:25-04:00 Remove further dead code found by a simple Python script. Avoid removing some functions that are part of an API even though they're not used in-tree at the moment. - - - - - 78bf8bf9 by Julien Debon at 2020-05-08T15:29:28-04:00 Add doc examples for Bifoldable See #17929 - - - - - 66f0a847 by Julien Debon at 2020-05-08T15:29:29-04:00 doc (Bitraversable): Add examples to Bitraversable * Add examples to Data.Bitraversable * Fix formatting for (,) in Bitraversable and Bifoldable * Fix mistake on bimapAccumR documentation See #17929 - - - - - 9749fe12 by Baldur Blöndal at 2020-05-08T15:29:32-04:00 Specify kind variables for inferred kinds in base. - - - - - 4e9aef9e by John Ericson at 2020-05-08T15:29:36-04:00 HsSigWcTypeScoping: Pull in documentation from stray location - - - - - f4d5c6df by John Ericson at 2020-05-08T15:29:36-04:00 Rename local `real_fvs` to `implicit_vs` It doesn't make sense to call the "free" variables we are about to implicitly bind the real ones. - - - - - 20570b4b by John Ericson at 2020-05-08T15:29:36-04:00 A few tiny style nits with renaming - Use case rather than guards that repeatedly scrutenize same thing. - No need for view pattern when `L` is fine. - Use type synnonym to convey the intent like elsewhere. - - - - - 09ac8de5 by John Ericson at 2020-05-08T15:29:36-04:00 Add `forAllOrNothing` function with note - - - - - bb35c0e5 by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Document lawlessness of Ap's Num instance - - - - - cdd229ff by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply suggestion to libraries/base/Data/Monoid.hs - - - - - 926d2aab by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply more suggestions from Simon Jakobi - - - - - 7a763cff by Adam Gundry at 2020-05-08T15:29:41-04:00 Reject all duplicate declarations involving DuplicateRecordFields (fixes #17965) This fixes a bug that resulted in some programs being accepted that used the same identifier as a field label and another declaration, depending on the order they appeared in the source code. - - - - - 88e3c815 by Simon Peyton Jones at 2020-05-08T15:29:41-04:00 Fix specialisation for DFuns When specialising a DFun we must take care to saturate the unfolding. See Note [Specialising DFuns] in Specialise. Fixes #18120 - - - - - 86c77b36 by Greg Steuck at 2020-05-08T15:29:45-04:00 Remove unused SEGMENT_PROT_RWX It's been unused for a year and is problematic on any OS which requires W^X for security. - - - - - 9d97f4b5 by nineonine at 2020-05-08T15:30:03-04:00 Add test for #16167 - - - - - aa318338 by Ryan Scott at 2020-05-08T15:30:04-04:00 Bump exceptions submodule so that dist-boot is .gitignore'd `exceptions` is a stage-0 boot library as of commit 30272412fa437ab8e7a8035db94a278e10513413, which means that building `exceptions` in a GHC tree will generate a `dist-boot` directory. However, this directory was not specified in `exceptions`' `.gitignore` file, which causes it to dirty up the current `git` working directory. Accordingly, this bumps the `exceptions` submodule to commit ghc/packages/exceptions at 23c0b8a50d7592af37ca09beeec16b93080df98f, which adds `dist-boot` to the `.gitignore` file. - - - - - ea86360f by Ömer Sinan Ağacan at 2020-05-08T15:30:30-04:00 Linker.c: initialize n_symbols of ObjectCode with other fields - - - - - 951c1fb0 by Sylvain Henry at 2020-05-09T21:46:38-04:00 Fix unboxed-sums GC ptr-slot rubbish value (#17791) This patch allows boot libraries to use unboxed sums without implicitly depending on `base` package because of `absentSumFieldError`. See updated Note [aBSENT_SUM_FIELD_ERROR_ID] in GHC.Core.Make - - - - - b352d63c by Ben Gamari at 2020-05-09T21:47:14-04:00 rts: Make non-existent linker search path merely a warning As noted in #18105, previously this resulted in a rather intrusive error message. This is in contrast to the general expectation that search paths are merely places to look, not places that must exist. Fixes #18105. - - - - - cf4f1e2f by Ben Gamari at 2020-05-13T02:02:33-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 - - - - - a03da9bf by Ömer Sinan Ağacan at 2020-05-13T02:03:16-04:00 Pack some of IdInfo fields into a bit field This reduces residency of compiler quite a bit on some programs. Example stats when building T10370: Before: 2,871,242,832 bytes allocated in the heap 4,693,328,008 bytes copied during GC 33,941,448 bytes maximum residency (276 sample(s)) 375,976 bytes maximum slop 83 MiB total memory in use (0 MB lost due to fragmentation) After: 2,858,897,344 bytes allocated in the heap 4,629,255,440 bytes copied during GC 32,616,624 bytes maximum residency (278 sample(s)) 314,400 bytes maximum slop 80 MiB total memory in use (0 MB lost due to fragmentation) So -3.9% residency, -1.3% bytes copied and -0.4% allocations. Fixes #17497 Metric Decrease: T9233 T9675 - - - - - 670c3e5c by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Fix base URL Revert a change previously made for testing purposes. - - - - - 8ad8dc41 by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Improve diagnostics output - - - - - 8c0740b7 by Simon Jakobi at 2020-05-13T02:04:33-04:00 docs: Add examples for Data.Semigroup.Arg{Min,Max} Context: #17153 - - - - - cb22348f by Ben Gamari at 2020-05-13T02:05:11-04:00 Add few cleanups of the CAF logic Give the NameSet of non-CAFfy names a proper newtype to distinguish it from all of the other NameSets floating about. - - - - - 90e38b81 by Emeka Nkurumeh at 2020-05-13T02:05:51-04:00 fix printf warning when using with ghc with clang on mingw - - - - - 86d8ac22 by Sebastian Graf at 2020-05-13T02:06:29-04:00 CprAnal: Don't attach CPR sigs to expandable bindings (#18154) Instead, look through expandable unfoldings in `cprTransform`. See the new Note [CPR for expandable unfoldings]: ``` Long static data structures (whether top-level or not) like xs = x1 : xs1 xs1 = x2 : xs2 xs2 = x3 : xs3 should not get CPR signatures, because they * Never get WW'd, so their CPR signature should be irrelevant after analysis (in fact the signature might even be harmful for that reason) * Would need to be inlined/expanded to see their constructed product * Recording CPR on them blows up interface file sizes and is redundant with their unfolding. In case of Nested CPR, this blow-up can be quadratic! But we can't just stop giving DataCon application bindings the CPR property, for example fac 0 = 1 fac n = n * fac (n-1) fac certainly has the CPR property and should be WW'd! But FloatOut will transform the first clause to lvl = 1 fac 0 = lvl If lvl doesn't have the CPR property, fac won't either. But lvl doesn't have a CPR signature to extrapolate into a CPR transformer ('cprTransform'). So instead we keep on cprAnal'ing through *expandable* unfoldings for these arity 0 bindings via 'cprExpandUnfolding_maybe'. In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one for each data declaration. It's wasteful to attach CPR signatures to each of them (and intractable in case of Nested CPR). ``` Fixes #18154. - - - - - e34bf656 by Ben Gamari at 2020-05-13T02:07:08-04:00 users-guide: Add discussion of shared object naming Fixes #18074. - - - - - 5d0f2445 by Ben Gamari at 2020-05-13T02:07:47-04:00 testsuite: Print sign of performance changes Executes the minor formatting change in the tabulated performance changes suggested in #18135. - - - - - 9e4b981f by Ben Gamari at 2020-05-13T02:08:24-04:00 testsuite: Add testcase for #18129 - - - - - 266310c3 by Ivan-Yudin at 2020-05-13T02:09:03-04:00 doc: Reformulate the opening paragraph of Ch. 4 in User's guide Removes mentioning of Hugs (it is not helpful for new users anymore). Changes the wording for the rest of the paragraph. Fixes #18132. - - - - - 55e35c0b by Baldur Blöndal at 2020-05-13T20:02:48-04:00 Predicate, Equivalence derive via `.. -> a -> All' - - - - - d7e0b57f by Alp Mestanogullari at 2020-05-13T20:03:30-04:00 hadrian: add a --freeze2 option to freeze stage 1 and 2 - - - - - d880d6b2 by Artem Pelenitsyn at 2020-05-13T20:04:11-04:00 Don't reload environment files on every setSessionDynFlags Makes `interpretPackageEnv` (which loads envirinment files) a part of `parseDynamicFlags` (parsing command-line arguments, which is typically done once) instead of `setSessionDynFlags` (which is typically called several times). Making several (transitive) calls to `interpretPackageEnv`, as before, caused #18125 #16318, which should be fixed now. - - - - - 102cfd67 by Ryan Scott at 2020-05-13T20:04:46-04:00 Factor out HsPatSigType for pat sigs/RULE term sigs (#16762) This implements chunks (2) and (3) of https://gitlab.haskell.org/ghc/ghc/issues/16762#note_270170. Namely, it introduces a dedicated `HsPatSigType` AST type, which represents the types that can appear in pattern signatures and term-level `RULE` binders. Previously, these were represented with `LHsSigWcType`. Although `LHsSigWcType` is isomorphic to `HsPatSigType`, the intended semantics of the two types are slightly different, as evidenced by the fact that they have different code paths in the renamer and typechecker. See also the new `Note [Pattern signature binders and scoping]` in `GHC.Hs.Types`. - - - - - b17574f7 by Hécate at 2020-05-13T20:05:28-04:00 fix(documentation): Fix the RST links to GHC.Prim - - - - - df021fb1 by Baldur Blöndal at 2020-05-13T20:06:06-04:00 Document (->) using inferred quantification for its runtime representations. Fixes #18142. - - - - - 1a93ea57 by Takenobu Tani at 2020-05-13T20:06:54-04:00 Tweak man page for ghc command This commit updates the ghc command's man page as followings: * Enable `man_show_urls` to show URL addresses in the `DESCRIPTION` section of ghc.rst, because sphinx currently removes hyperlinks for man pages. * Add a `SEE ALSO` section to point to the GHC homepage - - - - - a951e1ba by Takenobu Tani at 2020-05-13T20:07:37-04:00 GHCi: Add link to the user's guide in help message This commit adds a link to the user's guide in ghci's `:help` message. Newcomers could easily reach to details of ghci. - - - - - 404581ea by Jeff Happily at 2020-05-13T20:08:15-04:00 Handle single unused import - - - - - 1c999e5d by Ben Gamari at 2020-05-13T20:09:07-04:00 Ensure that printMinimalImports closes handle Fixes #18166. - - - - - c9f5a8f4 by Ben Gamari at 2020-05-13T20:09:51-04:00 hadrian: Tell testsuite driver about LLVM availability This reflects the logic present in the Make build system into Hadrian. Fixes #18167. - - - - - c05c0659 by Simon Jakobi at 2020-05-14T03:31:21-04:00 Improve some folds over Uniq[D]FM * Replace some non-deterministic lazy folds with strict folds. * Replace some O(n log n) folds in deterministic order with O(n) non-deterministic folds. * Replace some folds with set-operations on the underlying IntMaps. This reduces max residency when compiling `nofib/spectral/simple/Main.hs` with -O0 by about 1%. Maximum residency when compiling Cabal also seems reduced on the order of 3-9%. - - - - - 477f13bb by Simon Jakobi at 2020-05-14T03:31:58-04:00 Use Data.IntMap.disjoint Data.IntMap gained a dedicated `disjoint` function in containers-0.6.2.1. This patch applies this function where appropriate in hopes of modest compiler performance improvements. Closes #16806. - - - - - e9c0110c by Ben Gamari at 2020-05-14T12:25:53-04:00 IdInfo: Add reference to bitfield-packing ticket - - - - - 9bd20e83 by Sebastian Graf at 2020-05-15T10:42:09-04:00 DmdAnal: Improve handling of precise exceptions This patch does two things: Fix possible unsoundness in what was called the "IO hack" and implement part 2.1 of the "fixing precise exceptions" plan in https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions, which, in combination with !2956, supersedes !3014 and !2525. **IO hack** The "IO hack" (which is a fallback to preserve precise exceptions semantics and thus soundness, rather than some smart thing that increases precision) is called `exprMayThrowPreciseException` now. I came up with two testcases exemplifying possible unsoundness (if twisted enough) in the old approach: - `T13380d`: Demonstrating unsoundness of the "IO hack" when resorting to manual state token threading and direct use of primops. More details below. - `T13380e`: Demonstrating unsoundness of the "IO hack" when we have Nested CPR. Not currently relevant, as we don't have Nested CPR yet. - `T13380f`: Demonstrating unsoundness of the "IO hack" for safe FFI calls. Basically, the IO hack assumed that precise exceptions can only be thrown from a case scrutinee of type `(# State# RealWorld, _ #)`. I couldn't come up with a program using the `IO` abstraction that violates this assumption. But it's easy to do so via manual state token threading and direct use of primops, see `T13380d`. Also similar code might be generated by Nested CPR in the (hopefully not too) distant future, see `T13380e`. Hence, we now have a more careful test in `forcesRealWorld` that passes `T13380{d,e}` (and will hopefully be robust to Nested CPR). **Precise exceptions** In #13380 and #17676 we saw that we didn't preserve precise exception semantics in demand analysis. We fixed that with minimal changes in !2956, but that was terribly unprincipled. That unprincipledness resulted in a loss of precision, which is tracked by these new test cases: - `T13380b`: Regression in dead code elimination, because !2956 was too syntactic about `raiseIO#` - `T13380c`: No need to apply the "IO hack" when the IO action may not throw a precise exception (and the existing IO hack doesn't detect that) Fixing both issues in !3014 turned out to be too complicated and had the potential to regress in the future. Hence we decided to only fix `T13380b` and augment the `Divergence` lattice with a new middle-layer element, `ExnOrDiv`, which means either `Diverges` (, throws an imprecise exception) or throws a *precise* exception. See the wiki page on Step 2.1 for more implementational details: https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions#dead-code-elimination-for-raiseio-with-isdeadenddiv-introducing-exnordiv-step-21 - - - - - 568d7279 by Ben Gamari at 2020-05-15T10:42:46-04:00 GHC.Cmm.Opt: Handle MO_XX_Conv This MachOp was introduced by 2c959a1894311e59cd2fd469c1967491c1e488f3 but a wildcard match in cmmMachOpFoldM hid the fact that it wasn't handled. Ideally we would eliminate the match but this appears to be a larger task. Fixes #18141. - - - - - 5bcf8606 by Ryan Scott at 2020-05-17T08:46:38-04:00 Remove duplicate Note [When to print foralls] in GHC.Core.TyCo.Ppr There are two different Notes named `[When to print foralls]`. The most up-to-date one is in `GHC.Iface.Type`, but there is a second one in `GHC.Core.TyCo.Ppr`. The latter is less up-to-date, as it was written before GHC switched over to using ifaces to pretty-print types. I decided to just remove the latter and replace it with a reference to the former. [ci skip] - - - - - 55f0e783 by Fumiaki Kinoshita at 2020-05-21T12:10:44-04:00 base: Add Generic instances to various datatypes under GHC.* * GHC.Fingerprint.Types: Fingerprint * GHC.RTS.Flags: GiveGCStats, GCFlags, ConcFlags, DebugFlags, CCFlags, DoHeapProfile, ProfFlags, DoTrace, TraceFlags, TickyFlags, ParFlags and RTSFlags * GHC.Stats: RTSStats and GCStats * GHC.ByteOrder: ByteOrder * GHC.Unicode: GeneralCategory * GHC.Stack.Types: SrcLoc Metric Increase: haddock.base - - - - - a9311cd5 by Gert-Jan Bottu at 2020-05-21T12:11:31-04:00 Explicit Specificity Implementation for Ticket #16393. Explicit specificity allows users to manually create inferred type variables, by marking them with braces. This way, the user determines which variables can be instantiated through visible type application. The additional syntax is included in the parser, allowing users to write braces in type variable binders (type signatures, data constructors etc). This information is passed along through the renamer and verified in the type checker. The AST for type variable binders, data constructors, pattern synonyms, partial signatures and Template Haskell has been updated to include the specificity of type variables. Minor notes: - Bumps haddock submodule - Disables pattern match checking in GHC.Iface.Type with GHC 8.8 - - - - - 24e61aad by Ben Price at 2020-05-21T12:12:17-04:00 Lint should say when it is checking a rule It is rather confusing that when lint finds an error in a rule attached to a binder, it reports the error as in the RHS, not the rule: ... In the RHS of foo We add a clarifying line: ... In the RHS of foo In a rule attached to foo The implication that the rule lives inside the RHS is a bit odd, but this niggle is already present for unfoldings, whose pattern we are following. - - - - - 78c6523c by Ben Gamari at 2020-05-21T12:13:01-04:00 nonmoving: Optimise the write barrier - - - - - 13f6c9d0 by Andreas Klebinger at 2020-05-21T12:13:45-04:00 Refactor linear reg alloc to remember past assignments. When assigning registers we now first try registers we assigned to in the past, instead of picking the "first" one. This is in extremely helpful when dealing with loops for which variables are dead for part of the loop. This is important for patterns like this: foo = arg1 loop: use(foo) ... foo = getVal() goto loop; There we: * assign foo to the register of arg1. * use foo, it's dead after this use as it's overwritten after. * do other things. * look for a register to put foo in. If we pick an arbitrary one it might differ from the register the start of the loop expect's foo to be in. To fix this we simply look for past register assignments for the given variable. If we find one and the register is free we use that register. This reduces the need for fixup blocks which match the register assignment between blocks. In the example above between the end and the head of the loop. This patch also moves branch weight estimation ahead of register allocation and adds a flag to control it (cmm-static-pred). * It means the linear allocator is more likely to assign the hotter code paths first. * If it assign these first we are: + Less likely to spill on the hot path. + Less likely to introduce fixup blocks on the hot path. These two measure combined are surprisingly effective. Based on nofib we get in the mean: * -0.9% instructions executed * -0.1% reads/writes * -0.2% code size. * -0.1% compiler allocations. * -0.9% compile time. * -0.8% runtime. Most of the benefits are simply a result of removing redundant moves and spills. Reduced compiler allocations likely are the result of less code being generated. (The added lookup is mostly non-allocating). - - - - - edc2cc58 by Andreas Klebinger at 2020-05-21T12:14:25-04:00 NCG: Codelayout: Distinguish conditional and other branches. In #18053 we ended up with a suboptimal code layout because the code layout algorithm didn't distinguish between conditional and unconditional control flow. We can completely eliminate unconditional control flow instructions by placing blocks next to each other, not so much for conditionals. In terms of implementation we simply give conditional branches less weight before computing the layout. Fixes #18053 - - - - - b7a6b2f4 by Gleb Popov at 2020-05-21T12:15:26-04:00 gitlab-ci: Set locale to C.UTF-8. - - - - - a8c27cf6 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow spaces in GHCi :script file names This patch updates the user interface of GHCi so that file names passed to the ':script' command may contain spaces escaped with a backslash. For example: :script foo\ bar.script The implementation uses a modified version of 'words' that does not break on escaped spaces. Fixes #18027. - - - - - 82663959 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Add extra tests for GHCi :script syntax checks The syntax for GHCi's ":script" command allows for only a single file name to be passed as an argument. This patch adds a test for the cases in which a file name is missing or multiple file names are passed. Related to #T18027. - - - - - a0b79e1b by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow GHCi :script file names in double quotes This patch updates the user interface of GHCi so that file names passed to the ':script' command can be wrapped in double quotes. For example: :script "foo bar.script" The implementation uses a modified version of 'words' that treats character sequences enclosed in double quotes as single words. Fixes #18027. - - - - - cf566330 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Update documentation for GHCi :script This patch adds the fixes that allow for file names containing spaces to be passed to GHCi's ':script' command to the release notes for 8.12 and expands the user-guide documentation for ':script' by mentioning how such file names can be passed. Related to #18027. - - - - - 0004ccb8 by Tuan Le at 2020-05-21T12:16:46-04:00 llvmGen: Consider Relocatable read-only data as not constantReferences: #18137 - - - - - 964d3ea2 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_pat` - - - - - b797aa42 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_lpat` and `tc_lpats` - - - - - 5108e84a by John Ericson at 2020-05-21T12:17:30-04:00 More judiciously panic in `ts_pat` - - - - - 510e0451 by John Ericson at 2020-05-21T12:17:30-04:00 Put `PatEnv` first in `GHC.Tc.Gen.Pat.Checker` - - - - - cb4231db by John Ericson at 2020-05-21T12:17:30-04:00 Tiny cleaup eta-reduce away a function argument In GHC, not in the code being compiled! - - - - - 6890c38d by John Ericson at 2020-05-21T12:17:30-04:00 Use braces with do in `SplicePat` case for consistency - - - - - 3451584f by buggymcbugfix at 2020-05-21T12:18:06-04:00 Fix spelling mistakes and typos - - - - - b552e531 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Add INLINABLE pragmas to Enum list producers The INLINABLE pragmas ensure that we export stable (unoptimised) unfoldings in the interface file so we can do list fusion at usage sites. Related tickets: #15185, #8763, #18178. - - - - - e7480063 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Piggyback on Enum Word methods for Word64 If we are on a 64 bit platform, we can use the efficient Enum Word methods for the Enum Word64 instance. - - - - - 892b0c41 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Document INLINE(ABLE) pragmas that enable fusion - - - - - 2b363ebb by Richard Eisenberg at 2020-05-21T12:18:45-04:00 MR template should ask for key part - - - - - a95bbd0b by Sebastian Graf at 2020-05-21T12:19:37-04:00 Make `Int`'s `mod` and `rem` strict in their first arguments They used to be strict until 4d2ac2d (9 years ago). It's obviously better to be strict for performance reasons. It also blocks #18067. NoFib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- integer -1.1% +0.4% wheel-sieve2 +21.2% +20.7% -------------------------------------------------------------------------------- Min -1.1% -0.0% Max +21.2% +20.7% Geometric Mean +0.2% +0.2% ``` The regression in `wheel-sieve2` is due to reboxing that likely will go away with the resolution of #18067. See !3282 for details. Fixes #18187. - - - - - d3d055b8 by Galen Huntington at 2020-05-21T12:20:18-04:00 Clarify pitfalls of NegativeLiterals; see #18022. - - - - - 1b508a9e by Alexey Kuleshevich at 2020-05-21T12:21:02-04:00 Fix wording in primops documentation to reflect the correct reasoning: * Besides resizing functions, shrinking ones also mutate the size of a mutable array and because of those two `sizeofMutabeByteArray` and `sizeofSmallMutableArray` are now deprecated * Change reference in documentation to the newer functions `getSizeof*` instead of `sizeof*` for shrinking functions * Fix incorrect mention of "byte" instead of "small" - - - - - 4ca0c8a1 by Andreas Klebinger at 2020-05-21T12:21:53-04:00 Don't variable-length encode magic iface constant. We changed to use variable length encodings for many types by default, including Word32. This makes sense for numbers but not when Word32 is meant to represent four bytes. I added a FixedLengthEncoding newtype to Binary who's instances interpret their argument as a collection of bytes instead of a number. We then use this when writing/reading magic numbers to the iface file. I also took the libery to remove the dummy iface field. This fixes #18180. - - - - - a1275081 by Krzysztof Gogolewski at 2020-05-21T12:22:35-04:00 Add a regression test for #11506 The testcase works now. See explanation in https://gitlab.haskell.org/ghc/ghc/issues/11506#note_273202 - - - - - 8a816e5f by Krzysztof Gogolewski at 2020-05-21T12:23:55-04:00 Sort deterministically metric output Previously, we sorted according to the test name and way, but the metrics (max_bytes_used/peak_megabytes_allocated etc.) were appearing in nondeterministic order. - - - - - 566cc73f by Sylvain Henry at 2020-05-21T12:24:45-04:00 Move isDynLinkName into GHC.Types.Name It doesn't belong into GHC.Unit.State - - - - - d830bbc9 by Adam Sandberg Ericsson at 2020-05-23T13:36:20-04:00 docs: fix formatting and add some links [skip ci] - - - - - 49301ad6 by Andrew Martin at 2020-05-23T13:37:01-04:00 Implement cstringLength# and FinalPtr This function and its accompanying rule resolve issue #5218. A future PR to the bytestring library will make the internal Data.ByteString.Internal.unsafePackAddress compute string length with cstringLength#. This will improve the status quo because it is eligible for constant folding. Additionally, introduce a new data constructor to ForeignPtrContents named FinalPtr. This additional data constructor, when used in the IsString instance for ByteString, leads to more Core-to-Core optimization opportunities, fewer runtime allocations, and smaller binaries. Also, this commit re-exports all the functions from GHC.CString (including cstringLength#) in GHC.Exts. It also adds a new test driver. This test driver is used to perform substring matches on Core that is dumped after all the simplifier passes. In this commit, it is used to check that constant folding of cstringLength# works. - - - - - dcd6bdcc by Ben Gamari at 2020-05-23T13:37:48-04:00 simplCore: Ignore ticks in rule templates This fixes #17619, where a tick snuck in to the template of a rule, resulting in a panic during rule matching. The tick in question was introduced via post-inlining, as discussed in `Note [Simplifying rules]`. The solution we decided upon was to simply ignore ticks in the rule template, as discussed in `Note [Tick annotations in RULE matching]`. Fixes #18162. Fixes #17619. - - - - - 82cb8913 by John Ericson at 2020-05-23T13:38:32-04:00 Fix #18145 and also avoid needless work with implicit vars - `forAllOrNothing` now is monadic, so we can trace whether we bind an explicit `forall` or not. - #18145 arose because the free vars calculation was needlessly complex. It is now greatly simplified. - Replaced some other implicit var code with `filterFreeVarsToBind`. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - a60dc835 by Ben Gamari at 2020-05-23T13:39:12-04:00 Bump process submodule Fixes #17926. - - - - - 856adf54 by Ben Gamari at 2020-05-23T13:40:21-04:00 users-guide: Clarify meaning of -haddock flag Fixes #18206. - - - - - 7ae57afd by Ben Gamari at 2020-05-23T13:41:03-04:00 git: Add ignored commits file This can be used to tell git to ignore bulk renaming commits like the recently-finished module hierarchy refactoring. Configured with, git config blame.ignoreRevsFile .git-ignore-revs - - - - - 63d30e60 by jneira at 2020-05-24T01:54:42-04:00 Add hie-bios script for windows systems It is a direct translation of the sh script - - - - - 59182b88 by jneira at 2020-05-24T01:54:42-04:00 Honour previous values for CABAL and CABFLAGS The immediate goal is let the hie-bios.bat script set CABFLAGS with `-v0` and remove all cabal output except the compiler arguments - - - - - 932dc54e by jneira at 2020-05-24T01:54:42-04:00 Add specific configuration for windows in hie.yaml - - - - - e0eda070 by jneira at 2020-05-24T01:54:42-04:00 Remove not needed hie-bios output - - - - - a0ea59d6 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Move Config module into GHC.Settings - - - - - 37430251 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Core.Arity into GHC.Core.Opt.Arity - - - - - a426abb9 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Hs.Types into GHC.Hs.Type See discussion in https://gitlab.haskell.org/ghc/ghc/issues/13009#note_268610 - - - - - 1c91a7a0 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Bump haddock submodule - - - - - 66bd24d1 by Ryan Scott at 2020-05-24T01:56:03-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. - - - - - 01c43634 by Matthew Pickering at 2020-05-24T01:56:42-04:00 Remove unused hs-boot file - - - - - 7a07aa71 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix cross-compiler build (#16051) - - - - - 15ccca16 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix distDir per stage - - - - - b420fb24 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix hp2ps error during cross-compilation Fixed by @alp (see https://gitlab.haskell.org/ghc/ghc/issues/16051#note_274265) - - - - - cd339ef0 by Joshua Price at 2020-05-24T15:22:56-04:00 Make Unicode brackets opening/closing tokens (#18225) The tokens `[|`, `|]`, `(|`, and `|)` are opening/closing tokens as described in GHC Proposal #229. This commit makes the unicode variants (`⟦`, `⟧`, `⦇`, and `⦈`) act the same as their ASCII counterparts. - - - - - 013d7120 by Ben Gamari at 2020-05-25T09:48:17-04:00 Revert "Specify kind variables for inferred kinds in base." As noted in !3132, this has rather severe knock-on consequences in user-code. We'll need to revisit this before merging something along these lines. This reverts commit 9749fe1223d182b1f8e7e4f7378df661c509f396. - - - - - 4c4312ed by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Drop redundant ad-hoc boot module check To determine whether the module is a boot module Coverage.addTicksToBinds was checking for a `boot` suffix in the module source filename. This is quite ad-hoc and shouldn't be necessary; the callsite in `deSugar` already checks that the module isn't a boot module. - - - - - 1abf3c84 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make tickBoxCount strict This could otherwise easily cause a leak of (+) thunks. - - - - - b2813750 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make ccIndices strict This just seems like a good idea. - - - - - 02e278eb by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Don't produce ModBreaks if not HscInterpreted emptyModBreaks contains a bottom and consequently it's important that we don't use it unless necessary. - - - - - b8c014ce by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Factor out addMixEntry - - - - - 53814a64 by Zubin Duggal at 2020-05-26T03:03:24-04:00 Add info about typeclass evidence to .hie files See `testsuite/tests/hiefile/should_run/HieQueries.hs` and `testsuite/tests/hiefile/should_run/HieQueries.stdout` for an example of this We add two new fields, `EvidenceVarBind` and `EvidenceVarUse` to the `ContextInfo` associated with an Identifier. These are associated with the appropriate identifiers for the evidence variables collected when we come across `HsWrappers`, `TcEvBinds` and `IPBinds` while traversing the AST. Instance dictionary and superclass selector dictionaries from `tcg_insts` and classes defined in `tcg_tcs` are also recorded in the AST as originating from their definition span This allows us to save a complete picture of the evidence constructed by the constraint solver, and will let us report this to the user, enabling features like going to the instance definition from the invocation of a class method(or any other method taking a constraint) and finding all usages of a particular instance. Additionally, - Mark NodeInfo with an origin so we can differentiate between bindings origininating in the source vs those in ghc - Along with typeclass evidence info, also include information on Implicit Parameters - Add a few utility functions to HieUtils in order to query the new info Updates haddock submodule - - - - - 6604906c by Sebastian Graf at 2020-05-26T03:04:04-04:00 Make WorkWrap.Lib.isWorkerSmallEnough aware of the old arity We should allow a wrapper with up to 82 parameters when the original function had 82 parameters to begin with. I verified that this made no difference on NoFib, but then again it doesn't use huge records... Fixes #18122. - - - - - cf772f19 by Sylvain Henry at 2020-05-26T03:04:45-04:00 Enhance Note [About units] for Backpack - - - - - ede24126 by Takenobu Tani at 2020-05-27T00:13:55-04:00 core-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Core.hs <= coreSyn/CoreSyn.hs * GHC/Core/Coercion.hs <= types/Coercion.hs * GHC/Core/Coercion/Axiom.hs <= types/CoAxiom.hs * GHC/Core/Coercion/Opt.hs <= types/OptCoercion.hs * GHC/Core/DataCon.hs <= basicTypes/DataCon.hs * GHC/Core/FamInstEnv.hs <= types/FamInstEnv.hs * GHC/Core/Lint.hs <= coreSyn/CoreLint.hs * GHC/Core/Subst.hs <= coreSyn/CoreSubst.hs * GHC/Core/TyCo/Rep.hs <= types/TyCoRep.hs * GHC/Core/TyCon.hs <= types/TyCon.hs * GHC/Core/Type.hs <= types/Type.hs * GHC/Core/Unify.hs <= types/Unify.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/Var.hs <= basicTypes/Var.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [skip ci] - - - - - 04750304 by Ben Gamari at 2020-05-27T00:14:33-04:00 eventlog: Fix racy flushing Previously no attempt was made to avoid multiple threads writing their capability-local eventlog buffers to the eventlog writer simultaneously. This could result in multiple eventlog streams being interleaved. Fix this by documenting that the EventLogWriter's write() and flush() functions may be called reentrantly and fix the default writer to protect its FILE* by a mutex. Fixes #18210. - - - - - d6203f24 by Joshua Price at 2020-05-27T00:15:17-04:00 Make `identifier` parse unparenthesized `->` (#18060) - - - - - 28deee28 by Ben Gamari at 2020-05-28T16:23:21-04:00 GHC.Core.Unfold: Refactor traceInline This reduces duplication as well as fixes a bug wherein -dinlining-check would override -ddump-inlinings. Moreover, the new variant - - - - - 1f393e1e by Ben Gamari at 2020-05-28T16:23:21-04:00 Avoid unnecessary allocations due to tracing utilities While ticky-profiling the typechecker I noticed that hundreds of millions of SDocs are being allocated just in case -ddump-*-trace is enabled. This is awful. We avoid this by ensuring that the dump flag check is inlined into the call site, ensuring that the tracing document needn't be allocated unless it's actually needed. See Note [INLINE conditional tracing utilities] for details. Fixes #18168. Metric Decrease: T9961 haddock.Cabal haddock.base haddock.compiler - - - - - 5f621a78 by Vladislav Zavialov at 2020-05-28T16:23:58-04:00 Add Semigroup/Monoid for Q (#18123) - - - - - dc5f004c by Xavier Denis at 2020-05-28T16:24:37-04:00 Fix #18071 Run the core linter on candidate instances to ensure they are well-kinded. Better handle quantified constraints by using a CtWanted to avoid having unsolved constraints thrown away at the end by the solver. - - - - - 10e6982c by Sebastian Graf at 2020-05-28T16:25:14-04:00 FloatOut: Only eta-expand dead-end RHS if arity will increase (#18231) Otherwise we risk turning trivial RHS into non-trivial RHS, introducing unnecessary bindings in the next Simplifier run, resulting in more churn. Fixes #18231. - - - - - 08dab5f7 by Sebastian Graf at 2020-05-28T16:25:14-04:00 DmdAnal: Recognise precise exceptions from case alternatives (#18086) Consider ```hs m :: IO () m = do putStrLn "foo" error "bar" ``` `m` (from #18086) always throws a (precise or imprecise) exception or diverges. Yet demand analysis infers `<L,A>` as demand signature instead of `<L,A>x` for it. That's because the demand analyser sees `putStrLn` occuring in a case scrutinee and decides that it has to `deferAfterPreciseException`, because `putStrLn` throws a precise exception on some control flow paths. This will mask the `botDiv` `Divergence`of the single case alt containing `error` to `topDiv`. Since `putStrLn` has `topDiv` itself, the final `Divergence` is `topDiv`. This is easily fixed: `deferAfterPreciseException` works by `lub`ing with the demand type of a virtual case branch denoting the precise exceptional control flow. We used `nopDmdType` before, but we can be more precise and use `exnDmdType`, which is `nopDmdType` with `exnDiv`. Now the `Divergence` from the case alt will degrade `botDiv` to `exnDiv` instead of `topDiv`, which combines with the result from the scrutinee to `exnDiv`, and all is well. Fixes #18086. - - - - - aef95f11 by Ben Gamari at 2020-05-28T16:25:53-04:00 Ticky-ticky: Record DataCon name in ticker name This makes it significantly easier to spot the nature of allocations regressions and comes at a reasonably low cost. - - - - - 8f021b8c by Ben Gamari at 2020-05-28T16:26:34-04:00 hadrian: Don't track GHC's verbosity argument Teach hadrian to ignore GHC's -v argument in its recompilation check, thus fixing #18131. - - - - - 13d9380b by Ben Gamari at 2020-05-28T16:27:20-04:00 Rip out CmmStackInfo(updfr_space) As noted in #18232, this field is currently completely unused and moreover doesn't have a clear meaning. - - - - - f10d11fa by Andreas Klebinger at 2020-05-29T01:38:42-04:00 Fix "build/elem" RULE. An redundant constraint prevented the rule from matching. Fixing this allows a call to elem on a known list to be translated into a series of equality checks, and eventually a simple case expression. Surprisingly this seems to regress elem for strings. To avoid this we now also allow foldrCString to inline and add an UTF8 variant. This results in elem being compiled to a tight non-allocating loop over the primitive string literal which performs a linear search. In the process this commit adds UTF8 variants for some of the functions in GHC.CString. This is required to make this work for both ASCII and UTF8 strings. There are also small tweaks to the CString related rules. We now allow ourselfes the luxury to compare the folding function via eqExpr, which helps to ensure the rule fires before we inline foldrCString*. Together with a few changes to allow matching on both the UTF8 and ASCII variants of the CString functions. - - - - - bbeb2389 by Ben Gamari at 2020-05-29T01:39:19-04:00 CoreToStg: Add Outputable ArgInfo instance - - - - - 0e3361ca by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Make Lint check return type of a join point Consider join x = rhs in body It's important that the type of 'rhs' is the same as the type of 'body', but Lint wasn't checking that invariant. Now it does! This was exposed by investigation into !3113. - - - - - c49f7df0 by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Do not float join points in exprIsConApp_maybe We hvae been making exprIsConApp_maybe cleverer in recent times: commit b78cc64e923716ac0512c299f42d4d0012306c05 Date: Thu Nov 15 17:14:31 2018 +0100 Make constructor wrappers inline only during the final phase commit 7833cf407d1f608bebb1d38bb99d3035d8d735e6 Date: Thu Jan 24 17:58:50 2019 +0100 Look through newtype wrappers (Trac #16254) commit c25b135ff5b9c69a90df0ccf51b04952c2dc6ee1 Date: Thu Feb 21 12:03:22 2019 +0000 Fix exprIsConApp_maybe But alas there was still a bug, now immortalised in Note [Don't float join points] in SimpleOpt. It's quite hard to trigger because it requires a dead join point, but it came up when compiling Cabal Cabal.Distribution.Fields.Lexer.hs, when working on !3113. Happily, the fix is extremly easy. Finding the bug was not so easy. - - - - - 46720997 by Ben Gamari at 2020-05-29T01:39:19-04:00 Allow simplification through runRW# Because runRW# inlines so late, we were previously able to do very little simplification across it. For instance, given even a simple program like case runRW# (\s -> let n = I# 42# in n) of I# n# -> f n# we previously had no way to avoid the allocation of the I#. This patch allows the simplifier to push strict contexts into the continuation of a runRW# application, as explained in in Note [Simplification of runRW#] in GHC.CoreToStg.Prep. Fixes #15127. Metric Increase: T9961 Metric Decrease: ManyConstructors Co-Authored-By: Simon Peyton-Jone <simonpj at microsoft.com> - - - - - 277c2f26 by Ben Gamari at 2020-05-29T01:39:55-04:00 Eta expand un-saturated primops Now since we no longer try to predict CAFfyness we have no need for the solution to #16846. Eta expanding unsaturated primop applications is conceptually simpler, especially in the presence of levity polymorphism. This essentially reverts cac8dc9f51e31e4c0a6cd9bc302f7e1bc7c03beb, as suggested in #18079. Closes #18079. - - - - - f44d7ae0 by Simon Jakobi at 2020-05-29T01:40:34-04:00 base: Scrap deprecation plan for Data.Monoid.{First,Last} See the discussion on the libraries mailing list for context: https://mail.haskell.org/pipermail/libraries/2020-April/030357.html - - - - - 8b494895 by Jeremy Schlatter at 2020-05-29T01:41:12-04:00 Fix typo in documentation - - - - - 998450f4 by Gleb Popov at 2020-05-29T01:41:53-04:00 Always define USE_PTHREAD_FOR_ITIMER for FreeBSD. - - - - - f9a513e0 by Alp Mestanogullari at 2020-05-29T01:42:36-04:00 hadrian: introduce 'install' target Its logic is very simple. It `need`s the `binary-dist-dir` target and runs suitable `configure` and `make install` commands for the user. A new `--prefix` command line argument is introduced to specify where GHC should be installed. - - - - - 67738db1 by Travis Whitaker at 2020-05-29T13:34:48-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. - - - - - aac19e6c by Peter Trommler at 2020-05-29T13:35:24-04:00 PPC NCG: No per-symbol .section ".toc" directives All position independent symbols are collected during code generation and emitted in one go. Prepending each symbol with a .section ".toc" directive is redundant. This patch drops the per-symbol directives leading to smaller assembler files. Fixes #18250 - - - - - 4413828b by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Teach getNumProcessors to return available processors Previously we would report the number of physical processors, which can be quite wrong in a containerized setting. Now we rather return how many processors are in our affinity mask when possible. I also refactored the code to prefer platform-specific since this will report logical CPUs instead of physical (using `machdep.cpu.thread_count` on Darwin and `cpuset_getaffinity` on FreeBSD). Fixes #14781. - - - - - 1449435c by Ben Gamari at 2020-05-30T06:07:31-04:00 users-guide: Note change in getNumProcessors in users guide - - - - - 3d960169 by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Drop compatibility shims for Windows Vista We can now assume that the thread and processor group interfaces are available. - - - - - 7f8f948c by Peter Trommler at 2020-05-30T06:08:07-04:00 PPC NCG: Fix .size directive on powerpc64 ELF v1 Thanks to Sergei Trofimovich for pointing out the issue. Fixes #18237 - - - - - 7c555b05 by Andreas Klebinger at 2020-05-30T06:08:43-04:00 Optimize GHC.Utils.Monad. Many functions in this module are recursive and as such are marked loop breakers. Which means they are unlikely to get an unfolding. This is *bad*. We always want to specialize them to specific Monads. Which requires a visible unfolding at the use site. I rewrote the recursive ones from: foo f x = ... foo x' ... to foo f x = go x where go x = ... As well as giving some pragmas to make all of them available for specialization. The end result is a reduction of allocations of about -1.4% for nofib/spectral/simple/Main.hs when compiled with `-O`. ------------------------- Metric Decrease: T12425 T14683 T5631 T9233 T9675 T9961 WWRec ------------------------- - - - - - 8b1cb5df by Ben Gamari at 2020-05-30T06:09:20-04:00 Windows: Bump Windows toolchain to 0.2 - - - - - 6947231a by Zubin Duggal at 2020-05-30T06:10:02-04:00 Simplify contexts in GHC.Iface.Ext.Ast - - - - - 2ee4f36c by Daniel Gröber at 2020-06-01T06:32:56-04:00 Cleanup OVERWRITING_CLOSURE logic The code is just more confusing than it needs to be. We don't need to mix the threaded check with the ldv profiling check since ldv's init already checks for this. Hence they can be two separate checks. Taking the sanity checking into account is also cleaner via DebugFlags.sanity. No need for checking the DEBUG define. The ZERO_SLOP_FOR_LDV_PROF and ZERO_SLOP_FOR_SANITY_CHECK definitions the old code had also make things a lot more opaque IMO so I removed those. - - - - - 6159559b by Daniel Gröber at 2020-06-01T06:32:56-04:00 Fix OVERWRITING_CLOSURE assuming closures are not inherently used The new ASSERT in LDV_recordDead() was being tripped up by MVars when removeFromMVarBlockedQueue() calls OVERWRITING_CLOSURE() via OVERWRITE_INFO(). - - - - - 38992085 by Daniel Gröber at 2020-06-01T06:32:56-04:00 Always zero shrunk mutable array slop when profiling When shrinking arrays in the profiling way we currently don't always zero the leftover slop. This means we can't traverse such closures in the heap profiler. The old Note [zeroing slop] and #8402 have some rationale for why this is so but I belive the reasoning doesn't apply to mutable closures. There users already have to ensure multiple threads don't step on each other's toes so zeroing should be safe. - - - - - b0c1f2a6 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for #18151 - - - - - 9a99a178 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for desugaring of PostfixOperators - - - - - 2b89ca5b by Ben Gamari at 2020-06-01T06:33:37-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. - - - - - d412d7a3 by Kirill Elagin at 2020-06-01T06:34:21-04:00 Winferred-safe-imports: Do not exit with error Currently, when -Winferred-safe-imports is enabled, even when it is not turned into an error, the compiler will still exit with exit code 1 if this warning was emitted. Make sure it is really treated as a warning. - - - - - f945eea5 by Ben Gamari at 2020-06-01T06:34:58-04:00 nonmoving: Optimise log2_ceil - - - - - aab606e4 by Bodigrim at 2020-06-01T06:35:36-04:00 Clarify description of fromListN - - - - - 7e5220e2 by Bodigrim at 2020-06-01T06:35:36-04:00 Apply suggestion to libraries/base/GHC/Exts.hs - - - - - f3fb1ce9 by fendor at 2020-06-01T06:36:18-04:00 Add `isInScope` check to `lintCoercion` Mirrors the behaviour of `lintType`. - - - - - 5ac4d946 by fendor at 2020-06-01T06:36:18-04:00 Lint rhs of IfaceRule - - - - - 1cef6126 by Jeremy Schlatter at 2020-06-01T06:37:00-04:00 Fix wording in documentation The duplicate "orphan instance" phrase here doesn't make sense, and was probably an accident. - - - - - 5aaf08f2 by Takenobu Tani at 2020-06-01T06:37:43-04:00 configure: Modify aclocal.m4 according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * Rename: * compiler/GHC/Parser.hs <= compiler/parser/Parser.hs * compiler/GHC/Parser/Lexer.hs <= compiler/Parser/Lexer.hs * Add: * compiler/GHC/Cmm/Lexer.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular - - - - - 15857ad8 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Don't fail if we can't unlink __symlink_test Afterall, it's possible we were unable to create it due to lack of symlink permission. - - - - - 4a7229ef by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Refactor ghostscript detection Tamar reported that he saw crashes due to unhandled exceptions. - - - - - 2ab37eaf by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/perf_notes: Fix ill-typed assignments - - - - - e45d5b66 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/testutil: Fix bytes/str mismatch - - - - - 7002d0cb by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Work around spurious mypy failure - - - - - 11390e3a by Takenobu Tani at 2020-06-01T06:39:05-04:00 Clean up file paths for new module hierarchy This updates comments only. This patch replaces file references according to new module hierarchy. See also: * https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular * https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 8f2e5732 by Takenobu Tani at 2020-06-01T06:39:05-04:00 Modify file paths to module paths for new module hierarchy This updates comments only. This patch replaces module references according to new module hierarchy [1][2]. For files under the `compiler/` directory, I replace them as module paths instead of file paths. For instance, `GHC.Unit.State` instead of `compiler/GHC/Unit/State.hs` [3]. For current and future haddock's markup, this patch encloses the module name with "" [4]. [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 [3]: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3375#note_276613 [4]: https://haskell-haddock.readthedocs.io/en/latest/markup.html#linking-to-modules - - - - - 68b71c4a by Tom Ellis at 2020-06-01T06:39:55-04:00 Rename the singleton tuple GHC.Tuple.Unit to GHC.Tuple.Solo - - - - - 95da76c2 by Sylvain Henry at 2020-06-01T06:40:41-04:00 Hadrian: fix binary-dist target for cross-compilation - - - - - 730fcd54 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for the @-operator Since GHC diverges from the Haskell Report by allowing the user to define (@) as an infix operator, we better give a good error message when the user does so unintentionally. In general, this is rather hard to do, as some failures will be discovered only in the renamer or the type checker: x :: (Integer, Integer) x @ (a, b) = (1, 2) This patch does *not* address this general case. However, it gives much better error messages when the binding is not syntactically valid: pairs xs @ (_:xs') = zip xs xs' Before this patch, the error message was rather puzzling: <interactive>:1:1: error: Parse error in pattern: pairs After this patch, the error message includes a hint: <interactive>:1:1: error: Parse error in pattern: pairs In a function binding for the ‘@’ operator. Perhaps you meant an as-pattern, which must not be surrounded by whitespace - - - - - 0fde5377 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TypeApplications With this patch, we always parse f @t as a type application, thereby producing better error messages. This steals two syntactic forms: * Prefix form of the @-operator in expressions. Since the @-operator is a divergence from the Haskell Report anyway, this is not a major loss. * Prefix form of @-patterns. Since we are stealing loose infix form anyway, might as well sacrifice the prefix form for the sake of much better error messages. - - - - - c68e7e1e by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TemplateHaskellQuotes While [e| |], [t| |], [d| |], and so on, steal syntax from list comprehensions, [| |] and [|| ||] do not steal any syntax. Thus we can improve error messages by always accepting them in the lexer. Turns out the renamer already performs necessary validation. - - - - - 120aedbd by Ben Gamari at 2020-06-01T16:07:02-04:00 gitlab-ci: Disable use of ld.lld on ARMv7 It turns out that lld non-deterministically fails on ARMv7. I suspect this may be due to the a kernel regression as this only started happening when we upgraded to 5.4. Nevertheless, easily avoided by simply sticking with gold. Works around #18280. - - - - - d6279ff0 by Ben Gamari at 2020-06-02T13:03:30-04:00 gitlab-ci: Ensure that workaround for #18280 applies to bindisttest We need to ensure that the `configure` flags working around #18280 are propagated to the bindisttest `configure` as well. - - - - - cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00 gitlab-ci: Allow ARMv7 job to fail Due to #18298. - - - - - 32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00 Clean up boot vs non-boot disambiguating types We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule. - - - - - c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00 docs: Add more details on InterruptibleFFI. Details from https://gitlab.haskell.org/ghc/ghc/issues/8684 and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430 - - - - - 1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00 Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr. MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd. This regression did not make it into a release of GHC. Here, the original behavior is restored, and FinalPtr is given the same treatment as PlainPtr. - - - - - 2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00 Fix documentation on type families not being extracted It looks like the location of the Names used for CoAxioms on type families are now located at their type constructors. Previously, Docs.hs thought the Names were located in the RHS, so the RealSrcSpan in the instanceMap and getInstLoc didn't match up. Fixes #18241 - - - - - 6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00 GHC.Hs.Instances: Compile with -O0 This module contains exclusively Data instances, which are going to be slow no matter what we do. Furthermore, they are incredibly slow to compile with optimisation (see #9557). Consequently we compile this with -O0. See #18254. - - - - - c330331a by nineonine at 2020-06-04T04:37:59-04:00 Add test for #17669 - - - - - cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00 rts: Add Windows-specific implementation of rtsSleep Previously we would use the POSIX path, which uses `nanosleep`. However, it turns out that `nanosleep` is provided by `libpthread` on Windows. In general we don't want to incur such a dependency. Avoid this by simply using `Sleep` on Windows. Fixes #18272. - - - - - ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00 compiler: Disable use of process jobs with process < 1.6.9 Due to #17926. - - - - - 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 6c888db3 by Simon Peyton Jones at 2020-07-23T12:57:10+01:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 16 changed files: - + .git-ignore-revs - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/linters/check-cpp.py - .gitlab/merge_request_templates/merge-request.md - .gitlab/test-metrics.sh - .gitmodules - CODEOWNERS - Makefile - aclocal.m4 - compiler/GHC.hs - + compiler/GHC/Builtin/Names.hs - + compiler/GHC/Builtin/Names/TH.hs - + compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps.hs-boot - + compiler/GHC/Builtin/RebindableNames.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e245779ff0d183c6b1040ef25583f7083617f0a6...6c888db3275310c2cf875fb82e354ab567d2f84c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e245779ff0d183c6b1040ef25583f7083617f0a6...6c888db3275310c2cf875fb82e354ab567d2f84c You're receiving 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 Jul 23 13:01:24 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Thu, 23 Jul 2020 09:01:24 -0400 Subject: [Git][ghc/ghc][wip/spj-wibbles] Remove an incorrect WARN in extendLocalRdrEnv Message-ID: <5f198a24aa794_80b3f84868c382846899f7@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/spj-wibbles at Glasgow Haskell Compiler / GHC Commits: a81a9a72 by Simon Peyton Jones at 2020-07-23T14:00:19+01:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 2 changed files: - compiler/GHC/Rename/Pat.hs - compiler/GHC/Types/Name/Reader.hs Changes: ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -236,19 +236,25 @@ newPatName (LetMk is_top fix_env) rdr_name do { name <- case is_top of NotTopLevel -> newLocalBndrRn rdr_name TopLevel -> newTopSrcBinder rdr_name - ; bindLocalNames [name] $ -- Do *not* use bindLocalNameFV here - -- See Note [View pattern usage] + ; bindLocalNames [name] $ + -- Do *not* use bindLocalNameFV here; + -- see Note [View pattern usage] + -- For the TopLevel case + -- see Note [bindLocalNames for an External name] addLocalFixities fix_env [name] $ thing_inside name }) - -- Note: the bindLocalNames is somewhat suspicious - -- because it binds a top-level name as a local name. - -- however, this binding seems to work, and it only exists for - -- the duration of the patterns and the continuation; - -- then the top-level name is added to the global env - -- before going on to the RHSes (see GHC.Rename.Module). +{- Note [bindLocalNames for an External name] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The use of bindLocalNames is somewhat suspicious + because it binds a top-level External name in the LocalRdrEnv. + c.f. Note [LocalRdrEnv] in GHC.Types.Name.Reader. + + However, this odd binding seems to work, and it only exists for + the duration of the patterns and the continuation; + then the top-level name is added to the global env + before going on to the RHSes (see GHC.Rename.Module). -{- Note [View pattern usage] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -338,13 +338,24 @@ instance Ord RdrName where ************************************************************************ -} +{- Note [LocalRdrEnv] +~~~~~~~~~~~~~~~~~~~~~ +The LocalRdrEnv is used to store local bindings (let, where, lambda, case). + +* It is keyed by OccName, because we never use it for qualified names. + +* It maps the OccName to a Name. That Name is almost always an + Internal Name, but (hackily) it can be External too for top-level + pattern bindings. See Note [bindLocalNames for an External name] + in GHC.Rename.Pat + +* We keep the current mapping (lre_env), *and* the set of all Names in + scope (lre_in_scope). Reason: see Note [Splicing Exact names] in + GHC.Rename.Env. +-} + -- | Local Reader Environment --- --- This environment is used to store local bindings --- (@let@, @where@, lambda, @case@). --- It is keyed by OccName, because we never use it for qualified names --- We keep the current mapping, *and* the set of all Names in scope --- Reason: see Note [Splicing Exact names] in "GHC.Rename.Env" +-- See Note [LocalRdrEnv] data LocalRdrEnv = LRE { lre_env :: OccEnv Name , lre_in_scope :: NameSet } @@ -364,16 +375,15 @@ emptyLocalRdrEnv = LRE { lre_env = emptyOccEnv , lre_in_scope = emptyNameSet } extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv --- The Name should be a non-top-level thing +-- See Note [LocalRdrEnv] extendLocalRdrEnv lre@(LRE { lre_env = env, lre_in_scope = ns }) name - = WARN( isExternalName name, ppr name ) - lre { lre_env = extendOccEnv env (nameOccName name) name + = lre { lre_env = extendOccEnv env (nameOccName name) name , lre_in_scope = extendNameSet ns name } extendLocalRdrEnvList :: LocalRdrEnv -> [Name] -> LocalRdrEnv +-- See Note [LocalRdrEnv] extendLocalRdrEnvList lre@(LRE { lre_env = env, lre_in_scope = ns }) names - = WARN( any isExternalName names, ppr names ) - lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] + = lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] , lre_in_scope = extendNameSetList ns names } lookupLocalRdrEnv :: LocalRdrEnv -> RdrName -> Maybe Name View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a81a9a729f9d18d2576d4026ff955fce1253dbd2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a81a9a729f9d18d2576d4026ff955fce1253dbd2 You're receiving 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 Jul 23 14:36:10 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Thu, 23 Jul 2020 10:36:10 -0400 Subject: [Git][ghc/ghc][wip/T18451] Care with occCheckExpand in kind of occurrences Message-ID: <5f19a05a6cd53_80b3f84868c382847232af@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18451 at Glasgow Haskell Compiler / GHC Commits: 28a565dc by Simon Peyton Jones at 2020-07-23T15:35:34+01:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 10 changed files: - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Utils/Unify.hs - + testsuite/tests/polykinds/T18451.hs - + testsuite/tests/polykinds/T18451.stderr - + testsuite/tests/polykinds/T18451a.hs - + testsuite/tests/polykinds/T18451a.stderr - + testsuite/tests/polykinds/T18451b.hs - + testsuite/tests/polykinds/T18451b.stderr - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -34,10 +34,9 @@ import {-# SOURCE #-} GHC.CoreToIface , toIfaceTyCon, toIfaceTcArgs, toIfaceCoercionX ) import {-# SOURCE #-} GHC.Core.DataCon - ( dataConFullSig , dataConUserTyVarBinders - , DataCon ) + ( dataConFullSig , dataConUserTyVarBinders, DataCon ) -import GHC.Core.Type ( isLiftedTypeKind, pattern One, pattern Many ) +import GHC.Core.Type ( pickyIsLiftedTypeKind, pattern One, pattern Many ) import GHC.Core.TyCon import GHC.Core.TyCo.Rep @@ -192,11 +191,35 @@ pprTyVar :: TyVar -> SDoc -- pprIfaceTvBndr is minimal, and the loss of uniques etc in -- debug printing is disastrous pprTyVar tv - | isLiftedTypeKind kind = ppr tv - | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) + | pickyIsLiftedTypeKind kind = ppr tv -- See Note [Suppressing * kinds] + | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) where kind = tyVarKind tv +{- Note [Suppressing * kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Generally we want to print + forall a. a->a +not forall (a::*). a->a +or forall (a::Type). a->a +That is, for brevity we suppress a kind ascription of '*' (or Type). + +But what if the kind is (Const Type x)? + type Const p q = p + +Then (Const Type x) is just a long way of saying Type. But it may be +jolly confusing to suppress the 'x'. Suppose we have (polykinds/T18451a) + foo :: forall a b (c :: Const Type b). Proxy '[a, c] + +Then this error message + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) +would be much less helpful if we suppressed the kind ascription on 'a'. + +Hence the use of pickyIsLiftedTypeKind. +-} + ----------------- debugPprType :: Type -> SDoc -- ^ debugPprType is a simple pretty printer that prints a type ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -120,7 +120,7 @@ module GHC.Core.Type ( -- *** Levity and boxity isLiftedType_maybe, - isLiftedTypeKind, isUnliftedTypeKind, + isLiftedTypeKind, isUnliftedTypeKind, pickyIsLiftedTypeKind, isLiftedRuntimeRep, isUnliftedRuntimeRep, isUnliftedType, mightBeUnliftedType, isUnboxedTupleType, isUnboxedSumType, isAlgType, isDataFamilyAppType, @@ -554,6 +554,23 @@ isLiftedTypeKind kind Just rep -> isLiftedRuntimeRep rep Nothing -> False +pickyIsLiftedTypeKind :: Kind -> Bool +-- Checks whether the kind is literally +-- TYPE LiftedRep +-- or Type +-- without expanding type synonyms or anything +-- Used only when deciding whether to suppress the ":: *" in +-- (a :: *) when printing kinded type variables +-- See Note [Suppressing * kinds] in GHC.Core.TyCo.Ppr +pickyIsLiftedTypeKind kind + | TyConApp tc [arg] <- kind + , tc `hasKey` tYPETyConKey + , TyConApp rr_tc [] <- arg + , rr_tc `hasKey` liftedRepDataConKey = True + | TyConApp tc [] <- kind + , tc `hasKey` liftedTypeKindTyConKey = True + | otherwise = False + isLiftedRuntimeRep :: Type -> Bool -- isLiftedRuntimeRep is true of LiftedRep :: RuntimeRep -- False of type variables (a :: RuntimeRep) @@ -2619,6 +2636,46 @@ prefer doing inner expansions first. For example, We have occCheckExpand b (F (G b)) = Just (F Char) even though we could also expand F to get rid of b. + +Note [Occurrence checking: look inside kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we are considering unifying + (alpha :: *) ~ Int -> (beta :: alpha -> alpha) +This may be an error (what is that alpha doing inside beta's kind?), +but we must not make the mistake of actually unifying or we'll +build an infinite data structure. So when looking for occurrences +of alpha in the rhs, we must look in the kinds of type variables +that occur there. + +occCheckExpand tries to expand type synonyms to remove +unnecessary occurrences of a variable, and thereby get past an +occurs-check failure. This is good; but + we can't do it in the /kind/ of a variable /occurrence/ + +For example #18451 built an infinite type: + type Const a b = a + data SameKind :: k -> k -> Type + type T (k :: Const Type a) = forall (b :: k). SameKind a b + +We have + b :: k + k :: Const Type a + a :: k (must be same as b) + +So if we aren't careful, a's kind mentions a, which is bad. +And expanding an /occurrence/ of 'a' doesn't help, because the +/binding site/ is the master copy and all the occurrences should +match it. + +Here's a related example: + f :: forall a b (c :: Const Type b). Proxy '[a, c] + +The list means that 'a' gets the same kind as 'c'; but that +kind mentions 'b', so the binders are out of order. + +Bottom line: in occCheckExpand, do not expand inside the kinds +of occurrences. See bad_var_occ in occCheckExpand. And +see #18451 for more debate. -} occCheckExpand :: [Var] -> Type -> Maybe Type @@ -2639,11 +2696,10 @@ occCheckExpand vs_to_avoid ty -- The VarSet is the set of variables we are trying to avoid -- The VarEnv carries mappings necessary -- because of kind expansion - go cxt@(as, env) (TyVarTy tv') - | tv' `elemVarSet` as = Nothing - | Just tv'' <- lookupVarEnv env tv' = return (mkTyVarTy tv'') - | otherwise = do { tv'' <- go_var cxt tv' - ; return (mkTyVarTy tv'') } + go (as, env) ty@(TyVarTy tv) + | Just tv' <- lookupVarEnv env tv = return (mkTyVarTy tv') + | bad_var_occ as tv = Nothing + | otherwise = return ty go _ ty@(LitTy {}) = return ty go cxt (AppTy ty1 ty2) = do { ty1' <- go cxt ty1 @@ -2656,7 +2712,7 @@ occCheckExpand vs_to_avoid ty ; return (ty { ft_mult = w', ft_arg = ty1', ft_res = ty2' }) } go cxt@(as, env) (ForAllTy (Bndr tv vis) body_ty) = do { ki' <- go cxt (varType tv) - ; let tv' = setVarType tv ki' + ; let tv' = setVarType tv ki' env' = extendVarEnv env tv tv' as' = as `delVarSet` tv ; body' <- go (as', env') body_ty @@ -2680,9 +2736,12 @@ occCheckExpand vs_to_avoid ty ; return (mkCoercionTy co') } ------------------ - go_var cxt v = updateVarTypeM (go cxt) v - -- Works for TyVar and CoVar - -- See Note [Occurrence checking: look inside kinds] + bad_var_occ :: VarSet -> Var -> Bool + -- Works for TyVar and CoVar + -- See Note [Occurrence checking: look inside kinds] + bad_var_occ vs_to_avoid v + = v `elemVarSet` vs_to_avoid + || tyCoVarsOfType (varType v) `intersectsVarSet` vs_to_avoid ------------------ go_mco _ MRefl = return MRefl @@ -2712,13 +2771,15 @@ occCheckExpand vs_to_avoid ty ; co2' <- go_co cxt co2 ; w' <- go_co cxt w ; return (mkFunCo r w' co1' co2') } - go_co cxt@(as,env) (CoVarCo c) - | c `elemVarSet` as = Nothing + go_co (as,env) co@(CoVarCo c) | Just c' <- lookupVarEnv env c = return (mkCoVarCo c') - | otherwise = do { c' <- go_var cxt c - ; return (mkCoVarCo c') } - go_co cxt (HoleCo h) = do { c' <- go_var cxt (ch_co_var h) - ; return (HoleCo (h { ch_co_var = c' })) } + | bad_var_occ as c = Nothing + | otherwise = return co + + go_co (as,_) co@(HoleCo h) + | bad_var_occ as (ch_co_var h) = Nothing + | otherwise = return co + go_co cxt (AxiomInstCo ax ind args) = do { args' <- mapM (go_co cxt) args ; return (mkAxiomInstCo ax ind args') } go_co cxt (UnivCo p r ty1 ty2) = do { p' <- go_prov cxt p ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -1879,21 +1879,8 @@ matchExpectedFunKind hs_ty n k = go n k ********************************************************************* -} -{- Note [Occurrence checking: look inside kinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Suppose we are considering unifying - (alpha :: *) ~ Int -> (beta :: alpha -> alpha) -This may be an error (what is that alpha doing inside beta's kind?), -but we must not make the mistake of actually unifying or we'll -build an infinite data structure. So when looking for occurrences -of alpha in the rhs, we must look in the kinds of type variables -that occur there. - -NB: we may be able to remove the problem via expansion; see - Note [Occurs check expansion]. So we have to try that. - -Note [Checking for foralls] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Checking for foralls] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unless we have -XImpredicativeTypes (which is a totally unsupported feature), we do not want to unify alpha ~ (forall a. a->a) -> Int @@ -1906,10 +1893,10 @@ Consider (alpha :: forall k. k->*) ~ (beta :: forall k. k->*) This is legal; e.g. dependent/should_compile/T11635. -We don't want to reject it because of the forall in beta's kind, -but (see Note [Occurrence checking: look inside kinds]) we do -need to look in beta's kind. So we carry a flag saying if a 'forall' -is OK, and switch the flag on when stepping inside a kind. +We don't want to reject it because of the forall in beta's kind, but +(see Note [Occurrence checking: look inside kinds] in GHC.Core.Type) +we do need to look in beta's kind. So we carry a flag saying if a +'forall' is OK, and switch the flag on when stepping inside a kind. Why is it OK? Why does it not count as impredicative polymorphism? The reason foralls are bad is because we reply on "seeing" foralls @@ -2030,6 +2017,7 @@ preCheck dflags ty_fam_ok tv ty | tv == tv' = MTVU_Occurs | otherwise = fast_check_occ (tyVarKind tv') -- See Note [Occurrence checking: look inside kinds] + -- in GHC.Core.Type fast_check (TyConApp tc tys) | bad_tc tc = MTVU_Bad ===================================== testsuite/tests/polykinds/T18451.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind + +type Const a b = a +data SameKind :: k -> k -> Type + +type T (k :: Const Type a) = forall (b :: k). SameKind a b ===================================== testsuite/tests/polykinds/T18451.stderr ===================================== @@ -0,0 +1,9 @@ + +T18451.hs:10:58: error: + • Expected kind ‘k0’, but ‘b’ has kind ‘k’ + • In the second argument of ‘SameKind’, namely ‘b’ + In the type ‘forall (b :: k). SameKind a b’ + In the type declaration for ‘T’ + • Type variable kinds: + a :: k0 + k :: Const (*) a ===================================== testsuite/tests/polykinds/T18451a.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451a.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/T18451b.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451b.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451b.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -220,3 +220,6 @@ test('CuskFam', normal, compile, ['']) test('T17841', normal, compile_fail, ['']) test('T17963', normal, compile_fail, ['']) test('T18300', normal, compile_fail, ['']) +test('T18451', normal, compile_fail, ['']) +test('T18451a', normal, compile_fail, ['']) +test('T18451b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/28a565dce0816786df32c002a0a0d8df881bbbd1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/28a565dce0816786df32c002a0a0d8df881bbbd1 You're receiving 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 Jul 23 15:11:21 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 23 Jul 2020 11:11:21 -0400 Subject: [Git][ghc/ghc][wip/backports] Fix specialisation for DFuns Message-ID: <5f19a8998e930_80b3f849248fe08473288d@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: f579acd1 by Simon Peyton Jones at 2020-07-23T11:11:07-04:00 Fix specialisation for DFuns When specialising a DFun we must take care to saturate the unfolding. See Note [Specialising DFuns] in Specialise. Fixes #18120 (cherry picked from commit 88e3c8150d2b2d96c3ebc0b2942c9af44071c511) - - - - - 6 changed files: - compiler/coreSyn/CoreUnfold.hs - compiler/deSugar/DsBinds.hs - compiler/specialise/Specialise.hs - compiler/typecheck/TcSigs.hs - + testsuite/tests/simplCore/should_compile/T18120.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/coreSyn/CoreUnfold.hs ===================================== @@ -169,47 +169,47 @@ mkInlinableUnfolding dflags expr where expr' = simpleOptExpr dflags expr -specUnfolding :: DynFlags -> Id -> [Var] -> (CoreExpr -> CoreExpr) -> Arity +specUnfolding :: DynFlags + -> [Var] -> (CoreExpr -> CoreExpr) + -> [CoreArg] -- LHS arguments in the RULE -> Unfolding -> Unfolding -- See Note [Specialising unfoldings] --- specUnfolding spec_bndrs spec_app arity_decrease unf --- = \spec_bndrs. spec_app( unf ) +-- specUnfolding spec_bndrs spec_args unf +-- = \spec_bndrs. unf spec_args -- -specUnfolding dflags fn spec_bndrs spec_app arity_decrease +specUnfolding dflags spec_bndrs spec_app rule_lhs_args df@(DFunUnfolding { df_bndrs = old_bndrs, df_con = con, df_args = args }) - = ASSERT2( arity_decrease == count isId old_bndrs - count isId spec_bndrs - , ppr df $$ ppr spec_bndrs $$ ppr (spec_app (Var fn)) $$ ppr arity_decrease ) + = ASSERT2( rule_lhs_args `equalLength` old_bndrs + , ppr df $$ ppr rule_lhs_args ) + -- For this ASSERT see Note [DFunUnfoldings] in GHC.Core.Opt.Specialise mkDFunUnfolding spec_bndrs con (map spec_arg args) - -- There is a hard-to-check assumption here that the spec_app has - -- enough applications to exactly saturate the old_bndrs -- For DFunUnfoldings we transform - -- \old_bndrs. MkD ... + -- \obs. MkD ... -- to - -- \new_bndrs. MkD (spec_app(\old_bndrs. )) ... ditto - -- The ASSERT checks the value part of that + -- \sbs. MkD ((\obs. ) spec_args) ... ditto where - spec_arg arg = simpleOptExpr dflags (spec_app (mkLams old_bndrs arg)) + spec_arg arg = simpleOptExpr dflags $ + spec_app (mkLams old_bndrs arg) -- The beta-redexes created by spec_app will be -- simplified away by simplOptExpr -specUnfolding dflags _ spec_bndrs spec_app arity_decrease +specUnfolding dflags spec_bndrs spec_app rule_lhs_args (CoreUnfolding { uf_src = src, uf_tmpl = tmpl , uf_is_top = top_lvl , uf_guidance = old_guidance }) | isStableSource src -- See Note [Specialising unfoldings] - , UnfWhen { ug_arity = old_arity - , ug_unsat_ok = unsat_ok - , ug_boring_ok = boring_ok } <- old_guidance - = let guidance = UnfWhen { ug_arity = old_arity - arity_decrease - , ug_unsat_ok = unsat_ok - , ug_boring_ok = boring_ok } - new_tmpl = simpleOptExpr dflags (mkLams spec_bndrs (spec_app tmpl)) - -- The beta-redexes created by spec_app will be - -- simplified away by simplOptExpr + , UnfWhen { ug_arity = old_arity } <- old_guidance + = mkCoreUnfolding src top_lvl new_tmpl + (old_guidance { ug_arity = old_arity - arity_decrease }) + where + new_tmpl = simpleOptExpr dflags $ + mkLams spec_bndrs $ + spec_app tmpl -- The beta-redexes created by spec_app + -- will besimplified away by simplOptExpr + arity_decrease = count isValArg rule_lhs_args - count isId spec_bndrs - in mkCoreUnfolding src top_lvl new_tmpl guidance -specUnfolding _ _ _ _ _ _ = noUnfolding +specUnfolding _ _ _ _ _ = noUnfolding {- Note [Specialising unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/deSugar/DsBinds.hs ===================================== @@ -695,20 +695,19 @@ dsSpec mb_poly_rhs (dL->L loc (SpecPrag poly_id spec_co spec_inl)) dflags <- getDynFlags ; case decomposeRuleLhs dflags spec_bndrs ds_lhs of { Left msg -> do { warnDs NoReason msg; return Nothing } ; - Right (rule_bndrs, _fn, args) -> do + Right (rule_bndrs, _fn, rule_lhs_args) -> do { this_mod <- getModule ; let fn_unf = realIdUnfolding poly_id - spec_unf = specUnfolding dflags poly_id spec_bndrs core_app arity_decrease fn_unf + spec_unf = specUnfolding dflags spec_bndrs core_app rule_lhs_args fn_unf spec_id = mkLocalId spec_name spec_ty `setInlinePragma` inl_prag `setIdUnfolding` spec_unf - arity_decrease = count isValArg args - count isId spec_bndrs ; rule <- dsMkUserRule this_mod is_local_id (mkFastString ("SPEC " ++ showPpr dflags poly_name)) rule_act poly_name - rule_bndrs args + rule_bndrs rule_lhs_args (mkVarApps (Var spec_id) spec_bndrs) ; let spec_rhs = mkLams spec_bndrs (core_app poly_rhs) ===================================== compiler/specialise/Specialise.hs ===================================== @@ -1236,6 +1236,7 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs inl_prag = idInlinePragma fn inl_act = inlinePragmaActivation inl_prag is_local = isLocalId fn + is_dfun = isDFunId fn -- Figure out whether the function has an INLINE pragma -- See Note [Inline specialisations] @@ -1258,22 +1259,34 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs spec_call :: SpecInfo -- Accumulating parameter -> CallInfo -- Call instance -> SpecM SpecInfo - spec_call spec_acc@(rules_acc, pairs_acc, uds_acc) (CI { ci_key = call_args }) + spec_call spec_acc@(rules_acc, pairs_acc, uds_acc) _ci@(CI { ci_key = call_args }) = -- See Note [Specialising Calls] - do { ( useful, rhs_env2, leftover_bndrs + do { let all_call_args | is_dfun = call_args ++ repeat UnspecArg + | otherwise = call_args + -- See Note [Specialising DFuns] + ; ( useful, rhs_env2, leftover_bndrs , rule_bndrs, rule_lhs_args - , spec_bndrs, dx_binds, spec_args) <- specHeader env rhs_bndrs call_args + , spec_bndrs1, dx_binds, spec_args) <- specHeader env rhs_bndrs all_call_args + +-- ; pprTrace "spec_call" (vcat [ text "call info: " <+> ppr _ci +-- , text "useful: " <+> ppr useful +-- , text "rule_bndrs:" <+> ppr rule_bndrs +-- , text "lhs_args: " <+> ppr rule_lhs_args +-- , text "spec_bndrs:" <+> ppr spec_bndrs1 +-- , text "spec_args: " <+> ppr spec_args +-- , text "dx_binds: " <+> ppr dx_binds +-- , text "rhs_env2: " <+> ppr (se_subst rhs_env2) +-- , ppr dx_binds ]) $ +-- return () ; dflags <- getDynFlags ; if not useful -- No useful specialisation || already_covered dflags rules_acc rule_lhs_args then return spec_acc - else -- pprTrace "spec_call" (vcat [ ppr _call_info, ppr fn, ppr rhs_dict_ids - -- , text "rhs_env2" <+> ppr (se_subst rhs_env2) - -- , ppr dx_binds ]) $ + else do { -- Run the specialiser on the specialised RHS -- The "1" suffix is before we maybe add the void arg - ; (spec_rhs1, rhs_uds) <- specLam rhs_env2 (spec_bndrs ++ leftover_bndrs) rhs_body + ; (spec_rhs1, rhs_uds) <- specLam rhs_env2 (spec_bndrs1 ++ leftover_bndrs) rhs_body ; let spec_fn_ty1 = exprType spec_rhs1 -- Maybe add a void arg to the specialised function, @@ -1281,14 +1294,13 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs -- See Note [Specialisations Must Be Lifted] -- C.f. GHC.Core.Op.WorkWrap.Lib.mkWorkerArgs add_void_arg = isUnliftedType spec_fn_ty1 && not (isJoinId fn) - (spec_rhs, spec_fn_ty, rule_rhs_args) - | add_void_arg = ( Lam voidArgId spec_rhs1 - , mkVisFunTy voidPrimTy spec_fn_ty1 - , voidPrimId : spec_bndrs) - | otherwise = (spec_rhs1, spec_fn_ty1, spec_bndrs) - - arity_decr = count isValArg rule_lhs_args - count isId rule_rhs_args - join_arity_decr = length rule_lhs_args - length rule_rhs_args + (spec_bndrs, spec_rhs, spec_fn_ty) + | add_void_arg = ( voidPrimId : spec_bndrs1 + , Lam voidArgId spec_rhs1 + , mkVisFunTy voidPrimTy spec_fn_ty1) + | otherwise = (spec_bndrs1, spec_rhs1, spec_fn_ty1) + + join_arity_decr = length rule_lhs_args - length spec_bndrs spec_join_arity | Just orig_join_arity <- isJoinId_maybe fn = Just (orig_join_arity - join_arity_decr) | otherwise @@ -1323,7 +1335,7 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs (idName fn) rule_bndrs rule_lhs_args - (mkVarApps (Var spec_fn) rule_rhs_args) + (mkVarApps (Var spec_fn) spec_bndrs) spec_rule = case isJoinId_maybe fn of @@ -1346,15 +1358,15 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs = (inl_prag { inl_inline = NoUserInline }, noUnfolding) | otherwise - = (inl_prag, specUnfolding dflags fn spec_bndrs spec_app arity_decr fn_unf) - - spec_app e = e `mkApps` spec_args + = (inl_prag, specUnfolding dflags spec_bndrs (`mkApps` spec_args) + rule_lhs_args fn_unf) -------------------------------------- -- Adding arity information just propagates it a bit faster -- See Note [Arity decrease] in Simplify -- Copy InlinePragma information from the parent Id. -- So if f has INLINE[1] so does spec_fn + arity_decr = count isValArg rule_lhs_args - count isId spec_bndrs spec_f_w_arity = spec_fn `setIdArity` max 0 (fn_arity - arity_decr) `setInlinePragma` spec_inl_prag `setIdUnfolding` spec_unf @@ -1372,8 +1384,19 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs , spec_uds `plusUDs` uds_acc ) } } -{- Note [Specialisation Must Preserve Sharing] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Specialising DFuns] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +DFuns have a special sort of unfolding (DFunUnfolding), and these are +hard to specialise a DFunUnfolding to give another DFunUnfolding +unless the DFun is fully applied (#18120). So, in the case of DFunIds +we simply extend the CallKey with trailing UnspecArgs, so we'll +generate a rule that completely saturates the DFun. + +There is an ASSERT that checks this, in the DFunUnfolding case of +GHC.Core.Unfold.specUnfolding. + +Note [Specialisation Must Preserve Sharing] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a function: f :: forall a. Eq a => a -> blah @@ -2003,7 +2026,7 @@ isSpecDict _ = False -- -- Specialised function helpers -- , [c, i, x] -- , [dShow1 = $dfShow dShowT2] --- , [T1, T2, dEqT1, dShow1] +-- , [T1, T2, c, i, dEqT1, dShow1] -- ) specHeader :: SpecEnv @@ -2020,12 +2043,13 @@ specHeader -- RULE helpers , [OutBndr] -- Binders for the RULE - , [CoreArg] -- Args for the LHS of the rule + , [OutExpr] -- Args for the LHS of the rule -- Specialised function helpers , [OutBndr] -- Binders for $sf , [DictBind] -- Auxiliary dictionary bindings , [OutExpr] -- Specialised arguments for unfolding + -- Same length as "args for LHS of rule" ) -- We want to specialise on type 'T1', and so we must construct a substitution ===================================== compiler/typecheck/TcSigs.hs ===================================== @@ -638,7 +638,6 @@ to connect the two, something like This wrapper is put in the TcSpecPrag, in the ABExport record of the AbsBinds. - f :: (Eq a, Ix b) => a -> b -> Bool {-# SPECIALISE f :: (Ix p, Ix q) => Int -> (p,q) -> Bool #-} f = @@ -666,8 +665,6 @@ Note that * The RHS of f_spec, has a *copy* of 'binds', so that it can fully specialise it. - - From the TcSpecPrag, in DsBinds we generate a binding for f_spec and a RULE: f_spec :: Int -> b -> Int @@ -706,14 +703,14 @@ Some wrinkles So we simply do this: - Generate a constraint to check that the specialised type (after - skolemiseation) is equal to the instantiated function type. + skolemisation) is equal to the instantiated function type. - But *discard* the evidence (coercion) for that constraint, so that we ultimately generate the simpler code f_spec :: Int -> F Int f_spec = Int dNumInt RULE: forall d. f Int d = f_spec - You can see this discarding happening in + You can see this discarding happening in tcSpecPrag 3. Note that the HsWrapper can transform *any* function with the right type prefix ===================================== testsuite/tests/simplCore/should_compile/T18120.hs ===================================== @@ -0,0 +1,34 @@ +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE UndecidableSuperClasses #-} +module Bug where + +import Data.Kind + +type family + AllF (c :: k -> Constraint) (xs :: [k]) :: Constraint where + AllF _c '[] = () + AllF c (x ': xs) = (c x, All c xs) + +class (AllF c xs, SListI xs) => All (c :: k -> Constraint) (xs :: [k]) where +instance All c '[] where +instance (c x, All c xs) => All c (x ': xs) where + +class Top x +instance Top x + +type SListI = All Top + +class All SListI (Code a) => Generic (a :: Type) where + type Code a :: [[Type]] + +data T = MkT Int +instance Generic T where + type Code T = '[ '[Int] ] ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -323,3 +323,4 @@ test('T17966', makefile_test, ['T17966']) # NB: T17810: -fspecialise-aggressively test('T17810', normal, multimod_compile, ['T17810', '-fspecialise-aggressively -dcore-lint -O -v0']) +test('T18120', normal, compile, ['-dcore-lint -O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f579acd1b0531fb19831b3bf3012263c4bb532df -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f579acd1b0531fb19831b3bf3012263c4bb532df You're receiving 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 Jul 23 15:32:32 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 23 Jul 2020 11:32:32 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/win32-testsuite-fixes Message-ID: <5f19ad909466b_80b102510244734999@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/win32-testsuite-fixes at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/win32-testsuite-fixes You're receiving 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 Jul 23 16:40:08 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 23 Jul 2020 12:40:08 -0400 Subject: [Git][ghc/ghc][wip/T18291] 182 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f19bd68e8995_80b3f84962c9cf04754524@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18291 at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - cec23d0a by Ben Gamari at 2020-07-23T12:39:57-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 5bf2cffd by Ben Gamari at 2020-07-23T12:39:57-04:00 testsuite: Add test for #18291 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - Makefile - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - + compiler/GHC/CmmToAsm/Reg/Utils.hs - compiler/GHC/CmmToAsm/X86/RegInfo.hs - compiler/GHC/CmmToLlvm/Base.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b55674ccd9dc975e01c3ad893b77f4248626fb46...5bf2cffdb4d36d0c7d49c6d8aaf48d7e961aa210 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b55674ccd9dc975e01c3ad893b77f4248626fb46...5bf2cffdb4d36d0c7d49c6d8aaf48d7e961aa210 You're receiving 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 Jul 23 17:40:00 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Thu, 23 Jul 2020 13:40:00 -0400 Subject: [Git][ghc/ghc][wip/negative-literals] 198 commits: Hadrian: fix PowerPC64le support (#17601) Message-ID: <5f19cb705fc61_80b3f849c40b20c47591c8@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/negative-literals at Glasgow Haskell Compiler / GHC Commits: 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 1b611267 by Vladislav Zavialov at 2020-07-23T20:38:50+03:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - Makefile - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Sink.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/Base.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Linear/StackMap.hs - compiler/GHC/CmmToAsm/Reg/Linear/Stats.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/37a35038a961a3051c549d4aecc4e94588c354e5...1b611267fe9d130415aba2af0af16a766403b379 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/37a35038a961a3051c549d4aecc4e94588c354e5...1b611267fe9d130415aba2af0af16a766403b379 You're receiving 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 Jul 23 17:49:16 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Thu, 23 Jul 2020 13:49:16 -0400 Subject: [Git][ghc/ghc][wip/negative-literals] 25 commits: Fix dead link to haskell prime discussion Message-ID: <5f19cd9c1cd61_80b1025102447601e4@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/negative-literals at Glasgow Haskell Compiler / GHC Commits: 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - 213a90cb by Vladislav Zavialov at 2020-07-23T20:49:03+03:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/StringBuffer.hs - + compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Load.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1b611267fe9d130415aba2af0af16a766403b379...213a90cb5e46ca0ca067ae6d5e98f05e4e99c44c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1b611267fe9d130415aba2af0af16a766403b379...213a90cb5e46ca0ca067ae6d5e98f05e4e99c44c You're receiving 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 Jul 23 18:08:05 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 23 Jul 2020 14:08:05 -0400 Subject: [Git][ghc/ghc][wip/win32-testsuite-fixes] gitlab-ci: Kill ssh-agent after pushing test metrics Message-ID: <5f19d20520f8d_80bd68a9b84768561@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/win32-testsuite-fixes at Glasgow Haskell Compiler / GHC Commits: c887c41d by Ben Gamari at 2020-07-23T14:07:39-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 1 changed file: - .gitlab/test-metrics.sh Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -88,3 +88,5 @@ case $1 in pull) pull ;; *) fail "Invalid mode $1" ;; esac + +ssh-agent -k View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c887c41d325d5f1c0a261e249388ed4633e4e54a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c887c41d325d5f1c0a261e249388ed4633e4e54a You're receiving 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 Jul 23 18:30:23 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 23 Jul 2020 14:30:23 -0400 Subject: [Git][ghc/ghc][wip/win32-testsuite-fixes] 28 commits: Fix dead link to haskell prime discussion Message-ID: <5f19d73f3174a_80b3f84868c3828477153@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/win32-testsuite-fixes at Glasgow Haskell Compiler / GHC Commits: 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - 83f02056 by Ben Gamari at 2020-07-23T14:30:17-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - 7b25fb25 by Ben Gamari at 2020-07-23T14:30:17-04:00 testsuite: Update win32 output for parseTree - - - - - 9fe25790 by Ben Gamari at 2020-07-23T14:30:17-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - de974ea9 by Ben Gamari at 2020-07-23T14:30:17-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 30 changed files: - .gitlab/test-metrics.sh - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/StringBuffer.hs - + compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c887c41d325d5f1c0a261e249388ed4633e4e54a...de974ea945f7b5378fa03f1893be21795cff2009 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c887c41d325d5f1c0a261e249388ed4633e4e54a...de974ea945f7b5378fa03f1893be21795cff2009 You're receiving 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 Jul 23 19:10:33 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Thu, 23 Jul 2020 15:10:33 -0400 Subject: [Git][ghc/ghc][wip/negative-literals] Improve NegativeLiterals (#18022, GHC Proposal #344) Message-ID: <5f19e0a96049c_80b3f84962c9cf0477217f@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/negative-literals at Glasgow Haskell Compiler / GHC Commits: 5ccd9779 by Vladislav Zavialov at 2020-07-23T22:10:23+03:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 7 changed files: - compiler/GHC/Parser/Lexer.x - docs/users_guide/8.12.1-notes.rst - docs/users_guide/exts/negative_literals.rst - − testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/NegativeLiterals.hs - + testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs - testsuite/tests/parser/should_compile/all.T Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -199,7 +199,6 @@ $docsym = [\| \^ \* \$] -- normal signed numerical literals can only be explicitly negative, -- not explicitly positive (contrast @exponent) @negative = \- - at signed = @negative ? -- ----------------------------------------------------------------------------- @@ -531,12 +530,12 @@ $tab { warnTab } ifExtension BinaryLiteralsBit } { tok_primint positive 2 3 binary } 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 octal } 0[xX] @numspc @hexadecimal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 hexadecimal } - @negative @decimal \# / { ifExtension MagicHashBit } { tok_primint negative 1 2 decimal } - @negative 0[bB] @numspc @binary \# / { ifExtension MagicHashBit `alexAndPred` + @negative @decimal \# / { negHashLitPred } { tok_primint negative 1 2 decimal } + @negative 0[bB] @numspc @binary \# / { negHashLitPred `alexAndPred` ifExtension BinaryLiteralsBit } { tok_primint negative 3 4 binary } - @negative 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint negative 3 4 octal } + @negative 0[oO] @numspc @octal \# / { negHashLitPred } { tok_primint negative 3 4 octal } @negative 0[xX] @numspc @hexadecimal \# - / { ifExtension MagicHashBit } { tok_primint negative 3 4 hexadecimal } + / { negHashLitPred } { tok_primint negative 3 4 hexadecimal } @decimal \# \# / { ifExtension MagicHashBit } { tok_primword 0 2 decimal } 0[bB] @numspc @binary \# \# / { ifExtension MagicHashBit `alexAndPred` @@ -546,8 +545,11 @@ $tab { warnTab } -- Unboxed floats and doubles (:: Float#, :: Double#) -- prim_{float,double} work with signed literals - @signed @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } - @signed @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } + @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + + @negative @floating_point \# / { negHashLitPred } { tok_frac 1 tok_primfloat } + @negative @floating_point \# \# / { negHashLitPred } { tok_frac 2 tok_primdouble } } -- Strings and chars are lexed by hand-written code. The reason is @@ -1192,8 +1194,8 @@ atEOL _ _ _ (AI _ buf) = atEnd buf || currentChar buf == '\n' -- Check if we should parse a negative literal (e.g. -123) as a single token. negLitPred :: AlexAccPred ExtsBitmap negLitPred = - negative_literals `alexOrPred` - (lexical_negation `alexAndPred` prefix_minus) + prefix_minus `alexAndPred` + (negative_literals `alexOrPred` lexical_negation) where negative_literals = ifExtension NegativeLiteralsBit @@ -1202,14 +1204,33 @@ negLitPred = alexNotPred (ifExtension NoLexicalNegationBit) prefix_minus = - -- The condition for a prefix occurrence of an operator is: - -- - -- not precededByClosingToken && followedByOpeningToken - -- - -- but we don't check followedByOpeningToken here as it holds - -- simply because we immediately lex a literal after the minus. + -- Note [prefix_minus in negLitPred and negHashLitPred] + alexNotPred precededByClosingToken + +-- Check if we should parse an unboxed negative literal (e.g. -123#) as a single token. +negHashLitPred :: AlexAccPred ExtsBitmap +negHashLitPred = prefix_minus `alexAndPred` magic_hash + where + magic_hash = ifExtension MagicHashBit + prefix_minus = + -- Note [prefix_minus in negLitPred and negHashLitPred] alexNotPred precededByClosingToken +{- Note [prefix_minus in negLitPred and negHashLitPred] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We want to parse -1 as a single token, but x-1 as three tokens. +So in negLitPred (and negHashLitPred) we require that we have a prefix +occurrence of the minus sign. See Note [Whitespace-sensitive operator parsing] +for a detailed definition of a prefix occurrence. + +The condition for a prefix occurrence of an operator is: + + not precededByClosingToken && followedByOpeningToken + +but we don't check followedByOpeningToken when parsing a negative literal. +It holds simply because we immediately lex a literal after the minus. +-} + ifExtension :: ExtBits -> AlexAccPred ExtsBitmap ifExtension extBits bits _ _ _ = extBits `xtest` bits ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -224,6 +224,13 @@ Language f = (- x) -- operator section c = (-x) -- negation +* The behavior of :extension:`NegativeLiterals` changed, and now we require + that a negative literal must not be preceded by a closing token (see + `GHC Proposal #229 `__ + for the definition of a closing token). In other words, we parse ``f -123`` + as ``f (-123)``, but ``x-123`` as ``(-) x 123``. Before this amendment, + :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/negative_literals.rst ===================================== @@ -24,9 +24,11 @@ will elicit an unexpected integer-literal-overflow message. Whitespace can be inserted, as in ``- 123``, to force interpretation as two tokens. -One pitfall is that with :extension:`NegativeLiterals`, ``x-1`` will -be parsed as ``x`` applied to the argument ``-1``, which is usually -not what you want. ``x - 1`` or even ``x- 1`` can be used instead -for subtraction. To avoid this, consider using :extension:`LexicalNegation` -instead. - +In 8.12, the behavior of this extension changed, and now we require that a negative literal must not be preceded by a closing token (see +`GHC Proposal #229 `__ +for the definition of a closing token). In other words, we parse ``f -123`` as ``f (-123)``, but ``x-123`` as ``(-) x +123``. Before this amendment, :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + +:extension:`NegativeLiterals` is a subset of :extension:`LexicalNegation`. That +is, enabling both of those extensions has the same effect as enabling +:extension:`LexicalNegation` alone. ===================================== testsuite/tests/parser/should_compile/LexNegVsNegLit.hs deleted ===================================== @@ -1,17 +0,0 @@ -{-# LANGUAGE NegativeLiterals, LexicalNegation #-} - -module LexNegVsNegLit where - --- NegativeLiterals specifies that we parse x-1 as x (-1), even though it's --- considered a shortcoming. --- --- LexicalNegation does not change that. --- -b :: Bool -b = even-1 -- parsed as: even (-1) - -- so it is well-typed. - -- - -- with LexicalNegation alone, we'd get (-) even 1, - -- but NegativeLiterals takes precedence here. - --- See also: GHC Proposal #344 ===================================== testsuite/tests/parser/should_compile/NegativeLiterals.hs ===================================== @@ -0,0 +1,57 @@ +{-# LANGUAGE NegativeLiterals, MagicHash, BinaryLiterals #-} + +module NegativeLiterals where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p1 :: Bool +p1 = even -2 -- parsed as: even (-2) + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p3 :: Int +p3 = floor -2.4 -- parsed as: floor (-2.4) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +p6 :: Bool +p6 = even -0b10 -- parsed as: even (-2) + || even -0o10 -- parsed as: even (-8) + || even -0x10 -- parsed as: even (-16) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti1 :: Integer -> Integer +ti1 x = x-2 -- parsed as: (-) x 1 + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) + +ti6 :: Integer -> [Integer] +ti6 x = + [ x-0b10, -- parsed as: (-) x 2 + x-0o10, -- parsed as: (-) x 8 + x-0x10 ] -- parsed as: (-) x 16 ===================================== testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs ===================================== @@ -0,0 +1,39 @@ +{-# LANGUAGE NoNegativeLiterals, MagicHash, BinaryLiterals #-} + +-- Even when NegativeLiterals are disabled, +-- we parse unboxed literals appropriately. +module NegativeLiteralsNoExt where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -153,7 +153,8 @@ test('proposal-229b', normal, compile, ['']) test('proposal-229d', normal, compile, ['']) test('proposal-229e', normal, compile, ['']) test('LexicalNegation', normal, compile, ['']) -test('LexNegVsNegLit', normal, compile, ['']) +test('NegativeLiterals', normal, compile, ['']) +test('NegativeLiteralsNoExt', normal, compile, ['']) # We omit 'profasm' because it fails with: # Cannot load -prof objects when GHC is built with -dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ccd97796a5963a6087dd81e2b519f70a3bf16cc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ccd97796a5963a6087dd81e2b519f70a3bf16cc You're receiving 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 Jul 23 19:20:04 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 23 Jul 2020 15:20:04 -0400 Subject: [Git][ghc/ghc][wip/backports] 3 commits: Fix specialisation for DFuns Message-ID: <5f19e2e484907_80b3f84962c9cf047779a7@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: bc2c4d2d by Simon Peyton Jones at 2020-07-23T15:19:49-04:00 Fix specialisation for DFuns When specialising a DFun we must take care to saturate the unfolding. See Note [Specialising DFuns] in Specialise. Fixes #18120 (cherry picked from commit 88e3c8150d2b2d96c3ebc0b2942c9af44071c511) - - - - - 3e1c8caf by Ben Gamari at 2020-07-23T15:19:49-04:00 testsuite: Accept wibbles in specialiser test output - - - - - 309cff63 by Moritz Angermann at 2020-07-23T15:19:49-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. (cherry picked from commit aedfeb0b2b22172a0dfca0fe0c020ac80539d6ae) - - - - - 18 changed files: - compiler/coreSyn/CoreUnfold.hs - compiler/deSugar/DsBinds.hs - compiler/specialise/Specialise.hs - compiler/typecheck/TcSigs.hs - rts/Linker.c - rts/LinkerInternals.h - rts/linker/Elf.c - rts/linker/LoadArchive.c - rts/linker/M32Alloc.c - rts/linker/MachO.c - rts/linker/SymbolExtras.c - rts/linker/elf_got.c - testsuite/tests/ghci/T18060/T18060.stdout - testsuite/tests/perf/compiler/T16473.stdout - testsuite/tests/simplCore/should_compile/T17966.stdout - + testsuite/tests/simplCore/should_compile/T18120.hs - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/simplCore/should_compile/spec004.stderr Changes: ===================================== compiler/coreSyn/CoreUnfold.hs ===================================== @@ -169,47 +169,47 @@ mkInlinableUnfolding dflags expr where expr' = simpleOptExpr dflags expr -specUnfolding :: DynFlags -> Id -> [Var] -> (CoreExpr -> CoreExpr) -> Arity +specUnfolding :: DynFlags + -> [Var] -> (CoreExpr -> CoreExpr) + -> [CoreArg] -- LHS arguments in the RULE -> Unfolding -> Unfolding -- See Note [Specialising unfoldings] --- specUnfolding spec_bndrs spec_app arity_decrease unf --- = \spec_bndrs. spec_app( unf ) +-- specUnfolding spec_bndrs spec_args unf +-- = \spec_bndrs. unf spec_args -- -specUnfolding dflags fn spec_bndrs spec_app arity_decrease +specUnfolding dflags spec_bndrs spec_app rule_lhs_args df@(DFunUnfolding { df_bndrs = old_bndrs, df_con = con, df_args = args }) - = ASSERT2( arity_decrease == count isId old_bndrs - count isId spec_bndrs - , ppr df $$ ppr spec_bndrs $$ ppr (spec_app (Var fn)) $$ ppr arity_decrease ) + = ASSERT2( rule_lhs_args `equalLength` old_bndrs + , ppr df $$ ppr rule_lhs_args ) + -- For this ASSERT see Note [DFunUnfoldings] in GHC.Core.Opt.Specialise mkDFunUnfolding spec_bndrs con (map spec_arg args) - -- There is a hard-to-check assumption here that the spec_app has - -- enough applications to exactly saturate the old_bndrs -- For DFunUnfoldings we transform - -- \old_bndrs. MkD ... + -- \obs. MkD ... -- to - -- \new_bndrs. MkD (spec_app(\old_bndrs. )) ... ditto - -- The ASSERT checks the value part of that + -- \sbs. MkD ((\obs. ) spec_args) ... ditto where - spec_arg arg = simpleOptExpr dflags (spec_app (mkLams old_bndrs arg)) + spec_arg arg = simpleOptExpr dflags $ + spec_app (mkLams old_bndrs arg) -- The beta-redexes created by spec_app will be -- simplified away by simplOptExpr -specUnfolding dflags _ spec_bndrs spec_app arity_decrease +specUnfolding dflags spec_bndrs spec_app rule_lhs_args (CoreUnfolding { uf_src = src, uf_tmpl = tmpl , uf_is_top = top_lvl , uf_guidance = old_guidance }) | isStableSource src -- See Note [Specialising unfoldings] - , UnfWhen { ug_arity = old_arity - , ug_unsat_ok = unsat_ok - , ug_boring_ok = boring_ok } <- old_guidance - = let guidance = UnfWhen { ug_arity = old_arity - arity_decrease - , ug_unsat_ok = unsat_ok - , ug_boring_ok = boring_ok } - new_tmpl = simpleOptExpr dflags (mkLams spec_bndrs (spec_app tmpl)) - -- The beta-redexes created by spec_app will be - -- simplified away by simplOptExpr + , UnfWhen { ug_arity = old_arity } <- old_guidance + = mkCoreUnfolding src top_lvl new_tmpl + (old_guidance { ug_arity = old_arity - arity_decrease }) + where + new_tmpl = simpleOptExpr dflags $ + mkLams spec_bndrs $ + spec_app tmpl -- The beta-redexes created by spec_app + -- will besimplified away by simplOptExpr + arity_decrease = count isValArg rule_lhs_args - count isId spec_bndrs - in mkCoreUnfolding src top_lvl new_tmpl guidance -specUnfolding _ _ _ _ _ _ = noUnfolding +specUnfolding _ _ _ _ _ = noUnfolding {- Note [Specialising unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/deSugar/DsBinds.hs ===================================== @@ -695,20 +695,19 @@ dsSpec mb_poly_rhs (dL->L loc (SpecPrag poly_id spec_co spec_inl)) dflags <- getDynFlags ; case decomposeRuleLhs dflags spec_bndrs ds_lhs of { Left msg -> do { warnDs NoReason msg; return Nothing } ; - Right (rule_bndrs, _fn, args) -> do + Right (rule_bndrs, _fn, rule_lhs_args) -> do { this_mod <- getModule ; let fn_unf = realIdUnfolding poly_id - spec_unf = specUnfolding dflags poly_id spec_bndrs core_app arity_decrease fn_unf + spec_unf = specUnfolding dflags spec_bndrs core_app rule_lhs_args fn_unf spec_id = mkLocalId spec_name spec_ty `setInlinePragma` inl_prag `setIdUnfolding` spec_unf - arity_decrease = count isValArg args - count isId spec_bndrs ; rule <- dsMkUserRule this_mod is_local_id (mkFastString ("SPEC " ++ showPpr dflags poly_name)) rule_act poly_name - rule_bndrs args + rule_bndrs rule_lhs_args (mkVarApps (Var spec_id) spec_bndrs) ; let spec_rhs = mkLams spec_bndrs (core_app poly_rhs) ===================================== compiler/specialise/Specialise.hs ===================================== @@ -1236,6 +1236,7 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs inl_prag = idInlinePragma fn inl_act = inlinePragmaActivation inl_prag is_local = isLocalId fn + is_dfun = isDFunId fn -- Figure out whether the function has an INLINE pragma -- See Note [Inline specialisations] @@ -1258,22 +1259,34 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs spec_call :: SpecInfo -- Accumulating parameter -> CallInfo -- Call instance -> SpecM SpecInfo - spec_call spec_acc@(rules_acc, pairs_acc, uds_acc) (CI { ci_key = call_args }) + spec_call spec_acc@(rules_acc, pairs_acc, uds_acc) _ci@(CI { ci_key = call_args }) = -- See Note [Specialising Calls] - do { ( useful, rhs_env2, leftover_bndrs + do { let all_call_args | is_dfun = call_args ++ repeat UnspecArg + | otherwise = call_args + -- See Note [Specialising DFuns] + ; ( useful, rhs_env2, leftover_bndrs , rule_bndrs, rule_lhs_args - , spec_bndrs, dx_binds, spec_args) <- specHeader env rhs_bndrs call_args + , spec_bndrs1, dx_binds, spec_args) <- specHeader env rhs_bndrs all_call_args + +-- ; pprTrace "spec_call" (vcat [ text "call info: " <+> ppr _ci +-- , text "useful: " <+> ppr useful +-- , text "rule_bndrs:" <+> ppr rule_bndrs +-- , text "lhs_args: " <+> ppr rule_lhs_args +-- , text "spec_bndrs:" <+> ppr spec_bndrs1 +-- , text "spec_args: " <+> ppr spec_args +-- , text "dx_binds: " <+> ppr dx_binds +-- , text "rhs_env2: " <+> ppr (se_subst rhs_env2) +-- , ppr dx_binds ]) $ +-- return () ; dflags <- getDynFlags ; if not useful -- No useful specialisation || already_covered dflags rules_acc rule_lhs_args then return spec_acc - else -- pprTrace "spec_call" (vcat [ ppr _call_info, ppr fn, ppr rhs_dict_ids - -- , text "rhs_env2" <+> ppr (se_subst rhs_env2) - -- , ppr dx_binds ]) $ + else do { -- Run the specialiser on the specialised RHS -- The "1" suffix is before we maybe add the void arg - ; (spec_rhs1, rhs_uds) <- specLam rhs_env2 (spec_bndrs ++ leftover_bndrs) rhs_body + ; (spec_rhs1, rhs_uds) <- specLam rhs_env2 (spec_bndrs1 ++ leftover_bndrs) rhs_body ; let spec_fn_ty1 = exprType spec_rhs1 -- Maybe add a void arg to the specialised function, @@ -1281,14 +1294,13 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs -- See Note [Specialisations Must Be Lifted] -- C.f. GHC.Core.Op.WorkWrap.Lib.mkWorkerArgs add_void_arg = isUnliftedType spec_fn_ty1 && not (isJoinId fn) - (spec_rhs, spec_fn_ty, rule_rhs_args) - | add_void_arg = ( Lam voidArgId spec_rhs1 - , mkVisFunTy voidPrimTy spec_fn_ty1 - , voidPrimId : spec_bndrs) - | otherwise = (spec_rhs1, spec_fn_ty1, spec_bndrs) - - arity_decr = count isValArg rule_lhs_args - count isId rule_rhs_args - join_arity_decr = length rule_lhs_args - length rule_rhs_args + (spec_bndrs, spec_rhs, spec_fn_ty) + | add_void_arg = ( voidPrimId : spec_bndrs1 + , Lam voidArgId spec_rhs1 + , mkVisFunTy voidPrimTy spec_fn_ty1) + | otherwise = (spec_bndrs1, spec_rhs1, spec_fn_ty1) + + join_arity_decr = length rule_lhs_args - length spec_bndrs spec_join_arity | Just orig_join_arity <- isJoinId_maybe fn = Just (orig_join_arity - join_arity_decr) | otherwise @@ -1323,7 +1335,7 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs (idName fn) rule_bndrs rule_lhs_args - (mkVarApps (Var spec_fn) rule_rhs_args) + (mkVarApps (Var spec_fn) spec_bndrs) spec_rule = case isJoinId_maybe fn of @@ -1346,15 +1358,15 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs = (inl_prag { inl_inline = NoUserInline }, noUnfolding) | otherwise - = (inl_prag, specUnfolding dflags fn spec_bndrs spec_app arity_decr fn_unf) - - spec_app e = e `mkApps` spec_args + = (inl_prag, specUnfolding dflags spec_bndrs (`mkApps` spec_args) + rule_lhs_args fn_unf) -------------------------------------- -- Adding arity information just propagates it a bit faster -- See Note [Arity decrease] in Simplify -- Copy InlinePragma information from the parent Id. -- So if f has INLINE[1] so does spec_fn + arity_decr = count isValArg rule_lhs_args - count isId spec_bndrs spec_f_w_arity = spec_fn `setIdArity` max 0 (fn_arity - arity_decr) `setInlinePragma` spec_inl_prag `setIdUnfolding` spec_unf @@ -1372,8 +1384,19 @@ specCalls mb_mod env existing_rules calls_for_me fn rhs , spec_uds `plusUDs` uds_acc ) } } -{- Note [Specialisation Must Preserve Sharing] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Specialising DFuns] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +DFuns have a special sort of unfolding (DFunUnfolding), and these are +hard to specialise a DFunUnfolding to give another DFunUnfolding +unless the DFun is fully applied (#18120). So, in the case of DFunIds +we simply extend the CallKey with trailing UnspecArgs, so we'll +generate a rule that completely saturates the DFun. + +There is an ASSERT that checks this, in the DFunUnfolding case of +GHC.Core.Unfold.specUnfolding. + +Note [Specialisation Must Preserve Sharing] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a function: f :: forall a. Eq a => a -> blah @@ -2003,7 +2026,7 @@ isSpecDict _ = False -- -- Specialised function helpers -- , [c, i, x] -- , [dShow1 = $dfShow dShowT2] --- , [T1, T2, dEqT1, dShow1] +-- , [T1, T2, c, i, dEqT1, dShow1] -- ) specHeader :: SpecEnv @@ -2020,12 +2043,13 @@ specHeader -- RULE helpers , [OutBndr] -- Binders for the RULE - , [CoreArg] -- Args for the LHS of the rule + , [OutExpr] -- Args for the LHS of the rule -- Specialised function helpers , [OutBndr] -- Binders for $sf , [DictBind] -- Auxiliary dictionary bindings , [OutExpr] -- Specialised arguments for unfolding + -- Same length as "args for LHS of rule" ) -- We want to specialise on type 'T1', and so we must construct a substitution ===================================== compiler/typecheck/TcSigs.hs ===================================== @@ -638,7 +638,6 @@ to connect the two, something like This wrapper is put in the TcSpecPrag, in the ABExport record of the AbsBinds. - f :: (Eq a, Ix b) => a -> b -> Bool {-# SPECIALISE f :: (Ix p, Ix q) => Int -> (p,q) -> Bool #-} f = @@ -666,8 +665,6 @@ Note that * The RHS of f_spec, has a *copy* of 'binds', so that it can fully specialise it. - - From the TcSpecPrag, in DsBinds we generate a binding for f_spec and a RULE: f_spec :: Int -> b -> Int @@ -706,14 +703,14 @@ Some wrinkles So we simply do this: - Generate a constraint to check that the specialised type (after - skolemiseation) is equal to the instantiated function type. + skolemisation) is equal to the instantiated function type. - But *discard* the evidence (coercion) for that constraint, so that we ultimately generate the simpler code f_spec :: Int -> F Int f_spec = Int dNumInt RULE: forall d. f Int d = f_spec - You can see this discarding happening in + You can see this discarding happening in tcSpecPrag 3. Note that the HsWrapper can transform *any* function with the right type prefix ===================================== rts/Linker.c ===================================== @@ -188,7 +188,7 @@ int ocTryLoad( ObjectCode* oc ); * * MAP_32BIT not available on OpenBSD/amd64 */ -#if defined(MAP_32BIT) && defined(x86_64_HOST_ARCH) +#if defined(MAP_32BIT) && (defined(x86_64_HOST_ARCH) || (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH))) #define MAP_LOW_MEM #define TRY_MAP_32BIT MAP_32BIT #else @@ -214,10 +214,22 @@ int ocTryLoad( ObjectCode* oc ); * systems, we have to pick a base address in the low 2Gb of the address space * and try to allocate memory from there. * + * The same holds for aarch64, where the default, even with PIC, model + * is 4GB. The linker is free to emit AARCH64_ADR_PREL_PG_HI21 + * relocations. + * * We pick a default address based on the OS, but also make this * configurable via an RTS flag (+RTS -xm) */ -#if defined(MAP_32BIT) || DEFAULT_LINKER_ALWAYS_PIC + +#if (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH)) +// Try to use stg_upd_frame_info as the base. We need to be within +-4GB of that +// address, otherwise we violate the aarch64 memory model. Any object we load +// can potentially reference any of the ones we bake into the binary (and list) +// in RtsSymbols. Thus we'll need to be within +-4GB of those, +// stg_upd_frame_info is a good candidate as it's referenced often. +#define MMAP_32BIT_BASE_DEFAULT (void*)&stg_upd_frame_info; +#elif defined(MAP_32BIT) || DEFAULT_LINKER_ALWAYS_PIC // Try to use MAP_32BIT #define MMAP_32BIT_BASE_DEFAULT 0 #else @@ -995,11 +1007,47 @@ resolveSymbolAddr (pathchar* buffer, int size, } #if RTS_LINKER_USE_MMAP + +/* ----------------------------------------------------------------------------- + Occationally we depend on mmap'd region being close to already mmap'd regions. + + Our static in-memory linker may be restricted by the architectures relocation + range. E.g. aarch64 has a +-4GB range for PIC code, thus we'd preferrably + get memory for the linker close to existing mappings. mmap on it's own is + free to return any memory location, independent of what the preferred + location argument indicates. + + For example mmap (via qemu) might give you addresses all over the available + memory range if the requested location is already occupied. + + mmap_next will do a linear search from the start page upwards to find a + suitable location that is as close as possible to the locations (proivded + via the first argument). + -------------------------------------------------------------------------- */ + +void* +mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { + if(addr == NULL) return mmap(addr, length, prot, flags, fd, offset); + // we are going to look for up to pageSize * 1024 * 1024 (4GB) from the + // address. + size_t pageSize = getPageSize(); + for(int i = (uintptr_t)addr & (pageSize-1) ? 1 : 0; i < 1024*1024; i++) { + void *target = (void*)(((uintptr_t)addr & ~(pageSize-1))+(i*pageSize)); + void *mem = mmap(target, length, prot, flags, fd, offset); + if(mem == NULL) return mem; + if(mem == target) return mem; + munmap(mem, length); + IF_DEBUG(linker && (i % 1024 == 0), + debugBelch("mmap_next failed to find suitable space in %p - %p\n", addr, target)); + } + return NULL; +} + // // Returns NULL on failure. // void * -mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset) +mmapForLinker (size_t bytes, uint32_t prot, uint32_t flags, int fd, int offset) { void *map_addr = NULL; void *result; @@ -1020,15 +1068,14 @@ mmap_again: map_addr = mmap_32bit_base; } - const int prot = PROT_READ | PROT_WRITE; IF_DEBUG(linker, debugBelch("mmapForLinker: \tprotection %#0x\n", prot)); IF_DEBUG(linker, debugBelch("mmapForLinker: \tflags %#0x\n", MAP_PRIVATE | tryMap32Bit | fixed | flags)); - result = mmap(map_addr, size, prot, - MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); + result = mmap_next(map_addr, size, prot, + MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); if (result == MAP_FAILED) { sysErrorBelch("mmap %" FMT_Word " bytes at %p",(W_)size,map_addr); @@ -1081,6 +1128,28 @@ mmap_again: goto mmap_again; } } +#elif (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH)) + // for aarch64 we need to make sure we stay within 4GB of the + // mmap_32bit_base, and we also do not want to update it. +// if (mmap_32bit_base != (void*)&stg_upd_frame_info) { + if (result == map_addr) { + mmap_32bit_base = (void*)((uintptr_t)map_addr + size); + } else { + // upper limit 4GB - size of the object file - 1mb wiggle room. + if(llabs((uintptr_t)result - (uintptr_t)&stg_upd_frame_info) > (2<<32) - size - (2<<20)) { + // not within range :( + debugTrace(DEBUG_linker, + "MAP_32BIT didn't work; gave us %lu bytes at 0x%p", + bytes, result); + munmap(result, size); + // TODO: some abort/mmap_32bit_base recomputation based on + // if mmap_32bit_base is changed, or still at stg_upd_frame_info + goto mmap_again; + } else { + mmap_32bit_base = (void*)((uintptr_t)result + size); + } + } +// } #endif IF_DEBUG(linker, @@ -1421,9 +1490,9 @@ preloadObjectFile (pathchar *path) * See also the misalignment logic for darwin below. */ #if defined(ios_HOST_OS) - image = mmap(NULL, fileSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); + image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); #else - image = mmap(NULL, fileSize, PROT_READ|PROT_WRITE|PROT_EXEC, + image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, fd, 0); #endif ===================================== rts/LinkerInternals.h ===================================== @@ -14,6 +14,7 @@ #if RTS_LINKER_USE_MMAP #include +void* mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset); #endif #include "BeginPrivate.h" @@ -293,7 +294,7 @@ void exitLinker( void ); void freeObjectCode (ObjectCode *oc); SymbolAddr* loadSymbol(SymbolName *lbl, RtsSymbolInfo *pinfo); -void *mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset); +void *mmapForLinker (size_t bytes, uint32_t prot, uint32_t flags, int fd, int offset); void mmapForLinkerMarkExecutable (void *start, size_t len); void addProddableBlock ( ObjectCode* oc, void* start, int size ); ===================================== rts/linker/Elf.c ===================================== @@ -637,7 +637,7 @@ mapObjectFileSection (int fd, Elf_Word offset, Elf_Word size, pageOffset = roundDownToPage(offset); pageSize = roundUpToPage(offset-pageOffset+size); - p = mmapForLinker(pageSize, 0, fd, pageOffset); + p = mmapForLinker(pageSize, PROT_READ | PROT_WRITE, 0, fd, pageOffset); if (p == NULL) return NULL; *mapped_size = pageSize; *mapped_offset = pageOffset; @@ -709,7 +709,7 @@ ocGetNames_ELF ( ObjectCode* oc ) * address might be out of range for sections that are mmaped. */ alloc = SECTION_MMAP; - start = mmapForLinker(size, MAP_ANONYMOUS, -1, 0); + start = mmapForLinker(size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); mapped_start = start; mapped_offset = 0; mapped_size = roundUpToPage(size); @@ -751,8 +751,9 @@ ocGetNames_ELF ( ObjectCode* oc ) unsigned nstubs = numberOfStubsForSection(oc, i); unsigned stub_space = STUB_SIZE * nstubs; - void * mem = mmapForLinker(size+stub_space, MAP_ANON, -1, 0); - if( mem == NULL ) { + void * mem = mmapForLinker(size+stub_space, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + + if( mem == MAP_FAILED ) { barf("failed to mmap allocated memory to load section %d. " "errno = %d", i, errno); } @@ -841,6 +842,26 @@ ocGetNames_ELF ( ObjectCode* oc ) unsigned curSymbol = 0; + unsigned long common_size = 0; + unsigned long common_used = 0; + for(ElfSymbolTable *symTab = oc->info->symbolTables; + symTab != NULL; symTab = symTab->next) { + for (size_t j = 0; j < symTab->n_symbols; j++) { + ElfSymbol *symbol = &symTab->symbols[j]; + if (SHN_COMMON == symTab->symbols[j].elf_sym->st_shndx) { + common_size += symbol->elf_sym->st_size; + } + } + } + void * common_mem = NULL; + if(common_size > 0) { + common_mem = mmapForLinker(common_size, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, + -1, 0); + ASSERT(common_mem != NULL); + } + //TODO: we ignore local symbols anyway right? So we can use the // shdr[i].sh_info to get the index of the first non-local symbol // ie we should use j = shdr[i].sh_info @@ -876,12 +897,15 @@ ocGetNames_ELF ( ObjectCode* oc ) if (shndx == SHN_COMMON) { isLocal = false; - symbol->addr = stgCallocBytes(1, symbol->elf_sym->st_size, - "ocGetNames_ELF(COMMON)"); - /* - debugBelch("COMMON symbol, size %d name %s\n", - stab[j].st_size, nm); - */ + ASSERT(common_used < common_size); + ASSERT(common_mem); + symbol->addr = (void*)((uintptr_t)common_mem + common_used); + common_used += symbol->elf_sym->st_size; + ASSERT(common_used <= common_size); + + debugBelch("COMMON symbol, size %ld name %s allocated at %p\n", + symbol->elf_sym->st_size, nm, symbol->addr); + /* Pointless to do addProddableBlock() for this area, since the linker should never poke around in it. */ } else if ((ELF_ST_BIND(symbol->elf_sym->st_info) == STB_GLOBAL ===================================== rts/linker/LoadArchive.c ===================================== @@ -489,7 +489,7 @@ static HsInt loadArchive_ (pathchar *path) #if defined(darwin_HOST_OS) || defined(ios_HOST_OS) if (RTS_LINKER_USE_MMAP) - image = mmapForLinker(memberSize, MAP_ANONYMOUS, -1, 0); + image = mmapForLinker(memberSize, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); else { /* See loadObj() */ misalignment = machoGetMisalignment(f); @@ -547,7 +547,7 @@ while reading filename from `%" PATH_FMT "'", path); } DEBUG_LOG("Found GNU-variant file index\n"); #if RTS_LINKER_USE_MMAP - gnuFileIndex = mmapForLinker(memberSize + 1, MAP_ANONYMOUS, -1, 0); + gnuFileIndex = mmapForLinker(memberSize + 1, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); #else gnuFileIndex = stgMallocBytes(memberSize + 1, "loadArchive(image)"); #endif ===================================== rts/linker/M32Alloc.c ===================================== @@ -256,7 +256,7 @@ m32_alloc_page(void) m32_free_page_pool_size --; return page; } else { - struct m32_page_t *page = mmapForLinker(getPageSize(),MAP_ANONYMOUS,-1,0); + struct m32_page_t *page = mmapForLinker(getPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); if (page > (struct m32_page_t *) 0xffffffff) { barf("m32_alloc_page: failed to get allocation in lower 32-bits"); } @@ -280,7 +280,7 @@ m32_allocator_new(bool executable) // Preallocate the initial M32_MAX_PAGES to ensure that they don't // fragment the memory. size_t pgsz = getPageSize(); - char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES,MAP_ANONYMOUS,-1,0); + char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,-1,0); if (bigchunk == NULL) barf("m32_allocator_init: Failed to map"); @@ -396,7 +396,7 @@ m32_alloc(struct m32_allocator_t *alloc, size_t size, size_t alignment) if (m32_is_large_object(size,alignment)) { // large object size_t alsize = ROUND_UP(sizeof(struct m32_page_t), alignment); - struct m32_page_t *page = mmapForLinker(alsize+size,MAP_ANONYMOUS,-1,0); + struct m32_page_t *page = mmapForLinker(alsize+size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,-1,0); page->filled_page.size = alsize + size; m32_allocator_push_filled_list(&alloc->unprotected_list, (struct m32_page_t *) page); return (char*) page + alsize; ===================================== rts/linker/MachO.c ===================================== @@ -508,7 +508,7 @@ makeGot(ObjectCode * oc) { if(got_slots > 0) { oc->info->got_size = got_slots * sizeof(void*); - oc->info->got_start = mmap(NULL, oc->info->got_size, + oc->info->got_start = mmapForLinker(oc->info->got_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); @@ -1106,7 +1106,7 @@ ocBuildSegments_MachO(ObjectCode *oc) return 1; } - mem = mmapForLinker(size_compound, MAP_ANON, -1, 0); + mem = mmapForLinker(size_compound, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); if (NULL == mem) return 0; IF_DEBUG(linker, debugBelch("ocBuildSegments: allocating %d segments\n", n_activeSegments)); ===================================== rts/linker/SymbolExtras.c ===================================== @@ -79,7 +79,7 @@ int ocAllocateExtras(ObjectCode* oc, int count, int first, int bssSize) size_t n = roundUpToPage(oc->fileSize); bssSize = roundUpToAlign(bssSize, 8); size_t allocated_size = n + bssSize + extras_size; - void *new = mmapForLinker(allocated_size, MAP_ANONYMOUS, -1, 0); + void *new = mmapForLinker(allocated_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); if (new) { memcpy(new, oc->image, oc->fileSize); if (oc->imageMapped) { ===================================== rts/linker/elf_got.c ===================================== @@ -48,7 +48,7 @@ makeGot(ObjectCode * oc) { } if(got_slots > 0) { oc->info->got_size = got_slots * sizeof(void *); - void * mem = mmap(NULL, oc->info->got_size, + void * mem = mmapForLinker(oc->info->got_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); ===================================== testsuite/tests/ghci/T18060/T18060.stdout ===================================== @@ -7,6 +7,3 @@ instance Functor ((->) r) -- Defined in ‘GHC.Base’ instance Monad ((->) r) -- Defined in ‘GHC.Base’ instance Monoid b => Monoid (a -> b) -- Defined in ‘GHC.Base’ instance Semigroup b => Semigroup (a -> b) -- Defined in ‘GHC.Base’ -type (~) :: forall k. k -> k -> Constraint -class (a ~ b) => (~) a b - -- Defined in ‘GHC.Types’ ===================================== testsuite/tests/perf/compiler/T16473.stdout ===================================== @@ -68,15 +68,15 @@ Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op $p1Applicative (BUILTIN) -Rule fired: SPEC/Main $fApplicativeStateT @Identity _ (Main) -Rule fired: SPEC/Main $fMonadStateT_$c>>= @Identity _ (Main) -Rule fired: SPEC/Main $fMonadStateT_$c>> @Identity _ (Main) +Rule fired: SPEC/Main $fApplicativeStateT @ Identity _ (Main) +Rule fired: SPEC/Main $fMonadStateT_$c>>= @ Identity _ (Main) +Rule fired: SPEC/Main $fMonadStateT_$c>> @ Identity _ (Main) Rule fired: Class op return (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op $p1Applicative (BUILTIN) -Rule fired: SPEC/Main $fApplicativeStateT @Identity _ (Main) -Rule fired: SPEC/Main $fMonadStateT_$c>>= @Identity _ (Main) -Rule fired: SPEC/Main $fMonadStateT_$c>> @Identity _ (Main) +Rule fired: SPEC/Main $fApplicativeStateT @ Identity _ (Main) +Rule fired: SPEC/Main $fMonadStateT_$c>>= @ Identity _ (Main) +Rule fired: SPEC/Main $fMonadStateT_$c>> @ Identity _ (Main) Rule fired: Class op return (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) @@ -84,19 +84,19 @@ Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op $p1Applicative (BUILTIN) -Rule fired: SPEC/Main $fApplicativeStateT @Identity _ (Main) +Rule fired: SPEC/Main $fApplicativeStateT @ Identity _ (Main) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op $p1Applicative (BUILTIN) -Rule fired: SPEC/Main $fApplicativeStateT @Identity _ (Main) +Rule fired: SPEC/Main $fApplicativeStateT @ Identity _ (Main) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op fmap (BUILTIN) Rule fired: Class op fmap (BUILTIN) Rule fired: Class op fmap (BUILTIN) Rule fired: Class op fmap (BUILTIN) -Rule fired: SPEC/Main $fFunctorStateT_$cfmap @Identity _ (Main) +Rule fired: SPEC/Main $fFunctorStateT_$cfmap @ Identity _ (Main) Rule fired: Class op fmap (BUILTIN) -Rule fired: SPEC/Main $fFunctorStateT_$cfmap @Identity _ (Main) +Rule fired: SPEC/Main $fFunctorStateT_$cfmap @ Identity _ (Main) Rule fired: Class op fmap (BUILTIN) Rule fired: Class op return (BUILTIN) Rule fired: Class op return (BUILTIN) @@ -111,17 +111,19 @@ Rule fired: Class op fmap (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op fmap (BUILTIN) -Rule fired: SPEC/Main $fFunctorStateT @Identity _ (Main) -Rule fired: SPEC/Main $fApplicativeStateT_$cpure @Identity _ (Main) -Rule fired: SPEC/Main $fApplicativeStateT_$c<*> @Identity _ (Main) +Rule fired: SPEC/Main $fFunctorStateT @ Identity _ (Main) +Rule fired: + SPEC/Main $fApplicativeStateT_$cpure @ Identity _ (Main) +Rule fired: SPEC/Main $fApplicativeStateT_$c<*> @ Identity _ (Main) Rule fired: Class op fmap (BUILTIN) -Rule fired: SPEC/Main $fApplicativeStateT_$c*> @Identity _ (Main) +Rule fired: SPEC/Main $fApplicativeStateT_$c*> @ Identity _ (Main) Rule fired: Class op fmap (BUILTIN) -Rule fired: SPEC/Main $fFunctorStateT @Identity _ (Main) -Rule fired: SPEC/Main $fApplicativeStateT_$cpure @Identity _ (Main) -Rule fired: SPEC/Main $fApplicativeStateT_$c<*> @Identity _ (Main) -Rule fired: SPEC/Main $fApplicativeStateT_$c*> @Identity _ (Main) -Rule fired: SPEC/Main $fMonadStateT @Identity _ (Main) +Rule fired: SPEC/Main $fFunctorStateT @ Identity _ (Main) +Rule fired: + SPEC/Main $fApplicativeStateT_$cpure @ Identity _ (Main) +Rule fired: SPEC/Main $fApplicativeStateT_$c<*> @ Identity _ (Main) +Rule fired: SPEC/Main $fApplicativeStateT_$c*> @ Identity _ (Main) +Rule fired: SPEC/Main $fMonadStateT @ Identity _ (Main) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op fmap (BUILTIN) @@ -136,8 +138,8 @@ Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op fmap (BUILTIN) Rule fired: Class op >>= (BUILTIN) -Rule fired: SPEC go @(StateT (Sum Int) Identity) (Main) +Rule fired: SPEC go @ (StateT (Sum Int) Identity) (Main) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op pure (BUILTIN) -Rule fired: SPEC/Main $fMonadStateT @Identity _ (Main) -Rule fired: SPEC go @(StateT (Sum Int) Identity) (Main) +Rule fired: SPEC/Main $fMonadStateT @ Identity _ (Main) +Rule fired: SPEC go @ (StateT (Sum Int) Identity) (Main) ===================================== testsuite/tests/simplCore/should_compile/T17966.stdout ===================================== @@ -1,4 +1,4 @@ - RULES: "SPEC $cm @()" [0] - RULES: "SPEC f @Bool @() @(Maybe Integer)" [0] -"SPEC/T17966 $fShowMaybe_$cshowList @Integer" -"SPEC/T17966 $fShowMaybe @Integer" + RULES: "SPEC $cm @ ()" [0] + RULES: "SPEC f @ Bool @ () @ (Maybe Integer)" [0] +"SPEC/T17966 $fShowMaybe_$cshowList @ Integer" +"SPEC/T17966 $fShowMaybe @ Integer" ===================================== testsuite/tests/simplCore/should_compile/T18120.hs ===================================== @@ -0,0 +1,34 @@ +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE UndecidableSuperClasses #-} +module Bug where + +import Data.Kind + +type family + AllF (c :: k -> Constraint) (xs :: [k]) :: Constraint where + AllF _c '[] = () + AllF c (x ': xs) = (c x, All c xs) + +class (AllF c xs, SListI xs) => All (c :: k -> Constraint) (xs :: [k]) where +instance All c '[] where +instance (c x, All c xs) => All c (x ': xs) where + +class Top x +instance Top x + +type SListI = All Top + +class All SListI (Code a) => Generic (a :: Type) where + type Code a :: [[Type]] + +data T = MkT Int +instance Generic T where + type Code T = '[ '[Int] ] ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -323,3 +323,4 @@ test('T17966', makefile_test, ['T17966']) # NB: T17810: -fspecialise-aggressively test('T17810', normal, multimod_compile, ['T17810', '-fspecialise-aggressively -dcore-lint -O -v0']) +test('T18120', normal, compile, ['-dcore-lint -O']) ===================================== testsuite/tests/simplCore/should_compile/spec004.stderr ===================================== @@ -5,18 +5,20 @@ Result size of Specialise -- RHS size: {terms: 14, types: 12, coercions: 0, joins: 0/0} $sfoo [InlPrag=NOINLINE[0]] :: Int -> [Char] -[LclId] +[LclId, Arity=1] $sfoo = \ (y :: Int) -> GHC.Base.build - @Char - (\ (@b) (c [OS=OneShot] :: Char -> b -> b) (n [OS=OneShot] :: b) -> + @ Char + (\ (@ b) + (c [OS=OneShot] :: Char -> b -> b) + (n [OS=OneShot] :: b) -> GHC.Base.foldr - @Char - @b + @ Char + @ b c - (GHC.CString.unpackFoldrCString# @b "!"# c n) - (show @Int GHC.Show.$fShowInt y)) + (GHC.CString.unpackFoldrCString# @ b "!"# c n) + (show @ Int GHC.Show.$fShowInt y)) -- RHS size: {terms: 17, types: 17, coercions: 0, joins: 0/0} foo [InlPrag=NOINLINE[0]] :: forall a. () -> Show a => a -> String @@ -24,19 +26,23 @@ foo [InlPrag=NOINLINE[0]] :: forall a. () -> Show a => a -> String Arity=3, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 30 0] 150 40}, - RULES: "SPEC foo @Int" [0] - forall (dk :: ()) ($dShow :: Show Int). foo @Int dk $dShow = $sfoo] + RULES: "SPEC foo @ Int" [0] + forall (dk :: ()) ($dShow :: Show Int). + foo @ Int dk $dShow + = $sfoo] foo - = \ (@a) _ [Occ=Dead] ($dShow :: Show a) (y :: a) -> + = \ (@ a) _ [Occ=Dead] ($dShow :: Show a) (y :: a) -> GHC.Base.build - @Char - (\ (@b) (c [OS=OneShot] :: Char -> b -> b) (n [OS=OneShot] :: b) -> + @ Char + (\ (@ b) + (c [OS=OneShot] :: Char -> b -> b) + (n [OS=OneShot] :: b) -> GHC.Base.foldr - @Char - @b + @ Char + @ b c - (GHC.CString.unpackFoldrCString# @b "!"# c n) - (show @a $dShow y)) + (GHC.CString.unpackFoldrCString# @ b "!"# c n) + (show @ a $dShow y)) -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Prim.Addr# @@ -78,7 +84,7 @@ bar :: String [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=False, ConLike=False, WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 50 0}] -bar = foo @Int GHC.Tuple.() GHC.Show.$fShowInt (GHC.Types.I# 42#) +bar = foo @ Int GHC.Tuple.() GHC.Show.$fShowInt (GHC.Types.I# 42#) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f579acd1b0531fb19831b3bf3012263c4bb532df...309cff632977d372a65c698d6cd16992558acac7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f579acd1b0531fb19831b3bf3012263c4bb532df...309cff632977d372a65c698d6cd16992558acac7 You're receiving 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 Jul 23 19:41:42 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 23 Jul 2020 15:41:42 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: [linker] Fix out of range relocations. Message-ID: <5f19e7f61b182_80b104edf444780257@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - 0d52ac36 by Tamar Christina at 2020-07-23T15:41:35-04:00 winio: restore console cp on exit - - - - - 6f71d32f by Tamar Christina at 2020-07-23T15:41:36-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - 13 changed files: - includes/HsFFI.h - libraries/base/GHC/Event/Windows.hsc - libraries/base/GHC/Event/Windows/FFI.hsc - rts/Linker.c - rts/LinkerInternals.h - rts/RtsStartup.c - rts/linker/Elf.c - rts/linker/LoadArchive.c - rts/linker/M32Alloc.c - rts/linker/MachO.c - rts/linker/SymbolExtras.c - rts/linker/elf_got.c - rts/win32/veh_excn.c Changes: ===================================== includes/HsFFI.h ===================================== @@ -102,6 +102,7 @@ extern void hs_exit (void); extern void hs_exit_nowait(void); extern void hs_set_argv (int argc, char *argv[]); extern void hs_thread_done (void); +extern void hs_restoreConsoleCP (void); extern void hs_perform_gc (void); ===================================== libraries/base/GHC/Event/Windows.hsc ===================================== @@ -86,7 +86,9 @@ import Data.Foldable (mapM_, length, forM_) import Data.Maybe (isJust, maybe) import GHC.Event.Windows.Clock (Clock, Seconds, getClock, getTime) -import GHC.Event.Windows.FFI (LPOVERLAPPED, OVERLAPPED_ENTRY(..)) +import GHC.Event.Windows.FFI (LPOVERLAPPED, OVERLAPPED_ENTRY(..), + CompletionData(..), CompletionCallback, + withRequest) import GHC.Event.Windows.ManagedThreadPool import GHC.Event.Internal.Types import GHC.Event.Unique @@ -300,43 +302,6 @@ foreign import ccall safe "completeSynchronousRequest" ------------------------------------------------------------------------ -- Manager structures --- | Callback type that will be called when an I/O operation completes. -type IOCallback = CompletionCallback () - --- | Wrap the IOCallback type into a FunPtr. -foreign import ccall "wrapper" - wrapIOCallback :: IOCallback -> IO (FunPtr IOCallback) - --- | Unwrap a FunPtr IOCallback to a normal Haskell function. -foreign import ccall "dynamic" - mkIOCallback :: FunPtr IOCallback -> IOCallback - --- | Structure that the I/O manager uses to associate callbacks with --- additional payload such as their OVERLAPPED structure and Win32 handle --- etc. *Must* be kept in sync with that in `winio_structs.h` or horrible things --- happen. --- --- We keep the handle around for the benefit of ghc-external libraries making --- use of the manager. -data CompletionData = CompletionData { cdHandle :: !HANDLE - , cdCallback :: !IOCallback - } - -instance Storable CompletionData where - sizeOf _ = #{size CompletionData} - alignment _ = #{alignment CompletionData} - - peek ptr = do - cdCallback <- mkIOCallback `fmap` #{peek CompletionData, cdCallback} ptr - cdHandle <- #{peek CompletionData, cdHandle} ptr - let !cd = CompletionData{..} - return cd - - poke ptr CompletionData{..} = do - cb <- wrapIOCallback cdCallback - #{poke CompletionData, cdCallback} ptr cb - #{poke CompletionData, cdHandle} ptr cdHandle - -- | Pointer offset in bytes to the location of hoData in HASKELL_OVERLAPPPED cdOffset :: Int cdOffset = #{const __builtin_offsetof (HASKELL_OVERLAPPED, hoData)} @@ -507,11 +472,6 @@ data CbResult a -- manager will perform additional checks. deriving Show --- | Called when the completion is delivered. -type CompletionCallback a = ErrCode -- ^ 0 indicates success - -> DWORD -- ^ Number of bytes transferred - -> IO a - -- | Associate a 'HANDLE' with the current I/O manager's completion port. -- This must be done before using the handle with 'withOverlapped'. associateHandle' :: HANDLE -> IO () @@ -581,23 +541,18 @@ withOverlappedEx mgr fname h offset startCB completionCB = do signalThrow ex = failIfFalse_ (dbgMsg "signalThrow") $ writeIOPort signal (IOFailed ex) mask_ $ do - let completionCB' e b = completionCB e b >>= \result -> - case result of - IOSuccess val -> signalReturn val - IOFailed err -> signalThrow err - hs_lpol <- FFI.allocOverlapped offset - -- Create the completion record and store it. - -- We only need the record when we enqueue a request, however if we - -- delay creating it then we will run into a race condition where the - -- driver may have finished servicing the request before we were ready - -- and so the request won't have the book keeping information to know - -- what to do. So because of that we always create the payload, If we - -- need it ok, if we don't that's no problem. This approach prevents - -- expensive lookups in hash-tables. - -- - -- Todo: Use a memory pool for this so we don't have to hit malloc every - -- time. This would allow us to scale better. - cdData <- new (CompletionData h completionCB') :: IO (Ptr CompletionData) + let completionCB' e b = completionCB e b >>= \result -> + case result of + IOSuccess val -> signalReturn val + IOFailed err -> signalThrow err + let callbackData = CompletionData h completionCB' + -- Note [Memory Management] + -- These callback data and especially the overlapped structs have to keep + -- alive throughout the entire lifetime of the requests. Since this + -- function will block until done so it can call completionCB at the end + -- we can safely use dynamic memory management here and so reduce the + -- possibility of memory errors. + withRequest offset callbackData $ \hs_lpol cdData -> do let ptr_lpol = hs_lpol `plusPtr` cdOffset let lpol = castPtr hs_lpol debugIO $ "hs_lpol:" ++ show hs_lpol @@ -713,11 +668,8 @@ withOverlappedEx mgr fname h offset startCB completionCB = do debugIO $ "## Waiting for cancellation record... " _ <- FFI.getOverlappedResult h lpol True oldDataPtr <- exchangePtr ptr_lpol nullReq - -- Check if we have to free and cleanup pointer when (oldDataPtr == cdData) $ - do free oldDataPtr - free hs_lpol - reqs <- removeRequest + do reqs <- removeRequest debugIO $ "-1.. " ++ show reqs ++ " requests queued after error." status <- fmap fromIntegral getLastError completionCB' status 0 @@ -741,7 +693,6 @@ withOverlappedEx mgr fname h offset startCB completionCB = do case startCBResult of CbPending -> runner CbDone rdata -> do - free cdData debugIO $ dbgMsg $ ":: done " ++ show lpol ++ " - " ++ show rdata bytes <- if isJust rdata then return rdata @@ -749,23 +700,18 @@ withOverlappedEx mgr fname h offset startCB completionCB = do else FFI.getOverlappedResult h lpol False debugIO $ dbgMsg $ ":: done bytes: " ++ show bytes case bytes of - Just res -> free hs_lpol >> completionCB 0 res + Just res -> completionCB 0 res Nothing -> do err <- FFI.overlappedIOStatus lpol numBytes <- FFI.overlappedIONumBytes lpol -- TODO: Remap between STATUS_ and ERROR_ instead -- of re-interpret here. But for now, don't care. let err' = fromIntegral err - free hs_lpol debugIO $ dbgMsg $ ":: done callback: " ++ show err' ++ " - " ++ show numBytes completionCB err' (fromIntegral numBytes) CbError err -> do - free cdData - free hs_lpol let err' = fromIntegral err completionCB err' 0 _ -> do - free cdData - free hs_lpol error "unexpected case in `startCBResult'" where dbgMsg s = s ++ " (" ++ show h ++ ":" ++ show offset ++ ")" -- Wait for .25ms (threaded) and 1ms (non-threaded) @@ -1099,15 +1045,17 @@ processCompletion Manager{..} n delay = do do debugIO $ "exchanged: " ++ show oldDataPtr payload <- peek oldDataPtr :: IO CompletionData let !cb = cdCallback payload - free oldDataPtr reqs <- removeRequest debugIO $ "-1.. " ++ show reqs ++ " requests queued." status <- FFI.overlappedIOStatus (lpOverlapped oe) -- TODO: Remap between STATUS_ and ERROR_ instead -- of re-interpret here. But for now, don't care. let status' = fromIntegral status + -- We no longer explicitly free the memory, this is because we + -- now require the callback to free the memory since the + -- callback allocated it. This allows us to simplify memory + -- management and reduce bugs. See Note [Memory Management]. cb status' (dwNumberOfBytesTransferred oe) - free hs_lpol -- clear the array so we don't erroneously interpret the output, in -- certain circumstances like lockFileEx the code could return 1 entry ===================================== libraries/base/GHC/Event/Windows/FFI.hsc ===================================== @@ -30,6 +30,11 @@ module GHC.Event.Windows.FFI ( postQueuedCompletionStatus, getOverlappedResult, + -- * Completion Data + CompletionData(..), + CompletionCallback, + withRequest, + -- * Overlapped OVERLAPPED, LPOVERLAPPED, @@ -215,6 +220,51 @@ postQueuedCompletionStatus iocp numBytes completionKey lpol = failIfFalse_ "PostQueuedCompletionStatus" $ c_PostQueuedCompletionStatus iocp numBytes completionKey lpol +------------------------------------------------------------------------ +-- Completion Data + +-- | Called when the completion is delivered. +type CompletionCallback a = ErrCode -- ^ 0 indicates success + -> DWORD -- ^ Number of bytes transferred + -> IO a + +-- | Callback type that will be called when an I/O operation completes. +type IOCallback = CompletionCallback () + +-- | Wrap the IOCallback type into a FunPtr. +foreign import ccall "wrapper" + wrapIOCallback :: IOCallback -> IO (FunPtr IOCallback) + +-- | Unwrap a FunPtr IOCallback to a normal Haskell function. +foreign import ccall "dynamic" + mkIOCallback :: FunPtr IOCallback -> IOCallback + +-- | Structure that the I/O manager uses to associate callbacks with +-- additional payload such as their OVERLAPPED structure and Win32 handle +-- etc. *Must* be kept in sync with that in `winio_structs.h` or horrible things +-- happen. +-- +-- We keep the handle around for the benefit of ghc-external libraries making +-- use of the manager. +data CompletionData = CompletionData { cdHandle :: !HANDLE + , cdCallback :: !IOCallback + } + +instance Storable CompletionData where + sizeOf _ = #{size CompletionData} + alignment _ = #{alignment CompletionData} + + peek ptr = do + cdCallback <- mkIOCallback `fmap` #{peek CompletionData, cdCallback} ptr + cdHandle <- #{peek CompletionData, cdHandle} ptr + let !cd = CompletionData{..} + return cd + + poke ptr CompletionData{..} = do + cb <- wrapIOCallback cdCallback + #{poke CompletionData, cdCallback} ptr cb + #{poke CompletionData, cdHandle} ptr cdHandle + ------------------------------------------------------------------------ -- Overlapped @@ -293,6 +343,30 @@ pokeOffsetOverlapped lpol offset = do #{poke OVERLAPPED, OffsetHigh} lpol offsetHigh {-# INLINE pokeOffsetOverlapped #-} +------------------------------------------------------------------------ +-- Request management + +withRequest :: Word64 -> CompletionData + -> (Ptr HASKELL_OVERLAPPED -> Ptr CompletionData -> IO a) + -> IO a +withRequest offset cbData f = + -- Create the completion record and store it. + -- We only need the record when we enqueue a request, however if we + -- delay creating it then we will run into a race condition where the + -- driver may have finished servicing the request before we were ready + -- and so the request won't have the book keeping information to know + -- what to do. So because of that we always create the payload, If we + -- need it ok, if we don't that's no problem. This approach prevents + -- expensive lookups in hash-tables. + -- + -- Todo: Use a memory pool for this so we don't have to hit malloc every + -- time. This would allow us to scale better. + allocaBytes #{size HASKELL_OVERLAPPED} $ \hs_lpol -> + with cbData $ \cdData -> do + zeroOverlapped hs_lpol + pokeOffsetOverlapped (castPtr hs_lpol) offset + f hs_lpol cdData + ------------------------------------------------------------------------ -- Cancel pending I/O ===================================== rts/Linker.c ===================================== @@ -188,7 +188,7 @@ int ocTryLoad( ObjectCode* oc ); * * MAP_32BIT not available on OpenBSD/amd64 */ -#if defined(MAP_32BIT) && defined(x86_64_HOST_ARCH) +#if defined(MAP_32BIT) && (defined(x86_64_HOST_ARCH) || (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH))) #define MAP_LOW_MEM #define TRY_MAP_32BIT MAP_32BIT #else @@ -214,10 +214,22 @@ int ocTryLoad( ObjectCode* oc ); * systems, we have to pick a base address in the low 2Gb of the address space * and try to allocate memory from there. * + * The same holds for aarch64, where the default, even with PIC, model + * is 4GB. The linker is free to emit AARCH64_ADR_PREL_PG_HI21 + * relocations. + * * We pick a default address based on the OS, but also make this * configurable via an RTS flag (+RTS -xm) */ -#if defined(MAP_32BIT) || DEFAULT_LINKER_ALWAYS_PIC + +#if (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH)) +// Try to use stg_upd_frame_info as the base. We need to be within +-4GB of that +// address, otherwise we violate the aarch64 memory model. Any object we load +// can potentially reference any of the ones we bake into the binary (and list) +// in RtsSymbols. Thus we'll need to be within +-4GB of those, +// stg_upd_frame_info is a good candidate as it's referenced often. +#define MMAP_32BIT_BASE_DEFAULT (void*)&stg_upd_frame_info; +#elif defined(MAP_32BIT) || DEFAULT_LINKER_ALWAYS_PIC // Try to use MAP_32BIT #define MMAP_32BIT_BASE_DEFAULT 0 #else @@ -1040,11 +1052,47 @@ resolveSymbolAddr (pathchar* buffer, int size, } #if RTS_LINKER_USE_MMAP + +/* ----------------------------------------------------------------------------- + Occationally we depend on mmap'd region being close to already mmap'd regions. + + Our static in-memory linker may be restricted by the architectures relocation + range. E.g. aarch64 has a +-4GB range for PIC code, thus we'd preferrably + get memory for the linker close to existing mappings. mmap on it's own is + free to return any memory location, independent of what the preferred + location argument indicates. + + For example mmap (via qemu) might give you addresses all over the available + memory range if the requested location is already occupied. + + mmap_next will do a linear search from the start page upwards to find a + suitable location that is as close as possible to the locations (proivded + via the first argument). + -------------------------------------------------------------------------- */ + +void* +mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { + if(addr == NULL) return mmap(addr, length, prot, flags, fd, offset); + // we are going to look for up to pageSize * 1024 * 1024 (4GB) from the + // address. + size_t pageSize = getPageSize(); + for(int i = (uintptr_t)addr & (pageSize-1) ? 1 : 0; i < 1024*1024; i++) { + void *target = (void*)(((uintptr_t)addr & ~(pageSize-1))+(i*pageSize)); + void *mem = mmap(target, length, prot, flags, fd, offset); + if(mem == NULL) return mem; + if(mem == target) return mem; + munmap(mem, length); + IF_DEBUG(linker && (i % 1024 == 0), + debugBelch("mmap_next failed to find suitable space in %p - %p\n", addr, target)); + } + return NULL; +} + // // Returns NULL on failure. // void * -mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset) +mmapForLinker (size_t bytes, uint32_t prot, uint32_t flags, int fd, int offset) { void *map_addr = NULL; void *result; @@ -1065,15 +1113,14 @@ mmap_again: map_addr = mmap_32bit_base; } - const int prot = PROT_READ | PROT_WRITE; IF_DEBUG(linker, debugBelch("mmapForLinker: \tprotection %#0x\n", prot)); IF_DEBUG(linker, debugBelch("mmapForLinker: \tflags %#0x\n", MAP_PRIVATE | tryMap32Bit | fixed | flags)); - result = mmap(map_addr, size, prot, - MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); + result = mmap_next(map_addr, size, prot, + MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); if (result == MAP_FAILED) { sysErrorBelch("mmap %" FMT_Word " bytes at %p",(W_)size,map_addr); @@ -1126,6 +1173,28 @@ mmap_again: goto mmap_again; } } +#elif (defined(aarch64_TARGET_ARCH) || defined(aarch64_HOST_ARCH)) + // for aarch64 we need to make sure we stay within 4GB of the + // mmap_32bit_base, and we also do not want to update it. +// if (mmap_32bit_base != (void*)&stg_upd_frame_info) { + if (result == map_addr) { + mmap_32bit_base = (void*)((uintptr_t)map_addr + size); + } else { + // upper limit 4GB - size of the object file - 1mb wiggle room. + if(llabs((uintptr_t)result - (uintptr_t)&stg_upd_frame_info) > (2<<32) - size - (2<<20)) { + // not within range :( + debugTrace(DEBUG_linker, + "MAP_32BIT didn't work; gave us %lu bytes at 0x%p", + bytes, result); + munmap(result, size); + // TODO: some abort/mmap_32bit_base recomputation based on + // if mmap_32bit_base is changed, or still at stg_upd_frame_info + goto mmap_again; + } else { + mmap_32bit_base = (void*)((uintptr_t)result + size); + } + } +// } #endif IF_DEBUG(linker, @@ -1454,9 +1523,9 @@ preloadObjectFile (pathchar *path) * See also the misalignment logic for darwin below. */ #if defined(ios_HOST_OS) - image = mmap(NULL, fileSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); + image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); #else - image = mmap(NULL, fileSize, PROT_READ|PROT_WRITE|PROT_EXEC, + image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, fd, 0); #endif ===================================== rts/LinkerInternals.h ===================================== @@ -14,6 +14,7 @@ #if RTS_LINKER_USE_MMAP #include +void* mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset); #endif void printLoadedObjects(void); @@ -293,7 +294,7 @@ void exitLinker( void ); void freeObjectCode (ObjectCode *oc); SymbolAddr* loadSymbol(SymbolName *lbl, RtsSymbolInfo *pinfo); -void *mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset); +void *mmapForLinker (size_t bytes, uint32_t prot, uint32_t flags, int fd, int offset); void mmapForLinkerMarkExecutable (void *start, size_t len); void addProddableBlock ( ObjectCode* oc, void* start, int size ); ===================================== rts/RtsStartup.c ===================================== @@ -68,6 +68,11 @@ static int hs_init_count = 0; static bool rts_shutdown = false; +#if defined(mingw32_HOST_OS) +/* Indicates CodePage to set program to after exit. */ +static int64_t __codePage = 0; +#endif + static void flushStdHandles(void); /* ----------------------------------------------------------------------------- @@ -128,13 +133,38 @@ void fpreset(void) { static void initConsoleCP (void) { + /* Set the initial codepage to automatic. */ + __codePage = -1; + /* Check if the codepage is still the system default ANSI codepage. */ - if (GetConsoleCP () == GetOEMCP ()) { - if (! SetConsoleCP (CP_UTF8)) + if (GetConsoleCP () == GetOEMCP () + && GetConsoleOutputCP () == GetOEMCP ()) { + if (!SetConsoleCP (CP_UTF8) || !SetConsoleOutputCP (CP_UTF8)) errorBelch ("Unable to set console CodePage, Unicode output may be " "garbled.\n"); else IF_DEBUG (scheduler, debugBelch ("Codepage set to UTF-8.\n")); + + /* Assign the codepage so we can restore it on exit. */ + __codePage = (int64_t)GetOEMCP (); + } +} + +/* Restore the CodePage to what it was before we started. If the CodePage was + already set then this call is a no-op. */ +void +hs_restoreConsoleCP (void) +{ + /* If we set the CP at startup, we should set it on exit. */ + if (__codePage == -1) + return; + + UINT cp = (UINT)__codePage; + __codePage = -1; + if (SetConsoleCP (cp) && SetConsoleOutputCP (cp)) { + IF_DEBUG (scheduler, debugBelch ("Codepage restored to OEM.\n")); + } else { + IF_DEBUG (scheduler, debugBelch ("Unable to restore CodePage to OEM.\n")); } } #endif @@ -533,6 +563,11 @@ hs_exit_(bool wait_foreign) shutdownAsyncIO(wait_foreign); #endif + /* Restore the console Codepage. */ +#if defined(mingw32_HOST_OS) + if (is_io_mng_native_p()) + hs_restoreConsoleCP(); +#endif /* free hash table storage */ exitHashTable(); ===================================== rts/linker/Elf.c ===================================== @@ -637,7 +637,7 @@ mapObjectFileSection (int fd, Elf_Word offset, Elf_Word size, pageOffset = roundDownToPage(offset); pageSize = roundUpToPage(offset-pageOffset+size); - p = mmapForLinker(pageSize, 0, fd, pageOffset); + p = mmapForLinker(pageSize, PROT_READ | PROT_WRITE, 0, fd, pageOffset); if (p == NULL) return NULL; *mapped_size = pageSize; *mapped_offset = pageOffset; @@ -709,7 +709,7 @@ ocGetNames_ELF ( ObjectCode* oc ) * address might be out of range for sections that are mmaped. */ alloc = SECTION_MMAP; - start = mmapForLinker(size, MAP_ANONYMOUS, -1, 0); + start = mmapForLinker(size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); mapped_start = start; mapped_offset = 0; mapped_size = roundUpToPage(size); @@ -751,8 +751,9 @@ ocGetNames_ELF ( ObjectCode* oc ) unsigned nstubs = numberOfStubsForSection(oc, i); unsigned stub_space = STUB_SIZE * nstubs; - void * mem = mmapForLinker(size+stub_space, MAP_ANON, -1, 0); - if( mem == NULL ) { + void * mem = mmapForLinker(size+stub_space, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + + if( mem == MAP_FAILED ) { barf("failed to mmap allocated memory to load section %d. " "errno = %d", i, errno); } @@ -841,6 +842,26 @@ ocGetNames_ELF ( ObjectCode* oc ) unsigned curSymbol = 0; + unsigned long common_size = 0; + unsigned long common_used = 0; + for(ElfSymbolTable *symTab = oc->info->symbolTables; + symTab != NULL; symTab = symTab->next) { + for (size_t j = 0; j < symTab->n_symbols; j++) { + ElfSymbol *symbol = &symTab->symbols[j]; + if (SHN_COMMON == symTab->symbols[j].elf_sym->st_shndx) { + common_size += symbol->elf_sym->st_size; + } + } + } + void * common_mem = NULL; + if(common_size > 0) { + common_mem = mmapForLinker(common_size, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, + -1, 0); + ASSERT(common_mem != NULL); + } + //TODO: we ignore local symbols anyway right? So we can use the // shdr[i].sh_info to get the index of the first non-local symbol // ie we should use j = shdr[i].sh_info @@ -876,12 +897,15 @@ ocGetNames_ELF ( ObjectCode* oc ) if (shndx == SHN_COMMON) { isLocal = false; - symbol->addr = stgCallocBytes(1, symbol->elf_sym->st_size, - "ocGetNames_ELF(COMMON)"); - /* - debugBelch("COMMON symbol, size %d name %s\n", - stab[j].st_size, nm); - */ + ASSERT(common_used < common_size); + ASSERT(common_mem); + symbol->addr = (void*)((uintptr_t)common_mem + common_used); + common_used += symbol->elf_sym->st_size; + ASSERT(common_used <= common_size); + + debugBelch("COMMON symbol, size %ld name %s allocated at %p\n", + symbol->elf_sym->st_size, nm, symbol->addr); + /* Pointless to do addProddableBlock() for this area, since the linker should never poke around in it. */ } else if ((ELF_ST_BIND(symbol->elf_sym->st_info) == STB_GLOBAL ===================================== rts/linker/LoadArchive.c ===================================== @@ -489,7 +489,7 @@ static HsInt loadArchive_ (pathchar *path) #if defined(darwin_HOST_OS) || defined(ios_HOST_OS) if (RTS_LINKER_USE_MMAP) - image = mmapForLinker(memberSize, MAP_ANONYMOUS, -1, 0); + image = mmapForLinker(memberSize, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); else { /* See loadObj() */ misalignment = machoGetMisalignment(f); @@ -548,7 +548,7 @@ while reading filename from `%" PATH_FMT "'", path); } DEBUG_LOG("Found GNU-variant file index\n"); #if RTS_LINKER_USE_MMAP - gnuFileIndex = mmapForLinker(memberSize + 1, MAP_ANONYMOUS, -1, 0); + gnuFileIndex = mmapForLinker(memberSize + 1, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); #else gnuFileIndex = stgMallocBytes(memberSize + 1, "loadArchive(image)"); #endif ===================================== rts/linker/M32Alloc.c ===================================== @@ -256,7 +256,7 @@ m32_alloc_page(void) m32_free_page_pool_size --; return page; } else { - struct m32_page_t *page = mmapForLinker(getPageSize(),MAP_ANONYMOUS,-1,0); + struct m32_page_t *page = mmapForLinker(getPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); if (page > (struct m32_page_t *) 0xffffffff) { barf("m32_alloc_page: failed to get allocation in lower 32-bits"); } @@ -280,7 +280,7 @@ m32_allocator_new(bool executable) // Preallocate the initial M32_MAX_PAGES to ensure that they don't // fragment the memory. size_t pgsz = getPageSize(); - char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES,MAP_ANONYMOUS,-1,0); + char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,-1,0); if (bigchunk == NULL) barf("m32_allocator_init: Failed to map"); @@ -396,7 +396,7 @@ m32_alloc(struct m32_allocator_t *alloc, size_t size, size_t alignment) if (m32_is_large_object(size,alignment)) { // large object size_t alsize = ROUND_UP(sizeof(struct m32_page_t), alignment); - struct m32_page_t *page = mmapForLinker(alsize+size,MAP_ANONYMOUS,-1,0); + struct m32_page_t *page = mmapForLinker(alsize+size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,-1,0); page->filled_page.size = alsize + size; m32_allocator_push_filled_list(&alloc->unprotected_list, (struct m32_page_t *) page); return (char*) page + alsize; ===================================== rts/linker/MachO.c ===================================== @@ -508,7 +508,7 @@ makeGot(ObjectCode * oc) { if(got_slots > 0) { oc->info->got_size = got_slots * sizeof(void*); - oc->info->got_start = mmap(NULL, oc->info->got_size, + oc->info->got_start = mmapForLinker(oc->info->got_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); @@ -1114,7 +1114,7 @@ ocBuildSegments_MachO(ObjectCode *oc) return 1; } - mem = mmapForLinker(size_compound, MAP_ANON, -1, 0); + mem = mmapForLinker(size_compound, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); if (NULL == mem) return 0; IF_DEBUG(linker, debugBelch("ocBuildSegments: allocating %d segments\n", n_activeSegments)); ===================================== rts/linker/SymbolExtras.c ===================================== @@ -79,7 +79,7 @@ int ocAllocateExtras(ObjectCode* oc, int count, int first, int bssSize) size_t n = roundUpToPage(oc->fileSize); bssSize = roundUpToAlign(bssSize, 8); size_t allocated_size = n + bssSize + extras_size; - void *new = mmapForLinker(allocated_size, MAP_ANONYMOUS, -1, 0); + void *new = mmapForLinker(allocated_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); if (new) { memcpy(new, oc->image, oc->fileSize); if (oc->imageMapped) { ===================================== rts/linker/elf_got.c ===================================== @@ -48,7 +48,7 @@ makeGot(ObjectCode * oc) { } if(got_slots > 0) { oc->info->got_size = got_slots * sizeof(void *); - void * mem = mmap(NULL, oc->info->got_size, + void * mem = mmapForLinker(oc->info->got_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); ===================================== rts/win32/veh_excn.c ===================================== @@ -153,6 +153,7 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data) if (EXCEPTION_CONTINUE_EXECUTION == action) { fflush(stderr); + hs_restoreConsoleCP (); generateStack (exception_data); generateDump (exception_data); stg_exit(exit_code); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/862917378d92e19ba36af986d6f30d0af1dcd572...6f71d32f7c63e732dd905e8c7643e20101298568 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/862917378d92e19ba36af986d6f30d0af1dcd572...6f71d32f7c63e732dd905e8c7643e20101298568 You're receiving 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 Jul 23 21:09:49 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Thu, 23 Jul 2020 17:09:49 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/parser-refactor-jul24 Message-ID: <5f19fc9deb7fc_80b3f849248fe08478412e@gitlab.haskell.org.mail> Vladislav Zavialov pushed new branch wip/parser-refactor-jul24 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/parser-refactor-jul24 You're receiving 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 Jul 23 21:11:53 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Thu, 23 Jul 2020 17:11:53 -0400 Subject: [Git][ghc/ghc][wip/disamb-td] 857 commits: Show breakpoint locations of breakpoints which were ignored during :force (#2950) Message-ID: <5f19fd197679_80b3f84868c3828478572c@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/disamb-td at Glasgow Haskell Compiler / GHC Commits: 3979485b by Roland Senn at 2020-02-29T17:36:59+01:00 Show breakpoint locations of breakpoints which were ignored during :force (#2950) GHCi is split up into 2 major parts: The user-interface (UI) and the byte-code interpreter. With `-fexternal-interpreter` they even run in different processes. Communication between the UI and the Interpreter (called `iserv`) is done using messages over a pipe. This is called `Remote GHCI` and explained in the Note [Remote GHCi] in `compiler/ghci/GHCi.hs`. To process a `:force` command the UI sends a `Seq` message to the `iserv` process. Then `iserv` does the effective evaluation of the value. When during this process a breakpoint is hit, the `iserv` process has no additional information to enhance the `Ignoring breakpoint` output with the breakpoint location. To be able to print additional breakpoint information, there are 2 possible implementation choices: 1. Store the needed information in the `iserv` process. 2. Print the `Ignoring breakpoint` from the UI process. For option 1 we need to store the breakpoint info redundantely in 2 places and this is bad. Therfore option 2 was implemented in this MR: - The user enters a `force` command - The UI sends a `Seq` message to the `iserv` process. - If processing of the `Seq` message hits a breakpoint, the `iserv` process returns control to the UI process. - The UI looks up the source location of the breakpoint, and prints the enhanced `Ignoring breakpoint` output. - The UI sends a `ResumeSeq` message to the `iserv` process, to continue forcing. - - - - - 3cf7303b by Krzysztof Gogolewski at 2020-03-02T01:18:33-05:00 Remove dead code * The names in PrelName and THNames are no longer used since TH merged types and kinds, Typeable is kind-polymorphic, .net support was removed * unqualQuasiQuote no longer used since 6f8ff0bbad3b9fa3 - - - - - dbea7e9d by Ilias Tsitsimpis at 2020-03-02T01:19:12-05:00 Do not define hs_atomic{read,write}64() on non-64bit Do not define hs_atomicread64() and hs_atomicwrite64() on machines where WORD_SIZE_IN_BITS is less than 64, just like we do with the rest of the atomic functions which work on 64-bit values. Without this, compilation fails on MIPSel and PowerPC with the following error: /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicread64': atomic.c:(.text.hs_atomicread64+0x8): undefined reference to `__sync_add_and_fetch_8' /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicwrite64': atomic.c:(.text.hs_atomicwrite64+0x38): undefined reference to `__sync_bool_compare_and_swap_8' Fixes #17886. - - - - - 7c0c76fb by Roland Senn at 2020-03-02T17:13:55-05:00 Set `ImpredicativeTypes` during :print command. (#14828) If ImpredicativeTypes is not enabled, then `:print <term>` will fail if the type of <term> has nested `forall`s or `=>`s. This is because the GHCi debugger's internals will attempt to unify a metavariable with the type of <term> and then display the result, but if the type has nested `forall`s or `=>`s, then unification will fail. As a result, `:print` will bail out and the unhelpful result will be `<term> = (_t1::t1)` (where `t1` is a metavariable). Beware: <term> can have nested `forall`s even if its definition doesn't use RankNTypes! Here is an example from #14828: class Functor f where fmap :: (a -> b) -> f a -> f b Somewhat surprisingly, `:print fmap` considers the type of fmap to have nested foralls. This is because the GHCi debugger sees the type `fmap :: forall f. Functor f => forall a b. (a -> b) -> f a -> f b`. We could envision deeply instantiating this type to get the type `forall f a b. Functor f => (a -> b) -> f a -> f b`, but this trick wouldn't work for higher-rank types. Instead, we adopt a simpler fix: enable `ImpredicativeTypes` when using `:print` and friends in the GHCi debugger. This is allows metavariables to unify with types that have nested (or higher-rank) `forall`s/`=>`s, which makes `:print fmap` display as `fmap = (_t1::forall a b. Functor f => (a -> b) -> f a -> f b)`, as expected. Although ImpredicativeTypes is a somewhat unpredictable from a type inference perspective, there is no danger in using it in the GHCi debugger, since all of the terms that the GHCi debugger deals with have already been typechecked. - - - - - 2a2f51d7 by Sylvain Henry at 2020-03-02T17:14:38-05:00 Use configure script to detect that we should use in-tree GMP on Windows - - - - - 8c663c2c by Andreas Klebinger at 2020-03-04T16:12:14+01:00 Be explicit about how stack usage of mvar primops are covered. This fixes #17893 [skip-ci] - - - - - cedd6f30 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Add getCurrentThreadCPUTime helper - - - - - ace618cd by Ben Gamari at 2020-03-05T14:53:12-05:00 nonmoving-gc: Track time usage of nonmoving marking - - - - - 022b5ad5 by Ben Gamari at 2020-03-05T14:53:12-05:00 Stats: Add sync pauses to +RTS -S output - - - - - 06763234 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Report nonmoving collector statistics in machine-readable output - - - - - 70d2b995 by Ben Gamari at 2020-03-09T06:10:52-04:00 nonmoving: Fix collection of sparks Previously sparks living in the non-moving heap would be promptly GC'd by the minor collector since pruneSparkQueue uses the BF_EVACUATED flag, which non-moving heap blocks do not have set. Fix this by implementing proper support in pruneSparkQueue for determining reachability in the non-moving heap. The story is told in Note [Spark management in the nonmoving heap]. - - - - - 9668781a by Ben Gamari at 2020-03-09T06:11:30-04:00 gitlab-ci: Disable Sphinx documentation in Alpine build - - - - - 8eb2c263 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 Fix Windows breakage by not touching locales on Windows - - - - - b8dab057 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: ensure C numerics in heap profiles using Windows locales if needed - - - - - 7d95260f by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: refactor and comment profile locales - - - - - 5b627813 by Ryan Scott at 2020-03-09T16:34:14-04:00 Use InstanceSigs in GND/DerivingVia-generated code (#17899) Aside from making the generated code easier to read when `-ddump-deriv` is enabled, this makes the error message in `T15073` substantially simpler (see the updated `T15073` expected stderr). Fixes #17899. - - - - - 70b50778 by Ben Gamari at 2020-03-10T02:05:42-04:00 SysTools: Ensure that error parser can handle absolute paths on Windows This fixes #17786, where the error parser fails to correctly handle the drive name in absolute Windows paths. Unfortunately I couldn't find a satisfactory way to test this. - - - - - 85b861d8 by Ben Gamari at 2020-03-10T02:05:42-04:00 testsuite: Add test for #17786 This isn't pretty but it's perhaps better than nothing. - - - - - ee2c50cb by Sylvain Henry at 2020-03-10T02:06:33-04:00 Hadrian: track missing configure results - - - - - ca8f51d4 by Ömer Sinan Ağacan at 2020-03-10T02:07:22-04:00 Add regression test for T17904 Closes #17904 - - - - - 5fa9cb82 by Richard Eisenberg at 2020-03-10T12:29:46-04:00 anyRewritableTyVar now looks in RuntimeReps Previously, anyRewritableTyVar looked only at the arg and res of `arg -> res`, but their RuntimeReps are also subject to rewriting. Easy to fix. Test case: typecheck/should_compile/T17024 Fixes #17024. - - - - - 5ba01d83 by Ben Price at 2020-03-10T12:30:27-04:00 Clarify a Lint message When developing a plugin I had a shadowing problem, where I generated code app = \f{v r7B} x{v r7B} -> f{v r7B} x{v r7B} This is obviously wrong, since the occurrence of `f` to the right of the arrow refers to the `x` binder (they share a Unique). However, it is rather confusing when Lint reports Mismatch in type between binder and occurrence Var: x{v rB7} since it is printing the binder, rather than the occurrence. It is rather easy to read this as claiming there is something wrong with the `x` occurrence! We change the report to explicitly print both the binder and the occurrence variables. - - - - - 7b2c827b by Simon Peyton Jones at 2020-03-10T12:31:15-04:00 Comments only Clarify code added in #17852 and MR !2724 - - - - - 3300eeac by Krzysztof Gogolewski at 2020-03-10T12:31:54-04:00 Misc cleanup - Remove Note [Existentials in shift_con_pat]. The function shift_con_pat has been removed 15 years ago in 23f40f0e9be6d4. - Remove kcLookupTcTyCon - it's the same as tcLookupTcTyCon - Remove ASSERT in tyConAppArgN. It's already done by getNth, and it's the only reason getNth exists. - Remove unused function nextRole - - - - - abf5736b by Krzysztof Gogolewski at 2020-03-10T18:05:01+01:00 Typos in comments [skip ci] - - - - - bb586f89 by Ben Gamari at 2020-03-11T00:14:59-04:00 rts: Prefer darwin-specific getCurrentThreadCPUTime macOS Catalina now supports a non-POSIX-compliant version of clock_gettime which cannot use the clock_gettime codepath. Fixes #17906. - - - - - 20800b9a by Sylvain Henry at 2020-03-11T08:17:19-04:00 Split GHC.Iface.Utils module * GHC.Iface.Recomp: recompilation avoidance stuff * GHC.Iface.Make: mkIface* Moved `writeIfaceFile` into GHC.Iface.Load alongside `readIface` and renamed it `writeIface` for consistency. - - - - - 1daa2029 by Greg Steuck at 2020-03-11T08:17:56-04:00 Fixed a minor typo in codegen.rst - - - - - 0bc23338 by Ryan Scott at 2020-03-11T08:18:32-04:00 Re-quantify when generalising over rewrite rule types Previously, `tcRules` would check for naughty quantification candidates (see `Note [Naughty quantification candidates]` in `TcMType`) when generalising over the type of a rewrite rule. This caused sensible-looking rewrite rules (like those in #17710) to be rejected. A more permissing (and easier-to-implement) approach is to do what is described in `Note [Generalising in tcTyFamInstEqnGuts]` in `TcTyClsDecls`: just re-quantify all the type variable binders, regardless of the order in which the user specified them. After all, the notion of type variable specificity has no real meaning in rewrite rules, since one cannot "visibly apply" a rewrite rule. I have written up this wisdom in `Note [Re-quantify type variables in rules]` in `TcRules`. As a result of this patch, compiling the `ExplicitForAllRules1` test case now generates one fewer warning than it used to. As far as I can tell, this is benign, since the thing that the disappearing warning talked about was also mentioned in an entirely separate warning. Fixes #17710. - - - - - 336eac7e by Ben Gamari at 2020-03-11T08:19:08-04:00 testsuite: Mark ghci056 and ghcilink004 as fragile in unreg As noted in #17018. Also fix fragile declaration of T13786, which only runs in the normal way. - - - - - c61b9b02 by Simon Peyton Jones at 2020-03-11T08:19:44-04:00 Deepen call stack for isIn I see quite a few warnings like: WARNING: file compiler/utils/Util.hs, line 593 Over-long elem in unionLists But the call stack is uninformative. Better to add HasDebugCallStack to isIn. Ditto isn'tIn. - - - - - 3aa9b35f by Ömer Sinan Ağacan at 2020-03-11T08:20:27-04:00 Zero any slop after compaction in compacting GC In copying GC, with the relevant debug flags enabled, we release the old blocks after a GC, and the block allocator zeroes the space before releasing a block. This effectively zeros the old heap. In compacting GC we reuse the blocks and previously we didn't zero the unused space in a compacting generation after compaction. With this patch we zero the slop between the free pointer and the end of the block when we're done with compaction and when switching to a new block (because the current block doesn't have enough space for the next object we're shifting). - - - - - 8e6febce by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor GHC.Driver.Session (Ways and Flags) * extract flags and ways into their own modules (with some renaming) * remove one SOURCE import of GHC.Driver.Session from GHC.Driver.Phases * when GHC uses dynamic linking (WayDyn), `interpWays` was only reporting WayDyn even if the host was profiled (WayProf). Now it returns both as expected (might fix #16803). * `mkBuildTag :: [Way] -> String` wasn't reporting a canonical tag for differently ordered lists. Now we sort and nub the list to fix this. - - - - - bc41e471 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor interpreterDynamic and interpreterProfiled * `interpreterDynamic` and `interpreterProfiled` now take `Interp` parameters instead of DynFlags * slight refactoring of `ExternalInterp` so that we can read the iserv configuration (which is pure) without reading an MVar. - - - - - a6989971 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Use a Set to represent Ways Should make `member` queries faster and avoid messing up with missing `nubSort`. Metric Increase: hie002 - - - - - cb93a1a4 by Ryan Scott at 2020-03-11T20:34:14-04:00 Make DeriveFunctor-generated code require fewer beta reductions Issue #17880 demonstrates that `DeriveFunctor`-generated code is surprisingly fragile when rank-_n_ types are involved. The culprit is that `$fmap` (the algorithm used to generate `fmap` implementations) was too keen on applying arguments with rank-_n_ types to lambdas, which fail to typecheck more often than not. In this patch, I change `$fmap` (both the specification and the implementation) to produce code that avoids creating as many lambdas, avoiding problems when rank-_n_ field types arise. See the comments titled "Functor instances" in `TcGenFunctor` for a more detailed description. Not only does this fix #17880, but it also ensures that the code that `DeriveFunctor` generates will continue to work after simplified subsumption is implemented (see #17775). What is truly amazing is that #17880 is actually a regression (introduced in GHC 7.6.3) caused by commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e, the fix #7436. Prior to that commit, the version of `$fmap` that was used was almost identical to the one used in this patch! Why did that commit change `$fmap` then? It was to avoid severe performance issues that would arise for recursive `fmap` implementations, such as in the example below: ```hs data List a = Nil | Cons a (List a) deriving Functor -- ===> instance Functor List where fmap f Nil = Nil fmap f (Cons x xs) = Cons (f x) (fmap (\y -> f y) xs) ``` The fact that `\y -> f y` was eta expanded caused significant performance overheads. Commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e fixed this performance issue, but it went too far. As a result, this patch partially reverts 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e. To ensure that the performance issues pre-#7436 do not resurface, I have taken some precautionary measures: * I have added a special case to `$fmap` for situations where the last type variable in an application of some type occurs directly. If this special case fires, we avoid creating a lambda expression. This ensures that we generate `fmap f (Cons x xs) = Cons (f x) (fmap f xs)` in the derived `Functor List` instance above. For more details, see `Note [Avoid unnecessary eta expansion in derived fmap implementations]` in `TcGenFunctor`. * I have added a `T7436b` test case to ensure that the performance of this derived `Functor List`-style code does not regress. When implementing this, I discovered that `$replace`, the algorithm which generates implementations of `(<$)`, has a special case that is very similar to the `$fmap` special case described above. `$replace` marked this special case with a custom `Replacer` data type, which was a bit overkill. In order to use the same machinery for both `Functor` methods, I ripped out `Replacer` and instead implemented a simple way to detect the special case. See the updated commentary in `Note [Deriving <$]` for more details. - - - - - 1f9db3e7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Properly parenthesise LastStmt After ApplicatveDo strips the last `return` during renaming, the pretty printer has to restore it. However, if the return was followed by `$`, the dollar was stripped too and not restored. For example, the last stamement in: ``` foo = do x <- ... ... return $ f x ``` would be printed as: ``` return f x ``` This commit preserved the dolar, so it becomes: ``` return $ f x ``` - - - - - 5cb93af7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Do not print ApplicativeDo join * Do not print `join` in ApplictiveStmt, unless ppr-debug * Print parens around multiple parallel binds When ApplicativeDo is enabled, the renamer analyses the statements of a `do` block and in certain cases marks them as needing to be rewritten using `join`. For example, if you have: ``` foo = do a <- e1 b <- e2 doSomething a b ``` it will be desugared into: ``` foo = join (doSomething <$> e1 <*> e2) ``` After renaming but before desugaring the expression is stored essentially as: ``` foo = do [will need join] (a <- e1 | b <- e2) [no return] doSomething a b ``` Before this change, the pretty printer would print a call to `join`, even though it is not needed at this stage at all. The expression will be actually rewritten into one using join only at desugaring, at which point a literal call to join will be inserted. - - - - - 3a259092 by Simon Peyton Jones at 2020-03-12T09:46:29-04:00 Expose compulsory unfoldings always The unsafeCoerce# patch requires that unsafeCoerce# has a compulsory unfolding that is always available. So we have to be careful to expose compulsory unfoldings unconditionally and consistently. We didn't get this quite right: #17871. This patch fixes it. No real surprises here. See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy - - - - - 6a65b8c2 by Alp Mestanogullari at 2020-03-13T02:29:20-04:00 hadrian: improve dependency tracking for the check-* programs The code in Rules.Register responsible for finding all the build artifacts that Cabal installs when registering a library (static/shared libs, .hi files, ...) was looking in the wrong place. This patch fixes that logic and makes sure we gather all those artifacts in a list to declare that the rule for a given `.conf` file, our proxy for "Hadrian, please install this package in the package db for this stage", also produces those artifacts under the said package database. We also were completely missing some logic to declare that the check-* programs have dependencies besides their source code, at least when testing an in-tree compiler. Finally, this patch also removes redundant packages from 'testsuitePackages', since they should already be covered by the stage<N>Packages lists from Settings.Default. With this patch, after a complete build and freezing stage 1, a change to `compiler/parser/Parser.y` results in rebuilding the ghc lib, reinstalling it, and rebuilding the few programs that depend on it, _including_ `check-ppr` and `check-api-annotations` (therefore fixing #17273). - - - - - 44fad4a9 by Sylvain Henry at 2020-03-13T02:30:22-04:00 Rename isDllName I wanted to fix the dangling comment in `isDllName` ("This is the cause of #", #8696 is already mentioned earlier). I took the opportunity to change the function name to better reflect what it does. - - - - - 2f292db8 by Paavo at 2020-03-13T02:31:03-04:00 Update documentation for closureSize - - - - - f124ff0d by Ben Gamari at 2020-03-13T02:31:40-04:00 gitlab-ci: Rework triggering of release builds Use a push option instead of tagging. - - - - - 7f25557a by Ben Gamari at 2020-03-13T10:38:09-04:00 gitlab-ci: Distinguish integer-simple test envs Previously two integer-simple jobs declared the same test environment. One (the nightly job) was built in the perf way, the other in the validate way. Consequently they had appreciably different performance characteristics, causing in the nightly job to spuriously fail with performance changes. - - - - - c12a2ec5 by Simon Peyton Jones at 2020-03-14T05:25:30-04:00 Fix Lint Ticket #17590 pointed out a bug in the way the linter dealt with type lets, exposed by the new uniqAway story. The fix is described in Note [Linting type lets]. I ended up putting the in-scope Ids in a different env field, le_ids, rather than (as before) sneaking them into the TCvSubst. Surprisingly tiresome, but done. Metric Decrease: hie002 - - - - - b989845e by Sylvain Henry at 2020-03-14T05:26:11-04:00 Hadrian: fix absolute buildroot support (#17822) Shake's "**" wildcard doesn't match absolute root. We must use "//" instead. - - - - - 4f117135 by Sylvain Henry at 2020-03-14T05:26:49-04:00 Make: refactor GMP rules Document and use simpler rules for the ghc-gmp.h header. - - - - - 7432b327 by Sylvain Henry at 2020-03-14T05:27:28-04:00 Use correct option name (-opti) (fix #17314) s/pgmo/opti - - - - - 8f7dd571 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Allow overriding LD_STAGE0 and AR_STAGE0 in the configure script. Previously it was possible to override the stage0 C compiler via `CC_STAGE0`, but you couldn't override `ld` or `ar` in stage0. This change allows overriding them by setting `LD_STAGE0` or `AR_STAGE0`, respectively. Our team uses this feature internally to take more control of our GHC build and make it run more hermetically. - - - - - 7c3e39a9 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Use AC_ARG_VAR for LD_STAGE0 and AR_STAGE0. - - - - - 20d4d676 by Ben Gamari at 2020-03-14T05:28:43-04:00 nonmoving: Don't traverse filled segment list in pause The non-moving collector would previously walk the entire filled segment list during the preparatory pause. However, this is far more work than is strictly necessary. We can rather get away with merely collecting the allocators' filled segment list heads and process the lists themselves during the concurrent phase. This can significantly reduce the maximum gen1 GC pause time in programs with high rates of long-lived allocations. - - - - - fdfa2d01 by Ben Gamari at 2020-03-14T05:29:18-04:00 nonmoving: Remove redundant bitmap clearing nonmovingSweep already clears the bitmap in the sweep loop. There is no reason to do so a second time. - - - - - 2f8c7767 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Simple refactor of cheapEqExpr No change in functionality. Just seems tidier (and signficantly more efficient) to deal with ticks directly than to call stripTicksTopE. - - - - - 88f7a762 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Improve CSE.combineAlts This patch improves the way that CSE combines identical alternatives. See #17901. I'm still not happy about the duplication between CSE.combineAlts and GHC.Core.Utils.combineIdenticalAlts; see the Notes with those functions. But this patch is a step forward. Metric Decrease: T12425 T5642 - - - - - 8b95ddd3 by Ben Gamari at 2020-03-14T05:30:31-04:00 gitlab-ci: Add integer-simple release build for Windows Closes #16144. - - - - - e3c374cc by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Wrap an implication around class-sig kind errors Ticket #17841 showed that we can get a kind error in a class signature, but lack an enclosing implication that binds its skolems. This patch * Adds the wrapping implication: the new call to checkTvConstraints in tcClassDecl1 * Simplifies the API to checkTvConstraints, which was not otherwise called at all. * Simplifies TcErrors.report_unsolved by *not* initialising the TidyEnv from the typechecker lexical envt. It's enough to do so from the free vars of the unsolved constraints; and we get silly renamings if we add variables twice: once from the lexical scope and once from the implication constraint. - - - - - 73133a3b by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Refactoring in TcSMonad This patch is just refactoring: no change in behaviour. I removed the rather complicated checkConstraintsTcS checkTvConstraintsTcS in favour of simpler functions emitImplicationTcS emitTvImplicationTcS pushLevelNoWorkList The last of these is a little strange, but overall it's much better I think. - - - - - 93c88c26 by Ben Gamari at 2020-03-14T05:31:42-04:00 base: Make `open` calls interruptible As noted in #17912, `open` system calls were `safe` rather than `interruptible`. Consequently, the program could not be interrupted with SIGINT if stuck in a slow open operation. Fix this by marking `c_safe_open` as interruptible. - - - - - bee4cdad by Vladislav Zavialov at 2020-03-14T05:32:18-04:00 Remove second tcLookupTcTyCon in tcDataDefn Before this patch, tcDataDefn used to call tcLookupTcTyCon twice in a row: 1. in bindTyClTyVars itself 2. in the continuation passed to it Now bindTyClTyVars passes the TcTyCon to the continuation, making the second lookup unnecessary. - - - - - 3f116d35 by Cale Gibbard at 2020-03-14T19:34:42-04:00 Enable stage1 build of haddock The submodule has already been bumped to contain the fix. - - - - - 49e9d739 by Ömer Sinan Ağacan at 2020-03-14T19:35:24-04:00 rts: Fix printClosure when printing fwd ptrs - - - - - 1de3ab4a by Krzysztof Gogolewski at 2020-03-14T19:36:04-04:00 Remove unused field var_inline (#17915) - - - - - d30aeb4b by Krzysztof Gogolewski at 2020-03-15T03:57:41-04:00 Document restriction on SCC pragma syntax Currently, the names of cost centres must be quoted or be lowercase identifiers. Fixes #17916. - - - - - b4774598 by Brian Foley at 2020-03-15T03:58:18-04:00 Remove some dead code >From the notes.ghc.drop list found using weeder in #17713 - - - - - dd6ffe6b by Viktor Dukhovni at 2020-03-15T03:58:55-04:00 Note platform-specific Foreign.C.Types in context Also fix the markup in the general note at the top of the module. Haddock (usability trade-off), does not support multi-line emphasised text. - - - - - 2e82465f by Sylvain Henry at 2020-03-15T10:57:10-04:00 Refactor CmmToAsm (disentangle DynFlags) This patch disentangles a bit more DynFlags from the native code generator (CmmToAsm). In more details: - add a new NCGConfig datatype in GHC.CmmToAsm.Config which contains the configuration of a native code generation session - explicitly pass NCGConfig/Platform arguments when necessary - as a consequence `sdocWithPlatform` is gone and there are only a few `sdocWithDynFlags` left - remove the use of `unsafeGlobalDynFlags` from GHC.CmmToAsm.CFG - remove `sdocDebugLevel` (now we pass the debug level via NCGConfig) There are still some places where DynFlags is used, especially because of pretty-printing (CLabel), because of Cmm helpers (such as `cmmExprType`) and because of `Outputable` instance for the instructions. These are left for future refactoring as this patch is already big. - - - - - c35c545d by Judah Jacobson at 2020-03-15T10:57:48-04:00 Add a -no-haddock flag. This flag undoes the effect of a previous "-haddock" flag. Having both flags makes it easier for build systems to enable Haddock parsing in a set of global flags, but then disable it locally for specific targets (e.g., third-party packages whose comments don't pass the validation in the latest GHC). I added the flag to expected-undocumented-flags.txt since `-haddock` was alreadyin that list. - - - - - cfcc3c9a by Ömer Sinan Ağacan at 2020-03-15T10:58:27-04:00 Fix global_link of TSOs for threads reachable via dead weaks Fixes #17785 Here's how the problem occurs: - In generation 0 we have a TSO that is finished (i.e. it has no more work to do or it is killed). - The TSO only becomes reachable after collectDeadWeakPtrs(). - After collectDeadWeakPtrs() we switch to WeakDone phase where we don't move TSOs to different lists anymore (like the next gen's thread list or the resurrected_threads list). - So the TSO will never be moved to a generation's thread list, but it will be promoted to generation 1. - Generation 1 collected via mark-compact, and because the TSO is reachable it is marked, and its `global_link` field, which is bogus at this point (because the TSO is not in a list), will be threaded. - Chaos ensues. In other words, when these conditions hold: - A TSO is reachable only after collectDeadWeakPtrs() - It's finished (what_next is ThreadComplete or ThreadKilled) - It's retained by mark-compact collector (moving collector doesn't evacuate the global_list field) We end up doing random mutations on the heap because the TSO's global_list field is not valid, but it still looks like a heap pointer so we thread it during compacting GC. The fix is simple: when we traverse old_threads lists to resurrect unreachable threads the threads that won't be resurrected currently stays on the old_threads lists. Those threads will never be visited again by MarkWeak so we now reset the global_list fields. This way compacting GC does not thread pointers to nowhere. Testing ------- The reproducer in #17785 is quite large and hard to build, because of the dependencies, so I'm not adding a regression test. In my testing the reproducer would take a less than 5 seconds to run, and once in every ~5 runs would fail with a segfault or an assertion error. In other cases it also fails with a test failure. Because the tests never fail with the bug fix, assuming the code is correct, this also means that this bug can sometimes lead to incorrect runtime results. After the fix I was able to run the reproducer repeatedly for about an hour, with no runtime crashes or test failures. To run the reproducer clone the git repo: $ git clone https://github.com/osa1/streamly --branch ghc-segfault Then clone primitive and atomic-primops from their git repos and point to the clones in cabal.project.local. The project should then be buildable using GHC HEAD. Run the executable `properties` with `+RTS -c -DZ`. In addition to the reproducer above I run the test suite using: $ make slowtest EXTRA_HC_OPTS="-debug -with-rtsopts=-DS \ -with-rtsopts=-c +RTS -c -RTS" SKIPWAY='nonmoving nonmoving_thr' This enables compacting GC always in both GHC when building the test programs and when running the test programs, and also enables sanity checking when running the test programs. These set of flags are not compatible for all tests so there are some failures, but I got the same set of failures with this patch compared to GHC HEAD. - - - - - 818b3c38 by Lysxia at 2020-03-16T23:52:42-04:00 base: add strict IO functions: readFile', getContents', hGetContents' - - - - - 18a346a4 by Sylvain Henry at 2020-03-16T23:53:24-04:00 Modules: Core (#13009) Update submodule: haddock - - - - - 92327e3a by Ömer Sinan Ağacan at 2020-03-16T23:54:04-04:00 Update sanity checking for TSOs: - Remove an invalid assumption about GC checking what_next field. The GC doesn't care about what_next at all, if a TSO is reachable then all its pointers are followed (other than global_tso, which is only followed by compacting GC). - Remove checkSTACK in checkTSO: TSO stacks will be visited in checkHeapChain, or checkLargeObjects etc. - Add an assertion in checkTSO to check that the global_link field is sane. - Did some refactor to remove forward decls in checkGlobalTSOList and added braces around single-statement if statements. - - - - - e1aa4052 by PHO at 2020-03-17T07:36:09-04:00 Don't use non-portable operator "==" in configure.ac The test operator "==" is a Bash extension and produces a wrong result if /bin/sh is not Bash. - - - - - 89f034dd by Maximilian Tagher at 2020-03-17T07:36:48-04:00 Document the units of -ddump-timings Right now, in the output of -ddump-timings to a file, you can't tell what the units are: ``` CodeGen [TemplateTestImports]: alloc=22454880 time=14.597 ``` I believe bytes/milliseconds are the correct units, but confirmation would be appreciated. I'm basing it off of this snippet from `withTiming'`: ``` when (verbosity dflags >= 2 && prtimings == PrintTimings) $ liftIO $ logInfo dflags (defaultUserStyle dflags) (text "!!!" <+> what <> colon <+> text "finished in" <+> doublePrec 2 time <+> text "milliseconds" <> comma <+> text "allocated" <+> doublePrec 3 (realToFrac alloc / 1024 / 1024) <+> text "megabytes") ``` which implies time is in milliseconds, and allocations in bytes (which divided by 1024 would be KB, and again would be MB) - - - - - beffa147 by Simon Peyton Jones at 2020-03-17T07:37:25-04:00 Implement mapTyCo like foldTyCo This patch makes mapType use the successful idiom described in TyCoRep Note [Specialising foldType] I have not yet changed any functions to use mapType, though there may be some suitable candidates. This patch should be a no-op in terms of functionality but, because it inlines the mapper itself, I'm hoping that there may be some modest perf improvements. Metric Decrease: T5631 T5642 T3064 T9020 T14683 hie002 haddock.Cabal haddock.base haddock.compiler - - - - - 5800ebfe by Ömer Sinan Ağacan at 2020-03-17T07:38:08-04:00 Don't update ModDetails with CafInfos when opts are disabled This is consistent with the interface file behavior where we omit HsNoCafRefs annotations with -fomit-interface-pragmas (implied by -O0). ModDetails and ModIface are just different representations of the same thing, so they really need to be in sync. This patch does the right thing and does not need too much explanation, but here's an example of a problem not doing this causes in !2842: -- MyInteger.hs module MyInteger ( MyInteger (MyInteger) , ToMyInteger (toMyInteger) ) where newtype MyInteger = MyInteger Integer class ToMyInteger a where toMyInteger :: a -> MyInteger instance ToMyInteger Integer where toMyInteger = MyInteger {- . succ -} -- Main.hs module Main ( main ) where import MyInteger (MyInteger (MyInteger), toMyInteger) main :: IO () main = do let (MyInteger i) = (id . toMyInteger) (41 :: Integer) print i If I build this with -O0, without this fix, we generate a ModDetails with accurate LFInfo for toMyInteger (MyInteger.$fToMyIntegerInteger) which says that it's a LFReEntrant with arity 1. This means in the use site (Main) we tag the value: R3 = MyInteger.$fToMyIntegerInteger_closure + 1; R2 = GHC.Base.id_closure; R1 = GHC.Base.._closure; Sp = Sp - 16; call stg_ap_ppp_fast(R4, R3, R2, R1) args: 24, res: 0, upd: 24; Now we change the definition by uncommenting the `succ` part and it becomes a thunk: MyInteger.$fToMyIntegerInteger [InlPrag=INLINE (sat-args=0)] :: MyInteger.ToMyInteger GHC.Integer.Type.Integer [GblId[DFunId(nt)]] = {} \u [] $ctoMyInteger_rEA; and its LFInfo is now LFThunk. This change in LFInfo makes a difference in the use site: we can no longer tag it. But becuase the interface fingerprint does not change (because ModIface does not change) we don't rebuild Main and tag the thunk. (1.2% increase in allocations when building T12545 on armv7 because we generate more code without CafInfos) Metric Increase: T12545 - - - - - 5b632dad by Paavo at 2020-03-17T07:38:48-04:00 Add example for Data.Semigroup.diff - - - - - 4d85d68b by Paavo at 2020-03-17T07:38:48-04:00 Clean up - - - - - 75168d07 by Paavo at 2020-03-17T07:38:48-04:00 Make example collapsible - - - - - 53ff2cd0 by Richard Eisenberg at 2020-03-17T13:46:57+00:00 Fix #17021 by checking more return kinds All the details are in new Note [Datatype return kinds] in TcTyClsDecls. Test case: typecheck/should_fail/T17021{,b} typecheck/should_compile/T17021a Updates haddock submodule - - - - - 528df8ec by Sylvain Henry at 2020-03-18T10:06:43-04:00 Modules: Core operations (#13009) - - - - - 4e8a71c1 by Richard Eisenberg at 2020-03-18T10:07:19-04:00 Add release note about fix to #16502. We thought we needed to update the manual, but the fix for #16502 actually brings the implementation in line with the manual. So we just alert users of how to update their code. - - - - - 5cbf9934 by Andreas Klebinger at 2020-03-19T00:39:27-04:00 Update "GHC differences to the FFI Chapter" in user guide. The old entry had a heavy focus on how things had been. Which is not what I generally look for in a user guide. I also added a small section on behaviour of nested safe ffi calls. [skip-ci] - - - - - b03fd3bc by Sebastian Graf at 2020-03-19T00:40:06-04:00 PmCheck: Use ConLikeSet to model negative info In #17911, Simon recognised many warnings stemming from over-long list unions while coverage checking Cabal's `LicenseId` module. This patch introduces a new `PmAltConSet` type which uses a `UniqDSet` instead of an association list for `ConLike`s. For `PmLit`s, it will still use an assocation list, though, because a similar map data structure would entail a lot of busy work. Fixes #17911. - - - - - 64f20756 by Sylvain Henry at 2020-03-19T12:16:49-04:00 Refactoring: use Platform instead of DynFlags when possible Metric Decrease: ManyConstructors T12707 T13035 T1969 - - - - - cb1785d9 by Ömer Sinan Ağacan at 2020-03-19T12:16:54-04:00 FastString: fix eager reading of string ptr in hashStr This read causes NULL dereferencing when len is 0. Fixes #17909 In the reproducer in #17909 this bug is triggered as follows: - SimplOpt.dealWithStringLiteral is called with a single-char string ("=" in #17909) - tailFS gets called on the FastString of the single-char string. - tailFS checks the length of the string, which is 1, and calls mkFastStringByteString on the tail of the ByteString, which is an empty ByteString as the original ByteString has only one char. - ByteString's unsafeUseAsCStringLen returns (NULL, 0) for the empty ByteString, which is passed to mkFastStringWith. - mkFastStringWith gets hash of the NULL pointer via hashStr, which fails on empty strings because of this bug. - - - - - 73a7383e by Richard Eisenberg at 2020-03-20T20:42:56-04:00 Simplify treatment of heterogeneous equality Previously, if we had a [W] (a :: k1) ~ (rhs :: k2), we would spit out a [D] k1 ~ k2 and part the W as irreducible, hoping for a unification. But we needn't do this. Instead, we now spit out a [W] co :: k2 ~ k1 and then use co to cast the rhs of the original Wanted. This means that we retain the connection between the spat-out constraint and the original. The problem with this new approach is that we cannot use the casted equality for substitution; it's too like wanteds-rewriting- wanteds. So, we forbid CTyEqCans that mention coercion holes. All the details are in Note [Equalities with incompatible kinds] in TcCanonical. There are a few knock-on effects, documented where they occur. While debugging an error in this patch, Simon and I ran into infelicities in how patterns and matches are printed; we made small improvements. This patch includes mitigations for #17828, which causes spurious pattern-match warnings. When #17828 is fixed, these lines should be removed. - - - - - faa36e5b by Sylvain Henry at 2020-03-20T20:43:41-04:00 Hadrian: ignore in-tree GMP objects with ``--lint`` - - - - - 9a96ff6b by Richard Eisenberg at 2020-03-20T20:44:17-04:00 Update core spec to reflect changes to Core. Key changes: * Adds a new rule for forall-coercions over coercion variables, which was implemented but conspicuously missing from the spec. * Adds treatment for FunCo. * Adds treatment for ForAllTy over coercion variables. * Improves commentary (including restoring a Note lost in 03d4852658e1b7407abb4da84b1b03bfa6f6db3b) in the source. No changes to running code. - - - - - 7e0451c6 by Sergej Jaskiewicz at 2020-03-20T20:44:55-04:00 Fix event message in withTiming' This typo caused generating 'end' events without the corresponding 'begin' events. - - - - - 1542a626 by Ben Gamari at 2020-03-22T22:37:47-04:00 fs.h: Add missing declarations on Windows - - - - - 3bcf2ccd by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump process submodule Avoids redundant case alternative warning. - - - - - 3b363ef9 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Normalize slashes in ghc-api annotations output Enable `normalise_slashes` on `annotations`, `listcomps`, and `parseTree` to fix Windows failures. - - - - - 25fc9429 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - 7f58ec6d by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Fix TOP of T17786 - - - - - aadcd909 by GHC GitLab CI at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - dc1eb10d by GHC GitLab CI at 2020-03-22T22:37:47-04:00 hadrian: Fix executable extension passed to testsuite driver - - - - - 58f62e2c by GHC GitLab CI at 2020-03-22T22:37:47-04:00 gitlab-ci: Require that Windows-hadrian job passes - - - - - 8dd2415d by Ben Gamari at 2020-03-22T22:37:47-04:00 hadrian: Eliminate redundant .exe from GHC path Previously we were invoking: bash -c "c:/GitLabRunner/builds/eEQrxK4p/0/ghc/ghc/toolchain/bin/ghc.exe.exe testsuite/mk/ghc-config.hs -o _build/test/bin/ghc-config.exe" - - - - - 373621f6 by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump hsc2hs submodule - - - - - abc02b40 by Hécate at 2020-03-22T22:38:33-04:00 Annotate the non-total function in Data.Foldable as such - - - - - 19f12557 by Josef Svenningsson at 2020-03-23T14:05:33-04:00 Fix ApplicativeDo regression #17835 A previous fix for #15344 made sure that monadic 'fail' is used properly when translating ApplicativeDo. However, it didn't properly account for when a 'fail' will be inserted which resulted in some programs failing with a type error. - - - - - 2643ba46 by Paavo at 2020-03-24T08:31:32-04:00 Add example and doc for Arg (Fixes #17153) - - - - - 703221f4 by Roland Senn at 2020-03-25T14:45:04-04:00 Use export list of Main module in function TcRnDriver.hs:check_main (Fix #16453) - Provide the export list of the `Main` module as parameter to the `compiler/typecheck/TcRnDriver.hs:check_main` function. - Instead of `lookupOccRn_maybe` call the function `lookupInfoOccRn`. It returns the list `mains_all` of all the main functions in scope. - Select from this list `mains_all` all `main` functions that are in the export list of the `Main` module. - If this new list contains exactly one single `main` function, then typechecking continues. - Otherwise issue an appropriate error message. - - - - - 3e27205a by Sebastian Graf at 2020-03-25T14:45:40-04:00 Remove -fkill-absence and -fkill-one-shot flags They seem to be a benchmarking vestige of the Cardinality paper and probably shouldn't have been merged to HEAD in the first place. - - - - - 262e42aa by Peter Trommler at 2020-03-25T22:41:39-04:00 Do not panic on linker errors - - - - - 0de03cd7 by Sylvain Henry at 2020-03-25T22:42:02-04:00 DynFlags refactoring III Use Platform instead of DynFlags when possible: * `tARGET_MIN_INT` et al. replaced with `platformMinInt` et al. * no more DynFlags in PreRules: added a new `RuleOpts` datatype * don't use `wORD_SIZE` in the compiler * make `wordAlignment` use `Platform` * make `dOUBLE_SIZE` a constant Metric Decrease: T13035 T1969 - - - - - 7a04920b by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: fix a typo in liftA doc This change removes an extra '|' that should not be rendered in the liftA documentation. Tracking: #17929 - - - - - 1c5a15f7 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add Control.Applicative optional example This change adds an optional example. Tracking: #17929 - - - - - 6d172e63 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add markup around Except - - - - - eb2162c8 by John Ericson at 2020-03-26T12:37:08-04:00 Remove unused `ghciTablesNextToCode` from compiler proper - - - - - f51efc4b by Joachim Breitner at 2020-03-26T12:37:09-04:00 Prepare to use run-time tablesNextToCode in compiler exclusively Factor out CPP as much as possible to prepare for runtime determinattion. Progress towards #15548 - - - - - 1c446220 by Joachim Breitner at 2020-03-26T12:37:09-04:00 Use run-time tablesNextToCode in compiler exclusively (#15548) Summary: - There is no more use of the TABLES_NEXT_TO_CODE CPP macro in `compiler/`. GHCI_TABLES_NEXT_TO_CODE is also removed entirely. The field within `PlatformMisc` within `DynFlags` is used instead. - The field is still not exposed as a CLI flag. We might consider some way to ensure the right RTS / libraries are used before doing that. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082 - - - - - 1941ef4f by Sylvain Henry at 2020-03-29T17:28:51-04:00 Modules: Types (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - 1c7c6f1a by Sylvain Henry at 2020-03-29T17:28:51-04:00 Remove GHC.Types.Unique.Map module This module isn't used anywhere in GHC. - - - - - f1a6c73d by Sylvain Henry at 2020-03-29T17:28:51-04:00 Merge GHC.Types.CostCentre.Init into GHC.Driver.CodeOutput - - - - - 54250f2d by Simon Peyton Jones at 2020-03-29T17:29:30-04:00 Demand analysis: simplify the demand for a RHS Ticket #17932 showed that we were using a stupid demand for the RHS of a let-binding, when the result is a product. This was the result of a "fix" in 2013, which (happily) turns out to no longer be necessary. So I just deleted the code, which simplifies the demand analyser, and fixes #17932. That in turn uncovered that the anticipation of worker/wrapper in CPR analysis was inaccurate, hence the logic that decides whether to unbox an argument in WW was extracted into a function `wantToUnbox`, now consulted by CPR analysis. I tried nofib, and got 0.0% perf changes. All this came up when messing about with !2873 (ticket #17917), but is idependent of it. Unfortunately, this patch regresses #4267 and realised that it is now blocked on #16335. - - - - - 03060b2f by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 on Windows Fixes line ending normalization issue. - - - - - 1f7995ba by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 Fix missing quoting and expected exit code. - - - - - ef9c608e by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - e54500c1 by Sylvain Henry at 2020-03-29T17:30:47-04:00 Store ComponentId details As far as GHC is concerned, installed package components ("units") are identified by an opaque ComponentId string provided by Cabal. But we don't want to display it to users (as it contains a hash) so GHC queries the database to retrieve some infos about the original source package (name, version, component name). This patch caches these infos in the ComponentId itself so that we don't need to provide DynFlags (which contains installed package informations) to print a ComponentId. In the future we want GHC to support several independent package states (e.g. for plugins and for target code), hence we need to avoid implicitly querying a single global package state. - - - - - 7e7cb714 by Marius Bakke at 2020-03-29T17:31:27-04:00 testsuite: Remove test that dlopens a PIE object. glibc 2.30 disallowed dlopening PIE objects, so just remove the test. Fixes #17952. - - - - - 6c8f80d8 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Correct haddocks for testBit in Data.Bits It conflated the nth bit with the bit at offset n. Now we instead give the definition in terms of `bit and `.&.` on top of clearer phrasing. - - - - - c916f190 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Apply suggestion to libraries/base/Data/Bits.hs - - - - - 64bf7f51 by Ben Gamari at 2020-03-29T17:32:41-04:00 gitlab-ci: Add FreeBSD release job - - - - - a0d8e92e by Ryan Scott at 2020-03-29T17:33:20-04:00 Run checkNewDataCon before constraint-solving newtype constructors Within `checkValidDataCon`, we used to run `checkValidType` on the argument types of a newtype constructor before running `checkNewDataCon`, which ensures that the user does not attempt non-sensical things such as newtypes with multiple arguments or constraints. This works out in most situations, but this falls over on a corner case revealed in #17955: ```hs newtype T = Coercible () T => T () ``` `checkValidType`, among other things, peforms an ambiguity check on the context of a data constructor, and that it turn invokes the constraint solver. It turns out that there is a special case in the constraint solver for representational equalities (read: `Coercible` constraints) that causes newtypes to be unwrapped (see `Note [Unwrap newtypes first]` in `TcCanonical`). This special case does not know how to cope with an ill formed newtype like `T`, so it ends up panicking. The solution is surprisingly simple: just invoke `checkNewDataCon` before `checkValidType` to ensure that the illicit newtype constructor context is detected before the constraint solver can run amok with it. Fixes #17955. - - - - - 45eb9d8c by Krzysztof Gogolewski at 2020-03-29T17:33:59-04:00 Minor cleanup - Simplify mkBuildExpr, the function newTyVars was called only on a one-element list. - TTG: use noExtCon in more places. This is more future-proof. - In zonkExpr, panic instead of printing a warning. - - - - - f024b6e3 by Sylvain Henry at 2020-03-30T12:48:39+02:00 Expect T4267 to pass Since 54250f2d8de910b094070c1b48f086030df634b1 we expected T4267 to fail, but it passes on CI. - - - - - 57b888c0 by Ryan Scott at 2020-03-31T10:54:20-04:00 Require GHC 8.8 as the minimum compiler for bootstrapping This allows us to remove several bits of CPP that are either always true or no longer reachable. As an added bonus, we no longer need to worry about importing `Control.Monad.Fail.fail` qualified to avoid clashing with `Control.Monad.fail`, since the latter is now the same as the former. - - - - - 33f09551 by Ryan Scott at 2020-03-31T10:54:57-04:00 Add regression test for #17963 The panic in #17963 happened to be fixed by commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70. This patch adds a regression test to ensure that it remains fixed. Fixes #17963. - - - - - 09a36e80 by Ömer Sinan Ağacan at 2020-03-31T10:55:37-04:00 Simplify stderrSupportsAnsiColors The combinator andM is used only once, and the code is shorter and simpler if you inline it. - - - - - 95bccdd0 by Ben Gamari at 2020-03-31T10:56:19-04:00 base: Ensure that encoding global variables aren't inlined As noted in #17970, these (e.g. `getFileSystemEncoding` and `setFileSystemEncoding`) previously had unfoldings, which would break their global-ness. While not strictly necessary, I also add a NOINLINE on `initLocaleEncoding` since it is used in `System.IO`, ensuring that we only system's query the locale encoding once. Fixes #17970. - - - - - 982aaa83 by Andreas Klebinger at 2020-03-31T10:56:55-04:00 Update hadrian index revision. Required in order to build hadrian using ghc-8.10 - - - - - 4b9c5864 by Ben Gamari at 2020-03-31T10:57:32-04:00 integer-gmp: Bump version and add changelog entry - - - - - 9b39f2e6 by Ryan Scott at 2020-04-01T01:20:00-04:00 Clean up "Eta reduction for data families" Notes Before, there were two distinct Notes named "Eta reduction for data families". This renames one of them to "Implementing eta reduction for data families" to disambiguate the two and fixes references in other parts of the codebase to ensure that they are pointing to the right place. Fixes #17313. [ci skip] - - - - - 7627eab5 by Ryan Scott at 2020-04-01T01:20:38-04:00 Fix the changelog/@since information for hGetContents'/getContents'/readFile' Fixes #17979. [ci skip] - - - - - 0002db1b by Sylvain Henry at 2020-04-01T01:21:27-04:00 Kill wORDS_BIGENDIAN and replace it with platformByteOrder (#17957) Metric Decrease: T13035 T1969 - - - - - 7b217179 by Sebastian Graf at 2020-04-01T15:03:24-04:00 PmCheck: Adjust recursion depth for inhabitation test In #17977, we ran into the reduction depth limit of the typechecker. That was only a symptom of a much broader issue: The recursion depth of the coverage checker for trying to instantiate strict fields in the `nonVoid` test was far too high (100, the `defaultMaxTcBound`). As a result, we were performing quite poorly on `T17977`. Short of a proper termination analysis to prove emptyness of a type, we just arbitrarily default to a much lower recursion limit of 3. Fixes #17977. - - - - - 3c09f636 by Andreas Klebinger at 2020-04-01T15:03:59-04:00 Make hadrian pass on the no-colour setting to GHC. Fixes #17983. - - - - - b943b25d by Simon Peyton Jones at 2020-04-02T01:45:58-04:00 Re-engineer the binder-swap transformation The binder-swap transformation is implemented by the occurrence analyser -- see Note [Binder swap] in OccurAnal. However it had a very nasty corner in it, for the case where the case scrutinee was a GlobalId. This led to trouble and hacks, and ultimately to #16296. This patch re-engineers how the occurrence analyser implements the binder-swap, by actually carrying out a substitution rather than by adding a let-binding. It's all described in Note [The binder-swap substitution]. I did a few other things along the way * Fix a bug in StgCse, which could allow a loop breaker to be CSE'd away. See Note [Care with loop breakers] in StgCse. I think it can only show up if occurrence analyser sets up bad loop breakers, but still. * Better commenting in SimplUtils.prepareAlts * A little refactoring in CoreUnfold; nothing significant e.g. rename CoreUnfold.mkTopUnfolding to mkFinalUnfolding * Renamed CoreSyn.isFragileUnfolding to hasCoreUnfolding * Move mkRuleInfo to CoreFVs We observed respectively 4.6% and 5.9% allocation decreases for the following tests: Metric Decrease: T9961 haddock.base - - - - - 42d68364 by Sebastian Graf at 2020-04-02T01:46:34-04:00 Preserve precise exceptions in strictness analysis Fix #13380 and #17676 by 1. Changing `raiseIO#` to have `topDiv` instead of `botDiv` 2. Give it special treatment in `Simplifier.Util.mkArgInfo`, treating it as if it still had `botDiv`, to recover dead code elimination. This is the first commit of the plan outlined in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2525#note_260886. - - - - - 0a88dd11 by Ömer Sinan Ağacan at 2020-04-02T01:47:25-04:00 Fix a pointer format string in RTS - - - - - 5beac042 by Ömer Sinan Ağacan at 2020-04-02T01:48:05-04:00 Remove unused closure stg_IND_direct - - - - - 88f38b03 by Ben Gamari at 2020-04-02T01:48:42-04:00 Session: Memoize stderrSupportsAnsiColors Not only is this a reasonable efficiency measure but it avoids making reentrant calls into ncurses, which is not thread-safe. See #17922. - - - - - 27740f24 by Ryan Scott at 2020-04-02T01:49:21-04:00 Make Hadrian build with Cabal-3.2 GHC 8.10 ships with `Cabal-3.2.0.0`, so it would be convenient to make Hadrian supporting building against 3.2.* instead of having to rebuild the entirety of `Cabal-3.0.0.0`. There is one API change in `Cabal-3.2.*` that affects Hadrian: the `synopsis` and `description` functions now return `ShortText` instead of `String`. Since Hadrian manipulates these `String`s in various places, I found that the simplest fix was to use CPP to convert `ShortText` to `String`s where appropriate. - - - - - 49802002 by Sylvain Henry at 2020-04-02T01:50:00-04:00 Update Stack resolver for hadrian/build-stack Broken by 57b888c0e90be7189285a6b078c30b26d0923809 - - - - - 30a63e79 by Ryan Scott at 2020-04-02T01:50:36-04:00 Fix two ASSERT buglets in reifyDataCon Two `ASSERT`s in `reifyDataCon` were always using `arg_tys`, but `arg_tys` is not meaningful for GADT constructors. In fact, it's worse than non-meaningful, since using `arg_tys` when reifying a GADT constructor can lead to failed `ASSERT`ions, as #17305 demonstrates. This patch applies the simplest possible fix to the immediate problem. The `ASSERT`s now use `r_arg_tys` instead of `arg_tys`, as the former makes sure to give something meaningful for GADT constructors. This makes the panic go away at the very least. There is still an underlying issue with the way the internals of `reifyDataCon` work, as described in https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227023, but we leave that as future work, since fixing the underlying issue is much trickier (see https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227087). - - - - - ef7576c4 by Zubin Duggal at 2020-04-03T06:24:56-04:00 Add outputable instances for the types in GHC.Iface.Ext.Types, add -ddump-hie flag to dump pretty printed contents of the .hie file Metric Increase: hie002 Because of the regression on i386: compile_time/bytes allocated increased from i386-linux-deb9 baseline @ HEAD~10: Expected hie002 (normal) compile_time/bytes allocated: 583014888.0 +/-10% Lower bound hie002 (normal) compile_time/bytes allocated: 524713399 Upper bound hie002 (normal) compile_time/bytes allocated: 641316377 Actual hie002 (normal) compile_time/bytes allocated: 877986292 Deviation hie002 (normal) compile_time/bytes allocated: 50.6 % *** unexpected stat test failure for hie002(normal) - - - - - 9462452a by Andreas Klebinger at 2020-04-03T06:25:33-04:00 Improve and refactor StgToCmm codegen for DataCons. We now differentiate three cases of constructor bindings: 1)Bindings which we can "replace" with a reference to an existing closure. Reference the replacement closure when accessing the binding. 2)Bindings which we can "replace" as above. But we still generate a closure which will be referenced by modules importing this binding. 3)For any other binding generate a closure. Then reference it. Before this patch 1) did only apply to local bindings and we didn't do 2) at all. - - - - - a214d214 by Moritz Bruder at 2020-04-03T06:26:11-04:00 Add singleton to NonEmpty in libraries/base This adds a definition to construct a singleton non-empty list (Data.List.NonEmpty) according to issue #17851. - - - - - f7597aa0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Testsuite: measure compiler stats for T16190 We were mistakenly measuring program stats - - - - - a485c3c4 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Move blob handling into StgToCmm Move handling of big literal strings from CmmToAsm to StgToCmm. It avoids the use of `sdocWithDynFlags` (cf #10143). We might need to move this handling even higher in the pipeline in the future (cf #17960): this patch will make it easier. - - - - - cc2918a0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Refactor CmmStatics In !2959 we noticed that there was some redundant code (in GHC.Cmm.Utils and GHC.Cmm.StgToCmm.Utils) used to deal with `CmmStatics` datatype (before SRT generation) and `RawCmmStatics` datatype (after SRT generation). This patch removes this redundant code by using a single GADT for (Raw)CmmStatics. - - - - - 9e60273d by Maxim Koltsov at 2020-04-03T06:27:32-04:00 Fix haddock formatting in Control.Monad.ST.Lazy.Imp.hs - - - - - 1b7e8a94 by Andreas Klebinger at 2020-04-03T06:28:08-04:00 Turn newlines into spaces for hadrian/ghci. The newlines break the command on windows. - - - - - 4291bdda by Simon Peyton Jones at 2020-04-03T06:28:44-04:00 Major improvements to the specialiser This patch is joint work of Alexis King and Simon PJ. It does some significant refactoring of the type-class specialiser. Main highlights: * We can specialise functions with types like f :: Eq a => a -> Ord b => b => blah where the classes aren't all at the front (#16473). Here we can correctly specialise 'f' based on a call like f @Int @Bool dEqInt x dOrdBool This change really happened in an earlier patch commit 2d0cf6252957b8980d89481ecd0b79891da4b14b Author: Sandy Maguire <sandy at sandymaguire.me> Date: Thu May 16 12:12:10 2019 -0400 work that this new patch builds directly on that work, and refactors it a bit. * We can specialise functions with implicit parameters (#17930) g :: (?foo :: Bool, Show a) => a -> String Previously we could not, but now they behave just like a non-class argument as in 'f' above. * We can specialise under-saturated calls, where some (but not all of the dictionary arguments are provided (#17966). For example, we can specialise the above 'f' based on a call map (f @Int dEqInt) xs even though we don't (and can't) give Ord dictionary. This may sound exotic, but #17966 is a program from the wild, and showed significant perf loss for functions like f, if you need saturation of all dictionaries. * We fix a buglet in which a floated dictionary had a bogus demand (#17810), by using zapIdDemandInfo in the NonRec case of specBind. * A tiny side benefit: we can drop dead arguments to specialised functions; see Note [Drop dead args from specialisations] * Fixed a bug in deciding what dictionaries are "interesting"; see Note [Keep the old dictionaries interesting] This is all achieved by by building on Sandy Macguire's work in defining SpecArg, which mkCallUDs uses to describe the arguments of the call. Main changes: * Main work is in specHeader, which marched down the [InBndr] from the function definition and the [SpecArg] from the call site, together. * specCalls no longer has an arity check; the entire mechanism now handles unders-saturated calls fine. * mkCallUDs decides on an argument-by-argument basis whether to specialise a particular dictionary argument; this is new. See mk_spec_arg in mkCallUDs. It looks as if there are many more lines of code, but I think that all the extra lines are comments! - - - - - 40a85563 by Ömer Sinan Ağacan at 2020-04-03T18:26:19+03:00 Revert accidental change in 9462452 [ci skip] - - - - - bd75e5da by Ryan Scott at 2020-04-04T07:07:58-04:00 Enable ImpredicativeTypes internally when typechecking selector bindings This is necessary for certain record selectors with higher-rank types, such as the examples in #18005. See `Note [Impredicative record selectors]` in `TcTyDecls`. Fixes #18005. - - - - - dcfe29c8 by Ömer Sinan Ağacan at 2020-04-06T13:16:08-04:00 Don't override proc CafInfos in ticky builds Fixes #17947 When we have a ticky label for a proc, IdLabels for the ticky counter and proc entry share the same Name. This caused overriding proc CafInfos with the ticky CafInfos (i.e. NoCafRefs) during SRT analysis. We now ignore the ticky labels when building SRTMaps. This makes sense because: - When building the current module they don't need to be in SRTMaps as they're initialized as non-CAFFY (see mkRednCountsLabel), so they don't take part in the dependency analysis and they're never added to SRTs. (Reminder: a "dependency" in the SRT analysis is a CAFFY dependency, non-CAFFY uses are not considered as dependencies for the algorithm) - They don't appear in the interfaces as they're not exported, so it doesn't matter for cross-module concerns whether they're in the SRTMap or not. See also the new Note [Ticky labels in SRT analysis]. - - - - - cec2c71f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Fix an tricky specialiser loop Issue #17151 was a very tricky example of a bug in which the specialiser accidentally constructs a recurive dictionary, so that everything turns into bottom. I have fixed variants of this bug at least twice before: see Note [Avoiding loops]. It was a bit of a struggle to isolate the problem, greatly aided by the work that Alexey Kuleshevich did in distilling a test case. Once I'd understood the problem, it was not difficult to fix, though it did lead me a bit of refactoring in specImports. - - - - - e850d14f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Refactoring only This refactors DictBinds into a data type rather than a pair. No change in behaviour, just better code - - - - - f38e8d61 by Daniel Gröber at 2020-04-07T02:00:05-04:00 rts: ProfHeap: Fix memory leak when not compiled with profiling If we're doing heap profiling on an unprofiled executable we keep allocating new space in initEra via nextEra on each profiler run but we don't have a corresponding freeEra call. We do free the last era in endHeapProfiling but previous eras will have been overwritten by initEra and will never get free()ed. Metric Decrease: space_leak_001 - - - - - bcd66859 by Sebastian Graf at 2020-04-07T02:00:41-04:00 Re-export GHC.Magic.noinline from base - - - - - 3d2991f8 by Ben Gamari at 2020-04-07T18:36:09-04:00 simplifier: Kill off ufKeenessFactor We used to have another factor, ufKeenessFactor, which would scale the discounts before they were subtracted from the size. This was justified with the following comment: -- We multiple the raw discounts (args_discount and result_discount) -- ty opt_UnfoldingKeenessFactor because the former have to do with -- *size* whereas the discounts imply that there's some extra -- *efficiency* to be gained (e.g. beta reductions, case reductions) -- by inlining. However, this is highly suspect since it means that we subtract a *scaled* size from an absolute size, resulting in crazy (e.g. negative) scores in some cases (#15304). We consequently killed off ufKeenessFactor and bumped up the ufUseThreshold to compensate. Adjustment of unfolding use threshold ===================================== Since this removes a discount from our inlining heuristic, I revisited our default choice of -funfolding-use-threshold to minimize the change in overall inlining behavior. Specifically, I measured runtime allocations and executable size of nofib and the testsuite performance tests built using compilers (and core libraries) built with several values of -funfolding-use-threshold. This comes as a result of a quantitative comparison of testsuite performance and code size as a function of ufUseThreshold, comparing GHC trees using values of 50, 60, 70, 80, 90, and 100. The test set consisted of nofib and the testsuite performance tests. A full summary of these measurements are found in the description of !2608 Comparing executable sizes (relative to the base commit) across all nofib tests, we see that sizes are similar to the baseline: gmean min max median thresh 50 -6.36% -7.04% -4.82% -6.46% 60 -5.04% -5.97% -3.83% -5.11% 70 -2.90% -3.84% -2.31% -2.92% 80 -0.75% -2.16% -0.42% -0.73% 90 +0.24% -0.41% +0.55% +0.26% 100 +1.36% +0.80% +1.64% +1.37% baseline +0.00% +0.00% +0.00% +0.00% Likewise, looking at runtime allocations we see that 80 gives slightly better optimisation than the baseline: gmean min max median thresh 50 +0.16% -0.16% +4.43% +0.00% 60 +0.09% -0.00% +3.10% +0.00% 70 +0.04% -0.09% +2.29% +0.00% 80 +0.02% -1.17% +2.29% +0.00% 90 -0.02% -2.59% +1.86% +0.00% 100 +0.00% -2.59% +7.51% -0.00% baseline +0.00% +0.00% +0.00% +0.00% Finally, I had to add a NOINLINE in T4306 to ensure that `upd` is worker-wrappered as the test expects. This makes me wonder whether the inlining heuristic is now too liberal as `upd` is quite a large function. The same measure was taken in T12600. Wall clock time compiling Cabal with -O0 thresh 50 60 70 80 90 100 baseline build-Cabal 93.88 89.58 92.59 90.09 100.26 94.81 89.13 Also, this change happens to avoid the spurious test output in `plugin-recomp-change` and `plugin-recomp-change-prof` (see #17308). Metric Decrease: hie002 T12234 T13035 T13719 T14683 T4801 T5631 T5642 T9020 T9872d T9961 Metric Increase: T12150 T12425 T13701 T14697 T15426 T1969 T3064 T5837 T6048 T9203 T9872a T9872b T9872c T9872d haddock.Cabal haddock.base haddock.compiler - - - - - 255418da by Sylvain Henry at 2020-04-07T18:36:49-04:00 Modules: type-checker (#13009) Update Haddock submodule - - - - - 04b6cf94 by Ryan Scott at 2020-04-07T19:43:20-04:00 Make NoExtCon fields strict This changes every unused TTG extension constructor to be strict in its field so that the pattern-match coverage checker is smart enough any such constructors are unreachable in pattern matches. This lets us remove nearly every use of `noExtCon` in the GHC API. The only ones we cannot remove are ones underneath uses of `ghcPass`, but that is only because GHC 8.8's and 8.10's coverage checkers weren't smart enough to perform this kind of reasoning. GHC HEAD's coverage checker, on the other hand, _is_ smart enough, so we guard these uses of `noExtCon` with CPP for now. Bumps the `haddock` submodule. Fixes #17992. - - - - - 7802fa17 by Ryan Scott at 2020-04-08T16:43:44-04:00 Handle promoted data constructors in typeToLHsType correctly Instead of using `nlHsTyVar`, which hardcodes `NotPromoted`, have `typeToLHsType` pick between `Promoted` and `NotPromoted` by checking if a type constructor is promoted using `isPromotedDataCon`. Fixes #18020. - - - - - ce481361 by Ben Gamari at 2020-04-09T16:17:21-04:00 hadrian: Use --export-dynamic when linking iserv As noticed in #17962, the make build system currently does this (see 3ce0e0ba) but the change was never ported to Hadrian. - - - - - fa66f143 by Ben Gamari at 2020-04-09T16:17:21-04:00 iserv: Don't pass --export-dynamic on FreeBSD This is definitely a hack but it's probably the best we can do for now. Hadrian does the right thing here by passing --export-dynamic only to the linker. - - - - - 39075176 by Ömer Sinan Ağacan at 2020-04-09T16:18:00-04:00 Fix CNF handling in compacting GC Fixes #17937 Previously compacting GC simply ignored CNFs. This is mostly fine as most (see "What about small compacts?" below) CNF objects don't have outgoing pointers, and are "large" (allocated in large blocks) and large objects are not moved or compacted. However if we do GC *during* sharing-preserving compaction then the CNF will have a hash table mapping objects that have been moved to the CNF to their location in the CNF, to be able to preserve sharing. This case is handled in the copying collector, in `scavenge_compact`, where we evacuate hash table entries and then rehash the table. Compacting GC ignored this case. We now visit CNFs in all generations when threading pointers to the compacted heap and thread hash table keys. A visited CNF is added to the list `nfdata_chain`. After compaction is done, we re-visit the CNFs in that list and rehash the tables. The overhead is minimal: the list is static in `Compact.c`, and link field is added to `StgCompactNFData` closure. Programs that don't use CNFs should not be affected. To test this CNF tests are now also run in a new way 'compacting_gc', which just passes `-c` to the RTS, enabling compacting GC for the oldest generation. Before this patch the result would be: Unexpected failures: compact_gc.run compact_gc [bad exit code (139)] (compacting_gc) compact_huge_array.run compact_huge_array [bad exit code (1)] (compacting_gc) With this patch all tests pass. I can also pass `-c -DS` without any failures. What about small compacts? Small CNFs are still not handled by the compacting GC. However so far I'm unable to write a test that triggers a runtime panic ("update_fwd: unknown/strange object") by allocating a small CNF in a compated heap. It's possible that I'm missing something and it's not possible to have a small CNF. NoFib Results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS +0.1% 0.0% 0.0% +0.0% +0.0% CSD +0.1% 0.0% 0.0% 0.0% 0.0% FS +0.1% 0.0% 0.0% 0.0% 0.0% S +0.1% 0.0% 0.0% 0.0% 0.0% VS +0.1% 0.0% 0.0% 0.0% 0.0% VSD +0.1% 0.0% +0.0% +0.0% -0.0% VSM +0.1% 0.0% +0.0% -0.0% 0.0% anna +0.0% 0.0% -0.0% -0.0% -0.0% ansi +0.1% 0.0% +0.0% +0.0% +0.0% atom +0.1% 0.0% +0.0% +0.0% +0.0% awards +0.1% 0.0% +0.0% +0.0% +0.0% banner +0.1% 0.0% +0.0% +0.0% +0.0% bernouilli +0.1% 0.0% 0.0% -0.0% +0.0% binary-trees +0.1% 0.0% -0.0% -0.0% 0.0% boyer +0.1% 0.0% +0.0% +0.0% +0.0% boyer2 +0.1% 0.0% +0.0% +0.0% +0.0% bspt +0.1% 0.0% -0.0% -0.0% -0.0% cacheprof +0.1% 0.0% -0.0% -0.0% -0.0% calendar +0.1% 0.0% +0.0% +0.0% +0.0% cichelli +0.1% 0.0% +0.0% +0.0% +0.0% circsim +0.1% 0.0% +0.0% +0.0% +0.0% clausify +0.1% 0.0% -0.0% +0.0% +0.0% comp_lab_zift +0.1% 0.0% +0.0% +0.0% +0.0% compress +0.1% 0.0% +0.0% +0.0% 0.0% compress2 +0.1% 0.0% -0.0% 0.0% 0.0% constraints +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm1 +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm2 +0.1% 0.0% +0.0% +0.0% +0.0% cse +0.1% 0.0% +0.0% +0.0% +0.0% digits-of-e1 +0.1% 0.0% +0.0% -0.0% -0.0% digits-of-e2 +0.1% 0.0% -0.0% -0.0% -0.0% dom-lt +0.1% 0.0% +0.0% +0.0% +0.0% eliza +0.1% 0.0% +0.0% +0.0% +0.0% event +0.1% 0.0% +0.0% +0.0% +0.0% exact-reals +0.1% 0.0% +0.0% +0.0% +0.0% exp3_8 +0.1% 0.0% +0.0% -0.0% 0.0% expert +0.1% 0.0% +0.0% +0.0% +0.0% fannkuch-redux +0.1% 0.0% -0.0% 0.0% 0.0% fasta +0.1% 0.0% -0.0% +0.0% +0.0% fem +0.1% 0.0% -0.0% +0.0% 0.0% fft +0.1% 0.0% -0.0% +0.0% +0.0% fft2 +0.1% 0.0% +0.0% +0.0% +0.0% fibheaps +0.1% 0.0% +0.0% +0.0% +0.0% fish +0.1% 0.0% +0.0% +0.0% +0.0% fluid +0.0% 0.0% +0.0% +0.0% +0.0% fulsom +0.1% 0.0% -0.0% +0.0% 0.0% gamteb +0.1% 0.0% +0.0% +0.0% 0.0% gcd +0.1% 0.0% +0.0% +0.0% +0.0% gen_regexps +0.1% 0.0% -0.0% +0.0% 0.0% genfft +0.1% 0.0% +0.0% +0.0% +0.0% gg +0.1% 0.0% 0.0% +0.0% +0.0% grep +0.1% 0.0% -0.0% +0.0% +0.0% hidden +0.1% 0.0% +0.0% -0.0% 0.0% hpg +0.1% 0.0% -0.0% -0.0% -0.0% ida +0.1% 0.0% +0.0% +0.0% +0.0% infer +0.1% 0.0% +0.0% 0.0% -0.0% integer +0.1% 0.0% +0.0% +0.0% +0.0% integrate +0.1% 0.0% -0.0% -0.0% -0.0% k-nucleotide +0.1% 0.0% +0.0% +0.0% 0.0% kahan +0.1% 0.0% +0.0% +0.0% +0.0% knights +0.1% 0.0% -0.0% -0.0% -0.0% lambda +0.1% 0.0% +0.0% +0.0% -0.0% last-piece +0.1% 0.0% +0.0% 0.0% 0.0% lcss +0.1% 0.0% +0.0% +0.0% 0.0% life +0.1% 0.0% -0.0% +0.0% +0.0% lift +0.1% 0.0% +0.0% +0.0% +0.0% linear +0.1% 0.0% -0.0% +0.0% 0.0% listcompr +0.1% 0.0% +0.0% +0.0% +0.0% listcopy +0.1% 0.0% +0.0% +0.0% +0.0% maillist +0.1% 0.0% +0.0% -0.0% -0.0% mandel +0.1% 0.0% +0.0% +0.0% 0.0% mandel2 +0.1% 0.0% +0.0% +0.0% +0.0% mate +0.1% 0.0% +0.0% 0.0% +0.0% minimax +0.1% 0.0% -0.0% 0.0% -0.0% mkhprog +0.1% 0.0% +0.0% +0.0% +0.0% multiplier +0.1% 0.0% +0.0% 0.0% 0.0% n-body +0.1% 0.0% +0.0% +0.0% +0.0% nucleic2 +0.1% 0.0% +0.0% +0.0% +0.0% para +0.1% 0.0% 0.0% +0.0% +0.0% paraffins +0.1% 0.0% +0.0% -0.0% 0.0% parser +0.1% 0.0% -0.0% -0.0% -0.0% parstof +0.1% 0.0% +0.0% +0.0% +0.0% pic +0.1% 0.0% -0.0% -0.0% 0.0% pidigits +0.1% 0.0% +0.0% -0.0% -0.0% power +0.1% 0.0% +0.0% +0.0% +0.0% pretty +0.1% 0.0% -0.0% -0.0% -0.1% primes +0.1% 0.0% -0.0% -0.0% -0.0% primetest +0.1% 0.0% -0.0% -0.0% -0.0% prolog +0.1% 0.0% -0.0% -0.0% -0.0% puzzle +0.1% 0.0% -0.0% -0.0% -0.0% queens +0.1% 0.0% +0.0% +0.0% +0.0% reptile +0.1% 0.0% -0.0% -0.0% +0.0% reverse-complem +0.1% 0.0% +0.0% 0.0% -0.0% rewrite +0.1% 0.0% -0.0% -0.0% -0.0% rfib +0.1% 0.0% +0.0% +0.0% +0.0% rsa +0.1% 0.0% -0.0% +0.0% -0.0% scc +0.1% 0.0% -0.0% -0.0% -0.1% sched +0.1% 0.0% +0.0% +0.0% +0.0% scs +0.1% 0.0% +0.0% +0.0% +0.0% simple +0.1% 0.0% -0.0% -0.0% -0.0% solid +0.1% 0.0% +0.0% +0.0% +0.0% sorting +0.1% 0.0% -0.0% -0.0% -0.0% spectral-norm +0.1% 0.0% +0.0% +0.0% +0.0% sphere +0.1% 0.0% -0.0% -0.0% -0.0% symalg +0.1% 0.0% -0.0% -0.0% -0.0% tak +0.1% 0.0% +0.0% +0.0% +0.0% transform +0.1% 0.0% +0.0% +0.0% +0.0% treejoin +0.1% 0.0% +0.0% -0.0% -0.0% typecheck +0.1% 0.0% +0.0% +0.0% +0.0% veritas +0.0% 0.0% +0.0% +0.0% +0.0% wang +0.1% 0.0% 0.0% +0.0% +0.0% wave4main +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve1 +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve2 +0.1% 0.0% +0.0% +0.0% +0.0% x2n1 +0.1% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -0.0% -0.1% Max +0.1% 0.0% +0.0% +0.0% +0.0% Geometric Mean +0.1% -0.0% -0.0% -0.0% -0.0% Bumping numbers of nonsensical perf tests: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 It's simply not possible for this patch to increase allocations, and I've wasted enough time on these test in the past (see #17686). I think these tests should not be perf tests, but for now I'll bump the numbers. - - - - - dce50062 by Sylvain Henry at 2020-04-09T16:18:44-04:00 Rts: show errno on failure (#18033) - - - - - 045139f4 by Hécate at 2020-04-09T23:10:44-04:00 Add an example to liftIO and explain its purpose - - - - - 101fab6e by Sebastian Graf at 2020-04-09T23:11:21-04:00 Special case `isConstraintKindCon` on `AlgTyCon` Previously, the `tyConUnique` record selector would unfold into a huge case expression that would be inlined in all call sites, such as the `INLINE`-annotated `coreView`, see #18026. `constraintKindTyConKey` only occurs as the `Unique` of an `AlgTyCon` anyway, so we can make the code a lot more compact, but have to move it to GHC.Core.TyCon. Metric Decrease: T12150 T12234 - - - - - f5212dfc by Sebastian Graf at 2020-04-09T23:11:57-04:00 DmdAnal: No need to attach a StrictSig to DataCon workers In GHC.Types.Id.Make we were giving a strictness signature to every data constructor wrapper Id that we weren't looking at in demand analysis anyway. We used to use its CPR info, but that has its own CPR signature now. `Note [Data-con worker strictness]` then felt very out of place, so I moved it to GHC.Core.DataCon. - - - - - 75a185dc by Sylvain Henry at 2020-04-09T23:12:37-04:00 Hadrian: fix --summary - - - - - 723062ed by Ömer Sinan Ağacan at 2020-04-10T09:18:14+03:00 testsuite: Move no_lint to the top level, tweak hie002 - We don't want to benchmark linting so disable lints in hie002 perf test - Move no_lint to the top-level to be able to use it in tests other than those in `testsuite/tests/perf/compiler`. - Filter out -dstg-lint in no_lint. - hie002 allocation numbers on 32-bit are unstable, so skip it on 32-bit Metric Decrease: hie002 ManyConstructors T12150 T12234 T13035 T1969 T4801 T9233 T9961 - - - - - bcafaa82 by Peter Trommler at 2020-04-10T19:29:33-04:00 Testsuite: mark T11531 fragile The test depends on a link editor allowing undefined symbols in an ELF shared object. This is the standard but it seems some distributions patch their link editor. See the report by @hsyl20 in #11531. Fixes #11531 - - - - - 0889f5ee by Takenobu Tani at 2020-04-12T11:44:52+09:00 testsuite: Fix comment for a language extension [skip ci] - - - - - cd4f92b5 by Simon Peyton Jones at 2020-04-12T11:20:58-04:00 Significant refactor of Lint This refactoring of Lint was triggered by #17923, which is fixed by this patch. The main change is this. Instead of lintType :: Type -> LintM LintedKind we now have lintType :: Type -> LintM LintedType Previously, all of typeKind was effectively duplicate in lintType. Moreover, since we have an ambient substitution, we still had to apply the substition here and there, sometimes more than once. It was all very tricky, in the end, and made my head hurt. Now, lintType returns a fully linted type, with all substitutions performed on it. This is much simpler. The same thing is needed for Coercions. Instead of lintCoercion :: OutCoercion -> LintM (LintedKind, LintedKind, LintedType, LintedType, Role) we now have lintCoercion :: Coercion -> LintM LintedCoercion Much simpler! The code is shorter and less bug-prone. There are a lot of knock on effects. But life is now better. Metric Decrease: T1969 - - - - - 0efaf301 by Josh Meredith at 2020-04-12T11:21:34-04:00 Implement extensible interface files - - - - - 54ca66a7 by Ryan Scott at 2020-04-12T11:22:10-04:00 Use conLikeUserTyVarBinders to quantify field selector types This patch: 1. Writes up a specification for how the types of top-level field selectors should be determined in a new section of the GHC User's Guide, and 2. Makes GHC actually implement that specification by using `conLikeUserTyVarBinders` in `mkOneRecordSelector` to preserve the order and specificity of type variables written by the user. Fixes #18023. - - - - - 35799dda by Ben Gamari at 2020-04-12T11:22:50-04:00 hadrian: Don't --export-dynamic on Darwin When fixing #17962 I neglected to consider that --export-dynamic is only supported on ELF platforms. - - - - - e8029816 by Alexis King at 2020-04-12T11:23:27-04:00 Add an INLINE pragma to Control.Category.>>> This fixes #18013 by adding INLINE pragmas to both Control.Category.>>> and GHC.Desugar.>>>. The functional change in this patch is tiny (just two lines of pragmas!), but an accompanying Note explains in gory detail what’s going on. - - - - - 0da186c1 by Krzysztof Gogolewski at 2020-04-14T07:55:20-04:00 Change zipWith to zipWithEqual in a few places - - - - - 074c1ccd by Andreas Klebinger at 2020-04-14T07:55:55-04:00 Small change to the windows ticker. We already have a function to go from time to ms so use it. Also expand on the state of timer resolution. - - - - - b69cc884 by Alp Mestanogullari at 2020-04-14T07:56:38-04:00 hadrian: get rid of unnecessary levels of nesting in source-dist - - - - - d0c3b069 by Julien Debon at 2020-04-14T07:57:16-04:00 doc (Foldable): Add examples to Data.Foldable See #17929 - - - - - 5b08e0c0 by Ben Gamari at 2020-04-14T23:28:20-04:00 StgCRun: Enable unwinding only on Linux It's broken on macOS due and SmartOS due to assembler differences (#15207) so let's be conservative in enabling it. Also, refactor things to make the intent clearer. - - - - - 27cc2e7b by Ben Gamari at 2020-04-14T23:28:57-04:00 rts: Don't mark evacuate_large as inline This function has two callsites and is quite large. GCC consequently decides not to inline and warns instead. Given the situation, I can't blame it. Let's just remove the inline specifier. - - - - - 9853fc5e by Ben Gamari at 2020-04-14T23:29:48-04:00 base: Enable large file support for OFD locking impl. Not only is this a good idea in general but this should also avoid issue #17950 by ensuring that off_t is 64-bits. - - - - - 7b41f21b by Matthew Pickering at 2020-04-14T23:30:24-04:00 Hadrian: Make -i paths absolute The primary reason for this change is that ghcide does not work with relative paths. It also matches what cabal and stack do, they always pass absolute paths. - - - - - 41230e26 by Daniel Gröber at 2020-04-14T23:31:01-04:00 Zero out pinned block alignment slop when profiling The heap profiler currently cannot traverse pinned blocks because of alignment slop. This used to just be a minor annoyance as the whole block is accounted into a special cost center rather than the respective object's CCS, cf. #7275. However for the new root profiler we would like to be able to visit _every_ closure on the heap. We need to do this so we can get rid of the current 'flip' bit hack in the heap traversal code. Since info pointers are always non-zero we can in principle skip all the slop in the profiler if we can rely on it being zeroed. This assumption caused problems in the past though, commit a586b33f8e ("rts: Correct handling of LARGE ARR_WORDS in LDV profiler"), part of !1118, tried to use the same trick for BF_LARGE objects but neglected to take into account that shrink*Array# functions don't ensure that slop is zeroed when not compiling with profiling. Later, commit 0c114c6599 ("Handle large ARR_WORDS in heap census (fix as we will only be assuming slop is zeroed when profiling is on. This commit also reduces the ammount of slop we introduce in the first place by calculating the needed alignment before doing the allocation for small objects where we know the next available address. For large objects we don't know how much alignment we'll have to do yet since those details are hidden behind the allocateMightFail function so there we continue to allocate the maximum additional words we'll need to do the alignment. So we don't have to duplicate all this logic in the cmm code we pull it into the RTS allocatePinned function instead. Metric Decrease: T7257 haddock.Cabal haddock.base - - - - - 15fa9bd6 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Expand and add more notes regarding slop - - - - - caf3f444 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: allocatePinned: Fix confusion about word/byte units - - - - - c3c0f662 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Underline some Notes as is conventional - - - - - e149dea9 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Fix nomenclature in OVERWRITING_CLOSURE macros The additional commentary introduced by commit 8916e64e5437 ("Implement shrinkSmallMutableArray# and resizeSmallMutableArray#.") unfortunately got this wrong. We set 'prim' to true in overwritingClosureOfs because we _don't_ want to call LDV_recordDead(). The reason is because of this "inherently used" distinction made in the LDV profiler so I rename the variable to be more appropriate. - - - - - 1dd3d18c by Daniel Gröber at 2020-04-14T23:31:38-04:00 Remove call to LDV_RECORD_CREATE for array resizing - - - - - 19de2fb0 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Assert LDV_recordDead is not called for inherently used closures The comments make it clear LDV_recordDead should not be called for inhererently used closures, so add an assertion to codify this fact. - - - - - 0b934e30 by Ryan Scott at 2020-04-14T23:32:14-04:00 Bump template-haskell version to 2.17.0.0 This requires bumping the `exceptions` and `text` submodules to bring in commits that bump their respective upper version bounds on `template-haskell`. Fixes #17645. Fixes #17696. Note that the new `text` commit includes a fair number of additions to the Haddocks in that library. As a result, Haddock has to do more work during the `haddock.Cabal` test case, increasing the number of allocations it requires. Therefore, ------------------------- Metric Increase: haddock.Cabal ------------------------- - - - - - 22cc8e51 by Ryan Scott at 2020-04-15T17:48:47-04:00 Fix #18052 by using pprPrefixOcc in more places This fixes several small oversights in the choice of pretty-printing function to use. Fixes #18052. - - - - - ec77b2f1 by Daniel Gröber at 2020-04-15T17:49:24-04:00 rts: ProfHeap: Fix wrong time in last heap profile sample We've had this longstanding issue in the heap profiler, where the time of the last sample in the profile is sometimes way off causing the rendered graph to be quite useless for long runs. It seems to me the problem is that we use mut_user_time() for the last sample as opposed to getRTSStats(), which we use when calling heapProfile() in GC.c. The former is equivalent to getProcessCPUTime() but the latter does some additional stuff: getProcessCPUTime() - end_init_cpu - stats.gc_cpu_ns - stats.nonmoving_gc_cpu_ns So to fix this just use getRTSStats() in both places. - - - - - 85fc32f0 by Sylvain Henry at 2020-04-17T12:45:25-04:00 Hadrian: fix dyn_o/dyn_hi rule (#17534) - - - - - bfde3b76 by Ryan Scott at 2020-04-17T12:46:02-04:00 Fix #18065 by fixing an InstCo oversight in Core Lint There was a small thinko in Core Lint's treatment of `InstCo` coercions that ultimately led to #18065. The fix: add an apostrophe. That's it! Fixes #18065. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> - - - - - a05348eb by Cale Gibbard at 2020-04-17T13:08:47-04:00 Change the fail operator argument of BindStmt to be a Maybe Don't use noSyntaxExpr for it. There is no good way to defensively case on that, nor is it clear one ought to do so. - - - - - 79e27144 by John Ericson at 2020-04-17T13:08:47-04:00 Use trees that grow for rebindable operators for `<-` binds Also add more documentation. - - - - - 18bc16ed by Cale Gibbard at 2020-04-17T13:08:47-04:00 Use FailOperator in more places, define a couple datatypes (XBindStmtRn and XBindStmtTc) to help clarify the meaning of XBindStmt in the renamer and typechecker - - - - - 84cc8394 by Simon Peyton Jones at 2020-04-18T13:20:29-04:00 Add a missing zonk in tcHsPartialType I omitted a vital zonk when refactoring tcHsPartialType in commit 48fb3482f8cbc8a4b37161021e846105f980eed4 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Wed Jun 5 08:55:17 2019 +0100 Fix typechecking of partial type signatures This patch fixes it and adds commentary to explain why. Fixes #18008 - - - - - 2ee96ac1 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Bump FreeBSD bootstrap compiler to 8.10.1 - - - - - 434312e5 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Enable FreeBSD job for so-labelled MRs - - - - - ddffb227 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Use rules syntax for conditional jobs - - - - - e2586828 by Ben Gamari at 2020-04-18T13:21:05-04:00 Bump hsc2hs submodule - - - - - 15ab6cd5 by Ömer Sinan Ağacan at 2020-04-18T13:21:44-04:00 Improve prepForeignCall error reporting Show parameters and description of the error code when ffi_prep_cif fails. This may be helpful for debugging #17018. - - - - - 3ca52151 by Sylvain Henry at 2020-04-18T20:04:14+02:00 GHC.Core.Opt renaming * GHC.Core.Op => GHC.Core.Opt * GHC.Core.Opt.Simplify.Driver => GHC.Core.Opt.Driver * GHC.Core.Opt.Tidy => GHC.Core.Tidy * GHC.Core.Opt.WorkWrap.Lib => GHC.Core.Opt.WorkWrap.Utils As discussed in: * https://mail.haskell.org/pipermail/ghc-devs/2020-April/018758.html * https://gitlab.haskell.org/ghc/ghc/issues/13009#note_264650 - - - - - 15312bbb by Sylvain Henry at 2020-04-18T20:04:46+02:00 Modules (#13009) * SysTools * Parser * GHC.Builtin * GHC.Iface.Recomp * Settings Update Haddock submodule Metric Decrease: Naperian parsing001 - - - - - eaed0a32 by Alexis King at 2020-04-19T03:16:44-04:00 Add missing addInScope call for letrec binders in OccurAnal This fixes #18044, where a shadowed variable was incorrectly substituted by the binder swap on the RHS of a floated-in letrec. This can only happen when the uniques line up *just* right, so writing a regression test would be very difficult, but at least the fix is small and straightforward. - - - - - 36882493 by Shayne Fletcher at 2020-04-20T04:36:43-04:00 Derive Ord instance for Extension Metric Increase: T12150 T12234 - - - - - b43365ad by Simon Peyton Jones at 2020-04-20T04:37:20-04:00 Fix a buglet in redundant-constraint warnings Ticket #18036 pointed out that we were reporting a redundant constraint when it really really wasn't. Turned out to be a buglet in the SkolemInfo for the relevant implication constraint. Easily fixed! - - - - - d5fae7da by Ömer Sinan Ağacan at 2020-04-20T14:39:28-04:00 Mark T12010 fragile on 32-bit - - - - - bca02fca by Adam Sandberg Ericsson at 2020-04-21T06:38:45-04:00 docs: drop note about not supporting shared libraries on unix systems [skip ci] - - - - - 6655f933 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Use ParserFlags in GHC.Runtime.Eval (#17957) Instead of passing `DynFlags` to functions such as `isStmt` and `hasImport` in `GHC.Runtime.Eval` we pass `ParserFlags`. It's a much simpler structure that can be created purely with `mkParserFlags'`. - - - - - 70be0fbc by Sylvain Henry at 2020-04-21T06:39:32-04:00 GHC.Runtime: avoid DynFlags (#17957) * add `getPlatform :: TcM Platform` helper * remove unused `DynFlags` parameter from `emptyPLS` - - - - - 35e43d48 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid DynFlags in Ppr code (#17957) * replace `DynFlags` parameters with `SDocContext` parameters for a few Ppr related functions: `bufLeftRenderSDoc`, `printSDoc`, `printSDocLn`, `showSDocOneLine`. * remove the use of `pprCols :: DynFlags -> Int` in Outputable. We already have the information via `sdocLineLength :: SDocContext -> Int` - - - - - ce5c2999 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid using sdocWithDynFlags (#17957) Remove one use of `sdocWithDynFlags` from `GHC.CmmToLlvm.llvmCodeGen'` and from `GHC.Driver.CodeOutput.profilingInitCode` - - - - - f2a98996 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid `sdocWithDynFlags` in `pprCLbl` (#17957) * add a `DynFlags` parameter to `pprCLbl` * put `maybe_underscore` and `pprAsmCLbl` in a `where` clause to avoid `DynFlags` parameters - - - - - 747093b7 by Sylvain Henry at 2020-04-21T06:39:32-04:00 CmmToAsm DynFlags refactoring (#17957) * Remove `DynFlags` parameter from `isDynLinkName`: `isDynLinkName` used to test the global `ExternalDynamicRefs` flag. Now we test it outside of `isDynLinkName` * Add new fields into `NCGConfig`: current unit id, sse/bmi versions, externalDynamicRefs, etc. * Replace many uses of `DynFlags` by `NCGConfig` * Moved `BMI/SSE` datatypes into `GHC.Platform` - - - - - ffd7eef2 by Takenobu Tani at 2020-04-22T23:09:50-04:00 stg-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Stg/Syntax.hs <= stgSyn/StgSyn.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/CostCentre.hs <= profiling/CostCentre.hs This patch also updates old file path [2]: * utils/genapply/Main.hs <= utils/genapply/GenApply.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: commit 0cc4aad36f [skip ci] - - - - - e8a5d81b by Jonathan DK Gibbons at 2020-04-22T23:10:28-04:00 Refactor the `MatchResult` type in the desugarer This way, it does a better job of proving whether or not the fail operator is used. - - - - - dcb7fe5a by John Ericson at 2020-04-22T23:10:28-04:00 Remove panic in dsHandleMonadicFailure Rework dsHandleMonadicFailure to be correct by construction instead of using an unreachable panic. - - - - - cde23cd4 by John Ericson at 2020-04-22T23:10:28-04:00 Inline `adjustMatchResult` It is just `fmap` - - - - - 72cb6bcc by John Ericson at 2020-04-22T23:10:28-04:00 Generalize type of `matchCanFail` - - - - - 401f7bb3 by John Ericson at 2020-04-22T23:10:28-04:00 `MatchResult'` -> `MatchResult` Inline `MatchResult` alias accordingly. - - - - - 6c9fae23 by Alexis King at 2020-04-22T23:11:12-04:00 Mark DataCon wrappers CONLIKE Now that DataCon wrappers don’t inline until phase 0 (see commit b78cc64e923716ac0512c299f42d4d0012306c05), it’s important that case-of-known-constructor and RULE matching be able to see saturated applications of DataCon wrappers in unfoldings. Making them conlike is a natural way to do it, since they are, in fact, precisely the sort of thing the CONLIKE pragma exists to solve. Fixes #18012. This also bumps the version of the parsec submodule to incorporate a patch that avoids a metric increase on the haddock perf tests. The increase was not really a flaw in this patch, as parsec was implicitly relying on inlining heuristics. The patch to parsec just adds some INLINABLE pragmas, and we get a nice performance bump out of it (well beyond the performance we lost from this patch). Metric Decrease: T12234 WWRec haddock.Cabal haddock.base haddock.compiler - - - - - 48b8951e by Roland Senn at 2020-04-22T23:11:51-04:00 Fix tab-completion for :break (#17989) In tab-completion for the `:break` command, only those identifiers should be shown, that are accepted in the `:break` command. Hence these identifiers must be - defined in an interpreted module - top-level - currently in scope - listed in a `ModBreaks` value as a possible breakpoint. The identifiers my be qualified or unqualified. To get all possible top-level breakpoints for tab-completeion with the correct qualification do: 1. Build the list called `pifsBreaks` of all pairs of (Identifier, module-filename) from the `ModBreaks` values. Here all identifiers are unqualified. 2. Build the list called `pifInscope` of all pairs of (Identifiers, module-filename) with identifiers from the `GlobalRdrEnv`. Take only those identifiers that are in scope and have the correct prefix. Here the identifiers may be qualified. 3. From the `pifInscope` list seclect all pairs that can be found in the `pifsBreaks` list, by comparing only the unqualified part of the identifier. The remaining identifiers can be used for tab-completion. This ensures, that we show only identifiers, that can be used in a `:break` command. - - - - - 34a45ee6 by Peter Trommler at 2020-04-22T23:12:27-04:00 PPC NCG: Add DWARF constants and debug labels Fixes #11261 - - - - - ffde2348 by Simon Peyton Jones at 2020-04-22T23:13:06-04:00 Do eager instantation in terms This patch implements eager instantiation, a small but critical change to the type inference engine, #17173. The main change is this: When inferring types, always return an instantiated type (for now, deeply instantiated; in future shallowly instantiated) There is more discussion in https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html There is quite a bit of refactoring in this patch: * The ir_inst field of GHC.Tc.Utils.TcType.InferResultk has entirely gone. So tcInferInst and tcInferNoInst have collapsed into tcInfer. * Type inference of applications, via tcInferApp and tcInferAppHead, are substantially refactored, preparing the way for Quick Look impredicativity. * New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs are beatifully dual. We can see the zipper! * GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return a wrapper * In HsExpr, HsTypeApp now contains the the actual type argument, and is used in desugaring, rather than putting it in a mysterious wrapper. * I struggled a bit with good error reporting in Unify.matchActualFunTysPart. It's a little bit simpler than before, but still not great. Some smaller things * Rename tcPolyExpr --> tcCheckExpr tcMonoExpr --> tcLExpr * tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat Metric Decrease: T9961 Reduction of 1.6% in comiler allocation on T9961, I think. - - - - - 6f84aca3 by Ben Gamari at 2020-04-22T23:13:43-04:00 rts: Ensure that sigaction structs are initialized I noticed these may have uninitialized fields when looking into #18037. The reporter says that zeroing them doesn't fix the MSAN failures they observe but zeroing them is the right thing to do regardless. - - - - - c29f0fa6 by Andreas Klebinger at 2020-04-22T23:14:21-04:00 Add "ddump-cmm-opt" as alias for "ddump-opt-cmm". - - - - - 4b4a8b60 by Ben Gamari at 2020-04-22T23:14:57-04:00 llvmGen: Remove -fast-llvm flag Issue #18076 drew my attention to the undocumented `-fast-llvm` flag for the LLVM code generator introduced in 22733532171330136d87533d523f565f2a4f102f. Speaking to Moritz about this, the motivation for this flag was to avoid potential incompatibilities between LLVM and the assembler/linker toolchain by making LLVM responsible for machine-code generation. Unfortunately, this cannot possibly work: the LLVM backend's mangler performs a number of transforms on the assembler generated by LLVM that are necessary for correctness. These are currently: * mangling Haskell functions' symbol types to be `object` instead of `function` on ELF platforms (necessary for tables-next-to-code) * mangling AVX instructions to ensure that we don't assume alignment (which LLVM otherwise does) * mangling Darwin's subsections-via-symbols directives Given that these are all necessary I don't believe that we can support `-fast-llvm`. Let's rather remove it. - - - - - 831b6642 by Moritz Angermann at 2020-04-22T23:15:33-04:00 Fix build warning; add more informative information to the linker; fix linker for empty sections - - - - - c409961a by Ryan Scott at 2020-04-22T23:16:12-04:00 Update commentary and slightly refactor GHC.Tc.Deriv.Infer There was some out-of-date commentary in `GHC.Tc.Deriv.Infer` that has been modernized. Along the way, I removed the `bad` constraints in `simplifyDeriv`, which did not serve any useful purpose (besides being printed in debugging output). Fixes #18073. - - - - - 125aa2b8 by Ömer Sinan Ağacan at 2020-04-22T23:16:51-04:00 Remove leftover comment in tcRnModule', redundant bind The code for the comment was moved in dc8c03b2a5c but the comment was forgotten. - - - - - 8ea37b01 by Sylvain Henry at 2020-04-22T23:17:34-04:00 RTS: workaround a Linux kernel bug in timerfd Reading a timerfd may return 0: https://lkml.org/lkml/2019/8/16/335. This is currently undocumented behavior and documentation "won't happen anytime soon" (https://lkml.org/lkml/2020/2/13/295). With this patch, we just ignore the result instead of crashing. It may fix #18033 but we can't be sure because we don't have enough information. See also this discussion about the kernel bug: https://github.com/Azure/sonic-swss-common/pull/302/files/1f070e7920c2e5d63316c0105bf4481e73d72dc9 - - - - - cd8409c2 by Ryan Scott at 2020-04-23T11:39:24-04:00 Create di_scoped_tvs for associated data family instances properly See `Note [Associated data family instances and di_scoped_tvs]` in `GHC.Tc.TyCl.Instance`, which explains all of the moving parts. Fixes #18055. - - - - - 339e8ece by Ben Gamari at 2020-04-23T11:40:02-04:00 hadrian/ghci: Allow arguments to be passed to GHCi Previously the arguments passed to hadrian/ghci were passed both to `hadrian` and GHCi. This is rather odd given that there are essentially not arguments in the intersection of the two. Let's just pass them to GHCi; this allows `hadrian/ghci -Werror`. - - - - - 5946c85a by Ben Gamari at 2020-04-23T11:40:38-04:00 testsuite: Don't attempt to read .std{err,out} files if they don't exist Simon reports that he was previously seeing framework failures due to an attempt to read the non-existing T13456.stderr. While I don't know exactly what this is due to, it does seem like a non-existing .std{out,err} file should be equivalent to an empty file. Teach the testsuite driver to treat it as such. - - - - - c42754d5 by John Ericson at 2020-04-23T18:32:43-04:00 Trees That Grow refactor for `ConPat` and `CoPat` - `ConPat{In,Out}` -> `ConPat` - `CoPat` -> `XPat (CoPat ..)` Note that `GHC.HS.*` still uses `HsWrap`, but only when `p ~ GhcTc`. After this change, moving the type family instances out of `GHC.HS.*` is sufficient to break the cycle. Add XCollectPat class to decide how binders are collected from XXPat based on the pass. Previously we did this with IsPass, but that doesn't work for Haddock's DocNameI, and the constraint doesn't express what actual distinction is being made. Perhaps a class for collecting binders more generally is in order, but we haven't attempted this yet. Pure refactor of code around ConPat - InPat/OutPat synonyms removed - rename several identifiers - redundant constraints removed - move extension field in ConPat to be first - make ConPat use record syntax more consistently Fix T6145 (ConPatIn became ConPat) Add comments from SPJ. Add comment about haddock's use of CollectPass. Updates haddock submodule. - - - - - 72da0c29 by mniip at 2020-04-23T18:33:21-04:00 Add :doc to GHC.Prim - - - - - 2c23e2e3 by mniip at 2020-04-23T18:33:21-04:00 Include docs for non-primop entries in primops.txt as well - - - - - 0ac29c88 by mniip at 2020-04-23T18:33:21-04:00 GHC.Prim docs: note and test - - - - - b0fbfc75 by John Ericson at 2020-04-24T12:07:14-04:00 Switch order on `GhcMake.IsBoot` In !1798 we were requested to replace many `Bool`s with this data type. But those bools had `False` meaning `NotBoot`, so the `Ord` instance would be flipped if we use this data-type as-is. Since the planned formally-`Bool` occurrences vastly outnumber the current occurrences, we figured it would be better to conform the `Ord` instance to how the `Bool` is used now, fixing any issues, rather than fix them currently with the bigger refactor later in !1798. That way, !1798 can be a "pure" refactor with no behavioral changes. - - - - - af332442 by Sylvain Henry at 2020-04-26T13:55:14-04:00 Modules: Utils and Data (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - cd4434c8 by Sylvain Henry at 2020-04-26T13:55:16-04:00 Fix misleading Ptr phantom type in SerializedCompact (#15653) - - - - - 22bf5c73 by Ömer Sinan Ağacan at 2020-04-26T13:55:22-04:00 Tweak includes in non-moving GC headers We don't use hash tables in non-moving GC so remove the includes. This breaks Compact.c as existing includes no longer include Hash.h, so include Hash.h explicitly in Compact.c. - - - - - 99823ed2 by Sylvain Henry at 2020-04-27T20:24:46-04:00 TH: fix Show/Eq/Ord instances for Bytes (#16457) We shouldn't compare pointer values but the actual bytes. - - - - - c62271a2 by Alp Mestanogullari at 2020-04-27T20:25:33-04:00 hadrian: always capture both stdout and stderr when running a builder fails The idea being that when a builder('s command) fails, we quite likely want to have all the information available to figure out why. Depending on the builder _and_ the particular problem, the useful bits of information can be printed on stdout or stderr. We accomplish this by defining a simple wrapper for Shake's `cmd` function, that just _always_ captures both streams in case the command returns a non-zero exit code, and by using this wrapper everywhere in `hadrian/src/Builder.hs`. Fixes #18089. - - - - - 4b9764db by Ryan Scott at 2020-04-28T15:40:04-04:00 Define a Quote IO instance Fixes #18103. - - - - - 518a63d4 by Ryan Scott at 2020-04-28T15:40:42-04:00 Make boxed 1-tuples have known keys Unlike other tuples, which use special syntax and are "known" by way of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not use special syntax. Therefore, in order to make sure that the internals of GHC are aware of the `data Unit a = Unit a` definition in `GHC.Tuple`, we give `Unit` known keys. For the full details, see `Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)` in `GHC.Builtin.Types`. Fixes #18097. - - - - - 2cfc4ab9 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Document backpack fields in DynFlags - - - - - 10a2ba90 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo * Rename InstalledPackageInfo into GenericUnitInfo The name InstalledPackageInfo is only kept for alleged backward compatibility reason in Cabal. ghc-boot has its own stripped down copy of this datatype but it doesn't need to keep the name. Internally we already use type aliases (UnitInfo in GHC, PackageCacheFormat in ghc-pkg). * Rename UnitInfo fields: add "unit" prefix and fix misleading names * Add comments on every UnitInfo field * Rename SourcePackageId into PackageId "Package" already indicates that it's a "source package". Installed package components are called units. Update Haddock submodule - - - - - 69562e34 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Remove unused `emptyGenericUnitInfo` - - - - - 9e2c8e0e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo load/store from databases Converting between UnitInfo stored in package databases and UnitInfo as they are used in ghc-pkg and ghc was done in a very convoluted way (via BinaryStringRep and DbUnitModuleRep type classes using fun deps, etc.). It was difficult to understand and even more to modify (I wanted to try to use a GADT for UnitId but fun deps got in the way). The new code uses much more straightforward functions to convert between the different representations. Much simpler. - - - - - ea717aa4 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Factorize mungePackagePaths code This patch factorizes the duplicated code used in ghc-pkg and in GHC to munge package paths/urls. It also fixes haddock-html munging in GHC (allowed to be either a file or a url) to mimic ghc-pkg behavior. - - - - - 10d15f1e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactoring unit management code Over the years the unit management code has been modified a lot to keep up with changes in Cabal (e.g. support for several library components in the same package), to integrate BackPack, etc. I found it very hard to understand as the terminology wasn't consistent, was referring to past concepts, etc. The terminology is now explained as clearly as I could in the Note "About Units" and the code is refactored to reflect it. ------------------- Many names were misleading: UnitId is not an Id but could be a virtual unit (an indefinite one instantiated on the fly), IndefUnitId constructor may contain a definite instantiated unit, etc. * Rename IndefUnitId into InstantiatedUnit * Rename IndefModule into InstantiatedModule * Rename UnitId type into Unit * Rename IndefiniteUnitId constructor into VirtUnit * Rename DefiniteUnitId constructor into RealUnit * Rename packageConfigId into mkUnit * Rename getPackageDetails into unsafeGetUnitInfo * Rename InstalledUnitId into UnitId Remove references to misleading ComponentId: a ComponentId is just an indefinite unit-id to be instantiated. * Rename ComponentId into IndefUnitId * Rename ComponentDetails into UnitPprInfo * Fix display of UnitPprInfo with empty version: this is now used for units dynamically generated by BackPack Generalize several types (Module, Unit, etc.) so that they can be used with different unit identifier types: UnitKey, UnitId, Unit, etc. * GenModule: Module, InstantiatedModule and InstalledModule are now instances of this type * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit, PackageDatabase Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor. Add basic support for UnitKey. They should be used more in the future to avoid mixing them up with UnitId as we do now. Add many comments. Update Haddock submodule - - - - - 8bfb0219 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Unit: split and rename modules Introduce GHC.Unit.* hierarchy for everything concerning units, packages and modules. Update Haddock submodule - - - - - 71484b09 by Alexis King at 2020-04-30T01:57:35-04:00 Allow block arguments in arrow control operators Arrow control operators have their own entries in the grammar, so they did not cooperate with BlockArguments. This was just a minor oversight, so this patch adjusts the grammar to add the desired behavior. fixes #18050 - - - - - a48cd2a0 by Alexis King at 2020-04-30T01:57:35-04:00 Allow LambdaCase to be used as a command in proc notation - - - - - f4d3773c by Alexis King at 2020-04-30T01:57:35-04:00 Document BlockArguments/LambdaCase support in arrow notation - - - - - 5bdfdd13 by Simon Peyton Jones at 2020-04-30T01:58:15-04:00 Add tests for #17873 - - - - - 19b701c2 by Simon Peyton Jones at 2020-04-30T07:30:13-04:00 Mark rule args as non-tail-called This was just an omission...b I'd failed to call markAllNonTailCall on rule args. I think this bug has been here a long time, but it's quite hard to trigger. Fixes #18098 - - - - - 014ef4a3 by Matthew Pickering at 2020-04-30T07:30:50-04:00 Hadrian: Improve tool-args command to support more components There is a new command to hadrian, tool:path/to/file.hs, which returns the options needed to compile that file in GHCi. This is now used in the ghci script with argument `ghc/Main.hs` but its main purpose is to support the new multi-component branch of ghcide. - - - - - 2aa67611 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Clear bitmap after initializing block size Previously nonmovingInitSegment would clear the bitmap before initializing the segment's block size. This is broken since nonmovingClearBitmap looks at the segment's block size to determine how much bitmap to clear. - - - - - 54dad3cf by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Explicitly memoize block count A profile cast doubt on whether the compiler hoisted the bound out the loop as I would have expected here. It turns out it did but nevertheless it seems clearer to just do this manually. - - - - - 99ff8145 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Eagerly flush all capabilities' update remembered sets (cherry picked from commit 2fa79119570b358a4db61446396889b8260d7957) - - - - - 05b0a9fd by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 Remove OneShotInfo field of LFReEntrant, document OneShotInfo The field is only used in withNewTickyCounterFun and it's easier to directly pass a parameter for one-shot info to withNewTickyCounterFun instead of passing it via LFReEntrant. This also makes !2842 simpler. Other changes: - New Note (by SPJ) [OneShotInfo overview] added. - Arity argument of thunkCode removed as it's always 0. - - - - - a43620c6 by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 GHC.StgToCmm.Ticky: remove a few unused stuff - - - - - 780de9e1 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Use platform in Iface Binary - - - - - f8386c7b by Sylvain Henry at 2020-05-01T10:37:39-04:00 Refactor PprDebug handling If `-dppr-debug` is set, then PprUser and PprDump styles are silently replaced with PprDebug style. This was done in `mkUserStyle` and `mkDumpStyle` smart constructors. As a consequence they needed a DynFlags parameter. Now we keep the original PprUser and PprDump styles until they are used to create an `SDocContext`. I.e. the substitution is only performed in `initSDocContext`. - - - - - b3df9e78 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Remove PprStyle param of logging actions Use `withPprStyle` instead to apply a specific style to a SDoc. - - - - - de9fc995 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Fully remove PprDebug PprDebug was a pain to deal with consistently as it is implied by `-dppr-debug` but it isn't really a PprStyle. We remove it completely and query the appropriate SDoc flag instead (`sdocPprDebug`) via helpers (`getPprDebug` and its friends). - - - - - 8b51fcbd by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Only call checkSingle if we would report warnings - - - - - fd7ea0fe by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Pick up `EvVar`s bound in `HsWrapper`s for long-distance info `HsWrapper`s introduce evidence bindings through `WpEvLam` which the pattern-match coverage checker should be made aware of. Failing to do so caused #18049, where the resulting impreciseness of imcompleteness warnings seemingly contradicted with `-Winaccessible-code`. The solution is simple: Collect all the evidence binders of an `HsWrapper` and add it to the ambient `Deltas` before desugaring the wrapped expression. But that means we pick up many more evidence bindings, even when they wrap around code without a single pattern match to check! That regressed `T3064` by over 300%, so now we are adding long-distance info lazily through judicious use of `unsafeInterleaveIO`. Fixes #18049. - - - - - 7bfe9ac5 by Ben Gamari at 2020-05-03T04:41:33-04:00 rts: Enable tracing of nonmoving heap census with -ln Previously this was not easily available to the user. Fix this. Non-moving collection lifecycle events are now reported with -lg. - - - - - c560dd07 by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Move eventlog documentation users guide - - - - - 02543d5e by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Add documentation for non-moving GC events - - - - - b465dd45 by Alexis King at 2020-05-03T04:42:12-04:00 Flatten nested casts in the simple optimizer Normally, we aren’t supposed to generated any nested casts, since mkCast takes care to flatten them, but the simple optimizer didn’t use mkCast, so they could show up after inlining. This isn’t really a problem, since the simplifier will clean them up immediately anyway, but it can clutter the -ddump-ds output, and it’s an extremely easy fix. closes #18112 - - - - - 8bdc03d6 by Simon Peyton Jones at 2020-05-04T01:56:59-04:00 Don't return a panic in tcNestedSplice In GHC.Tc.Gen.Splice.tcNestedSplice we were returning a typechecked expression of "panic". That is usually OK, because the result is discarded. But it happens that tcApp now looks at the typechecked expression, trivially, to ask if it is tagToEnum. So being bottom is bad. Moreover a debug-trace might print it out. So better to return a civilised expression, even though it is usually discarded. - - - - - 0bf640b1 by Baldur Blöndal at 2020-05-04T01:57:36-04:00 Don't require parentheses around via type (`-XDerivingVia'). Fixes #18130". - - - - - 30272412 by Artem Pelenitsyn at 2020-05-04T13:19:59-04:00 Remove custom ExceptionMonad class (#18075) (updating haddock submodule accordingly) - - - - - b9f7c08f by jneira at 2020-05-04T13:20:37-04:00 Remove unused hs-boot file - - - - - 1d8f80cd by Sylvain Henry at 2020-05-05T03:22:46-04:00 Remove references to -package-key * remove references to `-package-key` which has been removed in 2016 (240ddd7c39536776e955e881d709bbb039b48513) * remove support for `-this-package-key` which has been deprecated at the same time - - - - - 7bc3a65b by Sylvain Henry at 2020-05-05T03:23:31-04:00 Remove SpecConstrAnnotation (#13681) This has been deprecated since 2013. Use GHC.Types.SPEC instead. Make GHC.Exts "not-home" for haddock Metric Decrease: haddock.base - - - - - 3c862f63 by DenisFrezzato at 2020-05-05T03:24:15-04:00 Fix Haskell98 short description in documentation - - - - - 2420c555 by Ryan Scott at 2020-05-05T03:24:53-04:00 Add regression tests for #16244, #16245, #16758 Commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70 ended up fixing quite a few bugs: * This commit fixes #16244 completely. A regression test has been added. * This commit fixes one program from #16245. (The program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211369 still panics, and the program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211400 still loops infinitely.) A regression test has been added for this program. * This commit fixes #16758. Accordingly, this patch removes the `expect_broken` label from the `T16758` test case, moves it from `should_compile` to `should_fail` (as it should produce an error message), and checks in the expected stderr. - - - - - 40c71c2c by Sylvain Henry at 2020-05-05T03:25:31-04:00 Fix colorized error messages (#18128) In b3df9e780fb2f5658412c644849cd0f1e6f50331 I broke colorized messages by using "dump" style instead of "user" style. This commits fixes it. - - - - - 7ab6ab09 by Richard Eisenberg at 2020-05-06T04:39:32-04:00 Refactor hole constraints. Previously, holes (both expression holes / out of scope variables and partial-type-signature wildcards) were emitted as *constraints* via the CHoleCan constructor. While this worked fine for error reporting, there was a fair amount of faff in keeping these constraints in line. In particular, and unlike other constraints, we could never change a CHoleCan to become CNonCanonical. In addition: * the "predicate" of a CHoleCan constraint was really the type of the hole, which is not a predicate at all * type-level holes (partial type signature wildcards) carried evidence, which was never used * tcNormalise (used in the pattern-match checker) had to create a hole constraint just to extract it again; it was quite messy The new approach is to record holes directly in WantedConstraints. It flows much more nicely now. Along the way, I did some cleaning up of commentary in GHC.Tc.Errors.Hole, which I had a hard time understanding. This was instigated by a future patch that will refactor the way predicates are handled. The fact that CHoleCan's "predicate" wasn't really a predicate is incompatible with that future patch. No test case, because this is meant to be purely internal. It turns out that this change improves the performance of the pattern-match checker, likely because fewer constraints are sloshing about in tcNormalise. I have not investigated deeply, but an improvement is not a surprise here: ------------------------- Metric Decrease: PmSeriesG ------------------------- - - - - - 420b957d by Ben Gamari at 2020-05-06T04:40:08-04:00 rts: Zero block flags with -DZ Block flags are very useful for determining the state of a block. However, some block allocator users don't touch them, leading to misleading values. Ensure that we zero then when zero-on-gc is set. This is safe and makes the flags more useful during debugging. - - - - - 740b3b8d by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix incorrect failed_to_evac value during deadlock gc Previously we would incorrectly set the failed_to_evac flag if we evacuated a value due to a deadlock GC. This would cause us to mark more things as dirty than strictly necessary. It also turned up a nasty but which I will fix next. - - - - - b2d72c75 by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix handling of dirty objects Previously we (incorrectly) relied on failed_to_evac to be "precise". That is, we expected it to only be true if *all* of an object's fields lived outside of the non-moving heap. However, does not match the behavior of failed_to_evac, which is true if *any* of the object's fields weren't promoted (meaning that some others *may* live in the non-moving heap). This is problematic as we skip the non-moving write barrier for dirty objects (which we can only safely do if *all* fields point outside of the non-moving heap). Clearly this arises due to a fundamental difference in the behavior expected of failed_to_evac in the moving and non-moving collector. e.g., in the moving collector it is always safe to conservatively say failed_to_evac=true whereas in the non-moving collector the safe value is false. This issue went unnoticed as I never wrote down the dirtiness invariant enforced by the non-moving collector. We now define this invariant as An object being marked as dirty implies that all of its fields are on the mark queue (or, equivalently, update remembered set). To maintain this invariant we teach nonmovingScavengeOne to push the fields of objects which we fail to evacuate to the update remembered set. This is a simple and reasonably cheap solution and avoids the complexity and fragility that other, more strict alternative invariants would require. All of this is described in a new Note, Note [Dirty flags in the non-moving collector] in NonMoving.c. - - - - - 9f3e6884 by Zubin Duggal at 2020-05-06T04:41:08-04:00 Allow atomic update of NameCache in readHieFile The situation arises in ghcide where multiple different threads may need to update the name cache, therefore with the older interface it could happen that you start reading a hie file with name cache A and produce name cache A + B, but another thread in the meantime updated the namecache to A + C. Therefore if you write the new namecache you will lose the A' updates from the second thread. Updates haddock submodule - - - - - edec6a6c by Ryan Scott at 2020-05-06T04:41:57-04:00 Make isTauTy detect higher-rank contexts Previously, `isTauTy` would only detect higher-rank `forall`s, not higher-rank contexts, which led to some minor bugs observed in #18127. Easily fixed by adding a case for `(FunTy InvisArg _ _)`. Fixes #18127. - - - - - a95e7fe0 by Ömer Sinan Ağacan at 2020-05-06T04:42:39-04:00 ELF linker: increment curSymbol after filling in fields of current entry The bug was introduced in a8b7cef4d45 which added a field to the `symbols` array elements and then updated this code incorrectly: - oc->symbols[curSymbol++] = nm; + oc->symbols[curSymbol++].name = nm; + oc->symbols[curSymbol].addr = symbol->addr; - - - - - cab1871a by Sylvain Henry at 2020-05-06T04:43:21-04:00 Move LeadingUnderscore into Platform (#17957) Avoid direct use of DynFlags to know if symbols must be prefixed by an underscore. - - - - - 94e7c563 by Sylvain Henry at 2020-05-06T04:43:21-04:00 Don't use DynFlags in showLinkerState (#17957) - - - - - 9afd9251 by Ryan Scott at 2020-05-06T04:43:58-04:00 Refactoring: Use bindSigTyVarsFV in rnMethodBinds `rnMethodBinds` was explicitly using `xoptM` to determine if `ScopedTypeVariables` is enabled before bringing type variables bound by the class/instance header into scope. However, this `xoptM` logic is already performed by the `bindSigTyVarsFV` function. This patch uses `bindSigTyVarsFV` in `rnMethodBinds` to reduce the number of places where we need to consult if `ScopedTypeVariables` is on. This is purely refactoring, and there should be no user-visible change in behavior. - - - - - 6f6d72b2 by Brian Foley at 2020-05-08T15:29:25-04:00 Remove further dead code found by a simple Python script. Avoid removing some functions that are part of an API even though they're not used in-tree at the moment. - - - - - 78bf8bf9 by Julien Debon at 2020-05-08T15:29:28-04:00 Add doc examples for Bifoldable See #17929 - - - - - 66f0a847 by Julien Debon at 2020-05-08T15:29:29-04:00 doc (Bitraversable): Add examples to Bitraversable * Add examples to Data.Bitraversable * Fix formatting for (,) in Bitraversable and Bifoldable * Fix mistake on bimapAccumR documentation See #17929 - - - - - 9749fe12 by Baldur Blöndal at 2020-05-08T15:29:32-04:00 Specify kind variables for inferred kinds in base. - - - - - 4e9aef9e by John Ericson at 2020-05-08T15:29:36-04:00 HsSigWcTypeScoping: Pull in documentation from stray location - - - - - f4d5c6df by John Ericson at 2020-05-08T15:29:36-04:00 Rename local `real_fvs` to `implicit_vs` It doesn't make sense to call the "free" variables we are about to implicitly bind the real ones. - - - - - 20570b4b by John Ericson at 2020-05-08T15:29:36-04:00 A few tiny style nits with renaming - Use case rather than guards that repeatedly scrutenize same thing. - No need for view pattern when `L` is fine. - Use type synnonym to convey the intent like elsewhere. - - - - - 09ac8de5 by John Ericson at 2020-05-08T15:29:36-04:00 Add `forAllOrNothing` function with note - - - - - bb35c0e5 by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Document lawlessness of Ap's Num instance - - - - - cdd229ff by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply suggestion to libraries/base/Data/Monoid.hs - - - - - 926d2aab by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply more suggestions from Simon Jakobi - - - - - 7a763cff by Adam Gundry at 2020-05-08T15:29:41-04:00 Reject all duplicate declarations involving DuplicateRecordFields (fixes #17965) This fixes a bug that resulted in some programs being accepted that used the same identifier as a field label and another declaration, depending on the order they appeared in the source code. - - - - - 88e3c815 by Simon Peyton Jones at 2020-05-08T15:29:41-04:00 Fix specialisation for DFuns When specialising a DFun we must take care to saturate the unfolding. See Note [Specialising DFuns] in Specialise. Fixes #18120 - - - - - 86c77b36 by Greg Steuck at 2020-05-08T15:29:45-04:00 Remove unused SEGMENT_PROT_RWX It's been unused for a year and is problematic on any OS which requires W^X for security. - - - - - 9d97f4b5 by nineonine at 2020-05-08T15:30:03-04:00 Add test for #16167 - - - - - aa318338 by Ryan Scott at 2020-05-08T15:30:04-04:00 Bump exceptions submodule so that dist-boot is .gitignore'd `exceptions` is a stage-0 boot library as of commit 30272412fa437ab8e7a8035db94a278e10513413, which means that building `exceptions` in a GHC tree will generate a `dist-boot` directory. However, this directory was not specified in `exceptions`' `.gitignore` file, which causes it to dirty up the current `git` working directory. Accordingly, this bumps the `exceptions` submodule to commit ghc/packages/exceptions at 23c0b8a50d7592af37ca09beeec16b93080df98f, which adds `dist-boot` to the `.gitignore` file. - - - - - ea86360f by Ömer Sinan Ağacan at 2020-05-08T15:30:30-04:00 Linker.c: initialize n_symbols of ObjectCode with other fields - - - - - 951c1fb0 by Sylvain Henry at 2020-05-09T21:46:38-04:00 Fix unboxed-sums GC ptr-slot rubbish value (#17791) This patch allows boot libraries to use unboxed sums without implicitly depending on `base` package because of `absentSumFieldError`. See updated Note [aBSENT_SUM_FIELD_ERROR_ID] in GHC.Core.Make - - - - - b352d63c by Ben Gamari at 2020-05-09T21:47:14-04:00 rts: Make non-existent linker search path merely a warning As noted in #18105, previously this resulted in a rather intrusive error message. This is in contrast to the general expectation that search paths are merely places to look, not places that must exist. Fixes #18105. - - - - - cf4f1e2f by Ben Gamari at 2020-05-13T02:02:33-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 - - - - - a03da9bf by Ömer Sinan Ağacan at 2020-05-13T02:03:16-04:00 Pack some of IdInfo fields into a bit field This reduces residency of compiler quite a bit on some programs. Example stats when building T10370: Before: 2,871,242,832 bytes allocated in the heap 4,693,328,008 bytes copied during GC 33,941,448 bytes maximum residency (276 sample(s)) 375,976 bytes maximum slop 83 MiB total memory in use (0 MB lost due to fragmentation) After: 2,858,897,344 bytes allocated in the heap 4,629,255,440 bytes copied during GC 32,616,624 bytes maximum residency (278 sample(s)) 314,400 bytes maximum slop 80 MiB total memory in use (0 MB lost due to fragmentation) So -3.9% residency, -1.3% bytes copied and -0.4% allocations. Fixes #17497 Metric Decrease: T9233 T9675 - - - - - 670c3e5c by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Fix base URL Revert a change previously made for testing purposes. - - - - - 8ad8dc41 by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Improve diagnostics output - - - - - 8c0740b7 by Simon Jakobi at 2020-05-13T02:04:33-04:00 docs: Add examples for Data.Semigroup.Arg{Min,Max} Context: #17153 - - - - - cb22348f by Ben Gamari at 2020-05-13T02:05:11-04:00 Add few cleanups of the CAF logic Give the NameSet of non-CAFfy names a proper newtype to distinguish it from all of the other NameSets floating about. - - - - - 90e38b81 by Emeka Nkurumeh at 2020-05-13T02:05:51-04:00 fix printf warning when using with ghc with clang on mingw - - - - - 86d8ac22 by Sebastian Graf at 2020-05-13T02:06:29-04:00 CprAnal: Don't attach CPR sigs to expandable bindings (#18154) Instead, look through expandable unfoldings in `cprTransform`. See the new Note [CPR for expandable unfoldings]: ``` Long static data structures (whether top-level or not) like xs = x1 : xs1 xs1 = x2 : xs2 xs2 = x3 : xs3 should not get CPR signatures, because they * Never get WW'd, so their CPR signature should be irrelevant after analysis (in fact the signature might even be harmful for that reason) * Would need to be inlined/expanded to see their constructed product * Recording CPR on them blows up interface file sizes and is redundant with their unfolding. In case of Nested CPR, this blow-up can be quadratic! But we can't just stop giving DataCon application bindings the CPR property, for example fac 0 = 1 fac n = n * fac (n-1) fac certainly has the CPR property and should be WW'd! But FloatOut will transform the first clause to lvl = 1 fac 0 = lvl If lvl doesn't have the CPR property, fac won't either. But lvl doesn't have a CPR signature to extrapolate into a CPR transformer ('cprTransform'). So instead we keep on cprAnal'ing through *expandable* unfoldings for these arity 0 bindings via 'cprExpandUnfolding_maybe'. In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one for each data declaration. It's wasteful to attach CPR signatures to each of them (and intractable in case of Nested CPR). ``` Fixes #18154. - - - - - e34bf656 by Ben Gamari at 2020-05-13T02:07:08-04:00 users-guide: Add discussion of shared object naming Fixes #18074. - - - - - 5d0f2445 by Ben Gamari at 2020-05-13T02:07:47-04:00 testsuite: Print sign of performance changes Executes the minor formatting change in the tabulated performance changes suggested in #18135. - - - - - 9e4b981f by Ben Gamari at 2020-05-13T02:08:24-04:00 testsuite: Add testcase for #18129 - - - - - 266310c3 by Ivan-Yudin at 2020-05-13T02:09:03-04:00 doc: Reformulate the opening paragraph of Ch. 4 in User's guide Removes mentioning of Hugs (it is not helpful for new users anymore). Changes the wording for the rest of the paragraph. Fixes #18132. - - - - - 55e35c0b by Baldur Blöndal at 2020-05-13T20:02:48-04:00 Predicate, Equivalence derive via `.. -> a -> All' - - - - - d7e0b57f by Alp Mestanogullari at 2020-05-13T20:03:30-04:00 hadrian: add a --freeze2 option to freeze stage 1 and 2 - - - - - d880d6b2 by Artem Pelenitsyn at 2020-05-13T20:04:11-04:00 Don't reload environment files on every setSessionDynFlags Makes `interpretPackageEnv` (which loads envirinment files) a part of `parseDynamicFlags` (parsing command-line arguments, which is typically done once) instead of `setSessionDynFlags` (which is typically called several times). Making several (transitive) calls to `interpretPackageEnv`, as before, caused #18125 #16318, which should be fixed now. - - - - - 102cfd67 by Ryan Scott at 2020-05-13T20:04:46-04:00 Factor out HsPatSigType for pat sigs/RULE term sigs (#16762) This implements chunks (2) and (3) of https://gitlab.haskell.org/ghc/ghc/issues/16762#note_270170. Namely, it introduces a dedicated `HsPatSigType` AST type, which represents the types that can appear in pattern signatures and term-level `RULE` binders. Previously, these were represented with `LHsSigWcType`. Although `LHsSigWcType` is isomorphic to `HsPatSigType`, the intended semantics of the two types are slightly different, as evidenced by the fact that they have different code paths in the renamer and typechecker. See also the new `Note [Pattern signature binders and scoping]` in `GHC.Hs.Types`. - - - - - b17574f7 by Hécate at 2020-05-13T20:05:28-04:00 fix(documentation): Fix the RST links to GHC.Prim - - - - - df021fb1 by Baldur Blöndal at 2020-05-13T20:06:06-04:00 Document (->) using inferred quantification for its runtime representations. Fixes #18142. - - - - - 1a93ea57 by Takenobu Tani at 2020-05-13T20:06:54-04:00 Tweak man page for ghc command This commit updates the ghc command's man page as followings: * Enable `man_show_urls` to show URL addresses in the `DESCRIPTION` section of ghc.rst, because sphinx currently removes hyperlinks for man pages. * Add a `SEE ALSO` section to point to the GHC homepage - - - - - a951e1ba by Takenobu Tani at 2020-05-13T20:07:37-04:00 GHCi: Add link to the user's guide in help message This commit adds a link to the user's guide in ghci's `:help` message. Newcomers could easily reach to details of ghci. - - - - - 404581ea by Jeff Happily at 2020-05-13T20:08:15-04:00 Handle single unused import - - - - - 1c999e5d by Ben Gamari at 2020-05-13T20:09:07-04:00 Ensure that printMinimalImports closes handle Fixes #18166. - - - - - c9f5a8f4 by Ben Gamari at 2020-05-13T20:09:51-04:00 hadrian: Tell testsuite driver about LLVM availability This reflects the logic present in the Make build system into Hadrian. Fixes #18167. - - - - - c05c0659 by Simon Jakobi at 2020-05-14T03:31:21-04:00 Improve some folds over Uniq[D]FM * Replace some non-deterministic lazy folds with strict folds. * Replace some O(n log n) folds in deterministic order with O(n) non-deterministic folds. * Replace some folds with set-operations on the underlying IntMaps. This reduces max residency when compiling `nofib/spectral/simple/Main.hs` with -O0 by about 1%. Maximum residency when compiling Cabal also seems reduced on the order of 3-9%. - - - - - 477f13bb by Simon Jakobi at 2020-05-14T03:31:58-04:00 Use Data.IntMap.disjoint Data.IntMap gained a dedicated `disjoint` function in containers-0.6.2.1. This patch applies this function where appropriate in hopes of modest compiler performance improvements. Closes #16806. - - - - - e9c0110c by Ben Gamari at 2020-05-14T12:25:53-04:00 IdInfo: Add reference to bitfield-packing ticket - - - - - 9bd20e83 by Sebastian Graf at 2020-05-15T10:42:09-04:00 DmdAnal: Improve handling of precise exceptions This patch does two things: Fix possible unsoundness in what was called the "IO hack" and implement part 2.1 of the "fixing precise exceptions" plan in https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions, which, in combination with !2956, supersedes !3014 and !2525. **IO hack** The "IO hack" (which is a fallback to preserve precise exceptions semantics and thus soundness, rather than some smart thing that increases precision) is called `exprMayThrowPreciseException` now. I came up with two testcases exemplifying possible unsoundness (if twisted enough) in the old approach: - `T13380d`: Demonstrating unsoundness of the "IO hack" when resorting to manual state token threading and direct use of primops. More details below. - `T13380e`: Demonstrating unsoundness of the "IO hack" when we have Nested CPR. Not currently relevant, as we don't have Nested CPR yet. - `T13380f`: Demonstrating unsoundness of the "IO hack" for safe FFI calls. Basically, the IO hack assumed that precise exceptions can only be thrown from a case scrutinee of type `(# State# RealWorld, _ #)`. I couldn't come up with a program using the `IO` abstraction that violates this assumption. But it's easy to do so via manual state token threading and direct use of primops, see `T13380d`. Also similar code might be generated by Nested CPR in the (hopefully not too) distant future, see `T13380e`. Hence, we now have a more careful test in `forcesRealWorld` that passes `T13380{d,e}` (and will hopefully be robust to Nested CPR). **Precise exceptions** In #13380 and #17676 we saw that we didn't preserve precise exception semantics in demand analysis. We fixed that with minimal changes in !2956, but that was terribly unprincipled. That unprincipledness resulted in a loss of precision, which is tracked by these new test cases: - `T13380b`: Regression in dead code elimination, because !2956 was too syntactic about `raiseIO#` - `T13380c`: No need to apply the "IO hack" when the IO action may not throw a precise exception (and the existing IO hack doesn't detect that) Fixing both issues in !3014 turned out to be too complicated and had the potential to regress in the future. Hence we decided to only fix `T13380b` and augment the `Divergence` lattice with a new middle-layer element, `ExnOrDiv`, which means either `Diverges` (, throws an imprecise exception) or throws a *precise* exception. See the wiki page on Step 2.1 for more implementational details: https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions#dead-code-elimination-for-raiseio-with-isdeadenddiv-introducing-exnordiv-step-21 - - - - - 568d7279 by Ben Gamari at 2020-05-15T10:42:46-04:00 GHC.Cmm.Opt: Handle MO_XX_Conv This MachOp was introduced by 2c959a1894311e59cd2fd469c1967491c1e488f3 but a wildcard match in cmmMachOpFoldM hid the fact that it wasn't handled. Ideally we would eliminate the match but this appears to be a larger task. Fixes #18141. - - - - - 5bcf8606 by Ryan Scott at 2020-05-17T08:46:38-04:00 Remove duplicate Note [When to print foralls] in GHC.Core.TyCo.Ppr There are two different Notes named `[When to print foralls]`. The most up-to-date one is in `GHC.Iface.Type`, but there is a second one in `GHC.Core.TyCo.Ppr`. The latter is less up-to-date, as it was written before GHC switched over to using ifaces to pretty-print types. I decided to just remove the latter and replace it with a reference to the former. [ci skip] - - - - - 55f0e783 by Fumiaki Kinoshita at 2020-05-21T12:10:44-04:00 base: Add Generic instances to various datatypes under GHC.* * GHC.Fingerprint.Types: Fingerprint * GHC.RTS.Flags: GiveGCStats, GCFlags, ConcFlags, DebugFlags, CCFlags, DoHeapProfile, ProfFlags, DoTrace, TraceFlags, TickyFlags, ParFlags and RTSFlags * GHC.Stats: RTSStats and GCStats * GHC.ByteOrder: ByteOrder * GHC.Unicode: GeneralCategory * GHC.Stack.Types: SrcLoc Metric Increase: haddock.base - - - - - a9311cd5 by Gert-Jan Bottu at 2020-05-21T12:11:31-04:00 Explicit Specificity Implementation for Ticket #16393. Explicit specificity allows users to manually create inferred type variables, by marking them with braces. This way, the user determines which variables can be instantiated through visible type application. The additional syntax is included in the parser, allowing users to write braces in type variable binders (type signatures, data constructors etc). This information is passed along through the renamer and verified in the type checker. The AST for type variable binders, data constructors, pattern synonyms, partial signatures and Template Haskell has been updated to include the specificity of type variables. Minor notes: - Bumps haddock submodule - Disables pattern match checking in GHC.Iface.Type with GHC 8.8 - - - - - 24e61aad by Ben Price at 2020-05-21T12:12:17-04:00 Lint should say when it is checking a rule It is rather confusing that when lint finds an error in a rule attached to a binder, it reports the error as in the RHS, not the rule: ... In the RHS of foo We add a clarifying line: ... In the RHS of foo In a rule attached to foo The implication that the rule lives inside the RHS is a bit odd, but this niggle is already present for unfoldings, whose pattern we are following. - - - - - 78c6523c by Ben Gamari at 2020-05-21T12:13:01-04:00 nonmoving: Optimise the write barrier - - - - - 13f6c9d0 by Andreas Klebinger at 2020-05-21T12:13:45-04:00 Refactor linear reg alloc to remember past assignments. When assigning registers we now first try registers we assigned to in the past, instead of picking the "first" one. This is in extremely helpful when dealing with loops for which variables are dead for part of the loop. This is important for patterns like this: foo = arg1 loop: use(foo) ... foo = getVal() goto loop; There we: * assign foo to the register of arg1. * use foo, it's dead after this use as it's overwritten after. * do other things. * look for a register to put foo in. If we pick an arbitrary one it might differ from the register the start of the loop expect's foo to be in. To fix this we simply look for past register assignments for the given variable. If we find one and the register is free we use that register. This reduces the need for fixup blocks which match the register assignment between blocks. In the example above between the end and the head of the loop. This patch also moves branch weight estimation ahead of register allocation and adds a flag to control it (cmm-static-pred). * It means the linear allocator is more likely to assign the hotter code paths first. * If it assign these first we are: + Less likely to spill on the hot path. + Less likely to introduce fixup blocks on the hot path. These two measure combined are surprisingly effective. Based on nofib we get in the mean: * -0.9% instructions executed * -0.1% reads/writes * -0.2% code size. * -0.1% compiler allocations. * -0.9% compile time. * -0.8% runtime. Most of the benefits are simply a result of removing redundant moves and spills. Reduced compiler allocations likely are the result of less code being generated. (The added lookup is mostly non-allocating). - - - - - edc2cc58 by Andreas Klebinger at 2020-05-21T12:14:25-04:00 NCG: Codelayout: Distinguish conditional and other branches. In #18053 we ended up with a suboptimal code layout because the code layout algorithm didn't distinguish between conditional and unconditional control flow. We can completely eliminate unconditional control flow instructions by placing blocks next to each other, not so much for conditionals. In terms of implementation we simply give conditional branches less weight before computing the layout. Fixes #18053 - - - - - b7a6b2f4 by Gleb Popov at 2020-05-21T12:15:26-04:00 gitlab-ci: Set locale to C.UTF-8. - - - - - a8c27cf6 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow spaces in GHCi :script file names This patch updates the user interface of GHCi so that file names passed to the ':script' command may contain spaces escaped with a backslash. For example: :script foo\ bar.script The implementation uses a modified version of 'words' that does not break on escaped spaces. Fixes #18027. - - - - - 82663959 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Add extra tests for GHCi :script syntax checks The syntax for GHCi's ":script" command allows for only a single file name to be passed as an argument. This patch adds a test for the cases in which a file name is missing or multiple file names are passed. Related to #T18027. - - - - - a0b79e1b by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow GHCi :script file names in double quotes This patch updates the user interface of GHCi so that file names passed to the ':script' command can be wrapped in double quotes. For example: :script "foo bar.script" The implementation uses a modified version of 'words' that treats character sequences enclosed in double quotes as single words. Fixes #18027. - - - - - cf566330 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Update documentation for GHCi :script This patch adds the fixes that allow for file names containing spaces to be passed to GHCi's ':script' command to the release notes for 8.12 and expands the user-guide documentation for ':script' by mentioning how such file names can be passed. Related to #18027. - - - - - 0004ccb8 by Tuan Le at 2020-05-21T12:16:46-04:00 llvmGen: Consider Relocatable read-only data as not constantReferences: #18137 - - - - - 964d3ea2 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_pat` - - - - - b797aa42 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_lpat` and `tc_lpats` - - - - - 5108e84a by John Ericson at 2020-05-21T12:17:30-04:00 More judiciously panic in `ts_pat` - - - - - 510e0451 by John Ericson at 2020-05-21T12:17:30-04:00 Put `PatEnv` first in `GHC.Tc.Gen.Pat.Checker` - - - - - cb4231db by John Ericson at 2020-05-21T12:17:30-04:00 Tiny cleaup eta-reduce away a function argument In GHC, not in the code being compiled! - - - - - 6890c38d by John Ericson at 2020-05-21T12:17:30-04:00 Use braces with do in `SplicePat` case for consistency - - - - - 3451584f by buggymcbugfix at 2020-05-21T12:18:06-04:00 Fix spelling mistakes and typos - - - - - b552e531 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Add INLINABLE pragmas to Enum list producers The INLINABLE pragmas ensure that we export stable (unoptimised) unfoldings in the interface file so we can do list fusion at usage sites. Related tickets: #15185, #8763, #18178. - - - - - e7480063 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Piggyback on Enum Word methods for Word64 If we are on a 64 bit platform, we can use the efficient Enum Word methods for the Enum Word64 instance. - - - - - 892b0c41 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Document INLINE(ABLE) pragmas that enable fusion - - - - - 2b363ebb by Richard Eisenberg at 2020-05-21T12:18:45-04:00 MR template should ask for key part - - - - - a95bbd0b by Sebastian Graf at 2020-05-21T12:19:37-04:00 Make `Int`'s `mod` and `rem` strict in their first arguments They used to be strict until 4d2ac2d (9 years ago). It's obviously better to be strict for performance reasons. It also blocks #18067. NoFib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- integer -1.1% +0.4% wheel-sieve2 +21.2% +20.7% -------------------------------------------------------------------------------- Min -1.1% -0.0% Max +21.2% +20.7% Geometric Mean +0.2% +0.2% ``` The regression in `wheel-sieve2` is due to reboxing that likely will go away with the resolution of #18067. See !3282 for details. Fixes #18187. - - - - - d3d055b8 by Galen Huntington at 2020-05-21T12:20:18-04:00 Clarify pitfalls of NegativeLiterals; see #18022. - - - - - 1b508a9e by Alexey Kuleshevich at 2020-05-21T12:21:02-04:00 Fix wording in primops documentation to reflect the correct reasoning: * Besides resizing functions, shrinking ones also mutate the size of a mutable array and because of those two `sizeofMutabeByteArray` and `sizeofSmallMutableArray` are now deprecated * Change reference in documentation to the newer functions `getSizeof*` instead of `sizeof*` for shrinking functions * Fix incorrect mention of "byte" instead of "small" - - - - - 4ca0c8a1 by Andreas Klebinger at 2020-05-21T12:21:53-04:00 Don't variable-length encode magic iface constant. We changed to use variable length encodings for many types by default, including Word32. This makes sense for numbers but not when Word32 is meant to represent four bytes. I added a FixedLengthEncoding newtype to Binary who's instances interpret their argument as a collection of bytes instead of a number. We then use this when writing/reading magic numbers to the iface file. I also took the libery to remove the dummy iface field. This fixes #18180. - - - - - a1275081 by Krzysztof Gogolewski at 2020-05-21T12:22:35-04:00 Add a regression test for #11506 The testcase works now. See explanation in https://gitlab.haskell.org/ghc/ghc/issues/11506#note_273202 - - - - - 8a816e5f by Krzysztof Gogolewski at 2020-05-21T12:23:55-04:00 Sort deterministically metric output Previously, we sorted according to the test name and way, but the metrics (max_bytes_used/peak_megabytes_allocated etc.) were appearing in nondeterministic order. - - - - - 566cc73f by Sylvain Henry at 2020-05-21T12:24:45-04:00 Move isDynLinkName into GHC.Types.Name It doesn't belong into GHC.Unit.State - - - - - d830bbc9 by Adam Sandberg Ericsson at 2020-05-23T13:36:20-04:00 docs: fix formatting and add some links [skip ci] - - - - - 49301ad6 by Andrew Martin at 2020-05-23T13:37:01-04:00 Implement cstringLength# and FinalPtr This function and its accompanying rule resolve issue #5218. A future PR to the bytestring library will make the internal Data.ByteString.Internal.unsafePackAddress compute string length with cstringLength#. This will improve the status quo because it is eligible for constant folding. Additionally, introduce a new data constructor to ForeignPtrContents named FinalPtr. This additional data constructor, when used in the IsString instance for ByteString, leads to more Core-to-Core optimization opportunities, fewer runtime allocations, and smaller binaries. Also, this commit re-exports all the functions from GHC.CString (including cstringLength#) in GHC.Exts. It also adds a new test driver. This test driver is used to perform substring matches on Core that is dumped after all the simplifier passes. In this commit, it is used to check that constant folding of cstringLength# works. - - - - - dcd6bdcc by Ben Gamari at 2020-05-23T13:37:48-04:00 simplCore: Ignore ticks in rule templates This fixes #17619, where a tick snuck in to the template of a rule, resulting in a panic during rule matching. The tick in question was introduced via post-inlining, as discussed in `Note [Simplifying rules]`. The solution we decided upon was to simply ignore ticks in the rule template, as discussed in `Note [Tick annotations in RULE matching]`. Fixes #18162. Fixes #17619. - - - - - 82cb8913 by John Ericson at 2020-05-23T13:38:32-04:00 Fix #18145 and also avoid needless work with implicit vars - `forAllOrNothing` now is monadic, so we can trace whether we bind an explicit `forall` or not. - #18145 arose because the free vars calculation was needlessly complex. It is now greatly simplified. - Replaced some other implicit var code with `filterFreeVarsToBind`. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - a60dc835 by Ben Gamari at 2020-05-23T13:39:12-04:00 Bump process submodule Fixes #17926. - - - - - 856adf54 by Ben Gamari at 2020-05-23T13:40:21-04:00 users-guide: Clarify meaning of -haddock flag Fixes #18206. - - - - - 7ae57afd by Ben Gamari at 2020-05-23T13:41:03-04:00 git: Add ignored commits file This can be used to tell git to ignore bulk renaming commits like the recently-finished module hierarchy refactoring. Configured with, git config blame.ignoreRevsFile .git-ignore-revs - - - - - 63d30e60 by jneira at 2020-05-24T01:54:42-04:00 Add hie-bios script for windows systems It is a direct translation of the sh script - - - - - 59182b88 by jneira at 2020-05-24T01:54:42-04:00 Honour previous values for CABAL and CABFLAGS The immediate goal is let the hie-bios.bat script set CABFLAGS with `-v0` and remove all cabal output except the compiler arguments - - - - - 932dc54e by jneira at 2020-05-24T01:54:42-04:00 Add specific configuration for windows in hie.yaml - - - - - e0eda070 by jneira at 2020-05-24T01:54:42-04:00 Remove not needed hie-bios output - - - - - a0ea59d6 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Move Config module into GHC.Settings - - - - - 37430251 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Core.Arity into GHC.Core.Opt.Arity - - - - - a426abb9 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Hs.Types into GHC.Hs.Type See discussion in https://gitlab.haskell.org/ghc/ghc/issues/13009#note_268610 - - - - - 1c91a7a0 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Bump haddock submodule - - - - - 66bd24d1 by Ryan Scott at 2020-05-24T01:56:03-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. - - - - - 01c43634 by Matthew Pickering at 2020-05-24T01:56:42-04:00 Remove unused hs-boot file - - - - - 7a07aa71 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix cross-compiler build (#16051) - - - - - 15ccca16 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix distDir per stage - - - - - b420fb24 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix hp2ps error during cross-compilation Fixed by @alp (see https://gitlab.haskell.org/ghc/ghc/issues/16051#note_274265) - - - - - cd339ef0 by Joshua Price at 2020-05-24T15:22:56-04:00 Make Unicode brackets opening/closing tokens (#18225) The tokens `[|`, `|]`, `(|`, and `|)` are opening/closing tokens as described in GHC Proposal #229. This commit makes the unicode variants (`⟦`, `⟧`, `⦇`, and `⦈`) act the same as their ASCII counterparts. - - - - - 013d7120 by Ben Gamari at 2020-05-25T09:48:17-04:00 Revert "Specify kind variables for inferred kinds in base." As noted in !3132, this has rather severe knock-on consequences in user-code. We'll need to revisit this before merging something along these lines. This reverts commit 9749fe1223d182b1f8e7e4f7378df661c509f396. - - - - - 4c4312ed by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Drop redundant ad-hoc boot module check To determine whether the module is a boot module Coverage.addTicksToBinds was checking for a `boot` suffix in the module source filename. This is quite ad-hoc and shouldn't be necessary; the callsite in `deSugar` already checks that the module isn't a boot module. - - - - - 1abf3c84 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make tickBoxCount strict This could otherwise easily cause a leak of (+) thunks. - - - - - b2813750 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make ccIndices strict This just seems like a good idea. - - - - - 02e278eb by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Don't produce ModBreaks if not HscInterpreted emptyModBreaks contains a bottom and consequently it's important that we don't use it unless necessary. - - - - - b8c014ce by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Factor out addMixEntry - - - - - 53814a64 by Zubin Duggal at 2020-05-26T03:03:24-04:00 Add info about typeclass evidence to .hie files See `testsuite/tests/hiefile/should_run/HieQueries.hs` and `testsuite/tests/hiefile/should_run/HieQueries.stdout` for an example of this We add two new fields, `EvidenceVarBind` and `EvidenceVarUse` to the `ContextInfo` associated with an Identifier. These are associated with the appropriate identifiers for the evidence variables collected when we come across `HsWrappers`, `TcEvBinds` and `IPBinds` while traversing the AST. Instance dictionary and superclass selector dictionaries from `tcg_insts` and classes defined in `tcg_tcs` are also recorded in the AST as originating from their definition span This allows us to save a complete picture of the evidence constructed by the constraint solver, and will let us report this to the user, enabling features like going to the instance definition from the invocation of a class method(or any other method taking a constraint) and finding all usages of a particular instance. Additionally, - Mark NodeInfo with an origin so we can differentiate between bindings origininating in the source vs those in ghc - Along with typeclass evidence info, also include information on Implicit Parameters - Add a few utility functions to HieUtils in order to query the new info Updates haddock submodule - - - - - 6604906c by Sebastian Graf at 2020-05-26T03:04:04-04:00 Make WorkWrap.Lib.isWorkerSmallEnough aware of the old arity We should allow a wrapper with up to 82 parameters when the original function had 82 parameters to begin with. I verified that this made no difference on NoFib, but then again it doesn't use huge records... Fixes #18122. - - - - - cf772f19 by Sylvain Henry at 2020-05-26T03:04:45-04:00 Enhance Note [About units] for Backpack - - - - - ede24126 by Takenobu Tani at 2020-05-27T00:13:55-04:00 core-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Core.hs <= coreSyn/CoreSyn.hs * GHC/Core/Coercion.hs <= types/Coercion.hs * GHC/Core/Coercion/Axiom.hs <= types/CoAxiom.hs * GHC/Core/Coercion/Opt.hs <= types/OptCoercion.hs * GHC/Core/DataCon.hs <= basicTypes/DataCon.hs * GHC/Core/FamInstEnv.hs <= types/FamInstEnv.hs * GHC/Core/Lint.hs <= coreSyn/CoreLint.hs * GHC/Core/Subst.hs <= coreSyn/CoreSubst.hs * GHC/Core/TyCo/Rep.hs <= types/TyCoRep.hs * GHC/Core/TyCon.hs <= types/TyCon.hs * GHC/Core/Type.hs <= types/Type.hs * GHC/Core/Unify.hs <= types/Unify.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/Var.hs <= basicTypes/Var.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [skip ci] - - - - - 04750304 by Ben Gamari at 2020-05-27T00:14:33-04:00 eventlog: Fix racy flushing Previously no attempt was made to avoid multiple threads writing their capability-local eventlog buffers to the eventlog writer simultaneously. This could result in multiple eventlog streams being interleaved. Fix this by documenting that the EventLogWriter's write() and flush() functions may be called reentrantly and fix the default writer to protect its FILE* by a mutex. Fixes #18210. - - - - - d6203f24 by Joshua Price at 2020-05-27T00:15:17-04:00 Make `identifier` parse unparenthesized `->` (#18060) - - - - - 28deee28 by Ben Gamari at 2020-05-28T16:23:21-04:00 GHC.Core.Unfold: Refactor traceInline This reduces duplication as well as fixes a bug wherein -dinlining-check would override -ddump-inlinings. Moreover, the new variant - - - - - 1f393e1e by Ben Gamari at 2020-05-28T16:23:21-04:00 Avoid unnecessary allocations due to tracing utilities While ticky-profiling the typechecker I noticed that hundreds of millions of SDocs are being allocated just in case -ddump-*-trace is enabled. This is awful. We avoid this by ensuring that the dump flag check is inlined into the call site, ensuring that the tracing document needn't be allocated unless it's actually needed. See Note [INLINE conditional tracing utilities] for details. Fixes #18168. Metric Decrease: T9961 haddock.Cabal haddock.base haddock.compiler - - - - - 5f621a78 by Vladislav Zavialov at 2020-05-28T16:23:58-04:00 Add Semigroup/Monoid for Q (#18123) - - - - - dc5f004c by Xavier Denis at 2020-05-28T16:24:37-04:00 Fix #18071 Run the core linter on candidate instances to ensure they are well-kinded. Better handle quantified constraints by using a CtWanted to avoid having unsolved constraints thrown away at the end by the solver. - - - - - 10e6982c by Sebastian Graf at 2020-05-28T16:25:14-04:00 FloatOut: Only eta-expand dead-end RHS if arity will increase (#18231) Otherwise we risk turning trivial RHS into non-trivial RHS, introducing unnecessary bindings in the next Simplifier run, resulting in more churn. Fixes #18231. - - - - - 08dab5f7 by Sebastian Graf at 2020-05-28T16:25:14-04:00 DmdAnal: Recognise precise exceptions from case alternatives (#18086) Consider ```hs m :: IO () m = do putStrLn "foo" error "bar" ``` `m` (from #18086) always throws a (precise or imprecise) exception or diverges. Yet demand analysis infers `<L,A>` as demand signature instead of `<L,A>x` for it. That's because the demand analyser sees `putStrLn` occuring in a case scrutinee and decides that it has to `deferAfterPreciseException`, because `putStrLn` throws a precise exception on some control flow paths. This will mask the `botDiv` `Divergence`of the single case alt containing `error` to `topDiv`. Since `putStrLn` has `topDiv` itself, the final `Divergence` is `topDiv`. This is easily fixed: `deferAfterPreciseException` works by `lub`ing with the demand type of a virtual case branch denoting the precise exceptional control flow. We used `nopDmdType` before, but we can be more precise and use `exnDmdType`, which is `nopDmdType` with `exnDiv`. Now the `Divergence` from the case alt will degrade `botDiv` to `exnDiv` instead of `topDiv`, which combines with the result from the scrutinee to `exnDiv`, and all is well. Fixes #18086. - - - - - aef95f11 by Ben Gamari at 2020-05-28T16:25:53-04:00 Ticky-ticky: Record DataCon name in ticker name This makes it significantly easier to spot the nature of allocations regressions and comes at a reasonably low cost. - - - - - 8f021b8c by Ben Gamari at 2020-05-28T16:26:34-04:00 hadrian: Don't track GHC's verbosity argument Teach hadrian to ignore GHC's -v argument in its recompilation check, thus fixing #18131. - - - - - 13d9380b by Ben Gamari at 2020-05-28T16:27:20-04:00 Rip out CmmStackInfo(updfr_space) As noted in #18232, this field is currently completely unused and moreover doesn't have a clear meaning. - - - - - f10d11fa by Andreas Klebinger at 2020-05-29T01:38:42-04:00 Fix "build/elem" RULE. An redundant constraint prevented the rule from matching. Fixing this allows a call to elem on a known list to be translated into a series of equality checks, and eventually a simple case expression. Surprisingly this seems to regress elem for strings. To avoid this we now also allow foldrCString to inline and add an UTF8 variant. This results in elem being compiled to a tight non-allocating loop over the primitive string literal which performs a linear search. In the process this commit adds UTF8 variants for some of the functions in GHC.CString. This is required to make this work for both ASCII and UTF8 strings. There are also small tweaks to the CString related rules. We now allow ourselfes the luxury to compare the folding function via eqExpr, which helps to ensure the rule fires before we inline foldrCString*. Together with a few changes to allow matching on both the UTF8 and ASCII variants of the CString functions. - - - - - bbeb2389 by Ben Gamari at 2020-05-29T01:39:19-04:00 CoreToStg: Add Outputable ArgInfo instance - - - - - 0e3361ca by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Make Lint check return type of a join point Consider join x = rhs in body It's important that the type of 'rhs' is the same as the type of 'body', but Lint wasn't checking that invariant. Now it does! This was exposed by investigation into !3113. - - - - - c49f7df0 by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Do not float join points in exprIsConApp_maybe We hvae been making exprIsConApp_maybe cleverer in recent times: commit b78cc64e923716ac0512c299f42d4d0012306c05 Date: Thu Nov 15 17:14:31 2018 +0100 Make constructor wrappers inline only during the final phase commit 7833cf407d1f608bebb1d38bb99d3035d8d735e6 Date: Thu Jan 24 17:58:50 2019 +0100 Look through newtype wrappers (Trac #16254) commit c25b135ff5b9c69a90df0ccf51b04952c2dc6ee1 Date: Thu Feb 21 12:03:22 2019 +0000 Fix exprIsConApp_maybe But alas there was still a bug, now immortalised in Note [Don't float join points] in SimpleOpt. It's quite hard to trigger because it requires a dead join point, but it came up when compiling Cabal Cabal.Distribution.Fields.Lexer.hs, when working on !3113. Happily, the fix is extremly easy. Finding the bug was not so easy. - - - - - 46720997 by Ben Gamari at 2020-05-29T01:39:19-04:00 Allow simplification through runRW# Because runRW# inlines so late, we were previously able to do very little simplification across it. For instance, given even a simple program like case runRW# (\s -> let n = I# 42# in n) of I# n# -> f n# we previously had no way to avoid the allocation of the I#. This patch allows the simplifier to push strict contexts into the continuation of a runRW# application, as explained in in Note [Simplification of runRW#] in GHC.CoreToStg.Prep. Fixes #15127. Metric Increase: T9961 Metric Decrease: ManyConstructors Co-Authored-By: Simon Peyton-Jone <simonpj at microsoft.com> - - - - - 277c2f26 by Ben Gamari at 2020-05-29T01:39:55-04:00 Eta expand un-saturated primops Now since we no longer try to predict CAFfyness we have no need for the solution to #16846. Eta expanding unsaturated primop applications is conceptually simpler, especially in the presence of levity polymorphism. This essentially reverts cac8dc9f51e31e4c0a6cd9bc302f7e1bc7c03beb, as suggested in #18079. Closes #18079. - - - - - f44d7ae0 by Simon Jakobi at 2020-05-29T01:40:34-04:00 base: Scrap deprecation plan for Data.Monoid.{First,Last} See the discussion on the libraries mailing list for context: https://mail.haskell.org/pipermail/libraries/2020-April/030357.html - - - - - 8b494895 by Jeremy Schlatter at 2020-05-29T01:41:12-04:00 Fix typo in documentation - - - - - 998450f4 by Gleb Popov at 2020-05-29T01:41:53-04:00 Always define USE_PTHREAD_FOR_ITIMER for FreeBSD. - - - - - f9a513e0 by Alp Mestanogullari at 2020-05-29T01:42:36-04:00 hadrian: introduce 'install' target Its logic is very simple. It `need`s the `binary-dist-dir` target and runs suitable `configure` and `make install` commands for the user. A new `--prefix` command line argument is introduced to specify where GHC should be installed. - - - - - 67738db1 by Travis Whitaker at 2020-05-29T13:34:48-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. - - - - - aac19e6c by Peter Trommler at 2020-05-29T13:35:24-04:00 PPC NCG: No per-symbol .section ".toc" directives All position independent symbols are collected during code generation and emitted in one go. Prepending each symbol with a .section ".toc" directive is redundant. This patch drops the per-symbol directives leading to smaller assembler files. Fixes #18250 - - - - - 4413828b by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Teach getNumProcessors to return available processors Previously we would report the number of physical processors, which can be quite wrong in a containerized setting. Now we rather return how many processors are in our affinity mask when possible. I also refactored the code to prefer platform-specific since this will report logical CPUs instead of physical (using `machdep.cpu.thread_count` on Darwin and `cpuset_getaffinity` on FreeBSD). Fixes #14781. - - - - - 1449435c by Ben Gamari at 2020-05-30T06:07:31-04:00 users-guide: Note change in getNumProcessors in users guide - - - - - 3d960169 by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Drop compatibility shims for Windows Vista We can now assume that the thread and processor group interfaces are available. - - - - - 7f8f948c by Peter Trommler at 2020-05-30T06:08:07-04:00 PPC NCG: Fix .size directive on powerpc64 ELF v1 Thanks to Sergei Trofimovich for pointing out the issue. Fixes #18237 - - - - - 7c555b05 by Andreas Klebinger at 2020-05-30T06:08:43-04:00 Optimize GHC.Utils.Monad. Many functions in this module are recursive and as such are marked loop breakers. Which means they are unlikely to get an unfolding. This is *bad*. We always want to specialize them to specific Monads. Which requires a visible unfolding at the use site. I rewrote the recursive ones from: foo f x = ... foo x' ... to foo f x = go x where go x = ... As well as giving some pragmas to make all of them available for specialization. The end result is a reduction of allocations of about -1.4% for nofib/spectral/simple/Main.hs when compiled with `-O`. ------------------------- Metric Decrease: T12425 T14683 T5631 T9233 T9675 T9961 WWRec ------------------------- - - - - - 8b1cb5df by Ben Gamari at 2020-05-30T06:09:20-04:00 Windows: Bump Windows toolchain to 0.2 - - - - - 6947231a by Zubin Duggal at 2020-05-30T06:10:02-04:00 Simplify contexts in GHC.Iface.Ext.Ast - - - - - 2ee4f36c by Daniel Gröber at 2020-06-01T06:32:56-04:00 Cleanup OVERWRITING_CLOSURE logic The code is just more confusing than it needs to be. We don't need to mix the threaded check with the ldv profiling check since ldv's init already checks for this. Hence they can be two separate checks. Taking the sanity checking into account is also cleaner via DebugFlags.sanity. No need for checking the DEBUG define. The ZERO_SLOP_FOR_LDV_PROF and ZERO_SLOP_FOR_SANITY_CHECK definitions the old code had also make things a lot more opaque IMO so I removed those. - - - - - 6159559b by Daniel Gröber at 2020-06-01T06:32:56-04:00 Fix OVERWRITING_CLOSURE assuming closures are not inherently used The new ASSERT in LDV_recordDead() was being tripped up by MVars when removeFromMVarBlockedQueue() calls OVERWRITING_CLOSURE() via OVERWRITE_INFO(). - - - - - 38992085 by Daniel Gröber at 2020-06-01T06:32:56-04:00 Always zero shrunk mutable array slop when profiling When shrinking arrays in the profiling way we currently don't always zero the leftover slop. This means we can't traverse such closures in the heap profiler. The old Note [zeroing slop] and #8402 have some rationale for why this is so but I belive the reasoning doesn't apply to mutable closures. There users already have to ensure multiple threads don't step on each other's toes so zeroing should be safe. - - - - - b0c1f2a6 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for #18151 - - - - - 9a99a178 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for desugaring of PostfixOperators - - - - - 2b89ca5b by Ben Gamari at 2020-06-01T06:33:37-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. - - - - - d412d7a3 by Kirill Elagin at 2020-06-01T06:34:21-04:00 Winferred-safe-imports: Do not exit with error Currently, when -Winferred-safe-imports is enabled, even when it is not turned into an error, the compiler will still exit with exit code 1 if this warning was emitted. Make sure it is really treated as a warning. - - - - - f945eea5 by Ben Gamari at 2020-06-01T06:34:58-04:00 nonmoving: Optimise log2_ceil - - - - - aab606e4 by Bodigrim at 2020-06-01T06:35:36-04:00 Clarify description of fromListN - - - - - 7e5220e2 by Bodigrim at 2020-06-01T06:35:36-04:00 Apply suggestion to libraries/base/GHC/Exts.hs - - - - - f3fb1ce9 by fendor at 2020-06-01T06:36:18-04:00 Add `isInScope` check to `lintCoercion` Mirrors the behaviour of `lintType`. - - - - - 5ac4d946 by fendor at 2020-06-01T06:36:18-04:00 Lint rhs of IfaceRule - - - - - 1cef6126 by Jeremy Schlatter at 2020-06-01T06:37:00-04:00 Fix wording in documentation The duplicate "orphan instance" phrase here doesn't make sense, and was probably an accident. - - - - - 5aaf08f2 by Takenobu Tani at 2020-06-01T06:37:43-04:00 configure: Modify aclocal.m4 according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * Rename: * compiler/GHC/Parser.hs <= compiler/parser/Parser.hs * compiler/GHC/Parser/Lexer.hs <= compiler/Parser/Lexer.hs * Add: * compiler/GHC/Cmm/Lexer.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular - - - - - 15857ad8 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Don't fail if we can't unlink __symlink_test Afterall, it's possible we were unable to create it due to lack of symlink permission. - - - - - 4a7229ef by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Refactor ghostscript detection Tamar reported that he saw crashes due to unhandled exceptions. - - - - - 2ab37eaf by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/perf_notes: Fix ill-typed assignments - - - - - e45d5b66 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/testutil: Fix bytes/str mismatch - - - - - 7002d0cb by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Work around spurious mypy failure - - - - - 11390e3a by Takenobu Tani at 2020-06-01T06:39:05-04:00 Clean up file paths for new module hierarchy This updates comments only. This patch replaces file references according to new module hierarchy. See also: * https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular * https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 8f2e5732 by Takenobu Tani at 2020-06-01T06:39:05-04:00 Modify file paths to module paths for new module hierarchy This updates comments only. This patch replaces module references according to new module hierarchy [1][2]. For files under the `compiler/` directory, I replace them as module paths instead of file paths. For instance, `GHC.Unit.State` instead of `compiler/GHC/Unit/State.hs` [3]. For current and future haddock's markup, this patch encloses the module name with "" [4]. [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 [3]: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3375#note_276613 [4]: https://haskell-haddock.readthedocs.io/en/latest/markup.html#linking-to-modules - - - - - 68b71c4a by Tom Ellis at 2020-06-01T06:39:55-04:00 Rename the singleton tuple GHC.Tuple.Unit to GHC.Tuple.Solo - - - - - 95da76c2 by Sylvain Henry at 2020-06-01T06:40:41-04:00 Hadrian: fix binary-dist target for cross-compilation - - - - - 730fcd54 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for the @-operator Since GHC diverges from the Haskell Report by allowing the user to define (@) as an infix operator, we better give a good error message when the user does so unintentionally. In general, this is rather hard to do, as some failures will be discovered only in the renamer or the type checker: x :: (Integer, Integer) x @ (a, b) = (1, 2) This patch does *not* address this general case. However, it gives much better error messages when the binding is not syntactically valid: pairs xs @ (_:xs') = zip xs xs' Before this patch, the error message was rather puzzling: <interactive>:1:1: error: Parse error in pattern: pairs After this patch, the error message includes a hint: <interactive>:1:1: error: Parse error in pattern: pairs In a function binding for the ‘@’ operator. Perhaps you meant an as-pattern, which must not be surrounded by whitespace - - - - - 0fde5377 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TypeApplications With this patch, we always parse f @t as a type application, thereby producing better error messages. This steals two syntactic forms: * Prefix form of the @-operator in expressions. Since the @-operator is a divergence from the Haskell Report anyway, this is not a major loss. * Prefix form of @-patterns. Since we are stealing loose infix form anyway, might as well sacrifice the prefix form for the sake of much better error messages. - - - - - c68e7e1e by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TemplateHaskellQuotes While [e| |], [t| |], [d| |], and so on, steal syntax from list comprehensions, [| |] and [|| ||] do not steal any syntax. Thus we can improve error messages by always accepting them in the lexer. Turns out the renamer already performs necessary validation. - - - - - 120aedbd by Ben Gamari at 2020-06-01T16:07:02-04:00 gitlab-ci: Disable use of ld.lld on ARMv7 It turns out that lld non-deterministically fails on ARMv7. I suspect this may be due to the a kernel regression as this only started happening when we upgraded to 5.4. Nevertheless, easily avoided by simply sticking with gold. Works around #18280. - - - - - d6279ff0 by Ben Gamari at 2020-06-02T13:03:30-04:00 gitlab-ci: Ensure that workaround for #18280 applies to bindisttest We need to ensure that the `configure` flags working around #18280 are propagated to the bindisttest `configure` as well. - - - - - cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00 gitlab-ci: Allow ARMv7 job to fail Due to #18298. - - - - - 32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00 Clean up boot vs non-boot disambiguating types We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule. - - - - - c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00 docs: Add more details on InterruptibleFFI. Details from https://gitlab.haskell.org/ghc/ghc/issues/8684 and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430 - - - - - 1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00 Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr. MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd. This regression did not make it into a release of GHC. Here, the original behavior is restored, and FinalPtr is given the same treatment as PlainPtr. - - - - - 2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00 Fix documentation on type families not being extracted It looks like the location of the Names used for CoAxioms on type families are now located at their type constructors. Previously, Docs.hs thought the Names were located in the RHS, so the RealSrcSpan in the instanceMap and getInstLoc didn't match up. Fixes #18241 - - - - - 6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00 GHC.Hs.Instances: Compile with -O0 This module contains exclusively Data instances, which are going to be slow no matter what we do. Furthermore, they are incredibly slow to compile with optimisation (see #9557). Consequently we compile this with -O0. See #18254. - - - - - c330331a by nineonine at 2020-06-04T04:37:59-04:00 Add test for #17669 - - - - - cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00 rts: Add Windows-specific implementation of rtsSleep Previously we would use the POSIX path, which uses `nanosleep`. However, it turns out that `nanosleep` is provided by `libpthread` on Windows. In general we don't want to incur such a dependency. Avoid this by simply using `Sleep` on Windows. Fixes #18272. - - - - - ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00 compiler: Disable use of process jobs with process < 1.6.9 Due to #17926. - - - - - 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - b95d4ff1 by Vladislav Zavialov at 2020-07-24T00:09:25+03:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - 34b390f3 by Vladislav Zavialov at 2020-07-24T00:11:27+03:00 Grammar for types and data/newtype constructors Before this patch, we parsed types into a reversed sequence of operators and operands. For example, (F x y + G a b * X) would be parsed as [X, *, b, a, G, +, y, x, F], using a simple grammar: tyapps : tyapp | tyapps tyapp tyapp : atype | PREFIX_AT atype | tyop | unpackedness Then we used a hand-written state machine to assemble this either into a type, using 'mergeOps', or into a constructor, using 'mergeDataCon'. This is due to a syntactic ambiguity: data T1 a = MkT1 a data T2 a = Ord a => MkT2 a In T1, what follows after the = sign is a data/newtype constructor declaration. However, in T2, what follows is a type (of kind Constraint). We don't know which of the two we are parsing until we encounter =>, and we cannot check for => without unlimited lookahead. This poses a few issues when it comes to e.g. infix operators: data I1 = Int :+ Bool :+ Char -- bad data I2 = Int :+ Bool :+ Char => MkI2 -- fine By this issue alone we are forced into parsing into an intermediate representation and doing a separate validation pass. However, should that intermediate representation be as low-level as a flat sequence of operators and operands? Before GHC Proposal #229, the answer was Yes, due to some particularly nasty corner cases: data T = ! A :+ ! B -- used to be fine, hard to parse data T = ! A :+ ! B => MkT -- bad However, now the answer is No, as this corner case is gone: data T = ! A :+ ! B -- bad data T = ! A :+ ! B => MkT -- bad This means we can write a proper grammar for types, overloading it in the DisambECP style, see Note [Ambiguous syntactic categories]. With this patch, we introduce a new class, DisambTD. Just like DisambECP is used to disambiguate between expressions, commands, and patterns, DisambTD is used to disambiguate between types and data/newtype constructors. This way, we get a proper, declarative grammar for constructors and types: infixtype : ftype | ftype tyop infixtype | unpackedness infixtype ftype : atype | tyop | ftype tyarg | ftype PREFIX_AT tyarg tyarg : atype | unpackedness atype And having a grammar for types means we are a step closer to using a single grammar for types and expressions. - - - - - 16 changed files: - + .git-ignore-revs - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/linters/check-cpp.py - .gitlab/merge_request_templates/merge-request.md - .gitlab/test-metrics.sh - .gitmodules - CODEOWNERS - Makefile - aclocal.m4 - compiler/GHC.hs - + compiler/GHC/Builtin/Names.hs - + compiler/GHC/Builtin/Names/TH.hs - + compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps.hs-boot - + compiler/GHC/Builtin/RebindableNames.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dd7b3378b5cadc0c5466c3404f3a32d5a3bb4a46...34b390f3d02d8d223d234d80527f3b80bbd57963 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dd7b3378b5cadc0c5466c3404f3a32d5a3bb4a46...34b390f3d02d8d223d234d80527f3b80bbd57963 You're receiving 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 Jul 23 23:26:47 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Thu, 23 Jul 2020 19:26:47 -0400 Subject: [Git][ghc/ghc][wip/T13253] 22 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f1a1cb7278e1_80b3f84962c9cf047906d1@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 9b1412f1 by Simon Peyton Jones at 2020-07-22T17:51:56+01:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes two significant changes: 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Then in postInlineUnconditionally use that info to avoid inling something many many times. Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally See Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils 2. Change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg] Current nofib run Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- VS -0.3% +115.9% +12.1% +11.2% 0.0% boyer2 -0.3% +10.0% +3.5% +4.0% 0.0% cryptarithm2 -0.3% +39.0% +16.6% +16.1% 0.0% gamteb -0.3% +4.1% -0.0% +0.4% 0.0% last-piece -0.3% +1.4% -1.1% -0.4% 0.0% mate -0.4% -11.1% -8.5% -9.0% 0.0% multiplier -0.3% -2.2% -1.5% -1.5% 0.0% transform -0.3% +3.4% +0.5% +0.8% 0.0% -------------------------------------------------------------------------------- Min -0.8% -11.1% -8.5% -9.0% 0.0% Max -0.3% +115.9% +30.1% +26.4% 0.0% Geometric Mean -0.3% +1.0% +1.0% +1.0% -0.0% Should investigate these numbers. But the tickets are indeed cured, I think. - - - - - ec35bcf7 by Simon Peyton Jones at 2020-07-24T00:24:57+01:00 Wibbles Improving simplifier some more. Need to squash this into the main commit, but meanwhile want CI - - - - - 29 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/UsageEnv.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Stats.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - 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/e8b04d89fd95d25c42ac81454d71d423bd81bccc...ec35bcf7cfd44ab7d29e83e799e3cf6ed76ce1ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8b04d89fd95d25c42ac81454d71d423bd81bccc...ec35bcf7cfd44ab7d29e83e799e3cf6ed76ce1ab You're receiving 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 Jul 24 07:02:06 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 24 Jul 2020 03:02:06 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: winio: restore console cp on exit Message-ID: <5f1a876e6b03a_80b3f84868c38284798059@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 50a9151b by Tamar Christina at 2020-07-24T03:02:00-04:00 winio: restore console cp on exit - - - - - 5a6b4355 by Tamar Christina at 2020-07-24T03:02:02-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - f5c95a23 by Simon Peyton Jones at 2020-07-24T03:02:02-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 15 changed files: - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Utils/Unify.hs - includes/HsFFI.h - libraries/base/GHC/Event/Windows.hsc - libraries/base/GHC/Event/Windows/FFI.hsc - rts/RtsStartup.c - rts/win32/veh_excn.c - + testsuite/tests/polykinds/T18451.hs - + testsuite/tests/polykinds/T18451.stderr - + testsuite/tests/polykinds/T18451a.hs - + testsuite/tests/polykinds/T18451a.stderr - + testsuite/tests/polykinds/T18451b.hs - + testsuite/tests/polykinds/T18451b.stderr - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -34,10 +34,9 @@ import {-# SOURCE #-} GHC.CoreToIface , toIfaceTyCon, toIfaceTcArgs, toIfaceCoercionX ) import {-# SOURCE #-} GHC.Core.DataCon - ( dataConFullSig , dataConUserTyVarBinders - , DataCon ) + ( dataConFullSig , dataConUserTyVarBinders, DataCon ) -import GHC.Core.Type ( isLiftedTypeKind, pattern One, pattern Many ) +import GHC.Core.Type ( pickyIsLiftedTypeKind, pattern One, pattern Many ) import GHC.Core.TyCon import GHC.Core.TyCo.Rep @@ -192,11 +191,35 @@ pprTyVar :: TyVar -> SDoc -- pprIfaceTvBndr is minimal, and the loss of uniques etc in -- debug printing is disastrous pprTyVar tv - | isLiftedTypeKind kind = ppr tv - | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) + | pickyIsLiftedTypeKind kind = ppr tv -- See Note [Suppressing * kinds] + | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) where kind = tyVarKind tv +{- Note [Suppressing * kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Generally we want to print + forall a. a->a +not forall (a::*). a->a +or forall (a::Type). a->a +That is, for brevity we suppress a kind ascription of '*' (or Type). + +But what if the kind is (Const Type x)? + type Const p q = p + +Then (Const Type x) is just a long way of saying Type. But it may be +jolly confusing to suppress the 'x'. Suppose we have (polykinds/T18451a) + foo :: forall a b (c :: Const Type b). Proxy '[a, c] + +Then this error message + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) +would be much less helpful if we suppressed the kind ascription on 'a'. + +Hence the use of pickyIsLiftedTypeKind. +-} + ----------------- debugPprType :: Type -> SDoc -- ^ debugPprType is a simple pretty printer that prints a type ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -120,7 +120,7 @@ module GHC.Core.Type ( -- *** Levity and boxity isLiftedType_maybe, - isLiftedTypeKind, isUnliftedTypeKind, + isLiftedTypeKind, isUnliftedTypeKind, pickyIsLiftedTypeKind, isLiftedRuntimeRep, isUnliftedRuntimeRep, isUnliftedType, mightBeUnliftedType, isUnboxedTupleType, isUnboxedSumType, isAlgType, isDataFamilyAppType, @@ -554,6 +554,23 @@ isLiftedTypeKind kind Just rep -> isLiftedRuntimeRep rep Nothing -> False +pickyIsLiftedTypeKind :: Kind -> Bool +-- Checks whether the kind is literally +-- TYPE LiftedRep +-- or Type +-- without expanding type synonyms or anything +-- Used only when deciding whether to suppress the ":: *" in +-- (a :: *) when printing kinded type variables +-- See Note [Suppressing * kinds] in GHC.Core.TyCo.Ppr +pickyIsLiftedTypeKind kind + | TyConApp tc [arg] <- kind + , tc `hasKey` tYPETyConKey + , TyConApp rr_tc [] <- arg + , rr_tc `hasKey` liftedRepDataConKey = True + | TyConApp tc [] <- kind + , tc `hasKey` liftedTypeKindTyConKey = True + | otherwise = False + isLiftedRuntimeRep :: Type -> Bool -- isLiftedRuntimeRep is true of LiftedRep :: RuntimeRep -- False of type variables (a :: RuntimeRep) @@ -2619,6 +2636,46 @@ prefer doing inner expansions first. For example, We have occCheckExpand b (F (G b)) = Just (F Char) even though we could also expand F to get rid of b. + +Note [Occurrence checking: look inside kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we are considering unifying + (alpha :: *) ~ Int -> (beta :: alpha -> alpha) +This may be an error (what is that alpha doing inside beta's kind?), +but we must not make the mistake of actually unifying or we'll +build an infinite data structure. So when looking for occurrences +of alpha in the rhs, we must look in the kinds of type variables +that occur there. + +occCheckExpand tries to expand type synonyms to remove +unnecessary occurrences of a variable, and thereby get past an +occurs-check failure. This is good; but + we can't do it in the /kind/ of a variable /occurrence/ + +For example #18451 built an infinite type: + type Const a b = a + data SameKind :: k -> k -> Type + type T (k :: Const Type a) = forall (b :: k). SameKind a b + +We have + b :: k + k :: Const Type a + a :: k (must be same as b) + +So if we aren't careful, a's kind mentions a, which is bad. +And expanding an /occurrence/ of 'a' doesn't help, because the +/binding site/ is the master copy and all the occurrences should +match it. + +Here's a related example: + f :: forall a b (c :: Const Type b). Proxy '[a, c] + +The list means that 'a' gets the same kind as 'c'; but that +kind mentions 'b', so the binders are out of order. + +Bottom line: in occCheckExpand, do not expand inside the kinds +of occurrences. See bad_var_occ in occCheckExpand. And +see #18451 for more debate. -} occCheckExpand :: [Var] -> Type -> Maybe Type @@ -2639,11 +2696,10 @@ occCheckExpand vs_to_avoid ty -- The VarSet is the set of variables we are trying to avoid -- The VarEnv carries mappings necessary -- because of kind expansion - go cxt@(as, env) (TyVarTy tv') - | tv' `elemVarSet` as = Nothing - | Just tv'' <- lookupVarEnv env tv' = return (mkTyVarTy tv'') - | otherwise = do { tv'' <- go_var cxt tv' - ; return (mkTyVarTy tv'') } + go (as, env) ty@(TyVarTy tv) + | Just tv' <- lookupVarEnv env tv = return (mkTyVarTy tv') + | bad_var_occ as tv = Nothing + | otherwise = return ty go _ ty@(LitTy {}) = return ty go cxt (AppTy ty1 ty2) = do { ty1' <- go cxt ty1 @@ -2656,7 +2712,7 @@ occCheckExpand vs_to_avoid ty ; return (ty { ft_mult = w', ft_arg = ty1', ft_res = ty2' }) } go cxt@(as, env) (ForAllTy (Bndr tv vis) body_ty) = do { ki' <- go cxt (varType tv) - ; let tv' = setVarType tv ki' + ; let tv' = setVarType tv ki' env' = extendVarEnv env tv tv' as' = as `delVarSet` tv ; body' <- go (as', env') body_ty @@ -2680,9 +2736,12 @@ occCheckExpand vs_to_avoid ty ; return (mkCoercionTy co') } ------------------ - go_var cxt v = updateVarTypeM (go cxt) v - -- Works for TyVar and CoVar - -- See Note [Occurrence checking: look inside kinds] + bad_var_occ :: VarSet -> Var -> Bool + -- Works for TyVar and CoVar + -- See Note [Occurrence checking: look inside kinds] + bad_var_occ vs_to_avoid v + = v `elemVarSet` vs_to_avoid + || tyCoVarsOfType (varType v) `intersectsVarSet` vs_to_avoid ------------------ go_mco _ MRefl = return MRefl @@ -2712,13 +2771,15 @@ occCheckExpand vs_to_avoid ty ; co2' <- go_co cxt co2 ; w' <- go_co cxt w ; return (mkFunCo r w' co1' co2') } - go_co cxt@(as,env) (CoVarCo c) - | c `elemVarSet` as = Nothing + go_co (as,env) co@(CoVarCo c) | Just c' <- lookupVarEnv env c = return (mkCoVarCo c') - | otherwise = do { c' <- go_var cxt c - ; return (mkCoVarCo c') } - go_co cxt (HoleCo h) = do { c' <- go_var cxt (ch_co_var h) - ; return (HoleCo (h { ch_co_var = c' })) } + | bad_var_occ as c = Nothing + | otherwise = return co + + go_co (as,_) co@(HoleCo h) + | bad_var_occ as (ch_co_var h) = Nothing + | otherwise = return co + go_co cxt (AxiomInstCo ax ind args) = do { args' <- mapM (go_co cxt) args ; return (mkAxiomInstCo ax ind args') } go_co cxt (UnivCo p r ty1 ty2) = do { p' <- go_prov cxt p ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -1879,21 +1879,8 @@ matchExpectedFunKind hs_ty n k = go n k ********************************************************************* -} -{- Note [Occurrence checking: look inside kinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Suppose we are considering unifying - (alpha :: *) ~ Int -> (beta :: alpha -> alpha) -This may be an error (what is that alpha doing inside beta's kind?), -but we must not make the mistake of actually unifying or we'll -build an infinite data structure. So when looking for occurrences -of alpha in the rhs, we must look in the kinds of type variables -that occur there. - -NB: we may be able to remove the problem via expansion; see - Note [Occurs check expansion]. So we have to try that. - -Note [Checking for foralls] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Checking for foralls] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unless we have -XImpredicativeTypes (which is a totally unsupported feature), we do not want to unify alpha ~ (forall a. a->a) -> Int @@ -1906,10 +1893,10 @@ Consider (alpha :: forall k. k->*) ~ (beta :: forall k. k->*) This is legal; e.g. dependent/should_compile/T11635. -We don't want to reject it because of the forall in beta's kind, -but (see Note [Occurrence checking: look inside kinds]) we do -need to look in beta's kind. So we carry a flag saying if a 'forall' -is OK, and switch the flag on when stepping inside a kind. +We don't want to reject it because of the forall in beta's kind, but +(see Note [Occurrence checking: look inside kinds] in GHC.Core.Type) +we do need to look in beta's kind. So we carry a flag saying if a +'forall' is OK, and switch the flag on when stepping inside a kind. Why is it OK? Why does it not count as impredicative polymorphism? The reason foralls are bad is because we reply on "seeing" foralls @@ -2030,6 +2017,7 @@ preCheck dflags ty_fam_ok tv ty | tv == tv' = MTVU_Occurs | otherwise = fast_check_occ (tyVarKind tv') -- See Note [Occurrence checking: look inside kinds] + -- in GHC.Core.Type fast_check (TyConApp tc tys) | bad_tc tc = MTVU_Bad ===================================== includes/HsFFI.h ===================================== @@ -102,6 +102,7 @@ extern void hs_exit (void); extern void hs_exit_nowait(void); extern void hs_set_argv (int argc, char *argv[]); extern void hs_thread_done (void); +extern void hs_restoreConsoleCP (void); extern void hs_perform_gc (void); ===================================== libraries/base/GHC/Event/Windows.hsc ===================================== @@ -86,7 +86,9 @@ import Data.Foldable (mapM_, length, forM_) import Data.Maybe (isJust, maybe) import GHC.Event.Windows.Clock (Clock, Seconds, getClock, getTime) -import GHC.Event.Windows.FFI (LPOVERLAPPED, OVERLAPPED_ENTRY(..)) +import GHC.Event.Windows.FFI (LPOVERLAPPED, OVERLAPPED_ENTRY(..), + CompletionData(..), CompletionCallback, + withRequest) import GHC.Event.Windows.ManagedThreadPool import GHC.Event.Internal.Types import GHC.Event.Unique @@ -300,43 +302,6 @@ foreign import ccall safe "completeSynchronousRequest" ------------------------------------------------------------------------ -- Manager structures --- | Callback type that will be called when an I/O operation completes. -type IOCallback = CompletionCallback () - --- | Wrap the IOCallback type into a FunPtr. -foreign import ccall "wrapper" - wrapIOCallback :: IOCallback -> IO (FunPtr IOCallback) - --- | Unwrap a FunPtr IOCallback to a normal Haskell function. -foreign import ccall "dynamic" - mkIOCallback :: FunPtr IOCallback -> IOCallback - --- | Structure that the I/O manager uses to associate callbacks with --- additional payload such as their OVERLAPPED structure and Win32 handle --- etc. *Must* be kept in sync with that in `winio_structs.h` or horrible things --- happen. --- --- We keep the handle around for the benefit of ghc-external libraries making --- use of the manager. -data CompletionData = CompletionData { cdHandle :: !HANDLE - , cdCallback :: !IOCallback - } - -instance Storable CompletionData where - sizeOf _ = #{size CompletionData} - alignment _ = #{alignment CompletionData} - - peek ptr = do - cdCallback <- mkIOCallback `fmap` #{peek CompletionData, cdCallback} ptr - cdHandle <- #{peek CompletionData, cdHandle} ptr - let !cd = CompletionData{..} - return cd - - poke ptr CompletionData{..} = do - cb <- wrapIOCallback cdCallback - #{poke CompletionData, cdCallback} ptr cb - #{poke CompletionData, cdHandle} ptr cdHandle - -- | Pointer offset in bytes to the location of hoData in HASKELL_OVERLAPPPED cdOffset :: Int cdOffset = #{const __builtin_offsetof (HASKELL_OVERLAPPED, hoData)} @@ -507,11 +472,6 @@ data CbResult a -- manager will perform additional checks. deriving Show --- | Called when the completion is delivered. -type CompletionCallback a = ErrCode -- ^ 0 indicates success - -> DWORD -- ^ Number of bytes transferred - -> IO a - -- | Associate a 'HANDLE' with the current I/O manager's completion port. -- This must be done before using the handle with 'withOverlapped'. associateHandle' :: HANDLE -> IO () @@ -581,23 +541,18 @@ withOverlappedEx mgr fname h offset startCB completionCB = do signalThrow ex = failIfFalse_ (dbgMsg "signalThrow") $ writeIOPort signal (IOFailed ex) mask_ $ do - let completionCB' e b = completionCB e b >>= \result -> - case result of - IOSuccess val -> signalReturn val - IOFailed err -> signalThrow err - hs_lpol <- FFI.allocOverlapped offset - -- Create the completion record and store it. - -- We only need the record when we enqueue a request, however if we - -- delay creating it then we will run into a race condition where the - -- driver may have finished servicing the request before we were ready - -- and so the request won't have the book keeping information to know - -- what to do. So because of that we always create the payload, If we - -- need it ok, if we don't that's no problem. This approach prevents - -- expensive lookups in hash-tables. - -- - -- Todo: Use a memory pool for this so we don't have to hit malloc every - -- time. This would allow us to scale better. - cdData <- new (CompletionData h completionCB') :: IO (Ptr CompletionData) + let completionCB' e b = completionCB e b >>= \result -> + case result of + IOSuccess val -> signalReturn val + IOFailed err -> signalThrow err + let callbackData = CompletionData h completionCB' + -- Note [Memory Management] + -- These callback data and especially the overlapped structs have to keep + -- alive throughout the entire lifetime of the requests. Since this + -- function will block until done so it can call completionCB at the end + -- we can safely use dynamic memory management here and so reduce the + -- possibility of memory errors. + withRequest offset callbackData $ \hs_lpol cdData -> do let ptr_lpol = hs_lpol `plusPtr` cdOffset let lpol = castPtr hs_lpol debugIO $ "hs_lpol:" ++ show hs_lpol @@ -713,11 +668,8 @@ withOverlappedEx mgr fname h offset startCB completionCB = do debugIO $ "## Waiting for cancellation record... " _ <- FFI.getOverlappedResult h lpol True oldDataPtr <- exchangePtr ptr_lpol nullReq - -- Check if we have to free and cleanup pointer when (oldDataPtr == cdData) $ - do free oldDataPtr - free hs_lpol - reqs <- removeRequest + do reqs <- removeRequest debugIO $ "-1.. " ++ show reqs ++ " requests queued after error." status <- fmap fromIntegral getLastError completionCB' status 0 @@ -741,7 +693,6 @@ withOverlappedEx mgr fname h offset startCB completionCB = do case startCBResult of CbPending -> runner CbDone rdata -> do - free cdData debugIO $ dbgMsg $ ":: done " ++ show lpol ++ " - " ++ show rdata bytes <- if isJust rdata then return rdata @@ -749,23 +700,18 @@ withOverlappedEx mgr fname h offset startCB completionCB = do else FFI.getOverlappedResult h lpol False debugIO $ dbgMsg $ ":: done bytes: " ++ show bytes case bytes of - Just res -> free hs_lpol >> completionCB 0 res + Just res -> completionCB 0 res Nothing -> do err <- FFI.overlappedIOStatus lpol numBytes <- FFI.overlappedIONumBytes lpol -- TODO: Remap between STATUS_ and ERROR_ instead -- of re-interpret here. But for now, don't care. let err' = fromIntegral err - free hs_lpol debugIO $ dbgMsg $ ":: done callback: " ++ show err' ++ " - " ++ show numBytes completionCB err' (fromIntegral numBytes) CbError err -> do - free cdData - free hs_lpol let err' = fromIntegral err completionCB err' 0 _ -> do - free cdData - free hs_lpol error "unexpected case in `startCBResult'" where dbgMsg s = s ++ " (" ++ show h ++ ":" ++ show offset ++ ")" -- Wait for .25ms (threaded) and 1ms (non-threaded) @@ -1099,15 +1045,17 @@ processCompletion Manager{..} n delay = do do debugIO $ "exchanged: " ++ show oldDataPtr payload <- peek oldDataPtr :: IO CompletionData let !cb = cdCallback payload - free oldDataPtr reqs <- removeRequest debugIO $ "-1.. " ++ show reqs ++ " requests queued." status <- FFI.overlappedIOStatus (lpOverlapped oe) -- TODO: Remap between STATUS_ and ERROR_ instead -- of re-interpret here. But for now, don't care. let status' = fromIntegral status + -- We no longer explicitly free the memory, this is because we + -- now require the callback to free the memory since the + -- callback allocated it. This allows us to simplify memory + -- management and reduce bugs. See Note [Memory Management]. cb status' (dwNumberOfBytesTransferred oe) - free hs_lpol -- clear the array so we don't erroneously interpret the output, in -- certain circumstances like lockFileEx the code could return 1 entry ===================================== libraries/base/GHC/Event/Windows/FFI.hsc ===================================== @@ -30,6 +30,11 @@ module GHC.Event.Windows.FFI ( postQueuedCompletionStatus, getOverlappedResult, + -- * Completion Data + CompletionData(..), + CompletionCallback, + withRequest, + -- * Overlapped OVERLAPPED, LPOVERLAPPED, @@ -215,6 +220,51 @@ postQueuedCompletionStatus iocp numBytes completionKey lpol = failIfFalse_ "PostQueuedCompletionStatus" $ c_PostQueuedCompletionStatus iocp numBytes completionKey lpol +------------------------------------------------------------------------ +-- Completion Data + +-- | Called when the completion is delivered. +type CompletionCallback a = ErrCode -- ^ 0 indicates success + -> DWORD -- ^ Number of bytes transferred + -> IO a + +-- | Callback type that will be called when an I/O operation completes. +type IOCallback = CompletionCallback () + +-- | Wrap the IOCallback type into a FunPtr. +foreign import ccall "wrapper" + wrapIOCallback :: IOCallback -> IO (FunPtr IOCallback) + +-- | Unwrap a FunPtr IOCallback to a normal Haskell function. +foreign import ccall "dynamic" + mkIOCallback :: FunPtr IOCallback -> IOCallback + +-- | Structure that the I/O manager uses to associate callbacks with +-- additional payload such as their OVERLAPPED structure and Win32 handle +-- etc. *Must* be kept in sync with that in `winio_structs.h` or horrible things +-- happen. +-- +-- We keep the handle around for the benefit of ghc-external libraries making +-- use of the manager. +data CompletionData = CompletionData { cdHandle :: !HANDLE + , cdCallback :: !IOCallback + } + +instance Storable CompletionData where + sizeOf _ = #{size CompletionData} + alignment _ = #{alignment CompletionData} + + peek ptr = do + cdCallback <- mkIOCallback `fmap` #{peek CompletionData, cdCallback} ptr + cdHandle <- #{peek CompletionData, cdHandle} ptr + let !cd = CompletionData{..} + return cd + + poke ptr CompletionData{..} = do + cb <- wrapIOCallback cdCallback + #{poke CompletionData, cdCallback} ptr cb + #{poke CompletionData, cdHandle} ptr cdHandle + ------------------------------------------------------------------------ -- Overlapped @@ -293,6 +343,30 @@ pokeOffsetOverlapped lpol offset = do #{poke OVERLAPPED, OffsetHigh} lpol offsetHigh {-# INLINE pokeOffsetOverlapped #-} +------------------------------------------------------------------------ +-- Request management + +withRequest :: Word64 -> CompletionData + -> (Ptr HASKELL_OVERLAPPED -> Ptr CompletionData -> IO a) + -> IO a +withRequest offset cbData f = + -- Create the completion record and store it. + -- We only need the record when we enqueue a request, however if we + -- delay creating it then we will run into a race condition where the + -- driver may have finished servicing the request before we were ready + -- and so the request won't have the book keeping information to know + -- what to do. So because of that we always create the payload, If we + -- need it ok, if we don't that's no problem. This approach prevents + -- expensive lookups in hash-tables. + -- + -- Todo: Use a memory pool for this so we don't have to hit malloc every + -- time. This would allow us to scale better. + allocaBytes #{size HASKELL_OVERLAPPED} $ \hs_lpol -> + with cbData $ \cdData -> do + zeroOverlapped hs_lpol + pokeOffsetOverlapped (castPtr hs_lpol) offset + f hs_lpol cdData + ------------------------------------------------------------------------ -- Cancel pending I/O ===================================== rts/RtsStartup.c ===================================== @@ -68,6 +68,11 @@ static int hs_init_count = 0; static bool rts_shutdown = false; +#if defined(mingw32_HOST_OS) +/* Indicates CodePage to set program to after exit. */ +static int64_t __codePage = 0; +#endif + static void flushStdHandles(void); /* ----------------------------------------------------------------------------- @@ -128,13 +133,38 @@ void fpreset(void) { static void initConsoleCP (void) { + /* Set the initial codepage to automatic. */ + __codePage = -1; + /* Check if the codepage is still the system default ANSI codepage. */ - if (GetConsoleCP () == GetOEMCP ()) { - if (! SetConsoleCP (CP_UTF8)) + if (GetConsoleCP () == GetOEMCP () + && GetConsoleOutputCP () == GetOEMCP ()) { + if (!SetConsoleCP (CP_UTF8) || !SetConsoleOutputCP (CP_UTF8)) errorBelch ("Unable to set console CodePage, Unicode output may be " "garbled.\n"); else IF_DEBUG (scheduler, debugBelch ("Codepage set to UTF-8.\n")); + + /* Assign the codepage so we can restore it on exit. */ + __codePage = (int64_t)GetOEMCP (); + } +} + +/* Restore the CodePage to what it was before we started. If the CodePage was + already set then this call is a no-op. */ +void +hs_restoreConsoleCP (void) +{ + /* If we set the CP at startup, we should set it on exit. */ + if (__codePage == -1) + return; + + UINT cp = (UINT)__codePage; + __codePage = -1; + if (SetConsoleCP (cp) && SetConsoleOutputCP (cp)) { + IF_DEBUG (scheduler, debugBelch ("Codepage restored to OEM.\n")); + } else { + IF_DEBUG (scheduler, debugBelch ("Unable to restore CodePage to OEM.\n")); } } #endif @@ -533,6 +563,11 @@ hs_exit_(bool wait_foreign) shutdownAsyncIO(wait_foreign); #endif + /* Restore the console Codepage. */ +#if defined(mingw32_HOST_OS) + if (is_io_mng_native_p()) + hs_restoreConsoleCP(); +#endif /* free hash table storage */ exitHashTable(); ===================================== rts/win32/veh_excn.c ===================================== @@ -153,6 +153,7 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data) if (EXCEPTION_CONTINUE_EXECUTION == action) { fflush(stderr); + hs_restoreConsoleCP (); generateStack (exception_data); generateDump (exception_data); stg_exit(exit_code); ===================================== testsuite/tests/polykinds/T18451.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind + +type Const a b = a +data SameKind :: k -> k -> Type + +type T (k :: Const Type a) = forall (b :: k). SameKind a b ===================================== testsuite/tests/polykinds/T18451.stderr ===================================== @@ -0,0 +1,9 @@ + +T18451.hs:10:58: error: + • Expected kind ‘k0’, but ‘b’ has kind ‘k’ + • In the second argument of ‘SameKind’, namely ‘b’ + In the type ‘forall (b :: k). SameKind a b’ + In the type declaration for ‘T’ + • Type variable kinds: + a :: k0 + k :: Const (*) a ===================================== testsuite/tests/polykinds/T18451a.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451a.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/T18451b.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451b.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451b.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -220,3 +220,6 @@ test('CuskFam', normal, compile, ['']) test('T17841', normal, compile_fail, ['']) test('T17963', normal, compile_fail, ['']) test('T18300', normal, compile_fail, ['']) +test('T18451', normal, compile_fail, ['']) +test('T18451a', normal, compile_fail, ['']) +test('T18451b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6f71d32f7c63e732dd905e8c7643e20101298568...f5c95a237888ab120c25ef7b73d22c108ad3596d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6f71d32f7c63e732dd905e8c7643e20101298568...f5c95a237888ab120c25ef7b73d22c108ad3596d You're receiving 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 Jul 24 09:10:00 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 24 Jul 2020 05:10:00 -0400 Subject: [Git][ghc/ghc][wip/T13253] Revert the multi-case inline fix Message-ID: <5f1aa568d8368_80b3f84901582f048124a4@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC Commits: eaa84461 by Simon Peyton Jones at 2020-07-24T10:08:56+01:00 Revert the multi-case inline fix It makes GHC run a bit slower in some cases. Let's try again without. - - - - - 1 changed file: - compiler/GHC/Core/Opt/Simplify/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1350,13 +1350,14 @@ postInlineUnconditionally env top_lvl bndr occ_info rhs -- This is very important in practice; e.g. wheel-seive1 doubles -- in allocation if you miss this out - OneOcc { occ_in_lam = in_lam, occ_int_cxt = int_cxt, occ_n_br = n_br } + OneOcc { occ_in_lam = in_lam, occ_int_cxt = int_cxt } + -- occ_n_br = n_br -> -- See Note [Suppress exponential blowup] - n_br < (case int_cxt of + {- n_br < (case int_cxt of IsInteresting -> 16 NotInteresting -> 4) - && smallEnoughToInline dflags unfolding -- Small enough to dup + && -} smallEnoughToInline dflags 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 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eaa8446170ae6685978c21a44f0ceb2c275aea3c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eaa8446170ae6685978c21a44f0ceb2c275aea3c You're receiving 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 Jul 24 11:02:06 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Fri, 24 Jul 2020 07:02:06 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] Rearrange #ifdef with GHC version Message-ID: <5f1abfaed9630_80b114037a4482129d@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: 5f73058e by Sven Tennie at 2020-07-24T13:01:58+02:00 Rearrange #ifdef with GHC version This prevents some "unused" warnings. - - - - - 1 changed file: - libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc Changes: ===================================== libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc ===================================== @@ -3,6 +3,8 @@ module GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled( peekStgTSOProfInfo ) where +#if __GLASGOW_HASKELL__ >= 811 + -- Manually defining PROFILING gives the #peek and #poke macros an accurate -- representation of the C structures when hsc2hs runs. This is valid because -- a non-profiling build would use @@ -14,6 +16,7 @@ module GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled( import Prelude import Foreign + import Foreign.C.String import GHC.Exts.Heap.ProfInfo.Types @@ -43,9 +46,6 @@ data Cache = Cache { type DecoderMonad a = StateT Cache IO a peekStgTSOProfInfo :: Ptr a -> IO (Maybe StgTSOProfInfo) -#if __GLASGOW_HASKELL__ < 811 -peekStgTSOProfInfo _ = return Nothing -#else peekStgTSOProfInfo tsoPtr = do print $ "peekStgTSOProfInfo - tsoPtr : " ++ show tsoPtr cccs_ptr <- peekByteOff tsoPtr cccsOffset @@ -185,4 +185,13 @@ peekIndexTable loopBreakers ptr = do return $ Just result where ptrAsInt = ptrToInt ptr + +#else +import Prelude +import Foreign + +import GHC.Exts.Heap.ProfInfo.Types + +peekStgTSOProfInfo :: Ptr a -> IO (Maybe StgTSOProfInfo) +peekStgTSOProfInfo _ = return Nothing #endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f73058e52b47950acbeffc929c137ffe6bb1cd2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f73058e52b47950acbeffc929c137ffe6bb1cd2 You're receiving 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 Jul 24 13:21:21 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 24 Jul 2020 09:21:21 -0400 Subject: [Git][ghc/ghc][wip/win32-testsuite-fixes] gitlab-ci: Kill ssh-agent after pushing test metrics Message-ID: <5f1ae0512389f_80b3f84925412344829326@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/win32-testsuite-fixes at Glasgow Haskell Compiler / GHC Commits: f81ae23c by Ben Gamari at 2020-07-24T09:21:10-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 1 changed file: - .gitlab/test-metrics.sh Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -81,6 +81,10 @@ function push() { echo "" echo "Failed to push git notes. Fetching, appending, and retrying... $MAX_RETRY retries left." done + + # Be sure to kill agent before we terminate since otherwise the Windows CI + # job won't finish. + ssh-agent -k } case $1 in @@ -88,3 +92,4 @@ case $1 in pull) pull ;; *) fail "Invalid mode $1" ;; esac + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f81ae23c9c334698babb436df9573d58bce51a97 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f81ae23c9c334698babb436df9573d58bce51a97 You're receiving 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 Jul 24 13:56:06 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 24 Jul 2020 09:56:06 -0400 Subject: [Git][ghc/ghc][wip/T13253] Further wibbles Message-ID: <5f1ae876e9d67_80b1025102448379ed@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC Commits: 1cfa23cd by Simon Peyton Jones at 2020-07-24T14:55:32+01:00 Further wibbles - - - - - 3 changed files: - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -1011,12 +1011,16 @@ simplExprF1 env (App fun arg) cont -- (instead of one-at-a-time). But in practice, we have not -- observed the quadratic behavior, so this extra entanglement -- seems not worthwhile. + -- + -- But the (exprType fun) is repeated, to push it into two + -- separate, rarely used, thunks; rather than always alloating + -- a shared thunk. Makes a small efficiency difference let fun_ty = exprType fun (m, _, _) = splitFunTy fun_ty in simplExprF env fun $ ApplyToVal { sc_arg = arg, sc_env = env - , sc_hole_ty = substTy env fun_ty + , sc_hole_ty = substTy env (exprType fun) , sc_dup = NoDup, sc_cont = cont, sc_mult = m } simplExprF1 env expr@(Lam {}) cont @@ -1975,9 +1979,9 @@ rebuildCall env info (ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_c ---------- The runRW# rule. Do this after absorbing all arguments ------ -- runRW# :: forall (r :: RuntimeRep) (o :: TYPE r). (State# RealWorld -> o) -> o -- K[ runRW# rr ty body ] --> runRW rr' ty' (\s. K[ body s ]) -rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args }) +rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) (ApplyToVal { sc_arg = arg, sc_env = arg_se, sc_cont = cont, sc_mult = m }) - | fun `hasKey` runRWKey + | fun_id `hasKey` runRWKey , not (contIsStop cont) -- Don't fiddle around if the continuation is boring , [ TyArg {}, TyArg {} ] <- rev_args = do { s <- newId (fsLit "s") Many realWorldStatePrimTy @@ -1991,25 +1995,24 @@ rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args }) ; body' <- simplExprC env' arg cont' ; let arg' = Lam s body' rr' = getRuntimeRep ty' - call' = mkApps (Var fun) [mkTyArg rr', mkTyArg ty', arg'] + call' = mkApps (Var fun_id) [mkTyArg rr', mkTyArg ty', arg'] ; return (emptyFloats env, call') } -rebuildCall env info@(ArgInfo { ai_encl = encl_rules - , ai_dmds = dmd:_, ai_discs = disc:_ }) +rebuildCall env fun_info (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_dup = dup_flag, sc_hole_ty = fun_ty , sc_cont = cont, sc_mult = m }) -- Argument is already simplified | isSimplified dup_flag -- See Note [Avoid redundant simplification] - = rebuildCall env (addValArgTo info (m, arg) fun_ty) cont + = rebuildCall env (addValArgTo fun_info (m, arg) fun_ty) cont -- Strict arguments - | isStrictDmd dmd || isUnliftedType arg_ty + | isStrictArgInfo fun_info , sm_case_case (getMode env) = -- pprTrace "Strict Arg" (ppr arg $$ ppr (seIdSubst env) $$ ppr (seInScope env)) $ simplExprF (arg_se `setInScopeFromE` env) arg - (StrictArg { sc_fun = info, sc_cci = cci_strict - , sc_dup = Simplified, sc_fun_ty = fun_ty + (StrictArg { sc_fun = fun_info, sc_fun_ty = fun_ty + , sc_dup = Simplified , sc_cont = cont, sc_mult = m }) -- Note [Shadowing] @@ -2020,26 +2023,11 @@ rebuildCall env info@(ArgInfo { ai_encl = encl_rules -- have to be very careful about bogus strictness through -- floating a demanded let. = do { arg' <- simplExprC (arg_se `setInScopeFromE` env) arg - (mkLazyArgStop arg_ty cci_lazy) - ; rebuildCall env (addValArgTo info (m, arg') fun_ty) cont } + (mkLazyArgStop arg_ty (lazyArgContext fun_info)) + ; rebuildCall env (addValArgTo fun_info (m, arg') fun_ty) cont } where arg_ty = funArgTy fun_ty - -- Use this for lazy arguments - cci_lazy | encl_rules = RuleArgCtxt - | disc > 0 = DiscArgCtxt -- Be keener here - | otherwise = BoringCtxt -- Nothing interesting - - -- ..and this for strict arguments - cci_strict | encl_rules = RuleArgCtxt - | disc > 0 = DiscArgCtxt - | otherwise = RhsCtxt - -- Why RhsCtxt? if we see f (g x) (h x), and f is strict, we - -- want to be a bit more eager to inline g, because it may - -- expose an eval (on x perhaps) that can be eliminated or - -- shared. I saw this in nofib 'boyer2', RewriteFuns.onewayunify1 - -- It's worth an 18% improvement in allocation for this - -- particular benchmark; 5% on 'mate' and 1.3% on 'multiplier' ---------- No further useful info, revert to generic rebuild ------------ rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args }) cont @@ -3311,10 +3299,10 @@ mkDupableContWithDmds env _ ; let join_body = wrapFloats floats1 join_inner res_ty = contResultType cont - ; mkDupableStrictBind env RhsCtxt bndr' join_body res_ty } + ; mkDupableStrictBind env bndr' join_body res_ty } mkDupableContWithDmds env _ - (StrictArg { sc_fun = fun, sc_cci = cci, sc_cont = cont + (StrictArg { sc_fun = fun, sc_cont = cont , sc_fun_ty = fun_ty, sc_mult = m }) -- See Note [Duplicating StrictArg] -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable @@ -3328,7 +3316,6 @@ mkDupableContWithDmds env _ ; return ( foldl' addLetFloats floats1 floats_s , StrictArg { sc_fun = fun { ai_args = args' } , sc_cont = cont' - , sc_cci = cci , sc_fun_ty = fun_ty , sc_mult = m , sc_dup = OkToDup} ) } @@ -3341,7 +3328,7 @@ mkDupableContWithDmds env _ ; arg_bndr <- newId (fsLit "arg") m arg_ty -- ToDo: check this linearity argument ; let env' = env `addNewInScopeIds` [arg_bndr] ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (m, Var arg_bndr) fun_ty) cont - ; mkDupableStrictBind env' cci arg_bndr (wrapFloats floats join_rhs) rhs_ty } + ; mkDupableStrictBind env' arg_bndr (wrapFloats floats join_rhs) rhs_ty } where ok_cont (StrictArg {}) = False ok_cont (CastIt _ k) = ok_cont k @@ -3425,9 +3412,9 @@ mkDupableContWithDmds env _ -- See Note [StaticEnv invariant] in GHC.Core.Opt.Simplify.Utils , sc_cont = mkBoringStop (contResultType cont) } ) } -mkDupableStrictBind :: SimplEnv -> CallCtxt -> OutId -> OutExpr -> OutType +mkDupableStrictBind :: SimplEnv -> OutId -> OutExpr -> OutType -> SimplM (SimplFloats, SimplCont) -mkDupableStrictBind env cci arg_bndr join_rhs res_ty +mkDupableStrictBind env arg_bndr join_rhs res_ty | exprIsDupable (targetPlatform (seDynFlags env)) join_rhs = return (emptyFloats env , StrictBind { sc_bndr = arg_bndr, sc_bndrs = [] @@ -3451,7 +3438,7 @@ mkDupableStrictBind env cci arg_bndr join_rhs res_ty , sc_fun_ty = idType join_bndr , sc_cont = mkBoringStop res_ty , sc_mult = Many -- ToDo: check this! - , sc_cci = cci } ) } + } ) } mkDupableAlt :: Platform -> OutId -> JoinFloats -> OutAlt ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -29,6 +29,7 @@ module GHC.Core.Opt.Simplify.Utils ( ArgInfo(..), ArgSpec(..), mkArgInfo, addValArgTo, addCastTo, addTyArgTo, argInfoExpr, argInfoAppArgs, pushSimplifiedArgs, + isStrictArgInfo, lazyArgContext, abstractFloats, @@ -156,7 +157,6 @@ data SimplCont -- plus demands and discount flags for *this* arg -- and further args -- So ai_dmds and ai_discs are never empty - , sc_cci :: CallCtxt -- Whether *this* argument position is interesting , sc_fun_ty :: OutType -- Type of the function (f e1 .. en), -- presumably (arg_ty -> res_ty) -- where res_ty is expected by sc_cont @@ -325,6 +325,12 @@ addTyArgTo ai arg_ty hole_ty = ai { ai_args = arg_spec : ai_args ai addCastTo :: ArgInfo -> OutCoercion -> ArgInfo addCastTo ai co = ai { ai_args = CastBy co : ai_args ai } +isStrictArgInfo :: ArgInfo -> Bool +-- True if the function is strict in the next argument +isStrictArgInfo (ArgInfo { ai_dmds = dmds }) + | dmd:_ <- dmds = isStrictDmd dmd + | otherwise = False + argInfoAppArgs :: [ArgSpec] -> [OutExpr] argInfoAppArgs [] = [] argInfoAppArgs (CastBy {} : _) = [] -- Stop at a cast @@ -512,10 +518,11 @@ mkArgInfo env fun rules n_val_args call_cont , ai_dmds = vanilla_dmds , ai_discs = vanilla_discounts } | otherwise - = ArgInfo { ai_fun = fun, ai_args = [] + = ArgInfo { ai_fun = fun + , ai_args = [] , ai_rules = fun_rules , ai_encl = interestingArgContext rules call_cont - , ai_dmds = arg_dmds + , ai_dmds = add_type_strictness (idType fun) arg_dmds , ai_discs = arg_discounts } where fun_rules = mkFunRules rules @@ -555,30 +562,32 @@ mkArgInfo env fun rules n_val_args call_cont <+> ppr n_val_args <+> ppr demands ) vanilla_dmds -- Not enough args, or no strictness -{- - add_type_str :: Type -> [Bool] -> [Bool] + add_type_strictness :: Type -> [Demand] -> [Demand] -- If the function arg types are strict, record that in the 'strictness bits' -- No need to instantiate because unboxed types (which dominate the strict -- types) can't instantiate type variables. - -- add_type_str is done repeatedly (for each call); + -- add_type_strictness is done repeatedly (for each call); -- might be better once-for-all in the function -- But beware primops/datacons with no strictness - add_type_str _ [] = [] - add_type_str fun_ty all_strs@(str:strs) + add_type_strictness fun_ty dmds + | null dmds = [] + + | Just (_, fun_ty') <- splitForAllTy_maybe fun_ty + = add_type_strictness fun_ty' dmds -- Look through foralls + | Just (_, arg_ty, fun_ty') <- splitFunTy_maybe fun_ty -- Add strict-type info - = (str || Just False == isLiftedType_maybe arg_ty) - : add_type_str fun_ty' strs + , dmd : rest_dmds <- dmds + , let dmd' = case isLiftedType_maybe arg_ty of + Just False -> strictenDmd dmd + _ -> dmd + = dmd' : add_type_strictness fun_ty' rest_dmds -- If the type is levity-polymorphic, we can't know whether it's -- strict. isLiftedType_maybe will return Just False only when -- we're sure the type is unlifted. - | Just (_, fun_ty') <- splitForAllTy_maybe fun_ty - = add_type_str fun_ty' all_strs -- Look through foralls - | otherwise - = all_strs --} + = dmds {- Note [Unsaturated functions] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -667,6 +676,26 @@ This made a small compile-time perf improvement in perf/compiler/T6048, and it looks plausible to me. -} +lazyArgContext :: ArgInfo -> CallCtxt +-- Use this for lazy arguments +lazyArgContext (ArgInfo { ai_encl = encl_rules, ai_discs = discs }) + | encl_rules = RuleArgCtxt + | disc:_ <- discs, disc > 0 = DiscArgCtxt -- Be keener here + | otherwise = BoringCtxt -- Nothing interesting + +strictArgContext :: ArgInfo -> CallCtxt +strictArgContext (ArgInfo { ai_encl = encl_rules, ai_discs = discs }) +-- Use this for strict arguments + | encl_rules = RuleArgCtxt + | disc:_ <- discs, disc > 0 = DiscArgCtxt -- Be keener here + | otherwise = RhsCtxt + -- Why RhsCtxt? if we see f (g x) (h x), and f is strict, we + -- want to be a bit more eager to inline g, because it may + -- expose an eval (on x perhaps) that can be eliminated or + -- shared. I saw this in nofib 'boyer2', RewriteFuns.onewayunify1 + -- It's worth an 18% improvement in allocation for this + -- particular benchmark; 5% on 'mate' and 1.3% on 'multiplier' + interestingCallContext :: SimplEnv -> SimplCont -> CallCtxt -- See Note [Interesting call context] interestingCallContext env cont @@ -683,7 +712,7 @@ interestingCallContext env cont -- motivation to inline. See Note [Cast then apply] -- in GHC.Core.Unfold - interesting (StrictArg { sc_cci = cci }) = cci + interesting (StrictArg { sc_fun = fun }) = strictArgContext fun interesting (StrictBind {}) = BoringCtxt interesting (Stop _ cci) = cci interesting (TickIt _ k) = interesting k @@ -733,16 +762,13 @@ interestingArgContext rules call_cont go (Select {}) = False go (ApplyToVal {}) = False -- Shouldn't really happen go (ApplyToTy {}) = False -- Ditto - go (StrictArg { sc_cci = cci }) = interesting cci + go (StrictArg { sc_fun = fun }) = ai_encl fun go (StrictBind {}) = False -- ?? go (CastIt _ c) = go c - go (Stop _ cci) = interesting cci + go (Stop _ RuleArgCtxt) = True + go (Stop _ _) = False go (TickIt _ c) = go c - interesting RuleArgCtxt = True - interesting _ = False - - {- Note [Interesting arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ An argument is interesting if it deserves a discount for unfoldings ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -1285,14 +1285,14 @@ splitDmdTy ty@(DmdType _ [] res_ty) = (defaultArgDmd res_ty, ty) deferAfterPreciseException :: DmdType -> DmdType deferAfterPreciseException = lubDmdType exnDmdType -strictenDmd :: Demand -> CleanDemand +strictenDmd :: Demand -> Demand strictenDmd (JD { sd = s, ud = u}) = JD { sd = poke_s s, ud = poke_u u } where - poke_s Lazy = HeadStr - poke_s (Str s) = s - poke_u Abs = UHead - poke_u (Use _ u) = u + poke_s Lazy = Str HeadStr + poke_s s = s + poke_u Abs = useTop + poke_u u = u -- Deferring and peeling View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1cfa23cd991315275214e36d5819d8791b31e323 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1cfa23cd991315275214e36d5819d8791b31e323 You're receiving 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 Jul 24 14:52:20 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 24 Jul 2020 10:52:20 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: winio: restore console cp on exit Message-ID: <5f1af5a44b32c_80b3f84868c3828485033f@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a4756d27 by Tamar Christina at 2020-07-24T10:52:14-04:00 winio: restore console cp on exit - - - - - 6541b8c1 by Tamar Christina at 2020-07-24T10:52:15-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - 0ed58267 by Simon Peyton Jones at 2020-07-24T10:52:16-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 15 changed files: - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Utils/Unify.hs - includes/HsFFI.h - libraries/base/GHC/Event/Windows.hsc - libraries/base/GHC/Event/Windows/FFI.hsc - rts/RtsStartup.c - rts/win32/veh_excn.c - + testsuite/tests/polykinds/T18451.hs - + testsuite/tests/polykinds/T18451.stderr - + testsuite/tests/polykinds/T18451a.hs - + testsuite/tests/polykinds/T18451a.stderr - + testsuite/tests/polykinds/T18451b.hs - + testsuite/tests/polykinds/T18451b.stderr - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -34,10 +34,9 @@ import {-# SOURCE #-} GHC.CoreToIface , toIfaceTyCon, toIfaceTcArgs, toIfaceCoercionX ) import {-# SOURCE #-} GHC.Core.DataCon - ( dataConFullSig , dataConUserTyVarBinders - , DataCon ) + ( dataConFullSig , dataConUserTyVarBinders, DataCon ) -import GHC.Core.Type ( isLiftedTypeKind, pattern One, pattern Many ) +import GHC.Core.Type ( pickyIsLiftedTypeKind, pattern One, pattern Many ) import GHC.Core.TyCon import GHC.Core.TyCo.Rep @@ -192,11 +191,35 @@ pprTyVar :: TyVar -> SDoc -- pprIfaceTvBndr is minimal, and the loss of uniques etc in -- debug printing is disastrous pprTyVar tv - | isLiftedTypeKind kind = ppr tv - | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) + | pickyIsLiftedTypeKind kind = ppr tv -- See Note [Suppressing * kinds] + | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) where kind = tyVarKind tv +{- Note [Suppressing * kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Generally we want to print + forall a. a->a +not forall (a::*). a->a +or forall (a::Type). a->a +That is, for brevity we suppress a kind ascription of '*' (or Type). + +But what if the kind is (Const Type x)? + type Const p q = p + +Then (Const Type x) is just a long way of saying Type. But it may be +jolly confusing to suppress the 'x'. Suppose we have (polykinds/T18451a) + foo :: forall a b (c :: Const Type b). Proxy '[a, c] + +Then this error message + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) +would be much less helpful if we suppressed the kind ascription on 'a'. + +Hence the use of pickyIsLiftedTypeKind. +-} + ----------------- debugPprType :: Type -> SDoc -- ^ debugPprType is a simple pretty printer that prints a type ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -120,7 +120,7 @@ module GHC.Core.Type ( -- *** Levity and boxity isLiftedType_maybe, - isLiftedTypeKind, isUnliftedTypeKind, + isLiftedTypeKind, isUnliftedTypeKind, pickyIsLiftedTypeKind, isLiftedRuntimeRep, isUnliftedRuntimeRep, isUnliftedType, mightBeUnliftedType, isUnboxedTupleType, isUnboxedSumType, isAlgType, isDataFamilyAppType, @@ -554,6 +554,23 @@ isLiftedTypeKind kind Just rep -> isLiftedRuntimeRep rep Nothing -> False +pickyIsLiftedTypeKind :: Kind -> Bool +-- Checks whether the kind is literally +-- TYPE LiftedRep +-- or Type +-- without expanding type synonyms or anything +-- Used only when deciding whether to suppress the ":: *" in +-- (a :: *) when printing kinded type variables +-- See Note [Suppressing * kinds] in GHC.Core.TyCo.Ppr +pickyIsLiftedTypeKind kind + | TyConApp tc [arg] <- kind + , tc `hasKey` tYPETyConKey + , TyConApp rr_tc [] <- arg + , rr_tc `hasKey` liftedRepDataConKey = True + | TyConApp tc [] <- kind + , tc `hasKey` liftedTypeKindTyConKey = True + | otherwise = False + isLiftedRuntimeRep :: Type -> Bool -- isLiftedRuntimeRep is true of LiftedRep :: RuntimeRep -- False of type variables (a :: RuntimeRep) @@ -2619,6 +2636,46 @@ prefer doing inner expansions first. For example, We have occCheckExpand b (F (G b)) = Just (F Char) even though we could also expand F to get rid of b. + +Note [Occurrence checking: look inside kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we are considering unifying + (alpha :: *) ~ Int -> (beta :: alpha -> alpha) +This may be an error (what is that alpha doing inside beta's kind?), +but we must not make the mistake of actually unifying or we'll +build an infinite data structure. So when looking for occurrences +of alpha in the rhs, we must look in the kinds of type variables +that occur there. + +occCheckExpand tries to expand type synonyms to remove +unnecessary occurrences of a variable, and thereby get past an +occurs-check failure. This is good; but + we can't do it in the /kind/ of a variable /occurrence/ + +For example #18451 built an infinite type: + type Const a b = a + data SameKind :: k -> k -> Type + type T (k :: Const Type a) = forall (b :: k). SameKind a b + +We have + b :: k + k :: Const Type a + a :: k (must be same as b) + +So if we aren't careful, a's kind mentions a, which is bad. +And expanding an /occurrence/ of 'a' doesn't help, because the +/binding site/ is the master copy and all the occurrences should +match it. + +Here's a related example: + f :: forall a b (c :: Const Type b). Proxy '[a, c] + +The list means that 'a' gets the same kind as 'c'; but that +kind mentions 'b', so the binders are out of order. + +Bottom line: in occCheckExpand, do not expand inside the kinds +of occurrences. See bad_var_occ in occCheckExpand. And +see #18451 for more debate. -} occCheckExpand :: [Var] -> Type -> Maybe Type @@ -2639,11 +2696,10 @@ occCheckExpand vs_to_avoid ty -- The VarSet is the set of variables we are trying to avoid -- The VarEnv carries mappings necessary -- because of kind expansion - go cxt@(as, env) (TyVarTy tv') - | tv' `elemVarSet` as = Nothing - | Just tv'' <- lookupVarEnv env tv' = return (mkTyVarTy tv'') - | otherwise = do { tv'' <- go_var cxt tv' - ; return (mkTyVarTy tv'') } + go (as, env) ty@(TyVarTy tv) + | Just tv' <- lookupVarEnv env tv = return (mkTyVarTy tv') + | bad_var_occ as tv = Nothing + | otherwise = return ty go _ ty@(LitTy {}) = return ty go cxt (AppTy ty1 ty2) = do { ty1' <- go cxt ty1 @@ -2656,7 +2712,7 @@ occCheckExpand vs_to_avoid ty ; return (ty { ft_mult = w', ft_arg = ty1', ft_res = ty2' }) } go cxt@(as, env) (ForAllTy (Bndr tv vis) body_ty) = do { ki' <- go cxt (varType tv) - ; let tv' = setVarType tv ki' + ; let tv' = setVarType tv ki' env' = extendVarEnv env tv tv' as' = as `delVarSet` tv ; body' <- go (as', env') body_ty @@ -2680,9 +2736,12 @@ occCheckExpand vs_to_avoid ty ; return (mkCoercionTy co') } ------------------ - go_var cxt v = updateVarTypeM (go cxt) v - -- Works for TyVar and CoVar - -- See Note [Occurrence checking: look inside kinds] + bad_var_occ :: VarSet -> Var -> Bool + -- Works for TyVar and CoVar + -- See Note [Occurrence checking: look inside kinds] + bad_var_occ vs_to_avoid v + = v `elemVarSet` vs_to_avoid + || tyCoVarsOfType (varType v) `intersectsVarSet` vs_to_avoid ------------------ go_mco _ MRefl = return MRefl @@ -2712,13 +2771,15 @@ occCheckExpand vs_to_avoid ty ; co2' <- go_co cxt co2 ; w' <- go_co cxt w ; return (mkFunCo r w' co1' co2') } - go_co cxt@(as,env) (CoVarCo c) - | c `elemVarSet` as = Nothing + go_co (as,env) co@(CoVarCo c) | Just c' <- lookupVarEnv env c = return (mkCoVarCo c') - | otherwise = do { c' <- go_var cxt c - ; return (mkCoVarCo c') } - go_co cxt (HoleCo h) = do { c' <- go_var cxt (ch_co_var h) - ; return (HoleCo (h { ch_co_var = c' })) } + | bad_var_occ as c = Nothing + | otherwise = return co + + go_co (as,_) co@(HoleCo h) + | bad_var_occ as (ch_co_var h) = Nothing + | otherwise = return co + go_co cxt (AxiomInstCo ax ind args) = do { args' <- mapM (go_co cxt) args ; return (mkAxiomInstCo ax ind args') } go_co cxt (UnivCo p r ty1 ty2) = do { p' <- go_prov cxt p ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -1879,21 +1879,8 @@ matchExpectedFunKind hs_ty n k = go n k ********************************************************************* -} -{- Note [Occurrence checking: look inside kinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Suppose we are considering unifying - (alpha :: *) ~ Int -> (beta :: alpha -> alpha) -This may be an error (what is that alpha doing inside beta's kind?), -but we must not make the mistake of actually unifying or we'll -build an infinite data structure. So when looking for occurrences -of alpha in the rhs, we must look in the kinds of type variables -that occur there. - -NB: we may be able to remove the problem via expansion; see - Note [Occurs check expansion]. So we have to try that. - -Note [Checking for foralls] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Checking for foralls] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unless we have -XImpredicativeTypes (which is a totally unsupported feature), we do not want to unify alpha ~ (forall a. a->a) -> Int @@ -1906,10 +1893,10 @@ Consider (alpha :: forall k. k->*) ~ (beta :: forall k. k->*) This is legal; e.g. dependent/should_compile/T11635. -We don't want to reject it because of the forall in beta's kind, -but (see Note [Occurrence checking: look inside kinds]) we do -need to look in beta's kind. So we carry a flag saying if a 'forall' -is OK, and switch the flag on when stepping inside a kind. +We don't want to reject it because of the forall in beta's kind, but +(see Note [Occurrence checking: look inside kinds] in GHC.Core.Type) +we do need to look in beta's kind. So we carry a flag saying if a +'forall' is OK, and switch the flag on when stepping inside a kind. Why is it OK? Why does it not count as impredicative polymorphism? The reason foralls are bad is because we reply on "seeing" foralls @@ -2030,6 +2017,7 @@ preCheck dflags ty_fam_ok tv ty | tv == tv' = MTVU_Occurs | otherwise = fast_check_occ (tyVarKind tv') -- See Note [Occurrence checking: look inside kinds] + -- in GHC.Core.Type fast_check (TyConApp tc tys) | bad_tc tc = MTVU_Bad ===================================== includes/HsFFI.h ===================================== @@ -102,6 +102,7 @@ extern void hs_exit (void); extern void hs_exit_nowait(void); extern void hs_set_argv (int argc, char *argv[]); extern void hs_thread_done (void); +extern void hs_restoreConsoleCP (void); extern void hs_perform_gc (void); ===================================== libraries/base/GHC/Event/Windows.hsc ===================================== @@ -86,7 +86,9 @@ import Data.Foldable (mapM_, length, forM_) import Data.Maybe (isJust, maybe) import GHC.Event.Windows.Clock (Clock, Seconds, getClock, getTime) -import GHC.Event.Windows.FFI (LPOVERLAPPED, OVERLAPPED_ENTRY(..)) +import GHC.Event.Windows.FFI (LPOVERLAPPED, OVERLAPPED_ENTRY(..), + CompletionData(..), CompletionCallback, + withRequest) import GHC.Event.Windows.ManagedThreadPool import GHC.Event.Internal.Types import GHC.Event.Unique @@ -300,43 +302,6 @@ foreign import ccall safe "completeSynchronousRequest" ------------------------------------------------------------------------ -- Manager structures --- | Callback type that will be called when an I/O operation completes. -type IOCallback = CompletionCallback () - --- | Wrap the IOCallback type into a FunPtr. -foreign import ccall "wrapper" - wrapIOCallback :: IOCallback -> IO (FunPtr IOCallback) - --- | Unwrap a FunPtr IOCallback to a normal Haskell function. -foreign import ccall "dynamic" - mkIOCallback :: FunPtr IOCallback -> IOCallback - --- | Structure that the I/O manager uses to associate callbacks with --- additional payload such as their OVERLAPPED structure and Win32 handle --- etc. *Must* be kept in sync with that in `winio_structs.h` or horrible things --- happen. --- --- We keep the handle around for the benefit of ghc-external libraries making --- use of the manager. -data CompletionData = CompletionData { cdHandle :: !HANDLE - , cdCallback :: !IOCallback - } - -instance Storable CompletionData where - sizeOf _ = #{size CompletionData} - alignment _ = #{alignment CompletionData} - - peek ptr = do - cdCallback <- mkIOCallback `fmap` #{peek CompletionData, cdCallback} ptr - cdHandle <- #{peek CompletionData, cdHandle} ptr - let !cd = CompletionData{..} - return cd - - poke ptr CompletionData{..} = do - cb <- wrapIOCallback cdCallback - #{poke CompletionData, cdCallback} ptr cb - #{poke CompletionData, cdHandle} ptr cdHandle - -- | Pointer offset in bytes to the location of hoData in HASKELL_OVERLAPPPED cdOffset :: Int cdOffset = #{const __builtin_offsetof (HASKELL_OVERLAPPED, hoData)} @@ -507,11 +472,6 @@ data CbResult a -- manager will perform additional checks. deriving Show --- | Called when the completion is delivered. -type CompletionCallback a = ErrCode -- ^ 0 indicates success - -> DWORD -- ^ Number of bytes transferred - -> IO a - -- | Associate a 'HANDLE' with the current I/O manager's completion port. -- This must be done before using the handle with 'withOverlapped'. associateHandle' :: HANDLE -> IO () @@ -581,23 +541,18 @@ withOverlappedEx mgr fname h offset startCB completionCB = do signalThrow ex = failIfFalse_ (dbgMsg "signalThrow") $ writeIOPort signal (IOFailed ex) mask_ $ do - let completionCB' e b = completionCB e b >>= \result -> - case result of - IOSuccess val -> signalReturn val - IOFailed err -> signalThrow err - hs_lpol <- FFI.allocOverlapped offset - -- Create the completion record and store it. - -- We only need the record when we enqueue a request, however if we - -- delay creating it then we will run into a race condition where the - -- driver may have finished servicing the request before we were ready - -- and so the request won't have the book keeping information to know - -- what to do. So because of that we always create the payload, If we - -- need it ok, if we don't that's no problem. This approach prevents - -- expensive lookups in hash-tables. - -- - -- Todo: Use a memory pool for this so we don't have to hit malloc every - -- time. This would allow us to scale better. - cdData <- new (CompletionData h completionCB') :: IO (Ptr CompletionData) + let completionCB' e b = completionCB e b >>= \result -> + case result of + IOSuccess val -> signalReturn val + IOFailed err -> signalThrow err + let callbackData = CompletionData h completionCB' + -- Note [Memory Management] + -- These callback data and especially the overlapped structs have to keep + -- alive throughout the entire lifetime of the requests. Since this + -- function will block until done so it can call completionCB at the end + -- we can safely use dynamic memory management here and so reduce the + -- possibility of memory errors. + withRequest offset callbackData $ \hs_lpol cdData -> do let ptr_lpol = hs_lpol `plusPtr` cdOffset let lpol = castPtr hs_lpol debugIO $ "hs_lpol:" ++ show hs_lpol @@ -713,11 +668,8 @@ withOverlappedEx mgr fname h offset startCB completionCB = do debugIO $ "## Waiting for cancellation record... " _ <- FFI.getOverlappedResult h lpol True oldDataPtr <- exchangePtr ptr_lpol nullReq - -- Check if we have to free and cleanup pointer when (oldDataPtr == cdData) $ - do free oldDataPtr - free hs_lpol - reqs <- removeRequest + do reqs <- removeRequest debugIO $ "-1.. " ++ show reqs ++ " requests queued after error." status <- fmap fromIntegral getLastError completionCB' status 0 @@ -741,7 +693,6 @@ withOverlappedEx mgr fname h offset startCB completionCB = do case startCBResult of CbPending -> runner CbDone rdata -> do - free cdData debugIO $ dbgMsg $ ":: done " ++ show lpol ++ " - " ++ show rdata bytes <- if isJust rdata then return rdata @@ -749,23 +700,18 @@ withOverlappedEx mgr fname h offset startCB completionCB = do else FFI.getOverlappedResult h lpol False debugIO $ dbgMsg $ ":: done bytes: " ++ show bytes case bytes of - Just res -> free hs_lpol >> completionCB 0 res + Just res -> completionCB 0 res Nothing -> do err <- FFI.overlappedIOStatus lpol numBytes <- FFI.overlappedIONumBytes lpol -- TODO: Remap between STATUS_ and ERROR_ instead -- of re-interpret here. But for now, don't care. let err' = fromIntegral err - free hs_lpol debugIO $ dbgMsg $ ":: done callback: " ++ show err' ++ " - " ++ show numBytes completionCB err' (fromIntegral numBytes) CbError err -> do - free cdData - free hs_lpol let err' = fromIntegral err completionCB err' 0 _ -> do - free cdData - free hs_lpol error "unexpected case in `startCBResult'" where dbgMsg s = s ++ " (" ++ show h ++ ":" ++ show offset ++ ")" -- Wait for .25ms (threaded) and 1ms (non-threaded) @@ -1099,15 +1045,17 @@ processCompletion Manager{..} n delay = do do debugIO $ "exchanged: " ++ show oldDataPtr payload <- peek oldDataPtr :: IO CompletionData let !cb = cdCallback payload - free oldDataPtr reqs <- removeRequest debugIO $ "-1.. " ++ show reqs ++ " requests queued." status <- FFI.overlappedIOStatus (lpOverlapped oe) -- TODO: Remap between STATUS_ and ERROR_ instead -- of re-interpret here. But for now, don't care. let status' = fromIntegral status + -- We no longer explicitly free the memory, this is because we + -- now require the callback to free the memory since the + -- callback allocated it. This allows us to simplify memory + -- management and reduce bugs. See Note [Memory Management]. cb status' (dwNumberOfBytesTransferred oe) - free hs_lpol -- clear the array so we don't erroneously interpret the output, in -- certain circumstances like lockFileEx the code could return 1 entry ===================================== libraries/base/GHC/Event/Windows/FFI.hsc ===================================== @@ -30,6 +30,11 @@ module GHC.Event.Windows.FFI ( postQueuedCompletionStatus, getOverlappedResult, + -- * Completion Data + CompletionData(..), + CompletionCallback, + withRequest, + -- * Overlapped OVERLAPPED, LPOVERLAPPED, @@ -215,6 +220,51 @@ postQueuedCompletionStatus iocp numBytes completionKey lpol = failIfFalse_ "PostQueuedCompletionStatus" $ c_PostQueuedCompletionStatus iocp numBytes completionKey lpol +------------------------------------------------------------------------ +-- Completion Data + +-- | Called when the completion is delivered. +type CompletionCallback a = ErrCode -- ^ 0 indicates success + -> DWORD -- ^ Number of bytes transferred + -> IO a + +-- | Callback type that will be called when an I/O operation completes. +type IOCallback = CompletionCallback () + +-- | Wrap the IOCallback type into a FunPtr. +foreign import ccall "wrapper" + wrapIOCallback :: IOCallback -> IO (FunPtr IOCallback) + +-- | Unwrap a FunPtr IOCallback to a normal Haskell function. +foreign import ccall "dynamic" + mkIOCallback :: FunPtr IOCallback -> IOCallback + +-- | Structure that the I/O manager uses to associate callbacks with +-- additional payload such as their OVERLAPPED structure and Win32 handle +-- etc. *Must* be kept in sync with that in `winio_structs.h` or horrible things +-- happen. +-- +-- We keep the handle around for the benefit of ghc-external libraries making +-- use of the manager. +data CompletionData = CompletionData { cdHandle :: !HANDLE + , cdCallback :: !IOCallback + } + +instance Storable CompletionData where + sizeOf _ = #{size CompletionData} + alignment _ = #{alignment CompletionData} + + peek ptr = do + cdCallback <- mkIOCallback `fmap` #{peek CompletionData, cdCallback} ptr + cdHandle <- #{peek CompletionData, cdHandle} ptr + let !cd = CompletionData{..} + return cd + + poke ptr CompletionData{..} = do + cb <- wrapIOCallback cdCallback + #{poke CompletionData, cdCallback} ptr cb + #{poke CompletionData, cdHandle} ptr cdHandle + ------------------------------------------------------------------------ -- Overlapped @@ -293,6 +343,30 @@ pokeOffsetOverlapped lpol offset = do #{poke OVERLAPPED, OffsetHigh} lpol offsetHigh {-# INLINE pokeOffsetOverlapped #-} +------------------------------------------------------------------------ +-- Request management + +withRequest :: Word64 -> CompletionData + -> (Ptr HASKELL_OVERLAPPED -> Ptr CompletionData -> IO a) + -> IO a +withRequest offset cbData f = + -- Create the completion record and store it. + -- We only need the record when we enqueue a request, however if we + -- delay creating it then we will run into a race condition where the + -- driver may have finished servicing the request before we were ready + -- and so the request won't have the book keeping information to know + -- what to do. So because of that we always create the payload, If we + -- need it ok, if we don't that's no problem. This approach prevents + -- expensive lookups in hash-tables. + -- + -- Todo: Use a memory pool for this so we don't have to hit malloc every + -- time. This would allow us to scale better. + allocaBytes #{size HASKELL_OVERLAPPED} $ \hs_lpol -> + with cbData $ \cdData -> do + zeroOverlapped hs_lpol + pokeOffsetOverlapped (castPtr hs_lpol) offset + f hs_lpol cdData + ------------------------------------------------------------------------ -- Cancel pending I/O ===================================== rts/RtsStartup.c ===================================== @@ -68,6 +68,11 @@ static int hs_init_count = 0; static bool rts_shutdown = false; +#if defined(mingw32_HOST_OS) +/* Indicates CodePage to set program to after exit. */ +static int64_t __codePage = 0; +#endif + static void flushStdHandles(void); /* ----------------------------------------------------------------------------- @@ -128,13 +133,38 @@ void fpreset(void) { static void initConsoleCP (void) { + /* Set the initial codepage to automatic. */ + __codePage = -1; + /* Check if the codepage is still the system default ANSI codepage. */ - if (GetConsoleCP () == GetOEMCP ()) { - if (! SetConsoleCP (CP_UTF8)) + if (GetConsoleCP () == GetOEMCP () + && GetConsoleOutputCP () == GetOEMCP ()) { + if (!SetConsoleCP (CP_UTF8) || !SetConsoleOutputCP (CP_UTF8)) errorBelch ("Unable to set console CodePage, Unicode output may be " "garbled.\n"); else IF_DEBUG (scheduler, debugBelch ("Codepage set to UTF-8.\n")); + + /* Assign the codepage so we can restore it on exit. */ + __codePage = (int64_t)GetOEMCP (); + } +} + +/* Restore the CodePage to what it was before we started. If the CodePage was + already set then this call is a no-op. */ +void +hs_restoreConsoleCP (void) +{ + /* If we set the CP at startup, we should set it on exit. */ + if (__codePage == -1) + return; + + UINT cp = (UINT)__codePage; + __codePage = -1; + if (SetConsoleCP (cp) && SetConsoleOutputCP (cp)) { + IF_DEBUG (scheduler, debugBelch ("Codepage restored to OEM.\n")); + } else { + IF_DEBUG (scheduler, debugBelch ("Unable to restore CodePage to OEM.\n")); } } #endif @@ -533,6 +563,11 @@ hs_exit_(bool wait_foreign) shutdownAsyncIO(wait_foreign); #endif + /* Restore the console Codepage. */ +#if defined(mingw32_HOST_OS) + if (is_io_mng_native_p()) + hs_restoreConsoleCP(); +#endif /* free hash table storage */ exitHashTable(); ===================================== rts/win32/veh_excn.c ===================================== @@ -153,6 +153,7 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data) if (EXCEPTION_CONTINUE_EXECUTION == action) { fflush(stderr); + hs_restoreConsoleCP (); generateStack (exception_data); generateDump (exception_data); stg_exit(exit_code); ===================================== testsuite/tests/polykinds/T18451.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind + +type Const a b = a +data SameKind :: k -> k -> Type + +type T (k :: Const Type a) = forall (b :: k). SameKind a b ===================================== testsuite/tests/polykinds/T18451.stderr ===================================== @@ -0,0 +1,9 @@ + +T18451.hs:10:58: error: + • Expected kind ‘k0’, but ‘b’ has kind ‘k’ + • In the second argument of ‘SameKind’, namely ‘b’ + In the type ‘forall (b :: k). SameKind a b’ + In the type declaration for ‘T’ + • Type variable kinds: + a :: k0 + k :: Const (*) a ===================================== testsuite/tests/polykinds/T18451a.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451a.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/T18451b.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451b.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451b.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -220,3 +220,6 @@ test('CuskFam', normal, compile, ['']) test('T17841', normal, compile_fail, ['']) test('T17963', normal, compile_fail, ['']) test('T18300', normal, compile_fail, ['']) +test('T18451', normal, compile_fail, ['']) +test('T18451a', normal, compile_fail, ['']) +test('T18451b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f5c95a237888ab120c25ef7b73d22c108ad3596d...0ed582676566f5d8ef6edff4a0ee5517f5c90d4a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f5c95a237888ab120c25ef7b73d22c108ad3596d...0ed582676566f5d8ef6edff4a0ee5517f5c90d4a You're receiving 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 Jul 24 14:58:02 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 24 Jul 2020 10:58:02 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18202-simplifier Message-ID: <5f1af6faee0a6_80b3f849248fe08485561@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T18202-simplifier at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18202-simplifier You're receiving 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 Jul 24 16:42:41 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 24 Jul 2020 12:42:41 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18494 Message-ID: <5f1b0f8197cc2_80b114037a448716a4@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T18494 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18494 You're receiving 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 Jul 24 16:44:39 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 24 Jul 2020 12:44:39 -0400 Subject: [Git][ghc/ghc][wip/T18494] Kill off sc_mult and as_mult fields Message-ID: <5f1b0ff749b30_80b10251024487324@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18494 at Glasgow Haskell Compiler / GHC Commits: 4e3a0d55 by Simon Peyton Jones at 2020-07-24T17:44:03+01:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - 2 changed files: - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -1002,7 +1002,7 @@ simplExprF1 env (App fun arg) cont , sc_hole_ty = hole' , sc_cont = cont } } _ -> - -- crucially, these are /lazy/ bindings. They will + -- Crucially, sc_hole_ty is a /lazy/ binding. It will -- be forced only if we need to run contHoleType. -- When these are forced, we might get quadratic behavior; -- this quadratic blowup could be avoided by drilling down @@ -1010,13 +1010,10 @@ simplExprF1 env (App fun arg) cont -- (instead of one-at-a-time). But in practice, we have not -- observed the quadratic behavior, so this extra entanglement -- seems not worthwhile. - let fun_ty = exprType fun - (m, _, _) = splitFunTy fun_ty - in simplExprF env fun $ ApplyToVal { sc_arg = arg, sc_env = env , sc_hole_ty = substTy env (exprType fun) - , sc_dup = NoDup, sc_cont = cont, sc_mult = m } + , sc_dup = NoDup, sc_cont = cont } simplExprF1 env expr@(Lam {}) cont = {-#SCC "simplExprF1-Lam" #-} @@ -1321,8 +1318,8 @@ rebuild env expr cont Select { sc_bndr = bndr, sc_alts = alts, sc_env = se, sc_cont = cont } -> rebuildCase (se `setInScopeFromE` env) expr bndr alts cont - StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty, sc_mult = m } - -> rebuildCall env (addValArgTo fun (m, expr) fun_ty ) cont + StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty } + -> rebuildCall env (addValArgTo fun expr fun_ty ) cont StrictBind { sc_bndr = b, sc_bndrs = bs, sc_body = body , sc_env = se, sc_cont = cont } -> do { (floats1, env') <- simplNonRecX (se `setInScopeFromE` env) b expr @@ -1414,7 +1411,7 @@ simplCast env body co0 cont0 -- co1 :: t1 ~ s1 -- co2 :: s2 ~ t2 addCoerce co cont@(ApplyToVal { sc_arg = arg, sc_env = arg_se - , sc_dup = dup, sc_cont = tail, sc_mult = m }) + , sc_dup = dup, sc_cont = tail }) | Just (co1, m_co2) <- pushCoValArg co , let new_ty = coercionRKind co1 , not (isTypeLevPoly new_ty) -- Without this check, we get a lev-poly arg @@ -1438,8 +1435,7 @@ simplCast env body co0 cont0 , sc_env = arg_se' , sc_dup = dup' , sc_cont = tail' - , sc_hole_ty = coercionLKind co - , sc_mult = m }) } } + , sc_hole_ty = coercionLKind co }) } } addCoerce co cont | isReflexiveCo co = return cont -- Having this at the end makes a huge @@ -1975,17 +1971,18 @@ rebuildCall env info (ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_c -- runRW# :: forall (r :: RuntimeRep) (o :: TYPE r). (State# RealWorld -> o) -> o -- K[ runRW# rr ty body ] --> runRW rr' ty' (\s. K[ body s ]) rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args }) - (ApplyToVal { sc_arg = arg, sc_env = arg_se, sc_cont = cont, sc_mult = m }) + (ApplyToVal { sc_arg = arg, sc_env = arg_se + , sc_cont = cont, sc_hole_ty = fun_ty }) | fun `hasKey` runRWKey , not (contIsStop cont) -- Don't fiddle around if the continuation is boring , [ TyArg {}, TyArg {} ] <- rev_args = do { s <- newId (fsLit "s") Many realWorldStatePrimTy - ; let env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] + ; let (m,_,_) = splitFunTy fun_ty + env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] ty' = contResultType cont cont' = ApplyToVal { sc_dup = Simplified, sc_arg = Var s , sc_env = env', sc_cont = cont - , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' - , sc_mult = m } + , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' } -- cont' applies to s, then K ; body' <- simplExprC env' arg cont' ; let arg' = Lam s body' @@ -1997,10 +1994,10 @@ rebuildCall env info@(ArgInfo { ai_encl = encl_rules , ai_strs = str:strs, ai_discs = disc:discs }) (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_dup = dup_flag, sc_hole_ty = fun_ty - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Argument is already simplified | isSimplified dup_flag -- See Note [Avoid redundant simplification] - = rebuildCall env (addValArgTo info' (m, arg) fun_ty) cont + = rebuildCall env (addValArgTo info' arg fun_ty) cont -- Strict arguments | str @@ -2009,7 +2006,7 @@ rebuildCall env info@(ArgInfo { ai_encl = encl_rules simplExprF (arg_se `setInScopeFromE` env) arg (StrictArg { sc_fun = info', sc_cci = cci_strict , sc_dup = Simplified, sc_fun_ty = fun_ty - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Note [Shadowing] -- Lazy arguments @@ -2020,7 +2017,7 @@ rebuildCall env info@(ArgInfo { ai_encl = encl_rules -- floating a demanded let. = do { arg' <- simplExprC (arg_se `setInScopeFromE` env) arg (mkLazyArgStop arg_ty cci_lazy) - ; rebuildCall env (addValArgTo info' (m, arg') fun_ty) cont } + ; rebuildCall env (addValArgTo info' arg' fun_ty) cont } where info' = info { ai_strs = strs, ai_discs = discs } arg_ty = funArgTy fun_ty @@ -2243,8 +2240,7 @@ trySeqRules in_env scrut rhs cont , TyArg { as_arg_ty = rhs_ty , as_hole_ty = res2_ty } , ValArg { as_arg = no_cast_scrut - , as_hole_ty = res3_ty - , as_mult = Many } ] + , as_hole_ty = res3_ty } ] -- The multiplicity of the scrutiny above is Many because the type -- of seq requires that its first argument is unrestricted. The -- typing rule of case also guarantees it though. In a more @@ -2253,7 +2249,9 @@ trySeqRules in_env scrut rhs cont -- the case (held in the case binder) instead. rule_cont = ApplyToVal { sc_dup = NoDup, sc_arg = rhs , sc_env = in_env, sc_cont = cont - , sc_hole_ty = res4_ty, sc_mult = Many } + , sc_hole_ty = res4_ty } + + -- TODO: what should this comment now say? -- The multiplicity in sc_mult above is the -- multiplicity of the second argument of seq. Since -- seq's type, as it stands, imposes that its second @@ -3318,7 +3316,7 @@ mkDupableCont env (StrictBind { sc_bndr = bndr, sc_bndrs = bndrs , sc_cont = mkBoringStop res_ty } ) } mkDupableCont env (StrictArg { sc_fun = info, sc_cci = cci - , sc_cont = cont, sc_fun_ty = fun_ty, sc_mult = m }) + , sc_cont = cont, sc_fun_ty = fun_ty }) -- See Note [Duplicating StrictArg] -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable = do { (floats1, cont') <- mkDupableCont env cont @@ -3329,7 +3327,6 @@ mkDupableCont env (StrictArg { sc_fun = info, sc_cci = cci , sc_cont = cont' , sc_cci = cci , sc_fun_ty = fun_ty - , sc_mult = m , sc_dup = OkToDup} ) } mkDupableCont env (ApplyToTy { sc_cont = cont @@ -3340,7 +3337,7 @@ mkDupableCont env (ApplyToTy { sc_cont = cont mkDupableCont env (ApplyToVal { sc_arg = arg, sc_dup = dup , sc_env = se, sc_cont = cont - , sc_hole_ty = hole_ty, sc_mult = mult }) + , sc_hole_ty = hole_ty }) = -- e.g. [...hole...] (...arg...) -- ==> -- let a = ...arg... @@ -3359,7 +3356,7 @@ mkDupableCont env (ApplyToVal { sc_arg = arg, sc_dup = dup -- has turned arg'' into a fresh variable -- See Note [StaticEnv invariant] in GHC.Core.Opt.Simplify.Utils , sc_dup = OkToDup, sc_cont = cont' - , sc_hole_ty = hole_ty, sc_mult = mult }) } + , sc_hole_ty = hole_ty }) } mkDupableCont env (Select { sc_bndr = case_bndr, sc_alts = alts , sc_env = se, sc_cont = cont }) ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -124,8 +124,7 @@ data SimplCont -- See Note [The hole type in ApplyToTy/Val] , sc_arg :: InExpr -- The argument, , sc_env :: StaticEnv -- see Note [StaticEnv invariant] - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | ApplyToTy -- (ApplyToTy ty K)[e] = K[ e ty ] { sc_arg_ty :: OutType -- Argument type @@ -158,8 +157,7 @@ data SimplCont , sc_fun_ty :: OutType -- Type of the function (f e1 .. en), -- presumably (arg_ty -> res_ty) -- where res_ty is expected by sc_cont - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | TickIt -- (TickIt t K)[e] = K[ tick t e ] (Tickish Id) -- Tick tickish @@ -278,23 +276,22 @@ data ArgInfo } data ArgSpec - = ValArg { as_mult :: Mult - , as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal + = ValArg { as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal , as_hole_ty :: OutType } -- Type of the function (presumably t1 -> t2) | TyArg { as_arg_ty :: OutType -- Apply to this type; c.f. ApplyToTy , as_hole_ty :: OutType } -- Type of the function (presumably forall a. blah) | CastBy OutCoercion -- Cast by this; c.f. CastIt instance Outputable ArgSpec where - ppr (ValArg { as_mult = mult, as_arg = arg }) = text "ValArg" <+> ppr mult <+> ppr arg + ppr (ValArg { as_arg = arg }) = text "ValArg" <+> ppr arg ppr (TyArg { as_arg_ty = ty }) = text "TyArg" <+> ppr ty ppr (CastBy c) = text "CastBy" <+> ppr c -addValArgTo :: ArgInfo -> (Mult, OutExpr) -> OutType -> ArgInfo -addValArgTo ai (w, arg) hole_ty = ai { ai_args = arg_spec : ai_args ai - , ai_rules = decRules (ai_rules ai) } +addValArgTo :: ArgInfo -> OutExpr -> OutType -> ArgInfo +addValArgTo ai arg hole_ty = ai { ai_args = arg_spec : ai_args ai + , ai_rules = decRules (ai_rules ai) } where - arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty, as_mult = w } + arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty } addTyArgTo :: ArgInfo -> OutType -> OutType -> ArgInfo addTyArgTo ai arg_ty hole_ty = ai { ai_args = arg_spec : ai_args ai @@ -317,9 +314,9 @@ pushSimplifiedArgs env (arg : args) k = case arg of TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } -> ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = rest } - ValArg { as_arg = arg, as_hole_ty = hole_ty, as_mult = w } + ValArg { as_arg = arg, as_hole_ty = hole_ty } -> ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified - , sc_hole_ty = hole_ty, sc_cont = rest, sc_mult = w } + , sc_hole_ty = hole_ty, sc_cont = rest } CastBy c -> CastIt c rest where rest = pushSimplifiedArgs env args k @@ -418,7 +415,7 @@ contHoleType (TickIt _ k) = contHoleType k contHoleType (CastIt co _) = coercionLKind co contHoleType (StrictBind { sc_bndr = b, sc_dup = dup, sc_env = se }) = perhapsSubstTy dup se (idType b) -contHoleType (StrictArg { sc_fun_ty = ty, sc_mult = _m }) = funArgTy ty +contHoleType (StrictArg { sc_fun_ty = ty }) = funArgTy ty contHoleType (ApplyToTy { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy] contHoleType (ApplyToVal { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy/Val] contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) @@ -436,12 +433,14 @@ contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) contHoleScaling :: SimplCont -> Mult contHoleScaling (Stop _ _) = One contHoleScaling (CastIt _ k) = contHoleScaling k -contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k -contHoleScaling (StrictArg { sc_mult = w, sc_cont = k }) = - w `mkMultMul` contHoleScaling k -contHoleScaling (Select { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k +contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (Select { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (StrictArg { sc_fun_ty = fun_ty, sc_cont = k }) + = w `mkMultMul` contHoleScaling k + where + (w, _, _) = splitFunTy fun_ty contHoleScaling (ApplyToTy { sc_cont = k }) = contHoleScaling k contHoleScaling (ApplyToVal { sc_cont = k }) = contHoleScaling k contHoleScaling (TickIt _ k) = contHoleScaling k View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4e3a0d55c0eba5d53c89a0eb9f021b2f4e55384e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4e3a0d55c0eba5d53c89a0eb9f021b2f4e55384e You're receiving 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 Jul 24 18:47:41 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Fri, 24 Jul 2020 14:47:41 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] Fix cpp redefinition warnings Message-ID: <5f1b2ccdb43f3_80b3f84925412344881465@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: f45bfdd1 by Sven Tennie at 2020-07-24T20:47:23+02:00 Fix cpp redefinition warnings With --Werror this made the build fail. - - - - - 1 changed file: - libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc Changes: ===================================== libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc ===================================== @@ -12,6 +12,9 @@ module GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled( #define PROFILING #include "Rts.h" +#undef BLOCK_SIZE +#undef MBLOCK_SIZE +#undef BLOCKS_PER_MBLOCK #include "DerivedConstants.h" import Prelude View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f45bfdd12e456f248ebde8a5cec0435aa9d5e396 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f45bfdd12e456f248ebde8a5cec0435aa9d5e396 You're receiving 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 Jul 24 20:57:14 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 24 Jul 2020 16:57:14 -0400 Subject: [Git][ghc/ghc][wip/T13253] 25 commits: Fix dead link to haskell prime discussion Message-ID: <5f1b4b2ace5c6_80b114037a4488379b@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC Commits: 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - df18a355 by Simon Peyton Jones at 2020-07-24T21:56:39+01:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes two significant changes: 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Then in postInlineUnconditionally use that info to avoid inling something many many times. Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally See Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils 2. Change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg] Current nofib run Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- VS -0.3% +115.9% +12.1% +11.2% 0.0% boyer2 -0.3% +10.0% +3.5% +4.0% 0.0% cryptarithm2 -0.3% +39.0% +16.6% +16.1% 0.0% gamteb -0.3% +4.1% -0.0% +0.4% 0.0% last-piece -0.3% +1.4% -1.1% -0.4% 0.0% mate -0.4% -11.1% -8.5% -9.0% 0.0% multiplier -0.3% -2.2% -1.5% -1.5% 0.0% transform -0.3% +3.4% +0.5% +0.8% 0.0% -------------------------------------------------------------------------------- Min -0.8% -11.1% -8.5% -9.0% 0.0% Max -0.3% +115.9% +30.1% +26.4% 0.0% Geometric Mean -0.3% +1.0% +1.0% +1.0% -0.0% Should investigate these numbers. But the tickets are indeed cured, I think. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/StringBuffer.hs - + compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1cfa23cd991315275214e36d5819d8791b31e323...df18a3552f2429b7bae81397cd02e6274481398c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1cfa23cd991315275214e36d5819d8791b31e323...df18a3552f2429b7bae81397cd02e6274481398c You're receiving 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 Jul 24 21:14:17 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 24 Jul 2020 17:14:17 -0400 Subject: [Git][ghc/ghc][wip/T18202-simplifier] Eta-expand the Simplifier monad Message-ID: <5f1b4f294bd63_80b10251024488529d@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18202-simplifier at Glasgow Haskell Compiler / GHC Commits: 07250e72 by Simon Peyton Jones at 2020-07-24T22:10:31+01:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 1 changed file: - compiler/GHC/Core/Opt/Simplify/Monad.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Monad.hs ===================================== @@ -43,6 +43,7 @@ import GHC.Utils.Panic (throwGhcExceptionIO, GhcException (..)) import GHC.Types.Basic ( IntWithInf, treatZeroAsInf, mkIntWithInf ) import Control.Monad ( ap ) import GHC.Core.Multiplicity ( pattern Many ) +import GHC.Exts( oneShot ) {- ************************************************************************ @@ -56,14 +57,25 @@ For the simplifier monad, we want to {\em thread} a unique supply and a counter. -} newtype SimplM result - = SM { unSM :: SimplTopEnv -- Envt that does not change much - -> UniqSupply -- We thread the unique supply because - -- constantly splitting it is rather expensive - -> SimplCount - -> IO (result, UniqSupply, SimplCount)} - -- we only need IO here for dump output + = SM' { unSM :: SimplTopEnv -- Envt that does not change much + -> UniqSupply -- We thread the unique supply because + -- constantly splitting it is rather expensive + -> SimplCount + -> IO (result, UniqSupply, SimplCount)} + -- We only need IO here for dump output deriving (Functor) +pattern SM :: (SimplTopEnv -> UniqSupply -> SimplCount + -> IO (result, UniqSupply, SimplCount)) + -> SimplM result +-- This pattern synonym makes the simplifier monad eta-expand, +-- which as a very beneficial effect on compiler performance +-- (worth a 1-2% reduction in bytes-allocated). See #18202. +-- See Note [The one-shot state monad trick] in GHC.Core.Unify +pattern SM m <- SM' m + where + SM m = SM' (oneShot m) + data SimplTopEnv = STE { st_flags :: DynFlags , st_max_ticks :: IntWithInf -- Max #ticks in this simplifier run View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07250e72b1f3c9db1cb84f1904a477f97cd13da0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07250e72b1f3c9db1cb84f1904a477f97cd13da0 You're receiving 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 Jul 24 22:12:30 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 24 Jul 2020 18:12:30 -0400 Subject: [Git][ghc/ghc][master] winio: restore console cp on exit Message-ID: <5f1b5cce238ef_80b3f84962c9cf048868c3@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - 3 changed files: - includes/HsFFI.h - rts/RtsStartup.c - rts/win32/veh_excn.c Changes: ===================================== includes/HsFFI.h ===================================== @@ -102,6 +102,7 @@ extern void hs_exit (void); extern void hs_exit_nowait(void); extern void hs_set_argv (int argc, char *argv[]); extern void hs_thread_done (void); +extern void hs_restoreConsoleCP (void); extern void hs_perform_gc (void); ===================================== rts/RtsStartup.c ===================================== @@ -68,6 +68,11 @@ static int hs_init_count = 0; static bool rts_shutdown = false; +#if defined(mingw32_HOST_OS) +/* Indicates CodePage to set program to after exit. */ +static int64_t __codePage = 0; +#endif + static void flushStdHandles(void); /* ----------------------------------------------------------------------------- @@ -128,13 +133,38 @@ void fpreset(void) { static void initConsoleCP (void) { + /* Set the initial codepage to automatic. */ + __codePage = -1; + /* Check if the codepage is still the system default ANSI codepage. */ - if (GetConsoleCP () == GetOEMCP ()) { - if (! SetConsoleCP (CP_UTF8)) + if (GetConsoleCP () == GetOEMCP () + && GetConsoleOutputCP () == GetOEMCP ()) { + if (!SetConsoleCP (CP_UTF8) || !SetConsoleOutputCP (CP_UTF8)) errorBelch ("Unable to set console CodePage, Unicode output may be " "garbled.\n"); else IF_DEBUG (scheduler, debugBelch ("Codepage set to UTF-8.\n")); + + /* Assign the codepage so we can restore it on exit. */ + __codePage = (int64_t)GetOEMCP (); + } +} + +/* Restore the CodePage to what it was before we started. If the CodePage was + already set then this call is a no-op. */ +void +hs_restoreConsoleCP (void) +{ + /* If we set the CP at startup, we should set it on exit. */ + if (__codePage == -1) + return; + + UINT cp = (UINT)__codePage; + __codePage = -1; + if (SetConsoleCP (cp) && SetConsoleOutputCP (cp)) { + IF_DEBUG (scheduler, debugBelch ("Codepage restored to OEM.\n")); + } else { + IF_DEBUG (scheduler, debugBelch ("Unable to restore CodePage to OEM.\n")); } } #endif @@ -533,6 +563,11 @@ hs_exit_(bool wait_foreign) shutdownAsyncIO(wait_foreign); #endif + /* Restore the console Codepage. */ +#if defined(mingw32_HOST_OS) + if (is_io_mng_native_p()) + hs_restoreConsoleCP(); +#endif /* free hash table storage */ exitHashTable(); ===================================== rts/win32/veh_excn.c ===================================== @@ -153,6 +153,7 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data) if (EXCEPTION_CONTINUE_EXECUTION == action) { fflush(stderr); + hs_restoreConsoleCP (); generateStack (exception_data); generateDump (exception_data); stg_exit(exit_code); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdd0ff16f20ce920c74f9128a1067cbe1bd378c2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdd0ff16f20ce920c74f9128a1067cbe1bd378c2 You're receiving 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 Jul 24 22:13:06 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 24 Jul 2020 18:13:06 -0400 Subject: [Git][ghc/ghc][master] winio: change memory allocation strategy and fix double free errors. Message-ID: <5f1b5cf250ea_80b104edf444888975@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - 2 changed files: - libraries/base/GHC/Event/Windows.hsc - libraries/base/GHC/Event/Windows/FFI.hsc Changes: ===================================== libraries/base/GHC/Event/Windows.hsc ===================================== @@ -86,7 +86,9 @@ import Data.Foldable (mapM_, length, forM_) import Data.Maybe (isJust, maybe) import GHC.Event.Windows.Clock (Clock, Seconds, getClock, getTime) -import GHC.Event.Windows.FFI (LPOVERLAPPED, OVERLAPPED_ENTRY(..)) +import GHC.Event.Windows.FFI (LPOVERLAPPED, OVERLAPPED_ENTRY(..), + CompletionData(..), CompletionCallback, + withRequest) import GHC.Event.Windows.ManagedThreadPool import GHC.Event.Internal.Types import GHC.Event.Unique @@ -300,43 +302,6 @@ foreign import ccall safe "completeSynchronousRequest" ------------------------------------------------------------------------ -- Manager structures --- | Callback type that will be called when an I/O operation completes. -type IOCallback = CompletionCallback () - --- | Wrap the IOCallback type into a FunPtr. -foreign import ccall "wrapper" - wrapIOCallback :: IOCallback -> IO (FunPtr IOCallback) - --- | Unwrap a FunPtr IOCallback to a normal Haskell function. -foreign import ccall "dynamic" - mkIOCallback :: FunPtr IOCallback -> IOCallback - --- | Structure that the I/O manager uses to associate callbacks with --- additional payload such as their OVERLAPPED structure and Win32 handle --- etc. *Must* be kept in sync with that in `winio_structs.h` or horrible things --- happen. --- --- We keep the handle around for the benefit of ghc-external libraries making --- use of the manager. -data CompletionData = CompletionData { cdHandle :: !HANDLE - , cdCallback :: !IOCallback - } - -instance Storable CompletionData where - sizeOf _ = #{size CompletionData} - alignment _ = #{alignment CompletionData} - - peek ptr = do - cdCallback <- mkIOCallback `fmap` #{peek CompletionData, cdCallback} ptr - cdHandle <- #{peek CompletionData, cdHandle} ptr - let !cd = CompletionData{..} - return cd - - poke ptr CompletionData{..} = do - cb <- wrapIOCallback cdCallback - #{poke CompletionData, cdCallback} ptr cb - #{poke CompletionData, cdHandle} ptr cdHandle - -- | Pointer offset in bytes to the location of hoData in HASKELL_OVERLAPPPED cdOffset :: Int cdOffset = #{const __builtin_offsetof (HASKELL_OVERLAPPED, hoData)} @@ -507,11 +472,6 @@ data CbResult a -- manager will perform additional checks. deriving Show --- | Called when the completion is delivered. -type CompletionCallback a = ErrCode -- ^ 0 indicates success - -> DWORD -- ^ Number of bytes transferred - -> IO a - -- | Associate a 'HANDLE' with the current I/O manager's completion port. -- This must be done before using the handle with 'withOverlapped'. associateHandle' :: HANDLE -> IO () @@ -581,23 +541,18 @@ withOverlappedEx mgr fname h offset startCB completionCB = do signalThrow ex = failIfFalse_ (dbgMsg "signalThrow") $ writeIOPort signal (IOFailed ex) mask_ $ do - let completionCB' e b = completionCB e b >>= \result -> - case result of - IOSuccess val -> signalReturn val - IOFailed err -> signalThrow err - hs_lpol <- FFI.allocOverlapped offset - -- Create the completion record and store it. - -- We only need the record when we enqueue a request, however if we - -- delay creating it then we will run into a race condition where the - -- driver may have finished servicing the request before we were ready - -- and so the request won't have the book keeping information to know - -- what to do. So because of that we always create the payload, If we - -- need it ok, if we don't that's no problem. This approach prevents - -- expensive lookups in hash-tables. - -- - -- Todo: Use a memory pool for this so we don't have to hit malloc every - -- time. This would allow us to scale better. - cdData <- new (CompletionData h completionCB') :: IO (Ptr CompletionData) + let completionCB' e b = completionCB e b >>= \result -> + case result of + IOSuccess val -> signalReturn val + IOFailed err -> signalThrow err + let callbackData = CompletionData h completionCB' + -- Note [Memory Management] + -- These callback data and especially the overlapped structs have to keep + -- alive throughout the entire lifetime of the requests. Since this + -- function will block until done so it can call completionCB at the end + -- we can safely use dynamic memory management here and so reduce the + -- possibility of memory errors. + withRequest offset callbackData $ \hs_lpol cdData -> do let ptr_lpol = hs_lpol `plusPtr` cdOffset let lpol = castPtr hs_lpol debugIO $ "hs_lpol:" ++ show hs_lpol @@ -713,11 +668,8 @@ withOverlappedEx mgr fname h offset startCB completionCB = do debugIO $ "## Waiting for cancellation record... " _ <- FFI.getOverlappedResult h lpol True oldDataPtr <- exchangePtr ptr_lpol nullReq - -- Check if we have to free and cleanup pointer when (oldDataPtr == cdData) $ - do free oldDataPtr - free hs_lpol - reqs <- removeRequest + do reqs <- removeRequest debugIO $ "-1.. " ++ show reqs ++ " requests queued after error." status <- fmap fromIntegral getLastError completionCB' status 0 @@ -741,7 +693,6 @@ withOverlappedEx mgr fname h offset startCB completionCB = do case startCBResult of CbPending -> runner CbDone rdata -> do - free cdData debugIO $ dbgMsg $ ":: done " ++ show lpol ++ " - " ++ show rdata bytes <- if isJust rdata then return rdata @@ -749,23 +700,18 @@ withOverlappedEx mgr fname h offset startCB completionCB = do else FFI.getOverlappedResult h lpol False debugIO $ dbgMsg $ ":: done bytes: " ++ show bytes case bytes of - Just res -> free hs_lpol >> completionCB 0 res + Just res -> completionCB 0 res Nothing -> do err <- FFI.overlappedIOStatus lpol numBytes <- FFI.overlappedIONumBytes lpol -- TODO: Remap between STATUS_ and ERROR_ instead -- of re-interpret here. But for now, don't care. let err' = fromIntegral err - free hs_lpol debugIO $ dbgMsg $ ":: done callback: " ++ show err' ++ " - " ++ show numBytes completionCB err' (fromIntegral numBytes) CbError err -> do - free cdData - free hs_lpol let err' = fromIntegral err completionCB err' 0 _ -> do - free cdData - free hs_lpol error "unexpected case in `startCBResult'" where dbgMsg s = s ++ " (" ++ show h ++ ":" ++ show offset ++ ")" -- Wait for .25ms (threaded) and 1ms (non-threaded) @@ -1099,15 +1045,17 @@ processCompletion Manager{..} n delay = do do debugIO $ "exchanged: " ++ show oldDataPtr payload <- peek oldDataPtr :: IO CompletionData let !cb = cdCallback payload - free oldDataPtr reqs <- removeRequest debugIO $ "-1.. " ++ show reqs ++ " requests queued." status <- FFI.overlappedIOStatus (lpOverlapped oe) -- TODO: Remap between STATUS_ and ERROR_ instead -- of re-interpret here. But for now, don't care. let status' = fromIntegral status + -- We no longer explicitly free the memory, this is because we + -- now require the callback to free the memory since the + -- callback allocated it. This allows us to simplify memory + -- management and reduce bugs. See Note [Memory Management]. cb status' (dwNumberOfBytesTransferred oe) - free hs_lpol -- clear the array so we don't erroneously interpret the output, in -- certain circumstances like lockFileEx the code could return 1 entry ===================================== libraries/base/GHC/Event/Windows/FFI.hsc ===================================== @@ -30,6 +30,11 @@ module GHC.Event.Windows.FFI ( postQueuedCompletionStatus, getOverlappedResult, + -- * Completion Data + CompletionData(..), + CompletionCallback, + withRequest, + -- * Overlapped OVERLAPPED, LPOVERLAPPED, @@ -215,6 +220,51 @@ postQueuedCompletionStatus iocp numBytes completionKey lpol = failIfFalse_ "PostQueuedCompletionStatus" $ c_PostQueuedCompletionStatus iocp numBytes completionKey lpol +------------------------------------------------------------------------ +-- Completion Data + +-- | Called when the completion is delivered. +type CompletionCallback a = ErrCode -- ^ 0 indicates success + -> DWORD -- ^ Number of bytes transferred + -> IO a + +-- | Callback type that will be called when an I/O operation completes. +type IOCallback = CompletionCallback () + +-- | Wrap the IOCallback type into a FunPtr. +foreign import ccall "wrapper" + wrapIOCallback :: IOCallback -> IO (FunPtr IOCallback) + +-- | Unwrap a FunPtr IOCallback to a normal Haskell function. +foreign import ccall "dynamic" + mkIOCallback :: FunPtr IOCallback -> IOCallback + +-- | Structure that the I/O manager uses to associate callbacks with +-- additional payload such as their OVERLAPPED structure and Win32 handle +-- etc. *Must* be kept in sync with that in `winio_structs.h` or horrible things +-- happen. +-- +-- We keep the handle around for the benefit of ghc-external libraries making +-- use of the manager. +data CompletionData = CompletionData { cdHandle :: !HANDLE + , cdCallback :: !IOCallback + } + +instance Storable CompletionData where + sizeOf _ = #{size CompletionData} + alignment _ = #{alignment CompletionData} + + peek ptr = do + cdCallback <- mkIOCallback `fmap` #{peek CompletionData, cdCallback} ptr + cdHandle <- #{peek CompletionData, cdHandle} ptr + let !cd = CompletionData{..} + return cd + + poke ptr CompletionData{..} = do + cb <- wrapIOCallback cdCallback + #{poke CompletionData, cdCallback} ptr cb + #{poke CompletionData, cdHandle} ptr cdHandle + ------------------------------------------------------------------------ -- Overlapped @@ -293,6 +343,30 @@ pokeOffsetOverlapped lpol offset = do #{poke OVERLAPPED, OffsetHigh} lpol offsetHigh {-# INLINE pokeOffsetOverlapped #-} +------------------------------------------------------------------------ +-- Request management + +withRequest :: Word64 -> CompletionData + -> (Ptr HASKELL_OVERLAPPED -> Ptr CompletionData -> IO a) + -> IO a +withRequest offset cbData f = + -- Create the completion record and store it. + -- We only need the record when we enqueue a request, however if we + -- delay creating it then we will run into a race condition where the + -- driver may have finished servicing the request before we were ready + -- and so the request won't have the book keeping information to know + -- what to do. So because of that we always create the payload, If we + -- need it ok, if we don't that's no problem. This approach prevents + -- expensive lookups in hash-tables. + -- + -- Todo: Use a memory pool for this so we don't have to hit malloc every + -- time. This would allow us to scale better. + allocaBytes #{size HASKELL_OVERLAPPED} $ \hs_lpol -> + with cbData $ \cdData -> do + zeroOverlapped hs_lpol + pokeOffsetOverlapped (castPtr hs_lpol) offset + f hs_lpol cdData + ------------------------------------------------------------------------ -- Cancel pending I/O View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1f4f81d3a439cd1a8128e4ab11c7caac7cc0ad8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1f4f81d3a439cd1a8128e4ab11c7caac7cc0ad8 You're receiving 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 Jul 24 22:13:41 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 24 Jul 2020 18:13:41 -0400 Subject: [Git][ghc/ghc][master] Care with occCheckExpand in kind of occurrences Message-ID: <5f1b5d15de731_80bd68a9b84893795@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 10 changed files: - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Utils/Unify.hs - + testsuite/tests/polykinds/T18451.hs - + testsuite/tests/polykinds/T18451.stderr - + testsuite/tests/polykinds/T18451a.hs - + testsuite/tests/polykinds/T18451a.stderr - + testsuite/tests/polykinds/T18451b.hs - + testsuite/tests/polykinds/T18451b.stderr - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -34,10 +34,9 @@ import {-# SOURCE #-} GHC.CoreToIface , toIfaceTyCon, toIfaceTcArgs, toIfaceCoercionX ) import {-# SOURCE #-} GHC.Core.DataCon - ( dataConFullSig , dataConUserTyVarBinders - , DataCon ) + ( dataConFullSig , dataConUserTyVarBinders, DataCon ) -import GHC.Core.Type ( isLiftedTypeKind, pattern One, pattern Many ) +import GHC.Core.Type ( pickyIsLiftedTypeKind, pattern One, pattern Many ) import GHC.Core.TyCon import GHC.Core.TyCo.Rep @@ -192,11 +191,35 @@ pprTyVar :: TyVar -> SDoc -- pprIfaceTvBndr is minimal, and the loss of uniques etc in -- debug printing is disastrous pprTyVar tv - | isLiftedTypeKind kind = ppr tv - | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) + | pickyIsLiftedTypeKind kind = ppr tv -- See Note [Suppressing * kinds] + | otherwise = parens (ppr tv <+> dcolon <+> ppr kind) where kind = tyVarKind tv +{- Note [Suppressing * kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Generally we want to print + forall a. a->a +not forall (a::*). a->a +or forall (a::Type). a->a +That is, for brevity we suppress a kind ascription of '*' (or Type). + +But what if the kind is (Const Type x)? + type Const p q = p + +Then (Const Type x) is just a long way of saying Type. But it may be +jolly confusing to suppress the 'x'. Suppose we have (polykinds/T18451a) + foo :: forall a b (c :: Const Type b). Proxy '[a, c] + +Then this error message + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) +would be much less helpful if we suppressed the kind ascription on 'a'. + +Hence the use of pickyIsLiftedTypeKind. +-} + ----------------- debugPprType :: Type -> SDoc -- ^ debugPprType is a simple pretty printer that prints a type ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -120,7 +120,7 @@ module GHC.Core.Type ( -- *** Levity and boxity isLiftedType_maybe, - isLiftedTypeKind, isUnliftedTypeKind, + isLiftedTypeKind, isUnliftedTypeKind, pickyIsLiftedTypeKind, isLiftedRuntimeRep, isUnliftedRuntimeRep, isUnliftedType, mightBeUnliftedType, isUnboxedTupleType, isUnboxedSumType, isAlgType, isDataFamilyAppType, @@ -554,6 +554,23 @@ isLiftedTypeKind kind Just rep -> isLiftedRuntimeRep rep Nothing -> False +pickyIsLiftedTypeKind :: Kind -> Bool +-- Checks whether the kind is literally +-- TYPE LiftedRep +-- or Type +-- without expanding type synonyms or anything +-- Used only when deciding whether to suppress the ":: *" in +-- (a :: *) when printing kinded type variables +-- See Note [Suppressing * kinds] in GHC.Core.TyCo.Ppr +pickyIsLiftedTypeKind kind + | TyConApp tc [arg] <- kind + , tc `hasKey` tYPETyConKey + , TyConApp rr_tc [] <- arg + , rr_tc `hasKey` liftedRepDataConKey = True + | TyConApp tc [] <- kind + , tc `hasKey` liftedTypeKindTyConKey = True + | otherwise = False + isLiftedRuntimeRep :: Type -> Bool -- isLiftedRuntimeRep is true of LiftedRep :: RuntimeRep -- False of type variables (a :: RuntimeRep) @@ -2619,6 +2636,46 @@ prefer doing inner expansions first. For example, We have occCheckExpand b (F (G b)) = Just (F Char) even though we could also expand F to get rid of b. + +Note [Occurrence checking: look inside kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we are considering unifying + (alpha :: *) ~ Int -> (beta :: alpha -> alpha) +This may be an error (what is that alpha doing inside beta's kind?), +but we must not make the mistake of actually unifying or we'll +build an infinite data structure. So when looking for occurrences +of alpha in the rhs, we must look in the kinds of type variables +that occur there. + +occCheckExpand tries to expand type synonyms to remove +unnecessary occurrences of a variable, and thereby get past an +occurs-check failure. This is good; but + we can't do it in the /kind/ of a variable /occurrence/ + +For example #18451 built an infinite type: + type Const a b = a + data SameKind :: k -> k -> Type + type T (k :: Const Type a) = forall (b :: k). SameKind a b + +We have + b :: k + k :: Const Type a + a :: k (must be same as b) + +So if we aren't careful, a's kind mentions a, which is bad. +And expanding an /occurrence/ of 'a' doesn't help, because the +/binding site/ is the master copy and all the occurrences should +match it. + +Here's a related example: + f :: forall a b (c :: Const Type b). Proxy '[a, c] + +The list means that 'a' gets the same kind as 'c'; but that +kind mentions 'b', so the binders are out of order. + +Bottom line: in occCheckExpand, do not expand inside the kinds +of occurrences. See bad_var_occ in occCheckExpand. And +see #18451 for more debate. -} occCheckExpand :: [Var] -> Type -> Maybe Type @@ -2639,11 +2696,10 @@ occCheckExpand vs_to_avoid ty -- The VarSet is the set of variables we are trying to avoid -- The VarEnv carries mappings necessary -- because of kind expansion - go cxt@(as, env) (TyVarTy tv') - | tv' `elemVarSet` as = Nothing - | Just tv'' <- lookupVarEnv env tv' = return (mkTyVarTy tv'') - | otherwise = do { tv'' <- go_var cxt tv' - ; return (mkTyVarTy tv'') } + go (as, env) ty@(TyVarTy tv) + | Just tv' <- lookupVarEnv env tv = return (mkTyVarTy tv') + | bad_var_occ as tv = Nothing + | otherwise = return ty go _ ty@(LitTy {}) = return ty go cxt (AppTy ty1 ty2) = do { ty1' <- go cxt ty1 @@ -2656,7 +2712,7 @@ occCheckExpand vs_to_avoid ty ; return (ty { ft_mult = w', ft_arg = ty1', ft_res = ty2' }) } go cxt@(as, env) (ForAllTy (Bndr tv vis) body_ty) = do { ki' <- go cxt (varType tv) - ; let tv' = setVarType tv ki' + ; let tv' = setVarType tv ki' env' = extendVarEnv env tv tv' as' = as `delVarSet` tv ; body' <- go (as', env') body_ty @@ -2680,9 +2736,12 @@ occCheckExpand vs_to_avoid ty ; return (mkCoercionTy co') } ------------------ - go_var cxt v = updateVarTypeM (go cxt) v - -- Works for TyVar and CoVar - -- See Note [Occurrence checking: look inside kinds] + bad_var_occ :: VarSet -> Var -> Bool + -- Works for TyVar and CoVar + -- See Note [Occurrence checking: look inside kinds] + bad_var_occ vs_to_avoid v + = v `elemVarSet` vs_to_avoid + || tyCoVarsOfType (varType v) `intersectsVarSet` vs_to_avoid ------------------ go_mco _ MRefl = return MRefl @@ -2712,13 +2771,15 @@ occCheckExpand vs_to_avoid ty ; co2' <- go_co cxt co2 ; w' <- go_co cxt w ; return (mkFunCo r w' co1' co2') } - go_co cxt@(as,env) (CoVarCo c) - | c `elemVarSet` as = Nothing + go_co (as,env) co@(CoVarCo c) | Just c' <- lookupVarEnv env c = return (mkCoVarCo c') - | otherwise = do { c' <- go_var cxt c - ; return (mkCoVarCo c') } - go_co cxt (HoleCo h) = do { c' <- go_var cxt (ch_co_var h) - ; return (HoleCo (h { ch_co_var = c' })) } + | bad_var_occ as c = Nothing + | otherwise = return co + + go_co (as,_) co@(HoleCo h) + | bad_var_occ as (ch_co_var h) = Nothing + | otherwise = return co + go_co cxt (AxiomInstCo ax ind args) = do { args' <- mapM (go_co cxt) args ; return (mkAxiomInstCo ax ind args') } go_co cxt (UnivCo p r ty1 ty2) = do { p' <- go_prov cxt p ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -1879,21 +1879,8 @@ matchExpectedFunKind hs_ty n k = go n k ********************************************************************* -} -{- Note [Occurrence checking: look inside kinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Suppose we are considering unifying - (alpha :: *) ~ Int -> (beta :: alpha -> alpha) -This may be an error (what is that alpha doing inside beta's kind?), -but we must not make the mistake of actually unifying or we'll -build an infinite data structure. So when looking for occurrences -of alpha in the rhs, we must look in the kinds of type variables -that occur there. - -NB: we may be able to remove the problem via expansion; see - Note [Occurs check expansion]. So we have to try that. - -Note [Checking for foralls] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Checking for foralls] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unless we have -XImpredicativeTypes (which is a totally unsupported feature), we do not want to unify alpha ~ (forall a. a->a) -> Int @@ -1906,10 +1893,10 @@ Consider (alpha :: forall k. k->*) ~ (beta :: forall k. k->*) This is legal; e.g. dependent/should_compile/T11635. -We don't want to reject it because of the forall in beta's kind, -but (see Note [Occurrence checking: look inside kinds]) we do -need to look in beta's kind. So we carry a flag saying if a 'forall' -is OK, and switch the flag on when stepping inside a kind. +We don't want to reject it because of the forall in beta's kind, but +(see Note [Occurrence checking: look inside kinds] in GHC.Core.Type) +we do need to look in beta's kind. So we carry a flag saying if a +'forall' is OK, and switch the flag on when stepping inside a kind. Why is it OK? Why does it not count as impredicative polymorphism? The reason foralls are bad is because we reply on "seeing" foralls @@ -2030,6 +2017,7 @@ preCheck dflags ty_fam_ok tv ty | tv == tv' = MTVU_Occurs | otherwise = fast_check_occ (tyVarKind tv') -- See Note [Occurrence checking: look inside kinds] + -- in GHC.Core.Type fast_check (TyConApp tc tys) | bad_tc tc = MTVU_Bad ===================================== testsuite/tests/polykinds/T18451.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind + +type Const a b = a +data SameKind :: k -> k -> Type + +type T (k :: Const Type a) = forall (b :: k). SameKind a b ===================================== testsuite/tests/polykinds/T18451.stderr ===================================== @@ -0,0 +1,9 @@ + +T18451.hs:10:58: error: + • Expected kind ‘k0’, but ‘b’ has kind ‘k’ + • In the second argument of ‘SameKind’, namely ‘b’ + In the type ‘forall (b :: k). SameKind a b’ + In the type declaration for ‘T’ + • Type variable kinds: + a :: k0 + k :: Const (*) a ===================================== testsuite/tests/polykinds/T18451a.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451a.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/T18451b.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type Const a b = a + +foo :: forall a b (c :: Const Type b). Proxy '[a, c] +foo = error "ruk" ===================================== testsuite/tests/polykinds/T18451b.stderr ===================================== @@ -0,0 +1,7 @@ + +T18451b.hs:10:8: error: + • These kind and type variables: a b (c :: Const Type b) + are out of dependency order. Perhaps try this ordering: + (b :: k) (a :: Const (*) b) (c :: Const (*) b) + • In the type signature: + foo :: forall a b (c :: Const Type b). Proxy '[a, c] ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -220,3 +220,6 @@ test('CuskFam', normal, compile, ['']) test('T17841', normal, compile_fail, ['']) test('T17963', normal, compile_fail, ['']) test('T18300', normal, compile_fail, ['']) +test('T18451', normal, compile_fail, ['']) +test('T18451a', normal, compile_fail, ['']) +test('T18451b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ba205046e4f2ea94b1c978c050b917de4daaf092 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ba205046e4f2ea94b1c978c050b917de4daaf092 You're receiving 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 Jul 24 22:44:25 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 24 Jul 2020 18:44:25 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 15 commits: winio: restore console cp on exit Message-ID: <5f1b6449ed38b_80b3f84901582f04895785@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 6c2f864a by Zubin Duggal at 2020-07-24T18:44:18-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - cd6da974 by Sylvain Henry at 2020-07-24T18:44:22-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - e0e78b11 by Sylvain Henry at 2020-07-24T18:44:22-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - a93f4533 by Sylvain Henry at 2020-07-24T18:44:22-04:00 Add GHC.Platform.Profile - - - - - bb8c809e by Sylvain Henry at 2020-07-24T18:44:22-04:00 Put PlatformConstants into Platform - - - - - f89a0649 by Sylvain Henry at 2020-07-24T18:44:22-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 546a0ec9 by Sylvain Henry at 2020-07-24T18:44:22-04:00 Remove dead code in utils/derivConstants - - - - - eda19fd5 by Sylvain Henry at 2020-07-24T18:44:22-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 387d060e by Sylvain Henry at 2020-07-24T18:44:22-04:00 Fix build systems - - - - - 6a0f0401 by Sylvain Henry at 2020-07-24T18:44:22-04:00 Bump CountParserDeps - - - - - 7dc8bd99 by Sylvain Henry at 2020-07-24T18:44:22-04:00 Add accessors to ArchOS - - - - - a69b4a76 by Stefan Schulze Frielinghaus at 2020-07-24T18:44:23-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.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/0ed582676566f5d8ef6edff4a0ee5517f5c90d4a...a69b4a761ec9fee8babc4cb6307330c772fbeb1a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0ed582676566f5d8ef6edff4a0ee5517f5c90d4a...a69b4a761ec9fee8babc4cb6307330c772fbeb1a You're receiving 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 Jul 25 04:44:46 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 25 Jul 2020 00:44:46 -0400 Subject: [Git][ghc/ghc][master] Simplify XRec definition Message-ID: <5f1bb8be6460b_80b3f849248fe0849150c2@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - 24 changed files: - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Expr.hs-boot - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Pat.hs-boot - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Gen/Foreign.hs - ghc/GHCi/UI.hs - ghc/GHCi/UI/Info.hs - testsuite/tests/pmcheck/should_compile/pmc009.hs - utils/haddock Changes: ===================================== compiler/GHC/Hs/Binds.hs ===================================== @@ -20,6 +20,7 @@ Datatype for: @BindGroup@, @Bind@, @Sig@, @Bind at . {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE ViewPatterns #-} module GHC.Hs.Binds where @@ -68,7 +69,7 @@ Global bindings (where clauses) type HsLocalBinds id = HsLocalBindsLR id id -- | Located Haskell local bindings -type LHsLocalBinds id = Located (HsLocalBinds id) +type LHsLocalBinds id = XRec id (HsLocalBinds id) -- | Haskell Local Bindings with separate Left and Right identifier types -- @@ -101,7 +102,7 @@ type instance XHsIPBinds (GhcPass pL) (GhcPass pR) = NoExtField type instance XEmptyLocalBinds (GhcPass pL) (GhcPass pR) = NoExtField type instance XXHsLocalBindsLR (GhcPass pL) (GhcPass pR) = NoExtCon -type LHsLocalBindsLR idL idR = Located (HsLocalBindsLR idL idR) +type LHsLocalBindsLR idL idR = XRec idL (HsLocalBindsLR idL idR) -- | Haskell Value Bindings @@ -156,7 +157,7 @@ type HsBind id = HsBindLR id id type LHsBindsLR idL idR = Bag (LHsBindLR idL idR) -- | Located Haskell Binding with separate Left and Right identifier types -type LHsBindLR idL idR = Located (HsBindLR idL idR) +type LHsBindLR idL idR = XRec idL (HsBindLR idL idR) {- Note [FunBind vs PatBind] ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -240,7 +241,7 @@ data HsBindLR idL idR -- type Int -> forall a'. a' -> a' -- Notice that the coercion captures the free a'. - fun_id :: Located (IdP idL), -- Note [fun_id in Match] in GHC.Hs.Expr + fun_id :: XRec idL (IdP idL), -- Note [fun_id in Match] in GHC.Hs.Expr fun_matches :: MatchGroup idR (LHsExpr idR), -- ^ The payload @@ -371,8 +372,8 @@ type instance XXABExport (GhcPass p) = NoExtCon data PatSynBind idL idR = PSB { psb_ext :: XPSB idL idR, -- ^ Post renaming, FVs. -- See Note [Bind free vars] - psb_id :: Located (IdP idL), -- ^ Name of the pattern synonym - psb_args :: HsPatSynDetails (Located (IdP idR)), + psb_id :: XRec idL (IdP idL), -- ^ Name of the pattern synonym + psb_args :: HsPatSynDetails (XRec idR (IdP idR)), -- ^ Formal parameter names psb_def :: LPat idR, -- ^ Right-hand side psb_dir :: HsPatSynDir idR -- ^ Directionality @@ -692,10 +693,10 @@ emptyValBindsIn, emptyValBindsOut :: HsValBindsLR (GhcPass a) (GhcPass b) emptyValBindsIn = ValBinds noExtField emptyBag [] emptyValBindsOut = XValBindsLR (NValBinds [] []) -emptyLHsBinds :: LHsBindsLR idL idR +emptyLHsBinds :: LHsBindsLR (GhcPass idL) idR emptyLHsBinds = emptyBag -isEmptyLHsBinds :: LHsBindsLR idL idR -> Bool +isEmptyLHsBinds :: LHsBindsLR (GhcPass idL) idR -> Bool isEmptyLHsBinds = isEmptyBag ------------ @@ -822,7 +823,7 @@ isEmptyIPBindsTc :: HsIPBinds GhcTc -> Bool isEmptyIPBindsTc (IPBinds ds is) = null is && isEmptyTcEvBinds ds -- | Located Implicit Parameter Binding -type LIPBind id = Located (IPBind id) +type LIPBind id = XRec id (IPBind id) -- ^ May have 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnSemi' when in a -- list @@ -841,7 +842,7 @@ type LIPBind id = Located (IPBind id) data IPBind id = IPBind (XCIPBind id) - (Either (Located HsIPName) (IdP id)) + (Either (XRec id HsIPName) (IdP id)) (LHsExpr id) | XIPBind !(XXIPBind id) @@ -873,7 +874,7 @@ serves for both. -} -- | Located Signature -type LSig pass = Located (Sig pass) +type LSig pass = XRec pass (Sig pass) -- | Signatures and pragmas data Sig pass @@ -895,7 +896,7 @@ data Sig pass -- For details on above see note [Api annotations] in GHC.Parser.Annotation TypeSig (XTypeSig pass) - [Located (IdP pass)] -- LHS of the signature; e.g. f,g,h :: blah + [XRec pass (IdP pass)] -- LHS of the signature; e.g. f,g,h :: blah (LHsSigWcType pass) -- RHS of the signature; can have wildcards -- | A pattern synonym type signature @@ -907,7 +908,7 @@ data Sig pass -- 'GHC.Parser.Annotation.AnnDot','GHC.Parser.Annotation.AnnDarrow' -- For details on above see note [Api annotations] in GHC.Parser.Annotation - | PatSynSig (XPatSynSig pass) [Located (IdP pass)] (LHsSigType pass) + | PatSynSig (XPatSynSig pass) [XRec pass (IdP pass)] (LHsSigType pass) -- P :: forall a b. Req => Prov => ty -- | A signature for a class method @@ -920,7 +921,7 @@ data Sig pass -- -- - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnDefault', -- 'GHC.Parser.Annotation.AnnDcolon' - | ClassOpSig (XClassOpSig pass) Bool [Located (IdP pass)] (LHsSigType pass) + | ClassOpSig (XClassOpSig pass) Bool [XRec pass (IdP pass)] (LHsSigType pass) -- | A type signature in generated code, notably the code -- generated for record selectors. We simply record @@ -952,7 +953,7 @@ data Sig pass -- For details on above see note [Api annotations] in GHC.Parser.Annotation | InlineSig (XInlineSig pass) - (Located (IdP pass)) -- Function name + (XRec pass (IdP pass)) -- Function name InlinePragma -- Never defaultInlinePragma -- | A specialisation pragma @@ -968,7 +969,7 @@ data Sig pass -- For details on above see note [Api annotations] in GHC.Parser.Annotation | SpecSig (XSpecSig pass) - (Located (IdP pass)) -- Specialise a function or datatype ... + (XRec pass (IdP pass)) -- Specialise a function or datatype ... [LHsSigType pass] -- ... to these types InlinePragma -- The pragma on SPECIALISE_INLINE form. -- If it's just defaultInlinePragma, then we said @@ -998,7 +999,7 @@ data Sig pass -- For details on above see note [Api annotations] in GHC.Parser.Annotation | MinimalSig (XMinimalSig pass) - SourceText (LBooleanFormula (Located (IdP pass))) + SourceText (LBooleanFormula (XRec pass (IdP pass))) -- Note [Pragma source text] in GHC.Types.Basic -- | A "set cost centre" pragma for declarations @@ -1010,9 +1011,9 @@ data Sig pass -- > {-# SCC funName "cost_centre_name" #-} | SCCFunSig (XSCCFunSig pass) - SourceText -- Note [Pragma source text] in GHC.Types.Basic - (Located (IdP pass)) -- Function name - (Maybe (Located StringLiteral)) + SourceText -- Note [Pragma source text] in GHC.Types.Basic + (XRec pass (IdP pass)) -- Function name + (Maybe (XRec pass StringLiteral)) -- | A complete match pragma -- -- > {-# COMPLETE C, D [:: T] #-} @@ -1022,8 +1023,8 @@ data Sig pass -- synonym definitions. | CompleteMatchSig (XCompleteMatchSig pass) SourceText - (Located [Located (IdP pass)]) - (Maybe (Located (IdP pass))) + (XRec pass [XRec pass (IdP pass)]) + (Maybe (XRec pass (IdP pass))) | XSig !(XXSig pass) type instance XTypeSig (GhcPass p) = NoExtField @@ -1040,10 +1041,10 @@ type instance XCompleteMatchSig (GhcPass p) = NoExtField type instance XXSig (GhcPass p) = NoExtCon -- | Located Fixity Signature -type LFixitySig pass = Located (FixitySig pass) +type LFixitySig pass = XRec pass (FixitySig pass) -- | Fixity Signature -data FixitySig pass = FixitySig (XFixitySig pass) [Located (IdP pass)] Fixity +data FixitySig pass = FixitySig (XFixitySig pass) [XRec pass (IdP pass)] Fixity | XFixitySig !(XXFixitySig pass) type instance XFixitySig (GhcPass p) = NoExtField @@ -1082,48 +1083,47 @@ isDefaultMethod :: TcSpecPrags -> Bool isDefaultMethod IsDefaultMethod = True isDefaultMethod (SpecPrags {}) = False - -isFixityLSig :: LSig name -> Bool -isFixityLSig (L _ (FixSig {})) = True +isFixityLSig :: forall p. UnXRec p => LSig p -> Bool +isFixityLSig (unXRec @p -> FixSig {}) = True isFixityLSig _ = False -isTypeLSig :: LSig name -> Bool -- Type signatures -isTypeLSig (L _(TypeSig {})) = True -isTypeLSig (L _(ClassOpSig {})) = True -isTypeLSig (L _(IdSig {})) = True +isTypeLSig :: forall p. UnXRec p => LSig p -> Bool -- Type signatures +isTypeLSig (unXRec @p -> TypeSig {}) = True +isTypeLSig (unXRec @p -> ClassOpSig {}) = True +isTypeLSig (unXRec @p -> IdSig {}) = True isTypeLSig _ = False -isSpecLSig :: LSig name -> Bool -isSpecLSig (L _(SpecSig {})) = True +isSpecLSig :: forall p. UnXRec p => LSig p -> Bool +isSpecLSig (unXRec @p -> SpecSig {}) = True isSpecLSig _ = False -isSpecInstLSig :: LSig name -> Bool -isSpecInstLSig (L _ (SpecInstSig {})) = True +isSpecInstLSig :: forall p. UnXRec p => LSig p -> Bool +isSpecInstLSig (unXRec @p -> SpecInstSig {}) = True isSpecInstLSig _ = False -isPragLSig :: LSig name -> Bool +isPragLSig :: forall p. UnXRec p => LSig p -> Bool -- Identifies pragmas -isPragLSig (L _ (SpecSig {})) = True -isPragLSig (L _ (InlineSig {})) = True -isPragLSig (L _ (SCCFunSig {})) = True -isPragLSig (L _ (CompleteMatchSig {})) = True +isPragLSig (unXRec @p -> SpecSig {}) = True +isPragLSig (unXRec @p -> InlineSig {}) = True +isPragLSig (unXRec @p -> SCCFunSig {}) = True +isPragLSig (unXRec @p -> CompleteMatchSig {}) = True isPragLSig _ = False -isInlineLSig :: LSig name -> Bool +isInlineLSig :: forall p. UnXRec p => LSig p -> Bool -- Identifies inline pragmas -isInlineLSig (L _ (InlineSig {})) = True +isInlineLSig (unXRec @p -> InlineSig {}) = True isInlineLSig _ = False -isMinimalLSig :: LSig name -> Bool -isMinimalLSig (L _ (MinimalSig {})) = True -isMinimalLSig _ = False +isMinimalLSig :: forall p. UnXRec p => LSig p -> Bool +isMinimalLSig (unXRec @p -> MinimalSig {}) = True +isMinimalLSig _ = False -isSCCFunSig :: LSig name -> Bool -isSCCFunSig (L _ (SCCFunSig {})) = True +isSCCFunSig :: forall p. UnXRec p => LSig p -> Bool +isSCCFunSig (unXRec @p -> SCCFunSig {}) = True isSCCFunSig _ = False -isCompleteMatchSig :: LSig name -> Bool -isCompleteMatchSig (L _ (CompleteMatchSig {} )) = True +isCompleteMatchSig :: forall p. UnXRec p => LSig p -> Bool +isCompleteMatchSig (unXRec @p -> CompleteMatchSig {} ) = True isCompleteMatchSig _ = False hsSigDoc :: Sig name -> SDoc ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -133,7 +133,7 @@ import Data.Data hiding (TyCon,Fixity, Infix) ************************************************************************ -} -type LHsDecl p = Located (HsDecl p) +type LHsDecl p = XRec p (HsDecl p) -- ^ When in a list this may have -- -- - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnSemi' @@ -411,13 +411,13 @@ instance (OutputableBndrId p) => Outputable (HsGroup (GhcPass p)) where vcat_mb gap (Just d : ds) = gap $$ d $$ vcat_mb blankLine ds -- | Located Splice Declaration -type LSpliceDecl pass = Located (SpliceDecl pass) +type LSpliceDecl pass = XRec pass (SpliceDecl pass) -- | Splice Declaration data SpliceDecl p = SpliceDecl -- Top level splice (XSpliceDecl p) - (Located (HsSplice p)) + (XRec p (HsSplice p)) SpliceExplicitFlag | XSpliceDecl !(XXSpliceDecl p) @@ -568,7 +568,7 @@ Interface file code: -} -- | Located Declaration of a Type or Class -type LTyClDecl pass = Located (TyClDecl pass) +type LTyClDecl pass = XRec pass (TyClDecl pass) -- | A type or class declaration. data TyClDecl pass @@ -592,7 +592,7 @@ data TyClDecl pass -- For details on above see note [Api annotations] in GHC.Parser.Annotation SynDecl { tcdSExt :: XSynDecl pass -- ^ Post renameer, FVs - , tcdLName :: Located (IdP pass) -- ^ Type constructor + , tcdLName :: XRec pass (IdP pass) -- ^ Type constructor , tcdTyVars :: LHsQTyVars pass -- ^ Type variables; for an -- associated type these -- include outer binders @@ -609,16 +609,16 @@ data TyClDecl pass -- For details on above see note [Api annotations] in GHC.Parser.Annotation DataDecl { tcdDExt :: XDataDecl pass -- ^ Post renamer, CUSK flag, FVs - , tcdLName :: Located (IdP pass) -- ^ Type constructor + , tcdLName :: XRec pass (IdP pass) -- ^ Type constructor , tcdTyVars :: LHsQTyVars pass -- ^ Type variables -- See Note [TyVar binders for associated declarations] , tcdFixity :: LexicalFixity -- ^ Fixity used in the declaration , tcdDataDefn :: HsDataDefn pass } - | ClassDecl { tcdCExt :: XClassDecl pass, -- ^ Post renamer, FVs - tcdCtxt :: LHsContext pass, -- ^ Context... - tcdLName :: Located (IdP pass), -- ^ Name of the class - tcdTyVars :: LHsQTyVars pass, -- ^ Class type variables + | ClassDecl { tcdCExt :: XClassDecl pass, -- ^ Post renamer, FVs + tcdCtxt :: LHsContext pass, -- ^ Context... + tcdLName :: XRec pass (IdP pass), -- ^ Name of the class + tcdTyVars :: LHsQTyVars pass, -- ^ Class type variables tcdFixity :: LexicalFixity, -- ^ Fixity used in the declaration tcdFDs :: [LHsFunDep pass], -- ^ Functional deps tcdSigs :: [LSig pass], -- ^ Methods' signatures @@ -637,7 +637,7 @@ data TyClDecl pass -- For details on above see note [Api annotations] in GHC.Parser.Annotation | XTyClDecl !(XXTyClDecl pass) -type LHsFunDep pass = Located (FunDep (Located (IdP pass))) +type LHsFunDep pass = XRec pass (FunDep (XRec pass (IdP pass))) data DataDeclRn = DataDeclRn { tcdDataCusk :: Bool -- ^ does this have a CUSK? @@ -764,6 +764,8 @@ tyClDeclLName (SynDecl { tcdLName = ln }) = ln tyClDeclLName (DataDecl { tcdLName = ln }) = ln tyClDeclLName (ClassDecl { tcdLName = ln }) = ln +-- FIXME: tcdName is commonly used by both GHC and third-party tools, so it +-- needs to be polymorphic in the pass tcdName :: TyClDecl (GhcPass p) -> IdP (GhcPass p) tcdName = unLoc . tyClDeclLName @@ -1095,7 +1097,7 @@ See also Note [Injective type families] in GHC.Core.TyCon -} -- | Located type Family Result Signature -type LFamilyResultSig pass = Located (FamilyResultSig pass) +type LFamilyResultSig pass = XRec pass (FamilyResultSig pass) -- | type Family Result Signature data FamilyResultSig pass = -- see Note [FamilyResultSig] @@ -1127,13 +1129,13 @@ type instance XXFamilyResultSig (GhcPass _) = NoExtCon -- | Located type Family Declaration -type LFamilyDecl pass = Located (FamilyDecl pass) +type LFamilyDecl pass = XRec pass (FamilyDecl pass) -- | type Family Declaration data FamilyDecl pass = FamilyDecl { fdExt :: XCFamilyDecl pass , fdInfo :: FamilyInfo pass -- type/data, closed/open - , fdLName :: Located (IdP pass) -- type constructor + , fdLName :: XRec pass (IdP pass) -- type constructor , fdTyVars :: LHsQTyVars pass -- type variables -- See Note [TyVar binders for associated declarations] , fdFixity :: LexicalFixity -- Fixity used in the declaration @@ -1155,7 +1157,7 @@ type instance XXFamilyDecl (GhcPass _) = NoExtCon -- | Located Injectivity Annotation -type LInjectivityAnn pass = Located (InjectivityAnn pass) +type LInjectivityAnn pass = XRec pass (InjectivityAnn pass) -- | If the user supplied an injectivity annotation it is represented using -- InjectivityAnn. At the moment this is a single injectivity condition - see @@ -1166,7 +1168,7 @@ type LInjectivityAnn pass = Located (InjectivityAnn pass) -- -- This will be represented as "InjectivityAnn `r` [`a`, `c`]" data InjectivityAnn pass - = InjectivityAnn (Located (IdP pass)) [Located (IdP pass)] + = InjectivityAnn (XRec pass (IdP pass)) [XRec pass (IdP pass)] -- ^ - 'GHC.Parser.Annotation.AnnKeywordId' : -- 'GHC.Parser.Annotation.AnnRarrow', 'GHC.Parser.Annotation.AnnVbar' @@ -1267,7 +1269,7 @@ data HsDataDefn pass -- The payload of a data type defn HsDataDefn { dd_ext :: XCHsDataDefn pass, dd_ND :: NewOrData, dd_ctxt :: LHsContext pass, -- ^ Context - dd_cType :: Maybe (Located CType), + dd_cType :: Maybe (XRec pass CType), dd_kindSig:: Maybe (LHsKind pass), -- ^ Optional kind signature. -- @@ -1295,7 +1297,7 @@ type instance XCHsDataDefn (GhcPass _) = NoExtField type instance XXHsDataDefn (GhcPass _) = NoExtCon -- | Haskell Deriving clause -type HsDeriving pass = Located [LHsDerivingClause pass] +type HsDeriving pass = XRec pass [LHsDerivingClause pass] -- ^ The optional @deriving@ clauses of a data declaration. "Clauses" is -- plural because one can specify multiple deriving clauses using the -- @-XDerivingStrategies@ language extension. @@ -1304,7 +1306,7 @@ type HsDeriving pass = Located [LHsDerivingClause pass] -- requested to derive, in order. If no deriving clauses were specified, -- the list is empty. -type LHsDerivingClause pass = Located (HsDerivingClause pass) +type LHsDerivingClause pass = XRec pass (HsDerivingClause pass) -- | A single @deriving@ clause of a data declaration. -- @@ -1319,7 +1321,7 @@ data HsDerivingClause pass , deriv_clause_strategy :: Maybe (LDerivStrategy pass) -- ^ The user-specified strategy (if any) to use when deriving -- 'deriv_clause_tys'. - , deriv_clause_tys :: Located [LHsSigType pass] + , deriv_clause_tys :: XRec pass [LHsSigType pass] -- ^ The types to derive. -- -- It uses 'LHsSigType's because, with @-XGeneralizedNewtypeDeriving@, @@ -1358,11 +1360,11 @@ instance OutputableBndrId p _ -> (ppDerivStrategy dcs, empty) -- | Located Standalone Kind Signature -type LStandaloneKindSig pass = Located (StandaloneKindSig pass) +type LStandaloneKindSig pass = XRec pass (StandaloneKindSig pass) data StandaloneKindSig pass = StandaloneKindSig (XStandaloneKindSig pass) - (Located (IdP pass)) -- Why a single binder? See #16754 + (XRec pass (IdP pass)) -- Why a single binder? See #16754 (LHsSigType pass) -- Why not LHsSigWcType? See Note [Wildcards in standalone kind signatures] | XStandaloneKindSig !(XXStandaloneKindSig pass) @@ -1399,7 +1401,7 @@ newOrDataToFlavour DataType = DataTypeFlavour -- | Located data Constructor Declaration -type LConDecl pass = Located (ConDecl pass) +type LConDecl pass = XRec pass (ConDecl pass) -- ^ May have 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnSemi' when -- in a GADT constructor list @@ -1433,13 +1435,13 @@ type LConDecl pass = Located (ConDecl pass) data ConDecl pass = ConDeclGADT { con_g_ext :: XConDeclGADT pass - , con_names :: [Located (IdP pass)] + , con_names :: [XRec pass (IdP pass)] -- The next four fields describe the type after the '::' -- See Note [GADT abstract syntax] -- The following field is Located to anchor API Annotations, -- AnnForall and AnnDot. - , con_forall :: Located Bool -- ^ True <=> explicit forall + , con_forall :: XRec pass Bool -- ^ True <=> explicit forall -- False => hsq_explicit is empty , con_qvars :: [LHsTyVarBndr Specificity pass] -- Whether or not there is an /explicit/ forall, we still @@ -1455,9 +1457,9 @@ data ConDecl pass | ConDeclH98 { con_ext :: XConDeclH98 pass - , con_name :: Located (IdP pass) + , con_name :: XRec pass (IdP pass) - , con_forall :: Located Bool + , con_forall :: XRec pass Bool -- ^ True <=> explicit user-written forall -- e.g. data T a = forall b. MkT b (b->a) -- con_ex_tvs = {b} @@ -1607,7 +1609,7 @@ or contexts in two parts: -- | Haskell data Constructor Declaration Details type HsConDeclDetails pass - = HsConDetails (HsScaled pass (LBangType pass)) (Located [LConDeclField pass]) + = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] @@ -1616,7 +1618,7 @@ getConNames ConDeclGADT {con_names = names} = names getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn getConArgs d = con_args d -hsConDeclArgTys :: HsConDeclDetails pass -> [HsScaled pass (LBangType pass)] +hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] hsConDeclArgTys (PrefixCon tys) = tys hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) @@ -1627,7 +1629,7 @@ hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc -- unrestricted). By the transfer property, projections are then correct in -- that all the non-projected fields have multiplicity Many, and can be dropped. -hsConDeclTheta :: Maybe (LHsContext pass) -> [LHsType pass] +hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] hsConDeclTheta (Just (L _ theta)) = theta @@ -1773,7 +1775,7 @@ free-standing `type instance` declaration. ----------------- Type synonym family instances ------------- -- | Located Type Family Instance Equation -type LTyFamInstEqn pass = Located (TyFamInstEqn pass) +type LTyFamInstEqn pass = XRec pass (TyFamInstEqn pass) -- ^ May have 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnSemi' -- when in a list @@ -1825,10 +1827,10 @@ type TyFamInstEqn pass = FamInstEqn pass (LHsType pass) type TyFamDefltDecl = TyFamInstDecl -- | Located type family default declarations. -type LTyFamDefltDecl pass = Located (TyFamDefltDecl pass) +type LTyFamDefltDecl pass = XRec pass (TyFamDefltDecl pass) -- | Located Type Family Instance Declaration -type LTyFamInstDecl pass = Located (TyFamInstDecl pass) +type LTyFamInstDecl pass = XRec pass (TyFamInstDecl pass) -- | Type Family Instance Declaration newtype TyFamInstDecl pass = TyFamInstDecl { tfid_eqn :: TyFamInstEqn pass } @@ -1841,7 +1843,7 @@ newtype TyFamInstDecl pass = TyFamInstDecl { tfid_eqn :: TyFamInstEqn pass } ----------------- Data family instances ------------- -- | Located Data Family Instance Declaration -type LDataFamInstDecl pass = Located (DataFamInstDecl pass) +type LDataFamInstDecl pass = XRec pass (DataFamInstDecl pass) -- | Data Family Instance Declaration newtype DataFamInstDecl pass @@ -1858,7 +1860,7 @@ newtype DataFamInstDecl pass ----------------- Family instances (common types) ------------- -- | Located Family Instance Equation -type LFamInstEqn pass rhs = Located (FamInstEqn pass rhs) +type LFamInstEqn pass rhs = XRec pass (FamInstEqn pass rhs) -- | Family Instance Equation type FamInstEqn pass rhs = HsImplicitBndrs pass (FamEqn pass rhs) @@ -1874,7 +1876,7 @@ type FamInstEqn pass rhs = HsImplicitBndrs pass (FamEqn pass rhs) data FamEqn pass rhs = FamEqn { feqn_ext :: XCFamEqn pass rhs - , feqn_tycon :: Located (IdP pass) + , feqn_tycon :: XRec pass (IdP pass) , feqn_bndrs :: Maybe [LHsTyVarBndr () pass] -- ^ Optional quantified type vars , feqn_pats :: HsTyPats pass , feqn_fixity :: LexicalFixity -- ^ Fixity used in the declaration @@ -1892,7 +1894,7 @@ type instance XXFamEqn (GhcPass _) r = NoExtCon ----------------- Class instances ------------- -- | Located Class Instance Declaration -type LClsInstDecl pass = Located (ClsInstDecl pass) +type LClsInstDecl pass = XRec pass (ClsInstDecl pass) -- | Class Instance Declaration data ClsInstDecl pass @@ -1905,7 +1907,7 @@ data ClsInstDecl pass , cid_sigs :: [LSig pass] -- User-supplied pragmatic info , cid_tyfam_insts :: [LTyFamInstDecl pass] -- Type family instances , cid_datafam_insts :: [LDataFamInstDecl pass] -- Data family instances - , cid_overlap_mode :: Maybe (Located OverlapMode) + , cid_overlap_mode :: Maybe (XRec pass OverlapMode) -- ^ - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnOpen', -- 'GHC.Parser.Annotation.AnnClose', @@ -1925,7 +1927,7 @@ type instance XXClsInstDecl (GhcPass _) = NoExtCon ----------------- Instances of all kinds ------------- -- | Located Instance Declaration -type LInstDecl pass = Located (InstDecl pass) +type LInstDecl pass = XRec pass (InstDecl pass) -- | Instance Declaration data InstDecl pass -- Both class and family instances @@ -2082,7 +2084,7 @@ instDeclDataFamInsts inst_decls -} -- | Located stand-alone 'deriving instance' declaration -type LDerivDecl pass = Located (DerivDecl pass) +type LDerivDecl pass = XRec pass (DerivDecl pass) -- | Stand-alone 'deriving instance' declaration data DerivDecl pass = DerivDecl @@ -2100,7 +2102,7 @@ data DerivDecl pass = DerivDecl -- See Note [Inferring the instance context] in GHC.Tc.Deriv.Infer. , deriv_strategy :: Maybe (LDerivStrategy pass) - , deriv_overlap_mode :: Maybe (Located OverlapMode) + , deriv_overlap_mode :: Maybe (XRec pass OverlapMode) -- ^ - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnDeriving', -- 'GHC.Parser.Annotation.AnnInstance', 'GHC.Parser.Annotation.AnnStock', -- 'GHC.Parser.Annotation.AnnAnyClass', 'Api.AnnNewtype', @@ -2133,7 +2135,7 @@ instance OutputableBndrId p -} -- | A 'Located' 'DerivStrategy'. -type LDerivStrategy pass = Located (DerivStrategy pass) +type LDerivStrategy pass = XRec pass (DerivStrategy pass) -- | Which technique the user explicitly requested when deriving an instance. data DerivStrategy pass @@ -2199,7 +2201,7 @@ syntax, and that restriction must be checked in the front end. -} -- | Located Default Declaration -type LDefaultDecl pass = Located (DefaultDecl pass) +type LDefaultDecl pass = XRec pass (DefaultDecl pass) -- | Default Declaration data DefaultDecl pass @@ -2233,19 +2235,19 @@ instance OutputableBndrId p -- has been used -- | Located Foreign Declaration -type LForeignDecl pass = Located (ForeignDecl pass) +type LForeignDecl pass = XRec pass (ForeignDecl pass) -- | Foreign Declaration data ForeignDecl pass = ForeignImport { fd_i_ext :: XForeignImport pass -- Post typechecker, rep_ty ~ sig_ty - , fd_name :: Located (IdP pass) -- defines this name + , fd_name :: XRec pass (IdP pass) -- defines this name , fd_sig_ty :: LHsSigType pass -- sig_ty , fd_fi :: ForeignImport } | ForeignExport { fd_e_ext :: XForeignExport pass -- Post typechecker, rep_ty ~ sig_ty - , fd_name :: Located (IdP pass) -- uses this name + , fd_name :: XRec pass (IdP pass) -- uses this name , fd_sig_ty :: LHsSigType pass -- sig_ty , fd_fe :: ForeignExport } -- ^ @@ -2370,7 +2372,7 @@ instance Outputable ForeignExport where -} -- | Located Rule Declarations -type LRuleDecls pass = Located (RuleDecls pass) +type LRuleDecls pass = XRec pass (RuleDecls pass) -- Note [Pragma source text] in GHC.Types.Basic -- | Rule Declarations @@ -2383,14 +2385,14 @@ type instance XCRuleDecls (GhcPass _) = NoExtField type instance XXRuleDecls (GhcPass _) = NoExtCon -- | Located Rule Declaration -type LRuleDecl pass = Located (RuleDecl pass) +type LRuleDecl pass = XRec pass (RuleDecl pass) -- | Rule Declaration data RuleDecl pass = HsRule -- Source rule { rd_ext :: XHsRule pass -- ^ After renamer, free-vars from the LHS and RHS - , rd_name :: Located (SourceText,RuleName) + , rd_name :: XRec pass (SourceText,RuleName) -- ^ Note [Pragma source text] in "GHC.Types.Basic" , rd_act :: Activation , rd_tyvs :: Maybe [LHsTyVarBndr () (NoGhcTc pass)] @@ -2398,8 +2400,8 @@ data RuleDecl pass , rd_tmvs :: [LRuleBndr pass] -- ^ Forall'd term vars, before typechecking; after typechecking -- this includes all forall'd vars - , rd_lhs :: Located (HsExpr pass) - , rd_rhs :: Located (HsExpr pass) + , rd_lhs :: XRec pass (HsExpr pass) + , rd_rhs :: XRec pass (HsExpr pass) } -- ^ -- - 'GHC.Parser.Annotation.AnnKeywordId' : @@ -2419,16 +2421,16 @@ type instance XHsRule GhcTc = HsRuleRn type instance XXRuleDecl (GhcPass _) = NoExtCon -flattenRuleDecls :: [LRuleDecls pass] -> [LRuleDecl pass] +flattenRuleDecls :: [LRuleDecls (GhcPass p)] -> [LRuleDecl (GhcPass p)] flattenRuleDecls decls = concatMap (rds_rules . unLoc) decls -- | Located Rule Binder -type LRuleBndr pass = Located (RuleBndr pass) +type LRuleBndr pass = XRec pass (RuleBndr pass) -- | Rule Binder data RuleBndr pass - = RuleBndr (XCRuleBndr pass) (Located (IdP pass)) - | RuleBndrSig (XRuleBndrSig pass) (Located (IdP pass)) (HsPatSigType pass) + = RuleBndr (XCRuleBndr pass) (XRec pass (IdP pass)) + | RuleBndrSig (XRuleBndrSig pass) (XRec pass (IdP pass)) (HsPatSigType pass) | XRuleBndr !(XXRuleBndr pass) -- ^ -- - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnOpen', @@ -2513,7 +2515,7 @@ We use exported entities for things to deprecate. -} -- | Located Warning Declarations -type LWarnDecls pass = Located (WarnDecls pass) +type LWarnDecls pass = XRec pass (WarnDecls pass) -- Note [Pragma source text] in GHC.Types.Basic -- | Warning pragma Declarations @@ -2527,10 +2529,10 @@ type instance XWarnings (GhcPass _) = NoExtField type instance XXWarnDecls (GhcPass _) = NoExtCon -- | Located Warning pragma Declaration -type LWarnDecl pass = Located (WarnDecl pass) +type LWarnDecl pass = XRec pass (WarnDecl pass) -- | Warning pragma Declaration -data WarnDecl pass = Warning (XWarning pass) [Located (IdP pass)] WarningTxt +data WarnDecl pass = Warning (XWarning pass) [XRec pass (IdP pass)] WarningTxt | XWarnDecl !(XXWarnDecl pass) type instance XWarning (GhcPass _) = NoExtField @@ -2558,13 +2560,13 @@ instance OutputableBndr (IdP (GhcPass p)) -} -- | Located Annotation Declaration -type LAnnDecl pass = Located (AnnDecl pass) +type LAnnDecl pass = XRec pass (AnnDecl pass) -- | Annotation Declaration data AnnDecl pass = HsAnnotation (XHsAnnotation pass) SourceText -- Note [Pragma source text] in GHC.Types.Basic - (AnnProvenance (IdP pass)) (Located (HsExpr pass)) + (AnnProvenance (IdP pass)) (XRec pass (HsExpr pass)) -- ^ - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnOpen', -- 'GHC.Parser.Annotation.AnnType' -- 'GHC.Parser.Annotation.AnnModule' @@ -2610,15 +2612,15 @@ pprAnnProvenance (TypeAnnProvenance (L _ name)) -} -- | Located Role Annotation Declaration -type LRoleAnnotDecl pass = Located (RoleAnnotDecl pass) +type LRoleAnnotDecl pass = XRec pass (RoleAnnotDecl pass) -- See #8185 for more info about why role annotations are -- top-level declarations -- | Role Annotation Declaration data RoleAnnotDecl pass = RoleAnnotDecl (XCRoleAnnotDecl pass) - (Located (IdP pass)) -- type constructor - [Located (Maybe Role)] -- optional annotations + (XRec pass (IdP pass)) -- type constructor + [XRec pass (Maybe Role)] -- optional annotations -- ^ - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnType', -- 'GHC.Parser.Annotation.AnnRole' ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -74,7 +74,7 @@ import qualified Language.Haskell.TH as TH (Q) -- * Expressions proper -- | Located Haskell Expression -type LHsExpr p = Located (HsExpr p) +type LHsExpr p = XRec p (HsExpr p) -- ^ May have 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnComma' when -- in a list @@ -241,7 +241,7 @@ is Less Cool because -- | A Haskell expression. data HsExpr p = HsVar (XVar p) - (Located (IdP p)) -- ^ Variable + (XRec p (IdP p)) -- ^ Variable -- See Note [Located RdrNames] @@ -415,7 +415,7 @@ data HsExpr p (HsStmtContext GhcRn) -- The parameterisation is unimportant -- because in this context we never use -- the PatGuard or ParStmt variant - (Located [ExprLStmt p]) -- "do":one or more stmts + (XRec p [ExprLStmt p]) -- "do":one or more stmts -- | Syntactic list: [a,b,c,...] -- @@ -438,7 +438,7 @@ data HsExpr p -- For details on above see note [Api annotations] in GHC.Parser.Annotation | RecordCon { rcon_ext :: XRecordCon p - , rcon_con_name :: Located (IdP p) -- The constructor name; + , rcon_con_name :: XRec p (IdP p) -- The constructor name; -- not used after type checking , rcon_flds :: HsRecordBinds p } -- The fields @@ -861,7 +861,7 @@ type instance XXPragE (GhcPass _) = NoExtCon -- @(,a,)@ is represented by -- @ExplicitTuple [Missing ty1, Present a, Missing ty3]@ -- Which in turn stands for @(\x:ty1 \y:ty2. (x,a,y))@ -type LHsTupArg id = Located (HsTupArg id) +type LHsTupArg id = XRec id (HsTupArg id) -- | - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnComma' -- For details on above see note [Api annotations] in GHC.Parser.Annotation @@ -880,10 +880,9 @@ type instance XMissing GhcTc = Scaled Type type instance XXTupArg (GhcPass _) = NoExtCon -tupArgPresent :: LHsTupArg id -> Bool +tupArgPresent :: LHsTupArg (GhcPass p) -> Bool tupArgPresent (L _ (Present {})) = True tupArgPresent (L _ (Missing {})) = False -tupArgPresent (L _ (XTupArg {})) = False {- Note [Parens in HsSyn] @@ -1415,7 +1414,7 @@ We re-use HsExpr to represent these. -} -- | Located Haskell Command (for arrow syntax) -type LHsCmd id = Located (HsCmd id) +type LHsCmd id = XRec id (HsCmd id) -- | Haskell Command (e.g. a "statement" in an Arrow proc block) data HsCmd id @@ -1505,7 +1504,7 @@ data HsCmd id -- For details on above see note [Api annotations] in GHC.Parser.Annotation | HsCmdDo (XCmdDo id) -- Type of the whole expression - (Located [CmdLStmt id]) + (XRec id [CmdLStmt id]) -- ^ - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnDo', -- 'GHC.Parser.Annotation.AnnOpen', 'GHC.Parser.Annotation.AnnSemi', -- 'GHC.Parser.Annotation.AnnVbar', @@ -1552,7 +1551,7 @@ argument of a command-forming operator. -} -- | Located Haskell Top-level Command -type LHsCmdTop p = Located (HsCmdTop p) +type LHsCmdTop p = XRec p (HsCmdTop p) -- | Haskell Top-level Command data HsCmdTop p @@ -1708,7 +1707,7 @@ patterns in each equation. data MatchGroup p body = MG { mg_ext :: XMG p body -- Post-typechecker, types of args and result - , mg_alts :: Located [LMatch p body] -- The alternatives + , mg_alts :: XRec p [LMatch p body] -- The alternatives , mg_origin :: Origin } -- The type is the type of the entire group -- t1 -> ... -> tn -> tr @@ -1728,7 +1727,7 @@ type instance XMG GhcTc b = MatchGroupTc type instance XXMatchGroup (GhcPass _) b = NoExtCon -- | Located Match -type LMatch id body = Located (Match id body) +type LMatch id body = XRec id (Match id body) -- ^ May have 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnSemi' when in a -- list @@ -1792,12 +1791,11 @@ isInfixMatch match = case m_ctxt match of FunRhs {mc_fixity = Infix} -> True _ -> False -isEmptyMatchGroup :: MatchGroup id body -> Bool +isEmptyMatchGroup :: MatchGroup (GhcPass p) body -> Bool isEmptyMatchGroup (MG { mg_alts = ms }) = null $ unLoc ms -isEmptyMatchGroup (XMatchGroup {}) = False -- | Is there only one RHS in this list of matches? -isSingletonMatchGroup :: [LMatch id body] -> Bool +isSingletonMatchGroup :: [LMatch (GhcPass p) body] -> Bool isSingletonMatchGroup matches | [L _ match] <- matches , Match { m_grhss = GRHSs { grhssGRHSs = [_] } } <- match @@ -1837,7 +1835,7 @@ type instance XCGRHSs (GhcPass _) b = NoExtField type instance XXGRHSs (GhcPass _) b = NoExtCon -- | Located Guarded Right-Hand Side -type LGRHS id body = Located (GRHS id body) +type LGRHS id body = XRec id (GRHS id body) -- | Guarded Right Hand Side. data GRHS p body = GRHS (XCGRHS p body) @@ -1934,10 +1932,10 @@ pp_rhs ctxt rhs = matchSeparator ctxt <+> pprDeeper (ppr rhs) -} -- | Located @do@ block Statement -type LStmt id body = Located (StmtLR id id body) +type LStmt id body = XRec id (StmtLR id id body) -- | Located Statement with separate Left and Right id's -type LStmtLR idL idR body = Located (StmtLR idL idR body) +type LStmtLR idL idR body = XRec idL (StmtLR idL idR body) -- | @do@ block Statement type Stmt id body = StmtLR id id body @@ -2388,11 +2386,10 @@ Bool flag that is True when the original statement was a BodyStmt, so that we can pretty-print it correctly. -} -instance (Outputable (StmtLR idL idL (LHsExpr idL)), - Outputable (XXParStmtBlock idL idR)) - => Outputable (ParStmtBlock idL idR) where +instance (Outputable (StmtLR (GhcPass idL) (GhcPass idL) (LHsExpr (GhcPass idL))), + Outputable (XXParStmtBlock (GhcPass idL) (GhcPass idR))) + => Outputable (ParStmtBlock (GhcPass idL) (GhcPass idR)) where ppr (ParStmtBlock _ stmts _ _) = interpp'SP stmts - ppr (XParStmtBlock x) = ppr x instance (OutputableBndrId pl, OutputableBndrId pr, Outputable body) @@ -2481,7 +2478,8 @@ pprArg (ApplicativeArgMany _ stmts return pat ctxt) = text "<-" <+> ppr (HsDo (panic "pprStmt") ctxt (noLoc (stmts ++ - [noLoc (LastStmt noExtField (noLoc return) Nothing noSyntaxExpr)]))) + [noLoc (LastStmt noExtField (noLoc return) Nothing noSyntaxExpr)])) + :: HsExpr (GhcPass idL)) pprTransformStmt :: (OutputableBndrId p) => [IdP (GhcPass p)] -> LHsExpr (GhcPass p) ===================================== compiler/GHC/Hs/Expr.hs-boot ===================================== @@ -10,11 +10,10 @@ module GHC.Hs.Expr where -import GHC.Types.SrcLoc ( Located ) import GHC.Utils.Outputable ( SDoc, Outputable ) import {-# SOURCE #-} GHC.Hs.Pat ( LPat ) import GHC.Types.Basic ( SpliceExplicitFlag(..)) -import GHC.Hs.Extension ( OutputableBndrId, GhcPass ) +import GHC.Hs.Extension ( OutputableBndrId, GhcPass, XRec ) import Data.Kind ( Type ) type role HsExpr nominal @@ -32,7 +31,7 @@ type family SyntaxExpr (i :: Type) instance OutputableBndrId p => Outputable (HsExpr (GhcPass p)) instance OutputableBndrId p => Outputable (HsCmd (GhcPass p)) -type LHsExpr a = Located (HsExpr a) +type LHsExpr a = XRec a (HsExpr a) pprLExpr :: (OutputableBndrId p) => LHsExpr (GhcPass p) -> SDoc ===================================== compiler/GHC/Hs/Extension.hs ===================================== @@ -32,7 +32,7 @@ import GHC.Types.Name import GHC.Types.Name.Reader import GHC.Types.Var import GHC.Utils.Outputable -import GHC.Types.SrcLoc (Located) +import GHC.Types.SrcLoc (Located, unLoc, noLoc) import Data.Kind @@ -168,9 +168,58 @@ noExtCon x = case x of {} -- | GHC's L prefixed variants wrap their vanilla variant in this type family, -- to add 'SrcLoc' info via 'Located'. Other passes than 'GhcPass' not --- interested in location information can define this instance as @f p at . -type family XRec p (f :: Type -> Type) = r | r -> p f -type instance XRec (GhcPass p) f = Located (f (GhcPass p)) +-- interested in location information can define this as +-- @type instance XRec NoLocated a = a at . +-- See Note [XRec and SrcSpans in the AST] +type family XRec p a = r | r -> a + +type instance XRec (GhcPass p) a = Located a + +{- +Note [XRec and SrcSpans in the AST] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +XRec is meant to replace most of the uses of `Located` in the AST. It is another +extension point meant to make it easier for non-GHC applications to reuse the +AST for their own purposes, and not have to deal the hassle of (perhaps) useless +SrcSpans everywhere. + +instead of `Located (HsExpr p)` or similar types, we will now have `XRec p +(HsExpr p)` + +XRec allows annotating certain points in the AST with extra information. This +maybe be source spans (for GHC), nothing (for TH), types (for HIE files), api +annotations (for exactprint) or anything else. + +This should hopefully bring us one step closer to sharing the AST between GHC +and TH. + +We use the `UnXRec`, `MapXRec` and `WrapXRec` type classes to aid us in writing +pass-polymorphic code that deals with `XRec`s +-} + +-- | We can strip off the XRec to access the underlying data. +-- See Note [XRec and SrcSpans in the AST] +class UnXRec p where + unXRec :: XRec p a -> a + +-- | We can map over the underlying type contained in an @XRec@ while preserving +-- the annotation as is. +-- See Note [XRec and SrcSpans in the AST] +class MapXRec p where + mapXRec :: (a -> b) -> XRec p a -> XRec p b + +-- | The trivial wrapper that carries no additional information +-- @noLoc@ for @GhcPass p@ +-- See Note [XRec and SrcSpans in the AST] +class WrapXRec p where + wrapXRec :: a -> XRec p a + +instance UnXRec (GhcPass p) where + unXRec = unLoc +instance MapXRec (GhcPass p) where + mapXRec = fmap +instance WrapXRec (GhcPass p) where + wrapXRec = noLoc {- Note [NoExtCon and strict fields] ===================================== compiler/GHC/Hs/ImpExp.hs ===================================== @@ -43,7 +43,7 @@ One per \tr{import} declaration in a module. -} -- | Located Import Declaration -type LImportDecl pass = Located (ImportDecl pass) +type LImportDecl pass = XRec pass (ImportDecl pass) -- ^ When in a list this may have -- -- - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnSemi' @@ -81,14 +81,14 @@ data ImportDecl pass ideclExt :: XCImportDecl pass, ideclSourceSrc :: SourceText, -- Note [Pragma source text] in GHC.Types.Basic - ideclName :: Located ModuleName, -- ^ Module name. + ideclName :: XRec pass ModuleName, -- ^ Module name. ideclPkgQual :: Maybe StringLiteral, -- ^ Package qualifier. ideclSource :: IsBootInterface, -- ^ IsBoot <=> {-\# SOURCE \#-} import ideclSafe :: Bool, -- ^ True => safe import ideclQualified :: ImportDeclQualifiedStyle, -- ^ If/how the import is qualified. ideclImplicit :: Bool, -- ^ True => implicit import (of Prelude) - ideclAs :: Maybe (Located ModuleName), -- ^ as Module - ideclHiding :: Maybe (Bool, Located [LIE pass]) + ideclAs :: Maybe (XRec pass ModuleName), -- ^ as Module + ideclHiding :: Maybe (Bool, XRec pass [LIE pass]) -- ^ (True => hiding, names) } | XImportDecl !(XXImportDecl pass) @@ -193,7 +193,7 @@ type LIEWrappedName name = Located (IEWrappedName name) -- | Located Import or Export -type LIE pass = Located (IE pass) +type LIE pass = XRec pass (IE pass) -- ^ When in a list this may have -- -- - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnComma' @@ -230,7 +230,7 @@ data IE pass (LIEWrappedName (IdP pass)) IEWildcard [LIEWrappedName (IdP pass)] - [Located (FieldLbl (IdP pass))] + [XRec pass (FieldLbl (IdP pass))] -- ^ Imported or exported Thing With given imported or exported -- -- The thing is a Class/Type and the imported or exported things are @@ -241,7 +241,7 @@ data IE pass -- 'GHC.Parser.Annotation.AnnType' -- For details on above see note [Api annotations] in GHC.Parser.Annotation - | IEModuleContents (XIEModuleContents pass) (Located ModuleName) + | IEModuleContents (XIEModuleContents pass) (XRec pass ModuleName) -- ^ Imported or exported module contents -- -- (Export Only) ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -33,6 +33,8 @@ import GHC.Hs.Type import GHC.Hs.Pat import GHC.Hs.ImpExp +import GHC.Types.SrcLoc ( Located ) + -- --------------------------------------------------------------------- -- Data derivations from GHC.Hs----------------------------------------- @@ -433,9 +435,9 @@ deriving instance Data thing => Data (HsScaled GhcPs thing) deriving instance Data thing => Data (HsScaled GhcRn thing) deriving instance Data thing => Data (HsScaled GhcTc thing) -deriving instance Data (LHsTypeArg GhcPs) -deriving instance Data (LHsTypeArg GhcRn) -deriving instance Data (LHsTypeArg GhcTc) +deriving instance Data (HsArg (Located (HsType GhcPs)) (Located (HsKind GhcPs))) +deriving instance Data (HsArg (Located (HsType GhcRn)) (Located (HsKind GhcRn))) +deriving instance Data (HsArg (Located (HsType GhcTc)) (Located (HsKind GhcTc))) -- deriving instance (DataIdLR p p) => Data (ConDeclField p) deriving instance Data (ConDeclField GhcPs) ===================================== compiler/GHC/Hs/Pat.hs ===================================== @@ -78,7 +78,7 @@ import GHC.Types.Name (Name) -- libraries: import Data.Data hiding (TyCon,Fixity) -type LPat p = XRec p Pat +type LPat p = XRec p (Pat p) -- | Pattern -- @@ -93,7 +93,7 @@ data Pat p -- AZ:TODO above comment needs to be updated | VarPat (XVarPat p) - (Located (IdP p)) -- ^ Variable Pattern + (XRec p (IdP p)) -- ^ Variable Pattern -- See Note [Located RdrNames] in GHC.Hs.Expr | LazyPat (XLazyPat p) @@ -103,7 +103,7 @@ data Pat p -- For details on above see note [Api annotations] in GHC.Parser.Annotation | AsPat (XAsPat p) - (Located (IdP p)) (LPat p) -- ^ As pattern + (XRec p (IdP p)) (LPat p) -- ^ As pattern -- ^ - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnAt' -- For details on above see note [Api annotations] in GHC.Parser.Annotation @@ -176,7 +176,7 @@ data Pat p ------------ Constructor patterns --------------- | ConPat { pat_con_ext :: XConPat p, - pat_con :: Located (ConLikeP p), + pat_con :: XRec p (ConLikeP p), pat_args :: HsConPatDetails p } -- ^ Constructor Pattern @@ -212,7 +212,7 @@ data Pat p (XNPat p) -- Overall type of pattern. Might be -- different than the literal's type -- if (==) or negate changes the type - (Located (HsOverLit p)) -- ALWAYS positive + (XRec p (HsOverLit p)) -- ALWAYS positive (Maybe (SyntaxExpr p)) -- Just (Name of 'negate') for -- negative patterns, Nothing -- otherwise @@ -224,8 +224,8 @@ data Pat p -- For details on above see note [Api annotations] in GHC.Parser.Annotation | NPlusKPat (XNPlusKPat p) -- Type of overall pattern - (Located (IdP p)) -- n+k pattern - (Located (HsOverLit p)) -- It'll always be an HsIntegral + (XRec p (IdP p)) -- n+k pattern + (XRec p (HsOverLit p)) -- It'll always be an HsIntegral (HsOverLit p) -- See Note [NPlusK patterns] in GHC.Tc.Gen.Pat -- NB: This could be (PostTc ...), but that induced a -- a new hs-boot file. Not worth it. ===================================== compiler/GHC/Hs/Pat.hs-boot ===================================== @@ -15,6 +15,6 @@ import Data.Kind type role Pat nominal data Pat (i :: Type) -type LPat i = XRec i Pat +type LPat i = XRec i (Pat i) instance OutputableBndrId p => Outputable (Pat (GhcPass p)) ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -117,7 +117,7 @@ import Data.Maybe -} -- | Located Bang Type -type LBangType pass = Located (BangType pass) +type LBangType pass = XRec pass (BangType pass) -- | Bang Type -- @@ -127,13 +127,13 @@ type LBangType pass = Located (BangType pass) -- 'HsDocTy'. See #15206 for motivation and 'getBangType' for an example. type BangType pass = HsType pass -- Bangs are in the HsType data type -getBangType :: LHsType a -> LHsType a +getBangType :: LHsType (GhcPass p) -> LHsType (GhcPass p) getBangType (L _ (HsBangTy _ _ lty)) = lty getBangType (L _ (HsDocTy x (L _ (HsBangTy _ _ lty)) lds)) = addCLoc lty lds (HsDocTy x lty lds) getBangType lty = lty -getBangStrictness :: LHsType a -> HsSrcBang +getBangStrictness :: LHsType (GhcPass p) -> HsSrcBang getBangStrictness (L _ (HsBangTy _ s _)) = s getBangStrictness (L _ (HsDocTy _ (L _ (HsBangTy _ s _)) _)) = s getBangStrictness _ = (HsSrcBang NoSourceText NoSrcUnpack NoSrcStrict) @@ -304,11 +304,11 @@ quantified in left-to-right order in kind signatures is nice since: -} -- | Located Haskell Context -type LHsContext pass = Located (HsContext pass) +type LHsContext pass = XRec pass (HsContext pass) -- ^ 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnUnit' -- For details on above see note [Api annotations] in GHC.Parser.Annotation -noLHsContext :: LHsContext pass +noLHsContext :: LHsContext (GhcPass p) -- Use this when there is no context in the original program -- It would really be more kosher to use a Maybe, to distinguish -- class () => C a where ... @@ -320,7 +320,7 @@ noLHsContext = noLoc [] type HsContext pass = [LHsType pass] -- | Located Haskell Type -type LHsType pass = Located (HsType pass) +type LHsType pass = XRec pass (HsType pass) -- ^ May have 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnComma' when -- in a list @@ -330,7 +330,7 @@ type LHsType pass = Located (HsType pass) type HsKind pass = HsType pass -- | Located Haskell Kind -type LHsKind pass = Located (HsKind pass) +type LHsKind pass = XRec pass (HsKind pass) -- ^ 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnDcolon' -- For details on above see note [Api annotations] in GHC.Parser.Annotation @@ -362,7 +362,7 @@ type instance XHsForAllInvis (GhcPass _) = NoExtField type instance XXHsForAllTelescope (GhcPass _) = NoExtCon -- | Located Haskell Type Variable Binder -type LHsTyVarBndr flag pass = Located (HsTyVarBndr flag pass) +type LHsTyVarBndr flag pass = XRec pass (HsTyVarBndr flag pass) -- See Note [HsType binders] -- | Located Haskell Quantified Type Variables @@ -638,13 +638,13 @@ data HsTyVarBndr flag pass = UserTyVar -- no explicit kinding (XUserTyVar pass) flag - (Located (IdP pass)) + (XRec pass (IdP pass)) -- See Note [Located RdrNames] in GHC.Hs.Expr | KindedTyVar (XKindedTyVar pass) flag - (Located (IdP pass)) + (XRec pass (IdP pass)) (LHsKind pass) -- The user-supplied kind signature -- ^ -- - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnOpen', @@ -678,7 +678,7 @@ isHsKindedTyVar (KindedTyVar {}) = True isHsKindedTyVar (XTyVarBndr {}) = False -- | Do all type variables in this 'LHsQTyVars' come with kind annotations? -hsTvbAllKinded :: LHsQTyVars pass -> Bool +hsTvbAllKinded :: LHsQTyVars (GhcPass p) -> Bool hsTvbAllKinded = all (isHsKindedTyVar . unLoc) . hsQTvExplicit instance NamedThing (HsTyVarBndr flag GhcRn) where @@ -705,7 +705,7 @@ data HsType pass | HsTyVar (XTyVar pass) PromotionFlag -- Whether explicitly promoted, -- for the pretty printer - (Located (IdP pass)) + (XRec pass (IdP pass)) -- Type variable, type constructor, or data constructor -- see Note [Promotions (HsTyVar)] -- See Note [Located RdrNames] in GHC.Hs.Expr @@ -755,7 +755,7 @@ data HsType pass -- For details on above see note [Api annotations] in GHC.Parser.Annotation | HsOpTy (XOpTy pass) - (LHsType pass) (Located (IdP pass)) (LHsType pass) + (LHsType pass) (XRec pass (IdP pass)) (LHsType pass) -- ^ - 'GHC.Parser.Annotation.AnnKeywordId' : None -- For details on above see note [Api annotations] in GHC.Parser.Annotation @@ -771,7 +771,7 @@ data HsType pass -- For details on above see note [Api annotations] in GHC.Parser.Annotation | HsIParamTy (XIParamTy pass) - (Located HsIPName) -- (?x :: ty) + (XRec pass HsIPName) -- (?x :: ty) (LHsType pass) -- Implicit parameters as they occur in -- contexts -- ^ @@ -1076,7 +1076,7 @@ data HsTupleSort = HsUnboxedTuple deriving Data -- | Located Constructor Declaration Field -type LConDeclField pass = Located (ConDeclField pass) +type LConDeclField pass = XRec pass (ConDeclField pass) -- ^ May have 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnComma' when -- in a list @@ -1117,8 +1117,8 @@ instance (Outputable arg, Outputable rec) ppr (InfixCon l r) = text "InfixCon:" <+> ppr [l, r] hsConDetailsArgs :: - HsConDetails (LHsType a) (Located [LConDeclField a]) - -> [LHsType a] + HsConDetails (LHsType (GhcPass p)) (Located [LConDeclField (GhcPass p)]) + -> [LHsType (GhcPass p)] hsConDetailsArgs details = case details of InfixCon a b -> [a,b] PrefixCon xs -> xs @@ -1275,7 +1275,7 @@ hsLTyVarLocNames qtvs = map hsLTyVarLocName (hsQTvExplicit qtvs) -- type S = (F :: res_kind) -- ^^^^^^^^ -- -hsTyKindSig :: LHsType pass -> Maybe (LHsKind pass) +hsTyKindSig :: LHsType (GhcPass p) -> Maybe (LHsKind (GhcPass p)) hsTyKindSig lty = case unLoc lty of HsParTy _ lty' -> hsTyKindSig lty' @@ -1283,11 +1283,11 @@ hsTyKindSig lty = _ -> Nothing --------------------- -ignoreParens :: LHsType pass -> LHsType pass +ignoreParens :: LHsType (GhcPass p) -> LHsType (GhcPass p) ignoreParens (L _ (HsParTy _ ty)) = ignoreParens ty ignoreParens ty = ty -isLHsForAllTy :: LHsType p -> Bool +isLHsForAllTy :: LHsType (GhcPass p) -> Bool isLHsForAllTy (L _ (HsForAllTy {})) = True isLHsForAllTy _ = False @@ -1374,7 +1374,7 @@ numVisibleArgs = count is_vis type LHsTypeArg p = HsArg (LHsType p) (LHsKind p) -- | Compute the 'SrcSpan' associated with an 'LHsTypeArg'. -lhsTypeArgSrcSpan :: LHsTypeArg pass -> SrcSpan +lhsTypeArgSrcSpan :: LHsTypeArg (GhcPass pass) -> SrcSpan lhsTypeArgSrcSpan arg = case arg of HsValArg tm -> getLoc tm HsTypeArg at ty -> at `combineSrcSpans` getLoc ty @@ -1406,12 +1406,12 @@ The SrcSpan is the span of the original HsPar -- such as @(forall a. <...>)@. The downside to this is that it is not -- generally possible to take the returned types and reconstruct the original -- type (parentheses and all) from them. -splitLHsPatSynTy :: LHsType pass - -> ( [LHsTyVarBndr Specificity pass] -- universals - , LHsContext pass -- required constraints - , [LHsTyVarBndr Specificity pass] -- existentials - , LHsContext pass -- provided constraints - , LHsType pass) -- body type +splitLHsPatSynTy :: LHsType (GhcPass p) + -> ( [LHsTyVarBndr Specificity (GhcPass p)] -- universals + , LHsContext (GhcPass p) -- required constraints + , [LHsTyVarBndr Specificity (GhcPass p)] -- existentials + , LHsContext (GhcPass p) -- provided constraints + , LHsType (GhcPass p)) -- body type splitLHsPatSynTy ty = (univs, reqs, exis, provs, ty4) where (univs, ty1) = splitLHsForAllTyInvis ty @@ -1433,8 +1433,8 @@ splitLHsPatSynTy ty = (univs, reqs, exis, provs, ty4) -- such as @(forall a. <...>)@. The downside to this is that it is not -- generally possible to take the returned types and reconstruct the original -- type (parentheses and all) from them. -splitLHsSigmaTyInvis :: LHsType pass - -> ([LHsTyVarBndr Specificity pass], LHsContext pass, LHsType pass) +splitLHsSigmaTyInvis :: LHsType (GhcPass p) + -> ([LHsTyVarBndr Specificity (GhcPass p)], LHsContext (GhcPass p), LHsType (GhcPass p)) splitLHsSigmaTyInvis ty | (tvs, ty1) <- splitLHsForAllTyInvis ty , (ctxt, ty2) <- splitLHsQualTy ty1 @@ -1453,8 +1453,8 @@ splitLHsSigmaTyInvis ty -- Unlike 'splitLHsSigmaTyInvis', this function does not look through -- parentheses, hence the suffix @_KP@ (short for \"Keep Parentheses\"). splitLHsSigmaTyInvis_KP :: - LHsType pass - -> (Maybe [LHsTyVarBndr Specificity pass], Maybe (LHsContext pass), LHsType pass) + LHsType (GhcPass pass) + -> (Maybe [LHsTyVarBndr Specificity (GhcPass pass)], Maybe (LHsContext (GhcPass pass)), LHsType (GhcPass pass)) splitLHsSigmaTyInvis_KP ty | (mb_tvbs, ty1) <- splitLHsForAllTyInvis_KP ty , (mb_ctxt, ty2) <- splitLHsQualTy_KP ty1 @@ -1475,8 +1475,8 @@ splitLHsSigmaTyInvis_KP ty -- See @Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts)@ -- "GHC.Hs.Decls" for why this is important. splitLHsGADTPrefixTy :: - LHsType pass - -> (Maybe [LHsTyVarBndr Specificity pass], Maybe (LHsContext pass), LHsType pass) + LHsType (GhcPass pass) + -> (Maybe [LHsTyVarBndr Specificity (GhcPass pass)], Maybe (LHsContext (GhcPass pass)), LHsType (GhcPass pass)) splitLHsGADTPrefixTy = splitLHsSigmaTyInvis_KP -- | Decompose a type of the form @forall . body@ into its constituent @@ -1495,7 +1495,7 @@ splitLHsGADTPrefixTy = splitLHsSigmaTyInvis_KP -- Unlike 'splitLHsSigmaTyInvis', this function does not look through -- parentheses, hence the suffix @_KP@ (short for \"Keep Parentheses\"). splitLHsForAllTyInvis :: - LHsType pass -> ([LHsTyVarBndr Specificity pass], LHsType pass) + LHsType (GhcPass pass) -> ([LHsTyVarBndr Specificity (GhcPass pass)], LHsType (GhcPass pass)) splitLHsForAllTyInvis ty | (mb_tvbs, body) <- splitLHsForAllTyInvis_KP (ignoreParens ty) = (fromMaybe [] mb_tvbs, body) @@ -1512,7 +1512,7 @@ splitLHsForAllTyInvis ty -- Unlike 'splitLHsForAllTyInvis', this function does not look through -- parentheses, hence the suffix @_KP@ (short for \"Keep Parentheses\"). splitLHsForAllTyInvis_KP :: - LHsType pass -> (Maybe [LHsTyVarBndr Specificity pass], LHsType pass) + LHsType (GhcPass pass) -> (Maybe [LHsTyVarBndr Specificity (GhcPass pass)], LHsType (GhcPass pass)) splitLHsForAllTyInvis_KP lty@(L _ ty) = case ty of HsForAllTy { hst_tele = HsForAllInvis { hsf_invis_bndrs = tvs } @@ -1526,7 +1526,7 @@ splitLHsForAllTyInvis_KP lty@(L _ ty) = -- such as @(context => <...>)@. The downside to this is that it is not -- generally possible to take the returned types and reconstruct the original -- type (parentheses and all) from them. -splitLHsQualTy :: LHsType pass -> (LHsContext pass, LHsType pass) +splitLHsQualTy :: LHsType (GhcPass pass) -> (LHsContext (GhcPass pass), LHsType (GhcPass pass)) splitLHsQualTy ty | (mb_ctxt, body) <- splitLHsQualTy_KP (ignoreParens ty) = (fromMaybe noLHsContext mb_ctxt, body) @@ -1535,7 +1535,7 @@ splitLHsQualTy ty -- -- Unlike 'splitLHsQualTy', this function does not look through -- parentheses, hence the suffix @_KP@ (short for \"Keep Parentheses\"). -splitLHsQualTy_KP :: LHsType pass -> (Maybe (LHsContext pass), LHsType pass) +splitLHsQualTy_KP :: LHsType (GhcPass pass) -> (Maybe (LHsContext (GhcPass pass)), LHsType (GhcPass pass)) splitLHsQualTy_KP (L _ (HsQualTy { hst_ctxt = ctxt, hst_body = body })) = (Just ctxt, body) splitLHsQualTy_KP body = (Nothing, body) @@ -1671,7 +1671,7 @@ also forbids them in types involved with `deriving`: -} -- | Located Field Occurrence -type LFieldOcc pass = Located (FieldOcc pass) +type LFieldOcc pass = XRec pass (FieldOcc pass) -- | Field Occurrence -- @@ -2009,7 +2009,7 @@ hsTypeNeedsParens p = go_hs_ty go_core_ty (CastTy t _) = go_core_ty t go_core_ty (CoercionTy{}) = False -maybeAddSpace :: [LHsType pass] -> SDoc -> SDoc +maybeAddSpace :: [LHsType (GhcPass p)] -> SDoc -> SDoc -- See Note [Printing promoted type constructors] -- in GHC.Iface.Type. This code implements the same -- logic for printing HsType @@ -2018,7 +2018,7 @@ maybeAddSpace tys doc , lhsTypeHasLeadingPromotionQuote ty = space <> doc | otherwise = doc -lhsTypeHasLeadingPromotionQuote :: LHsType pass -> Bool +lhsTypeHasLeadingPromotionQuote :: LHsType (GhcPass p) -> Bool lhsTypeHasLeadingPromotionQuote ty = goL ty where ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -178,9 +178,9 @@ unguardedRHS :: SrcSpan -> Located (body (GhcPass p)) -> [LGRHS (GhcPass p) (Located (body (GhcPass p)))] unguardedRHS loc rhs = [L loc (GRHS noExtField [] rhs)] -mkMatchGroup :: (XMG name (Located (body name)) ~ NoExtField) - => Origin -> [LMatch name (Located (body name))] - -> MatchGroup name (Located (body name)) +mkMatchGroup :: ( XMG (GhcPass p) (Located (body (GhcPass p))) ~ NoExtField ) + => Origin -> [Located (Match (GhcPass p) (Located (body (GhcPass p))))] + -> MatchGroup (GhcPass p) (Located (body (GhcPass p))) mkMatchGroup origin matches = MG { mg_ext = noExtField , mg_alts = mkLocatedList matches , mg_origin = origin } @@ -787,9 +787,9 @@ mkPatSynBind name details lpat dir = PatSynBind noExtField psb -- |If any of the matches in the 'FunBind' are infix, the 'FunBind' is -- considered infix. -isInfixFunBind :: HsBindLR id1 id2 -> Bool +isInfixFunBind :: forall id1 id2. UnXRec id2 => HsBindLR id1 id2 -> Bool isInfixFunBind (FunBind { fun_matches = MG _ matches _ }) - = any (isInfixMatch . unLoc) (unLoc matches) + = any (isInfixMatch . unXRec @id2) (unXRec @id2 matches) isInfixFunBind _ = False @@ -942,11 +942,11 @@ collectHsBindsBinders :: CollectPass p -> [IdP p] collectHsBindsBinders binds = collect_binds False binds [] -collectHsBindListBinders :: CollectPass p +collectHsBindListBinders :: forall p idR. CollectPass p => [LHsBindLR p idR] -> [IdP p] -- ^ Same as 'collectHsBindsBinders', but works over a list of bindings -collectHsBindListBinders = foldr (collect_bind False . unLoc) [] +collectHsBindListBinders = foldr (collect_bind False . unXRec @p) [] collect_hs_val_binders :: CollectPass (GhcPass idL) => Bool @@ -956,42 +956,42 @@ collect_hs_val_binders ps (ValBinds _ binds _) = collect_binds ps binds [] collect_hs_val_binders ps (XValBindsLR (NValBinds binds _)) = collect_out_binds ps binds -collect_out_binds :: CollectPass p +collect_out_binds :: forall p. CollectPass p => Bool -> [(RecFlag, LHsBinds p)] -> [IdP p] collect_out_binds ps = foldr (collect_binds ps . snd) [] -collect_binds :: CollectPass p +collect_binds :: forall p idR. CollectPass p => Bool -> LHsBindsLR p idR -> [IdP p] -> [IdP p] -- ^ Collect 'Id's, or 'Id's + pattern synonyms, depending on boolean flag -collect_binds ps binds acc = foldr (collect_bind ps . unLoc) acc binds +collect_binds ps binds acc = foldr (collect_bind ps . unXRec @p) acc binds -collect_bind :: CollectPass p +collect_bind :: forall p idR. CollectPass p => Bool -> HsBindLR p idR -> [IdP p] -> [IdP p] collect_bind _ (PatBind { pat_lhs = p }) acc = collect_lpat p acc -collect_bind _ (FunBind { fun_id = L _ f }) acc = f : acc +collect_bind _ (FunBind { fun_id = f }) acc = unXRec @p f : acc collect_bind _ (VarBind { var_id = f }) acc = f : acc collect_bind _ (AbsBinds { abs_exports = dbinds }) acc = map abe_poly dbinds ++ acc -- I don't think we want the binders from the abe_binds -- binding (hence see AbsBinds) is in zonking in GHC.Tc.Utils.Zonk -collect_bind omitPatSyn (PatSynBind _ (PSB { psb_id = L _ ps })) acc +collect_bind omitPatSyn (PatSynBind _ (PSB { psb_id = ps })) acc | omitPatSyn = acc - | otherwise = ps : acc + | otherwise = unXRec @p ps : acc collect_bind _ (PatSynBind _ (XPatSynBind _)) acc = acc collect_bind _ (XHsBindsLR _) acc = acc -collectMethodBinders :: LHsBindsLR idL idR -> [Located (IdP idL)] +collectMethodBinders :: forall idL idR. UnXRec idL => LHsBindsLR idL idR -> [XRec idL (IdP idL)] -- ^ Used exclusively for the bindings of an instance decl which are all -- 'FunBinds' -collectMethodBinders binds = foldr (get . unLoc) [] binds +collectMethodBinders binds = foldr (get . unXRec @idL) [] binds where get (FunBind { fun_id = f }) fs = f : fs get _ fs = fs @@ -1042,18 +1042,18 @@ collectPatsBinders pats = foldr collect_lpat [] pats ------------- collect_lpat :: forall pass. (CollectPass pass) => LPat pass -> [IdP pass] -> [IdP pass] -collect_lpat p bndrs = collect_pat (unLoc p) bndrs +collect_lpat p bndrs = collect_pat (unXRec @pass p) bndrs collect_pat :: forall p. CollectPass p => Pat p -> [IdP p] -> [IdP p] collect_pat pat bndrs = case pat of - (VarPat _ var) -> unLoc var : bndrs + (VarPat _ var) -> unXRec @p var : bndrs (WildPat _) -> bndrs (LazyPat _ pat) -> collect_lpat pat bndrs (BangPat _ pat) -> collect_lpat pat bndrs - (AsPat _ a pat) -> unLoc a : collect_lpat pat bndrs + (AsPat _ a pat) -> unXRec @p a : collect_lpat pat bndrs (ViewPat _ _ pat) -> collect_lpat pat bndrs (ParPat _ pat) -> collect_lpat pat bndrs (ListPat _ pats) -> foldr collect_lpat bndrs pats @@ -1063,7 +1063,7 @@ collect_pat pat bndrs = case pat of -- See Note [Dictionary binders in ConPatOut] (LitPat _ _) -> bndrs (NPat {}) -> bndrs - (NPlusKPat _ n _ _ _ _) -> unLoc n : bndrs + (NPlusKPat _ n _ _ _ _) -> unXRec @p n : bndrs (SigPat _ pat _) -> collect_lpat pat bndrs (SplicePat _ (HsSpliced _ _ (HsSplicedPat pat))) -> collect_pat pat bndrs @@ -1076,18 +1076,15 @@ collect_pat pat bndrs = case pat of -- -- In particular, Haddock already makes use of this, with an instance for its 'DocNameI' pass so that -- it can reuse the code in GHC for collecting binders. -class (XRec p Pat ~ Located (Pat p)) => CollectPass p where +class UnXRec p => CollectPass p where collectXXPat :: Proxy p -> XXPat p -> [IdP p] -> [IdP p] -instance CollectPass (GhcPass 'Parsed) where - collectXXPat _ ext = noExtCon ext - -instance CollectPass (GhcPass 'Renamed) where - collectXXPat _ ext = noExtCon ext - -instance CollectPass (GhcPass 'Typechecked) where - collectXXPat _ (CoPat _ pat _) = collect_pat pat - +instance IsPass p => CollectPass (GhcPass p) where + collectXXPat _ ext = + case ghcPass @p of + GhcTc -> let CoPat _ pat _ = ext in collect_pat pat + GhcRn -> noExtCon ext + GhcPs -> noExtCon ext {- Note [Dictionary binders in ConPatOut] See also same Note in GHC.HsToCore.Arrows @@ -1174,32 +1171,33 @@ hsLTyClDeclBinders (L loc (DataDecl { tcdLName = (L _ name) ------------------- -hsForeignDeclsBinders :: [LForeignDecl pass] -> [Located (IdP pass)] +hsForeignDeclsBinders :: forall pass. (UnXRec pass, MapXRec pass) => [LForeignDecl pass] -> [XRec pass (IdP pass)] -- ^ See Note [SrcSpan for binders] hsForeignDeclsBinders foreign_decls - = [ L decl_loc n - | L decl_loc (ForeignImport { fd_name = L _ n }) + = [ mapXRec @pass (const $ unXRec @pass n) fi + | fi@(unXRec @pass -> ForeignImport { fd_name = n }) <- foreign_decls] ------------------- -hsPatSynSelectors :: HsValBinds (GhcPass p) -> [IdP (GhcPass p)] +hsPatSynSelectors :: IsPass p => HsValBinds (GhcPass p) -> [IdP (GhcPass p)] -- ^ Collects record pattern-synonym selectors only; the pattern synonym -- names are collected by 'collectHsValBinders'. hsPatSynSelectors (ValBinds _ _ _) = panic "hsPatSynSelectors" hsPatSynSelectors (XValBindsLR (NValBinds binds _)) = foldr addPatSynSelector [] . unionManyBags $ map snd binds -addPatSynSelector:: LHsBind p -> [IdP p] -> [IdP p] +addPatSynSelector :: forall p. UnXRec p => LHsBind p -> [IdP p] -> [IdP p] addPatSynSelector bind sels - | PatSynBind _ (PSB { psb_args = RecCon as }) <- unLoc bind - = map (unLoc . recordPatSynSelectorId) as ++ sels + | PatSynBind _ (PSB { psb_args = RecCon as }) <- unXRec @p bind + = map (unXRec @p . recordPatSynSelectorId) as ++ sels | otherwise = sels -getPatSynBinds :: [(RecFlag, LHsBinds id)] -> [PatSynBind id id] +getPatSynBinds :: forall id. UnXRec id + => [(RecFlag, LHsBinds id)] -> [PatSynBind id id] getPatSynBinds binds = [ psb | (_, lbinds) <- binds - , L _ (PatSynBind _ psb) <- bagToList lbinds ] + , (unXRec @id -> (PatSynBind _ psb)) <- bagToList lbinds ] ------------------- hsLInstDeclBinders :: IsPass p @@ -1343,7 +1341,7 @@ lStmtsImplicits = hs_lstmts hs_stmt (BindStmt _ pat _) = lPatImplicits pat hs_stmt (ApplicativeStmt _ args _) = concatMap do_arg args where do_arg (_, ApplicativeArgOne { app_arg_pattern = pat }) = lPatImplicits pat - do_arg (_, ApplicativeArgMany { app_stmts = stmts }) = hs_lstmts stmts + do_arg (_, ApplicativeArgMany { app_stmts = stmts }) = hs_lstmts stmts hs_stmt (LetStmt _ binds) = hs_local_binds (unLoc binds) hs_stmt (BodyStmt {}) = [] hs_stmt (LastStmt {}) = [] ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -1,5 +1,8 @@ -- | Extract docs from the renamer output so they can be serialized. {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ViewPatterns #-} @@ -112,9 +115,7 @@ user-written. This lets us relate Names (from ClsInsts) to comments (associated with InstDecls and DerivDecls). -} -getMainDeclBinder :: (CollectPass (GhcPass p)) - => HsDecl (GhcPass p) - -> [IdP (GhcPass p)] +getMainDeclBinder :: CollectPass (GhcPass p) => HsDecl (GhcPass p) -> [IdP (GhcPass p)] getMainDeclBinder (TyClD _ d) = [tcdName d] getMainDeclBinder (ValD _ d) = case collectHsBindBinders d of @@ -125,13 +126,14 @@ getMainDeclBinder (ForD _ (ForeignImport _ name _ _)) = [unLoc name] getMainDeclBinder (ForD _ (ForeignExport _ _ _ _)) = [] getMainDeclBinder _ = [] -sigNameNoLoc :: Sig pass -> [IdP pass] -sigNameNoLoc (TypeSig _ ns _) = map unLoc ns -sigNameNoLoc (ClassOpSig _ _ ns _) = map unLoc ns -sigNameNoLoc (PatSynSig _ ns _) = map unLoc ns -sigNameNoLoc (SpecSig _ n _ _) = [unLoc n] -sigNameNoLoc (InlineSig _ n _) = [unLoc n] -sigNameNoLoc (FixSig _ (FixitySig _ ns _)) = map unLoc ns + +sigNameNoLoc :: forall pass. UnXRec pass => Sig pass -> [IdP pass] +sigNameNoLoc (TypeSig _ ns _) = map (unXRec @pass) ns +sigNameNoLoc (ClassOpSig _ _ ns _) = map (unXRec @pass) ns +sigNameNoLoc (PatSynSig _ ns _) = map (unXRec @pass) ns +sigNameNoLoc (SpecSig _ n _ _) = [unXRec @pass n] +sigNameNoLoc (InlineSig _ n _) = [unXRec @pass n] +sigNameNoLoc (FixSig _ (FixitySig _ ns _)) = map (unXRec @pass) ns sigNameNoLoc _ = [] -- Extract the source location where an instance is defined. This is used @@ -302,14 +304,14 @@ ungroup group_ = -- | Collect docs and attach them to the right declarations. -- -- A declaration may have multiple doc strings attached to it. -collectDocs :: [LHsDecl pass] -> [(LHsDecl pass, [HsDocString])] +collectDocs :: forall p. UnXRec p => [LHsDecl p] -> [(LHsDecl p, [HsDocString])] -- ^ This is an example. collectDocs = go [] Nothing where go docs mprev decls = case (decls, mprev) of - ((unLoc->DocD _ (DocCommentNext s)) : ds, Nothing) -> go (s:docs) Nothing ds - ((unLoc->DocD _ (DocCommentNext s)) : ds, Just prev) -> finished prev docs $ go [s] Nothing ds - ((unLoc->DocD _ (DocCommentPrev s)) : ds, mprev) -> go (s:docs) mprev ds + ((unXRec @p -> DocD _ (DocCommentNext s)) : ds, Nothing) -> go (s:docs) Nothing ds + ((unXRec @p -> DocD _ (DocCommentNext s)) : ds, Just prev) -> finished prev docs $ go [s] Nothing ds + ((unXRec @p -> DocD _ (DocCommentPrev s)) : ds, mprev) -> go (s:docs) mprev ds (d : ds, Nothing) -> go docs (Just d) ds (d : ds, Just prev) -> finished prev docs $ go [] (Just d) ds ([] , Nothing) -> [] @@ -318,8 +320,8 @@ collectDocs = go [] Nothing finished decl docs rest = (decl, reverse docs) : rest -- | Filter out declarations that we don't handle in Haddock -filterDecls :: [(LHsDecl a, doc)] -> [(LHsDecl a, doc)] -filterDecls = filter (isHandled . unLoc . fst) +filterDecls :: forall p doc. UnXRec p => [(LHsDecl p, doc)] -> [(LHsDecl p, doc)] +filterDecls = filter (isHandled . unXRec @p . fst) where isHandled (ForD _ (ForeignImport {})) = True isHandled (TyClD {}) = True @@ -333,12 +335,12 @@ filterDecls = filter (isHandled . unLoc . fst) -- | Go through all class declarations and filter their sub-declarations -filterClasses :: [(LHsDecl a, doc)] -> [(LHsDecl a, doc)] -filterClasses = map (first (mapLoc filterClass)) +filterClasses :: forall p doc. (UnXRec p, MapXRec p) => [(LHsDecl p, doc)] -> [(LHsDecl p, doc)] +filterClasses = map (first (mapXRec @p filterClass)) where filterClass (TyClD x c@(ClassDecl {})) = TyClD x $ c { tcdSigs = - filter (liftA2 (||) (isUserSig . unLoc) isMinimalLSig) (tcdSigs c) } + filter (liftA2 (||) (isUserSig . unXRec @p) isMinimalLSig) (tcdSigs c) } filterClass d = d -- | Was this signature given by the user? ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -102,6 +102,7 @@ dsIPBinds (IPBinds ev_binds ip_binds) body -- dependency order; hence Rec ; foldrM ds_ip_bind inner ip_binds } where + ds_ip_bind :: LIPBind GhcTc -> CoreExpr -> DsM CoreExpr ds_ip_bind (L _ (IPBind _ ~(Right n) e)) body = do e' <- dsLExpr e return (Let (NonRec n e') body) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -390,9 +390,8 @@ getRealSpan :: SrcSpan -> Maybe Span getRealSpan (RealSrcSpan sp _) = Just sp getRealSpan _ = Nothing -grhss_span :: GRHSs p body -> SrcSpan +grhss_span :: GRHSs (GhcPass p) body -> SrcSpan grhss_span (GRHSs _ xs bs) = foldl' combineSrcSpans (getLoc bs) (map getLoc xs) -grhss_span (XGRHSs _) = panic "XGRHS has no span" bindingsOnly :: [Context Name] -> HieM [HieAST a] bindingsOnly [] = pure [] @@ -488,8 +487,8 @@ patScopes rsp useScope patScope xs = tvScopes :: TyVarScope -> Scope - -> [LHsTyVarBndr flag a] - -> [TVScoped (LHsTyVarBndr flag a)] + -> [LHsTyVarBndr flag (GhcPass a)] + -> [TVScoped (LHsTyVarBndr flag (GhcPass a))] tvScopes tvScope rhsScope xs = map (\(RS sc a)-> TVS tvScope sc a) $ listScopes rhsScope xs @@ -540,11 +539,11 @@ instance HasLoc a => HasLoc [a] where loc [] = noSrcSpan loc xs = foldl1' combineSrcSpans $ map loc xs -instance HasLoc a => HasLoc (FamEqn s a) where +instance HasLoc a => HasLoc (FamEqn (GhcPass s) a) where loc (FamEqn _ a Nothing b _ c) = foldl1' combineSrcSpans [loc a, loc b, loc c] loc (FamEqn _ a (Just tvs) b _ c) = foldl1' combineSrcSpans [loc a, loc tvs, loc b, loc c] - loc _ = noSrcSpan + instance (HasLoc tm, HasLoc ty) => HasLoc (HsArg tm ty) where loc (HsValArg tm) = loc tm loc (HsTypeArg _ ty) = loc ty @@ -684,7 +683,7 @@ instance ToHie (Located HsWrapper) where concatMapM (toHie . C EvidenceVarUse . L osp) $ evVarsOfTermList a _ -> pure [] -instance HiePass p => HasType (LHsBind (GhcPass p)) where +instance HiePass p => HasType (Located (HsBind (GhcPass p))) where getTypeNode (L spn bind) = case hiePass @p of HieRn -> makeNode bind spn @@ -713,7 +712,7 @@ instance HiePass p => HasType (Located (Pat (GhcPass p))) where -- expression's type is going to be expensive. -- -- See #16233 -instance HiePass p => HasType (LHsExpr (GhcPass p)) where +instance HiePass p => HasType (Located (HsExpr (GhcPass p))) where getTypeNode e@(L spn e') = case hiePass @p of HieRn -> makeNode e' spn @@ -800,7 +799,7 @@ instance HiePass 'Renamed where instance HiePass 'Typechecked where hiePass = HieTc -instance HiePass p => ToHie (BindContext (LHsBind (GhcPass p))) where +instance HiePass p => ToHie (BindContext (Located (HsBind (GhcPass p)))) where toHie (BC context scope b@(L span bind)) = concatM $ getTypeNode b : case bind of FunBind{fun_id = name, fun_matches = matches, fun_ext = wrap} -> @@ -884,7 +883,7 @@ instance HiePass p => ToHie (HsPatSynDir (GhcPass p)) where instance ( HiePass p , Data body , ToHie (Located body) - ) => ToHie (LMatch (GhcPass p) (Located body)) where + ) => ToHie (Located (Match (GhcPass p) (Located body))) where toHie (L span m ) = concatM $ node : case m of Match{m_ctxt=mctx, m_pats = pats, m_grhss = grhss } -> [ toHie mctx @@ -1006,7 +1005,6 @@ instance HiePass p => ToHie (PScoped (Located (Pat (GhcPass p)))) where L spn $ HsRecField lbl (PS rsp scope fscope pat) pun scoped_fds = listScopes pscope fds - instance ToHie (TScoped (HsPatSigType GhcRn)) where toHie (TS sc (HsPS (HsPSRn wcs tvs) body@(L span _))) = concatM $ [ bindingsOnly $ map (C $ TyVarBind (mkScope span) sc) (wcs++tvs) @@ -1027,7 +1025,7 @@ instance ( ToHie (Located body) instance ( ToHie (Located body) , HiePass a , Data body - ) => ToHie (LGRHS (GhcPass a) (Located body)) where + ) => ToHie (Located (GRHS (GhcPass a) (Located body))) where toHie (L span g) = concatM $ node : case g of GRHS _ guards body -> [ toHie $ listScopes (mkLScope body) guards @@ -1038,7 +1036,7 @@ instance ( ToHie (Located body) HieRn -> makeNode g span HieTc -> makeNode g span -instance HiePass p => ToHie (LHsExpr (GhcPass p)) where +instance HiePass p => ToHie (Located (HsExpr (GhcPass p))) where toHie e@(L mspan oexpr) = concatM $ getTypeNode e : case oexpr of HsVar _ (L _ var) -> [ toHie $ C Use (L mspan var) @@ -1176,7 +1174,7 @@ instance HiePass p => ToHie (LHsExpr (GhcPass p)) where ] | otherwise -> [] -instance HiePass p => ToHie (LHsTupArg (GhcPass p)) where +instance HiePass p => ToHie (Located (HsTupArg (GhcPass p))) where toHie (L span arg) = concatM $ makeNode arg span : case arg of Present _ expr -> [ toHie expr @@ -1186,7 +1184,7 @@ instance HiePass p => ToHie (LHsTupArg (GhcPass p)) where instance ( ToHie (Located body) , Data body , HiePass p - ) => ToHie (RScoped (LStmt (GhcPass p) (Located body))) where + ) => ToHie (RScoped (Located (Stmt (GhcPass p) (Located body)))) where toHie (RS scope (L span stmt)) = concatM $ node : case stmt of LastStmt _ body _ _ -> [ toHie body @@ -1222,7 +1220,7 @@ instance ( ToHie (Located body) HieTc -> makeNode stmt span HieRn -> makeNode stmt span -instance HiePass p => ToHie (RScoped (LHsLocalBinds (GhcPass p))) where +instance HiePass p => ToHie (RScoped (Located (HsLocalBinds (GhcPass p)))) where toHie (RS scope (L sp binds)) = concatM $ makeNode binds sp : case binds of EmptyLocalBinds _ -> [] HsIPBinds _ ipbinds -> case ipbinds of @@ -1237,7 +1235,7 @@ instance HiePass p => ToHie (RScoped (LHsLocalBinds (GhcPass p))) where valBinds ] -instance HiePass p => ToHie (RScoped (LIPBind (GhcPass p))) where +instance HiePass p => ToHie (RScoped (Located (IPBind (GhcPass p)))) where toHie (RS scope (L sp bind)) = concatM $ makeNode bind sp : case bind of IPBind _ (Left _) expr -> [toHie expr] IPBind _ (Right v) expr -> @@ -1277,13 +1275,13 @@ instance ( ToHie (RFContext (Located label)) removeDefSrcSpan :: Name -> Name removeDefSrcSpan n = setNameLoc n noSrcSpan -instance ToHie (RFContext (LFieldOcc GhcRn)) where +instance ToHie (RFContext (Located (FieldOcc GhcRn))) where toHie (RFC c rhs (L nspan f)) = concatM $ case f of FieldOcc name _ -> [ toHie $ C (RecField c rhs) (L nspan $ removeDefSrcSpan name) ] -instance ToHie (RFContext (LFieldOcc GhcTc)) where +instance ToHie (RFContext (Located (FieldOcc GhcTc))) where toHie (RFC c rhs (L nspan f)) = concatM $ case f of FieldOcc var _ -> let var' = setVarName var (removeDefSrcSpan $ varName var) @@ -1324,13 +1322,13 @@ instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] -instance HiePass p => ToHie (LHsCmdTop (GhcPass p)) where +instance HiePass p => ToHie (Located (HsCmdTop (GhcPass p))) where toHie (L span top) = concatM $ makeNode top span : case top of HsCmdTop _ cmd -> [ toHie cmd ] -instance HiePass p => ToHie (LHsCmd (GhcPass p)) where +instance HiePass p => ToHie (Located (HsCmd (GhcPass p))) where toHie (L span cmd) = concatM $ makeNode cmd span : case cmd of HsCmdArrApp _ a b _ _ -> [ toHie a @@ -1384,7 +1382,7 @@ instance ToHie (TyClGroup GhcRn) where , toHie instances ] -instance ToHie (LTyClDecl GhcRn) where +instance ToHie (Located (TyClDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of FamDecl {tcdFam = fdecl} -> [ toHie (L span fdecl) @@ -1429,7 +1427,7 @@ instance ToHie (LTyClDecl GhcRn) where rhs_scope = foldl1' combineScopes $ map mkScope [ loc deps, loc sigs, loc (bagToList meths), loc typs, loc deftyps] -instance ToHie (LFamilyDecl GhcRn) where +instance ToHie (Located (FamilyDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of FamilyDecl _ info name vars _ sig inj -> [ toHie $ C (Decl FamDec $ getRealSpan span) name @@ -1452,7 +1450,7 @@ instance ToHie (FamilyInfo GhcRn) where go (L l ib) = TS (ResolvedScopes [mkScope l]) ib toHie _ = pure [] -instance ToHie (RScoped (LFamilyResultSig GhcRn)) where +instance ToHie (RScoped (Located (FamilyResultSig GhcRn))) where toHie (RS sc (L span sig)) = concatM $ makeNode sig span : case sig of NoSig _ -> [] @@ -1486,7 +1484,7 @@ instance (ToHie rhs, HasLoc rhs) patsScope = mkScope (loc pats) rhsScope = mkScope (loc rhs) -instance ToHie (LInjectivityAnn GhcRn) where +instance ToHie (Located (InjectivityAnn GhcRn)) where toHie (L span ann) = concatM $ makeNode ann span : case ann of InjectivityAnn lhs rhs -> [ toHie $ C Use lhs @@ -1501,13 +1499,13 @@ instance ToHie (HsDataDefn GhcRn) where , toHie derivs ] -instance ToHie (HsDeriving GhcRn) where +instance ToHie (Located [Located (HsDerivingClause GhcRn)]) where toHie (L span clauses) = concatM [ locOnly span , toHie clauses ] -instance ToHie (LHsDerivingClause GhcRn) where +instance ToHie (Located (HsDerivingClause GhcRn)) where toHie (L span cl) = concatM $ makeNode cl span : case cl of HsDerivingClause _ strat (L ispan tys) -> [ toHie strat @@ -1528,7 +1526,7 @@ instance ToHie (Located OverlapMode) where instance ToHie a => ToHie (HsScaled GhcRn a) where toHie (HsScaled w t) = concatM [toHie (arrowToHsType w), toHie t] -instance ToHie (LConDecl GhcRn) where +instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> @@ -1557,14 +1555,14 @@ instance ToHie (LConDecl GhcRn) where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails p -> Scope + where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope condecl_scope args = case args of PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) (mkLScope (hsScaledThing b)) RecCon x -> mkLScope x -instance ToHie (Located [LConDeclField GhcRn]) where +instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ [ locOnly span , toHie decls @@ -1588,7 +1586,7 @@ instance ( HasLoc thing ] where span = loc a -instance ToHie (LStandaloneKindSig GhcRn) where +instance ToHie (Located (StandaloneKindSig GhcRn)) where toHie (L sp sig) = concatM [makeNode sig sp, toHie sig] instance ToHie (StandaloneKindSig GhcRn) where @@ -1598,7 +1596,7 @@ instance ToHie (StandaloneKindSig GhcRn) where , toHie $ TS (ResolvedScopes []) typ ] -instance HiePass p => ToHie (SigContext (LSig (GhcPass p))) where +instance HiePass p => ToHie (SigContext (Located (Sig (GhcPass p)))) where toHie (SC (SI styp msp) (L sp sig)) = case hiePass @p of HieTc -> pure [] @@ -1644,10 +1642,10 @@ instance HiePass p => ToHie (SigContext (LSig (GhcPass p))) where , toHie $ fmap (C Use) typ ] -instance ToHie (LHsType GhcRn) where +instance ToHie (Located (HsType GhcRn)) where toHie x = toHie $ TS (ResolvedScopes []) x -instance ToHie (TScoped (LHsType GhcRn)) where +instance ToHie (TScoped (Located (HsType GhcRn))) where toHie (TS tsc (L span t)) = concatM $ makeNode t span : case t of HsForAllTy _ tele body -> let scope = mkScope $ getLoc body in @@ -1731,7 +1729,7 @@ instance (ToHie tm, ToHie ty) => ToHie (HsArg tm ty) where toHie (HsTypeArg _ ty) = toHie ty toHie (HsArgPar sp) = locOnly sp -instance Data flag => ToHie (TVScoped (LHsTyVarBndr flag GhcRn)) where +instance Data flag => ToHie (TVScoped (Located (HsTyVarBndr flag GhcRn))) where toHie (TVS tsc sc (L span bndr)) = concatM $ makeNode bndr span : case bndr of UserTyVar _ _ var -> [ toHie $ C (TyVarBind sc tsc) var @@ -1750,13 +1748,13 @@ instance ToHie (TScoped (LHsQTyVars GhcRn)) where varLoc = loc vars bindings = map (C $ TyVarBind (mkScope varLoc) sc) implicits -instance ToHie (LHsContext GhcRn) where +instance ToHie (Located [Located (HsType GhcRn)]) where toHie (L span tys) = concatM $ [ locOnly span , toHie tys ] -instance ToHie (LConDeclField GhcRn) where +instance ToHie (Located (ConDeclField GhcRn)) where toHie (L span field) = concatM $ makeNode field span : case field of ConDeclField _ fields typ _ -> [ toHie $ map (RFC RecFieldDecl (getRealSpan $ loc typ)) fields @@ -1779,7 +1777,7 @@ instance ToHie (LHsExpr a) => ToHie (ArithSeqInfo a) where , toHie c ] -instance ToHie (LSpliceDecl GhcRn) where +instance ToHie (Located (SpliceDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of SpliceDecl _ splice _ -> [ toHie splice @@ -1833,14 +1831,14 @@ instance HiePass p => ToHie (Located (HsSplice (GhcPass p))) where GhcTc -> case x of HsSplicedT _ -> [] -instance ToHie (LRoleAnnotDecl GhcRn) where +instance ToHie (Located (RoleAnnotDecl GhcRn)) where toHie (L span annot) = concatM $ makeNode annot span : case annot of RoleAnnotDecl _ var roles -> [ toHie $ C Use var , concatMapM (locOnly . getLoc) roles ] -instance ToHie (LInstDecl GhcRn) where +instance ToHie (Located (InstDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ClsInstD _ d -> [ toHie $ L span d @@ -1852,7 +1850,7 @@ instance ToHie (LInstDecl GhcRn) where [ toHie $ L span d ] -instance ToHie (LClsInstDecl GhcRn) where +instance ToHie (Located (ClsInstDecl GhcRn)) where toHie (L span decl) = concatM [ toHie $ TS (ResolvedScopes [mkScope span]) $ cid_poly_ty decl , toHie $ fmap (BC InstanceBind ModuleScope) $ cid_binds decl @@ -1864,10 +1862,10 @@ instance ToHie (LClsInstDecl GhcRn) where , toHie $ cid_overlap_mode decl ] -instance ToHie (LDataFamInstDecl GhcRn) where +instance ToHie (Located (DataFamInstDecl GhcRn)) where toHie (L sp (DataFamInstDecl d)) = toHie $ TS (ResolvedScopes [mkScope sp]) d -instance ToHie (LTyFamInstDecl GhcRn) where +instance ToHie (Located (TyFamInstDecl GhcRn)) where toHie (L sp (TyFamInstDecl d)) = toHie $ TS (ResolvedScopes [mkScope sp]) d instance ToHie (Context a) @@ -1877,7 +1875,7 @@ instance ToHie (Context a) , toHie $ C Use b ] -instance ToHie (LDerivDecl GhcRn) where +instance ToHie (Located (DerivDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of DerivDecl _ typ strat overlap -> [ toHie $ TS (ResolvedScopes []) typ @@ -1885,19 +1883,19 @@ instance ToHie (LDerivDecl GhcRn) where , toHie overlap ] -instance ToHie (LFixitySig GhcRn) where +instance ToHie (Located (FixitySig GhcRn)) where toHie (L span sig) = concatM $ makeNode sig span : case sig of FixitySig _ vars _ -> [ toHie $ map (C Use) vars ] -instance ToHie (LDefaultDecl GhcRn) where +instance ToHie (Located (DefaultDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of DefaultDecl _ typs -> [ toHie typs ] -instance ToHie (LForeignDecl GhcRn) where +instance ToHie (Located (ForeignDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ForeignImport {fd_name = name, fd_sig_ty = sig, fd_fi = fi} -> [ toHie $ C (ValBind RegularBind ModuleScope $ getRealSpan span) name @@ -1923,19 +1921,19 @@ instance ToHie ForeignExport where , locOnly b ] -instance ToHie (LWarnDecls GhcRn) where +instance ToHie (Located (WarnDecls GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of Warnings _ _ warnings -> [ toHie warnings ] -instance ToHie (LWarnDecl GhcRn) where +instance ToHie (Located (WarnDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of Warning _ vars _ -> [ toHie $ map (C Use) vars ] -instance ToHie (LAnnDecl GhcRn) where +instance ToHie (Located (AnnDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of HsAnnotation _ _ prov expr -> [ toHie prov @@ -1947,13 +1945,13 @@ instance ToHie (Context (Located a)) => ToHie (AnnProvenance a) where toHie (TypeAnnProvenance a) = toHie $ C Use a toHie ModuleAnnProvenance = pure [] -instance ToHie (LRuleDecls GhcRn) where +instance ToHie (Located (RuleDecls GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of HsRules _ _ rules -> [ toHie rules ] -instance ToHie (LRuleDecl GhcRn) where +instance ToHie (Located (RuleDecl GhcRn)) where toHie (L span r@(HsRule _ rname _ tybndrs bndrs exprA exprB)) = concatM [ makeNode r span , locOnly $ getLoc rname @@ -1967,7 +1965,7 @@ instance ToHie (LRuleDecl GhcRn) where exprA_sc = mkLScope exprA exprB_sc = mkLScope exprB -instance ToHie (RScoped (LRuleBndr GhcRn)) where +instance ToHie (RScoped (Located (RuleBndr GhcRn))) where toHie (RS sc (L span bndr)) = concatM $ makeNode bndr span : case bndr of RuleBndr _ var -> [ toHie $ C (ValBind RegularBind sc Nothing) var @@ -1977,7 +1975,7 @@ instance ToHie (RScoped (LRuleBndr GhcRn)) where , toHie $ TS (ResolvedScopes [sc]) typ ] -instance ToHie (LImportDecl GhcRn) where +instance ToHie (Located (ImportDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ImportDecl { ideclName = name, ideclAs = as, ideclHiding = hidden } -> [ toHie $ IEC Import name @@ -1992,7 +1990,7 @@ instance ToHie (LImportDecl GhcRn) where where c = if hiding then ImportHiding else Import -instance ToHie (IEContext (LIE GhcRn)) where +instance ToHie (IEContext (Located (IE GhcRn))) where toHie (IEC c (L span ie)) = concatM $ makeNode ie span : case ie of IEVar _ n -> [ toHie $ IEC c n ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2529,7 +2529,7 @@ mkRdrRecordCon :: Located RdrName -> HsRecordBinds GhcPs -> HsExpr GhcPs mkRdrRecordCon con flds = RecordCon { rcon_ext = noExtField, rcon_con_name = con, rcon_flds = flds } -mk_rec_fields :: [LHsRecField id arg] -> Maybe SrcSpan -> HsRecFields id arg +mk_rec_fields :: [Located (HsRecField (GhcPass p) arg)] -> Maybe SrcSpan -> HsRecFields (GhcPass p) arg mk_rec_fields fs Nothing = HsRecFields { rec_flds = fs, rec_dotdot = Nothing } mk_rec_fields fs (Just s) = HsRecFields { rec_flds = fs , rec_dotdot = Just (L s (length fs)) } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -8,6 +8,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE DerivingVia #-} +{-# LANGUAGE RankNTypes #-} {- | This module implements 'addHaddockToModule', which inserts Haddock comments accumulated during parsing into the AST (#17544). @@ -52,6 +53,7 @@ module GHC.Parser.PostProcess.Haddock (addHaddockToModule) where import GHC.Prelude hiding (mod) import GHC.Hs + import GHC.Types.SrcLoc import GHC.Driver.Session ( WarningFlag(..) ) import GHC.Utils.Outputable hiding ( (<>) ) @@ -301,7 +303,7 @@ instance HasHaddock (Located HsModule) where -- import I (a, b, c) -- do not use here! -- -- Imports cannot have documentation comments anyway. -instance HasHaddock (Located [LIE GhcPs]) where +instance HasHaddock (Located [Located (IE GhcPs)]) where addHaddock (L l_exports exports) = extendHdkA l_exports $ do exports' <- addHaddockInterleaveItems NoLayoutInfo mkDocIE exports @@ -309,7 +311,7 @@ instance HasHaddock (Located [LIE GhcPs]) where pure $ L l_exports exports' -- Needed to use 'addHaddockInterleaveItems' in 'instance HasHaddock (Located [LIE GhcPs])'. -instance HasHaddock (LIE GhcPs) where +instance HasHaddock (Located (IE GhcPs)) where addHaddock a = a <$ registerHdkA a {- Add Haddock items to a list of non-Haddock items. @@ -386,7 +388,7 @@ addHaddockInterleaveItems layout_info get_doc_item = go let loc_range = mempty { loc_range_col = ColumnFrom (n+1) } in hoistHdkA (inLocRange loc_range) -instance HasHaddock (LHsDecl GhcPs) where +instance HasHaddock (Located (HsDecl GhcPs)) where addHaddock ldecl = extendHdkA (getLoc ldecl) $ traverse @Located addHaddock ldecl @@ -594,7 +596,7 @@ instance HasHaddock (HsDataDefn GhcPs) where -- Process the deriving clauses of a data/newtype declaration. -- Not used for standalone deriving. -instance HasHaddock (HsDeriving GhcPs) where +instance HasHaddock (Located [Located (HsDerivingClause GhcPs)]) where addHaddock lderivs = extendHdkA (getLoc lderivs) $ traverse @Located addHaddock lderivs @@ -606,7 +608,7 @@ instance HasHaddock (HsDeriving GhcPs) where -- deriving (Ord {- ^ Comment on Ord N -}) via Down N -- -- Not used for standalone deriving. -instance HasHaddock (LHsDerivingClause GhcPs) where +instance HasHaddock (Located (HsDerivingClause GhcPs)) where addHaddock lderiv = extendHdkA (getLoc lderiv) $ for @Located lderiv $ \deriv -> @@ -668,7 +670,7 @@ instance HasHaddock (LHsDerivingClause GhcPs) where -- bool_field :: Bool } -- ^ Comment on bool_field -- -> T -- -instance HasHaddock (LConDecl GhcPs) where +instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of @@ -920,10 +922,10 @@ We implement this in two steps: instance HasHaddock a => HasHaddock (HsScaled GhcPs a) where addHaddock (HsScaled mult a) = HsScaled mult <$> addHaddock a -instance HasHaddock (LHsSigWcType GhcPs) where +instance HasHaddock a => HasHaddock (HsWildCardBndrs GhcPs a) where addHaddock (HsWC _ t) = HsWC noExtField <$> addHaddock t -instance HasHaddock (LHsSigType GhcPs) where +instance HasHaddock a => HasHaddock (HsImplicitBndrs GhcPs a) where addHaddock (HsIB _ t) = HsIB noExtField <$> addHaddock t -- Process a type, adding documentation comments to function arguments @@ -953,7 +955,7 @@ instance HasHaddock (LHsSigType GhcPs) where -- -- This is achieved by simply ignoring (not registering the location of) the -- function arrow (->). -instance HasHaddock (LHsType GhcPs) where +instance HasHaddock (Located (HsType GhcPs)) where addHaddock (L l t) = extendHdkA l $ case t of ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -439,6 +439,7 @@ rnCmdArgs (arg:args) rnCmdTop :: LHsCmdTop GhcPs -> RnM (LHsCmdTop GhcRn, FreeVars) rnCmdTop = wrapLocFstM rnCmdTop' where + rnCmdTop' :: HsCmdTop GhcPs -> RnM (HsCmdTop GhcRn, FreeVars) rnCmdTop' (HsCmdTop _ cmd) = do { (cmd', fvCmd) <- rnLCmd cmd ; let cmd_names = [arrAName, composeAName, firstAName] ++ @@ -1871,7 +1872,7 @@ hasRefutablePattern (ApplicativeArgOne { app_arg_pattern = pat , is_body_stmt = False}) = not (isIrrefutableHsPat pat) hasRefutablePattern _ = False -isLetStmt :: LStmt a b -> Bool +isLetStmt :: LStmt (GhcPass a) b -> Bool isLetStmt (L _ LetStmt{}) = True isLetStmt _ = False ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -1717,7 +1717,7 @@ rnTyClDecl (ClassDecl { tcdCtxt = context, tcdLName = lcls, cls_doc = ClassDeclCtx lcls -- Does the data type declaration include a CUSK? -data_decl_has_cusk :: LHsQTyVars pass -> NewOrData -> Bool -> Maybe (LHsKind pass') -> RnM Bool +data_decl_has_cusk :: LHsQTyVars (GhcPass p) -> NewOrData -> Bool -> Maybe (LHsKind (GhcPass p')) -> RnM Bool data_decl_has_cusk tyvars new_or_data no_rhs_kvs kind_sig = do { -- See Note [Unlifted Newtypes and CUSKs], and for a broader -- picture, see Note [Implementation of UnliftedNewtypes]. @@ -2128,7 +2128,7 @@ rnConDecls = mapFvRn (wrapLocFstM rnConDecl) rnConDecl :: ConDecl GhcPs -> RnM (ConDecl GhcRn, FreeVars) rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs , con_mb_cxt = mcxt, con_args = args - , con_doc = mb_doc }) + , con_doc = mb_doc, con_forall = forall }) = do { _ <- addLocM checkConName name ; new_name <- lookupLocatedTopBndrRn name ; mb_doc' <- rnMbLHsDoc mb_doc @@ -2155,11 +2155,12 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; return (decl { con_ext = noExtField , con_name = new_name, con_ex_tvs = new_ex_tvs , con_mb_cxt = new_context, con_args = new_args - , con_doc = mb_doc' }, + , con_doc = mb_doc' + , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) }} rnConDecl decl@(ConDeclGADT { con_names = names - , con_forall = L _ explicit_forall + , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt , con_args = args @@ -2197,7 +2198,8 @@ rnConDecl decl@(ConDeclGADT { con_names = names ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt , con_args = new_args, con_res_ty = new_res_ty - , con_doc = mb_doc' }, + , con_doc = mb_doc' + , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } -- This case is only used for prefix GADT constructors generated by GHC's ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -385,7 +385,9 @@ rnImportDecl this_mod warnUnqualifiedImport decl iface let new_imp_decl = L loc (decl { ideclExt = noExtField, ideclSafe = mod_safe' - , ideclHiding = new_imp_details }) + , ideclHiding = new_imp_details + , ideclName = ideclName decl + , ideclAs = ideclAs decl }) return (new_imp_decl, gbl_env, imports, mi_hpc iface) @@ -1393,6 +1395,7 @@ findImportUsage imports used_gres import_usage :: ImportMap import_usage = mkImportMap used_gres + unused_decl :: LImportDecl GhcRn -> (LImportDecl GhcRn, [GlobalRdrElt], [Name]) unused_decl decl@(L loc (ImportDecl { ideclHiding = imps })) = (decl, used_gres, nameSetElemsStable unused_imps) where ===================================== compiler/GHC/Tc/Gen/Foreign.hs ===================================== @@ -6,6 +6,10 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ViewPatterns #-} -- | Typechecking @foreign@ declarations -- @@ -68,13 +72,13 @@ import qualified GHC.LanguageExtensions as LangExt import Control.Monad -- Defines a binding -isForeignImport :: LForeignDecl name -> Bool -isForeignImport (L _ (ForeignImport {})) = True +isForeignImport :: forall name. UnXRec name => LForeignDecl name -> Bool +isForeignImport (unXRec @name -> ForeignImport {}) = True isForeignImport _ = False -- Exports a binding -isForeignExport :: LForeignDecl name -> Bool -isForeignExport (L _ (ForeignExport {})) = True +isForeignExport :: forall name. UnXRec name => LForeignDecl name -> Bool +isForeignExport (unXRec @name -> ForeignExport {}) = True isForeignExport _ = False {- ===================================== ghc/GHCi/UI.hs ===================================== @@ -9,6 +9,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE TypeFamilies #-} ----------------------------------------------------------------------------- -- @@ -1255,7 +1256,9 @@ runStmt input step = do mk_stmt :: SrcSpan -> HsBind GhcPs -> GhciLStmt GhcPs mk_stmt loc bind = - let l = L loc + let + l :: a -> Located a + l = L loc in l (LetStmt noExtField (l (HsValBinds noExtField (ValBinds noExtField (unitBag (l bind)) [])))) -- | Clean up the GHCi environment after a statement has run @@ -2797,6 +2800,7 @@ showDynFlags show_all dflags = do text "warning settings:" $$ nest 2 (vcat (map (setting "-W" "-Wno-" wopt) DynFlags.wWarningFlags)) where + setting :: String -> String -> (flag -> DynFlags -> Bool) -> FlagSpec flag -> SDoc setting prefix noPrefix test flag | quiet = empty | is_on = text prefix <> text name ===================================== ghc/GHCi/UI/Info.hs ===================================== @@ -349,6 +349,7 @@ processAllTypeCheckedModule tcm = do getTypeLPat (L spn pat) = pure (Just (getMaybeId pat,spn,hsPatType pat)) where + getMaybeId :: Pat GhcTc -> Maybe Id getMaybeId (VarPat _ (L _ vid)) = Just vid getMaybeId _ = Nothing ===================================== testsuite/tests/pmcheck/should_compile/pmc009.hs ===================================== @@ -2,7 +2,7 @@ module HsUtils where import GHC.Hs.Binds import GHC.Types.SrcLoc -addPatSynSelector:: LHsBind p -> [a] +addPatSynSelector:: GenLocated l (HsBindLR idL idR) -> [a] addPatSynSelector bind | PatSynBind _ _ <- unLoc bind = [] ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 904dce0cafe0a241dd3ef355775db47fc12f434d +Subproject commit 7e6628febc482b4ad451f49ad416722375d1b170 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/02133353e712e98bfbbc6ed32305b137bb3654eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/02133353e712e98bfbbc6ed32305b137bb3654eb You're receiving 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 Jul 25 04:45:13 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 25 Jul 2020 00:45:13 -0400 Subject: [Git][ghc/ghc][master] 10 commits: DynFlags: store printer in TraceBinIfaceReading Message-ID: <5f1bb8d963c81_80b1025102449161a1@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Parser/Header.hs - libraries/ghc-boot/GHC/Platform.hs → compiler/GHC/Platform.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/02133353e712e98bfbbc6ed32305b137bb3654eb...6e2db34bdfead7ad309d8fd01d4423554650cf4c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/02133353e712e98bfbbc6ed32305b137bb3654eb...6e2db34bdfead7ad309d8fd01d4423554650cf4c You're receiving 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 Jul 25 04:45:50 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 25 Jul 2020 00:45:50 -0400 Subject: [Git][ghc/ghc][master] Require SMP support in order to build a threaded stage1 Message-ID: <5f1bb8fee8e0f_80b3f84901582f04920825@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - 1 changed file: - configure.ac Changes: ===================================== configure.ac ===================================== @@ -166,13 +166,17 @@ if test "$WithGhc" != ""; then fi BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) + BOOTSTRAPPING_GHC_INFO_FIELD([SUPPORT_SMP_STAGE0],[Support SMP]) BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) dnl Check whether or not the bootstrapping GHC has a threaded RTS. This dnl determines whether or not we can have a threaded stage 1. dnl See Note [Linking ghc-bin against threaded stage0 RTS] in dnl hadrian/src/Settings/Packages.hs for details. - if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null; then + dnl SMP support which implies a registerised stage0 is also required (see issue 18266) + if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null && \ + test "$SUPPORT_SMP_STAGE0" = "YES" + then AC_SUBST(GhcThreadedRts, YES) else AC_SUBST(GhcThreadedRts, NO) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc0f6fbcd95f2dc69a8efabbee2d8a485c34cc47 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc0f6fbcd95f2dc69a8efabbee2d8a485c34cc47 You're receiving 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 Jul 25 16:34:56 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Sat, 25 Jul 2020 12:34:56 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] Add dummy import for PeekProfInfo_ProfilingEnabled for non-profiled builds Message-ID: <5f1c5f3099a3e_80b104edf44493716a@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: 2db2bfb3 by Sven Tennie at 2020-07-25T18:34:47+02:00 Add dummy import for PeekProfInfo_ProfilingEnabled for non-profiled builds This circumvents #15197. Otherwise PeekProfInfo_ProfilingEnabled wouldn't be available for make-based builds. - - - - - 1 changed file: - libraries/ghc-heap/GHC/Exts/Heap.hs Changes: ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -64,6 +64,13 @@ import GHC.Exts.Heap.ProfInfo.Types import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled import GHC.Exts.Heap.InfoTableProf #else +-- This import makes PeekProfInfo_ProfilingEnabled available in make-based +-- builds. See #15197 for details (even though the related patch didn't +-- seem to fix the issue). +-- GHC.Exts.Heap.Closures uses the same trick to include +-- GHC.Exts.Heap.InfoTableProf into make-based builds. +import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled () + import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled import GHC.Exts.Heap.InfoTable #endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2db2bfb3a0d2a0017864e1d4c1491910213bb880 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2db2bfb3a0d2a0017864e1d4c1491910213bb880 You're receiving 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 Jul 25 23:59:53 2020 From: gitlab at gitlab.haskell.org (Brandon Chinn) Date: Sat, 25 Jul 2020 19:59:53 -0400 Subject: [Git][ghc/ghc][wip/T16341] 3 commits: Factor out getPossibleDataCons Message-ID: <5f1cc77969401_80b104edf4449631ef@gitlab.haskell.org.mail> Brandon Chinn pushed to branch wip/T16341 at Glasgow Haskell Compiler / GHC Commits: d9a8f6b0 by Brandon Chinn at 2020-07-25T16:49:25-07:00 Factor out getPossibleDataCons - - - - - 805ceb81 by Brandon Chinn at 2020-07-25T16:55:50-07:00 Filter out impossible constructors for Functor, Foldable, Traversable, Lift - - - - - a03e1c0e by Brandon Chinn at 2020-07-25T16:57:33-07:00 Remove filter for deriving Data - - - - - 4 changed files: - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Utils.hs - testsuite/tests/deriving/should_compile/T16341.hs Changes: ===================================== compiler/GHC/Tc/Deriv/Functor.hs ===================================== @@ -151,10 +151,10 @@ is a similar algorithm for generating `p <$ x` (for some constant `p`): $(coreplace 'a '(tb -> tc) x) = \(y:tb[b/a]) -> $(coreplace 'a' 'tc' (x $(replace 'a 'tb y))) -} -gen_Functor_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Functor_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use fmap _ = coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag fmap_bind, emptyBag) where @@ -165,10 +165,10 @@ gen_Functor_binds loc tycon coerce_Expr] fmap_match_ctxt = mkPrefixFunRhs fmap_name -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon tycon_args = (listToBag [fmap_bind, replace_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args fmap_name = L loc fmap_RDR -- See Note [EmptyDataDecls with Functor, Foldable, and Traversable] @@ -787,10 +787,10 @@ could surprise users if they switch to other types, but Ryan Scott seems to think it's okay to do it for now. -} -gen_Foldable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Foldable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the parameter is phantom, we can use foldMap _ _ = mempty -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag foldMap_bind, emptyBag) where @@ -801,7 +801,7 @@ gen_Foldable_binds loc tycon mempty_Expr] foldMap_match_ctxt = mkPrefixFunRhs foldMap_name -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon tycon_args | null data_cons -- There's no real point producing anything but -- foldMap for a type with no constructors. = (unitBag foldMap_bind, emptyBag) @@ -809,7 +809,7 @@ gen_Foldable_binds loc tycon | otherwise = (listToBag [foldr_bind, foldMap_bind, null_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args foldr_bind = mkRdrFunBind (L loc foldable_foldr_RDR) eqns eqns = map foldr_eqn data_cons @@ -1016,10 +1016,10 @@ removes all such types from consideration. See Note [Generated code for DeriveFoldable and DeriveTraversable]. -} -gen_Traversable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Traversable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use traverse = pure . coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag traverse_bind, emptyBag) where @@ -1031,10 +1031,10 @@ gen_Traversable_binds loc tycon (nlHsApps pure_RDR [nlHsApp coerce_Expr z_Expr])] traverse_match_ctxt = mkPrefixFunRhs traverse_name -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon tycon_args = (unitBag traverse_bind, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args traverse_name = L loc traverse_RDR ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -33,7 +33,9 @@ module GHC.Tc.Deriv.Generate ( mkCoerceClassMethEqn, genAuxBinds, ordOpTbl, boxConTbl, litConTbl, - mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr + mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr, + + getPossibleDataCons ) where #include "HsVersions.h" @@ -219,7 +221,7 @@ gen_Eq_binds loc tycon tycon_args = do return (method_binds con2tag_RDR, aux_binds con2tag_RDR) where - all_cons = filter (not . dataConCannotMatch tycon_args) $ tyConDataCons tycon + all_cons = getPossibleDataCons tycon tycon_args (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon all_cons -- If there are ten or more (arbitrary number) nullary constructors, @@ -432,7 +434,7 @@ gen_Ord_binds loc tycon tycon_args = do -- We want *zero-based* tags, because that's what -- con2Tag returns (generated by untag_Expr)! - tycon_data_cons = filter (not . dataConCannotMatch tycon_args) $ tyConDataCons tycon + tycon_data_cons = getPossibleDataCons tycon tycon_args single_con_type = isSingleton tycon_data_cons (first_con : _) = tycon_data_cons (last_con : _) = reverse tycon_data_cons @@ -738,8 +740,8 @@ gen_Enum_binds loc tycon _ = do ************************************************************************ -} -gen_Bounded_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Bounded_binds loc tycon +gen_Bounded_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Bounded_binds loc tycon _ | isEnumerationTyCon tycon = (listToBag [ min_bound_enum, max_bound_enum ], emptyBag) | otherwise @@ -1042,7 +1044,7 @@ gen_Read_binds get_fixity loc tycon tycon_args = mkHsVarBind loc readListPrec_RDR (nlHsVar readListPrecDefault_RDR) ----------------------------------------------------------------------- - data_cons = filter (not . dataConCannotMatch tycon_args) $ tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon data_cons read_prec = mkHsVarBind loc readPrec_RDR rhs @@ -1218,7 +1220,7 @@ gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] gen_Show_binds get_fixity loc tycon tycon_args = (unitBag shows_prec, emptyBag) where - data_cons = filter (not . dataConCannotMatch tycon_args) $ tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args shows_prec = mkFunBindEC 2 loc showsPrec_RDR id (map pats_etc data_cons) comma_space = nlHsVar showCommaSpace_RDR @@ -1388,7 +1390,7 @@ gen_Data_binds :: SrcSpan -> [Type] -> TcM (LHsBinds GhcPs, -- The method bindings BagDerivStuff) -- Auxiliary bindings -gen_Data_binds loc rep_tc rep_tc_args +gen_Data_binds loc rep_tc _ = do { -- See Note [Auxiliary binders] dataT_RDR <- new_dataT_rdr_name loc rep_tc ; dataC_RDRs <- traverse (new_dataC_rdr_name loc) data_cons @@ -1404,7 +1406,7 @@ gen_Data_binds loc rep_tc rep_tc_args data_cons dataC_RDRs ) ) } where - data_cons = filter (not . dataConCannotMatch rep_tc_args) $ tyConDataCons rep_tc + data_cons = tyConDataCons rep_tc n_cons = length data_cons one_constr = n_cons == 1 @@ -1617,8 +1619,8 @@ Example: -} -gen_Lift_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) +gen_Lift_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Lift_binds loc tycon tycon_args = (listToBag [lift_bind, liftTyped_bind], emptyBag) where lift_bind = mkFunBindEC 1 loc lift_RDR (nlHsApp pure_Expr) (map (pats_etc mk_exp) data_cons) @@ -1627,7 +1629,7 @@ gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) mk_exp = ExpBr noExtField mk_texp = TExpBr noExtField - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args pats_etc mk_bracket data_con = ([con_pat], lift_Expr) @@ -2516,6 +2518,12 @@ newAuxBinderRdrName loc parent occ_fun = do uniq <- newUnique pure $ Exact $ mkSystemNameAt uniq (occ_fun (nameOccName parent)) loc +-- | If we're deriving an instance for a GADT, e.g. `Eq (Foo Int)`, we should treat any constructors +-- for which it's impossible to match `Foo Int` as not being there at all. +-- +-- See #16341 and the T16341.hs test case. +getPossibleDataCons :: TyCon -> [Type] -> [DataCon] +getPossibleDataCons tycon tycon_args = filter (not . dataConCannotMatch tycon_args) $ tyConDataCons tycon {- Note [Auxiliary binders] ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -590,8 +590,8 @@ hasStockDeriving clas , (genClassKey, generic (gen_Generic_binds Gen0)) , (gen1ClassKey, generic (gen_Generic_binds Gen1)) ] - simple gen_fn loc tc _ _ - = let (binds, deriv_stuff) = gen_fn loc tc + simple gen_fn loc tc tc_args _ + = let (binds, deriv_stuff) = gen_fn loc tc tc_args in return (binds, deriv_stuff, []) -- Like `simple`, but monadic. The only monadic thing that these functions ===================================== testsuite/tests/deriving/should_compile/T16341.hs ===================================== @@ -8,14 +8,22 @@ module T16341 where import Data.Data (Data) data Foo a where - X :: Foo Int - Y :: (Bool -> Bool) -> Foo Bool + Foo1 :: Foo Int + Foo2 :: (Bool -> Bool) -> Foo Bool --- These instances should work whether or not `Y` is a constructor in --- `Foo`, because the `Foo Int` designation precludes `Y` from being +-- These instances should work whether or not `Foo2` is a constructor in +-- `Foo`, because the `Foo Int` designation precludes `Foo2` from being -- a reachable constructor deriving instance Show (Foo Int) deriving instance Read (Foo Int) deriving instance Eq (Foo Int) deriving instance Ord (Foo Int) -deriving instance Data (Foo Int) +deriving instance Lift (Foo Int) + +data Bar a b where + Bar1 :: b -> Bar Int b + Bar2 :: (Bool -> Bool) -> b -> Bar Bool b + +deriving instance Functor (Bar Int) +deriving instance Foldable (Bar Int) +deriving instance Traversable (Bar Int) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df96714fc1b997dc52166d04b12a3226327c54d4...a03e1c0efe4d34d9dc45aee7d6fbd6d9e9bb1c4d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df96714fc1b997dc52166d04b12a3226327c54d4...a03e1c0efe4d34d9dc45aee7d6fbd6d9e9bb1c4d You're receiving 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 Jul 26 11:23:22 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 26 Jul 2020 07:23:22 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 20 commits: Simplify XRec definition Message-ID: <5f1d67aa74b2e_80bd68a9b84982395@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - aec09e5b by Matthias Andreas Benkard at 2020-07-26T07:23:13-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - ff394db1 by Ben Gamari at 2020-07-26T07:23:14-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - 6da69656 by Ben Gamari at 2020-07-26T07:23:14-04:00 testsuite: Update win32 output for parseTree - - - - - 4d289264 by Ben Gamari at 2020-07-26T07:23:14-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 42e1958a by Ben Gamari at 2020-07-26T07:23:14-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 239d7704 by Tamar Christina at 2020-07-26T07:23:16-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ff0b6fe4 by Tamar Christina at 2020-07-26T07:23:17-04:00 winio: fix detection of tty terminals - - - - - fad5c724 by Tamar Christina at 2020-07-26T07:23:18-04:00 winio: update codeowners - - - - - 30 changed files: - .gitlab/test-metrics.sh - CODEOWNERS - compiler/GHC.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.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/a69b4a761ec9fee8babc4cb6307330c772fbeb1a...fad5c724ae203b4ced4f7ad99c9325f9b6ba1f3e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a69b4a761ec9fee8babc4cb6307330c772fbeb1a...fad5c724ae203b4ced4f7ad99c9325f9b6ba1f3e You're receiving 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 Jul 26 11:34:53 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Sun, 26 Jul 2020 07:34:53 -0400 Subject: [Git][ghc/ghc][wip/negative-literals] 16 commits: winio: restore console cp on exit Message-ID: <5f1d6a5d15e07_80b3f84901582f0499002c@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/negative-literals at Glasgow Haskell Compiler / GHC Commits: cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - 9b78d4ce by Vladislav Zavialov at 2020-07-26T07:34:51-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.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/5ccd97796a5963a6087dd81e2b519f70a3bf16cc...9b78d4ce2d595d8d683b150ca4db21e16ee95035 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5ccd97796a5963a6087dd81e2b519f70a3bf16cc...9b78d4ce2d595d8d683b150ca4db21e16ee95035 You're receiving 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 Jul 26 11:35:24 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Sun, 26 Jul 2020 07:35:24 -0400 Subject: [Git][ghc/ghc][wip/parser-refactor-jul24] 16 commits: winio: restore console cp on exit Message-ID: <5f1d6a7cf36f5_80b3f84925412344990624@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/parser-refactor-jul24 at Glasgow Haskell Compiler / GHC Commits: cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - 6356fe4f by Vladislav Zavialov at 2020-07-26T07:35:23-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.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/b95d4ff146086d3068f16a2e1f0eedfa95af20bc...6356fe4f2c591fd359c2134451fb753c3202b14d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b95d4ff146086d3068f16a2e1f0eedfa95af20bc...6356fe4f2c591fd359c2134451fb753c3202b14d You're receiving 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 Jul 26 14:45:50 2020 From: gitlab at gitlab.haskell.org (Josh Meredith) Date: Sun, 26 Jul 2020 10:45:50 -0400 Subject: [Git][ghc/ghc][wip/pluginExtFields] 235 commits: No need for CURSES_INCLUDE_DIRS Message-ID: <5f1d971eb5770_80b3f84901582f0500145a@gitlab.haskell.org.mail> Josh Meredith pushed to branch wip/pluginExtFields at Glasgow Haskell Compiler / GHC Commits: 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - de64ec94 by Josh Meredith at 2020-07-27T00:45:24+10:00 Add machinery for plugins to write data to extensible interface fields - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - Makefile - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/842771d5ff7f60672f86800846e3cf8a82f4aafe...de64ec94d02cbd92c9d96280082c82a342ec1526 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/842771d5ff7f60672f86800846e3cf8a82f4aafe...de64ec94d02cbd92c9d96280082c82a342ec1526 You're receiving 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 Jul 26 17:17:26 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sun, 26 Jul 2020 13:17:26 -0400 Subject: [Git][ghc/ghc][wip/T18470] Don't mark closed type family equations as occurrences Message-ID: <5f1dbaa69b1cc_80b104edf445006179@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18470 at Glasgow Haskell Compiler / GHC Commits: f69ad265 by Ryan Scott at 2020-07-26T13:15:52-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. - - - - - 4 changed files: - compiler/GHC/Rename/Module.hs - + testsuite/tests/typecheck/should_compile/T18470.hs - + testsuite/tests/typecheck/should_compile/T18470.stderr - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -424,11 +424,11 @@ patchCCallTarget unit callTarget = rnSrcInstDecl :: InstDecl GhcPs -> RnM (InstDecl GhcRn, FreeVars) rnSrcInstDecl (TyFamInstD { tfid_inst = tfi }) - = do { (tfi', fvs) <- rnTyFamInstDecl NonAssocTyFamEqn tfi + = do { (tfi', fvs) <- rnTyFamInstDecl (NonAssocTyFamEqn NotClosedTyFam) tfi ; return (TyFamInstD { tfid_ext = noExtField, tfid_inst = tfi' }, fvs) } rnSrcInstDecl (DataFamInstD { dfid_inst = dfi }) - = do { (dfi', fvs) <- rnDataFamInstDecl NonAssocTyFamEqn dfi + = do { (dfi', fvs) <- rnDataFamInstDecl (NonAssocTyFamEqn NotClosedTyFam) dfi ; return (DataFamInstD { dfid_ext = noExtField, dfid_inst = dfi' }, fvs) } rnSrcInstDecl (ClsInstD { cid_inst = cid }) @@ -760,8 +760,12 @@ rnFamInstEqn doc atfi rhs_kvars all_nms = all_imp_var_names ++ hsLTyVarNames bndrs' ; warnUnusedTypePatterns all_nms nms_used - ; let all_fvs = (rhs_fvs `plusFV` pat_fvs) `addOneFV` unLoc tycon' - -- type instance => use, hence addOneFV + ; let eqn_fvs = rhs_fvs `plusFV` pat_fvs + -- See Note [Type family equations and occurrences] + all_fvs = case atfi of + NonAssocTyFamEqn (ClosedTyFam{}) + -> eqn_fvs + _ -> eqn_fvs `addOneFV` unLoc tycon' ; return (HsIB { hsib_ext = all_imp_var_names -- Note [Wildcards in family instances] , hsib_body @@ -776,14 +780,14 @@ rnFamInstEqn doc atfi rhs_kvars -- The parent class, if we are dealing with an associated type family -- instance. mb_cls = case atfi of - NonAssocTyFamEqn -> Nothing + NonAssocTyFamEqn _ -> Nothing AssocTyFamDeflt cls -> Just cls AssocTyFamInst cls _ -> Just cls -- The type variables from the instance head, if we are dealing with an -- associated type family instance. inst_tvs = case atfi of - NonAssocTyFamEqn -> [] + NonAssocTyFamEqn _ -> [] AssocTyFamDeflt _ -> [] AssocTyFamInst _ inst_tvs -> inst_tvs @@ -806,22 +810,46 @@ rnTyFamInstDecl :: AssocTyFamInfo -> TyFamInstDecl GhcPs -> RnM (TyFamInstDecl GhcRn, FreeVars) rnTyFamInstDecl atfi (TyFamInstDecl { tfid_eqn = eqn }) - = do { (eqn', fvs) <- rnTyFamInstEqn atfi NotClosedTyFam eqn + = do { (eqn', fvs) <- rnTyFamInstEqn atfi eqn ; return (TyFamInstDecl { tfid_eqn = eqn' }, fvs) } -- | Tracks whether we are renaming: -- -- 1. A type family equation that is not associated --- with a parent type class ('NonAssocTyFamEqn') +-- with a parent type class ('NonAssocTyFamEqn'). Examples: -- --- 2. An associated type family default declaration ('AssocTyFamDeflt') +-- @ +-- type family F a +-- type instance F Int = Bool -- NonAssocTyFamEqn NotClosed -- --- 3. An associated type family instance declaration ('AssocTyFamInst') +-- type family G a where +-- G Int = Bool -- NonAssocTyFamEqn Closed +-- @ +-- +-- 2. An associated type family default declaration ('AssocTyFamDeflt'). +-- Example: +-- +-- @ +-- class C a where +-- type A a +-- type instance A a = a -> a -- AssocTyFamDeflt C +-- @ +-- +-- 3. An associated type family instance declaration ('AssocTyFamInst'). +-- Example: +-- +-- @ +-- instance C a => C [a] where +-- type A [a] = Bool -- AssocTyFamInst C [a] +-- @ data AssocTyFamInfo = NonAssocTyFamEqn - | AssocTyFamDeflt Name -- Name of the parent class - | AssocTyFamInst Name -- Name of the parent class - [Name] -- Names of the tyvars of the parent instance decl + ClosedTyFamInfo -- Is this a closed type family? + | AssocTyFamDeflt + Name -- Name of the parent class + | AssocTyFamInst + Name -- Name of the parent class + [Name] -- Names of the tyvars of the parent instance decl -- | Tracks whether we are renaming an equation in a closed type family -- equation ('ClosedTyFam') or not ('NotClosedTyFam'). @@ -831,22 +859,25 @@ data ClosedTyFamInfo -- The names (RdrName and Name) of the closed type family rnTyFamInstEqn :: AssocTyFamInfo - -> ClosedTyFamInfo -> TyFamInstEqn GhcPs -> RnM (TyFamInstEqn GhcRn, FreeVars) -rnTyFamInstEqn atfi ctf_info +rnTyFamInstEqn atfi eqn@(HsIB { hsib_body = FamEqn { feqn_tycon = tycon , feqn_rhs = rhs }}) = do { let rhs_kvs = extractHsTyRdrTyVarsKindVars rhs ; (eqn'@(HsIB { hsib_body = FamEqn { feqn_tycon = L _ tycon' }}), fvs) <- rnFamInstEqn (TySynCtx tycon) atfi rhs_kvs eqn rnTySyn - ; case ctf_info of - NotClosedTyFam -> pure () - ClosedTyFam fam_rdr_name fam_name -> + + -- For closed type families, check that each equation is for the + -- right type family. E.g. barf on + -- type family F a where { G Int = Bool } + ; case atfi of + NonAssocTyFamEqn (ClosedTyFam fam_rdr_name fam_name) -> checkTc (fam_name == tycon') $ withHsDocContext (TyFamilyCtx fam_rdr_name) $ wrongTyFamName fam_name tycon' + _ -> pure () ; pure (eqn', fvs) } rnTyFamDefltDecl :: Name @@ -995,6 +1026,51 @@ was previously bound by the `instance C (Maybe a)` part. (see #16116). In each case, the function which detects improperly bound variables on the RHS is GHC.Tc.Validity.checkValidFamPats. + +Note [Type family equations and occurrences] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In most data/type family equations, the type family name used in the equation +is treated as an occurrence. For example: + + module A where + type family F a + + module B () where + import B (F) + type instance F Int = Bool + +We do not want to warn about `F` being unused in the module `B`, as the +instance constitutes a use site for `F`. The exception to this rule is closed +type families, whose equations constitute a definition, not occurrences. For +example: + + module C () where + type family CF a where + CF Char = Float + +Here, we /do/ want to warn that `CF` is unused in the module `C`, as it is +defined but not used (#18470). + +GHC accomplishes this in rnFamInstEqn when determining the set of free +variables to return at the end. If renaming a data family or open type family +equation, we add the name of the type family constructor to the set of returned +free variables to ensure that the name is marked as an occurrence. If renaming +a closed type family equation, we avoid adding the type family constructor name +to the free variables. This is quite simple, but it is not a perfect solution. +Consider this example: + + module X () where + type family F a where + F Int = Bool + F Double = F Int + +At present, GHC will treat any use of a type family constructor on the RHS of a +type family equation as an occurrence. Since `F` is used on the RHS of the +second equation of `F`, it is treated as an occurrence, causing `F` not to be +warned about. This is not ideal, since `F` isn't exported—it really /should/ +cause a warning to be emitted. There is some discussion in #10089/#12920 about +how this limitation might be overcome, but until then, we stick to the +simplistic solution above, as it fixes the egregious bug in #18470. -} @@ -1963,7 +2039,7 @@ rnFamDecl mb_cls (FamilyDecl { fdLName = tycon, fdTyVars = tyvars -> FamilyInfo GhcPs -> RnM (FamilyInfo GhcRn, FreeVars) rn_info (L _ fam_name) (ClosedTypeFamily (Just eqns)) = do { (eqns', fvs) - <- rnList (rnTyFamInstEqn NonAssocTyFamEqn (ClosedTyFam tycon fam_name)) + <- rnList (rnTyFamInstEqn (NonAssocTyFamEqn (ClosedTyFam tycon fam_name))) -- no class context eqns ; return (ClosedTypeFamily (Just eqns'), fvs) } ===================================== testsuite/tests/typecheck/should_compile/T18470.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC -Wunused-top-binds #-} + +module T18470 () where + +type family Closed x where + Closed Int = Bool ===================================== testsuite/tests/typecheck/should_compile/T18470.stderr ===================================== @@ -0,0 +1,3 @@ + +T18470.hs:6:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] + Defined but not used: type constructor or class ‘Closed’ ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -717,3 +717,4 @@ test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) test('T17775-viewpats-d', normal, compile_fail, ['']) test('T18412', normal, compile, ['']) +test('T18470', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f69ad265cce76b85d31e81eb62dede6eb02bd96f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f69ad265cce76b85d31e81eb62dede6eb02bd96f You're receiving 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 Jul 26 17:20:52 2020 From: gitlab at gitlab.haskell.org (Brandon Chinn) Date: Sun, 26 Jul 2020 13:20:52 -0400 Subject: [Git][ghc/ghc][wip/T16341] 2 commits: Remove from Read, fix test suite Message-ID: <5f1dbb74baac_80b3f84868c382850090a9@gitlab.haskell.org.mail> Brandon Chinn pushed to branch wip/T16341 at Glasgow Haskell Compiler / GHC Commits: fcaed721 by Brandon Chinn at 2020-07-26T10:08:59-07:00 Remove from Read, fix test suite - - - - - 58960da7 by Brandon Chinn at 2020-07-26T10:20:48-07:00 Added note - - - - - 2 changed files: - compiler/GHC/Tc/Deriv/Generate.hs - testsuite/tests/deriving/should_compile/T16341.hs Changes: ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -1033,7 +1033,7 @@ we want to be able to parse (Left 3) just fine. gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Read_binds get_fixity loc tycon tycon_args +gen_Read_binds get_fixity loc tycon _ = (listToBag [read_prec, default_readlist, default_readlistprec], emptyBag) where ----------------------------------------------------------------------- @@ -1044,7 +1044,7 @@ gen_Read_binds get_fixity loc tycon tycon_args = mkHsVarBind loc readListPrec_RDR (nlHsVar readListPrecDefault_RDR) ----------------------------------------------------------------------- - data_cons = getPossibleDataCons tycon tycon_args + data_cons = tyConDataCons tycon (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon data_cons read_prec = mkHsVarBind loc readPrec_RDR rhs @@ -1406,7 +1406,7 @@ gen_Data_binds loc rep_tc _ data_cons dataC_RDRs ) ) } where - data_cons = tyConDataCons rep_tc + data_cons = tyConDataCons rep_tc n_cons = length data_cons one_constr = n_cons == 1 @@ -2521,7 +2521,7 @@ newAuxBinderRdrName loc parent occ_fun = do -- | If we're deriving an instance for a GADT, e.g. `Eq (Foo Int)`, we should treat any constructors -- for which it's impossible to match `Foo Int` as not being there at all. -- --- See #16341 and the T16341.hs test case. +-- See Note [Filter out impossible GADT data constructors] getPossibleDataCons :: TyCon -> [Type] -> [DataCon] getPossibleDataCons tycon tycon_args = filter (not . dataConCannotMatch tycon_args) $ tyConDataCons tycon @@ -2742,4 +2742,34 @@ derived instances within the same module, not separated by any TH splices. (This is the case described in "Wrinkle: Reducing code duplication".) In situation (1), we can at least fall back on GHC's simplifier to pick up genAuxBinds' slack. + +Note [Filter out impossible GADT data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some stock-derivable classes will filter out impossible GADT data constructors, +to rule out problematic constructors when deriving instances. Classes that +filter constructors: + +* Eq +* Ord +* Show +* Lift +* Functor +* Foldable +* Traversable + +Classes that do not filter constructors: + +* Enum: doesn't make sense for GADTs in the first place +* Bounded: only makes sense for GADTs with a single constructor +* Ix: only makes sense for GADTs with a single constructor +* Read: `Read a` returns `a` instead of consumes `a`, so filtering data + constructors would make this function _more_ partial instead of less +* Data: uses `tagToEnum` to pick the constructor, which could reference + the incorrect constructors if we filter out constructors + +Classes that do not currently filter constructors may do so in the future, if +there is a valid use-case and we have requirements for how they should work. + +See #16341 and the T16341.hs test case. -} ===================================== testsuite/tests/deriving/should_compile/T16341.hs ===================================== @@ -1,12 +1,13 @@ -{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveLift #-} +{-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE StandaloneDeriving #-} module T16341 where -import Data.Data (Data) - data Foo a where Foo1 :: Foo Int Foo2 :: (Bool -> Bool) -> Foo Bool @@ -15,7 +16,6 @@ data Foo a where -- `Foo`, because the `Foo Int` designation precludes `Foo2` from being -- a reachable constructor deriving instance Show (Foo Int) -deriving instance Read (Foo Int) deriving instance Eq (Foo Int) deriving instance Ord (Foo Int) deriving instance Lift (Foo Int) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a03e1c0efe4d34d9dc45aee7d6fbd6d9e9bb1c4d...58960da7b7bf446035debddd1fc0b64f2afe68e4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a03e1c0efe4d34d9dc45aee7d6fbd6d9e9bb1c4d...58960da7b7bf446035debddd1fc0b64f2afe68e4 You're receiving 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 Jul 26 17:23:29 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 26 Jul 2020 13:23:29 -0400 Subject: [Git][ghc/ghc][master] Document loadFramework changes. (#18446) Message-ID: <5f1dbc11b0fd2_80b3f849248fe0850116cf@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - 1 changed file: - compiler/GHC/Runtime/Linker.hs Changes: ===================================== compiler/GHC/Runtime/Linker.hs ===================================== @@ -1695,6 +1695,38 @@ addEnvPaths name list -- ---------------------------------------------------------------------------- -- Loading a dynamic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32) +{- +Note [macOS Big Sur dynamic libraries] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +macOS Big Sur makes the following change to how frameworks are shipped +with the OS: + +> New in macOS Big Sur 11 beta, the system ships with a built-in +> dynamic linker cache of all system-provided libraries. As part of +> this change, copies of dynamic libraries are no longer present on +> the filesystem. Code that attempts to check for dynamic library +> presence by looking for a file at a path or enumerating a directory +> will fail. Instead, check for library presence by attempting to +> dlopen() the path, which will correctly check for the library in the +> cache. (62986286) + +(https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/) + +Therefore, the previous method of checking whether a library exists +before attempting to load it makes GHC.Runtime.Linker.loadFramework +fail to find frameworks installed at /System/Library/Frameworks. +Instead, any attempt to load a framework at runtime, such as by +passing -framework OpenGL to runghc or running code loading such a +framework with GHCi, fails with a 'not found' message. + +GHC.Runtime.Linker.loadFramework now opportunistically loads the +framework libraries without checking for their existence first, +failing only if all attempts to load a given framework from any of the +various possible locations fail. See also #18446, which this change +addresses. +-} + -- Darwin / MacOS X only: load a framework -- a framework is a dynamic library packaged inside a directory of the same -- name. They are searched for in different paths than normal libraries. @@ -1714,6 +1746,9 @@ loadFramework hsc_env extraPaths rootname -- sorry for the hardcoded paths, I hope they won't change anytime soon: defaultFrameworkPaths = ["/Library/Frameworks", "/System/Library/Frameworks"] + -- Try to call loadDLL for each candidate path. + -- + -- See Note [macOS Big Sur dynamic libraries] findLoadDLL [] errs = -- Tried all our known library paths, but dlopen() -- has no built-in paths for frameworks: give up View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a7c4439a407ad85b76aab9301fda61e7c10183ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a7c4439a407ad85b76aab9301fda61e7c10183ff You're receiving 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 Jul 26 17:24:05 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 26 Jul 2020 13:24:05 -0400 Subject: [Git][ghc/ghc][master] 4 commits: rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Message-ID: <5f1dbc3519fa4_80b3f849c40b20c5014887@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 5 changed files: - .gitlab/test-metrics.sh - libraries/base/tests/IO/all.T - rts/win32/OSMem.c - testsuite/driver/testlib.py - testsuite/tests/ghc-api/annotations/parseTree.stdout-mingw32 Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -81,6 +81,10 @@ function push() { echo "" echo "Failed to push git notes. Fetching, appending, and retrying... $MAX_RETRY retries left." done + + # Be sure to kill agent before we terminate since otherwise the Windows CI + # job won't finish. + ssh-agent -k } case $1 in @@ -88,3 +92,4 @@ case $1 in pull) pull ;; *) fail "Invalid mode $1" ;; esac + ===================================== libraries/base/tests/IO/all.T ===================================== @@ -10,7 +10,7 @@ test('IOError001', [omit_ways(['ghci']), set_stdin('IOError001.hs')], test('IOError002', normal, compile_and_run, ['']) test('finalization001', normal, compile_and_run, ['']) test('hClose001', [], compile_and_run, ['']) -test('hClose002', [], compile_and_run, ['']) +test('hClose002', [normalise_win32_io_errors], compile_and_run, ['']) test('hClose003', reqlib('unix'), compile_and_run, ['-package unix']) test('hFileSize001', normal, compile_and_run, ['']) test('hFileSize002', [omit_ways(['ghci'])], compile_and_run, ['']) @@ -61,8 +61,8 @@ test('misc001', [extra_run_opts('misc001.hs misc001.out')], compile_and_run, ['']) test('openFile001', normal, compile_and_run, ['']) -test('openFile002', exit_code(1), compile_and_run, ['']) -test('openFile003', [], compile_and_run, ['']) +test('openFile002', [exit_code(1), normalise_win32_io_errors], compile_and_run, ['']) +test('openFile003', [normalise_win32_io_errors], compile_and_run, ['']) test('openFile004', [], compile_and_run, ['']) test('openFile005', [], compile_and_run, ['']) test('openFile006', [], compile_and_run, ['']) ===================================== rts/win32/OSMem.c ===================================== @@ -472,7 +472,7 @@ void osCommitMemory (void *at, W_ size) temp = VirtualAlloc(at, size, MEM_COMMIT, PAGE_READWRITE); if (temp == NULL) { sysErrorBelch("osCommitMemory: VirtualAlloc MEM_COMMIT failed"); - stg_exit(EXIT_FAILURE); + stg_exit(EXIT_HEAPOVERFLOW); } } ===================================== testsuite/driver/testlib.py ===================================== @@ -743,6 +743,30 @@ def normalise_whitespace_fun(f): def _normalise_whitespace_fun(name, opts, f): opts.whitespace_normaliser = f +def normalise_win32_io_errors(name, opts): + """ + On Windows we currently have two IO manager implementations: both WinIO IO + manager and the old POSIX-emulated implementation. These currently differ + slightly in the error messages that they provide. Normalise these + differences away, preferring the new WinIO errors. + + This can be dropped when the old IO manager is removed. + """ + + SUBS = [ + ('Bad file descriptor', 'The handle is invalid'), + ('Permission denied', 'Access is denied.'), + ('No such file or directory', 'The system cannot find the file specified.'), + ] + + def f(s: str): + for old,new in SUBS: + s = s.replace(old, new) + + return s + + return when(opsys('mingw32'), normalise_fun(f)) + def normalise_version_( *pkgs ): def normalise_version__( str ): return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+', ===================================== testsuite/tests/ghc-api/annotations/parseTree.stdout-mingw32 ===================================== @@ -1,11 +1,11 @@ -[(AnnotationTuple.hs:14:20, [p], Unit 1), - (AnnotationTuple.hs:14:23-29, [p], Unit "hello"), - (AnnotationTuple.hs:14:35-37, [p], Unit 6.5), +[(AnnotationTuple.hs:14:20, [p], Solo 1), + (AnnotationTuple.hs:14:23-29, [p], Solo "hello"), + (AnnotationTuple.hs:14:35-37, [p], Solo 6.5), (AnnotationTuple.hs:14:39, [m], ()), - (AnnotationTuple.hs:14:41-52, [p], Unit [5, 5, 6, 7]), - (AnnotationTuple.hs:16:8, [p], Unit 1), - (AnnotationTuple.hs:16:11-17, [p], Unit "hello"), - (AnnotationTuple.hs:16:20-22, [p], Unit 6.5), + (AnnotationTuple.hs:14:41-52, [p], Solo [5, 5, 6, 7]), + (AnnotationTuple.hs:16:8, [p], Solo 1), + (AnnotationTuple.hs:16:11-17, [p], Solo "hello"), + (AnnotationTuple.hs:16:20-22, [p], Solo 6.5), (AnnotationTuple.hs:16:24, [m], ()), (AnnotationTuple.hs:16:25, [m], ()), (AnnotationTuple.hs:16:26, [m], ()), (, [m], ())] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a7c4439a407ad85b76aab9301fda61e7c10183ff...9cbfe0868418a531da0872b0c477a15aa67f8861 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a7c4439a407ad85b76aab9301fda61e7c10183ff...9cbfe0868418a531da0872b0c477a15aa67f8861 You're receiving 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 Jul 26 17:24:42 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 26 Jul 2020 13:24:42 -0400 Subject: [Git][ghc/ghc][master] winio: remove dead argument to stg_newIOPortzh Message-ID: <5f1dbc5acaa4_80b3f849248fe085019223@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - 1 changed file: - rts/PrimOps.cmm Changes: ===================================== rts/PrimOps.cmm ===================================== @@ -2221,7 +2221,7 @@ loop: IOPort primitives -------------------------------------------------------------------------- */ -stg_newIOPortzh ( gcptr init ) +stg_newIOPortzh () { W_ ioport; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8236925fc8cc2e6e3fed61a0676fa65270a4a538 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8236925fc8cc2e6e3fed61a0676fa65270a4a538 You're receiving 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 Jul 26 17:25:17 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 26 Jul 2020 13:25:17 -0400 Subject: [Git][ghc/ghc][master] winio: fix detection of tty terminals Message-ID: <5f1dbc7dc3f0_80b3f849c40b20c5020355@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 1 changed file: - libraries/base/cbits/IOutils.c Changes: ===================================== libraries/base/cbits/IOutils.c ===================================== @@ -209,8 +209,8 @@ __is_console(HANDLE hFile) DWORD handleType = GetFileType (hFile); /* TTY must be a character device */ - if (handleType == FILE_TYPE_CHAR) - return true; + if (handleType != FILE_TYPE_CHAR) + return false; DWORD st; /* GetConsoleMode appears to fail when it's not a TTY. In View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce0a1d678fbc8efa5fd384fd0227b7b3dc97cadd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce0a1d678fbc8efa5fd384fd0227b7b3dc97cadd You're receiving 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 Jul 26 17:25:53 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 26 Jul 2020 13:25:53 -0400 Subject: [Git][ghc/ghc][master] winio: update codeowners Message-ID: <5f1dbca17fa5c_80b3f849c40b20c502267d@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - 1 changed file: - CODEOWNERS Changes: ===================================== CODEOWNERS ===================================== @@ -49,3 +49,18 @@ /utils/gen-dll/ @Phyx /utils/fs/ @Phyx +# WinIO related code +/libraries/base/GHC/Event/Windows/ @Phyx +/libraries/base/GHC/IO/Windows/ @Phyx +/rts/win32/ @Phyx +/libraries/base/GHC/IO/Handle/Lock/Windows.hsc @Phyx +/libraries/base/GHC/Event/Windows.hsc @Phyx +/libraries/base/GHC/Conc/WinIO.hs @Phyx +/libraries/base/GHC/Conc/Windows.hs @Phyx +/libraries/base/GHC/IO/Handle/Windows.hs @Phyx +/libraries/base/GHC/IO/StdHandles.hs @Phyx +/libraries/base/GHC/Windows.hs @Phyx +/libraries/base/cbits/IOutils.c @Phyx +/libraries/base/cbits/Win32Utils.c @Phyx +/libraries/base/cbits/consUtils.c @Phyx +/libraries/base/include/winio_structs.h @Phyx View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52685cf7c077c51e3719e3c4dd5ca8257a99c4ea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52685cf7c077c51e3719e3c4dd5ca8257a99c4ea You're receiving 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 Jul 26 17:56:38 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 26 Jul 2020 13:56:38 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 11 commits: Document loadFramework changes. (#18446) Message-ID: <5f1dc3d66abe_80b3f849248fe0850339ed@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - ae0e0972 by Vladislav Zavialov at 2020-07-26T13:56:29-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 4c22f7a8 by leiftw at 2020-07-26T13:56:31-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - cb0bb4cb by Vladislav Zavialov at 2020-07-26T13:56:31-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - 19 changed files: - .gitlab/test-metrics.sh - CODEOWNERS - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Runtime/Linker.hs - docs/users_guide/8.12.1-notes.rst - docs/users_guide/exts/negative_literals.rst - docs/users_guide/separate_compilation.rst - libraries/base/cbits/IOutils.c - libraries/base/tests/IO/all.T - rts/PrimOps.cmm - rts/win32/OSMem.c - testsuite/driver/testlib.py - testsuite/tests/ghc-api/annotations/parseTree.stdout-mingw32 - − testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/NegativeLiterals.hs - + testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs - testsuite/tests/parser/should_compile/all.T Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -81,6 +81,10 @@ function push() { echo "" echo "Failed to push git notes. Fetching, appending, and retrying... $MAX_RETRY retries left." done + + # Be sure to kill agent before we terminate since otherwise the Windows CI + # job won't finish. + ssh-agent -k } case $1 in @@ -88,3 +92,4 @@ case $1 in pull) pull ;; *) fail "Invalid mode $1" ;; esac + ===================================== CODEOWNERS ===================================== @@ -49,3 +49,18 @@ /utils/gen-dll/ @Phyx /utils/fs/ @Phyx +# WinIO related code +/libraries/base/GHC/Event/Windows/ @Phyx +/libraries/base/GHC/IO/Windows/ @Phyx +/rts/win32/ @Phyx +/libraries/base/GHC/IO/Handle/Lock/Windows.hsc @Phyx +/libraries/base/GHC/Event/Windows.hsc @Phyx +/libraries/base/GHC/Conc/WinIO.hs @Phyx +/libraries/base/GHC/Conc/Windows.hs @Phyx +/libraries/base/GHC/IO/Handle/Windows.hs @Phyx +/libraries/base/GHC/IO/StdHandles.hs @Phyx +/libraries/base/GHC/Windows.hs @Phyx +/libraries/base/cbits/IOutils.c @Phyx +/libraries/base/cbits/Win32Utils.c @Phyx +/libraries/base/cbits/consUtils.c @Phyx +/libraries/base/include/winio_structs.h @Phyx ===================================== compiler/GHC/Parser.y ===================================== @@ -1884,9 +1884,9 @@ sigtypes1 :: { (OrdList (LHsSigType GhcPs)) } ----------------------------------------------------------------------------- -- Types -unpackedness :: { Located ([AddAnn], SourceText, SrcUnpackedness) } - : '{-# UNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getUNPACK_PRAGs $1, SrcUnpack) } - | '{-# NOUNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getNOUNPACK_PRAGs $1, SrcNoUnpack) } +unpackedness :: { Located UnpackednessPragma } + : '{-# UNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getUNPACK_PRAGs $1) SrcUnpack) } + | '{-# NOUNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getNOUNPACK_PRAGs $1) SrcNoUnpack) } forall_telescope :: { Located ([AddAnn], HsForAllTelescope GhcPs) } : 'forall' tv_bndrs '.' {% do { hintExplicitForall $1 @@ -1980,13 +1980,16 @@ tyapp :: { Located TyEl } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | PREFIX_AT atype { sLL $1 $> $ (TyElKindApp (comb2 $1 $2) $2) } - | qtyconop { sL1 $1 $ TyElOpr (unLoc $1) } - | tyvarop { sL1 $1 $ TyElOpr (unLoc $1) } - | SIMPLEQUOTE qconop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | tyop { mapLoc TyElOpr $1 } + | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } + +tyop :: { Located RdrName } + : qtyconop { $1 } + | tyvarop { $1 } + | SIMPLEQUOTE qconop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | SIMPLEQUOTE varop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | SIMPLEQUOTE varop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } atype :: { LHsType GhcPs } : ntgtycon { sL1 $1 (HsTyVar noExtField NotPromoted $1) } -- Not including unit tuples ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -199,7 +199,6 @@ $docsym = [\| \^ \* \$] -- normal signed numerical literals can only be explicitly negative, -- not explicitly positive (contrast @exponent) @negative = \- - at signed = @negative ? -- ----------------------------------------------------------------------------- @@ -531,12 +530,12 @@ $tab { warnTab } ifExtension BinaryLiteralsBit } { tok_primint positive 2 3 binary } 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 octal } 0[xX] @numspc @hexadecimal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 hexadecimal } - @negative @decimal \# / { ifExtension MagicHashBit } { tok_primint negative 1 2 decimal } - @negative 0[bB] @numspc @binary \# / { ifExtension MagicHashBit `alexAndPred` + @negative @decimal \# / { negHashLitPred } { tok_primint negative 1 2 decimal } + @negative 0[bB] @numspc @binary \# / { negHashLitPred `alexAndPred` ifExtension BinaryLiteralsBit } { tok_primint negative 3 4 binary } - @negative 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint negative 3 4 octal } + @negative 0[oO] @numspc @octal \# / { negHashLitPred } { tok_primint negative 3 4 octal } @negative 0[xX] @numspc @hexadecimal \# - / { ifExtension MagicHashBit } { tok_primint negative 3 4 hexadecimal } + / { negHashLitPred } { tok_primint negative 3 4 hexadecimal } @decimal \# \# / { ifExtension MagicHashBit } { tok_primword 0 2 decimal } 0[bB] @numspc @binary \# \# / { ifExtension MagicHashBit `alexAndPred` @@ -546,8 +545,11 @@ $tab { warnTab } -- Unboxed floats and doubles (:: Float#, :: Double#) -- prim_{float,double} work with signed literals - @signed @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } - @signed @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } + @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + + @negative @floating_point \# / { negHashLitPred } { tok_frac 1 tok_primfloat } + @negative @floating_point \# \# / { negHashLitPred } { tok_frac 2 tok_primdouble } } -- Strings and chars are lexed by hand-written code. The reason is @@ -1192,8 +1194,8 @@ atEOL _ _ _ (AI _ buf) = atEnd buf || currentChar buf == '\n' -- Check if we should parse a negative literal (e.g. -123) as a single token. negLitPred :: AlexAccPred ExtsBitmap negLitPred = - negative_literals `alexOrPred` - (lexical_negation `alexAndPred` prefix_minus) + prefix_minus `alexAndPred` + (negative_literals `alexOrPred` lexical_negation) where negative_literals = ifExtension NegativeLiteralsBit @@ -1202,14 +1204,33 @@ negLitPred = alexNotPred (ifExtension NoLexicalNegationBit) prefix_minus = - -- The condition for a prefix occurrence of an operator is: - -- - -- not precededByClosingToken && followedByOpeningToken - -- - -- but we don't check followedByOpeningToken here as it holds - -- simply because we immediately lex a literal after the minus. + -- Note [prefix_minus in negLitPred and negHashLitPred] + alexNotPred precededByClosingToken + +-- Check if we should parse an unboxed negative literal (e.g. -123#) as a single token. +negHashLitPred :: AlexAccPred ExtsBitmap +negHashLitPred = prefix_minus `alexAndPred` magic_hash + where + magic_hash = ifExtension MagicHashBit + prefix_minus = + -- Note [prefix_minus in negLitPred and negHashLitPred] alexNotPred precededByClosingToken +{- Note [prefix_minus in negLitPred and negHashLitPred] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We want to parse -1 as a single token, but x-1 as three tokens. +So in negLitPred (and negHashLitPred) we require that we have a prefix +occurrence of the minus sign. See Note [Whitespace-sensitive operator parsing] +for a detailed definition of a prefix occurrence. + +The condition for a prefix occurrence of an operator is: + + not precededByClosingToken && followedByOpeningToken + +but we don't check followedByOpeningToken when parsing a negative literal. +It holds simply because we immediately lex a literal after the minus. +-} + ifExtension :: ExtBits -> AlexAccPred ExtsBitmap ifExtension extBits bits _ _ _ = extBits `xtest` bits ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -70,6 +70,7 @@ module GHC.Parser.PostProcess ( addFatalError, hintBangPat, TyEl(..), mergeOps, mergeDataCon, mkBangTy, + UnpackednessPragma(..), -- Help with processing exports ImpExpSubSpec(..), @@ -559,25 +560,6 @@ As the result, in order to determine whether (C t1 t2) declares a data constructor, a type, or a context, we would need unlimited lookahead which 'happy' is not so happy with. -To further complicate matters, the interpretation of (!) and (~) is different -in constructors and types: - - (b1) type T = C ! D - (b2) data T = C ! D - (b3) data T = C ! D => E - -In (b1) and (b3), (!) is a type operator with two arguments: 'C' and 'D'. At -the same time, in (b2) it is a strictness annotation: 'C' is a data constructor -with a single strict argument 'D'. For the programmer, these cases are usually -easy to tell apart due to whitespace conventions: - - (b2) data T = C !D -- no space after the bang hints that - -- it is a strictness annotation - -For the parser, on the other hand, this whitespace does not matter. We cannot -tell apart (b2) from (b3) until we encounter (=>), so it requires unlimited -lookahead. - The solution that accounts for all of these issues is to initially parse data declarations and types as a reversed list of TyEl: @@ -1324,7 +1306,7 @@ isFunLhs e = go e [] [] data TyEl = TyElOpr RdrName | TyElOpd (HsType GhcPs) | TyElKindApp SrcSpan (LHsType GhcPs) -- See Note [TyElKindApp SrcSpan interpretation] - | TyElUnpackedness ([AddAnn], SourceText, SrcUnpackedness) + | TyElUnpackedness UnpackednessPragma {- Note [TyElKindApp SrcSpan interpretation] @@ -1345,20 +1327,15 @@ instance Outputable TyEl where ppr (TyElOpr name) = ppr name ppr (TyElOpd ty) = ppr ty ppr (TyElKindApp _ ki) = text "@" <> ppr ki - ppr (TyElUnpackedness (_, _, unpk)) = ppr unpk + ppr (TyElUnpackedness (UnpackednessPragma _ _ unpk)) = ppr unpk -- | Extract a strictness/unpackedness annotation from the front of a reversed -- 'TyEl' list. pUnpackedness :: [Located TyEl] -- reversed TyEl - -> Maybe ( SrcSpan - , [AddAnn] - , SourceText - , SrcUnpackedness - , [Located TyEl] {- remaining TyEl -}) -pUnpackedness (L l x1 : xs) - | TyElUnpackedness (anns, prag, unpk) <- x1 - = Just (l, anns, prag, unpk, xs) + -> Maybe (SrcSpan, UnpackednessPragma, + [Located TyEl] {- remaining TyEl -}) +pUnpackedness (L l x1 : xs) | TyElUnpackedness up <- x1 = Just (l, up, xs) pUnpackedness _ = Nothing pBangTy @@ -1371,7 +1348,7 @@ pBangTy pBangTy lt@(L l1 _) xs = case pUnpackedness xs of Nothing -> (False, lt, pure (), xs) - Just (l2, anns, prag, unpk, xs') -> + Just (l2, UnpackednessPragma anns prag unpk, xs') -> let bl = combineSrcSpans l1 l2 bt = addUnpackedness (prag, unpk) lt in (True, L bl bt, addAnnsAt bl anns, xs') @@ -1380,6 +1357,10 @@ mkBangTy :: SrcStrictness -> LHsType GhcPs -> HsType GhcPs mkBangTy strictness = HsBangTy noExtField (HsSrcBang NoSourceText NoSrcUnpack strictness) +-- Result of parsing {-# UNPACK #-} or {-# NOUNPACK #-} +data UnpackednessPragma = + UnpackednessPragma [AddAnn] SourceText SrcUnpackedness + addUnpackedness :: (SourceText, SrcUnpackedness) -> LHsType GhcPs -> HsType GhcPs addUnpackedness (prag, unpk) (L _ (HsBangTy x bang t)) | HsSrcBang NoSourceText NoSrcUnpack strictness <- bang @@ -1411,7 +1392,7 @@ mergeOps all_xs = go (0 :: Int) [] id all_xs -- clause [unpk]: -- handle (NO)UNPACK pragmas - go k acc ops_acc ((L l (TyElUnpackedness (anns, unpkSrc, unpk))):xs) = + go k acc ops_acc ((L l (TyElUnpackedness (UnpackednessPragma anns unpkSrc unpk))):xs) = if not (null acc) && null xs then do { acc' <- eitherToP $ mergeOpsAcc acc ; let a = ops_acc acc' ===================================== compiler/GHC/Runtime/Linker.hs ===================================== @@ -1695,6 +1695,38 @@ addEnvPaths name list -- ---------------------------------------------------------------------------- -- Loading a dynamic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32) +{- +Note [macOS Big Sur dynamic libraries] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +macOS Big Sur makes the following change to how frameworks are shipped +with the OS: + +> New in macOS Big Sur 11 beta, the system ships with a built-in +> dynamic linker cache of all system-provided libraries. As part of +> this change, copies of dynamic libraries are no longer present on +> the filesystem. Code that attempts to check for dynamic library +> presence by looking for a file at a path or enumerating a directory +> will fail. Instead, check for library presence by attempting to +> dlopen() the path, which will correctly check for the library in the +> cache. (62986286) + +(https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/) + +Therefore, the previous method of checking whether a library exists +before attempting to load it makes GHC.Runtime.Linker.loadFramework +fail to find frameworks installed at /System/Library/Frameworks. +Instead, any attempt to load a framework at runtime, such as by +passing -framework OpenGL to runghc or running code loading such a +framework with GHCi, fails with a 'not found' message. + +GHC.Runtime.Linker.loadFramework now opportunistically loads the +framework libraries without checking for their existence first, +failing only if all attempts to load a given framework from any of the +various possible locations fail. See also #18446, which this change +addresses. +-} + -- Darwin / MacOS X only: load a framework -- a framework is a dynamic library packaged inside a directory of the same -- name. They are searched for in different paths than normal libraries. @@ -1714,6 +1746,9 @@ loadFramework hsc_env extraPaths rootname -- sorry for the hardcoded paths, I hope they won't change anytime soon: defaultFrameworkPaths = ["/Library/Frameworks", "/System/Library/Frameworks"] + -- Try to call loadDLL for each candidate path. + -- + -- See Note [macOS Big Sur dynamic libraries] findLoadDLL [] errs = -- Tried all our known library paths, but dlopen() -- has no built-in paths for frameworks: give up ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -224,6 +224,13 @@ Language f = (- x) -- operator section c = (-x) -- negation +* The behavior of :extension:`NegativeLiterals` changed, and now we require + that a negative literal must not be preceded by a closing token (see + `GHC Proposal #229 `__ + for the definition of a closing token). In other words, we parse ``f -123`` + as ``f (-123)``, but ``x-123`` as ``(-) x 123``. Before this amendment, + :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/negative_literals.rst ===================================== @@ -24,9 +24,11 @@ will elicit an unexpected integer-literal-overflow message. Whitespace can be inserted, as in ``- 123``, to force interpretation as two tokens. -One pitfall is that with :extension:`NegativeLiterals`, ``x-1`` will -be parsed as ``x`` applied to the argument ``-1``, which is usually -not what you want. ``x - 1`` or even ``x- 1`` can be used instead -for subtraction. To avoid this, consider using :extension:`LexicalNegation` -instead. - +In 8.12, the behavior of this extension changed, and now we require that a negative literal must not be preceded by a closing token (see +`GHC Proposal #229 `__ +for the definition of a closing token). In other words, we parse ``f -123`` as ``f (-123)``, but ``x-123`` as ``(-) x +123``. Before this amendment, :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + +:extension:`NegativeLiterals` is a subset of :extension:`LexicalNegation`. That +is, enabling both of those extensions has the same effect as enabling +:extension:`LexicalNegation` alone. ===================================== docs/users_guide/separate_compilation.rst ===================================== @@ -758,7 +758,7 @@ There are several points to note here: the same machine-generated binary format as any other GHC-generated interface file (e.g. ``B.hi``). You can display its contents with ``ghc --show-iface``. If you specify a directory for - interface files, the ``-ohidir`` flag, then that affects ``hi-boot`` files + interface files, the ``-hidir`` flag, then that affects ``hi-boot`` files too. - If hs-boot files are considered distinct from their parent source ===================================== libraries/base/cbits/IOutils.c ===================================== @@ -209,8 +209,8 @@ __is_console(HANDLE hFile) DWORD handleType = GetFileType (hFile); /* TTY must be a character device */ - if (handleType == FILE_TYPE_CHAR) - return true; + if (handleType != FILE_TYPE_CHAR) + return false; DWORD st; /* GetConsoleMode appears to fail when it's not a TTY. In ===================================== libraries/base/tests/IO/all.T ===================================== @@ -10,7 +10,7 @@ test('IOError001', [omit_ways(['ghci']), set_stdin('IOError001.hs')], test('IOError002', normal, compile_and_run, ['']) test('finalization001', normal, compile_and_run, ['']) test('hClose001', [], compile_and_run, ['']) -test('hClose002', [], compile_and_run, ['']) +test('hClose002', [normalise_win32_io_errors], compile_and_run, ['']) test('hClose003', reqlib('unix'), compile_and_run, ['-package unix']) test('hFileSize001', normal, compile_and_run, ['']) test('hFileSize002', [omit_ways(['ghci'])], compile_and_run, ['']) @@ -61,8 +61,8 @@ test('misc001', [extra_run_opts('misc001.hs misc001.out')], compile_and_run, ['']) test('openFile001', normal, compile_and_run, ['']) -test('openFile002', exit_code(1), compile_and_run, ['']) -test('openFile003', [], compile_and_run, ['']) +test('openFile002', [exit_code(1), normalise_win32_io_errors], compile_and_run, ['']) +test('openFile003', [normalise_win32_io_errors], compile_and_run, ['']) test('openFile004', [], compile_and_run, ['']) test('openFile005', [], compile_and_run, ['']) test('openFile006', [], compile_and_run, ['']) ===================================== rts/PrimOps.cmm ===================================== @@ -2221,7 +2221,7 @@ loop: IOPort primitives -------------------------------------------------------------------------- */ -stg_newIOPortzh ( gcptr init ) +stg_newIOPortzh () { W_ ioport; ===================================== rts/win32/OSMem.c ===================================== @@ -472,7 +472,7 @@ void osCommitMemory (void *at, W_ size) temp = VirtualAlloc(at, size, MEM_COMMIT, PAGE_READWRITE); if (temp == NULL) { sysErrorBelch("osCommitMemory: VirtualAlloc MEM_COMMIT failed"); - stg_exit(EXIT_FAILURE); + stg_exit(EXIT_HEAPOVERFLOW); } } ===================================== testsuite/driver/testlib.py ===================================== @@ -743,6 +743,30 @@ def normalise_whitespace_fun(f): def _normalise_whitespace_fun(name, opts, f): opts.whitespace_normaliser = f +def normalise_win32_io_errors(name, opts): + """ + On Windows we currently have two IO manager implementations: both WinIO IO + manager and the old POSIX-emulated implementation. These currently differ + slightly in the error messages that they provide. Normalise these + differences away, preferring the new WinIO errors. + + This can be dropped when the old IO manager is removed. + """ + + SUBS = [ + ('Bad file descriptor', 'The handle is invalid'), + ('Permission denied', 'Access is denied.'), + ('No such file or directory', 'The system cannot find the file specified.'), + ] + + def f(s: str): + for old,new in SUBS: + s = s.replace(old, new) + + return s + + return when(opsys('mingw32'), normalise_fun(f)) + def normalise_version_( *pkgs ): def normalise_version__( str ): return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+', ===================================== testsuite/tests/ghc-api/annotations/parseTree.stdout-mingw32 ===================================== @@ -1,11 +1,11 @@ -[(AnnotationTuple.hs:14:20, [p], Unit 1), - (AnnotationTuple.hs:14:23-29, [p], Unit "hello"), - (AnnotationTuple.hs:14:35-37, [p], Unit 6.5), +[(AnnotationTuple.hs:14:20, [p], Solo 1), + (AnnotationTuple.hs:14:23-29, [p], Solo "hello"), + (AnnotationTuple.hs:14:35-37, [p], Solo 6.5), (AnnotationTuple.hs:14:39, [m], ()), - (AnnotationTuple.hs:14:41-52, [p], Unit [5, 5, 6, 7]), - (AnnotationTuple.hs:16:8, [p], Unit 1), - (AnnotationTuple.hs:16:11-17, [p], Unit "hello"), - (AnnotationTuple.hs:16:20-22, [p], Unit 6.5), + (AnnotationTuple.hs:14:41-52, [p], Solo [5, 5, 6, 7]), + (AnnotationTuple.hs:16:8, [p], Solo 1), + (AnnotationTuple.hs:16:11-17, [p], Solo "hello"), + (AnnotationTuple.hs:16:20-22, [p], Solo 6.5), (AnnotationTuple.hs:16:24, [m], ()), (AnnotationTuple.hs:16:25, [m], ()), (AnnotationTuple.hs:16:26, [m], ()), (, [m], ())] ===================================== testsuite/tests/parser/should_compile/LexNegVsNegLit.hs deleted ===================================== @@ -1,17 +0,0 @@ -{-# LANGUAGE NegativeLiterals, LexicalNegation #-} - -module LexNegVsNegLit where - --- NegativeLiterals specifies that we parse x-1 as x (-1), even though it's --- considered a shortcoming. --- --- LexicalNegation does not change that. --- -b :: Bool -b = even-1 -- parsed as: even (-1) - -- so it is well-typed. - -- - -- with LexicalNegation alone, we'd get (-) even 1, - -- but NegativeLiterals takes precedence here. - --- See also: GHC Proposal #344 ===================================== testsuite/tests/parser/should_compile/NegativeLiterals.hs ===================================== @@ -0,0 +1,57 @@ +{-# LANGUAGE NegativeLiterals, MagicHash, BinaryLiterals #-} + +module NegativeLiterals where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p1 :: Bool +p1 = even -2 -- parsed as: even (-2) + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p3 :: Int +p3 = floor -2.4 -- parsed as: floor (-2.4) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +p6 :: Bool +p6 = even -0b10 -- parsed as: even (-2) + || even -0o10 -- parsed as: even (-8) + || even -0x10 -- parsed as: even (-16) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti1 :: Integer -> Integer +ti1 x = x-2 -- parsed as: (-) x 1 + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) + +ti6 :: Integer -> [Integer] +ti6 x = + [ x-0b10, -- parsed as: (-) x 2 + x-0o10, -- parsed as: (-) x 8 + x-0x10 ] -- parsed as: (-) x 16 ===================================== testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs ===================================== @@ -0,0 +1,39 @@ +{-# LANGUAGE NoNegativeLiterals, MagicHash, BinaryLiterals #-} + +-- Even when NegativeLiterals are disabled, +-- we parse unboxed literals appropriately. +module NegativeLiteralsNoExt where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -153,7 +153,8 @@ test('proposal-229b', normal, compile, ['']) test('proposal-229d', normal, compile, ['']) test('proposal-229e', normal, compile, ['']) test('LexicalNegation', normal, compile, ['']) -test('LexNegVsNegLit', normal, compile, ['']) +test('NegativeLiterals', normal, compile, ['']) +test('NegativeLiteralsNoExt', normal, compile, ['']) # We omit 'profasm' because it fails with: # Cannot load -prof objects when GHC is built with -dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fad5c724ae203b4ced4f7ad99c9325f9b6ba1f3e...cb0bb4cbbac3cb21ebb028ed13a383c8f963ca12 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fad5c724ae203b4ced4f7ad99c9325f9b6ba1f3e...cb0bb4cbbac3cb21ebb028ed13a383c8f963ca12 You're receiving 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 Jul 26 19:06:02 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 26 Jul 2020 15:06:02 -0400 Subject: [Git][ghc/ghc][wip/backports] 7 commits: Make `identifier` parse unparenthesized `->` (#18060) Message-ID: <5f1dd41abe45c_80b3f849c40b20c5042995@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: 83bcf37d by Joshua Price at 2020-07-26T15:05:52-04:00 Make `identifier` parse unparenthesized `->` (#18060) (cherry picked from commit d6203f24cf421749616a247c047a9b44192f963a) - - - - - 50f25994 by Simon Peyton Jones at 2020-07-26T15:05:52-04:00 Wrap an implication around class-sig kind errors Ticket #17841 showed that we can get a kind error in a class signature, but lack an enclosing implication that binds its skolems. This patch * Adds the wrapping implication: the new call to checkTvConstraints in tcClassDecl1 * Simplifies the API to checkTvConstraints, which was not otherwise called at all. * Simplifies TcErrors.report_unsolved by *not* initialising the TidyEnv from the typechecker lexical envt. It's enough to do so from the free vars of the unsolved constraints; and we get silly renamings if we add variables twice: once from the lexical scope and once from the implication constraint. (cherry picked from commit 3f431587c2db712136a3b5a353758ca63e1a5fd8) - - - - - a063768e by Simon Peyton Jones at 2020-07-26T15:05:52-04:00 Refactoring in TcSMonad This patch is just refactoring: no change in behaviour. I removed the rather complicated checkConstraintsTcS checkTvConstraintsTcS in favour of simpler functions emitImplicationTcS emitTvImplicationTcS pushLevelNoWorkList The last of these is a little strange, but overall it's much better I think. (cherry picked from commit 9d87ced6832e75fce1e01b67bc6b7d9d1cf31efb) - - - - - 05be81e8 by Simon Peyton Jones at 2020-07-26T15:05:52-04:00 Major improvements to the specialiser This patch is joint work of Alexis King and Simon PJ. It does some significant refactoring of the type-class specialiser. Main highlights: * We can specialise functions with types like f :: Eq a => a -> Ord b => b => blah where the classes aren't all at the front (#16473). Here we can correctly specialise 'f' based on a call like f @Int @Bool dEqInt x dOrdBool This change really happened in an earlier patch commit 2d0cf6252957b8980d89481ecd0b79891da4b14b Author: Sandy Maguire <sandy at sandymaguire.me> Date: Thu May 16 12:12:10 2019 -0400 work that this new patch builds directly on that work, and refactors it a bit. * We can specialise functions with implicit parameters (#17930) g :: (?foo :: Bool, Show a) => a -> String Previously we could not, but now they behave just like a non-class argument as in 'f' above. * We can specialise under-saturated calls, where some (but not all of the dictionary arguments are provided (#17966). For example, we can specialise the above 'f' based on a call map (f @Int dEqInt) xs even though we don't (and can't) give Ord dictionary. This may sound exotic, but #17966 is a program from the wild, and showed significant perf loss for functions like f, if you need saturation of all dictionaries. * We fix a buglet in which a floated dictionary had a bogus demand (#17810), by using zapIdDemandInfo in the NonRec case of specBind. * A tiny side benefit: we can drop dead arguments to specialised functions; see Note [Drop dead args from specialisations] * Fixed a bug in deciding what dictionaries are "interesting"; see Note [Keep the old dictionaries interesting] This is all achieved by by building on Sandy Macguire's work in defining SpecArg, which mkCallUDs uses to describe the arguments of the call. Main changes: * Main work is in specHeader, which marched down the [InBndr] from the function definition and the [SpecArg] from the call site, together. * specCalls no longer has an arity check; the entire mechanism now handles unders-saturated calls fine. * mkCallUDs decides on an argument-by-argument basis whether to specialise a particular dictionary argument; this is new. See mk_spec_arg in mkCallUDs. It looks as if there are many more lines of code, but I think that all the extra lines are comments! (cherry picked from commit 7052d7c7ce3418db9e66ad6ff31e80b2a2c724bb) - - - - - a10c6ddf by Simon Peyton Jones at 2020-07-26T15:05:52-04:00 Fix specialisation for DFuns When specialising a DFun we must take care to saturate the unfolding. See Note [Specialising DFuns] in Specialise. Fixes #18120 (cherry picked from commit 88e3c8150d2b2d96c3ebc0b2942c9af44071c511) - - - - - 5015d3ac by Ben Gamari at 2020-07-26T15:05:52-04:00 testsuite: Accept wibbles in specialiser test output - - - - - 6471cc6a by Moritz Angermann at 2020-07-26T15:05:52-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. (cherry picked from commit aedfeb0b2b22172a0dfca0fe0c020ac80539d6ae) - - - - - 30 changed files: - compiler/coreSyn/CoreSubst.hs - compiler/coreSyn/CoreUnfold.hs - compiler/deSugar/DsBinds.hs - compiler/parser/Parser.y - compiler/specialise/Specialise.hs - compiler/typecheck/TcCanonical.hs - compiler/typecheck/TcClassDcl.hs - compiler/typecheck/TcErrors.hs - compiler/typecheck/TcEvidence.hs - compiler/typecheck/TcSMonad.hs - compiler/typecheck/TcSigs.hs - compiler/typecheck/TcTyClsDecls.hs - compiler/typecheck/TcUnify.hs - rts/Linker.c - rts/LinkerInternals.h - rts/linker/Elf.c - rts/linker/LoadArchive.c - rts/linker/M32Alloc.c - rts/linker/MachO.c - rts/linker/SymbolExtras.c - rts/linker/elf_got.c - + testsuite/tests/ghci/T18060/T18060.script - + testsuite/tests/ghci/T18060/T18060.stdout - + testsuite/tests/ghci/T18060/all.T - testsuite/tests/perf/compiler/T16473.stdout - testsuite/tests/polykinds/T16902.stderr - + testsuite/tests/polykinds/T17841.hs - + testsuite/tests/polykinds/T17841.stderr - testsuite/tests/polykinds/all.T - testsuite/tests/simplCore/should_compile/Makefile The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/309cff632977d372a65c698d6cd16992558acac7...6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/309cff632977d372a65c698d6cd16992558acac7...6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 You're receiving 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 Jul 26 19:31:31 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 26 Jul 2020 15:31:31 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/gc/nonmoving-pinned Message-ID: <5f1dda135e08f_80bd68a9b850478b5@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/gc/nonmoving-pinned at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/gc/nonmoving-pinned You're receiving 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 Jul 26 19:37:03 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 26 Jul 2020 15:37:03 -0400 Subject: [Git][ghc/ghc][wip/gc/nonmoving-pinned] nonmoving: Teach allocatePinned() to allocate into nonmoving heap Message-ID: <5f1ddb5f9b8d9_80b3f849c40b20c504956@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/gc/nonmoving-pinned at Glasgow Haskell Compiler / GHC Commits: d64deb00 by Ben Gamari at 2020-07-26T15:36:57-04:00 nonmoving: Teach allocatePinned() to allocate into nonmoving heap The allocatePinned() function is used to allocate pinned memory (e.g. for newPinnedByteArray#) - - - - - 2 changed files: - rts/sm/NonMoving.h - rts/sm/Storage.c Changes: ===================================== rts/sm/NonMoving.h ===================================== @@ -73,11 +73,17 @@ struct NonmovingAllocator { // allocators cover block sizes of 2^NONMOVING_ALLOCA0 to // 2^(NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT) (in bytes) +// The largest allocator class must be at least LARGE_OBJECT_THRESHOLD in size +// as Storage.c:allocatePinned will allocate small pinned allocations into the +// non-moving heap. #define NONMOVING_ALLOCA_CNT 12 // maximum number of free segments to hold on to #define NONMOVING_MAX_FREE 16 +// block size of largest allocator in bytes. +#define NONMOVING_MAX_BLOCK_SZ (1 << (NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT)) + struct NonmovingHeap { struct NonmovingAllocator *allocators[NONMOVING_ALLOCA_CNT]; // free segment list. This is a cache where we keep up to ===================================== rts/sm/Storage.c ===================================== @@ -1165,6 +1165,21 @@ allocatePinned (Capability *cap, W_ n /*words*/, W_ alignment /*bytes*/, W_ alig const StgWord alignment_w = alignment / sizeof(W_); + // If the non-moving collector is enabled then we can allocate small, + // pinned allocations directly into the non-moving heap. This is a bit more + // expensive up-front but reduces fragmentation and is worthwhile since + // pinned allocations are often long-lived.. + if (RTS_UNLIKELY(RtsFlags.GcFlags.use_nonmoving) + && n * WORD_SIZE + alignment_w <= NONMOVING_MAX_BLOCK_SZ) + { + p = nonmovingAllocate(cap, n + alignment_w); + W_ off_w = ALIGN_WITH_OFF_W(p, alignment, align_off); + MEMSET_IF_PROFILING_W(p, 0, off_w); + p += off_w; + MEMSET_IF_PROFILING_W(p + n, 0, alignment_w - off_w - 1); + return p; + } + // If the request is for a large object, then allocate() // will give us a pinned object anyway. if (n >= LARGE_OBJECT_THRESHOLD/sizeof(W_)) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d64deb00785523ee77b84be96ecceb4f44f46303 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d64deb00785523ee77b84be96ecceb4f44f46303 You're receiving 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 Jul 26 19:41:19 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 26 Jul 2020 15:41:19 -0400 Subject: [Git][ghc/ghc][wip/bump-win32] 68 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f1ddc5f7e653_80b114037a4504991e@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bump-win32 at Glasgow Haskell Compiler / GHC Commits: 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - f314afd7 by Ben Gamari at 2020-07-26T15:41:17-04:00 Bump Win32 and process submodules - - - - - 30 changed files: - .gitlab/test-metrics.sh - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Lint.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cdfc18918cc93970795dee7741e41400efe89cba...f314afd7006118885ea7c7d1991f89812f67e3e3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cdfc18918cc93970795dee7741e41400efe89cba...f314afd7006118885ea7c7d1991f89812f67e3e3 You're receiving 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 Jul 26 19:56:18 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 26 Jul 2020 15:56:18 -0400 Subject: [Git][ghc/ghc][wip/gc/nonmoving-pinned] nonmoving: Teach allocatePinned() to allocate into nonmoving heap Message-ID: <5f1ddfe29d44d_80b3f84925412345052150@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/gc/nonmoving-pinned at Glasgow Haskell Compiler / GHC Commits: 615373c2 by Ben Gamari at 2020-07-26T15:55:32-04:00 nonmoving: Teach allocatePinned() to allocate into nonmoving heap The allocatePinned() function is used to allocate pinned memory (e.g. for newPinnedByteArray#) - - - - - 2 changed files: - rts/sm/NonMoving.h - rts/sm/Storage.c Changes: ===================================== rts/sm/NonMoving.h ===================================== @@ -73,11 +73,17 @@ struct NonmovingAllocator { // allocators cover block sizes of 2^NONMOVING_ALLOCA0 to // 2^(NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT) (in bytes) +// The largest allocator class must be at least LARGE_OBJECT_THRESHOLD in size +// as Storage.c:allocatePinned will allocate small pinned allocations into the +// non-moving heap. #define NONMOVING_ALLOCA_CNT 12 // maximum number of free segments to hold on to #define NONMOVING_MAX_FREE 16 +// block size of largest allocator in bytes. +#define NONMOVING_MAX_BLOCK_SZ (1 << (NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT)) + struct NonmovingHeap { struct NonmovingAllocator *allocators[NONMOVING_ALLOCA_CNT]; // free segment list. This is a cache where we keep up to ===================================== rts/sm/Storage.c ===================================== @@ -1165,6 +1165,21 @@ allocatePinned (Capability *cap, W_ n /*words*/, W_ alignment /*bytes*/, W_ alig const StgWord alignment_w = alignment / sizeof(W_); + // If the non-moving collector is enabled then we can allocate small, + // pinned allocations directly into the non-moving heap. This is a bit more + // expensive up-front but reduces fragmentation and is worthwhile since + // pinned allocations are often long-lived.. + if (RTS_UNLIKELY(RtsFlags.GcFlags.useNonmoving) + && n * WORD_SIZE + alignment_w <= NONMOVING_MAX_BLOCK_SZ) + { + p = nonmovingAllocate(cap, n + alignment_w); + W_ off_w = ALIGN_WITH_OFF_W(p, alignment, align_off); + MEMSET_IF_PROFILING_W(p, 0, off_w); + p += off_w; + MEMSET_IF_PROFILING_W(p + n, 0, alignment_w - off_w - 1); + return p; + } + // If the request is for a large object, then allocate() // will give us a pinned object anyway. if (n >= LARGE_OBJECT_THRESHOLD/sizeof(W_)) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/615373c20a9588a0a793e97e4eac0222d01532f8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/615373c20a9588a0a793e97e4eac0222d01532f8 You're receiving 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 Jul 26 20:03:20 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 26 Jul 2020 16:03:20 -0400 Subject: [Git][ghc/ghc][wip/gc/nonmoving-pinned] nonmoving: Teach allocatePinned() to allocate into nonmoving heap Message-ID: <5f1de188859bc_80b114037a45056162@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/gc/nonmoving-pinned at Glasgow Haskell Compiler / GHC Commits: d9f9efe7 by Ben Gamari at 2020-07-26T16:03:12-04:00 nonmoving: Teach allocatePinned() to allocate into nonmoving heap The allocatePinned() function is used to allocate pinned memory (e.g. for newPinnedByteArray#) - - - - - 2 changed files: - rts/sm/NonMoving.h - rts/sm/Storage.c Changes: ===================================== rts/sm/NonMoving.h ===================================== @@ -73,11 +73,17 @@ struct NonmovingAllocator { // allocators cover block sizes of 2^NONMOVING_ALLOCA0 to // 2^(NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT) (in bytes) +// The largest allocator class must be at least LARGE_OBJECT_THRESHOLD in size +// as Storage.c:allocatePinned will allocate small pinned allocations into the +// non-moving heap. #define NONMOVING_ALLOCA_CNT 12 // maximum number of free segments to hold on to #define NONMOVING_MAX_FREE 16 +// block size of largest allocator in bytes. +#define NONMOVING_MAX_BLOCK_SZ (1 << (NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT)) + struct NonmovingHeap { struct NonmovingAllocator *allocators[NONMOVING_ALLOCA_CNT]; // free segment list. This is a cache where we keep up to ===================================== rts/sm/Storage.c ===================================== @@ -1165,6 +1165,21 @@ allocatePinned (Capability *cap, W_ n /*words*/, W_ alignment /*bytes*/, W_ alig const StgWord alignment_w = alignment / sizeof(W_); + // If the non-moving collector is enabled then we can allocate small, + // pinned allocations directly into the non-moving heap. This is a bit more + // expensive up-front but reduces fragmentation and is worthwhile since + // pinned allocations are often long-lived.. + if (RTS_UNLIKELY(RtsFlags.GcFlags.useNonmoving) + && n * sizeof(W_) + alignment_w <= NONMOVING_MAX_BLOCK_SZ) + { + p = nonmovingAllocate(cap, n + alignment_w); + W_ off_w = ALIGN_WITH_OFF_W(p, alignment, align_off); + MEMSET_IF_PROFILING_W(p, 0, off_w); + p += off_w; + MEMSET_IF_PROFILING_W(p + n, 0, alignment_w - off_w - 1); + return p; + } + // If the request is for a large object, then allocate() // will give us a pinned object anyway. if (n >= LARGE_OBJECT_THRESHOLD/sizeof(W_)) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d9f9efe730c26dc5d3a5f6cba27142fb034e3d5a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d9f9efe730c26dc5d3a5f6cba27142fb034e3d5a You're receiving 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 Jul 26 20:10:16 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 26 Jul 2020 16:10:16 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/bump-bootstrap Message-ID: <5f1de32821579_80bd68a9b85056566@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/bump-bootstrap at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/bump-bootstrap You're receiving 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 Jul 26 21:02:31 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 26 Jul 2020 17:02:31 -0400 Subject: [Git][ghc/ghc][wip/gc/nonmoving-pinned] nonmoving: Teach allocatePinned() to allocate into nonmoving heap Message-ID: <5f1def673fead_80b3f84962c9cf050597dd@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/gc/nonmoving-pinned at Glasgow Haskell Compiler / GHC Commits: 5efe1dc9 by Ben Gamari at 2020-07-26T17:02:21-04:00 nonmoving: Teach allocatePinned() to allocate into nonmoving heap The allocatePinned() function is used to allocate pinned memory (e.g. for newPinnedByteArray#) - - - - - 5 changed files: - rts/sm/NonMoving.c - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c - rts/sm/NonMovingScav.c - rts/sm/Storage.c Changes: ===================================== rts/sm/NonMoving.c ===================================== @@ -474,6 +474,24 @@ Mutex concurrent_coll_finished_lock; * remembered set during the preparatory GC. This allows us to safely skip the * non-moving write barrier without jeopardizing the snapshot invariant. * + * + * Note [Allocating pinned objects into the non-moving heap] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * Under the moving collector small, pinned ByteArray#s are allocated by + * Storage.c:allocatePinned() into a per-capability accumulator block which is + * filled in a bump-pointer fashion. While this scheme is simple, it can lead + * to very poor fragmentation behavior as objects become unreachable: a single + * live ByteArray# can keep an entire block of memory alive. + * + * When the non-moving collector is in use we can do better by allocating small + * pinned objects directly into the non-moving heap. + * + * One wrinkle here is that pinned ByteArrays may have alignment requirements + * which requires that we insert padding zero-words before the beginning of the + * object. We must be certain to account for this padding when inspecting the + * object. + * */ memcount nonmoving_live_words = 0; ===================================== rts/sm/NonMoving.h ===================================== @@ -73,11 +73,17 @@ struct NonmovingAllocator { // allocators cover block sizes of 2^NONMOVING_ALLOCA0 to // 2^(NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT) (in bytes) +// The largest allocator class must be at least LARGE_OBJECT_THRESHOLD in size +// as Storage.c:allocatePinned will allocate small pinned allocations into the +// non-moving heap. #define NONMOVING_ALLOCA_CNT 12 // maximum number of free segments to hold on to #define NONMOVING_MAX_FREE 16 +// block size of largest allocator in bytes. +#define NONMOVING_MAX_BLOCK_SZ (1 << (NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT)) + struct NonmovingHeap { struct NonmovingAllocator *allocators[NONMOVING_ALLOCA_CNT]; // free segment list. This is a cache where we keep up to ===================================== rts/sm/NonMovingMark.c ===================================== @@ -1359,6 +1359,11 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) // Trace pointers ///////////////////////////////////////////////////// + // Find beginning of object. + // See Note [Allocating pinned objects into the non-moving heap]. + while (*(StgPtr*) q == NULL) + q = (StgClosure *) ((StgPtr*) q + 1); + const StgInfoTable *info = get_itbl(p); switch (info->type) { ===================================== rts/sm/NonMovingScav.c ===================================== @@ -11,9 +11,18 @@ #include "MarkWeak.h" // scavengeLiveWeak void -nonmovingScavengeOne (StgClosure *q) +nonmovingScavengeOne (StgClosure *q0) { + StgClosure *q = q0; + + // N.B. There may be a gap before the first word of the closure in the case + // of an aligned ByteArray# as allocated by allocatePinned(). + // See Note [Allocating pinned objects into the non-moving heap]. + while (*(StgPtr*) q == NULL) + q = (StgClosure *) ((StgPtr*) q + 1); + ASSERT(LOOKS_LIKE_CLOSURE_PTR(q)); + StgPtr p = (StgPtr)q; const StgInfoTable *info = get_itbl(q); const bool saved_eager_promotion = gct->eager_promotion; ===================================== rts/sm/Storage.c ===================================== @@ -1165,6 +1165,23 @@ allocatePinned (Capability *cap, W_ n /*words*/, W_ alignment /*bytes*/, W_ alig const StgWord alignment_w = alignment / sizeof(W_); + // If the non-moving collector is enabled then we can allocate small, + // pinned allocations directly into the non-moving heap. This is a bit more + // expensive up-front but reduces fragmentation and is worthwhile since + // pinned allocations are often long-lived.. + // + // See Note [Allocating pinned objects into the non-moving heap]. + if (RTS_UNLIKELY(RtsFlags.GcFlags.useNonmoving) + && n * sizeof(W_) + alignment_w <= NONMOVING_MAX_BLOCK_SZ) + { + p = nonmovingAllocate(cap, n + alignment_w); + W_ off_w = ALIGN_WITH_OFF_W(p, alignment, align_off); + MEMSET_IF_PROFILING_W(p, 0, off_w); + p += off_w; + MEMSET_IF_PROFILING_W(p + n, 0, alignment_w - off_w - 1); + return p; + } + // If the request is for a large object, then allocate() // will give us a pinned object anyway. if (n >= LARGE_OBJECT_THRESHOLD/sizeof(W_)) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5efe1dc9f0774fa78f6fe7fa4bb19bd59e7b187c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5efe1dc9f0774fa78f6fe7fa4bb19bd59e7b187c You're receiving 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 Jul 26 21:04:24 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 26 Jul 2020 17:04:24 -0400 Subject: [Git][ghc/ghc][wip/gc/nonmoving-pinned] nonmoving: Teach allocatePinned() to allocate into nonmoving heap Message-ID: <5f1defd88e29_80b1025102450601cb@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/gc/nonmoving-pinned at Glasgow Haskell Compiler / GHC Commits: 43b0bcf9 by Ben Gamari at 2020-07-26T17:04:16-04:00 nonmoving: Teach allocatePinned() to allocate into nonmoving heap The allocatePinned() function is used to allocate pinned memory (e.g. for newPinnedByteArray#) - - - - - 5 changed files: - rts/sm/NonMoving.c - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c - rts/sm/NonMovingScav.c - rts/sm/Storage.c Changes: ===================================== rts/sm/NonMoving.c ===================================== @@ -474,6 +474,24 @@ Mutex concurrent_coll_finished_lock; * remembered set during the preparatory GC. This allows us to safely skip the * non-moving write barrier without jeopardizing the snapshot invariant. * + * + * Note [Allocating pinned objects into the non-moving heap] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * Under the moving collector small, pinned ByteArray#s are allocated by + * Storage.c:allocatePinned() into a per-capability accumulator block which is + * filled in a bump-pointer fashion. While this scheme is simple, it can lead + * to very poor fragmentation behavior as objects become unreachable: a single + * live ByteArray# can keep an entire block of memory alive. + * + * When the non-moving collector is in use we can do better by allocating small + * pinned objects directly into the non-moving heap. + * + * One wrinkle here is that pinned ByteArrays may have alignment requirements + * which requires that we insert padding zero-words before the beginning of the + * object. We must be certain to account for this padding when inspecting the + * object. + * */ memcount nonmoving_live_words = 0; ===================================== rts/sm/NonMoving.h ===================================== @@ -73,11 +73,17 @@ struct NonmovingAllocator { // allocators cover block sizes of 2^NONMOVING_ALLOCA0 to // 2^(NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT) (in bytes) +// The largest allocator class must be at least LARGE_OBJECT_THRESHOLD in size +// as Storage.c:allocatePinned will allocate small pinned allocations into the +// non-moving heap. #define NONMOVING_ALLOCA_CNT 12 // maximum number of free segments to hold on to #define NONMOVING_MAX_FREE 16 +// block size of largest allocator in bytes. +#define NONMOVING_MAX_BLOCK_SZ (1 << (NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT)) + struct NonmovingHeap { struct NonmovingAllocator *allocators[NONMOVING_ALLOCA_CNT]; // free segment list. This is a cache where we keep up to ===================================== rts/sm/NonMovingMark.c ===================================== @@ -1359,6 +1359,11 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) // Trace pointers ///////////////////////////////////////////////////// + // Find beginning of object. + // See Note [Allocating pinned objects into the non-moving heap]. + while (*(StgPtr*) p == NULL) + p = (StgClosure *) ((StgPtr*) p + 1); + const StgInfoTable *info = get_itbl(p); switch (info->type) { ===================================== rts/sm/NonMovingScav.c ===================================== @@ -11,9 +11,18 @@ #include "MarkWeak.h" // scavengeLiveWeak void -nonmovingScavengeOne (StgClosure *q) +nonmovingScavengeOne (StgClosure *q0) { + StgClosure *q = q0; + + // N.B. There may be a gap before the first word of the closure in the case + // of an aligned ByteArray# as allocated by allocatePinned(). + // See Note [Allocating pinned objects into the non-moving heap]. + while (*(StgPtr*) q == NULL) + q = (StgClosure *) ((StgPtr*) q + 1); + ASSERT(LOOKS_LIKE_CLOSURE_PTR(q)); + StgPtr p = (StgPtr)q; const StgInfoTable *info = get_itbl(q); const bool saved_eager_promotion = gct->eager_promotion; ===================================== rts/sm/Storage.c ===================================== @@ -1165,6 +1165,23 @@ allocatePinned (Capability *cap, W_ n /*words*/, W_ alignment /*bytes*/, W_ alig const StgWord alignment_w = alignment / sizeof(W_); + // If the non-moving collector is enabled then we can allocate small, + // pinned allocations directly into the non-moving heap. This is a bit more + // expensive up-front but reduces fragmentation and is worthwhile since + // pinned allocations are often long-lived.. + // + // See Note [Allocating pinned objects into the non-moving heap]. + if (RTS_UNLIKELY(RtsFlags.GcFlags.useNonmoving) + && n * sizeof(W_) + alignment_w <= NONMOVING_MAX_BLOCK_SZ) + { + p = nonmovingAllocate(cap, n + alignment_w); + W_ off_w = ALIGN_WITH_OFF_W(p, alignment, align_off); + MEMSET_IF_PROFILING_W(p, 0, off_w); + p += off_w; + MEMSET_IF_PROFILING_W(p + n, 0, alignment_w - off_w - 1); + return p; + } + // If the request is for a large object, then allocate() // will give us a pinned object anyway. if (n >= LARGE_OBJECT_THRESHOLD/sizeof(W_)) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43b0bcf92bf1cf3708c140a2e5d9b98111ba5817 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43b0bcf92bf1cf3708c140a2e5d9b98111ba5817 You're receiving 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 Jul 27 03:16:11 2020 From: gitlab at gitlab.haskell.org (Josh Meredith) Date: Sun, 26 Jul 2020 23:16:11 -0400 Subject: [Git][ghc/ghc][wip/pluginExtFields] 9 commits: Document loadFramework changes. (#18446) Message-ID: <5f1e46fbd2a34_80b3f84901582f05076768@gitlab.haskell.org.mail> Josh Meredith pushed to branch wip/pluginExtFields at Glasgow Haskell Compiler / GHC Commits: a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - 945bee49 by Josh Meredith at 2020-07-26T23:16:08-04:00 Add machinery for plugins to write data to extensible interface fields - - - - - 13 changed files: - .gitlab/test-metrics.sh - CODEOWNERS - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Runtime/Linker.hs - libraries/base/cbits/IOutils.c - libraries/base/tests/IO/all.T - rts/PrimOps.cmm - rts/win32/OSMem.c - testsuite/driver/testlib.py - testsuite/tests/ghc-api/annotations/parseTree.stdout-mingw32 Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -81,6 +81,10 @@ function push() { echo "" echo "Failed to push git notes. Fetching, appending, and retrying... $MAX_RETRY retries left." done + + # Be sure to kill agent before we terminate since otherwise the Windows CI + # job won't finish. + ssh-agent -k } case $1 in @@ -88,3 +92,4 @@ case $1 in pull) pull ;; *) fail "Invalid mode $1" ;; esac + ===================================== CODEOWNERS ===================================== @@ -49,3 +49,18 @@ /utils/gen-dll/ @Phyx /utils/fs/ @Phyx +# WinIO related code +/libraries/base/GHC/Event/Windows/ @Phyx +/libraries/base/GHC/IO/Windows/ @Phyx +/rts/win32/ @Phyx +/libraries/base/GHC/IO/Handle/Lock/Windows.hsc @Phyx +/libraries/base/GHC/Event/Windows.hsc @Phyx +/libraries/base/GHC/Conc/WinIO.hs @Phyx +/libraries/base/GHC/Conc/Windows.hs @Phyx +/libraries/base/GHC/IO/Handle/Windows.hs @Phyx +/libraries/base/GHC/IO/StdHandles.hs @Phyx +/libraries/base/GHC/Windows.hs @Phyx +/libraries/base/cbits/IOutils.c @Phyx +/libraries/base/cbits/Win32Utils.c @Phyx +/libraries/base/cbits/consUtils.c @Phyx +/libraries/base/include/winio_structs.h @Phyx ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -198,6 +198,7 @@ newHscEnv dflags = do us <- mkSplitUniqSupply 'r' nc_var <- newIORef (initNameCache us knownKeyNames) fc_var <- newIORef emptyInstalledModuleEnv + ext_fs <- newIORef emptyExtensibleFields emptyDynLinker <- uninitializedLinker return HscEnv { hsc_dflags = dflags , hsc_targets = [] @@ -207,6 +208,7 @@ newHscEnv dflags = do , hsc_EPS = eps_var , hsc_NC = nc_var , hsc_FC = fc_var + , hsc_ext_fields = ext_fs , hsc_type_env_var = Nothing , hsc_interp = Nothing , hsc_dynLinker = emptyDynLinker @@ -810,11 +812,10 @@ finish summary tc_result mb_old_hash = do (cg_guts, details) <- {-# SCC "CoreTidy" #-} liftIO $ tidyProgram hsc_env simplified_guts - let !partial_iface = - {-# SCC "GHC.Driver.Main.mkPartialIface" #-} + !partial_iface <- {-# SCC "GHC.Driver.Main.mkPartialIface" #-} -- This `force` saves 2M residency in test T10370 -- See Note [Avoiding space leaks in toIface*] for details. - force (mkPartialIface hsc_env details simplified_guts) + liftIO $ force <$> (mkPartialIface hsc_env details simplified_guts) return HscRecomp { hscs_guts = cg_guts, hscs_mod_location = ms_location summary, ===================================== compiler/GHC/Driver/Types.hs ===================================== @@ -155,6 +155,7 @@ module GHC.Driver.Types ( readField, readIfaceField, readIfaceFieldWith, writeField, writeIfaceField, writeIfaceFieldWith, deleteField, deleteIfaceField, + registerInterfaceData, registerInterfaceDataWith, ) where #include "HsVersions.h" @@ -475,6 +476,10 @@ data HscEnv hsc_FC :: {-# UNPACK #-} !(IORef FinderCache), -- ^ The cached result of performing finding in the file system + hsc_ext_fields :: {-# UNPACK #-} !(IORef ExtensibleFields), + -- ^ Extensible interface field data stored by plugins to be later + -- output in the `.hi` file. + hsc_type_env_var :: Maybe (Module, IORef TypeEnv) -- ^ Used for one-shot compilation only, to initialise -- the 'IfGblEnv'. See 'GHC.Tc.Utils.tcg_type_env_var' for @@ -3404,3 +3409,12 @@ deleteField name (ExtensibleFields fs) = ExtensibleFields $ Map.delete name fs deleteIfaceField :: FieldName -> ModIface -> ModIface deleteIfaceField name iface = iface { mi_ext_fields = deleteField name (mi_ext_fields iface) } + +registerInterfaceData :: Binary a => FieldName -> HscEnv -> a -> IO () +registerInterfaceData name env x = registerInterfaceDataWith name env (`put_` x) + +registerInterfaceDataWith :: FieldName -> HscEnv -> (BinHandle -> IO ()) -> IO () +registerInterfaceDataWith name env write = do + ext_fs <- readIORef (hsc_ext_fields env) + ext_fs' <- writeFieldWith name write ext_fs + writeIORef (hsc_ext_fields env) ext_fs' ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -81,7 +81,7 @@ import GHC.Driver.Plugins (LoadedPlugin(..)) mkPartialIface :: HscEnv -> ModDetails -> ModGuts - -> PartialModIface + -> IO PartialModIface mkPartialIface hsc_env mod_details ModGuts{ mg_module = this_mod , mg_hsc_src = hsc_src @@ -98,8 +98,11 @@ mkPartialIface hsc_env mod_details , mg_decl_docs = decl_docs , mg_arg_docs = arg_docs } - = mkIface_ hsc_env this_mod hsc_src used_th deps rdr_env fix_env warns hpc_info self_trust - safe_mode usages doc_hdr decl_docs arg_docs mod_details + = do ext_fs <- readIORef $ hsc_ext_fields hsc_env + return iface{mi_ext_fields = ext_fs} + where + iface = mkIface_ hsc_env this_mod hsc_src used_th deps rdr_env fix_env warns hpc_info self_trust + safe_mode usages doc_hdr decl_docs arg_docs mod_details -- | Fully instantiate an interface. Adds fingerprints and potentially code -- generator produced information. ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -20,7 +20,9 @@ module GHC.IfaceToCore ( tcIfaceAnnotations, tcIfaceCompleteSigs, tcIfaceExpr, -- Desired by HERMIT (#7683) tcIfaceGlobal, - tcIfaceOneShot + tcIfaceOneShot, + tcIfaceType, + tcJoinInfo, ) where #include "HsVersions.h" ===================================== compiler/GHC/Runtime/Linker.hs ===================================== @@ -1695,6 +1695,38 @@ addEnvPaths name list -- ---------------------------------------------------------------------------- -- Loading a dynamic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32) +{- +Note [macOS Big Sur dynamic libraries] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +macOS Big Sur makes the following change to how frameworks are shipped +with the OS: + +> New in macOS Big Sur 11 beta, the system ships with a built-in +> dynamic linker cache of all system-provided libraries. As part of +> this change, copies of dynamic libraries are no longer present on +> the filesystem. Code that attempts to check for dynamic library +> presence by looking for a file at a path or enumerating a directory +> will fail. Instead, check for library presence by attempting to +> dlopen() the path, which will correctly check for the library in the +> cache. (62986286) + +(https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/) + +Therefore, the previous method of checking whether a library exists +before attempting to load it makes GHC.Runtime.Linker.loadFramework +fail to find frameworks installed at /System/Library/Frameworks. +Instead, any attempt to load a framework at runtime, such as by +passing -framework OpenGL to runghc or running code loading such a +framework with GHCi, fails with a 'not found' message. + +GHC.Runtime.Linker.loadFramework now opportunistically loads the +framework libraries without checking for their existence first, +failing only if all attempts to load a given framework from any of the +various possible locations fail. See also #18446, which this change +addresses. +-} + -- Darwin / MacOS X only: load a framework -- a framework is a dynamic library packaged inside a directory of the same -- name. They are searched for in different paths than normal libraries. @@ -1714,6 +1746,9 @@ loadFramework hsc_env extraPaths rootname -- sorry for the hardcoded paths, I hope they won't change anytime soon: defaultFrameworkPaths = ["/Library/Frameworks", "/System/Library/Frameworks"] + -- Try to call loadDLL for each candidate path. + -- + -- See Note [macOS Big Sur dynamic libraries] findLoadDLL [] errs = -- Tried all our known library paths, but dlopen() -- has no built-in paths for frameworks: give up ===================================== libraries/base/cbits/IOutils.c ===================================== @@ -209,8 +209,8 @@ __is_console(HANDLE hFile) DWORD handleType = GetFileType (hFile); /* TTY must be a character device */ - if (handleType == FILE_TYPE_CHAR) - return true; + if (handleType != FILE_TYPE_CHAR) + return false; DWORD st; /* GetConsoleMode appears to fail when it's not a TTY. In ===================================== libraries/base/tests/IO/all.T ===================================== @@ -10,7 +10,7 @@ test('IOError001', [omit_ways(['ghci']), set_stdin('IOError001.hs')], test('IOError002', normal, compile_and_run, ['']) test('finalization001', normal, compile_and_run, ['']) test('hClose001', [], compile_and_run, ['']) -test('hClose002', [], compile_and_run, ['']) +test('hClose002', [normalise_win32_io_errors], compile_and_run, ['']) test('hClose003', reqlib('unix'), compile_and_run, ['-package unix']) test('hFileSize001', normal, compile_and_run, ['']) test('hFileSize002', [omit_ways(['ghci'])], compile_and_run, ['']) @@ -61,8 +61,8 @@ test('misc001', [extra_run_opts('misc001.hs misc001.out')], compile_and_run, ['']) test('openFile001', normal, compile_and_run, ['']) -test('openFile002', exit_code(1), compile_and_run, ['']) -test('openFile003', [], compile_and_run, ['']) +test('openFile002', [exit_code(1), normalise_win32_io_errors], compile_and_run, ['']) +test('openFile003', [normalise_win32_io_errors], compile_and_run, ['']) test('openFile004', [], compile_and_run, ['']) test('openFile005', [], compile_and_run, ['']) test('openFile006', [], compile_and_run, ['']) ===================================== rts/PrimOps.cmm ===================================== @@ -2221,7 +2221,7 @@ loop: IOPort primitives -------------------------------------------------------------------------- */ -stg_newIOPortzh ( gcptr init ) +stg_newIOPortzh () { W_ ioport; ===================================== rts/win32/OSMem.c ===================================== @@ -472,7 +472,7 @@ void osCommitMemory (void *at, W_ size) temp = VirtualAlloc(at, size, MEM_COMMIT, PAGE_READWRITE); if (temp == NULL) { sysErrorBelch("osCommitMemory: VirtualAlloc MEM_COMMIT failed"); - stg_exit(EXIT_FAILURE); + stg_exit(EXIT_HEAPOVERFLOW); } } ===================================== testsuite/driver/testlib.py ===================================== @@ -743,6 +743,30 @@ def normalise_whitespace_fun(f): def _normalise_whitespace_fun(name, opts, f): opts.whitespace_normaliser = f +def normalise_win32_io_errors(name, opts): + """ + On Windows we currently have two IO manager implementations: both WinIO IO + manager and the old POSIX-emulated implementation. These currently differ + slightly in the error messages that they provide. Normalise these + differences away, preferring the new WinIO errors. + + This can be dropped when the old IO manager is removed. + """ + + SUBS = [ + ('Bad file descriptor', 'The handle is invalid'), + ('Permission denied', 'Access is denied.'), + ('No such file or directory', 'The system cannot find the file specified.'), + ] + + def f(s: str): + for old,new in SUBS: + s = s.replace(old, new) + + return s + + return when(opsys('mingw32'), normalise_fun(f)) + def normalise_version_( *pkgs ): def normalise_version__( str ): return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+', ===================================== testsuite/tests/ghc-api/annotations/parseTree.stdout-mingw32 ===================================== @@ -1,11 +1,11 @@ -[(AnnotationTuple.hs:14:20, [p], Unit 1), - (AnnotationTuple.hs:14:23-29, [p], Unit "hello"), - (AnnotationTuple.hs:14:35-37, [p], Unit 6.5), +[(AnnotationTuple.hs:14:20, [p], Solo 1), + (AnnotationTuple.hs:14:23-29, [p], Solo "hello"), + (AnnotationTuple.hs:14:35-37, [p], Solo 6.5), (AnnotationTuple.hs:14:39, [m], ()), - (AnnotationTuple.hs:14:41-52, [p], Unit [5, 5, 6, 7]), - (AnnotationTuple.hs:16:8, [p], Unit 1), - (AnnotationTuple.hs:16:11-17, [p], Unit "hello"), - (AnnotationTuple.hs:16:20-22, [p], Unit 6.5), + (AnnotationTuple.hs:14:41-52, [p], Solo [5, 5, 6, 7]), + (AnnotationTuple.hs:16:8, [p], Solo 1), + (AnnotationTuple.hs:16:11-17, [p], Solo "hello"), + (AnnotationTuple.hs:16:20-22, [p], Solo 6.5), (AnnotationTuple.hs:16:24, [m], ()), (AnnotationTuple.hs:16:25, [m], ()), (AnnotationTuple.hs:16:26, [m], ()), (, [m], ())] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de64ec94d02cbd92c9d96280082c82a342ec1526...945bee49b0b4f0d4ee95c5dde31c630ee445f3a3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de64ec94d02cbd92c9d96280082c82a342ec1526...945bee49b0b4f0d4ee95c5dde31c630ee445f3a3 You're receiving 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 Jul 27 03:16:53 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 26 Jul 2020 23:16:53 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Improve NegativeLiterals (#18022, GHC Proposal #344) Message-ID: <5f1e47258eb58_80b8d8e570507874d@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5b4de7d5 by Vladislav Zavialov at 2020-07-26T23:16:47-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 4ce89549 by leiftw at 2020-07-26T23:16:49-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 76ab8756 by Vladislav Zavialov at 2020-07-26T23:16:49-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - 10 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - docs/users_guide/8.12.1-notes.rst - docs/users_guide/exts/negative_literals.rst - docs/users_guide/separate_compilation.rst - − testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/NegativeLiterals.hs - + testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs - testsuite/tests/parser/should_compile/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1884,9 +1884,9 @@ sigtypes1 :: { (OrdList (LHsSigType GhcPs)) } ----------------------------------------------------------------------------- -- Types -unpackedness :: { Located ([AddAnn], SourceText, SrcUnpackedness) } - : '{-# UNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getUNPACK_PRAGs $1, SrcUnpack) } - | '{-# NOUNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getNOUNPACK_PRAGs $1, SrcNoUnpack) } +unpackedness :: { Located UnpackednessPragma } + : '{-# UNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getUNPACK_PRAGs $1) SrcUnpack) } + | '{-# NOUNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getNOUNPACK_PRAGs $1) SrcNoUnpack) } forall_telescope :: { Located ([AddAnn], HsForAllTelescope GhcPs) } : 'forall' tv_bndrs '.' {% do { hintExplicitForall $1 @@ -1980,13 +1980,16 @@ tyapp :: { Located TyEl } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | PREFIX_AT atype { sLL $1 $> $ (TyElKindApp (comb2 $1 $2) $2) } - | qtyconop { sL1 $1 $ TyElOpr (unLoc $1) } - | tyvarop { sL1 $1 $ TyElOpr (unLoc $1) } - | SIMPLEQUOTE qconop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | tyop { mapLoc TyElOpr $1 } + | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } + +tyop :: { Located RdrName } + : qtyconop { $1 } + | tyvarop { $1 } + | SIMPLEQUOTE qconop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | SIMPLEQUOTE varop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | SIMPLEQUOTE varop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } atype :: { LHsType GhcPs } : ntgtycon { sL1 $1 (HsTyVar noExtField NotPromoted $1) } -- Not including unit tuples ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -199,7 +199,6 @@ $docsym = [\| \^ \* \$] -- normal signed numerical literals can only be explicitly negative, -- not explicitly positive (contrast @exponent) @negative = \- - at signed = @negative ? -- ----------------------------------------------------------------------------- @@ -531,12 +530,12 @@ $tab { warnTab } ifExtension BinaryLiteralsBit } { tok_primint positive 2 3 binary } 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 octal } 0[xX] @numspc @hexadecimal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 hexadecimal } - @negative @decimal \# / { ifExtension MagicHashBit } { tok_primint negative 1 2 decimal } - @negative 0[bB] @numspc @binary \# / { ifExtension MagicHashBit `alexAndPred` + @negative @decimal \# / { negHashLitPred } { tok_primint negative 1 2 decimal } + @negative 0[bB] @numspc @binary \# / { negHashLitPred `alexAndPred` ifExtension BinaryLiteralsBit } { tok_primint negative 3 4 binary } - @negative 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint negative 3 4 octal } + @negative 0[oO] @numspc @octal \# / { negHashLitPred } { tok_primint negative 3 4 octal } @negative 0[xX] @numspc @hexadecimal \# - / { ifExtension MagicHashBit } { tok_primint negative 3 4 hexadecimal } + / { negHashLitPred } { tok_primint negative 3 4 hexadecimal } @decimal \# \# / { ifExtension MagicHashBit } { tok_primword 0 2 decimal } 0[bB] @numspc @binary \# \# / { ifExtension MagicHashBit `alexAndPred` @@ -546,8 +545,11 @@ $tab { warnTab } -- Unboxed floats and doubles (:: Float#, :: Double#) -- prim_{float,double} work with signed literals - @signed @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } - @signed @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } + @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + + @negative @floating_point \# / { negHashLitPred } { tok_frac 1 tok_primfloat } + @negative @floating_point \# \# / { negHashLitPred } { tok_frac 2 tok_primdouble } } -- Strings and chars are lexed by hand-written code. The reason is @@ -1192,8 +1194,8 @@ atEOL _ _ _ (AI _ buf) = atEnd buf || currentChar buf == '\n' -- Check if we should parse a negative literal (e.g. -123) as a single token. negLitPred :: AlexAccPred ExtsBitmap negLitPred = - negative_literals `alexOrPred` - (lexical_negation `alexAndPred` prefix_minus) + prefix_minus `alexAndPred` + (negative_literals `alexOrPred` lexical_negation) where negative_literals = ifExtension NegativeLiteralsBit @@ -1202,14 +1204,33 @@ negLitPred = alexNotPred (ifExtension NoLexicalNegationBit) prefix_minus = - -- The condition for a prefix occurrence of an operator is: - -- - -- not precededByClosingToken && followedByOpeningToken - -- - -- but we don't check followedByOpeningToken here as it holds - -- simply because we immediately lex a literal after the minus. + -- Note [prefix_minus in negLitPred and negHashLitPred] + alexNotPred precededByClosingToken + +-- Check if we should parse an unboxed negative literal (e.g. -123#) as a single token. +negHashLitPred :: AlexAccPred ExtsBitmap +negHashLitPred = prefix_minus `alexAndPred` magic_hash + where + magic_hash = ifExtension MagicHashBit + prefix_minus = + -- Note [prefix_minus in negLitPred and negHashLitPred] alexNotPred precededByClosingToken +{- Note [prefix_minus in negLitPred and negHashLitPred] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We want to parse -1 as a single token, but x-1 as three tokens. +So in negLitPred (and negHashLitPred) we require that we have a prefix +occurrence of the minus sign. See Note [Whitespace-sensitive operator parsing] +for a detailed definition of a prefix occurrence. + +The condition for a prefix occurrence of an operator is: + + not precededByClosingToken && followedByOpeningToken + +but we don't check followedByOpeningToken when parsing a negative literal. +It holds simply because we immediately lex a literal after the minus. +-} + ifExtension :: ExtBits -> AlexAccPred ExtsBitmap ifExtension extBits bits _ _ _ = extBits `xtest` bits ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -70,6 +70,7 @@ module GHC.Parser.PostProcess ( addFatalError, hintBangPat, TyEl(..), mergeOps, mergeDataCon, mkBangTy, + UnpackednessPragma(..), -- Help with processing exports ImpExpSubSpec(..), @@ -559,25 +560,6 @@ As the result, in order to determine whether (C t1 t2) declares a data constructor, a type, or a context, we would need unlimited lookahead which 'happy' is not so happy with. -To further complicate matters, the interpretation of (!) and (~) is different -in constructors and types: - - (b1) type T = C ! D - (b2) data T = C ! D - (b3) data T = C ! D => E - -In (b1) and (b3), (!) is a type operator with two arguments: 'C' and 'D'. At -the same time, in (b2) it is a strictness annotation: 'C' is a data constructor -with a single strict argument 'D'. For the programmer, these cases are usually -easy to tell apart due to whitespace conventions: - - (b2) data T = C !D -- no space after the bang hints that - -- it is a strictness annotation - -For the parser, on the other hand, this whitespace does not matter. We cannot -tell apart (b2) from (b3) until we encounter (=>), so it requires unlimited -lookahead. - The solution that accounts for all of these issues is to initially parse data declarations and types as a reversed list of TyEl: @@ -1324,7 +1306,7 @@ isFunLhs e = go e [] [] data TyEl = TyElOpr RdrName | TyElOpd (HsType GhcPs) | TyElKindApp SrcSpan (LHsType GhcPs) -- See Note [TyElKindApp SrcSpan interpretation] - | TyElUnpackedness ([AddAnn], SourceText, SrcUnpackedness) + | TyElUnpackedness UnpackednessPragma {- Note [TyElKindApp SrcSpan interpretation] @@ -1345,20 +1327,15 @@ instance Outputable TyEl where ppr (TyElOpr name) = ppr name ppr (TyElOpd ty) = ppr ty ppr (TyElKindApp _ ki) = text "@" <> ppr ki - ppr (TyElUnpackedness (_, _, unpk)) = ppr unpk + ppr (TyElUnpackedness (UnpackednessPragma _ _ unpk)) = ppr unpk -- | Extract a strictness/unpackedness annotation from the front of a reversed -- 'TyEl' list. pUnpackedness :: [Located TyEl] -- reversed TyEl - -> Maybe ( SrcSpan - , [AddAnn] - , SourceText - , SrcUnpackedness - , [Located TyEl] {- remaining TyEl -}) -pUnpackedness (L l x1 : xs) - | TyElUnpackedness (anns, prag, unpk) <- x1 - = Just (l, anns, prag, unpk, xs) + -> Maybe (SrcSpan, UnpackednessPragma, + [Located TyEl] {- remaining TyEl -}) +pUnpackedness (L l x1 : xs) | TyElUnpackedness up <- x1 = Just (l, up, xs) pUnpackedness _ = Nothing pBangTy @@ -1371,7 +1348,7 @@ pBangTy pBangTy lt@(L l1 _) xs = case pUnpackedness xs of Nothing -> (False, lt, pure (), xs) - Just (l2, anns, prag, unpk, xs') -> + Just (l2, UnpackednessPragma anns prag unpk, xs') -> let bl = combineSrcSpans l1 l2 bt = addUnpackedness (prag, unpk) lt in (True, L bl bt, addAnnsAt bl anns, xs') @@ -1380,6 +1357,10 @@ mkBangTy :: SrcStrictness -> LHsType GhcPs -> HsType GhcPs mkBangTy strictness = HsBangTy noExtField (HsSrcBang NoSourceText NoSrcUnpack strictness) +-- Result of parsing {-# UNPACK #-} or {-# NOUNPACK #-} +data UnpackednessPragma = + UnpackednessPragma [AddAnn] SourceText SrcUnpackedness + addUnpackedness :: (SourceText, SrcUnpackedness) -> LHsType GhcPs -> HsType GhcPs addUnpackedness (prag, unpk) (L _ (HsBangTy x bang t)) | HsSrcBang NoSourceText NoSrcUnpack strictness <- bang @@ -1411,7 +1392,7 @@ mergeOps all_xs = go (0 :: Int) [] id all_xs -- clause [unpk]: -- handle (NO)UNPACK pragmas - go k acc ops_acc ((L l (TyElUnpackedness (anns, unpkSrc, unpk))):xs) = + go k acc ops_acc ((L l (TyElUnpackedness (UnpackednessPragma anns unpkSrc unpk))):xs) = if not (null acc) && null xs then do { acc' <- eitherToP $ mergeOpsAcc acc ; let a = ops_acc acc' ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -224,6 +224,13 @@ Language f = (- x) -- operator section c = (-x) -- negation +* The behavior of :extension:`NegativeLiterals` changed, and now we require + that a negative literal must not be preceded by a closing token (see + `GHC Proposal #229 `__ + for the definition of a closing token). In other words, we parse ``f -123`` + as ``f (-123)``, but ``x-123`` as ``(-) x 123``. Before this amendment, + :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/negative_literals.rst ===================================== @@ -24,9 +24,11 @@ will elicit an unexpected integer-literal-overflow message. Whitespace can be inserted, as in ``- 123``, to force interpretation as two tokens. -One pitfall is that with :extension:`NegativeLiterals`, ``x-1`` will -be parsed as ``x`` applied to the argument ``-1``, which is usually -not what you want. ``x - 1`` or even ``x- 1`` can be used instead -for subtraction. To avoid this, consider using :extension:`LexicalNegation` -instead. - +In 8.12, the behavior of this extension changed, and now we require that a negative literal must not be preceded by a closing token (see +`GHC Proposal #229 `__ +for the definition of a closing token). In other words, we parse ``f -123`` as ``f (-123)``, but ``x-123`` as ``(-) x +123``. Before this amendment, :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + +:extension:`NegativeLiterals` is a subset of :extension:`LexicalNegation`. That +is, enabling both of those extensions has the same effect as enabling +:extension:`LexicalNegation` alone. ===================================== docs/users_guide/separate_compilation.rst ===================================== @@ -758,7 +758,7 @@ There are several points to note here: the same machine-generated binary format as any other GHC-generated interface file (e.g. ``B.hi``). You can display its contents with ``ghc --show-iface``. If you specify a directory for - interface files, the ``-ohidir`` flag, then that affects ``hi-boot`` files + interface files, the ``-hidir`` flag, then that affects ``hi-boot`` files too. - If hs-boot files are considered distinct from their parent source ===================================== testsuite/tests/parser/should_compile/LexNegVsNegLit.hs deleted ===================================== @@ -1,17 +0,0 @@ -{-# LANGUAGE NegativeLiterals, LexicalNegation #-} - -module LexNegVsNegLit where - --- NegativeLiterals specifies that we parse x-1 as x (-1), even though it's --- considered a shortcoming. --- --- LexicalNegation does not change that. --- -b :: Bool -b = even-1 -- parsed as: even (-1) - -- so it is well-typed. - -- - -- with LexicalNegation alone, we'd get (-) even 1, - -- but NegativeLiterals takes precedence here. - --- See also: GHC Proposal #344 ===================================== testsuite/tests/parser/should_compile/NegativeLiterals.hs ===================================== @@ -0,0 +1,57 @@ +{-# LANGUAGE NegativeLiterals, MagicHash, BinaryLiterals #-} + +module NegativeLiterals where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p1 :: Bool +p1 = even -2 -- parsed as: even (-2) + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p3 :: Int +p3 = floor -2.4 -- parsed as: floor (-2.4) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +p6 :: Bool +p6 = even -0b10 -- parsed as: even (-2) + || even -0o10 -- parsed as: even (-8) + || even -0x10 -- parsed as: even (-16) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti1 :: Integer -> Integer +ti1 x = x-2 -- parsed as: (-) x 1 + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) + +ti6 :: Integer -> [Integer] +ti6 x = + [ x-0b10, -- parsed as: (-) x 2 + x-0o10, -- parsed as: (-) x 8 + x-0x10 ] -- parsed as: (-) x 16 ===================================== testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs ===================================== @@ -0,0 +1,39 @@ +{-# LANGUAGE NoNegativeLiterals, MagicHash, BinaryLiterals #-} + +-- Even when NegativeLiterals are disabled, +-- we parse unboxed literals appropriately. +module NegativeLiteralsNoExt where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -153,7 +153,8 @@ test('proposal-229b', normal, compile, ['']) test('proposal-229d', normal, compile, ['']) test('proposal-229e', normal, compile, ['']) test('LexicalNegation', normal, compile, ['']) -test('LexNegVsNegLit', normal, compile, ['']) +test('NegativeLiterals', normal, compile, ['']) +test('NegativeLiteralsNoExt', normal, compile, ['']) # We omit 'profasm' because it fails with: # Cannot load -prof objects when GHC is built with -dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb0bb4cbbac3cb21ebb028ed13a383c8f963ca12...76ab87569d99ceca65f655c38b4452fb94979428 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb0bb4cbbac3cb21ebb028ed13a383c8f963ca12...76ab87569d99ceca65f655c38b4452fb94979428 You're receiving 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 Jul 27 07:50:42 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 27 Jul 2020 03:50:42 -0400 Subject: [Git][ghc/ghc][wip/T13253] This patch addresses the exponential blow-up in the simplifier. Message-ID: <5f1e87527da0f_80b3f849248fe0851882ce@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC Commits: 8d686760 by Simon Peyton Jones at 2020-07-27T08:48:11+01:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 30 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T10421a.hs - + testsuite/tests/perf/compiler/T13253-spj.hs - + testsuite/tests/perf/compiler/T13253.hs - + testsuite/tests/perf/compiler/T18140.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T15631.stdout - testsuite/tests/simplCore/should_compile/T17901.stdout - testsuite/tests/simplCore/should_compile/T18355.stderr - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4908.stderr - testsuite/tests/simplCore/should_compile/T4930.stderr - testsuite/tests/simplCore/should_compile/T5366.stdout - testsuite/tests/simplCore/should_compile/T7360.stderr - testsuite/tests/simplCore/should_compile/T7865.stdout The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d686760f96574476101ed458709e72950599751 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d686760f96574476101ed458709e72950599751 You're receiving 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 Jul 27 08:16:14 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 27 Jul 2020 04:16:14 -0400 Subject: [Git][ghc/ghc][wip/T18494] 24 commits: winio: restore console cp on exit Message-ID: <5f1e8d4e6a0b1_80b8d8e57051972a7@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18494 at Glasgow Haskell Compiler / GHC Commits: cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - b31c478d by Simon Peyton Jones at 2020-07-27T09:15:54+01:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - 30 changed files: - .gitlab/test-metrics.sh - CODEOWNERS - compiler/GHC.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Plugins.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e3a0d55c0eba5d53c89a0eb9f021b2f4e55384e...b31c478d416a1abffb89104f00c7dc5f5d0b607f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e3a0d55c0eba5d53c89a0eb9f021b2f4e55384e...b31c478d416a1abffb89104f00c7dc5f5d0b607f You're receiving 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 Jul 27 09:05:08 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 27 Jul 2020 05:05:08 -0400 Subject: [Git][ghc/ghc][wip/T13253] This patch addresses the exponential blow-up in the simplifier. Message-ID: <5f1e98c473edc_80b8d8e5705204581@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC Commits: d738eb62 by Simon Peyton Jones at 2020-07-27T10:04:32+01:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 30 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T10421a.hs - + testsuite/tests/perf/compiler/T13253-spj.hs - + testsuite/tests/perf/compiler/T13253.hs - + testsuite/tests/perf/compiler/T18140.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T15631.stdout - testsuite/tests/simplCore/should_compile/T17901.stdout - testsuite/tests/simplCore/should_compile/T18355.stderr - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4908.stderr - testsuite/tests/simplCore/should_compile/T4930.stderr - testsuite/tests/simplCore/should_compile/T5366.stdout - testsuite/tests/simplCore/should_compile/T7360.stderr - testsuite/tests/simplCore/should_compile/T7865.stdout The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d738eb62e987fb3179756010e3ce6d4016e70f09 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d738eb62e987fb3179756010e3ce6d4016e70f09 You're receiving 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 Jul 27 09:42:06 2020 From: gitlab at gitlab.haskell.org (Josh Meredith) Date: Mon, 27 Jul 2020 05:42:06 -0400 Subject: [Git][ghc/ghc][wip/pluginExtFields] Add function to remove plugin interface fields Message-ID: <5f1ea16ebfb00_80b3f849248fe085215088@gitlab.haskell.org.mail> Josh Meredith pushed to branch wip/pluginExtFields at Glasgow Haskell Compiler / GHC Commits: 20d97fb0 by Josh Meredith at 2020-07-27T19:41:57+10:00 Add function to remove plugin interface fields - - - - - 1 changed file: - compiler/GHC/Driver/Types.hs Changes: ===================================== compiler/GHC/Driver/Types.hs ===================================== @@ -156,6 +156,7 @@ module GHC.Driver.Types ( writeField, writeIfaceField, writeIfaceFieldWith, deleteField, deleteIfaceField, registerInterfaceData, registerInterfaceDataWith, + unregisterInterfaceData, ) where #include "HsVersions.h" @@ -3418,3 +3419,8 @@ registerInterfaceDataWith name env write = do ext_fs <- readIORef (hsc_ext_fields env) ext_fs' <- writeFieldWith name write ext_fs writeIORef (hsc_ext_fields env) ext_fs' + +unregisterInterfaceData :: FieldName -> HscEnv -> IO () +unregisterInterfaceData name env = do + ext_fs <- readIORef (hsc_ext_fields env) + writeIORef (hsc_ext_fields env) (deleteField name ext_fs) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/20d97fb0246043acd44018aaf1d6423c6300e7a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/20d97fb0246043acd44018aaf1d6423c6300e7a5 You're receiving 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 Jul 27 10:17:41 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 27 Jul 2020 06:17:41 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18502 Message-ID: <5f1ea9c5ea7d7_80b8d8e5705222129@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T18502 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18502 You're receiving 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 Jul 27 10:30:41 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 27 Jul 2020 06:30:41 -0400 Subject: [Git][ghc/ghc][wip/spj-wibbles] 48 commits: Fix dead link to haskell prime discussion Message-ID: <5f1eacd182b71_80b3f84868c38285224937@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/spj-wibbles at Glasgow Haskell Compiler / GHC Commits: 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - b87eb02b by Simon Peyton Jones at 2020-07-27T11:30:22+01:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 30 changed files: - .gitlab/test-metrics.sh - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a81a9a729f9d18d2576d4026ff955fce1253dbd2...b87eb02be35440dfc941e5e9a12dbcc01849e6d3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a81a9a729f9d18d2576d4026ff955fce1253dbd2...b87eb02be35440dfc941e5e9a12dbcc01849e6d3 You're receiving 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 Jul 27 10:42:19 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 27 Jul 2020 06:42:19 -0400 Subject: [Git][ghc/ghc][wip/T13253] This patch addresses the exponential blow-up in the simplifier. Message-ID: <5f1eaf8be9517_80b3f84962c9cf05227924@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC Commits: 3f65f1e0 by Simon Peyton Jones at 2020-07-27T11:41:45+01:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 30 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T10421a.hs - + testsuite/tests/perf/compiler/T10421a_Form.hs - + testsuite/tests/perf/compiler/T13253-spj.hs - + testsuite/tests/perf/compiler/T13253.hs - + testsuite/tests/perf/compiler/T18140.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T15631.stdout - testsuite/tests/simplCore/should_compile/T17901.stdout - testsuite/tests/simplCore/should_compile/T18355.stderr - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4908.stderr - testsuite/tests/simplCore/should_compile/T4930.stderr - testsuite/tests/simplCore/should_compile/T5366.stdout - testsuite/tests/simplCore/should_compile/T7360.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f65f1e043d9f603dd729026e09bcea7873af1bb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f65f1e043d9f603dd729026e09bcea7873af1bb You're receiving 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 Jul 27 11:07:02 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 27 Jul 2020 07:07:02 -0400 Subject: [Git][ghc/ghc][master] Improve NegativeLiterals (#18022, GHC Proposal #344) Message-ID: <5f1eb5563f004_80bd68a9b8523223b@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 7 changed files: - compiler/GHC/Parser/Lexer.x - docs/users_guide/8.12.1-notes.rst - docs/users_guide/exts/negative_literals.rst - − testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/NegativeLiterals.hs - + testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs - testsuite/tests/parser/should_compile/all.T Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -199,7 +199,6 @@ $docsym = [\| \^ \* \$] -- normal signed numerical literals can only be explicitly negative, -- not explicitly positive (contrast @exponent) @negative = \- - at signed = @negative ? -- ----------------------------------------------------------------------------- @@ -531,12 +530,12 @@ $tab { warnTab } ifExtension BinaryLiteralsBit } { tok_primint positive 2 3 binary } 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 octal } 0[xX] @numspc @hexadecimal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 hexadecimal } - @negative @decimal \# / { ifExtension MagicHashBit } { tok_primint negative 1 2 decimal } - @negative 0[bB] @numspc @binary \# / { ifExtension MagicHashBit `alexAndPred` + @negative @decimal \# / { negHashLitPred } { tok_primint negative 1 2 decimal } + @negative 0[bB] @numspc @binary \# / { negHashLitPred `alexAndPred` ifExtension BinaryLiteralsBit } { tok_primint negative 3 4 binary } - @negative 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint negative 3 4 octal } + @negative 0[oO] @numspc @octal \# / { negHashLitPred } { tok_primint negative 3 4 octal } @negative 0[xX] @numspc @hexadecimal \# - / { ifExtension MagicHashBit } { tok_primint negative 3 4 hexadecimal } + / { negHashLitPred } { tok_primint negative 3 4 hexadecimal } @decimal \# \# / { ifExtension MagicHashBit } { tok_primword 0 2 decimal } 0[bB] @numspc @binary \# \# / { ifExtension MagicHashBit `alexAndPred` @@ -546,8 +545,11 @@ $tab { warnTab } -- Unboxed floats and doubles (:: Float#, :: Double#) -- prim_{float,double} work with signed literals - @signed @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } - @signed @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } + @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + + @negative @floating_point \# / { negHashLitPred } { tok_frac 1 tok_primfloat } + @negative @floating_point \# \# / { negHashLitPred } { tok_frac 2 tok_primdouble } } -- Strings and chars are lexed by hand-written code. The reason is @@ -1192,8 +1194,8 @@ atEOL _ _ _ (AI _ buf) = atEnd buf || currentChar buf == '\n' -- Check if we should parse a negative literal (e.g. -123) as a single token. negLitPred :: AlexAccPred ExtsBitmap negLitPred = - negative_literals `alexOrPred` - (lexical_negation `alexAndPred` prefix_minus) + prefix_minus `alexAndPred` + (negative_literals `alexOrPred` lexical_negation) where negative_literals = ifExtension NegativeLiteralsBit @@ -1202,14 +1204,33 @@ negLitPred = alexNotPred (ifExtension NoLexicalNegationBit) prefix_minus = - -- The condition for a prefix occurrence of an operator is: - -- - -- not precededByClosingToken && followedByOpeningToken - -- - -- but we don't check followedByOpeningToken here as it holds - -- simply because we immediately lex a literal after the minus. + -- Note [prefix_minus in negLitPred and negHashLitPred] + alexNotPred precededByClosingToken + +-- Check if we should parse an unboxed negative literal (e.g. -123#) as a single token. +negHashLitPred :: AlexAccPred ExtsBitmap +negHashLitPred = prefix_minus `alexAndPred` magic_hash + where + magic_hash = ifExtension MagicHashBit + prefix_minus = + -- Note [prefix_minus in negLitPred and negHashLitPred] alexNotPred precededByClosingToken +{- Note [prefix_minus in negLitPred and negHashLitPred] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We want to parse -1 as a single token, but x-1 as three tokens. +So in negLitPred (and negHashLitPred) we require that we have a prefix +occurrence of the minus sign. See Note [Whitespace-sensitive operator parsing] +for a detailed definition of a prefix occurrence. + +The condition for a prefix occurrence of an operator is: + + not precededByClosingToken && followedByOpeningToken + +but we don't check followedByOpeningToken when parsing a negative literal. +It holds simply because we immediately lex a literal after the minus. +-} + ifExtension :: ExtBits -> AlexAccPred ExtsBitmap ifExtension extBits bits _ _ _ = extBits `xtest` bits ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -224,6 +224,13 @@ Language f = (- x) -- operator section c = (-x) -- negation +* The behavior of :extension:`NegativeLiterals` changed, and now we require + that a negative literal must not be preceded by a closing token (see + `GHC Proposal #229 `__ + for the definition of a closing token). In other words, we parse ``f -123`` + as ``f (-123)``, but ``x-123`` as ``(-) x 123``. Before this amendment, + :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/negative_literals.rst ===================================== @@ -24,9 +24,11 @@ will elicit an unexpected integer-literal-overflow message. Whitespace can be inserted, as in ``- 123``, to force interpretation as two tokens. -One pitfall is that with :extension:`NegativeLiterals`, ``x-1`` will -be parsed as ``x`` applied to the argument ``-1``, which is usually -not what you want. ``x - 1`` or even ``x- 1`` can be used instead -for subtraction. To avoid this, consider using :extension:`LexicalNegation` -instead. - +In 8.12, the behavior of this extension changed, and now we require that a negative literal must not be preceded by a closing token (see +`GHC Proposal #229 `__ +for the definition of a closing token). In other words, we parse ``f -123`` as ``f (-123)``, but ``x-123`` as ``(-) x +123``. Before this amendment, :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + +:extension:`NegativeLiterals` is a subset of :extension:`LexicalNegation`. That +is, enabling both of those extensions has the same effect as enabling +:extension:`LexicalNegation` alone. ===================================== testsuite/tests/parser/should_compile/LexNegVsNegLit.hs deleted ===================================== @@ -1,17 +0,0 @@ -{-# LANGUAGE NegativeLiterals, LexicalNegation #-} - -module LexNegVsNegLit where - --- NegativeLiterals specifies that we parse x-1 as x (-1), even though it's --- considered a shortcoming. --- --- LexicalNegation does not change that. --- -b :: Bool -b = even-1 -- parsed as: even (-1) - -- so it is well-typed. - -- - -- with LexicalNegation alone, we'd get (-) even 1, - -- but NegativeLiterals takes precedence here. - --- See also: GHC Proposal #344 ===================================== testsuite/tests/parser/should_compile/NegativeLiterals.hs ===================================== @@ -0,0 +1,57 @@ +{-# LANGUAGE NegativeLiterals, MagicHash, BinaryLiterals #-} + +module NegativeLiterals where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p1 :: Bool +p1 = even -2 -- parsed as: even (-2) + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p3 :: Int +p3 = floor -2.4 -- parsed as: floor (-2.4) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +p6 :: Bool +p6 = even -0b10 -- parsed as: even (-2) + || even -0o10 -- parsed as: even (-8) + || even -0x10 -- parsed as: even (-16) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti1 :: Integer -> Integer +ti1 x = x-2 -- parsed as: (-) x 1 + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) + +ti6 :: Integer -> [Integer] +ti6 x = + [ x-0b10, -- parsed as: (-) x 2 + x-0o10, -- parsed as: (-) x 8 + x-0x10 ] -- parsed as: (-) x 16 ===================================== testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs ===================================== @@ -0,0 +1,39 @@ +{-# LANGUAGE NoNegativeLiterals, MagicHash, BinaryLiterals #-} + +-- Even when NegativeLiterals are disabled, +-- we parse unboxed literals appropriately. +module NegativeLiteralsNoExt where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -153,7 +153,8 @@ test('proposal-229b', normal, compile, ['']) test('proposal-229d', normal, compile, ['']) test('proposal-229e', normal, compile, ['']) test('LexicalNegation', normal, compile, ['']) -test('LexNegVsNegLit', normal, compile, ['']) +test('NegativeLiterals', normal, compile, ['']) +test('NegativeLiteralsNoExt', normal, compile, ['']) # We omit 'profasm' because it fails with: # Cannot load -prof objects when GHC is built with -dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aee45d9ea8c6cf4ebad4d5c732748923c7865cbe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aee45d9ea8c6cf4ebad4d5c732748923c7865cbe You're receiving 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 Jul 27 11:07:38 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 27 Jul 2020 07:07:38 -0400 Subject: [Git][ghc/ghc][master] fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think Message-ID: <5f1eb57ae3d3f_80bd68a9b85236613@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 1 changed file: - docs/users_guide/separate_compilation.rst Changes: ===================================== docs/users_guide/separate_compilation.rst ===================================== @@ -758,7 +758,7 @@ There are several points to note here: the same machine-generated binary format as any other GHC-generated interface file (e.g. ``B.hi``). You can display its contents with ``ghc --show-iface``. If you specify a directory for - interface files, the ``-ohidir`` flag, then that affects ``hi-boot`` files + interface files, the ``-hidir`` flag, then that affects ``hi-boot`` files too. - If hs-boot files are considered distinct from their parent source View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/667ab69e5edacb2ce2f42fb810cd54c8f856d30b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/667ab69e5edacb2ce2f42fb810cd54c8f856d30b You're receiving 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 Jul 27 11:08:13 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 27 Jul 2020 07:08:13 -0400 Subject: [Git][ghc/ghc][master] Refactor the parser a little Message-ID: <5f1eb59de635_80b3f84962c9cf052375bb@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - 2 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1884,9 +1884,9 @@ sigtypes1 :: { (OrdList (LHsSigType GhcPs)) } ----------------------------------------------------------------------------- -- Types -unpackedness :: { Located ([AddAnn], SourceText, SrcUnpackedness) } - : '{-# UNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getUNPACK_PRAGs $1, SrcUnpack) } - | '{-# NOUNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getNOUNPACK_PRAGs $1, SrcNoUnpack) } +unpackedness :: { Located UnpackednessPragma } + : '{-# UNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getUNPACK_PRAGs $1) SrcUnpack) } + | '{-# NOUNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getNOUNPACK_PRAGs $1) SrcNoUnpack) } forall_telescope :: { Located ([AddAnn], HsForAllTelescope GhcPs) } : 'forall' tv_bndrs '.' {% do { hintExplicitForall $1 @@ -1980,13 +1980,16 @@ tyapp :: { Located TyEl } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | PREFIX_AT atype { sLL $1 $> $ (TyElKindApp (comb2 $1 $2) $2) } - | qtyconop { sL1 $1 $ TyElOpr (unLoc $1) } - | tyvarop { sL1 $1 $ TyElOpr (unLoc $1) } - | SIMPLEQUOTE qconop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | tyop { mapLoc TyElOpr $1 } + | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } + +tyop :: { Located RdrName } + : qtyconop { $1 } + | tyvarop { $1 } + | SIMPLEQUOTE qconop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | SIMPLEQUOTE varop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | SIMPLEQUOTE varop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } atype :: { LHsType GhcPs } : ntgtycon { sL1 $1 (HsTyVar noExtField NotPromoted $1) } -- Not including unit tuples ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -70,6 +70,7 @@ module GHC.Parser.PostProcess ( addFatalError, hintBangPat, TyEl(..), mergeOps, mergeDataCon, mkBangTy, + UnpackednessPragma(..), -- Help with processing exports ImpExpSubSpec(..), @@ -559,25 +560,6 @@ As the result, in order to determine whether (C t1 t2) declares a data constructor, a type, or a context, we would need unlimited lookahead which 'happy' is not so happy with. -To further complicate matters, the interpretation of (!) and (~) is different -in constructors and types: - - (b1) type T = C ! D - (b2) data T = C ! D - (b3) data T = C ! D => E - -In (b1) and (b3), (!) is a type operator with two arguments: 'C' and 'D'. At -the same time, in (b2) it is a strictness annotation: 'C' is a data constructor -with a single strict argument 'D'. For the programmer, these cases are usually -easy to tell apart due to whitespace conventions: - - (b2) data T = C !D -- no space after the bang hints that - -- it is a strictness annotation - -For the parser, on the other hand, this whitespace does not matter. We cannot -tell apart (b2) from (b3) until we encounter (=>), so it requires unlimited -lookahead. - The solution that accounts for all of these issues is to initially parse data declarations and types as a reversed list of TyEl: @@ -1324,7 +1306,7 @@ isFunLhs e = go e [] [] data TyEl = TyElOpr RdrName | TyElOpd (HsType GhcPs) | TyElKindApp SrcSpan (LHsType GhcPs) -- See Note [TyElKindApp SrcSpan interpretation] - | TyElUnpackedness ([AddAnn], SourceText, SrcUnpackedness) + | TyElUnpackedness UnpackednessPragma {- Note [TyElKindApp SrcSpan interpretation] @@ -1345,20 +1327,15 @@ instance Outputable TyEl where ppr (TyElOpr name) = ppr name ppr (TyElOpd ty) = ppr ty ppr (TyElKindApp _ ki) = text "@" <> ppr ki - ppr (TyElUnpackedness (_, _, unpk)) = ppr unpk + ppr (TyElUnpackedness (UnpackednessPragma _ _ unpk)) = ppr unpk -- | Extract a strictness/unpackedness annotation from the front of a reversed -- 'TyEl' list. pUnpackedness :: [Located TyEl] -- reversed TyEl - -> Maybe ( SrcSpan - , [AddAnn] - , SourceText - , SrcUnpackedness - , [Located TyEl] {- remaining TyEl -}) -pUnpackedness (L l x1 : xs) - | TyElUnpackedness (anns, prag, unpk) <- x1 - = Just (l, anns, prag, unpk, xs) + -> Maybe (SrcSpan, UnpackednessPragma, + [Located TyEl] {- remaining TyEl -}) +pUnpackedness (L l x1 : xs) | TyElUnpackedness up <- x1 = Just (l, up, xs) pUnpackedness _ = Nothing pBangTy @@ -1371,7 +1348,7 @@ pBangTy pBangTy lt@(L l1 _) xs = case pUnpackedness xs of Nothing -> (False, lt, pure (), xs) - Just (l2, anns, prag, unpk, xs') -> + Just (l2, UnpackednessPragma anns prag unpk, xs') -> let bl = combineSrcSpans l1 l2 bt = addUnpackedness (prag, unpk) lt in (True, L bl bt, addAnnsAt bl anns, xs') @@ -1380,6 +1357,10 @@ mkBangTy :: SrcStrictness -> LHsType GhcPs -> HsType GhcPs mkBangTy strictness = HsBangTy noExtField (HsSrcBang NoSourceText NoSrcUnpack strictness) +-- Result of parsing {-# UNPACK #-} or {-# NOUNPACK #-} +data UnpackednessPragma = + UnpackednessPragma [AddAnn] SourceText SrcUnpackedness + addUnpackedness :: (SourceText, SrcUnpackedness) -> LHsType GhcPs -> HsType GhcPs addUnpackedness (prag, unpk) (L _ (HsBangTy x bang t)) | HsSrcBang NoSourceText NoSrcUnpack strictness <- bang @@ -1411,7 +1392,7 @@ mergeOps all_xs = go (0 :: Int) [] id all_xs -- clause [unpk]: -- handle (NO)UNPACK pragmas - go k acc ops_acc ((L l (TyElUnpackedness (anns, unpkSrc, unpk))):xs) = + go k acc ops_acc ((L l (TyElUnpackedness (UnpackednessPragma anns unpkSrc unpk))):xs) = if not (null acc) && null xs then do { acc' <- eitherToP $ mergeOpsAcc acc ; let a = ops_acc acc' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6ff89c173f39813f74d7bbf95770c5e40039f155 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6ff89c173f39813f74d7bbf95770c5e40039f155 You're receiving 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 Jul 27 11:38:53 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 27 Jul 2020 07:38:53 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Improve NegativeLiterals (#18022, GHC Proposal #344) Message-ID: <5f1ebccda16a7_80b1025102452426ea@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - 7532aa05 by Ben Gamari at 2020-07-27T07:38:47-04:00 Bump Win32 and process submodules - - - - - af578491 by Michalis Pardalos at 2020-07-27T07:38:48-04:00 Add minimal test for #12492 - - - - - b5174f38 by Michalis Pardalos at 2020-07-27T07:38:49-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 15 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - docs/users_guide/8.12.1-notes.rst - docs/users_guide/exts/negative_literals.rst - docs/users_guide/separate_compilation.rst - libraries/Win32 - libraries/process - rts/PrimOps.cmm - − testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/NegativeLiterals.hs - + testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs - testsuite/tests/parser/should_compile/all.T - + testsuite/tests/primops/should_run/T12492.hs - testsuite/tests/primops/should_run/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1884,9 +1884,9 @@ sigtypes1 :: { (OrdList (LHsSigType GhcPs)) } ----------------------------------------------------------------------------- -- Types -unpackedness :: { Located ([AddAnn], SourceText, SrcUnpackedness) } - : '{-# UNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getUNPACK_PRAGs $1, SrcUnpack) } - | '{-# NOUNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getNOUNPACK_PRAGs $1, SrcNoUnpack) } +unpackedness :: { Located UnpackednessPragma } + : '{-# UNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getUNPACK_PRAGs $1) SrcUnpack) } + | '{-# NOUNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getNOUNPACK_PRAGs $1) SrcNoUnpack) } forall_telescope :: { Located ([AddAnn], HsForAllTelescope GhcPs) } : 'forall' tv_bndrs '.' {% do { hintExplicitForall $1 @@ -1980,13 +1980,16 @@ tyapp :: { Located TyEl } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | PREFIX_AT atype { sLL $1 $> $ (TyElKindApp (comb2 $1 $2) $2) } - | qtyconop { sL1 $1 $ TyElOpr (unLoc $1) } - | tyvarop { sL1 $1 $ TyElOpr (unLoc $1) } - | SIMPLEQUOTE qconop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | tyop { mapLoc TyElOpr $1 } + | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } + +tyop :: { Located RdrName } + : qtyconop { $1 } + | tyvarop { $1 } + | SIMPLEQUOTE qconop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | SIMPLEQUOTE varop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | SIMPLEQUOTE varop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } atype :: { LHsType GhcPs } : ntgtycon { sL1 $1 (HsTyVar noExtField NotPromoted $1) } -- Not including unit tuples ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -199,7 +199,6 @@ $docsym = [\| \^ \* \$] -- normal signed numerical literals can only be explicitly negative, -- not explicitly positive (contrast @exponent) @negative = \- - at signed = @negative ? -- ----------------------------------------------------------------------------- @@ -531,12 +530,12 @@ $tab { warnTab } ifExtension BinaryLiteralsBit } { tok_primint positive 2 3 binary } 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 octal } 0[xX] @numspc @hexadecimal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 hexadecimal } - @negative @decimal \# / { ifExtension MagicHashBit } { tok_primint negative 1 2 decimal } - @negative 0[bB] @numspc @binary \# / { ifExtension MagicHashBit `alexAndPred` + @negative @decimal \# / { negHashLitPred } { tok_primint negative 1 2 decimal } + @negative 0[bB] @numspc @binary \# / { negHashLitPred `alexAndPred` ifExtension BinaryLiteralsBit } { tok_primint negative 3 4 binary } - @negative 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint negative 3 4 octal } + @negative 0[oO] @numspc @octal \# / { negHashLitPred } { tok_primint negative 3 4 octal } @negative 0[xX] @numspc @hexadecimal \# - / { ifExtension MagicHashBit } { tok_primint negative 3 4 hexadecimal } + / { negHashLitPred } { tok_primint negative 3 4 hexadecimal } @decimal \# \# / { ifExtension MagicHashBit } { tok_primword 0 2 decimal } 0[bB] @numspc @binary \# \# / { ifExtension MagicHashBit `alexAndPred` @@ -546,8 +545,11 @@ $tab { warnTab } -- Unboxed floats and doubles (:: Float#, :: Double#) -- prim_{float,double} work with signed literals - @signed @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } - @signed @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } + @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + + @negative @floating_point \# / { negHashLitPred } { tok_frac 1 tok_primfloat } + @negative @floating_point \# \# / { negHashLitPred } { tok_frac 2 tok_primdouble } } -- Strings and chars are lexed by hand-written code. The reason is @@ -1192,8 +1194,8 @@ atEOL _ _ _ (AI _ buf) = atEnd buf || currentChar buf == '\n' -- Check if we should parse a negative literal (e.g. -123) as a single token. negLitPred :: AlexAccPred ExtsBitmap negLitPred = - negative_literals `alexOrPred` - (lexical_negation `alexAndPred` prefix_minus) + prefix_minus `alexAndPred` + (negative_literals `alexOrPred` lexical_negation) where negative_literals = ifExtension NegativeLiteralsBit @@ -1202,14 +1204,33 @@ negLitPred = alexNotPred (ifExtension NoLexicalNegationBit) prefix_minus = - -- The condition for a prefix occurrence of an operator is: - -- - -- not precededByClosingToken && followedByOpeningToken - -- - -- but we don't check followedByOpeningToken here as it holds - -- simply because we immediately lex a literal after the minus. + -- Note [prefix_minus in negLitPred and negHashLitPred] + alexNotPred precededByClosingToken + +-- Check if we should parse an unboxed negative literal (e.g. -123#) as a single token. +negHashLitPred :: AlexAccPred ExtsBitmap +negHashLitPred = prefix_minus `alexAndPred` magic_hash + where + magic_hash = ifExtension MagicHashBit + prefix_minus = + -- Note [prefix_minus in negLitPred and negHashLitPred] alexNotPred precededByClosingToken +{- Note [prefix_minus in negLitPred and negHashLitPred] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We want to parse -1 as a single token, but x-1 as three tokens. +So in negLitPred (and negHashLitPred) we require that we have a prefix +occurrence of the minus sign. See Note [Whitespace-sensitive operator parsing] +for a detailed definition of a prefix occurrence. + +The condition for a prefix occurrence of an operator is: + + not precededByClosingToken && followedByOpeningToken + +but we don't check followedByOpeningToken when parsing a negative literal. +It holds simply because we immediately lex a literal after the minus. +-} + ifExtension :: ExtBits -> AlexAccPred ExtsBitmap ifExtension extBits bits _ _ _ = extBits `xtest` bits ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -70,6 +70,7 @@ module GHC.Parser.PostProcess ( addFatalError, hintBangPat, TyEl(..), mergeOps, mergeDataCon, mkBangTy, + UnpackednessPragma(..), -- Help with processing exports ImpExpSubSpec(..), @@ -559,25 +560,6 @@ As the result, in order to determine whether (C t1 t2) declares a data constructor, a type, or a context, we would need unlimited lookahead which 'happy' is not so happy with. -To further complicate matters, the interpretation of (!) and (~) is different -in constructors and types: - - (b1) type T = C ! D - (b2) data T = C ! D - (b3) data T = C ! D => E - -In (b1) and (b3), (!) is a type operator with two arguments: 'C' and 'D'. At -the same time, in (b2) it is a strictness annotation: 'C' is a data constructor -with a single strict argument 'D'. For the programmer, these cases are usually -easy to tell apart due to whitespace conventions: - - (b2) data T = C !D -- no space after the bang hints that - -- it is a strictness annotation - -For the parser, on the other hand, this whitespace does not matter. We cannot -tell apart (b2) from (b3) until we encounter (=>), so it requires unlimited -lookahead. - The solution that accounts for all of these issues is to initially parse data declarations and types as a reversed list of TyEl: @@ -1324,7 +1306,7 @@ isFunLhs e = go e [] [] data TyEl = TyElOpr RdrName | TyElOpd (HsType GhcPs) | TyElKindApp SrcSpan (LHsType GhcPs) -- See Note [TyElKindApp SrcSpan interpretation] - | TyElUnpackedness ([AddAnn], SourceText, SrcUnpackedness) + | TyElUnpackedness UnpackednessPragma {- Note [TyElKindApp SrcSpan interpretation] @@ -1345,20 +1327,15 @@ instance Outputable TyEl where ppr (TyElOpr name) = ppr name ppr (TyElOpd ty) = ppr ty ppr (TyElKindApp _ ki) = text "@" <> ppr ki - ppr (TyElUnpackedness (_, _, unpk)) = ppr unpk + ppr (TyElUnpackedness (UnpackednessPragma _ _ unpk)) = ppr unpk -- | Extract a strictness/unpackedness annotation from the front of a reversed -- 'TyEl' list. pUnpackedness :: [Located TyEl] -- reversed TyEl - -> Maybe ( SrcSpan - , [AddAnn] - , SourceText - , SrcUnpackedness - , [Located TyEl] {- remaining TyEl -}) -pUnpackedness (L l x1 : xs) - | TyElUnpackedness (anns, prag, unpk) <- x1 - = Just (l, anns, prag, unpk, xs) + -> Maybe (SrcSpan, UnpackednessPragma, + [Located TyEl] {- remaining TyEl -}) +pUnpackedness (L l x1 : xs) | TyElUnpackedness up <- x1 = Just (l, up, xs) pUnpackedness _ = Nothing pBangTy @@ -1371,7 +1348,7 @@ pBangTy pBangTy lt@(L l1 _) xs = case pUnpackedness xs of Nothing -> (False, lt, pure (), xs) - Just (l2, anns, prag, unpk, xs') -> + Just (l2, UnpackednessPragma anns prag unpk, xs') -> let bl = combineSrcSpans l1 l2 bt = addUnpackedness (prag, unpk) lt in (True, L bl bt, addAnnsAt bl anns, xs') @@ -1380,6 +1357,10 @@ mkBangTy :: SrcStrictness -> LHsType GhcPs -> HsType GhcPs mkBangTy strictness = HsBangTy noExtField (HsSrcBang NoSourceText NoSrcUnpack strictness) +-- Result of parsing {-# UNPACK #-} or {-# NOUNPACK #-} +data UnpackednessPragma = + UnpackednessPragma [AddAnn] SourceText SrcUnpackedness + addUnpackedness :: (SourceText, SrcUnpackedness) -> LHsType GhcPs -> HsType GhcPs addUnpackedness (prag, unpk) (L _ (HsBangTy x bang t)) | HsSrcBang NoSourceText NoSrcUnpack strictness <- bang @@ -1411,7 +1392,7 @@ mergeOps all_xs = go (0 :: Int) [] id all_xs -- clause [unpk]: -- handle (NO)UNPACK pragmas - go k acc ops_acc ((L l (TyElUnpackedness (anns, unpkSrc, unpk))):xs) = + go k acc ops_acc ((L l (TyElUnpackedness (UnpackednessPragma anns unpkSrc unpk))):xs) = if not (null acc) && null xs then do { acc' <- eitherToP $ mergeOpsAcc acc ; let a = ops_acc acc' ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -224,6 +224,13 @@ Language f = (- x) -- operator section c = (-x) -- negation +* The behavior of :extension:`NegativeLiterals` changed, and now we require + that a negative literal must not be preceded by a closing token (see + `GHC Proposal #229 `__ + for the definition of a closing token). In other words, we parse ``f -123`` + as ``f (-123)``, but ``x-123`` as ``(-) x 123``. Before this amendment, + :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/negative_literals.rst ===================================== @@ -24,9 +24,11 @@ will elicit an unexpected integer-literal-overflow message. Whitespace can be inserted, as in ``- 123``, to force interpretation as two tokens. -One pitfall is that with :extension:`NegativeLiterals`, ``x-1`` will -be parsed as ``x`` applied to the argument ``-1``, which is usually -not what you want. ``x - 1`` or even ``x- 1`` can be used instead -for subtraction. To avoid this, consider using :extension:`LexicalNegation` -instead. - +In 8.12, the behavior of this extension changed, and now we require that a negative literal must not be preceded by a closing token (see +`GHC Proposal #229 `__ +for the definition of a closing token). In other words, we parse ``f -123`` as ``f (-123)``, but ``x-123`` as ``(-) x +123``. Before this amendment, :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + +:extension:`NegativeLiterals` is a subset of :extension:`LexicalNegation`. That +is, enabling both of those extensions has the same effect as enabling +:extension:`LexicalNegation` alone. ===================================== docs/users_guide/separate_compilation.rst ===================================== @@ -758,7 +758,7 @@ There are several points to note here: the same machine-generated binary format as any other GHC-generated interface file (e.g. ``B.hi``). You can display its contents with ``ghc --show-iface``. If you specify a directory for - interface files, the ``-ohidir`` flag, then that affects ``hi-boot`` files + interface files, the ``-hidir`` flag, then that affects ``hi-boot`` files too. - If hs-boot files are considered distinct from their parent source ===================================== libraries/Win32 ===================================== @@ -1 +1 @@ -Subproject commit ca5fbc12851b98a52f96a43ea19c54c9ecf0f9e3 +Subproject commit f059037820ce68c5f524b188496cab196d979950 ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit cb1d1a6ead68f0e1b209277e79ec608980e9ac84 +Subproject commit afa1f3cd73dd3de8ef028b9dc1411f9c79583579 ===================================== rts/PrimOps.cmm ===================================== @@ -2360,6 +2360,7 @@ stg_mkApUpd0zh ( P_ bco ) stg_unpackClosurezh ( P_ closure ) { W_ info, ptrs, nptrs, p, ptrs_arr, dat_arr; + MAYBE_GC_P(stg_unpackClosurezh, closure); info = %GET_STD_INFO(UNTAG(closure)); prim_read_barrier; @@ -2375,12 +2376,13 @@ stg_unpackClosurezh ( P_ closure ) (len) = foreign "C" heap_view_closureSize(clos "ptr"); W_ ptrs_arr_sz, ptrs_arr_cards, dat_arr_sz; - dat_arr_sz = SIZEOF_StgArrBytes + WDS(len); - - ALLOC_PRIM_P (dat_arr_sz, stg_unpackClosurezh, closure); - - dat_arr = Hp - dat_arr_sz + WDS(1); + dat_arr_sz = SIZEOF_StgArrBytes + WDS(len); + ("ptr" dat_arr) = ccall allocateMightFail(MyCapability() "ptr", BYTES_TO_WDS(dat_arr_sz)); + if (dat_arr == NULL) (likely: False) { + jump stg_raisezh(base_GHCziIOziException_heapOverflow_closure); + } + TICK_ALLOC_PRIM(SIZEOF_StgArrBytes, WDS(len), 0); SET_HDR(dat_arr, stg_ARR_WORDS_info, CCCS); StgArrBytes_bytes(dat_arr) = WDS(len); ===================================== testsuite/tests/parser/should_compile/LexNegVsNegLit.hs deleted ===================================== @@ -1,17 +0,0 @@ -{-# LANGUAGE NegativeLiterals, LexicalNegation #-} - -module LexNegVsNegLit where - --- NegativeLiterals specifies that we parse x-1 as x (-1), even though it's --- considered a shortcoming. --- --- LexicalNegation does not change that. --- -b :: Bool -b = even-1 -- parsed as: even (-1) - -- so it is well-typed. - -- - -- with LexicalNegation alone, we'd get (-) even 1, - -- but NegativeLiterals takes precedence here. - --- See also: GHC Proposal #344 ===================================== testsuite/tests/parser/should_compile/NegativeLiterals.hs ===================================== @@ -0,0 +1,57 @@ +{-# LANGUAGE NegativeLiterals, MagicHash, BinaryLiterals #-} + +module NegativeLiterals where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p1 :: Bool +p1 = even -2 -- parsed as: even (-2) + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p3 :: Int +p3 = floor -2.4 -- parsed as: floor (-2.4) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +p6 :: Bool +p6 = even -0b10 -- parsed as: even (-2) + || even -0o10 -- parsed as: even (-8) + || even -0x10 -- parsed as: even (-16) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti1 :: Integer -> Integer +ti1 x = x-2 -- parsed as: (-) x 1 + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) + +ti6 :: Integer -> [Integer] +ti6 x = + [ x-0b10, -- parsed as: (-) x 2 + x-0o10, -- parsed as: (-) x 8 + x-0x10 ] -- parsed as: (-) x 16 ===================================== testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs ===================================== @@ -0,0 +1,39 @@ +{-# LANGUAGE NoNegativeLiterals, MagicHash, BinaryLiterals #-} + +-- Even when NegativeLiterals are disabled, +-- we parse unboxed literals appropriately. +module NegativeLiteralsNoExt where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -153,7 +153,8 @@ test('proposal-229b', normal, compile, ['']) test('proposal-229d', normal, compile, ['']) test('proposal-229e', normal, compile, ['']) test('LexicalNegation', normal, compile, ['']) -test('LexNegVsNegLit', normal, compile, ['']) +test('NegativeLiterals', normal, compile, ['']) +test('NegativeLiteralsNoExt', normal, compile, ['']) # We omit 'profasm' because it fails with: # Cannot load -prof objects when GHC is built with -dynamic ===================================== testsuite/tests/primops/should_run/T12492.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +import GHC.Exts +import GHC.IO + +main :: IO () +main = IO $ \s -> case newByteArray# 1032161# s of + (# s', mba# #) -> case unpackClosure# (unsafeCoerce# mba# :: Any) of + (# !_, _, _ #) -> (# s', () #) ===================================== testsuite/tests/primops/should_run/all.T ===================================== @@ -19,6 +19,7 @@ test('ArithWord8', omit_ways(['ghci']), compile_and_run, ['']) test('CmpInt8', normal, compile_and_run, ['']) test('CmpWord8', normal, compile_and_run, ['']) test('ShowPrim', normal, compile_and_run, ['']) +test('T12492', normal, compile_and_run, ['']) # These two tests use unboxed tuples, which GHCi doesn't support test('ArithInt16', omit_ways(['ghci']), compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/76ab87569d99ceca65f655c38b4452fb94979428...b5174f38273ec93b4bb2a1c05aa5d20ca0da1fa3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/76ab87569d99ceca65f655c38b4452fb94979428...b5174f38273ec93b4bb2a1c05aa5d20ca0da1fa3 You're receiving 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 Jul 27 12:09:22 2020 From: gitlab at gitlab.haskell.org (Josh Meredith) Date: Mon, 27 Jul 2020 08:09:22 -0400 Subject: [Git][ghc/ghc][wip/pluginExtFields] 5 commits: Improve NegativeLiterals (#18022, GHC Proposal #344) Message-ID: <5f1ec3f2dfe22_80b3f849254123452502f1@gitlab.haskell.org.mail> Josh Meredith pushed to branch wip/pluginExtFields at Glasgow Haskell Compiler / GHC Commits: aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - 031539e3 by Josh Meredith at 2020-07-27T08:09:19-04:00 Add machinery for plugins to write data to extensible interface fields - - - - - b5693b5f by Josh Meredith at 2020-07-27T08:09:19-04:00 Add function to remove plugin interface fields - - - - - 14 changed files: - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - docs/users_guide/8.12.1-notes.rst - docs/users_guide/exts/negative_literals.rst - docs/users_guide/separate_compilation.rst - − testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/NegativeLiterals.hs - + testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs - testsuite/tests/parser/should_compile/all.T Changes: ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -198,6 +198,7 @@ newHscEnv dflags = do us <- mkSplitUniqSupply 'r' nc_var <- newIORef (initNameCache us knownKeyNames) fc_var <- newIORef emptyInstalledModuleEnv + ext_fs <- newIORef emptyExtensibleFields emptyDynLinker <- uninitializedLinker return HscEnv { hsc_dflags = dflags , hsc_targets = [] @@ -207,6 +208,7 @@ newHscEnv dflags = do , hsc_EPS = eps_var , hsc_NC = nc_var , hsc_FC = fc_var + , hsc_ext_fields = ext_fs , hsc_type_env_var = Nothing , hsc_interp = Nothing , hsc_dynLinker = emptyDynLinker @@ -810,11 +812,10 @@ finish summary tc_result mb_old_hash = do (cg_guts, details) <- {-# SCC "CoreTidy" #-} liftIO $ tidyProgram hsc_env simplified_guts - let !partial_iface = - {-# SCC "GHC.Driver.Main.mkPartialIface" #-} + !partial_iface <- {-# SCC "GHC.Driver.Main.mkPartialIface" #-} -- This `force` saves 2M residency in test T10370 -- See Note [Avoiding space leaks in toIface*] for details. - force (mkPartialIface hsc_env details simplified_guts) + liftIO $ force <$> (mkPartialIface hsc_env details simplified_guts) return HscRecomp { hscs_guts = cg_guts, hscs_mod_location = ms_location summary, ===================================== compiler/GHC/Driver/Types.hs ===================================== @@ -155,6 +155,8 @@ module GHC.Driver.Types ( readField, readIfaceField, readIfaceFieldWith, writeField, writeIfaceField, writeIfaceFieldWith, deleteField, deleteIfaceField, + registerInterfaceData, registerInterfaceDataWith, + unregisterInterfaceData, ) where #include "HsVersions.h" @@ -475,6 +477,10 @@ data HscEnv hsc_FC :: {-# UNPACK #-} !(IORef FinderCache), -- ^ The cached result of performing finding in the file system + hsc_ext_fields :: {-# UNPACK #-} !(IORef ExtensibleFields), + -- ^ Extensible interface field data stored by plugins to be later + -- output in the `.hi` file. + hsc_type_env_var :: Maybe (Module, IORef TypeEnv) -- ^ Used for one-shot compilation only, to initialise -- the 'IfGblEnv'. See 'GHC.Tc.Utils.tcg_type_env_var' for @@ -3404,3 +3410,17 @@ deleteField name (ExtensibleFields fs) = ExtensibleFields $ Map.delete name fs deleteIfaceField :: FieldName -> ModIface -> ModIface deleteIfaceField name iface = iface { mi_ext_fields = deleteField name (mi_ext_fields iface) } + +registerInterfaceData :: Binary a => FieldName -> HscEnv -> a -> IO () +registerInterfaceData name env x = registerInterfaceDataWith name env (`put_` x) + +registerInterfaceDataWith :: FieldName -> HscEnv -> (BinHandle -> IO ()) -> IO () +registerInterfaceDataWith name env write = do + ext_fs <- readIORef (hsc_ext_fields env) + ext_fs' <- writeFieldWith name write ext_fs + writeIORef (hsc_ext_fields env) ext_fs' + +unregisterInterfaceData :: FieldName -> HscEnv -> IO () +unregisterInterfaceData name env = do + ext_fs <- readIORef (hsc_ext_fields env) + writeIORef (hsc_ext_fields env) (deleteField name ext_fs) ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -81,7 +81,7 @@ import GHC.Driver.Plugins (LoadedPlugin(..)) mkPartialIface :: HscEnv -> ModDetails -> ModGuts - -> PartialModIface + -> IO PartialModIface mkPartialIface hsc_env mod_details ModGuts{ mg_module = this_mod , mg_hsc_src = hsc_src @@ -98,8 +98,11 @@ mkPartialIface hsc_env mod_details , mg_decl_docs = decl_docs , mg_arg_docs = arg_docs } - = mkIface_ hsc_env this_mod hsc_src used_th deps rdr_env fix_env warns hpc_info self_trust - safe_mode usages doc_hdr decl_docs arg_docs mod_details + = do ext_fs <- readIORef $ hsc_ext_fields hsc_env + return iface{mi_ext_fields = ext_fs} + where + iface = mkIface_ hsc_env this_mod hsc_src used_th deps rdr_env fix_env warns hpc_info self_trust + safe_mode usages doc_hdr decl_docs arg_docs mod_details -- | Fully instantiate an interface. Adds fingerprints and potentially code -- generator produced information. ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -20,7 +20,9 @@ module GHC.IfaceToCore ( tcIfaceAnnotations, tcIfaceCompleteSigs, tcIfaceExpr, -- Desired by HERMIT (#7683) tcIfaceGlobal, - tcIfaceOneShot + tcIfaceOneShot, + tcIfaceType, + tcJoinInfo, ) where #include "HsVersions.h" ===================================== compiler/GHC/Parser.y ===================================== @@ -1884,9 +1884,9 @@ sigtypes1 :: { (OrdList (LHsSigType GhcPs)) } ----------------------------------------------------------------------------- -- Types -unpackedness :: { Located ([AddAnn], SourceText, SrcUnpackedness) } - : '{-# UNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getUNPACK_PRAGs $1, SrcUnpack) } - | '{-# NOUNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getNOUNPACK_PRAGs $1, SrcNoUnpack) } +unpackedness :: { Located UnpackednessPragma } + : '{-# UNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getUNPACK_PRAGs $1) SrcUnpack) } + | '{-# NOUNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getNOUNPACK_PRAGs $1) SrcNoUnpack) } forall_telescope :: { Located ([AddAnn], HsForAllTelescope GhcPs) } : 'forall' tv_bndrs '.' {% do { hintExplicitForall $1 @@ -1980,13 +1980,16 @@ tyapp :: { Located TyEl } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | PREFIX_AT atype { sLL $1 $> $ (TyElKindApp (comb2 $1 $2) $2) } - | qtyconop { sL1 $1 $ TyElOpr (unLoc $1) } - | tyvarop { sL1 $1 $ TyElOpr (unLoc $1) } - | SIMPLEQUOTE qconop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | tyop { mapLoc TyElOpr $1 } + | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } + +tyop :: { Located RdrName } + : qtyconop { $1 } + | tyvarop { $1 } + | SIMPLEQUOTE qconop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | SIMPLEQUOTE varop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | SIMPLEQUOTE varop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } atype :: { LHsType GhcPs } : ntgtycon { sL1 $1 (HsTyVar noExtField NotPromoted $1) } -- Not including unit tuples ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -199,7 +199,6 @@ $docsym = [\| \^ \* \$] -- normal signed numerical literals can only be explicitly negative, -- not explicitly positive (contrast @exponent) @negative = \- - at signed = @negative ? -- ----------------------------------------------------------------------------- @@ -531,12 +530,12 @@ $tab { warnTab } ifExtension BinaryLiteralsBit } { tok_primint positive 2 3 binary } 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 octal } 0[xX] @numspc @hexadecimal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 hexadecimal } - @negative @decimal \# / { ifExtension MagicHashBit } { tok_primint negative 1 2 decimal } - @negative 0[bB] @numspc @binary \# / { ifExtension MagicHashBit `alexAndPred` + @negative @decimal \# / { negHashLitPred } { tok_primint negative 1 2 decimal } + @negative 0[bB] @numspc @binary \# / { negHashLitPred `alexAndPred` ifExtension BinaryLiteralsBit } { tok_primint negative 3 4 binary } - @negative 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint negative 3 4 octal } + @negative 0[oO] @numspc @octal \# / { negHashLitPred } { tok_primint negative 3 4 octal } @negative 0[xX] @numspc @hexadecimal \# - / { ifExtension MagicHashBit } { tok_primint negative 3 4 hexadecimal } + / { negHashLitPred } { tok_primint negative 3 4 hexadecimal } @decimal \# \# / { ifExtension MagicHashBit } { tok_primword 0 2 decimal } 0[bB] @numspc @binary \# \# / { ifExtension MagicHashBit `alexAndPred` @@ -546,8 +545,11 @@ $tab { warnTab } -- Unboxed floats and doubles (:: Float#, :: Double#) -- prim_{float,double} work with signed literals - @signed @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } - @signed @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } + @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + + @negative @floating_point \# / { negHashLitPred } { tok_frac 1 tok_primfloat } + @negative @floating_point \# \# / { negHashLitPred } { tok_frac 2 tok_primdouble } } -- Strings and chars are lexed by hand-written code. The reason is @@ -1192,8 +1194,8 @@ atEOL _ _ _ (AI _ buf) = atEnd buf || currentChar buf == '\n' -- Check if we should parse a negative literal (e.g. -123) as a single token. negLitPred :: AlexAccPred ExtsBitmap negLitPred = - negative_literals `alexOrPred` - (lexical_negation `alexAndPred` prefix_minus) + prefix_minus `alexAndPred` + (negative_literals `alexOrPred` lexical_negation) where negative_literals = ifExtension NegativeLiteralsBit @@ -1202,14 +1204,33 @@ negLitPred = alexNotPred (ifExtension NoLexicalNegationBit) prefix_minus = - -- The condition for a prefix occurrence of an operator is: - -- - -- not precededByClosingToken && followedByOpeningToken - -- - -- but we don't check followedByOpeningToken here as it holds - -- simply because we immediately lex a literal after the minus. + -- Note [prefix_minus in negLitPred and negHashLitPred] + alexNotPred precededByClosingToken + +-- Check if we should parse an unboxed negative literal (e.g. -123#) as a single token. +negHashLitPred :: AlexAccPred ExtsBitmap +negHashLitPred = prefix_minus `alexAndPred` magic_hash + where + magic_hash = ifExtension MagicHashBit + prefix_minus = + -- Note [prefix_minus in negLitPred and negHashLitPred] alexNotPred precededByClosingToken +{- Note [prefix_minus in negLitPred and negHashLitPred] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We want to parse -1 as a single token, but x-1 as three tokens. +So in negLitPred (and negHashLitPred) we require that we have a prefix +occurrence of the minus sign. See Note [Whitespace-sensitive operator parsing] +for a detailed definition of a prefix occurrence. + +The condition for a prefix occurrence of an operator is: + + not precededByClosingToken && followedByOpeningToken + +but we don't check followedByOpeningToken when parsing a negative literal. +It holds simply because we immediately lex a literal after the minus. +-} + ifExtension :: ExtBits -> AlexAccPred ExtsBitmap ifExtension extBits bits _ _ _ = extBits `xtest` bits ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -70,6 +70,7 @@ module GHC.Parser.PostProcess ( addFatalError, hintBangPat, TyEl(..), mergeOps, mergeDataCon, mkBangTy, + UnpackednessPragma(..), -- Help with processing exports ImpExpSubSpec(..), @@ -559,25 +560,6 @@ As the result, in order to determine whether (C t1 t2) declares a data constructor, a type, or a context, we would need unlimited lookahead which 'happy' is not so happy with. -To further complicate matters, the interpretation of (!) and (~) is different -in constructors and types: - - (b1) type T = C ! D - (b2) data T = C ! D - (b3) data T = C ! D => E - -In (b1) and (b3), (!) is a type operator with two arguments: 'C' and 'D'. At -the same time, in (b2) it is a strictness annotation: 'C' is a data constructor -with a single strict argument 'D'. For the programmer, these cases are usually -easy to tell apart due to whitespace conventions: - - (b2) data T = C !D -- no space after the bang hints that - -- it is a strictness annotation - -For the parser, on the other hand, this whitespace does not matter. We cannot -tell apart (b2) from (b3) until we encounter (=>), so it requires unlimited -lookahead. - The solution that accounts for all of these issues is to initially parse data declarations and types as a reversed list of TyEl: @@ -1324,7 +1306,7 @@ isFunLhs e = go e [] [] data TyEl = TyElOpr RdrName | TyElOpd (HsType GhcPs) | TyElKindApp SrcSpan (LHsType GhcPs) -- See Note [TyElKindApp SrcSpan interpretation] - | TyElUnpackedness ([AddAnn], SourceText, SrcUnpackedness) + | TyElUnpackedness UnpackednessPragma {- Note [TyElKindApp SrcSpan interpretation] @@ -1345,20 +1327,15 @@ instance Outputable TyEl where ppr (TyElOpr name) = ppr name ppr (TyElOpd ty) = ppr ty ppr (TyElKindApp _ ki) = text "@" <> ppr ki - ppr (TyElUnpackedness (_, _, unpk)) = ppr unpk + ppr (TyElUnpackedness (UnpackednessPragma _ _ unpk)) = ppr unpk -- | Extract a strictness/unpackedness annotation from the front of a reversed -- 'TyEl' list. pUnpackedness :: [Located TyEl] -- reversed TyEl - -> Maybe ( SrcSpan - , [AddAnn] - , SourceText - , SrcUnpackedness - , [Located TyEl] {- remaining TyEl -}) -pUnpackedness (L l x1 : xs) - | TyElUnpackedness (anns, prag, unpk) <- x1 - = Just (l, anns, prag, unpk, xs) + -> Maybe (SrcSpan, UnpackednessPragma, + [Located TyEl] {- remaining TyEl -}) +pUnpackedness (L l x1 : xs) | TyElUnpackedness up <- x1 = Just (l, up, xs) pUnpackedness _ = Nothing pBangTy @@ -1371,7 +1348,7 @@ pBangTy pBangTy lt@(L l1 _) xs = case pUnpackedness xs of Nothing -> (False, lt, pure (), xs) - Just (l2, anns, prag, unpk, xs') -> + Just (l2, UnpackednessPragma anns prag unpk, xs') -> let bl = combineSrcSpans l1 l2 bt = addUnpackedness (prag, unpk) lt in (True, L bl bt, addAnnsAt bl anns, xs') @@ -1380,6 +1357,10 @@ mkBangTy :: SrcStrictness -> LHsType GhcPs -> HsType GhcPs mkBangTy strictness = HsBangTy noExtField (HsSrcBang NoSourceText NoSrcUnpack strictness) +-- Result of parsing {-# UNPACK #-} or {-# NOUNPACK #-} +data UnpackednessPragma = + UnpackednessPragma [AddAnn] SourceText SrcUnpackedness + addUnpackedness :: (SourceText, SrcUnpackedness) -> LHsType GhcPs -> HsType GhcPs addUnpackedness (prag, unpk) (L _ (HsBangTy x bang t)) | HsSrcBang NoSourceText NoSrcUnpack strictness <- bang @@ -1411,7 +1392,7 @@ mergeOps all_xs = go (0 :: Int) [] id all_xs -- clause [unpk]: -- handle (NO)UNPACK pragmas - go k acc ops_acc ((L l (TyElUnpackedness (anns, unpkSrc, unpk))):xs) = + go k acc ops_acc ((L l (TyElUnpackedness (UnpackednessPragma anns unpkSrc unpk))):xs) = if not (null acc) && null xs then do { acc' <- eitherToP $ mergeOpsAcc acc ; let a = ops_acc acc' ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -224,6 +224,13 @@ Language f = (- x) -- operator section c = (-x) -- negation +* The behavior of :extension:`NegativeLiterals` changed, and now we require + that a negative literal must not be preceded by a closing token (see + `GHC Proposal #229 `__ + for the definition of a closing token). In other words, we parse ``f -123`` + as ``f (-123)``, but ``x-123`` as ``(-) x 123``. Before this amendment, + :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/negative_literals.rst ===================================== @@ -24,9 +24,11 @@ will elicit an unexpected integer-literal-overflow message. Whitespace can be inserted, as in ``- 123``, to force interpretation as two tokens. -One pitfall is that with :extension:`NegativeLiterals`, ``x-1`` will -be parsed as ``x`` applied to the argument ``-1``, which is usually -not what you want. ``x - 1`` or even ``x- 1`` can be used instead -for subtraction. To avoid this, consider using :extension:`LexicalNegation` -instead. - +In 8.12, the behavior of this extension changed, and now we require that a negative literal must not be preceded by a closing token (see +`GHC Proposal #229 `__ +for the definition of a closing token). In other words, we parse ``f -123`` as ``f (-123)``, but ``x-123`` as ``(-) x +123``. Before this amendment, :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + +:extension:`NegativeLiterals` is a subset of :extension:`LexicalNegation`. That +is, enabling both of those extensions has the same effect as enabling +:extension:`LexicalNegation` alone. ===================================== docs/users_guide/separate_compilation.rst ===================================== @@ -758,7 +758,7 @@ There are several points to note here: the same machine-generated binary format as any other GHC-generated interface file (e.g. ``B.hi``). You can display its contents with ``ghc --show-iface``. If you specify a directory for - interface files, the ``-ohidir`` flag, then that affects ``hi-boot`` files + interface files, the ``-hidir`` flag, then that affects ``hi-boot`` files too. - If hs-boot files are considered distinct from their parent source ===================================== testsuite/tests/parser/should_compile/LexNegVsNegLit.hs deleted ===================================== @@ -1,17 +0,0 @@ -{-# LANGUAGE NegativeLiterals, LexicalNegation #-} - -module LexNegVsNegLit where - --- NegativeLiterals specifies that we parse x-1 as x (-1), even though it's --- considered a shortcoming. --- --- LexicalNegation does not change that. --- -b :: Bool -b = even-1 -- parsed as: even (-1) - -- so it is well-typed. - -- - -- with LexicalNegation alone, we'd get (-) even 1, - -- but NegativeLiterals takes precedence here. - --- See also: GHC Proposal #344 ===================================== testsuite/tests/parser/should_compile/NegativeLiterals.hs ===================================== @@ -0,0 +1,57 @@ +{-# LANGUAGE NegativeLiterals, MagicHash, BinaryLiterals #-} + +module NegativeLiterals where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p1 :: Bool +p1 = even -2 -- parsed as: even (-2) + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p3 :: Int +p3 = floor -2.4 -- parsed as: floor (-2.4) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +p6 :: Bool +p6 = even -0b10 -- parsed as: even (-2) + || even -0o10 -- parsed as: even (-8) + || even -0x10 -- parsed as: even (-16) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti1 :: Integer -> Integer +ti1 x = x-2 -- parsed as: (-) x 1 + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) + +ti6 :: Integer -> [Integer] +ti6 x = + [ x-0b10, -- parsed as: (-) x 2 + x-0o10, -- parsed as: (-) x 8 + x-0x10 ] -- parsed as: (-) x 16 ===================================== testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs ===================================== @@ -0,0 +1,39 @@ +{-# LANGUAGE NoNegativeLiterals, MagicHash, BinaryLiterals #-} + +-- Even when NegativeLiterals are disabled, +-- we parse unboxed literals appropriately. +module NegativeLiteralsNoExt where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -153,7 +153,8 @@ test('proposal-229b', normal, compile, ['']) test('proposal-229d', normal, compile, ['']) test('proposal-229e', normal, compile, ['']) test('LexicalNegation', normal, compile, ['']) -test('LexNegVsNegLit', normal, compile, ['']) +test('NegativeLiterals', normal, compile, ['']) +test('NegativeLiteralsNoExt', normal, compile, ['']) # We omit 'profasm' because it fails with: # Cannot load -prof objects when GHC is built with -dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/20d97fb0246043acd44018aaf1d6423c6300e7a5...b5693b5f633faf0b6a1452f7214e28eedb04dc63 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/20d97fb0246043acd44018aaf1d6423c6300e7a5...b5693b5f633faf0b6a1452f7214e28eedb04dc63 You're receiving 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 Jul 27 12:11:52 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Mon, 27 Jul 2020 08:11:52 -0400 Subject: [Git][ghc/ghc][wip/disamb-td] 27 commits: winio: restore console cp on exit Message-ID: <5f1ec488afd46_80b3f849254123452506d0@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/disamb-td at Glasgow Haskell Compiler / GHC Commits: cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - 02139b31 by Vladislav Zavialov at 2020-07-27T15:06:34+03:00 Grammar for types and data/newtype constructors Before this patch, we parsed types into a reversed sequence of operators and operands. For example, (F x y + G a b * X) would be parsed as [X, *, b, a, G, +, y, x, F], using a simple grammar: tyapps : tyapp | tyapps tyapp tyapp : atype | PREFIX_AT atype | tyop | unpackedness Then we used a hand-written state machine to assemble this either into a type, using 'mergeOps', or into a constructor, using 'mergeDataCon'. This is due to a syntactic ambiguity: data T1 a = MkT1 a data T2 a = Ord a => MkT2 a In T1, what follows after the = sign is a data/newtype constructor declaration. However, in T2, what follows is a type (of kind Constraint). We don't know which of the two we are parsing until we encounter =>, and we cannot check for => without unlimited lookahead. This poses a few issues when it comes to e.g. infix operators: data I1 = Int :+ Bool :+ Char -- bad data I2 = Int :+ Bool :+ Char => MkI2 -- fine By this issue alone we are forced into parsing into an intermediate representation and doing a separate validation pass. However, should that intermediate representation be as low-level as a flat sequence of operators and operands? Before GHC Proposal #229, the answer was Yes, due to some particularly nasty corner cases: data T = ! A :+ ! B -- used to be fine, hard to parse data T = ! A :+ ! B => MkT -- bad However, now the answer is No, as this corner case is gone: data T = ! A :+ ! B -- bad data T = ! A :+ ! B => MkT -- bad This means we can write a proper grammar for types, overloading it in the DisambECP style, see Note [Ambiguous syntactic categories]. With this patch, we introduce a new class, DisambTD. Just like DisambECP is used to disambiguate between expressions, commands, and patterns, DisambTD is used to disambiguate between types and data/newtype constructors. This way, we get a proper, declarative grammar for constructors and types: infixtype : ftype | ftype tyop infixtype | unpackedness infixtype ftype : atype | tyop | ftype tyarg | ftype PREFIX_AT tyarg tyarg : atype | unpackedness atype And having a grammar for types means we are a step closer to using a single grammar for types and expressions. - - - - - 30 changed files: - .gitlab/test-metrics.sh - CODEOWNERS - compiler/GHC.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Plugins.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Binds.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/34b390f3d02d8d223d234d80527f3b80bbd57963...02139b3172aa01820c91431f7309727934bc2b74 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/34b390f3d02d8d223d234d80527f3b80bbd57963...02139b3172aa01820c91431f7309727934bc2b74 You're receiving 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 Jul 27 13:10:19 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 27 Jul 2020 09:10:19 -0400 Subject: [Git][ghc/ghc][wip/T18502] Add two bangs to improve perf of flattening Message-ID: <5f1ed23bdd358_80bd68a9b852716ee@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18502 at Glasgow Haskell Compiler / GHC Commits: 65ef562c by Simon Peyton Jones at 2020-07-27T14:05:53+01:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 1 changed file: - compiler/GHC/Core/Coercion.hs Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -1891,7 +1891,9 @@ substForAllCoBndrUsingLC sym sco (LC subst lc_env) tv co -- -- For the inverse operation, see 'liftCoMatch' ty_co_subst :: LiftingContext -> Role -> Type -> Coercion -ty_co_subst lc role ty +ty_co_subst !lc role ty + -- !lc: making this function strict in lc allows callers to + -- pass its two components separately, rather than boxing them = go role ty where go :: Role -> Type -> Coercion @@ -2864,9 +2866,9 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs -- need a coercion (kind_co :: old_kind ~ new_kind). -- -- The bangs here have been observed to improve performance - -- significantly in optimized builds. - let kind_co = mkSymCo $ - liftCoSubst Nominal lc (tyCoBinderType binder) + -- significantly in optimized builds; see #18502 + let !kind_co = mkSymCo $ + liftCoSubst Nominal lc (tyCoBinderType binder) !casted_xi = xi `mkCastTy` kind_co casted_co = mkCoherenceLeftCo role xi kind_co co View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65ef562cf75fe22b2437af994ec0c8610a85e34b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65ef562cf75fe22b2437af994ec0c8610a85e34b You're receiving 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 Jul 27 14:15:37 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 27 Jul 2020 10:15:37 -0400 Subject: [Git][ghc/ghc] Pushed new branch ghc-9.0 Message-ID: <5f1ee189bc231_80bd68a9b852835a1@gitlab.haskell.org.mail> Ben Gamari pushed new branch ghc-9.0 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-9.0 You're receiving 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 Jul 27 14:15:45 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 27 Jul 2020 10:15:45 -0400 Subject: [Git][ghc/ghc] Deleted branch ghc-8.12 Message-ID: <5f1ee1913de88_80b3f849248fe085283793@gitlab.haskell.org.mail> Ben Gamari deleted branch ghc-8.12 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 Jul 27 14:51:35 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 27 Jul 2020 10:51:35 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18323 Message-ID: <5f1ee9f7c1047_80b3f849254123452879f3@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T18323 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18323 You're receiving 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 Jul 27 15:20:26 2020 From: gitlab at gitlab.haskell.org (Peter Trommler) Date: Mon, 27 Jul 2020 11:20:26 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/remove-gcc44-support Message-ID: <5f1ef0ba78165_80b3f8492541234529213d@gitlab.haskell.org.mail> Peter Trommler pushed new branch wip/remove-gcc44-support at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/remove-gcc44-support You're receiving 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 Jul 27 17:04:44 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 27 Jul 2020 13:04:44 -0400 Subject: [Git][ghc/ghc][wip/gc/nonmoving-pinned] 2 commits: nonmoving: Teach allocatePinned() to allocate into nonmoving heap Message-ID: <5f1f092cbefac_80b8d8e57053245c1@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/gc/nonmoving-pinned at Glasgow Haskell Compiler / GHC Commits: 02e97485 by Ben Gamari at 2020-07-27T12:58:37-04:00 nonmoving: Teach allocatePinned() to allocate into nonmoving heap The allocatePinned() function is used to allocate pinned memory (e.g. for newPinnedByteArray#) - - - - - f16461d3 by Ben Gamari at 2020-07-27T13:03:58-04:00 gitlab-ci: Respect TEST_TYPE It seems that this was dropped in the refactoring of the CI driver. - - - - - 6 changed files: - .gitlab/ci.sh - rts/sm/NonMoving.c - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c - rts/sm/NonMovingScav.c - rts/sm/Storage.c Changes: ===================================== .gitlab/ci.sh ===================================== @@ -364,8 +364,11 @@ function push_perf_notes() { } function test_make() { + if [[ -z "$TEST_TYPE" ]]; then + TEST_TYPE="test" + fi run "$MAKE" test_bindist TEST_PREP=YES - run "$MAKE" V=0 test \ + run "$MAKE" V=0 $TEST_TYPE \ THREADS="$cores" \ JUNIT_FILE=../../junit.xml } ===================================== rts/sm/NonMoving.c ===================================== @@ -474,6 +474,24 @@ Mutex concurrent_coll_finished_lock; * remembered set during the preparatory GC. This allows us to safely skip the * non-moving write barrier without jeopardizing the snapshot invariant. * + * + * Note [Allocating pinned objects into the non-moving heap] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * Under the moving collector small, pinned ByteArray#s are allocated by + * Storage.c:allocatePinned() into a per-capability accumulator block which is + * filled in a bump-pointer fashion. While this scheme is simple, it can lead + * to very poor fragmentation behavior as objects become unreachable: a single + * live ByteArray# can keep an entire block of memory alive. + * + * When the non-moving collector is in use we can do better by allocating small + * pinned objects directly into the non-moving heap. + * + * One wrinkle here is that pinned ByteArrays may have alignment requirements + * which requires that we insert padding zero-words before the beginning of the + * object. We must be certain to account for this padding when inspecting the + * object. + * */ memcount nonmoving_live_words = 0; ===================================== rts/sm/NonMoving.h ===================================== @@ -73,11 +73,17 @@ struct NonmovingAllocator { // allocators cover block sizes of 2^NONMOVING_ALLOCA0 to // 2^(NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT) (in bytes) +// The largest allocator class must be at least LARGE_OBJECT_THRESHOLD in size +// as Storage.c:allocatePinned will allocate small pinned allocations into the +// non-moving heap. #define NONMOVING_ALLOCA_CNT 12 // maximum number of free segments to hold on to #define NONMOVING_MAX_FREE 16 +// block size of largest allocator in bytes. +#define NONMOVING_MAX_BLOCK_SZ (1 << (NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT)) + struct NonmovingHeap { struct NonmovingAllocator *allocators[NONMOVING_ALLOCA_CNT]; // free segment list. This is a cache where we keep up to ===================================== rts/sm/NonMovingMark.c ===================================== @@ -1359,6 +1359,11 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) // Trace pointers ///////////////////////////////////////////////////// + // Find beginning of object. + // See Note [Allocating pinned objects into the non-moving heap]. + while (*(StgPtr*) p == NULL) + p = (StgClosure *) ((StgPtr*) p + 1); + const StgInfoTable *info = get_itbl(p); switch (info->type) { ===================================== rts/sm/NonMovingScav.c ===================================== @@ -11,9 +11,18 @@ #include "MarkWeak.h" // scavengeLiveWeak void -nonmovingScavengeOne (StgClosure *q) +nonmovingScavengeOne (StgClosure *q0) { + StgClosure *q = q0; + + // N.B. There may be a gap before the first word of the closure in the case + // of an aligned ByteArray# as allocated by allocatePinned(). + // See Note [Allocating pinned objects into the non-moving heap]. + while (*(StgPtr*) q == NULL) + q = (StgClosure *) ((StgPtr*) q + 1); + ASSERT(LOOKS_LIKE_CLOSURE_PTR(q)); + StgPtr p = (StgPtr)q; const StgInfoTable *info = get_itbl(q); const bool saved_eager_promotion = gct->eager_promotion; ===================================== rts/sm/Storage.c ===================================== @@ -1165,6 +1165,23 @@ allocatePinned (Capability *cap, W_ n /*words*/, W_ alignment /*bytes*/, W_ alig const StgWord alignment_w = alignment / sizeof(W_); + // If the non-moving collector is enabled then we can allocate small, + // pinned allocations directly into the non-moving heap. This is a bit more + // expensive up-front but reduces fragmentation and is worthwhile since + // pinned allocations are often long-lived.. + // + // See Note [Allocating pinned objects into the non-moving heap]. + if (RTS_UNLIKELY(RtsFlags.GcFlags.useNonmoving) + && n * sizeof(W_) + alignment_w <= NONMOVING_MAX_BLOCK_SZ) + { + p = nonmovingAllocate(cap, n + alignment_w); + W_ off_w = ALIGN_WITH_OFF_W(p, alignment, align_off); + memset(p, 0, off_w); + p += off_w; + MEMSET_IF_PROFILING_W(p + n, 0, alignment_w - off_w - 1); + return p; + } + // If the request is for a large object, then allocate() // will give us a pinned object anyway. if (n >= LARGE_OBJECT_THRESHOLD/sizeof(W_)) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/43b0bcf92bf1cf3708c140a2e5d9b98111ba5817...f16461d354a0e11954a350c7a23cbe33c1032e6e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/43b0bcf92bf1cf3708c140a2e5d9b98111ba5817...f16461d354a0e11954a350c7a23cbe33c1032e6e You're receiving 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 Jul 27 17:16:36 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 27 Jul 2020 13:16:36 -0400 Subject: [Git][ghc/ghc][wip/T18291] 58 commits: DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) Message-ID: <5f1f0bf48873c_80b102510245325052@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18291 at Glasgow Haskell Compiler / GHC Commits: 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - 94be2073 by Ben Gamari at 2020-07-27T13:16:16-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 0f5b3d7e by Ben Gamari at 2020-07-27T13:16:16-04:00 testsuite: Add test for #18291 - - - - - 30 changed files: - .gitlab/test-metrics.sh - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5bf2cffdb4d36d0c7d49c6d8aaf48d7e961aa210...0f5b3d7e6010c9c302ab9d8a7474ba89f89d3651 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5bf2cffdb4d36d0c7d49c6d8aaf48d7e961aa210...0f5b3d7e6010c9c302ab9d8a7474ba89f89d3651 You're receiving 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 Jul 27 17:19:04 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 27 Jul 2020 13:19:04 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Drop 32-bit Windows support Message-ID: <5f1f0c88cb18d_80b3f849c40b20c5327577@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b0e4b041 by Ben Gamari at 2020-07-27T13:18:59-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - cc72e209 by Michalis Pardalos at 2020-07-27T13:19:00-04:00 Add minimal test for #12492 - - - - - f82bc7c9 by Michalis Pardalos at 2020-07-27T13:19:00-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - fcbca90a by Simon Peyton Jones at 2020-07-27T13:19:01-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - cf67c2c8 by Ben Gamari at 2020-07-27T13:19:01-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 61e1d542 by Ben Gamari at 2020-07-27T13:19:01-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 6 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Opt/Simplify/Monad.hs - docs/users_guide/8.12.1-notes.rst - rts/PrimOps.cmm - + testsuite/tests/primops/should_run/T12492.hs - testsuite/tests/primops/should_run/all.T Changes: ===================================== .gitlab-ci.yml ===================================== @@ -190,6 +190,7 @@ lint-release-changelogs: key: hadrian paths: - cabal-cache + dependencies: [] artifacts: reports: junit: junit.xml @@ -292,8 +293,8 @@ hadrian-ghc-in-ghci: # porting guide [1]. # [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" - GHC_VERSION: 8.10.1 - CABAL_INSTALL_VERSION: 3.2.0.0 + GHC_VERSION: "8.10.1" + CABAL_INSTALL_VERSION: "3.2.0.0" BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" TEST_ENV: "x86_64-freebsd" BUILD_FLAVOUR: "validate" @@ -367,7 +368,7 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: 8.8.3 + GHC_VERSION: 8.8.4 CABAL_INSTALL_VERSION: 3.0.0.0 BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-apple-darwin.tar.xz" MACOSX_DEPLOYMENT_TARGET: "10.7" @@ -395,7 +396,7 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: 8.8.3 + GHC_VERSION: 8.8.4 MACOSX_DEPLOYMENT_TARGET: "10.7" ac_cv_func_clock_gettime: "no" LANG: "en_US.UTF-8" @@ -776,8 +777,8 @@ validate-x86_64-linux-fedora27: #FORCE_SYMLINKS: 1 LANG: "en_US.UTF-8" SPHINXBUILD: "/mingw64/bin/sphinx-build.exe" - CABAL_INSTALL_VERSION: 3.0.0.0 - GHC_VERSION: "8.8.3" + CABAL_INSTALL_VERSION: "3.0.0.0" + GHC_VERSION: "8.8.4" cache: paths: - cabal-cache @@ -817,15 +818,6 @@ validate-x86_64-windows-hadrian: cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows-hadrian: - <<: *nightly - extends: .build-windows-hadrian - variables: - MSYSTEM: MINGW32 - TEST_ENV: "i386-windows-hadrian" - cache: - key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" - .build-windows-make: extends: .build-windows stage: full-build @@ -882,34 +874,6 @@ release-x86_64-windows-integer-simple: BIGNUM_BACKEND: native BUILD_FLAVOUR: "perf" - -.build-i386-windows-make: - extends: .build-windows-make - variables: - MSYSTEM: MINGW32 - # Due to #15934 - BUILD_PROF_LIBS: "NO" - TEST_ENV: "i386-windows" - # Due to #17736 - allow_failure: true - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" - -validate-i386-windows: - extends: .build-i386-windows-make - variables: - BUILD_FLAVOUR: "perf" - -release-i386-windows: - <<: *release - extends: .build-i386-windows-make - variables: - BUILD_FLAVOUR: "perf" - -nightly-i386-windows: - <<: *nightly - extends: .build-i386-windows-make - ############################################################ # Cleanup ############################################################ ===================================== compiler/GHC/Core/Opt/Simplify/Monad.hs ===================================== @@ -43,6 +43,7 @@ import GHC.Utils.Panic (throwGhcExceptionIO, GhcException (..)) import GHC.Types.Basic ( IntWithInf, treatZeroAsInf, mkIntWithInf ) import Control.Monad ( ap ) import GHC.Core.Multiplicity ( pattern Many ) +import GHC.Exts( oneShot ) {- ************************************************************************ @@ -56,14 +57,25 @@ For the simplifier monad, we want to {\em thread} a unique supply and a counter. -} newtype SimplM result - = SM { unSM :: SimplTopEnv -- Envt that does not change much - -> UniqSupply -- We thread the unique supply because - -- constantly splitting it is rather expensive - -> SimplCount - -> IO (result, UniqSupply, SimplCount)} - -- we only need IO here for dump output + = SM' { unSM :: SimplTopEnv -- Envt that does not change much + -> UniqSupply -- We thread the unique supply because + -- constantly splitting it is rather expensive + -> SimplCount + -> IO (result, UniqSupply, SimplCount)} + -- We only need IO here for dump output deriving (Functor) +pattern SM :: (SimplTopEnv -> UniqSupply -> SimplCount + -> IO (result, UniqSupply, SimplCount)) + -> SimplM result +-- This pattern synonym makes the simplifier monad eta-expand, +-- which as a very beneficial effect on compiler performance +-- (worth a 1-2% reduction in bytes-allocated). See #18202. +-- See Note [The one-shot state monad trick] in GHC.Core.Unify +pattern SM m <- SM' m + where + SM m = SM' (oneShot m) + data SimplTopEnv = STE { st_flags :: DynFlags , st_max_ticks :: IntWithInf -- Max #ticks in this simplifier run ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -79,6 +79,11 @@ Highlights $(return []) instance C Bool where foo = True + * Support for 32-bit Windows has officially been dropped as Microsoft has + formally discontinued new 32-bit Windows 10 releases in 2020. See + :ghc-ticket:`18487` for details. + + Full details ------------ ===================================== rts/PrimOps.cmm ===================================== @@ -2360,6 +2360,7 @@ stg_mkApUpd0zh ( P_ bco ) stg_unpackClosurezh ( P_ closure ) { W_ info, ptrs, nptrs, p, ptrs_arr, dat_arr; + MAYBE_GC_P(stg_unpackClosurezh, closure); info = %GET_STD_INFO(UNTAG(closure)); prim_read_barrier; @@ -2375,12 +2376,13 @@ stg_unpackClosurezh ( P_ closure ) (len) = foreign "C" heap_view_closureSize(clos "ptr"); W_ ptrs_arr_sz, ptrs_arr_cards, dat_arr_sz; - dat_arr_sz = SIZEOF_StgArrBytes + WDS(len); - - ALLOC_PRIM_P (dat_arr_sz, stg_unpackClosurezh, closure); - - dat_arr = Hp - dat_arr_sz + WDS(1); + dat_arr_sz = SIZEOF_StgArrBytes + WDS(len); + ("ptr" dat_arr) = ccall allocateMightFail(MyCapability() "ptr", BYTES_TO_WDS(dat_arr_sz)); + if (dat_arr == NULL) (likely: False) { + jump stg_raisezh(base_GHCziIOziException_heapOverflow_closure); + } + TICK_ALLOC_PRIM(SIZEOF_StgArrBytes, WDS(len), 0); SET_HDR(dat_arr, stg_ARR_WORDS_info, CCCS); StgArrBytes_bytes(dat_arr) = WDS(len); ===================================== testsuite/tests/primops/should_run/T12492.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +import GHC.Exts +import GHC.IO + +main :: IO () +main = IO $ \s -> case newByteArray# 1032161# s of + (# s', mba# #) -> case unpackClosure# (unsafeCoerce# mba# :: Any) of + (# !_, _, _ #) -> (# s', () #) ===================================== testsuite/tests/primops/should_run/all.T ===================================== @@ -19,6 +19,7 @@ test('ArithWord8', omit_ways(['ghci']), compile_and_run, ['']) test('CmpInt8', normal, compile_and_run, ['']) test('CmpWord8', normal, compile_and_run, ['']) test('ShowPrim', normal, compile_and_run, ['']) +test('T12492', normal, compile_and_run, ['']) # These two tests use unboxed tuples, which GHCi doesn't support test('ArithInt16', omit_ways(['ghci']), compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b5174f38273ec93b4bb2a1c05aa5d20ca0da1fa3...61e1d542585b5be4e5fe26dc7e9245ff60efd32d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b5174f38273ec93b4bb2a1c05aa5d20ca0da1fa3...61e1d542585b5be4e5fe26dc7e9245ff60efd32d You're receiving 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 Jul 27 17:51:11 2020 From: gitlab at gitlab.haskell.org (Peter Trommler) Date: Mon, 27 Jul 2020 13:51:11 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18505 Message-ID: <5f1f140f64e3b_80b3f84901582f05336999@gitlab.haskell.org.mail> Peter Trommler pushed new branch wip/T18505 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18505 You're receiving 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 Jul 27 19:15:30 2020 From: gitlab at gitlab.haskell.org (Brandon Chinn) Date: Mon, 27 Jul 2020 15:15:30 -0400 Subject: [Git][ghc/ghc][wip/T16341] 3 commits: Update note Message-ID: <5f1f27d2df3a5_80b3f848601c0f85361798@gitlab.haskell.org.mail> Brandon Chinn pushed to branch wip/T16341 at Glasgow Haskell Compiler / GHC Commits: db407f3f by Brandon Chinn at 2020-07-27T10:35:52-07:00 Update note - - - - - 8855e414 by Brandon Chinn at 2020-07-27T11:12:36-07:00 Fix getting list of type variables for Functor derivation - - - - - 700f1868 by Brandon Chinn at 2020-07-27T12:15:25-07:00 Fix test - - - - - 3 changed files: - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Infer.hs - testsuite/tests/deriving/should_compile/T16341.hs Changes: ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -35,7 +35,7 @@ module GHC.Tc.Deriv.Generate ( ordOpTbl, boxConTbl, litConTbl, mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr, - getPossibleDataCons + getPossibleDataCons, getTyConArgs ) where #include "HsVersions.h" @@ -2523,7 +2523,17 @@ newAuxBinderRdrName loc parent occ_fun = do -- -- See Note [Filter out impossible GADT data constructors] getPossibleDataCons :: TyCon -> [Type] -> [DataCon] -getPossibleDataCons tycon tycon_args = filter (not . dataConCannotMatch tycon_args) $ tyConDataCons tycon +getPossibleDataCons tycon tycon_args = filter isPossible $ tyConDataCons tycon + where + isPossible = not . dataConCannotMatch (getTyConArgs tycon tycon_args) + +-- | Get the full list of TyCon args, given a partial instantiation. +-- +-- e.g. Given 'tycon: Foo a b' and 'tycon_args: [Int]', return '[Int, b]'. +getTyConArgs :: TyCon -> [Type] -> [Type] +getTyConArgs tycon tycon_args = tycon_args ++ map mkTyVarTy tycon_args_suffix + where + tycon_args_suffix = drop (length tycon_args) $ tyConTyVars tycon {- Note [Auxiliary binders] @@ -2747,8 +2757,18 @@ Note [Filter out impossible GADT data constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Some stock-derivable classes will filter out impossible GADT data constructors, -to rule out problematic constructors when deriving instances. Classes that -filter constructors: +to rule out problematic constructors when deriving instances. e.g. + +``` +data Foo a where + X :: Foo Int + Y :: (Bool -> Bool) -> Foo Bool +``` + +when deriving an instance on `Foo Int`, `Y` should be treated as if it didn't +exist in the first place. + +Classes that filter constructors: * Eq * Ord @@ -2765,8 +2785,9 @@ Classes that do not filter constructors: * Ix: only makes sense for GADTs with a single constructor * Read: `Read a` returns `a` instead of consumes `a`, so filtering data constructors would make this function _more_ partial instead of less -* Data: uses `tagToEnum` to pick the constructor, which could reference - the incorrect constructors if we filter out constructors +* Data: derived implementations of gunfold rely on a constructor-indexing + scheme that wouldn't work if certain constructors were filtered out +* Generic/Generic1: doesn't make sense for GADTs Classes that do not currently filter constructors may do so in the future, if there is a valid use-case and we have requirements for how they should work. ===================================== compiler/GHC/Tc/Deriv/Infer.hs ===================================== @@ -260,9 +260,7 @@ inferConstraintsStock (DerivInstTys { dit_cls_tys = cls_tys -- substitute each type variable with its counterpart in the derived -- instance. rep_tc_args lists each of these counterpart types in -- the same order as the type variables. - all_rep_tc_args - = rep_tc_args ++ map mkTyVarTy - (drop (length rep_tc_args) rep_tc_tvs) + all_rep_tc_args = getTyConArgs rep_tc rep_tc_args -- Stupid constraints stupid_constraints ===================================== testsuite/tests/deriving/should_compile/T16341.hs ===================================== @@ -8,6 +8,8 @@ module T16341 where +import Language.Haskell.TH.Syntax (Lift) + data Foo a where Foo1 :: Foo Int Foo2 :: (Bool -> Bool) -> Foo Bool View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/58960da7b7bf446035debddd1fc0b64f2afe68e4...700f1868b32a6cf081275941e6a9d7a4911605ec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/58960da7b7bf446035debddd1fc0b64f2afe68e4...700f1868b32a6cf081275941e6a9d7a4911605ec You're receiving 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 Jul 27 19:16:06 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 27 Jul 2020 15:16:06 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/backports Message-ID: <5f1f27f6de3d9_80b102000e853646b8@gitlab.haskell.org.mail> Ben Gamari deleted branch wip/backports 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 Jul 27 19:16:08 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 27 Jul 2020 15:16:08 -0400 Subject: [Git][ghc/ghc][ghc-8.10] 15 commits: rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Message-ID: <5f1f27f863801_80be82961053648e@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.10 at Glasgow Haskell Compiler / GHC Commits: 96a16275 by Ben Gamari at 2020-07-22T19:56:38-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. (cherry picked from commit 750a1595ef31cdc335f3bab045b2f19a9c43ff93) - - - - - 29d24d10 by Moritz Angermann at 2020-07-22T19:59:40-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. (cherry picked from commit aef523ea1254e8bb9e4143ad8f5994ca89ea9d2d) - - - - - 9ab76ca5 by Sylvain Henry at 2020-07-22T20:47:38-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. (cherry picked from commit 54b595c1b91ad9e686b5baf7640177becb372336) - - - - - e447bd2c by Sylvain Henry at 2020-07-22T22:57:09-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). (cherry picked from commit 499f3a2829d7c5a047c2ee87377d71ab2ea8c6d9) - - - - - f96a4b2c by Sylvain Henry at 2020-07-22T22:57:09-04:00 LLVM: refactor and comment register padding code (#17920) (cherry picked from commit 9bdc2a056f459b0e05ddbc49d978dfed547ecc13) - - - - - 36656d70 by Sylvain Henry at 2020-07-22T22:57:10-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 (cherry picked from commit aa54d1a2b2d2c89107cfa77d8c14a50d6ee9c140) - - - - - b7c216cb by Ben Gamari at 2020-07-22T22:57:10-04:00 Fix GhcThreaded setting This adopts a patch from NetBSD's packaging fixing the `GhcThreaded` option of the make build system. In addition we introduce a `ghcThreaded` option in hadrian's `Flavour` type. Also fix Hadrian's treatment of the `Use Threaded` entry in `settings`. Previously it would incorrectly claim `Use Threaded = True` if we were building the `threaded` runtime way. However, this is inconsistent with the `make` build system, which defines it to be whether the `ghc` executable is linked against the threaded runtime. Fixes #17692. - - - - - 55fac768 by Travis Whitaker at 2020-07-22T22:57:10-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. (cherry picked from commit 67738db10010fd28a8e997b5c8f83ea591b88a0e) (cherry picked from commit a228d0a83db06fbe81b1c74fe3b1aea3133cee50) - - - - - 83bcf37d by Joshua Price at 2020-07-26T15:05:52-04:00 Make `identifier` parse unparenthesized `->` (#18060) (cherry picked from commit d6203f24cf421749616a247c047a9b44192f963a) - - - - - 50f25994 by Simon Peyton Jones at 2020-07-26T15:05:52-04:00 Wrap an implication around class-sig kind errors Ticket #17841 showed that we can get a kind error in a class signature, but lack an enclosing implication that binds its skolems. This patch * Adds the wrapping implication: the new call to checkTvConstraints in tcClassDecl1 * Simplifies the API to checkTvConstraints, which was not otherwise called at all. * Simplifies TcErrors.report_unsolved by *not* initialising the TidyEnv from the typechecker lexical envt. It's enough to do so from the free vars of the unsolved constraints; and we get silly renamings if we add variables twice: once from the lexical scope and once from the implication constraint. (cherry picked from commit 3f431587c2db712136a3b5a353758ca63e1a5fd8) - - - - - a063768e by Simon Peyton Jones at 2020-07-26T15:05:52-04:00 Refactoring in TcSMonad This patch is just refactoring: no change in behaviour. I removed the rather complicated checkConstraintsTcS checkTvConstraintsTcS in favour of simpler functions emitImplicationTcS emitTvImplicationTcS pushLevelNoWorkList The last of these is a little strange, but overall it's much better I think. (cherry picked from commit 9d87ced6832e75fce1e01b67bc6b7d9d1cf31efb) - - - - - 05be81e8 by Simon Peyton Jones at 2020-07-26T15:05:52-04:00 Major improvements to the specialiser This patch is joint work of Alexis King and Simon PJ. It does some significant refactoring of the type-class specialiser. Main highlights: * We can specialise functions with types like f :: Eq a => a -> Ord b => b => blah where the classes aren't all at the front (#16473). Here we can correctly specialise 'f' based on a call like f @Int @Bool dEqInt x dOrdBool This change really happened in an earlier patch commit 2d0cf6252957b8980d89481ecd0b79891da4b14b Author: Sandy Maguire <sandy at sandymaguire.me> Date: Thu May 16 12:12:10 2019 -0400 work that this new patch builds directly on that work, and refactors it a bit. * We can specialise functions with implicit parameters (#17930) g :: (?foo :: Bool, Show a) => a -> String Previously we could not, but now they behave just like a non-class argument as in 'f' above. * We can specialise under-saturated calls, where some (but not all of the dictionary arguments are provided (#17966). For example, we can specialise the above 'f' based on a call map (f @Int dEqInt) xs even though we don't (and can't) give Ord dictionary. This may sound exotic, but #17966 is a program from the wild, and showed significant perf loss for functions like f, if you need saturation of all dictionaries. * We fix a buglet in which a floated dictionary had a bogus demand (#17810), by using zapIdDemandInfo in the NonRec case of specBind. * A tiny side benefit: we can drop dead arguments to specialised functions; see Note [Drop dead args from specialisations] * Fixed a bug in deciding what dictionaries are "interesting"; see Note [Keep the old dictionaries interesting] This is all achieved by by building on Sandy Macguire's work in defining SpecArg, which mkCallUDs uses to describe the arguments of the call. Main changes: * Main work is in specHeader, which marched down the [InBndr] from the function definition and the [SpecArg] from the call site, together. * specCalls no longer has an arity check; the entire mechanism now handles unders-saturated calls fine. * mkCallUDs decides on an argument-by-argument basis whether to specialise a particular dictionary argument; this is new. See mk_spec_arg in mkCallUDs. It looks as if there are many more lines of code, but I think that all the extra lines are comments! (cherry picked from commit 7052d7c7ce3418db9e66ad6ff31e80b2a2c724bb) - - - - - a10c6ddf by Simon Peyton Jones at 2020-07-26T15:05:52-04:00 Fix specialisation for DFuns When specialising a DFun we must take care to saturate the unfolding. See Note [Specialising DFuns] in Specialise. Fixes #18120 (cherry picked from commit 88e3c8150d2b2d96c3ebc0b2942c9af44071c511) - - - - - 5015d3ac by Ben Gamari at 2020-07-26T15:05:52-04:00 testsuite: Accept wibbles in specialiser test output - - - - - 6471cc6a by Moritz Angermann at 2020-07-26T15:05:52-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. (cherry picked from commit aedfeb0b2b22172a0dfca0fe0c020ac80539d6ae) - - - - - 30 changed files: - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/StgToCmm/Prof.hs - compiler/GHC/StgToCmm/Ticky.hs - compiler/GHC/StgToCmm/Utils.hs - compiler/cmm/CLabel.hs - compiler/cmm/CmmCallConv.hs - compiler/cmm/CmmParse.y - compiler/coreSyn/CoreSubst.hs - compiler/coreSyn/CoreUnfold.hs - compiler/deSugar/DsBinds.hs - compiler/ghc.cabal.in - compiler/ghc.mk - compiler/ghci/Linker.hs - compiler/llvmGen/LlvmCodeGen/Base.hs - compiler/llvmGen/LlvmCodeGen/CodeGen.hs - compiler/parser/Parser.y - compiler/specialise/Specialise.hs - compiler/typecheck/TcCanonical.hs - compiler/typecheck/TcClassDcl.hs - compiler/typecheck/TcErrors.hs - compiler/typecheck/TcEvidence.hs - compiler/typecheck/TcSMonad.hs - compiler/typecheck/TcSigs.hs - compiler/typecheck/TcTyClsDecls.hs - compiler/typecheck/TcUnify.hs - configure.ac - docs/users_guide/runtime_control.rst - ghc/ghc.mk - hadrian/cfg/system.config.in - hadrian/doc/user-settings.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc8800f9f482460ceb2d450137766e0350551740...6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc8800f9f482460ceb2d450137766e0350551740...6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 You're receiving 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 Jul 27 19:46:27 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 27 Jul 2020 15:46:27 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/runtests-refactor Message-ID: <5f1f2f13e5698_80b3f848c1e06f453704e3@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/runtests-refactor at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/runtests-refactor You're receiving 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 Jul 27 19:46:57 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 27 Jul 2020 15:46:57 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] Deleted 6 commits: testsuite: Refactor runtests.py Message-ID: <5f1f2f31e9dd_80b104e15b45370630@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline 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: 2680da51 by Ben Gamari at 2020-07-05T14:23:37-04:00 testsuite: Refactor runtests.py Trying to bring some order to the chaos of this module. Starting by moving most code to `main` and breaking out local function bindings. - - - - - 8617a7ff by Ben Gamari at 2020-07-05T17:25:53-04:00 testsuite: Refactor compiler configuration - - - - - 869bfae0 by Ben Gamari at 2020-07-05T19:29:41-04:00 Further refactoring - - - - - e3e762b6 by Ben Gamari at 2020-07-05T21:23:26-04:00 Fix it - - - - - 4b559f04 by Ben Gamari at 2020-07-05T22:16:44-04:00 Things - - - - - 2b239b32 by Ben Gamari at 2020-07-05T22:24:08-04:00 hi - - - - - 8 changed files: - hadrian/src/Settings/Builders/RunTest.hs - − testsuite/config/ghc - testsuite/driver/runtests.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - + testsuite/driver/testsuite_config.py - testsuite/mk/test.mk - testsuite/tests/concurrent/prog002/all.T Changes: ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -103,6 +103,7 @@ runTestBuilderArgs = builder RunTest ? do -- TODO: set CABAL_MINIMAL_BUILD/CABAL_PLUGIN_BUILD mconcat [ arg $ "testsuite/driver/runtests.py" , pure [ "--rootdir=" ++ testdir | testdir <- rootdirs ] + , arg "--extra-hc-flag", arg ghcFlags , arg "-e", arg $ "windows=" ++ show windowsHost , arg "-e", arg $ "darwin=" ++ show osxHost , arg "-e", arg $ "config.local=False" @@ -111,23 +112,20 @@ runTestBuilderArgs = builder RunTest ? do , arg "-e", arg $ "config.accept_platform=" ++ show acceptPlatform , arg "-e", arg $ "config.accept_os=" ++ show acceptOS , arg "-e", arg $ "config.exeext=" ++ quote (if null exe then "" else "."<>exe) - , arg "-e", arg $ "config.compiler_debugged=" ++ - show debugged + , arg "-e", arg $ "config.compiler_debugged=" ++ show debugged , arg "-e", arg $ asBool "ghc_with_native_codegen=" withNativeCodeGen , arg "-e", arg $ "config.have_interp=" ++ show withInterpreter , arg "-e", arg $ "config.unregisterised=" ++ show unregisterised - , arg "-e", arg $ "ghc_compiler_always_flags=" ++ quote ghcFlags - , arg "-e", arg $ asBool "ghc_with_dynamic_rts=" (hasRtsWay "dyn") - , arg "-e", arg $ asBool "ghc_with_threaded_rts=" (hasRtsWay "thr") + , arg "-e", arg $ asBool "config.ghc_with_dynamic_rts=" (hasRtsWay "dyn") + , arg "-e", arg $ asBool "config.ghc_with_threaded_rts=" (hasRtsWay "thr") , arg "-e", arg $ asBool "config.have_vanilla=" (hasLibWay vanilla) , arg "-e", arg $ asBool "config.have_dynamic=" (hasLibWay dynamic) , arg "-e", arg $ asBool "config.have_profiling=" (hasLibWay profiling) , arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) - , arg "-e", arg $ asBool "ghc_with_smp=" withSMP - , arg "-e", arg $ asBool "ghc_with_llvm=" withLlvm - + , arg "-e", arg $ asBool "config.ghc_with_smp=" withSMP + , arg "-e", arg $ asBool "config.ghc_with_llvm=" withLlvm , arg "-e", arg $ "config.ghc_dynamic_by_default=" ++ show hasDynamicByDefault , arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic ===================================== testsuite/config/ghc deleted ===================================== @@ -1,266 +0,0 @@ -# vim: set filetype=python: - -import re - -# Testsuite configuration setup for GHC -# -# This file is Python source -# -config.compiler_always_flags = ghc_compiler_always_flags.split() - -# By default, the 'normal' and 'hpc' ways are enabled. In addition, certain -# ways are enabled automatically if this GHC supports them. Ways that fall in -# this group are 'optasm', 'optllvm', 'profasm', 'threaded1', 'threaded2', -# 'profthreaded', 'ghci', and whichever of 'static/dyn' is not this GHC's -# default mode. Other ways should be set explicitly from .T files. -config.compile_ways = ['normal', 'hpc'] -config.run_ways = ['normal', 'hpc'] - -# ways that are not enabled by default, but can always be invoked explicitly -config.other_ways = ['prof', 'normal_h', - 'prof_hc_hb','prof_hb', - 'prof_hd','prof_hy','prof_hr', - 'sanity', - 'threaded1_ls', 'threaded2_hT', 'debug_numa', - 'llvm', 'debugllvm', - 'profllvm', 'profoptllvm', 'profthreadedllvm', - 'debug', - 'ghci-ext', 'ghci-ext-prof', - 'ext-interp', - 'nonmoving', - 'nonmoving_thr', - 'nonmoving_thr_ghc', - 'compacting_gc', - ] - -if ghc_with_native_codegen: - config.compile_ways.append('optasm') - config.run_ways.append('optasm') - -if config.have_profiling: - config.compile_ways.append('profasm') - config.run_ways.append('profasm') - -if config.have_interp: - config.run_ways.append('ghci') - -if ghc_with_threaded_rts: - config.run_ways.append('threaded1') - if ghc_with_smp: - config.have_smp = True - config.run_ways.append('threaded2') - if config.speed == 0: - config.run_ways.append('nonmoving_thr') - -if ghc_with_dynamic_rts: - config.have_shared_libs = True - -if config.ghc_dynamic_by_default and config.have_vanilla == 1: - config.run_ways.append('static') -else: - if ghc_with_dynamic_rts: - config.run_ways.append('dyn') - -if (config.have_profiling and ghc_with_threaded_rts): - config.run_ways.append('profthreaded') - -if (ghc_with_llvm and not config.unregisterised): - config.compile_ways.append('optllvm') - config.run_ways.append('optllvm') - -config.way_flags = { - 'normal' : [], - 'normal_h' : [], - 'g1' : [], - 'nursery_chunks' : [], - 'debug_numa' : ['-threaded', '-debug'], - 'optasm' : ['-O', '-fasm'], - 'llvm' : ['-fllvm'], - 'optllvm' : ['-O', '-fllvm'], - 'debugllvm' : ['-fllvm', '-keep-llvm-files'], - 'prof' : ['-prof', '-static', '-fprof-auto', '-fasm'], - 'prof_no_auto' : ['-prof', '-static', '-fasm'], - 'profasm' : ['-O', '-prof', '-static', '-fprof-auto'], - 'profthreaded' : ['-O', '-prof', '-static', '-fprof-auto', '-threaded'], - 'ghci' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '+RTS', '-I0.1', '-RTS'] + (['-fghci-leak-check'] if not config.compiler_debugged else []), - 'sanity' : ['-debug'], - 'threaded1' : ['-threaded', '-debug'], - 'threaded1_ls' : ['-threaded', '-debug'], - 'threaded2' : ['-O', '-threaded', '-eventlog'], - 'threaded2_hT' : ['-O', '-threaded'], - 'hpc' : ['-O', '-fhpc'], - 'prof_hc_hb' : ['-O', '-prof', '-static', '-fprof-auto'], - 'prof_hb' : ['-O', '-prof', '-static', '-fprof-auto'], - 'prof_hd' : ['-O', '-prof', '-static', '-fprof-auto'], - 'prof_hy' : ['-O', '-prof', '-static', '-fprof-auto'], - 'prof_hr' : ['-O', '-prof', '-static', '-fprof-auto'], - 'dyn' : ['-O', '-dynamic'], - 'static' : ['-O', '-static'], - 'debug' : ['-O', '-g', '-dannot-lint'], - # llvm variants... - 'profllvm' : ['-prof', '-static', '-fprof-auto', '-fllvm'], - 'profoptllvm' : ['-O', '-prof', '-static', '-fprof-auto', '-fllvm'], - 'profthreadedllvm' : ['-O', '-prof', '-static', '-fprof-auto', '-threaded', '-fllvm'], - 'ghci-ext' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '-fexternal-interpreter', '+RTS', '-I0.1', '-RTS'], - 'ghci-ext-prof' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '-fexternal-interpreter', '-prof', '+RTS', '-I0.1', '-RTS'], - 'ext-interp' : ['-fexternal-interpreter'], - 'nonmoving' : [], - 'nonmoving_thr': ['-threaded'], - 'nonmoving_thr_ghc': ['+RTS', '-xn', '-N2', '-RTS', '-threaded'], - 'compacting_gc': [], - } - -config.way_rts_flags = { - 'normal' : [], - 'normal_h' : ['-h'], # works without -prof - 'g1' : ['-G1'], - 'nursery_chunks' : ['-n32k'], - 'debug_numa' : ['-N2', '--debug-numa=2'], - 'optasm' : [], - 'llvm' : [], - 'optllvm' : [], - 'debugllvm' : [], - 'prof' : ['-p'], - 'prof_no_auto' : ['-p'], - 'profasm' : ['-hc', '-p'], # test heap profiling too - 'profthreaded' : ['-p'], - 'ghci' : [], - 'sanity' : ['-DS'], - 'threaded1' : [], - 'threaded1_ls' : ['-ls'], - 'threaded2' : ['-N2', '-ls'], - 'threaded2_hT' : ['-N2', '-hT'], - 'hpc' : [], - 'prof_hc_hb' : ['-hc', '-hbvoid'], - 'prof_hb' : ['-hb'], - 'prof_hd' : ['-hd'], - 'prof_hy' : ['-hy'], - 'prof_hr' : ['-hr'], - 'dyn' : [], - 'static' : [], - 'debug' : [], - # llvm variants... - 'profllvm' : ['-p'], - 'profoptllvm' : ['-hc', '-p'], - 'profthreadedllvm' : ['-p'], - 'ghci-ext' : [], - 'ghci-ext-prof' : [], - 'ext-interp' : [], - 'nonmoving' : ['-xn'], - 'nonmoving_thr' : ['-xn', '-N2'], - 'nonmoving_thr_ghc': ['-xn', '-N2'], - 'compacting_gc': ['-c'], - } - -# Useful classes of ways that can be used with only_ways(), omit_ways() and -# expect_broken_for(). - -prof_ways = [x[0] for x in config.way_flags.items() - if '-prof' in x[1]] - -threaded_ways = [x[0] for x in config.way_flags.items() - if '-threaded' in x[1] or 'ghci' == x[0]] - -# Ways which run with multiple capabilities -concurrent_ways = [name for name, flags in config.way_flags.items() - if '-threaded' in flags or 'ghci' == name - if '-N2' in config.way_rts_flags.get(name, [])] - -opt_ways = [x[0] for x in config.way_flags.items() - if '-O' in x[1]] - -llvm_ways = [x[0] for x in config.way_flags.items() - if '-fflvm' in x[1]] - - -def get_compiler_info(): - s = getStdout([config.compiler, '--info']) - s = re.sub('[\r\n]', '', s) - compilerInfoDict = dict(eval(s)) - s = getStdout([config.compiler, '+RTS', '--info']) - s = re.sub('[\r\n]', '', s) - rtsInfoDict = dict(eval(s)) - - config.have_ncg = compilerInfoDict.get("Have native code generator", "NO") == "YES" - - # Whether GHC itself was built using the LLVM backend. We need to know this - # since some tests in ext-interp fail when stage2 ghc is built using - # LLVM. See #16087. - # - # The condition here is a bit approximate: we assume that if stage2 doesn't - # have the NCG and isn't unregisterised then it must be using the LLVM - # backend by default. - config.ghc_built_by_llvm = not config.have_ncg and not config.unregisterised - - config.have_RTS_linker = compilerInfoDict.get("target has RTS linker", "NO") == "YES" - # external interpreter needs RTS linker support - # If the field is not present (GHC 8.0 and earlier), assume we don't - # have -fexternal-interpreter (though GHC 8.0 actually does) - # so we can still run most tests. - config.have_ext_interp = compilerInfoDict.get("target has RTS linker", "NO") == "YES" - - # See Note [Replacing backward slashes in config.libdir]. - config.libdir = compilerInfoDict['LibDir'].replace('\\', '/') - - if re.match(".*_p(_.*|$)", rtsInfoDict["RTS way"]): - config.compiler_profiled = True - else: - config.compiler_profiled = False - - try: - config.package_conf_cache_file = compilerInfoDict["Global Package DB"] + '/package.cache' - except: - config.package_conf_cache_file = '' - - # See Note [WayFlags] - if config.ghc_dynamic: - config.ghc_th_way_flags = "-dynamic" - config.ghci_way_flags = "-dynamic" - config.plugin_way_flags = "-dynamic" - config.ghc_th_way = "dyn" - config.ghc_plugin_way = "dyn" - elif config.compiler_profiled: - config.ghc_th_way_flags = "-prof" - config.ghci_way_flags = "-prof" - config.plugin_way_flags = "-prof" - config.ghc_th_way = "prof" - config.ghc_plugin_way = "prof" - else: - config.ghc_th_way_flags = "-static" - config.ghci_way_flags = "-static" - config.plugin_way_flags = "-static" - config.ghc_th_way = "normal" - config.ghc_plugin_way = "normal" - -# Note [Replacing backward slashes in config.libdir] -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# We *do* need to replace backslashes in config.libdir, for the following -# reason: -# -# * Tests use config.libdir as follows: -# -# extra_run_opts('"' + config.libdir + '"') -# -# The double quotes are there because config.libdir might contain -# spaces. -# -# * This string is then written /as is/ to .genscript in -# testlib.interpreter_run: -# -# script.write(':set args ' + opts.extra_run_opts + '\n') -# -# * But GHCi expects the arguments to ':set args' to be proper Haskell -# strings (when they are quoted), with backslashes escaped. Since -# config.libdir contains single backslash characters, tests such as T5313 -# will fail for WAY=ghci with "Pattern match failure in do expression". -# -# Arguably the above code for writing `:set args` should be smarter. This -# is tricky to get right though, because in GHCI `:set args foo\bar` (no -# double quotes) works perfectly fine, and is interpreted as the Haskell -# string "foo\\bar". Therefore, simply escaping all backward slashes in -# opts.extra_run_opts before concatenating it with ':set args' is not right -# either. -# -# Replacing backslashes to forward slashes in config.libdir works around the -# problem. ===================================== testsuite/driver/runtests.py ===================================== @@ -5,6 +5,7 @@ # import argparse +from copy import copy import signal import sys import os @@ -14,6 +15,7 @@ import tempfile import time import re import traceback +import datetime # We don't actually need subprocess in runtests.py, but: # * We do need it in testlibs.py @@ -26,212 +28,27 @@ import subprocess from testutil import getStdout, Watcher, str_warn, str_info from testglobals import getConfig, ghc_env, getTestRun, TestConfig, \ TestOptions, brokens, PerfMetric -from my_typing import TestName +from my_typing import TestName, List from perf_notes import MetricChange, GitRef, inside_git_repo, is_worktree_dirty, format_perf_stat +import perf_notes as Perf +import testsuite_config from junit import junit import term_color from term_color import Color, colored import cpu_features -# Readline sometimes spews out ANSI escapes for some values of TERM, -# which result in test failures. Thus set TERM to a nice, simple, safe -# value. -os.environ['TERM'] = 'vt100' -ghc_env['TERM'] = 'vt100' - -global config -config = getConfig() # get it from testglobals - def signal_handler(signal, frame): stopNow() -def get_compiler_info() -> TestConfig: - """ Overriddden by configuration file. """ - raise NotImplementedError - -# ----------------------------------------------------------------------------- -# cmd-line options - -parser = argparse.ArgumentParser(description="GHC's testsuite driver") -perf_group = parser.add_mutually_exclusive_group() - -parser.add_argument("-e", action='append', help="A string to execute from the command line.") -parser.add_argument("--config-file", action="append", help="config file") -parser.add_argument("--config", action='append', help="config field") -parser.add_argument("--rootdir", action='append', help="root of tree containing tests (default: .)") -parser.add_argument("--metrics-file", help="file in which to save (append) the performance test metrics. If omitted, git notes will be used.") -parser.add_argument("--summary-file", help="file in which to save the (human-readable) summary") -parser.add_argument("--no-print-summary", action="store_true", help="should we print the summary?") -parser.add_argument("--only", action="append", help="just this test (can be give multiple --only= flags)") -parser.add_argument("--way", action="append", help="just this way") -parser.add_argument("--skipway", action="append", help="skip this way") -parser.add_argument("--threads", type=int, help="threads to run simultaneously") -parser.add_argument("--verbose", type=int, choices=[0,1,2,3,4,5], help="verbose (Values 0 through 5 accepted)") -parser.add_argument("--junit", type=argparse.FileType('wb'), help="output testsuite summary in JUnit format") -parser.add_argument("--broken-test", action="append", default=[], help="a test name to mark as broken for this run") -parser.add_argument("--test-env", default='local', help="Override default chosen test-env.") -parser.add_argument("--perf-baseline", type=GitRef, metavar='COMMIT', help="Baseline commit for performance comparsons.") -perf_group.add_argument("--skip-perf-tests", action="store_true", help="skip performance tests") -perf_group.add_argument("--only-perf-tests", action="store_true", help="Only do performance tests") - -args = parser.parse_args() - -# Initialize variables that are set by the build system with -e -windows = False -darwin = False - -if args.e: - for e in args.e: - exec(e) - -if args.config_file: - for arg in args.config_file: - exec(open(arg).read()) - -if args.config: - for arg in args.config: - field, value = arg.split('=', 1) - setattr(config, field, value) - -all_ways = config.run_ways+config.compile_ways+config.other_ways - -if args.rootdir: - config.rootdirs = args.rootdir - -config.metrics_file = args.metrics_file -hasMetricsFile = config.metrics_file is not None -config.summary_file = args.summary_file -config.no_print_summary = args.no_print_summary -config.baseline_commit = args.perf_baseline - -if args.only: - config.only = args.only - config.run_only_some_tests = True - -if args.way: - for way in args.way: - if way not in all_ways: - print('WARNING: Unknown WAY %s in --way' % way) - else: - config.cmdline_ways += [way] - if way in config.other_ways: - config.run_ways += [way] - config.compile_ways += [way] - -if args.skipway: - for way in args.skipway: - if way not in all_ways: - print('WARNING: Unknown WAY %s in --skipway' % way) - - config.other_ways = [w for w in config.other_ways if w not in args.skipway] - config.run_ways = [w for w in config.run_ways if w not in args.skipway] - config.compile_ways = [w for w in config.compile_ways if w not in args.skipway] - -config.broken_tests |= {TestName(t) for t in args.broken_test} - -if args.threads: - config.threads = args.threads - config.use_threads = True - -if args.verbose is not None: - config.verbose = args.verbose - -# Note force skip perf tests: skip if this is not a git repo (estimated with inside_git_repo) -# and no metrics file is given. In this case there is no way to read the previous commit's -# perf test results, nor a way to store new perf test results. -forceSkipPerfTests = not hasMetricsFile and not inside_git_repo() -config.skip_perf_tests = args.skip_perf_tests or forceSkipPerfTests -config.only_perf_tests = args.only_perf_tests - -if args.test_env: - config.test_env = args.test_env - -config.cygwin = False -config.msys = False - -if windows: - h = os.popen('uname -s', 'r') - v = h.read() - h.close() - if v.startswith("CYGWIN"): - config.cygwin = True - elif v.startswith("MINGW") or v.startswith("MSYS"): -# msys gives "MINGW32" -# msys2 gives "MINGW_NT-6.2" or "MSYS_NT-6.3" - config.msys = True - else: - raise Exception("Can't detect Windows terminal type") - -# Try to use UTF8 -if windows: - import ctypes - # Windows and mingw* Python provide windll, msys2 python provides cdll. - if hasattr(ctypes, 'WinDLL'): - mydll = ctypes.WinDLL # type: ignore - else: - mydll = ctypes.CDLL - - # This actually leaves the terminal in codepage 65001 (UTF8) even - # after python terminates. We ought really remember the old codepage - # and set it back. - kernel32 = mydll('kernel32.dll') - if kernel32.SetConsoleCP(65001) == 0: - raise Exception("Failure calling SetConsoleCP(65001)") - if kernel32.SetConsoleOutputCP(65001) == 0: - raise Exception("Failure calling SetConsoleOutputCP(65001)") - - # register the interrupt handler - signal.signal(signal.SIGINT, signal_handler) -else: - # Try and find a utf8 locale to use - # First see if we already have a UTF8 locale - h = os.popen('locale | grep LC_CTYPE | grep -i utf', 'r') - v = h.read() - h.close() - if v == '': - # We don't, so now see if 'locale -a' works - h = os.popen('locale -a | grep -F .', 'r') - v = h.read() - h.close() - if v != '': - # If it does then use the first utf8 locale that is available - h = os.popen('locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') - v = h.readline().strip() - h.close() - if v != '': - os.environ['LC_ALL'] = v - ghc_env['LC_ALL'] = v - print("setting LC_ALL to", v) - else: - print('WARNING: No UTF8 locale found.') - print('You may get some spurious test failures.') - -# https://stackoverflow.com/a/22254892/1308058 -def supports_colors(): - """ - Returns True if the running system's terminal supports color, and False - otherwise. - """ - plat = sys.platform - supported_platform = plat != 'Pocket PC' and (plat != 'win32' or - 'ANSICON' in os.environ) - # isatty is not always implemented, #6223. - is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() - if not supported_platform or not is_a_tty: - return False - return True - -config.supports_colors = supports_colors() -term_color.enable_color = config.supports_colors - -# This has to come after arg parsing as the args can change the compiler -get_compiler_info() - -# Can't import this earlier as we need to know if threading will be -# enabled or not -from testlib import * +# Globals +config = getConfig() # get it from testglobals +windows = False # type: bool +cygwin = False # type: bool +darwin = False # type: bool +tempdir = '' # type: str -def format_path(path): +def format_path(path) -> str: + global config, windows if windows: if os.pathsep == ':': # If using msys2 python instead of mingw we have to change the drive @@ -246,101 +63,102 @@ def format_path(path): path = re.sub('\\\\', '/', path) return path -# On Windows we need to set $PATH to include the paths to all the DLLs -# in order for the dynamic library tests to work. -if windows or darwin: - pkginfo = getStdout([config.ghc_pkg, 'dump']) - topdir = config.libdir - if windows: - mingw = os.path.abspath(os.path.join(topdir, '../mingw/bin')) - mingw = format_path(mingw) - ghc_env['PATH'] = os.pathsep.join([ghc_env.get("PATH", ""), mingw]) - for line in pkginfo.split('\n'): - if line.startswith('library-dirs:'): - path = line.rstrip() - path = re.sub('^library-dirs: ', '', path) - # Use string.replace instead of re.sub, because re.sub - # interprets backslashes in the replacement string as - # escape sequences. - path = path.replace('$topdir', topdir) - if path.startswith('"'): - path = re.sub('^"(.*)"$', '\\1', path) - path = re.sub('\\\\(.)', '\\1', path) - if windows: - path = format_path(path) - ghc_env['PATH'] = os.pathsep.join([path, ghc_env.get("PATH", "")]) - else: - # darwin - ghc_env['DYLD_LIBRARY_PATH'] = os.pathsep.join([path, ghc_env.get("DYLD_LIBRARY_PATH", "")]) - -testopts_local.x = TestOptions() - -# if timeout == -1 then we try to calculate a sensible value -if config.timeout == -1: - config.timeout = int(read_no_crs(config.top + '/timeout/calibrate.out')) - -print('Timeout is ' + str(config.timeout)) -print('Known ways: ' + ', '.join(config.other_ways)) -print('Run ways: ' + ', '.join(config.run_ways)) -print('Compile ways: ' + ', '.join(config.compile_ways)) - -# Try get allowed performance changes from the git commit. -try: - config.allowed_perf_changes = Perf.get_allowed_perf_changes() -except subprocess.CalledProcessError: - print('Failed to get allowed metric changes from the HEAD git commit message.') - -print('Allowing performance changes in: ' + ', '.join(config.allowed_perf_changes.keys())) - -# ----------------------------------------------------------------------------- -# The main dude - -if config.rootdirs == []: - config.rootdirs = ['.'] - -t_files = list(findTFiles(config.rootdirs)) - -print('Found', len(t_files), '.T files...') - -t = getTestRun() # type: TestRun - -# Avoid cmd.exe built-in 'date' command on Windows -t.start_time = datetime.datetime.now() - -print('Beginning test run at', t.start_time.strftime("%c %Z")) - -# For reference -try: - print('Detected CPU features: ', cpu_features.get_cpu_features()) -except Exception as e: - print('Failed to detect CPU features: ', e) - -sys.stdout.flush() -# we output text, which cannot be unbuffered -sys.stdout = os.fdopen(sys.__stdout__.fileno(), "w") - -if config.local: - tempdir = '' -else: - # See note [Running tests in /tmp] - tempdir = tempfile.mkdtemp('', 'ghctest-') - - # opts.testdir should be quoted when used, to make sure the testsuite - # keeps working when it contains backward slashes, for example from - # using os.path.join. Windows native and mingw* python - # (/mingw64/bin/python) set `os.path.sep = '\\'`, while msys2 python - # (/bin/python, /usr/bin/python or /usr/local/bin/python) sets - # `os.path.sep = '/'`. - # To catch usage of unquoted opts.testdir early, insert some spaces into - # tempdir. - tempdir = os.path.join(tempdir, 'test spaces') +# https://stackoverflow.com/a/22254892/1308058 +def supports_colors(): + """ + Returns True if the running system's terminal supports color, and False + otherwise. + """ + plat = sys.platform + supported_platform = plat != 'Pocket PC' and (plat != 'win32' or + 'ANSICON' in os.environ) + # isatty is not always implemented, #6223. + is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() + if not supported_platform or not is_a_tty: + return False + return True -def cleanup_and_exit(exitcode): - if config.cleanup and tempdir: - shutil.rmtree(tempdir, ignore_errors=True) - exit(exitcode) +def setup_locale() -> None: + """ + Try to use UTF-8 + """ + global windows -def tabulate_metrics(metrics: List[PerfMetric]) -> None: + if windows: + import ctypes + # Windows and mingw* Python provide windll, msys2 python provides cdll. + if hasattr(ctypes, 'WinDLL'): + mydll = ctypes.WinDLL # type: ignore + else: + mydll = ctypes.CDLL + + # This actually leaves the terminal in codepage 65001 (UTF8) even + # after python terminates. We ought really remember the old codepage + # and set it back. + kernel32 = mydll('kernel32.dll') + if kernel32.SetConsoleCP(65001) == 0: + raise Exception("Failure calling SetConsoleCP(65001)") + if kernel32.SetConsoleOutputCP(65001) == 0: + raise Exception("Failure calling SetConsoleOutputCP(65001)") + + # register the interrupt handler + signal.signal(signal.SIGINT, signal_handler) + else: + # Try and find a utf8 locale to use + # First see if we already have a UTF8 locale + h = os.popen('locale | grep LC_CTYPE | grep -i utf', 'r') + v = h.read() + h.close() + if v == '': + # We don't, so now see if 'locale -a' works + h = os.popen('locale -a | grep -F .', 'r') + v = h.read() + h.close() + if v != '': + # If it does then use the first utf8 locale that is available + h = os.popen('locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') + v = h.readline().strip() + h.close() + if v != '': + os.environ['LC_ALL'] = v + ghc_env['LC_ALL'] = v + print("setting LC_ALL to", v) + else: + print('WARNING: No UTF8 locale found.') + print('You may get some spurious test failures.') + +def setup_path() -> None: + """ + On Windows we need to set $PATH to include the paths to all the DLLs + in order for the dynamic library tests to work. + """ + global windows, darwin + if windows or darwin: + pkginfo = getStdout([config.ghc_pkg, 'dump']) + topdir = config.libdir + if windows: + mingw = os.path.abspath(os.path.join(topdir, '../mingw/bin')) + mingw = format_path(mingw) + ghc_env['PATH'] = os.pathsep.join([ghc_env.get("PATH", ""), mingw]) + for line in pkginfo.split('\n'): + if line.startswith('library-dirs:'): + path = line.rstrip() + path = re.sub('^library-dirs: ', '', path) + # Use string.replace instead of re.sub, because re.sub + # interprets backslashes in the replacement string as + # escape sequences. + path = path.replace('$topdir', topdir) + if path.startswith('"'): + path = re.sub('^"(.*)"$', '\\1', path) + path = re.sub('\\\\(.)', '\\1', path) + if windows: + path = format_path(path) + ghc_env['PATH'] = os.pathsep.join([path, ghc_env.get("PATH", "")]) + else: + # darwin + ghc_env['DYLD_LIBRARY_PATH'] = os.pathsep.join([path, ghc_env.get("DYLD_LIBRARY_PATH", "")]) + +def tabulate_perf_metrics(metrics: List[PerfMetric]) -> None: for metric in sorted(metrics, key=lambda m: (m.stat.test, m.stat.way, m.stat.metric)): print("{test:24} {metric:40} {value:15.3f}".format( test = "{}({})".format(metric.stat.test, metric.stat.way), @@ -360,81 +178,21 @@ def tabulate_metrics(metrics: List[PerfMetric]) -> None: rel = rel )) -# First collect all the tests to be run -t_files_ok = True -for file in t_files: - if_verbose(2, '====> Scanning %s' % file) - newTestDir(tempdir, os.path.dirname(file)) - try: - with io.open(file, encoding='utf8') as f: - src = f.read() - - exec(src) - except Exception as e: - traceback.print_exc() - framework_fail(None, None, 'exception: %s' % e) - t_files_ok = False - -for name in config.only: - if t_files_ok: - # See Note [Mutating config.only] - framework_fail(name, None, 'test not found') - else: - # Let user fix .T file errors before reporting on unfound tests. - # The reason the test can not be found is likely because of those - # .T file errors. - pass - -if config.list_broken: - print('') - print('Broken tests:') - print('\n '.join('#{ticket}({a}/{b})'.format(ticket=ticket, a=a, b=b) - for ticket, a, b in brokens)) - print('') - - if t.framework_failures: - print('WARNING:', len(t.framework_failures), 'framework failures!') - print('') -else: - # completion watcher - watcher = Watcher(len(parallelTests)) - - # Now run all the tests - try: - for oneTest in parallelTests: - if stopping(): - break - oneTest(watcher) - - # wait for parallel tests to finish - if not stopping(): - watcher.wait() - - # Run the following tests purely sequential - config.use_threads = False - for oneTest in aloneTests: - if stopping(): - break - oneTest(watcher) - except KeyboardInterrupt: - pass - - # flush everything before we continue - sys.stdout.flush() - +def print_perf_summary(skip_perf_tests: bool, force_skip_perf_tests: bool) -> None: # Dump metrics data. + t = getTestRun() print("\nPerformance Metrics (test environment: {}):\n".format(config.test_env)) if config.baseline_commit: print('Performance baseline: %s\n' % config.baseline_commit) if any(t.metrics): - tabulate_metrics(t.metrics) + tabulate_perf_metrics(t.metrics) else: print("\nNone collected.") print("") - # Warn if had to force skip perf tests (see Note force skip perf tests). + # Warn if had to force skip perf tests (see Note [force skip perf tests]). spacing = " " - if forceSkipPerfTests and not args.skip_perf_tests: + if force_skip_perf_tests and not skip_perf_tests: print() print(str_warn('Skipping All Performance Tests') + ' `git` exited with non-zero exit code.') print(spacing + 'Git is required because performance test results are compared with ancestor git commits\' results (stored with git notes).') @@ -455,11 +213,11 @@ else: ' the missing metrics. Alternatively, a baseline may be' + \ ' recovered from ci results once fetched:\n\n' + \ spacing + 'git fetch ' + \ - 'https://gitlab.haskell.org/ghc/ghc-performance-notes.git' + \ - ' refs/notes/perf:refs/notes/' + Perf.CiNamespace + 'https://gitlab.haskell.org/ghc/ghc-performance-notes.git' + \ + ' refs/notes/perf:refs/notes/' + Perf.CiNamespace else: reason = "this is not a git repo so the previous git commit's" + \ - " metrics cannot be loaded from git notes:" + " metrics cannot be loaded from git notes:" fix = "" print() print(str_warn('Missing Baseline Metrics') + \ @@ -478,40 +236,317 @@ else: print(Perf.allow_changes_string([(m.change, m.stat) for m in t.metrics])) print('-' * 25) - summary(t, sys.stdout, config.no_print_summary, config.supports_colors) +def main() -> None: + global config, windows, darwin, tempdir + + # Readline sometimes spews out ANSI escapes for some values of TERM, + # which result in test failures. Thus set TERM to a nice, simple, safe + # value. + os.environ['TERM'] = 'vt100' + ghc_env['TERM'] = 'vt100' + + # ----------------------------------------------------------------------------- + # cmd-line options + + parser = argparse.ArgumentParser(description="GHC's testsuite driver") + perf_group = parser.add_mutually_exclusive_group() + + parser.add_argument("-e", action='append', help="A string to execute from the command line.") + parser.add_argument("--config-file", action="append", help="config file") + parser.add_argument("--config", action='append', help="config field") + parser.add_argument("--rootdir", action='append', help="root of tree containing tests (default: .)") + parser.add_argument("--metrics-file", help="file in which to save (append) the performance test metrics. If omitted, git notes will be used.") + parser.add_argument("--summary-file", help="file in which to save the (human-readable) summary") + parser.add_argument("--no-print-summary", action="store_true", help="should we print the summary?") + parser.add_argument("--only", action="append", help="just this test (can be give multiple --only= flags)") + parser.add_argument("--way", action="append", help="just this way") + parser.add_argument("--skipway", action="append", help="skip this way") + parser.add_argument("--threads", type=int, help="threads to run simultaneously") + parser.add_argument("--verbose", type=int, choices=[0,1,2,3,4,5], help="verbose (Values 0 through 5 accepted)") + parser.add_argument("--junit", type=argparse.FileType('wb'), help="output testsuite summary in JUnit format") + parser.add_argument("--broken-test", action="append", default=[], help="a test name to mark as broken for this run") + parser.add_argument('--extra-hc-flag', action="append", default=[], help="extra flags to pass to the Haskell compiler") + parser.add_argument("--test-env", default='local', help="Override default chosen test-env.") + parser.add_argument("--perf-baseline", type=GitRef, metavar='COMMIT', help="Baseline commit for performance comparsons.") + perf_group.add_argument("--skip-perf-tests", action="store_true", help="skip performance tests") + perf_group.add_argument("--only-perf-tests", action="store_true", help="Only do performance tests") + + args = parser.parse_args() + + # Initialize variables that are set by the build system with -e + windows = False + darwin = False + + if args.e: + for e in args.e: + exec(e) + + ts_config = testsuite_config.GHCTestsuiteConfig + ts_config_globals = ts_config.init_config(config) + + if args.config: + for arg in args.config: + field, value = arg.split('=', 1) + setattr(config, field, value) + + all_ways = config.run_ways+config.compile_ways+config.other_ways + + if args.rootdir: + config.rootdirs = args.rootdir + + config.compiler_always_flags = [ + flag + for flags in args.extra_hc_flag + for flag in flags.split() + ] + + config.metrics_file = args.metrics_file + hasMetricsFile = config.metrics_file is not None + config.summary_file = args.summary_file + config.no_print_summary = args.no_print_summary + config.baseline_commit = args.perf_baseline + + if args.only: + config.only = args.only + config.run_only_some_tests = True + + if args.way: + for way in args.way: + if way not in all_ways: + print('WARNING: Unknown WAY %s in --way' % way) + else: + config.cmdline_ways += [way] + if way in config.other_ways: + config.run_ways += [way] + config.compile_ways += [way] - # Write perf stats if any exist or if a metrics file is specified. - stats = [stat for (_, stat, __) in t.metrics] # type: List[PerfStat] - if hasMetricsFile: - print('Appending ' + str(len(stats)) + ' stats to file: ' + config.metrics_file) - with open(config.metrics_file, 'a') as f: - f.write("\n" + Perf.format_perf_stat(stats)) - elif inside_git_repo() and any(stats): - if is_worktree_dirty(): - print() - print(str_warn('Performance Metrics NOT Saved') + \ - ' working tree is dirty. Commit changes or use ' + \ - '--metrics-file to save metrics to a file.') + if args.skipway: + for way in args.skipway: + if way not in all_ways: + print('WARNING: Unknown WAY %s in --skipway' % way) + + config.other_ways = [w for w in config.other_ways if w not in args.skipway] + config.run_ways = [w for w in config.run_ways if w not in args.skipway] + config.compile_ways = [w for w in config.compile_ways if w not in args.skipway] + + config.broken_tests |= {TestName(t) for t in args.broken_test} + + if args.threads: + config.threads = args.threads + config.use_threads = True + + if args.verbose is not None: + config.verbose = args.verbose + + # Note [force skip perf tests] + # skip if this is not a git repo (estimated with inside_git_repo) + # and no metrics file is given. In this case there is no way to read the previous commit's + # perf test results, nor a way to store new perf test results. + force_skip_perf_tests = not hasMetricsFile and not inside_git_repo() + config.skip_perf_tests = args.skip_perf_tests or force_skip_perf_tests + config.only_perf_tests = args.only_perf_tests + + if args.test_env: + config.test_env = args.test_env + + config.cygwin = False + config.msys = False + + if windows: + h = os.popen('uname -s', 'r') + v = h.read() + h.close() + if v.startswith("CYGWIN"): + config.cygwin = True + elif v.startswith("MINGW") or v.startswith("MSYS"): + # msys gives "MINGW32" + # msys2 gives "MINGW_NT-6.2" or "MSYS_NT-6.3" + config.msys = True else: - Perf.append_perf_stat(stats) + raise Exception("Can't detect Windows terminal type") + + setup_locale() + + config.supports_colors = supports_colors() + term_color.enable_color = config.supports_colors + + # This has to come after arg parsing as the args can change the compiler + ts_config.get_compiler_info(config) - # Write summary - if config.summary_file: - with open(config.summary_file, 'w') as f: - summary(t, f) + # Can't import this earlier as we need to know if threading will be + # enabled or not + import testlib - if args.junit: - junit(t).write(args.junit) + setup_path() -if len(t.unexpected_failures) > 0 or \ - len(t.unexpected_stat_failures) > 0 or \ - len(t.unexpected_passes) > 0 or \ - len(t.framework_failures) > 0: - exitcode = 1 -else: - exitcode = 0 + testlib.testopts_local.x = TestOptions() -cleanup_and_exit(exitcode) + # if timeout == -1 then we try to calculate a sensible value + if config.timeout == -1: + config.timeout = int(testlib.read_no_crs(config.top + '/timeout/calibrate.out')) + + print('Timeout is ' + str(config.timeout)) + print('Known ways: ' + ', '.join(config.other_ways)) + print('Run ways: ' + ', '.join(config.run_ways)) + print('Compile ways: ' + ', '.join(config.compile_ways)) + + # Try get allowed performance changes from the git commit. + try: + config.allowed_perf_changes = Perf.get_allowed_perf_changes() + except subprocess.CalledProcessError: + print('Failed to get allowed metric changes from the HEAD git commit message.') + + print('Allowing performance changes in: ' + ', '.join(config.allowed_perf_changes.keys())) + + # ----------------------------------------------------------------------------- + # The main dude + + if config.rootdirs == []: + config.rootdirs = ['.'] + + t_files = list(testlib.findTFiles(config.rootdirs)) + + print('Found', len(t_files), '.T files...') + + t = getTestRun() # type: testlib.TestRun + + # Avoid cmd.exe built-in 'date' command on Windows + t.start_time = datetime.datetime.now() + + print('Beginning test run at', t.start_time.strftime("%c %Z")) + + # For reference + try: + print('Detected CPU features: ', cpu_features.get_cpu_features()) + except Exception as e: + print('Failed to detect CPU features: ', e) + + sys.stdout.flush() + # we output text, which cannot be unbuffered + sys.stdout = os.fdopen(sys.__stdout__.fileno(), "w") + + if config.local: + tempdir = '' + else: + # See note [Running tests in /tmp] + tempdir = tempfile.mkdtemp('', 'ghctest-') + + # opts.testdir should be quoted when used, to make sure the testsuite + # keeps working when it contains backward slashes, for example from + # using os.path.join. Windows native and mingw* python + # (/mingw64/bin/python) set `os.path.sep = '\\'`, while msys2 python + # (/bin/python, /usr/bin/python or /usr/local/bin/python) sets + # `os.path.sep = '/'`. + # To catch usage of unquoted opts.testdir early, insert some spaces into + # tempdir. + tempdir = os.path.join(tempdir, 'test spaces') + + def cleanup_and_exit(exitcode: int): + if config.cleanup and tempdir: + shutil.rmtree(tempdir, ignore_errors=True) + exit(exitcode) + + # First collect all the tests to be run + t_files_ok = True + test_globals = copy(testlib.__dict__) + test_globals.update(ts_config_globals) + for file in t_files: + testlib.if_verbose(2, '====> Scanning %s' % file) + testlib.newTestDir(tempdir, os.path.dirname(file)) + try: + with io.open(file, encoding='utf8') as f: + src = f.read() + + exec(src, test_globals) + except Exception as e: + traceback.print_exc() + testlib.framework_fail(None, None, 'exception: %s' % e) + t_files_ok = False + + for name in config.only: + if t_files_ok: + # See Note [Mutating config.only] + testlib.framework_fail(name, None, 'test not found') + else: + # Let user fix .T file errors before reporting on unfound tests. + # The reason the test can not be found is likely because of those + # .T file errors. + pass + + if config.list_broken: + print('') + print('Broken tests:') + print('\n '.join('#{ticket}({a}/{b})'.format(ticket=ticket, a=a, b=b) + for ticket, a, b in brokens)) + print('') + + if t.framework_failures: + print('WARNING:', len(t.framework_failures), 'framework failures!') + print('') + else: + # completion watcher + watcher = Watcher(len(testlib.parallelTests)) + + # Now run all the tests + try: + for oneTest in testlib.parallelTests: + if testlib.stopping(): + break + oneTest(watcher) + + # wait for parallel tests to finish + if not testlib.stopping(): + watcher.wait() + + # Run the following tests purely sequential + config.use_threads = False + for oneTest in testlib.aloneTests: + if testlib.stopping(): + break + oneTest(watcher) + except KeyboardInterrupt: + pass + + # flush everything before we continue + sys.stdout.flush() + + print_perf_summary( + force_skip_perf_tests=force_skip_perf_tests, + skip_perf_tests=args.skip_perf_tests) + testlib.summary(t, sys.stdout, config.no_print_summary, config.supports_colors) + + # Write perf stats if any exist or if a metrics file is specified. + stats = [stat for (_, stat, __) in t.metrics] # type: List[Perf.PerfStat] + if hasMetricsFile: + print('Appending ' + str(len(stats)) + ' stats to file: ' + config.metrics_file) + with open(config.metrics_file, 'a') as f: + f.write("\n" + Perf.format_perf_stat(stats)) + elif inside_git_repo() and any(stats): + if is_worktree_dirty(): + print() + print(str_warn('Performance Metrics NOT Saved') + \ + ' working tree is dirty. Commit changes or use ' + \ + '--metrics-file to save metrics to a file.') + else: + Perf.append_perf_stat(stats) + + # Write summary + if config.summary_file: + with open(config.summary_file, 'w') as f: + testlib.summary(t, f) + + if args.junit: + junit(t).write(args.junit) + + if len(t.unexpected_failures) > 0 or \ + len(t.unexpected_stat_failures) > 0 or \ + len(t.unexpected_passes) > 0 or \ + len(t.framework_failures) > 0: + exitcode = 1 + else: + exitcode = 0 + + cleanup_and_exit(exitcode) # Note [Running tests in /tmp] # @@ -544,3 +579,6 @@ cleanup_and_exit(exitcode) # # [1] # https://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/separate_compilation.html#output-files + +if __name__ == '__main__': + main() \ No newline at end of file ===================================== testsuite/driver/testglobals.py ===================================== @@ -189,6 +189,13 @@ class TestConfig: # I have no idea what this does self.package_conf_cache_file = None # type: Optional[Path] + self.ghc_compiler_always_flags = [] # type: List[str] + self.ghc_with_native_codegen = False + self.ghc_dynamic_by_default = False + self.ghc_with_dynamic_rts = False + self.ghc_with_threaded_rts = False + self.ghc_with_smp = False + self.ghc_with_llvm = False global config config = TestConfig() ===================================== testsuite/driver/testlib.py ===================================== @@ -502,6 +502,9 @@ def doing_ghci() -> bool: def ghc_dynamic() -> bool: return config.ghc_dynamic +def ghc_with_threaded_rts() -> bool: + return config.ghc_with_threaded_rts + def fast() -> bool: return config.speed == 2 @@ -1942,7 +1945,8 @@ def check_prof_ok(name: TestName, way: WayName) -> bool: def compare_outputs(way: WayName, kind: str, normaliser: OutputNormalizer, - expected_file, actual_file, diff_file=None, + expected_file: str, actual_file: str, + diff_file: Optional[str]=None, whitespace_normaliser: OutputNormalizer=lambda x:x) -> bool: expected_path = in_srcdir(expected_file) @@ -1997,18 +2001,19 @@ def compare_outputs(way: WayName, if_verbose(1, 'Test is expected to fail. Not accepting new output.') return False elif config.accept and actual_raw: + suffix = '' if config.accept_platform: if_verbose(1, 'Accepting new output for platform "' + config.platform + '".') - expected_path += '-' + config.platform + suffix += '-' + config.platform elif config.accept_os: if_verbose(1, 'Accepting new output for os "' + config.os + '".') - expected_path += '-' + config.os + suffix += '-' + config.os else: if_verbose(1, 'Accepting new output.') - write_file(expected_path, actual_raw) + write_file(expected_path.with_suffix(expected_path.suffix + suffix), actual_raw) return True elif config.accept: if_verbose(1, 'No output. Deleting "{0}".'.format(expected_path)) ===================================== testsuite/driver/testsuite_config.py ===================================== @@ -0,0 +1,287 @@ +# vim: set filetype=python: + +import re +from testglobals import TestConfig, WayName +from testutil import getStdout + +class TestsuiteConfig: + @staticmethod + def init_config(config: TestConfig) -> None: + raise NotImplemented + + @staticmethod + def get_compiler_info(config: TestConfig) -> None: + raise NotImplemented + +class GHCTestsuiteConfig(TestsuiteConfig): + """ + Testsuite configuration setup for GHC + """ + + @staticmethod + def init_config(config: TestConfig): + WayNames = lambda xs: [ WayName(x) for x in xs ] + + # By default, the 'normal' and 'hpc' ways are enabled. In addition, certain + # ways are enabled automatically if this GHC supports them. Ways that fall in + # this group are 'optasm', 'optllvm', 'profasm', 'threaded1', 'threaded2', + # 'profthreaded', 'ghci', and whichever of 'static/dyn' is not this GHC's + # default mode. Other ways should be set explicitly from .T files. + config.compile_ways = WayNames(['normal', 'hpc']) + config.run_ways = WayNames(['normal', 'hpc']) + + # ways that are not enabled by default, but can always be invoked explicitly + config.other_ways = WayNames([ + 'prof', 'normal_h', + 'prof_hc_hb','prof_hb', + 'prof_hd','prof_hy','prof_hr', + 'sanity', + 'threaded1_ls', 'threaded2_hT', 'debug_numa', + 'llvm', 'debugllvm', + 'profllvm', 'profoptllvm', 'profthreadedllvm', + 'debug', + 'ghci-ext', 'ghci-ext-prof', + 'ext-interp', + 'nonmoving', + 'nonmoving_thr', + 'nonmoving_thr_ghc', + 'compacting_gc', + ]) + + if config.ghc_with_native_codegen: + config.compile_ways.append(WayName('optasm')) + config.run_ways.append(WayName('optasm')) + + if config.have_profiling: + config.compile_ways.append(WayName('profasm')) + config.run_ways.append(WayName('profasm')) + + if config.have_interp: + config.run_ways.append(WayName('ghci')) + + if config.ghc_with_threaded_rts: + config.run_ways.append(WayName('threaded1')) + if config.ghc_with_smp: + config.have_smp = True + config.run_ways.append(WayName('threaded2')) + if config.speed == 0: + config.run_ways.append(WayName('nonmoving_thr')) + + if config.ghc_with_dynamic_rts: + config.have_shared_libs = True + + if config.ghc_dynamic_by_default and config.have_vanilla == 1: + config.run_ways.append(WayName('static')) + else: + if config.ghc_with_dynamic_rts: + config.run_ways.append(WayName('dyn')) + + if (config.have_profiling and config.ghc_with_threaded_rts): + config.run_ways.append(WayName('profthreaded')) + + if (config.ghc_with_llvm and not config.unregisterised): + config.compile_ways.append(WayName('optllvm')) + config.run_ways.append(WayName('optllvm')) + + WayFlags = lambda d: { WayName(k): v for k, v in d.items() } + config.way_flags = WayFlags({ + 'normal' : [], + 'normal_h' : [], + 'g1' : [], + 'nursery_chunks' : [], + 'debug_numa' : ['-threaded', '-debug'], + 'optasm' : ['-O', '-fasm'], + 'llvm' : ['-fllvm'], + 'optllvm' : ['-O', '-fllvm'], + 'debugllvm' : ['-fllvm', '-keep-llvm-files'], + 'prof' : ['-prof', '-static', '-fprof-auto', '-fasm'], + 'prof_no_auto' : ['-prof', '-static', '-fasm'], + 'profasm' : ['-O', '-prof', '-static', '-fprof-auto'], + 'profthreaded' : ['-O', '-prof', '-static', '-fprof-auto', '-threaded'], + 'ghci' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '+RTS', '-I0.1', '-RTS'] + (['-fghci-leak-check'] if not config.compiler_debugged else []), + 'sanity' : ['-debug'], + 'threaded1' : ['-threaded', '-debug'], + 'threaded1_ls' : ['-threaded', '-debug'], + 'threaded2' : ['-O', '-threaded', '-eventlog'], + 'threaded2_hT' : ['-O', '-threaded'], + 'hpc' : ['-O', '-fhpc'], + 'prof_hc_hb' : ['-O', '-prof', '-static', '-fprof-auto'], + 'prof_hb' : ['-O', '-prof', '-static', '-fprof-auto'], + 'prof_hd' : ['-O', '-prof', '-static', '-fprof-auto'], + 'prof_hy' : ['-O', '-prof', '-static', '-fprof-auto'], + 'prof_hr' : ['-O', '-prof', '-static', '-fprof-auto'], + 'dyn' : ['-O', '-dynamic'], + 'static' : ['-O', '-static'], + 'debug' : ['-O', '-g', '-dannot-lint'], + # llvm variants... + 'profllvm' : ['-prof', '-static', '-fprof-auto', '-fllvm'], + 'profoptllvm' : ['-O', '-prof', '-static', '-fprof-auto', '-fllvm'], + 'profthreadedllvm' : ['-O', '-prof', '-static', '-fprof-auto', '-threaded', '-fllvm'], + 'ghci-ext' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '-fexternal-interpreter', '+RTS', '-I0.1', '-RTS'], + 'ghci-ext-prof' : ['--interactive', '-v0', '-ignore-dot-ghci', '-fno-ghci-history', '-fexternal-interpreter', '-prof', '+RTS', '-I0.1', '-RTS'], + 'ext-interp' : ['-fexternal-interpreter'], + 'nonmoving' : [], + 'nonmoving_thr': ['-threaded'], + 'nonmoving_thr_ghc': ['+RTS', '-xn', '-N2', '-RTS', '-threaded'], + 'compacting_gc': [], + }) + + config.way_rts_flags = WayFlags({ + 'normal' : [], + 'normal_h' : ['-h'], # works without -prof + 'g1' : ['-G1'], + 'nursery_chunks' : ['-n32k'], + 'debug_numa' : ['-N2', '--debug-numa=2'], + 'optasm' : [], + 'llvm' : [], + 'optllvm' : [], + 'debugllvm' : [], + 'prof' : ['-p'], + 'prof_no_auto' : ['-p'], + 'profasm' : ['-hc', '-p'], # test heap profiling too + 'profthreaded' : ['-p'], + 'ghci' : [], + 'sanity' : ['-DS'], + 'threaded1' : [], + 'threaded1_ls' : ['-ls'], + 'threaded2' : ['-N2', '-ls'], + 'threaded2_hT' : ['-N2', '-hT'], + 'hpc' : [], + 'prof_hc_hb' : ['-hc', '-hbvoid'], + 'prof_hb' : ['-hb'], + 'prof_hd' : ['-hd'], + 'prof_hy' : ['-hy'], + 'prof_hr' : ['-hr'], + 'dyn' : [], + 'static' : [], + 'debug' : [], + # llvm variants... + 'profllvm' : ['-p'], + 'profoptllvm' : ['-hc', '-p'], + 'profthreadedllvm' : ['-p'], + 'ghci-ext' : [], + 'ghci-ext-prof' : [], + 'ext-interp' : [], + 'nonmoving' : ['-xn'], + 'nonmoving_thr' : ['-xn', '-N2'], + 'nonmoving_thr_ghc': ['-xn', '-N2'], + 'compacting_gc': ['-c'], + }) + + # Useful classes of ways that can be used with only_ways(), omit_ways() and + # expect_broken_for(). + # + # These are injected into the global scope which the tests are + # evaluated within. + globals = { + 'prof_ways' : [x[0] for x in config.way_flags.items() + if '-prof' in x[1]], + + 'threaded_ways' : [x[0] for x in config.way_flags.items() + if '-threaded' in x[1] or 'ghci' == x[0]], + + # Ways which run with multiple capabilities + 'concurrent_ways' : [name for name, flags in config.way_flags.items() + if '-threaded' in flags or 'ghci' == name + if '-N2' in config.way_rts_flags.get(name, [])], + + 'opt_ways' : [x[0] for x in config.way_flags.items() + if '-O' in x[1]], + + 'llvm_ways' : [x[0] for x in config.way_flags.items() + if '-fflvm' in x[1]], + } + return globals + + @staticmethod + def get_compiler_info(config): + s = getStdout([config.compiler, '--info']) + s = re.sub('[\r\n]', '', s) + compilerInfoDict = dict(eval(s)) + s = getStdout([config.compiler, '+RTS', '--info']) + s = re.sub('[\r\n]', '', s) + rtsInfoDict = dict(eval(s)) + + config.have_ncg = compilerInfoDict.get("Have native code generator", "NO") == "YES" + + # Whether GHC itself was built using the LLVM backend. We need to know this + # since some tests in ext-interp fail when stage2 ghc is built using + # LLVM. See #16087. + # + # The condition here is a bit approximate: we assume that if stage2 doesn't + # have the NCG and isn't unregisterised then it must be using the LLVM + # backend by default. + config.ghc_built_by_llvm = not config.have_ncg and not config.unregisterised + + config.have_RTS_linker = compilerInfoDict.get("target has RTS linker", "NO") == "YES" + # external interpreter needs RTS linker support + # If the field is not present (GHC 8.0 and earlier), assume we don't + # have -fexternal-interpreter (though GHC 8.0 actually does) + # so we can still run most tests. + config.have_ext_interp = compilerInfoDict.get("target has RTS linker", "NO") == "YES" + + # See Note [Replacing backward slashes in config.libdir]. + config.libdir = compilerInfoDict['LibDir'].replace('\\', '/') + + if re.match(".*_p(_.*|$)", rtsInfoDict["RTS way"]): + config.compiler_profiled = True + else: + config.compiler_profiled = False + + try: + config.package_conf_cache_file = compilerInfoDict["Global Package DB"] + '/package.cache' + except: + config.package_conf_cache_file = '' + + # See Note [WayFlags] + if config.ghc_dynamic: + config.ghc_th_way_flags = "-dynamic" + config.ghci_way_flags = "-dynamic" + config.plugin_way_flags = "-dynamic" + config.ghc_th_way = "dyn" + config.ghc_plugin_way = "dyn" + elif config.compiler_profiled: + config.ghc_th_way_flags = "-prof" + config.ghci_way_flags = "-prof" + config.plugin_way_flags = "-prof" + config.ghc_th_way = "prof" + config.ghc_plugin_way = "prof" + else: + config.ghc_th_way_flags = "-static" + config.ghci_way_flags = "-static" + config.plugin_way_flags = "-static" + config.ghc_th_way = "normal" + config.ghc_plugin_way = "normal" + +# Note [Replacing backward slashes in config.libdir] +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# We *do* need to replace backslashes in config.libdir, for the following +# reason: +# +# * Tests use config.libdir as follows: +# +# extra_run_opts('"' + config.libdir + '"') +# +# The double quotes are there because config.libdir might contain +# spaces. +# +# * This string is then written /as is/ to .genscript in +# testlib.interpreter_run: +# +# script.write(':set args ' + opts.extra_run_opts + '\n') +# +# * But GHCi expects the arguments to ':set args' to be proper Haskell +# strings (when they are quoted), with backslashes escaped. Since +# config.libdir contains single backslash characters, tests such as T5313 +# will fail for WAY=ghci with "Pattern match failure in do expression". +# +# Arguably the above code for writing `:set args` should be smarter. This +# is tricky to get right though, because in GHCI `:set args foo\bar` (no +# double quotes) works perfectly fine, and is interpreted as the Haskell +# string "foo\\bar". Therefore, simply escaping all backward slashes in +# opts.extra_run_opts before concatenating it with ':set args' is not right +# either. +# +# Replacing backslashes to forward slashes in config.libdir works around the +# problem. ===================================== testsuite/mk/test.mk ===================================== @@ -79,7 +79,7 @@ else dllext = .so endif -RUNTEST_OPTS += -e "ghc_compiler_always_flags='$(TEST_HC_OPTS)'" +RUNTEST_OPTS += --extra-hc-flag "$(TEST_HC_OPTS)" ifeq "$(GhcDebugged)" "YES" RUNTEST_OPTS += -e "config.compiler_debugged=True" @@ -123,15 +123,15 @@ RUNTEST_OPTS += -e config.have_profiling=False endif ifeq "$(filter thr, $(GhcRTSWays))" "thr" -RUNTEST_OPTS += -e ghc_with_threaded_rts=True +RUNTEST_OPTS += -e config.ghc_with_threaded_rts=True else -RUNTEST_OPTS += -e ghc_with_threaded_rts=False +RUNTEST_OPTS += -e config.ghc_with_threaded_rts=False endif ifeq "$(filter dyn, $(GhcRTSWays))" "dyn" -RUNTEST_OPTS += -e ghc_with_dynamic_rts=True +RUNTEST_OPTS += -e config.ghc_with_dynamic_rts=True else -RUNTEST_OPTS += -e ghc_with_dynamic_rts=False +RUNTEST_OPTS += -e config.ghc_with_dynamic_rts=False endif ifeq "$(GhcWithInterpreter)" "NO" @@ -183,21 +183,21 @@ CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared endif ifeq "$(GhcWithSMP)" "YES" -RUNTEST_OPTS += -e ghc_with_smp=True +RUNTEST_OPTS += -e config.ghc_with_smp=True else -RUNTEST_OPTS += -e ghc_with_smp=False +RUNTEST_OPTS += -e config.ghc_with_smp=False endif # Does the LLVM backend work? ifeq "$(LLC)" "" -RUNTEST_OPTS += -e ghc_with_llvm=False +RUNTEST_OPTS += -e config.ghc_with_llvm=False else ifeq "$(TargetARCH_CPP)" "powerpc" -RUNTEST_OPTS += -e ghc_with_llvm=False +RUNTEST_OPTS += -e config.ghc_with_llvm=False else ifneq "$(LLC)" "llc" # If we have a real detected value for LLVM, then it really ought to work -RUNTEST_OPTS += -e ghc_with_llvm=True +RUNTEST_OPTS += -e config.ghc_with_llvm=True else -RUNTEST_OPTS += -e ghc_with_llvm=False +RUNTEST_OPTS += -e config.ghc_with_llvm=False endif ifeq "$(WINDOWS)" "YES" ===================================== testsuite/tests/concurrent/prog002/all.T ===================================== @@ -1,7 +1,7 @@ # Test for bug #713, results in crashes in GHC prior to 20060315 with +RTS -N2 # Add 'threaded2_hT' so that we have at least one test for bug #5127 -if ghc_with_threaded_rts and ghc_with_smp: +if ghc_with_threaded_rts(): ways = ['threaded2_hT'] else: ways = [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9636134e798e5964526dd0c5a82d025f8bf2518d...2b239b32cf53fccfb8240eab48ea5566daf74be6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9636134e798e5964526dd0c5a82d025f8bf2518d...2b239b32cf53fccfb8240eab48ea5566daf74be6 You're receiving 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 Jul 27 20:20:46 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 27 Jul 2020 16:20:46 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] 238 commits: ghc-prim: Turn some comments into haddocks Message-ID: <5f1f371eb6cc9_80b3f848e5a5cd853738f3@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - 0624a8b0 by Ben Gamari at 2020-07-27T16:20:40-04:00 testsuite: Allow baseline commit to be set explicitly - - - - - ec31a37c by Ben Gamari at 2020-07-27T16:20:40-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/test-metrics.sh - CODEOWNERS - Makefile - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9636134e798e5964526dd0c5a82d025f8bf2518d...ec31a37c518785c69253e6d5627245b166f73e72 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9636134e798e5964526dd0c5a82d025f8bf2518d...ec31a37c518785c69253e6d5627245b166f73e72 You're receiving 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 Jul 27 23:07:32 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 27 Jul 2020 19:07:32 -0400 Subject: [Git][ghc/ghc][wip/T18494] 4 commits: Improve NegativeLiterals (#18022, GHC Proposal #344) Message-ID: <5f1f5e34b3383_80b3f848c1e06f4538451d@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18494 at Glasgow Haskell Compiler / GHC Commits: aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - 5c60e073 by Simon Peyton Jones at 2020-07-28T00:07:11+01:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - 12 changed files: - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - docs/users_guide/8.12.1-notes.rst - docs/users_guide/exts/negative_literals.rst - docs/users_guide/separate_compilation.rst - − testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/NegativeLiterals.hs - + testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs - testsuite/tests/parser/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -1002,7 +1002,7 @@ simplExprF1 env (App fun arg) cont , sc_hole_ty = hole' , sc_cont = cont } } _ -> - -- crucially, these are /lazy/ bindings. They will + -- Crucially, sc_hole_ty is a /lazy/ binding. It will -- be forced only if we need to run contHoleType. -- When these are forced, we might get quadratic behavior; -- this quadratic blowup could be avoided by drilling down @@ -1010,13 +1010,10 @@ simplExprF1 env (App fun arg) cont -- (instead of one-at-a-time). But in practice, we have not -- observed the quadratic behavior, so this extra entanglement -- seems not worthwhile. - let fun_ty = exprType fun - (m, _, _) = splitFunTy fun_ty - in simplExprF env fun $ ApplyToVal { sc_arg = arg, sc_env = env , sc_hole_ty = substTy env (exprType fun) - , sc_dup = NoDup, sc_cont = cont, sc_mult = m } + , sc_dup = NoDup, sc_cont = cont } simplExprF1 env expr@(Lam {}) cont = {-#SCC "simplExprF1-Lam" #-} @@ -1321,8 +1318,8 @@ rebuild env expr cont Select { sc_bndr = bndr, sc_alts = alts, sc_env = se, sc_cont = cont } -> rebuildCase (se `setInScopeFromE` env) expr bndr alts cont - StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty, sc_mult = m } - -> rebuildCall env (addValArgTo fun (m, expr) fun_ty ) cont + StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty } + -> rebuildCall env (addValArgTo fun expr fun_ty ) cont StrictBind { sc_bndr = b, sc_bndrs = bs, sc_body = body , sc_env = se, sc_cont = cont } -> do { (floats1, env') <- simplNonRecX (se `setInScopeFromE` env) b expr @@ -1414,7 +1411,7 @@ simplCast env body co0 cont0 -- co1 :: t1 ~ s1 -- co2 :: s2 ~ t2 addCoerce co cont@(ApplyToVal { sc_arg = arg, sc_env = arg_se - , sc_dup = dup, sc_cont = tail, sc_mult = m }) + , sc_dup = dup, sc_cont = tail }) | Just (co1, m_co2) <- pushCoValArg co , let new_ty = coercionRKind co1 , not (isTypeLevPoly new_ty) -- Without this check, we get a lev-poly arg @@ -1438,8 +1435,7 @@ simplCast env body co0 cont0 , sc_env = arg_se' , sc_dup = dup' , sc_cont = tail' - , sc_hole_ty = coercionLKind co - , sc_mult = m }) } } + , sc_hole_ty = coercionLKind co }) } } addCoerce co cont | isReflexiveCo co = return cont -- Having this at the end makes a huge @@ -1975,17 +1971,18 @@ rebuildCall env info (ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_c -- runRW# :: forall (r :: RuntimeRep) (o :: TYPE r). (State# RealWorld -> o) -> o -- K[ runRW# rr ty body ] --> runRW rr' ty' (\s. K[ body s ]) rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args }) - (ApplyToVal { sc_arg = arg, sc_env = arg_se, sc_cont = cont, sc_mult = m }) + (ApplyToVal { sc_arg = arg, sc_env = arg_se + , sc_cont = cont, sc_hole_ty = fun_ty }) | fun `hasKey` runRWKey , not (contIsStop cont) -- Don't fiddle around if the continuation is boring , [ TyArg {}, TyArg {} ] <- rev_args = do { s <- newId (fsLit "s") Many realWorldStatePrimTy - ; let env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] + ; let (m,_,_) = splitFunTy fun_ty + env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] ty' = contResultType cont cont' = ApplyToVal { sc_dup = Simplified, sc_arg = Var s , sc_env = env', sc_cont = cont - , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' - , sc_mult = m } + , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' } -- cont' applies to s, then K ; body' <- simplExprC env' arg cont' ; let arg' = Lam s body' @@ -1997,10 +1994,10 @@ rebuildCall env info@(ArgInfo { ai_encl = encl_rules , ai_strs = str:strs, ai_discs = disc:discs }) (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_dup = dup_flag, sc_hole_ty = fun_ty - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Argument is already simplified | isSimplified dup_flag -- See Note [Avoid redundant simplification] - = rebuildCall env (addValArgTo info' (m, arg) fun_ty) cont + = rebuildCall env (addValArgTo info' arg fun_ty) cont -- Strict arguments | str @@ -2009,7 +2006,7 @@ rebuildCall env info@(ArgInfo { ai_encl = encl_rules simplExprF (arg_se `setInScopeFromE` env) arg (StrictArg { sc_fun = info', sc_cci = cci_strict , sc_dup = Simplified, sc_fun_ty = fun_ty - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Note [Shadowing] -- Lazy arguments @@ -2020,7 +2017,7 @@ rebuildCall env info@(ArgInfo { ai_encl = encl_rules -- floating a demanded let. = do { arg' <- simplExprC (arg_se `setInScopeFromE` env) arg (mkLazyArgStop arg_ty cci_lazy) - ; rebuildCall env (addValArgTo info' (m, arg') fun_ty) cont } + ; rebuildCall env (addValArgTo info' arg' fun_ty) cont } where info' = info { ai_strs = strs, ai_discs = discs } arg_ty = funArgTy fun_ty @@ -2243,24 +2240,10 @@ trySeqRules in_env scrut rhs cont , TyArg { as_arg_ty = rhs_ty , as_hole_ty = res2_ty } , ValArg { as_arg = no_cast_scrut - , as_hole_ty = res3_ty - , as_mult = Many } ] - -- The multiplicity of the scrutiny above is Many because the type - -- of seq requires that its first argument is unrestricted. The - -- typing rule of case also guarantees it though. In a more - -- general world, where the first argument of seq would have - -- affine multiplicity, then we could use the multiplicity of - -- the case (held in the case binder) instead. + , as_hole_ty = res3_ty } ] rule_cont = ApplyToVal { sc_dup = NoDup, sc_arg = rhs , sc_env = in_env, sc_cont = cont - , sc_hole_ty = res4_ty, sc_mult = Many } - -- The multiplicity in sc_mult above is the - -- multiplicity of the second argument of seq. Since - -- seq's type, as it stands, imposes that its second - -- argument be unrestricted, so is - -- sc_mult. However, a more precise typing rule, - -- for seq, would be to have it be linear. In which - -- case, sc_mult should be 1. + , sc_hole_ty = res4_ty } -- Lazily evaluated, so we don't do most of this @@ -3318,7 +3301,7 @@ mkDupableCont env (StrictBind { sc_bndr = bndr, sc_bndrs = bndrs , sc_cont = mkBoringStop res_ty } ) } mkDupableCont env (StrictArg { sc_fun = info, sc_cci = cci - , sc_cont = cont, sc_fun_ty = fun_ty, sc_mult = m }) + , sc_cont = cont, sc_fun_ty = fun_ty }) -- See Note [Duplicating StrictArg] -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable = do { (floats1, cont') <- mkDupableCont env cont @@ -3329,7 +3312,6 @@ mkDupableCont env (StrictArg { sc_fun = info, sc_cci = cci , sc_cont = cont' , sc_cci = cci , sc_fun_ty = fun_ty - , sc_mult = m , sc_dup = OkToDup} ) } mkDupableCont env (ApplyToTy { sc_cont = cont @@ -3340,7 +3322,7 @@ mkDupableCont env (ApplyToTy { sc_cont = cont mkDupableCont env (ApplyToVal { sc_arg = arg, sc_dup = dup , sc_env = se, sc_cont = cont - , sc_hole_ty = hole_ty, sc_mult = mult }) + , sc_hole_ty = hole_ty }) = -- e.g. [...hole...] (...arg...) -- ==> -- let a = ...arg... @@ -3359,7 +3341,7 @@ mkDupableCont env (ApplyToVal { sc_arg = arg, sc_dup = dup -- has turned arg'' into a fresh variable -- See Note [StaticEnv invariant] in GHC.Core.Opt.Simplify.Utils , sc_dup = OkToDup, sc_cont = cont' - , sc_hole_ty = hole_ty, sc_mult = mult }) } + , sc_hole_ty = hole_ty }) } mkDupableCont env (Select { sc_bndr = case_bndr, sc_alts = alts , sc_env = se, sc_cont = cont }) ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -124,8 +124,7 @@ data SimplCont -- See Note [The hole type in ApplyToTy/Val] , sc_arg :: InExpr -- The argument, , sc_env :: StaticEnv -- see Note [StaticEnv invariant] - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | ApplyToTy -- (ApplyToTy ty K)[e] = K[ e ty ] { sc_arg_ty :: OutType -- Argument type @@ -158,8 +157,7 @@ data SimplCont , sc_fun_ty :: OutType -- Type of the function (f e1 .. en), -- presumably (arg_ty -> res_ty) -- where res_ty is expected by sc_cont - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | TickIt -- (TickIt t K)[e] = K[ tick t e ] (Tickish Id) -- Tick tickish @@ -278,23 +276,22 @@ data ArgInfo } data ArgSpec - = ValArg { as_mult :: Mult - , as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal + = ValArg { as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal , as_hole_ty :: OutType } -- Type of the function (presumably t1 -> t2) | TyArg { as_arg_ty :: OutType -- Apply to this type; c.f. ApplyToTy , as_hole_ty :: OutType } -- Type of the function (presumably forall a. blah) | CastBy OutCoercion -- Cast by this; c.f. CastIt instance Outputable ArgSpec where - ppr (ValArg { as_mult = mult, as_arg = arg }) = text "ValArg" <+> ppr mult <+> ppr arg + ppr (ValArg { as_arg = arg }) = text "ValArg" <+> ppr arg ppr (TyArg { as_arg_ty = ty }) = text "TyArg" <+> ppr ty ppr (CastBy c) = text "CastBy" <+> ppr c -addValArgTo :: ArgInfo -> (Mult, OutExpr) -> OutType -> ArgInfo -addValArgTo ai (w, arg) hole_ty = ai { ai_args = arg_spec : ai_args ai - , ai_rules = decRules (ai_rules ai) } +addValArgTo :: ArgInfo -> OutExpr -> OutType -> ArgInfo +addValArgTo ai arg hole_ty = ai { ai_args = arg_spec : ai_args ai + , ai_rules = decRules (ai_rules ai) } where - arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty, as_mult = w } + arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty } addTyArgTo :: ArgInfo -> OutType -> OutType -> ArgInfo addTyArgTo ai arg_ty hole_ty = ai { ai_args = arg_spec : ai_args ai @@ -317,9 +314,9 @@ pushSimplifiedArgs env (arg : args) k = case arg of TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } -> ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = rest } - ValArg { as_arg = arg, as_hole_ty = hole_ty, as_mult = w } + ValArg { as_arg = arg, as_hole_ty = hole_ty } -> ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified - , sc_hole_ty = hole_ty, sc_cont = rest, sc_mult = w } + , sc_hole_ty = hole_ty, sc_cont = rest } CastBy c -> CastIt c rest where rest = pushSimplifiedArgs env args k @@ -418,7 +415,7 @@ contHoleType (TickIt _ k) = contHoleType k contHoleType (CastIt co _) = coercionLKind co contHoleType (StrictBind { sc_bndr = b, sc_dup = dup, sc_env = se }) = perhapsSubstTy dup se (idType b) -contHoleType (StrictArg { sc_fun_ty = ty, sc_mult = _m }) = funArgTy ty +contHoleType (StrictArg { sc_fun_ty = ty }) = funArgTy ty contHoleType (ApplyToTy { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy] contHoleType (ApplyToVal { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy/Val] contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) @@ -436,12 +433,14 @@ contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) contHoleScaling :: SimplCont -> Mult contHoleScaling (Stop _ _) = One contHoleScaling (CastIt _ k) = contHoleScaling k -contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k -contHoleScaling (StrictArg { sc_mult = w, sc_cont = k }) = - w `mkMultMul` contHoleScaling k -contHoleScaling (Select { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k +contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (Select { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (StrictArg { sc_fun_ty = fun_ty, sc_cont = k }) + = w `mkMultMul` contHoleScaling k + where + (w, _, _) = splitFunTy fun_ty contHoleScaling (ApplyToTy { sc_cont = k }) = contHoleScaling k contHoleScaling (ApplyToVal { sc_cont = k }) = contHoleScaling k contHoleScaling (TickIt _ k) = contHoleScaling k ===================================== compiler/GHC/Parser.y ===================================== @@ -1884,9 +1884,9 @@ sigtypes1 :: { (OrdList (LHsSigType GhcPs)) } ----------------------------------------------------------------------------- -- Types -unpackedness :: { Located ([AddAnn], SourceText, SrcUnpackedness) } - : '{-# UNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getUNPACK_PRAGs $1, SrcUnpack) } - | '{-# NOUNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getNOUNPACK_PRAGs $1, SrcNoUnpack) } +unpackedness :: { Located UnpackednessPragma } + : '{-# UNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getUNPACK_PRAGs $1) SrcUnpack) } + | '{-# NOUNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getNOUNPACK_PRAGs $1) SrcNoUnpack) } forall_telescope :: { Located ([AddAnn], HsForAllTelescope GhcPs) } : 'forall' tv_bndrs '.' {% do { hintExplicitForall $1 @@ -1980,13 +1980,16 @@ tyapp :: { Located TyEl } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | PREFIX_AT atype { sLL $1 $> $ (TyElKindApp (comb2 $1 $2) $2) } - | qtyconop { sL1 $1 $ TyElOpr (unLoc $1) } - | tyvarop { sL1 $1 $ TyElOpr (unLoc $1) } - | SIMPLEQUOTE qconop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | tyop { mapLoc TyElOpr $1 } + | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } + +tyop :: { Located RdrName } + : qtyconop { $1 } + | tyvarop { $1 } + | SIMPLEQUOTE qconop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | SIMPLEQUOTE varop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | SIMPLEQUOTE varop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } atype :: { LHsType GhcPs } : ntgtycon { sL1 $1 (HsTyVar noExtField NotPromoted $1) } -- Not including unit tuples ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -199,7 +199,6 @@ $docsym = [\| \^ \* \$] -- normal signed numerical literals can only be explicitly negative, -- not explicitly positive (contrast @exponent) @negative = \- - at signed = @negative ? -- ----------------------------------------------------------------------------- @@ -531,12 +530,12 @@ $tab { warnTab } ifExtension BinaryLiteralsBit } { tok_primint positive 2 3 binary } 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 octal } 0[xX] @numspc @hexadecimal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 hexadecimal } - @negative @decimal \# / { ifExtension MagicHashBit } { tok_primint negative 1 2 decimal } - @negative 0[bB] @numspc @binary \# / { ifExtension MagicHashBit `alexAndPred` + @negative @decimal \# / { negHashLitPred } { tok_primint negative 1 2 decimal } + @negative 0[bB] @numspc @binary \# / { negHashLitPred `alexAndPred` ifExtension BinaryLiteralsBit } { tok_primint negative 3 4 binary } - @negative 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint negative 3 4 octal } + @negative 0[oO] @numspc @octal \# / { negHashLitPred } { tok_primint negative 3 4 octal } @negative 0[xX] @numspc @hexadecimal \# - / { ifExtension MagicHashBit } { tok_primint negative 3 4 hexadecimal } + / { negHashLitPred } { tok_primint negative 3 4 hexadecimal } @decimal \# \# / { ifExtension MagicHashBit } { tok_primword 0 2 decimal } 0[bB] @numspc @binary \# \# / { ifExtension MagicHashBit `alexAndPred` @@ -546,8 +545,11 @@ $tab { warnTab } -- Unboxed floats and doubles (:: Float#, :: Double#) -- prim_{float,double} work with signed literals - @signed @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } - @signed @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } + @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + + @negative @floating_point \# / { negHashLitPred } { tok_frac 1 tok_primfloat } + @negative @floating_point \# \# / { negHashLitPred } { tok_frac 2 tok_primdouble } } -- Strings and chars are lexed by hand-written code. The reason is @@ -1192,8 +1194,8 @@ atEOL _ _ _ (AI _ buf) = atEnd buf || currentChar buf == '\n' -- Check if we should parse a negative literal (e.g. -123) as a single token. negLitPred :: AlexAccPred ExtsBitmap negLitPred = - negative_literals `alexOrPred` - (lexical_negation `alexAndPred` prefix_minus) + prefix_minus `alexAndPred` + (negative_literals `alexOrPred` lexical_negation) where negative_literals = ifExtension NegativeLiteralsBit @@ -1202,14 +1204,33 @@ negLitPred = alexNotPred (ifExtension NoLexicalNegationBit) prefix_minus = - -- The condition for a prefix occurrence of an operator is: - -- - -- not precededByClosingToken && followedByOpeningToken - -- - -- but we don't check followedByOpeningToken here as it holds - -- simply because we immediately lex a literal after the minus. + -- Note [prefix_minus in negLitPred and negHashLitPred] + alexNotPred precededByClosingToken + +-- Check if we should parse an unboxed negative literal (e.g. -123#) as a single token. +negHashLitPred :: AlexAccPred ExtsBitmap +negHashLitPred = prefix_minus `alexAndPred` magic_hash + where + magic_hash = ifExtension MagicHashBit + prefix_minus = + -- Note [prefix_minus in negLitPred and negHashLitPred] alexNotPred precededByClosingToken +{- Note [prefix_minus in negLitPred and negHashLitPred] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We want to parse -1 as a single token, but x-1 as three tokens. +So in negLitPred (and negHashLitPred) we require that we have a prefix +occurrence of the minus sign. See Note [Whitespace-sensitive operator parsing] +for a detailed definition of a prefix occurrence. + +The condition for a prefix occurrence of an operator is: + + not precededByClosingToken && followedByOpeningToken + +but we don't check followedByOpeningToken when parsing a negative literal. +It holds simply because we immediately lex a literal after the minus. +-} + ifExtension :: ExtBits -> AlexAccPred ExtsBitmap ifExtension extBits bits _ _ _ = extBits `xtest` bits ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -70,6 +70,7 @@ module GHC.Parser.PostProcess ( addFatalError, hintBangPat, TyEl(..), mergeOps, mergeDataCon, mkBangTy, + UnpackednessPragma(..), -- Help with processing exports ImpExpSubSpec(..), @@ -559,25 +560,6 @@ As the result, in order to determine whether (C t1 t2) declares a data constructor, a type, or a context, we would need unlimited lookahead which 'happy' is not so happy with. -To further complicate matters, the interpretation of (!) and (~) is different -in constructors and types: - - (b1) type T = C ! D - (b2) data T = C ! D - (b3) data T = C ! D => E - -In (b1) and (b3), (!) is a type operator with two arguments: 'C' and 'D'. At -the same time, in (b2) it is a strictness annotation: 'C' is a data constructor -with a single strict argument 'D'. For the programmer, these cases are usually -easy to tell apart due to whitespace conventions: - - (b2) data T = C !D -- no space after the bang hints that - -- it is a strictness annotation - -For the parser, on the other hand, this whitespace does not matter. We cannot -tell apart (b2) from (b3) until we encounter (=>), so it requires unlimited -lookahead. - The solution that accounts for all of these issues is to initially parse data declarations and types as a reversed list of TyEl: @@ -1324,7 +1306,7 @@ isFunLhs e = go e [] [] data TyEl = TyElOpr RdrName | TyElOpd (HsType GhcPs) | TyElKindApp SrcSpan (LHsType GhcPs) -- See Note [TyElKindApp SrcSpan interpretation] - | TyElUnpackedness ([AddAnn], SourceText, SrcUnpackedness) + | TyElUnpackedness UnpackednessPragma {- Note [TyElKindApp SrcSpan interpretation] @@ -1345,20 +1327,15 @@ instance Outputable TyEl where ppr (TyElOpr name) = ppr name ppr (TyElOpd ty) = ppr ty ppr (TyElKindApp _ ki) = text "@" <> ppr ki - ppr (TyElUnpackedness (_, _, unpk)) = ppr unpk + ppr (TyElUnpackedness (UnpackednessPragma _ _ unpk)) = ppr unpk -- | Extract a strictness/unpackedness annotation from the front of a reversed -- 'TyEl' list. pUnpackedness :: [Located TyEl] -- reversed TyEl - -> Maybe ( SrcSpan - , [AddAnn] - , SourceText - , SrcUnpackedness - , [Located TyEl] {- remaining TyEl -}) -pUnpackedness (L l x1 : xs) - | TyElUnpackedness (anns, prag, unpk) <- x1 - = Just (l, anns, prag, unpk, xs) + -> Maybe (SrcSpan, UnpackednessPragma, + [Located TyEl] {- remaining TyEl -}) +pUnpackedness (L l x1 : xs) | TyElUnpackedness up <- x1 = Just (l, up, xs) pUnpackedness _ = Nothing pBangTy @@ -1371,7 +1348,7 @@ pBangTy pBangTy lt@(L l1 _) xs = case pUnpackedness xs of Nothing -> (False, lt, pure (), xs) - Just (l2, anns, prag, unpk, xs') -> + Just (l2, UnpackednessPragma anns prag unpk, xs') -> let bl = combineSrcSpans l1 l2 bt = addUnpackedness (prag, unpk) lt in (True, L bl bt, addAnnsAt bl anns, xs') @@ -1380,6 +1357,10 @@ mkBangTy :: SrcStrictness -> LHsType GhcPs -> HsType GhcPs mkBangTy strictness = HsBangTy noExtField (HsSrcBang NoSourceText NoSrcUnpack strictness) +-- Result of parsing {-# UNPACK #-} or {-# NOUNPACK #-} +data UnpackednessPragma = + UnpackednessPragma [AddAnn] SourceText SrcUnpackedness + addUnpackedness :: (SourceText, SrcUnpackedness) -> LHsType GhcPs -> HsType GhcPs addUnpackedness (prag, unpk) (L _ (HsBangTy x bang t)) | HsSrcBang NoSourceText NoSrcUnpack strictness <- bang @@ -1411,7 +1392,7 @@ mergeOps all_xs = go (0 :: Int) [] id all_xs -- clause [unpk]: -- handle (NO)UNPACK pragmas - go k acc ops_acc ((L l (TyElUnpackedness (anns, unpkSrc, unpk))):xs) = + go k acc ops_acc ((L l (TyElUnpackedness (UnpackednessPragma anns unpkSrc unpk))):xs) = if not (null acc) && null xs then do { acc' <- eitherToP $ mergeOpsAcc acc ; let a = ops_acc acc' ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -224,6 +224,13 @@ Language f = (- x) -- operator section c = (-x) -- negation +* The behavior of :extension:`NegativeLiterals` changed, and now we require + that a negative literal must not be preceded by a closing token (see + `GHC Proposal #229 `__ + for the definition of a closing token). In other words, we parse ``f -123`` + as ``f (-123)``, but ``x-123`` as ``(-) x 123``. Before this amendment, + :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/negative_literals.rst ===================================== @@ -24,9 +24,11 @@ will elicit an unexpected integer-literal-overflow message. Whitespace can be inserted, as in ``- 123``, to force interpretation as two tokens. -One pitfall is that with :extension:`NegativeLiterals`, ``x-1`` will -be parsed as ``x`` applied to the argument ``-1``, which is usually -not what you want. ``x - 1`` or even ``x- 1`` can be used instead -for subtraction. To avoid this, consider using :extension:`LexicalNegation` -instead. - +In 8.12, the behavior of this extension changed, and now we require that a negative literal must not be preceded by a closing token (see +`GHC Proposal #229 `__ +for the definition of a closing token). In other words, we parse ``f -123`` as ``f (-123)``, but ``x-123`` as ``(-) x +123``. Before this amendment, :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + +:extension:`NegativeLiterals` is a subset of :extension:`LexicalNegation`. That +is, enabling both of those extensions has the same effect as enabling +:extension:`LexicalNegation` alone. ===================================== docs/users_guide/separate_compilation.rst ===================================== @@ -758,7 +758,7 @@ There are several points to note here: the same machine-generated binary format as any other GHC-generated interface file (e.g. ``B.hi``). You can display its contents with ``ghc --show-iface``. If you specify a directory for - interface files, the ``-ohidir`` flag, then that affects ``hi-boot`` files + interface files, the ``-hidir`` flag, then that affects ``hi-boot`` files too. - If hs-boot files are considered distinct from their parent source ===================================== testsuite/tests/parser/should_compile/LexNegVsNegLit.hs deleted ===================================== @@ -1,17 +0,0 @@ -{-# LANGUAGE NegativeLiterals, LexicalNegation #-} - -module LexNegVsNegLit where - --- NegativeLiterals specifies that we parse x-1 as x (-1), even though it's --- considered a shortcoming. --- --- LexicalNegation does not change that. --- -b :: Bool -b = even-1 -- parsed as: even (-1) - -- so it is well-typed. - -- - -- with LexicalNegation alone, we'd get (-) even 1, - -- but NegativeLiterals takes precedence here. - --- See also: GHC Proposal #344 ===================================== testsuite/tests/parser/should_compile/NegativeLiterals.hs ===================================== @@ -0,0 +1,57 @@ +{-# LANGUAGE NegativeLiterals, MagicHash, BinaryLiterals #-} + +module NegativeLiterals where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p1 :: Bool +p1 = even -2 -- parsed as: even (-2) + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p3 :: Int +p3 = floor -2.4 -- parsed as: floor (-2.4) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +p6 :: Bool +p6 = even -0b10 -- parsed as: even (-2) + || even -0o10 -- parsed as: even (-8) + || even -0x10 -- parsed as: even (-16) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti1 :: Integer -> Integer +ti1 x = x-2 -- parsed as: (-) x 1 + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) + +ti6 :: Integer -> [Integer] +ti6 x = + [ x-0b10, -- parsed as: (-) x 2 + x-0o10, -- parsed as: (-) x 8 + x-0x10 ] -- parsed as: (-) x 16 ===================================== testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs ===================================== @@ -0,0 +1,39 @@ +{-# LANGUAGE NoNegativeLiterals, MagicHash, BinaryLiterals #-} + +-- Even when NegativeLiterals are disabled, +-- we parse unboxed literals appropriately. +module NegativeLiteralsNoExt where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -153,7 +153,8 @@ test('proposal-229b', normal, compile, ['']) test('proposal-229d', normal, compile, ['']) test('proposal-229e', normal, compile, ['']) test('LexicalNegation', normal, compile, ['']) -test('LexNegVsNegLit', normal, compile, ['']) +test('NegativeLiterals', normal, compile, ['']) +test('NegativeLiteralsNoExt', normal, compile, ['']) # We omit 'profasm' because it fails with: # Cannot load -prof objects when GHC is built with -dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b31c478d416a1abffb89104f00c7dc5f5d0b607f...5c60e07345176f14661fcf67dd15980879848442 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b31c478d416a1abffb89104f00c7dc5f5d0b607f...5c60e07345176f14661fcf67dd15980879848442 You're receiving 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 Jul 27 23:09:24 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 27 Jul 2020 19:09:24 -0400 Subject: [Git][ghc/ghc][wip/spj-wibbles] 4 commits: Improve NegativeLiterals (#18022, GHC Proposal #344) Message-ID: <5f1f5ea4f02e4_80b3f84924cce7053852f2@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/spj-wibbles at Glasgow Haskell Compiler / GHC Commits: aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - b7a902db by Simon Peyton Jones at 2020-07-28T00:09:02+01:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 12 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Types/Name/Reader.hs - docs/users_guide/8.12.1-notes.rst - docs/users_guide/exts/negative_literals.rst - docs/users_guide/separate_compilation.rst - − testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/NegativeLiterals.hs - + testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs - testsuite/tests/parser/should_compile/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1884,9 +1884,9 @@ sigtypes1 :: { (OrdList (LHsSigType GhcPs)) } ----------------------------------------------------------------------------- -- Types -unpackedness :: { Located ([AddAnn], SourceText, SrcUnpackedness) } - : '{-# UNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getUNPACK_PRAGs $1, SrcUnpack) } - | '{-# NOUNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getNOUNPACK_PRAGs $1, SrcNoUnpack) } +unpackedness :: { Located UnpackednessPragma } + : '{-# UNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getUNPACK_PRAGs $1) SrcUnpack) } + | '{-# NOUNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getNOUNPACK_PRAGs $1) SrcNoUnpack) } forall_telescope :: { Located ([AddAnn], HsForAllTelescope GhcPs) } : 'forall' tv_bndrs '.' {% do { hintExplicitForall $1 @@ -1980,13 +1980,16 @@ tyapp :: { Located TyEl } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | PREFIX_AT atype { sLL $1 $> $ (TyElKindApp (comb2 $1 $2) $2) } - | qtyconop { sL1 $1 $ TyElOpr (unLoc $1) } - | tyvarop { sL1 $1 $ TyElOpr (unLoc $1) } - | SIMPLEQUOTE qconop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | tyop { mapLoc TyElOpr $1 } + | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } + +tyop :: { Located RdrName } + : qtyconop { $1 } + | tyvarop { $1 } + | SIMPLEQUOTE qconop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | SIMPLEQUOTE varop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | SIMPLEQUOTE varop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } atype :: { LHsType GhcPs } : ntgtycon { sL1 $1 (HsTyVar noExtField NotPromoted $1) } -- Not including unit tuples ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -199,7 +199,6 @@ $docsym = [\| \^ \* \$] -- normal signed numerical literals can only be explicitly negative, -- not explicitly positive (contrast @exponent) @negative = \- - at signed = @negative ? -- ----------------------------------------------------------------------------- @@ -531,12 +530,12 @@ $tab { warnTab } ifExtension BinaryLiteralsBit } { tok_primint positive 2 3 binary } 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 octal } 0[xX] @numspc @hexadecimal \# / { ifExtension MagicHashBit } { tok_primint positive 2 3 hexadecimal } - @negative @decimal \# / { ifExtension MagicHashBit } { tok_primint negative 1 2 decimal } - @negative 0[bB] @numspc @binary \# / { ifExtension MagicHashBit `alexAndPred` + @negative @decimal \# / { negHashLitPred } { tok_primint negative 1 2 decimal } + @negative 0[bB] @numspc @binary \# / { negHashLitPred `alexAndPred` ifExtension BinaryLiteralsBit } { tok_primint negative 3 4 binary } - @negative 0[oO] @numspc @octal \# / { ifExtension MagicHashBit } { tok_primint negative 3 4 octal } + @negative 0[oO] @numspc @octal \# / { negHashLitPred } { tok_primint negative 3 4 octal } @negative 0[xX] @numspc @hexadecimal \# - / { ifExtension MagicHashBit } { tok_primint negative 3 4 hexadecimal } + / { negHashLitPred } { tok_primint negative 3 4 hexadecimal } @decimal \# \# / { ifExtension MagicHashBit } { tok_primword 0 2 decimal } 0[bB] @numspc @binary \# \# / { ifExtension MagicHashBit `alexAndPred` @@ -546,8 +545,11 @@ $tab { warnTab } -- Unboxed floats and doubles (:: Float#, :: Double#) -- prim_{float,double} work with signed literals - @signed @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } - @signed @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + @floating_point \# / { ifExtension MagicHashBit } { tok_frac 1 tok_primfloat } + @floating_point \# \# / { ifExtension MagicHashBit } { tok_frac 2 tok_primdouble } + + @negative @floating_point \# / { negHashLitPred } { tok_frac 1 tok_primfloat } + @negative @floating_point \# \# / { negHashLitPred } { tok_frac 2 tok_primdouble } } -- Strings and chars are lexed by hand-written code. The reason is @@ -1192,8 +1194,8 @@ atEOL _ _ _ (AI _ buf) = atEnd buf || currentChar buf == '\n' -- Check if we should parse a negative literal (e.g. -123) as a single token. negLitPred :: AlexAccPred ExtsBitmap negLitPred = - negative_literals `alexOrPred` - (lexical_negation `alexAndPred` prefix_minus) + prefix_minus `alexAndPred` + (negative_literals `alexOrPred` lexical_negation) where negative_literals = ifExtension NegativeLiteralsBit @@ -1202,14 +1204,33 @@ negLitPred = alexNotPred (ifExtension NoLexicalNegationBit) prefix_minus = - -- The condition for a prefix occurrence of an operator is: - -- - -- not precededByClosingToken && followedByOpeningToken - -- - -- but we don't check followedByOpeningToken here as it holds - -- simply because we immediately lex a literal after the minus. + -- Note [prefix_minus in negLitPred and negHashLitPred] + alexNotPred precededByClosingToken + +-- Check if we should parse an unboxed negative literal (e.g. -123#) as a single token. +negHashLitPred :: AlexAccPred ExtsBitmap +negHashLitPred = prefix_minus `alexAndPred` magic_hash + where + magic_hash = ifExtension MagicHashBit + prefix_minus = + -- Note [prefix_minus in negLitPred and negHashLitPred] alexNotPred precededByClosingToken +{- Note [prefix_minus in negLitPred and negHashLitPred] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We want to parse -1 as a single token, but x-1 as three tokens. +So in negLitPred (and negHashLitPred) we require that we have a prefix +occurrence of the minus sign. See Note [Whitespace-sensitive operator parsing] +for a detailed definition of a prefix occurrence. + +The condition for a prefix occurrence of an operator is: + + not precededByClosingToken && followedByOpeningToken + +but we don't check followedByOpeningToken when parsing a negative literal. +It holds simply because we immediately lex a literal after the minus. +-} + ifExtension :: ExtBits -> AlexAccPred ExtsBitmap ifExtension extBits bits _ _ _ = extBits `xtest` bits ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -70,6 +70,7 @@ module GHC.Parser.PostProcess ( addFatalError, hintBangPat, TyEl(..), mergeOps, mergeDataCon, mkBangTy, + UnpackednessPragma(..), -- Help with processing exports ImpExpSubSpec(..), @@ -559,25 +560,6 @@ As the result, in order to determine whether (C t1 t2) declares a data constructor, a type, or a context, we would need unlimited lookahead which 'happy' is not so happy with. -To further complicate matters, the interpretation of (!) and (~) is different -in constructors and types: - - (b1) type T = C ! D - (b2) data T = C ! D - (b3) data T = C ! D => E - -In (b1) and (b3), (!) is a type operator with two arguments: 'C' and 'D'. At -the same time, in (b2) it is a strictness annotation: 'C' is a data constructor -with a single strict argument 'D'. For the programmer, these cases are usually -easy to tell apart due to whitespace conventions: - - (b2) data T = C !D -- no space after the bang hints that - -- it is a strictness annotation - -For the parser, on the other hand, this whitespace does not matter. We cannot -tell apart (b2) from (b3) until we encounter (=>), so it requires unlimited -lookahead. - The solution that accounts for all of these issues is to initially parse data declarations and types as a reversed list of TyEl: @@ -1324,7 +1306,7 @@ isFunLhs e = go e [] [] data TyEl = TyElOpr RdrName | TyElOpd (HsType GhcPs) | TyElKindApp SrcSpan (LHsType GhcPs) -- See Note [TyElKindApp SrcSpan interpretation] - | TyElUnpackedness ([AddAnn], SourceText, SrcUnpackedness) + | TyElUnpackedness UnpackednessPragma {- Note [TyElKindApp SrcSpan interpretation] @@ -1345,20 +1327,15 @@ instance Outputable TyEl where ppr (TyElOpr name) = ppr name ppr (TyElOpd ty) = ppr ty ppr (TyElKindApp _ ki) = text "@" <> ppr ki - ppr (TyElUnpackedness (_, _, unpk)) = ppr unpk + ppr (TyElUnpackedness (UnpackednessPragma _ _ unpk)) = ppr unpk -- | Extract a strictness/unpackedness annotation from the front of a reversed -- 'TyEl' list. pUnpackedness :: [Located TyEl] -- reversed TyEl - -> Maybe ( SrcSpan - , [AddAnn] - , SourceText - , SrcUnpackedness - , [Located TyEl] {- remaining TyEl -}) -pUnpackedness (L l x1 : xs) - | TyElUnpackedness (anns, prag, unpk) <- x1 - = Just (l, anns, prag, unpk, xs) + -> Maybe (SrcSpan, UnpackednessPragma, + [Located TyEl] {- remaining TyEl -}) +pUnpackedness (L l x1 : xs) | TyElUnpackedness up <- x1 = Just (l, up, xs) pUnpackedness _ = Nothing pBangTy @@ -1371,7 +1348,7 @@ pBangTy pBangTy lt@(L l1 _) xs = case pUnpackedness xs of Nothing -> (False, lt, pure (), xs) - Just (l2, anns, prag, unpk, xs') -> + Just (l2, UnpackednessPragma anns prag unpk, xs') -> let bl = combineSrcSpans l1 l2 bt = addUnpackedness (prag, unpk) lt in (True, L bl bt, addAnnsAt bl anns, xs') @@ -1380,6 +1357,10 @@ mkBangTy :: SrcStrictness -> LHsType GhcPs -> HsType GhcPs mkBangTy strictness = HsBangTy noExtField (HsSrcBang NoSourceText NoSrcUnpack strictness) +-- Result of parsing {-# UNPACK #-} or {-# NOUNPACK #-} +data UnpackednessPragma = + UnpackednessPragma [AddAnn] SourceText SrcUnpackedness + addUnpackedness :: (SourceText, SrcUnpackedness) -> LHsType GhcPs -> HsType GhcPs addUnpackedness (prag, unpk) (L _ (HsBangTy x bang t)) | HsSrcBang NoSourceText NoSrcUnpack strictness <- bang @@ -1411,7 +1392,7 @@ mergeOps all_xs = go (0 :: Int) [] id all_xs -- clause [unpk]: -- handle (NO)UNPACK pragmas - go k acc ops_acc ((L l (TyElUnpackedness (anns, unpkSrc, unpk))):xs) = + go k acc ops_acc ((L l (TyElUnpackedness (UnpackednessPragma anns unpkSrc unpk))):xs) = if not (null acc) && null xs then do { acc' <- eitherToP $ mergeOpsAcc acc ; let a = ops_acc acc' ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -236,19 +236,30 @@ newPatName (LetMk is_top fix_env) rdr_name do { name <- case is_top of NotTopLevel -> newLocalBndrRn rdr_name TopLevel -> newTopSrcBinder rdr_name - ; bindLocalNames [name] $ -- Do *not* use bindLocalNameFV here - -- See Note [View pattern usage] + ; bindLocalNames [name] $ + -- Do *not* use bindLocalNameFV here; + -- see Note [View pattern usage] + -- For the TopLevel case + -- see Note [bindLocalNames for an External name] addLocalFixities fix_env [name] $ thing_inside name }) - -- Note: the bindLocalNames is somewhat suspicious - -- because it binds a top-level name as a local name. - -- however, this binding seems to work, and it only exists for - -- the duration of the patterns and the continuation; - -- then the top-level name is added to the global env - -- before going on to the RHSes (see GHC.Rename.Module). +{- Note [bindLocalNames for an External name] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In the TopLevel case, the use of bindLocalNames here is somewhat +suspicious because it binds a top-level External name in the +LocalRdrEnv. c.f. Note [LocalRdrEnv] in GHC.Types.Name.Reader. + +However, this only happens when renaming the LHS (only) of a top-level +pattern binding. Even though this only the LHS, we need to bring the +binder into scope in the pattern itself in case the binder is used in +subsequent view patterns. A bit bizarre, something like + (x, Just y <- f x) = e + +Anyway, bindLocalNames does work, and the binding only exists for the +duration of the pattern; then the top-level name is added to the +global env before going on to the RHSes (see GHC.Rename.Module). -{- Note [View pattern usage] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -338,13 +338,24 @@ instance Ord RdrName where ************************************************************************ -} +{- Note [LocalRdrEnv] +~~~~~~~~~~~~~~~~~~~~~ +The LocalRdrEnv is used to store local bindings (let, where, lambda, case). + +* It is keyed by OccName, because we never use it for qualified names. + +* It maps the OccName to a Name. That Name is almost always an + Internal Name, but (hackily) it can be External too for top-level + pattern bindings. See Note [bindLocalNames for an External name] + in GHC.Rename.Pat + +* We keep the current mapping (lre_env), *and* the set of all Names in + scope (lre_in_scope). Reason: see Note [Splicing Exact names] in + GHC.Rename.Env. +-} + -- | Local Reader Environment --- --- This environment is used to store local bindings --- (@let@, @where@, lambda, @case@). --- It is keyed by OccName, because we never use it for qualified names --- We keep the current mapping, *and* the set of all Names in scope --- Reason: see Note [Splicing Exact names] in "GHC.Rename.Env" +-- See Note [LocalRdrEnv] data LocalRdrEnv = LRE { lre_env :: OccEnv Name , lre_in_scope :: NameSet } @@ -364,16 +375,15 @@ emptyLocalRdrEnv = LRE { lre_env = emptyOccEnv , lre_in_scope = emptyNameSet } extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv --- The Name should be a non-top-level thing +-- See Note [LocalRdrEnv] extendLocalRdrEnv lre@(LRE { lre_env = env, lre_in_scope = ns }) name - = WARN( isExternalName name, ppr name ) - lre { lre_env = extendOccEnv env (nameOccName name) name + = lre { lre_env = extendOccEnv env (nameOccName name) name , lre_in_scope = extendNameSet ns name } extendLocalRdrEnvList :: LocalRdrEnv -> [Name] -> LocalRdrEnv +-- See Note [LocalRdrEnv] extendLocalRdrEnvList lre@(LRE { lre_env = env, lre_in_scope = ns }) names - = WARN( any isExternalName names, ppr names ) - lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] + = lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] , lre_in_scope = extendNameSetList ns names } lookupLocalRdrEnv :: LocalRdrEnv -> RdrName -> Maybe Name ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -224,6 +224,13 @@ Language f = (- x) -- operator section c = (-x) -- negation +* The behavior of :extension:`NegativeLiterals` changed, and now we require + that a negative literal must not be preceded by a closing token (see + `GHC Proposal #229 `__ + for the definition of a closing token). In other words, we parse ``f -123`` + as ``f (-123)``, but ``x-123`` as ``(-) x 123``. Before this amendment, + :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + Compiler ~~~~~~~~ ===================================== docs/users_guide/exts/negative_literals.rst ===================================== @@ -24,9 +24,11 @@ will elicit an unexpected integer-literal-overflow message. Whitespace can be inserted, as in ``- 123``, to force interpretation as two tokens. -One pitfall is that with :extension:`NegativeLiterals`, ``x-1`` will -be parsed as ``x`` applied to the argument ``-1``, which is usually -not what you want. ``x - 1`` or even ``x- 1`` can be used instead -for subtraction. To avoid this, consider using :extension:`LexicalNegation` -instead. - +In 8.12, the behavior of this extension changed, and now we require that a negative literal must not be preceded by a closing token (see +`GHC Proposal #229 `__ +for the definition of a closing token). In other words, we parse ``f -123`` as ``f (-123)``, but ``x-123`` as ``(-) x +123``. Before this amendment, :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + +:extension:`NegativeLiterals` is a subset of :extension:`LexicalNegation`. That +is, enabling both of those extensions has the same effect as enabling +:extension:`LexicalNegation` alone. ===================================== docs/users_guide/separate_compilation.rst ===================================== @@ -758,7 +758,7 @@ There are several points to note here: the same machine-generated binary format as any other GHC-generated interface file (e.g. ``B.hi``). You can display its contents with ``ghc --show-iface``. If you specify a directory for - interface files, the ``-ohidir`` flag, then that affects ``hi-boot`` files + interface files, the ``-hidir`` flag, then that affects ``hi-boot`` files too. - If hs-boot files are considered distinct from their parent source ===================================== testsuite/tests/parser/should_compile/LexNegVsNegLit.hs deleted ===================================== @@ -1,17 +0,0 @@ -{-# LANGUAGE NegativeLiterals, LexicalNegation #-} - -module LexNegVsNegLit where - --- NegativeLiterals specifies that we parse x-1 as x (-1), even though it's --- considered a shortcoming. --- --- LexicalNegation does not change that. --- -b :: Bool -b = even-1 -- parsed as: even (-1) - -- so it is well-typed. - -- - -- with LexicalNegation alone, we'd get (-) even 1, - -- but NegativeLiterals takes precedence here. - --- See also: GHC Proposal #344 ===================================== testsuite/tests/parser/should_compile/NegativeLiterals.hs ===================================== @@ -0,0 +1,57 @@ +{-# LANGUAGE NegativeLiterals, MagicHash, BinaryLiterals #-} + +module NegativeLiterals where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p1 :: Bool +p1 = even -2 -- parsed as: even (-2) + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p3 :: Int +p3 = floor -2.4 -- parsed as: floor (-2.4) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +p6 :: Bool +p6 = even -0b10 -- parsed as: even (-2) + || even -0o10 -- parsed as: even (-8) + || even -0x10 -- parsed as: even (-16) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti1 :: Integer -> Integer +ti1 x = x-2 -- parsed as: (-) x 1 + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) + +ti6 :: Integer -> [Integer] +ti6 x = + [ x-0b10, -- parsed as: (-) x 2 + x-0o10, -- parsed as: (-) x 8 + x-0x10 ] -- parsed as: (-) x 16 ===================================== testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs ===================================== @@ -0,0 +1,39 @@ +{-# LANGUAGE NoNegativeLiterals, MagicHash, BinaryLiterals #-} + +-- Even when NegativeLiterals are disabled, +-- we parse unboxed literals appropriately. +module NegativeLiteralsNoExt where + +import GHC.Exts + +------------------------------------ +-- Prefix occurrence of the minus -- +------------------------------------ + +p2 :: Int +p2 = I# -1# -- parsed as: I# (-1#) + +p4 :: Float +p4 = F# -0.01# -- parsed as: F# (-0.01#) + +p5 :: Double +p5 = D# -0.01## -- parsed as: D# (-0.01##) + +----------------------------------------- +-- Tight infix occurrence of the minus -- +----------------------------------------- + +ti2 :: Int# -> Int# +ti2 x = x-1# -- parsed as: (-) x 1# + where (-) = (-#) + +ti3 :: Double -> Double +ti3 x = x-2.4 -- parsed as: (-) x 2.4 + +ti4 :: Float# -> Float# +ti4 x = x-0.1# -- parsed as: (-) x 0.1# + where (-) = minusFloat# + +ti5 :: Double# -> Double# +ti5 x = x-0.1## -- parsed as: (-) x 0.1## + where (-) = (-##) ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -153,7 +153,8 @@ test('proposal-229b', normal, compile, ['']) test('proposal-229d', normal, compile, ['']) test('proposal-229e', normal, compile, ['']) test('LexicalNegation', normal, compile, ['']) -test('LexNegVsNegLit', normal, compile, ['']) +test('NegativeLiterals', normal, compile, ['']) +test('NegativeLiteralsNoExt', normal, compile, ['']) # We omit 'profasm' because it fails with: # Cannot load -prof objects when GHC is built with -dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b87eb02be35440dfc941e5e9a12dbcc01849e6d3...b7a902db47e91377b501400c66ab779003ad1182 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b87eb02be35440dfc941e5e9a12dbcc01849e6d3...b7a902db47e91377b501400c66ab779003ad1182 You're receiving 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 Jul 28 00:09:12 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 27 Jul 2020 20:09:12 -0400 Subject: [Git][ghc/ghc][master] Drop 32-bit Windows support Message-ID: <5f1f6ca8d6db1_80b3f848e5a5cd85392556@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 2 changed files: - .gitlab-ci.yml - docs/users_guide/8.12.1-notes.rst Changes: ===================================== .gitlab-ci.yml ===================================== @@ -817,15 +817,6 @@ validate-x86_64-windows-hadrian: cache: key: "x86_64-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" -nightly-i386-windows-hadrian: - <<: *nightly - extends: .build-windows-hadrian - variables: - MSYSTEM: MINGW32 - TEST_ENV: "i386-windows-hadrian" - cache: - key: "i386-windows-hadrian-$WINDOWS_TOOLCHAIN_VERSION" - .build-windows-make: extends: .build-windows stage: full-build @@ -882,34 +873,6 @@ release-x86_64-windows-integer-simple: BIGNUM_BACKEND: native BUILD_FLAVOUR: "perf" - -.build-i386-windows-make: - extends: .build-windows-make - variables: - MSYSTEM: MINGW32 - # Due to #15934 - BUILD_PROF_LIBS: "NO" - TEST_ENV: "i386-windows" - # Due to #17736 - allow_failure: true - cache: - key: "i386-windows-$WINDOWS_TOOLCHAIN_VERSION" - -validate-i386-windows: - extends: .build-i386-windows-make - variables: - BUILD_FLAVOUR: "perf" - -release-i386-windows: - <<: *release - extends: .build-i386-windows-make - variables: - BUILD_FLAVOUR: "perf" - -nightly-i386-windows: - <<: *nightly - extends: .build-i386-windows-make - ############################################################ # Cleanup ############################################################ ===================================== docs/users_guide/8.12.1-notes.rst ===================================== @@ -79,6 +79,11 @@ Highlights $(return []) instance C Bool where foo = True + * Support for 32-bit Windows has officially been dropped as Microsoft has + formally discontinued new 32-bit Windows 10 releases in 2020. See + :ghc-ticket:`18487` for details. + + Full details ------------ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aa054d32a8ff69c334293a0d6c9d11b83a236a96 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aa054d32a8ff69c334293a0d6c9d11b83a236a96 You're receiving 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 Jul 28 00:09:51 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 27 Jul 2020 20:09:51 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Add minimal test for #12492 Message-ID: <5f1f6ccf1f32b_80b3f848e5a5cd85398947@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3 changed files: - rts/PrimOps.cmm - + testsuite/tests/primops/should_run/T12492.hs - testsuite/tests/primops/should_run/all.T Changes: ===================================== rts/PrimOps.cmm ===================================== @@ -2360,6 +2360,7 @@ stg_mkApUpd0zh ( P_ bco ) stg_unpackClosurezh ( P_ closure ) { W_ info, ptrs, nptrs, p, ptrs_arr, dat_arr; + MAYBE_GC_P(stg_unpackClosurezh, closure); info = %GET_STD_INFO(UNTAG(closure)); prim_read_barrier; @@ -2375,12 +2376,13 @@ stg_unpackClosurezh ( P_ closure ) (len) = foreign "C" heap_view_closureSize(clos "ptr"); W_ ptrs_arr_sz, ptrs_arr_cards, dat_arr_sz; - dat_arr_sz = SIZEOF_StgArrBytes + WDS(len); - - ALLOC_PRIM_P (dat_arr_sz, stg_unpackClosurezh, closure); - - dat_arr = Hp - dat_arr_sz + WDS(1); + dat_arr_sz = SIZEOF_StgArrBytes + WDS(len); + ("ptr" dat_arr) = ccall allocateMightFail(MyCapability() "ptr", BYTES_TO_WDS(dat_arr_sz)); + if (dat_arr == NULL) (likely: False) { + jump stg_raisezh(base_GHCziIOziException_heapOverflow_closure); + } + TICK_ALLOC_PRIM(SIZEOF_StgArrBytes, WDS(len), 0); SET_HDR(dat_arr, stg_ARR_WORDS_info, CCCS); StgArrBytes_bytes(dat_arr) = WDS(len); ===================================== testsuite/tests/primops/should_run/T12492.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +import GHC.Exts +import GHC.IO + +main :: IO () +main = IO $ \s -> case newByteArray# 1032161# s of + (# s', mba# #) -> case unpackClosure# (unsafeCoerce# mba# :: Any) of + (# !_, _, _ #) -> (# s', () #) ===================================== testsuite/tests/primops/should_run/all.T ===================================== @@ -19,6 +19,7 @@ test('ArithWord8', omit_ways(['ghci']), compile_and_run, ['']) test('CmpInt8', normal, compile_and_run, ['']) test('CmpWord8', normal, compile_and_run, ['']) test('ShowPrim', normal, compile_and_run, ['']) +test('T12492', normal, compile_and_run, ['']) # These two tests use unboxed tuples, which GHCi doesn't support test('ArithInt16', omit_ways(['ghci']), compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aa054d32a8ff69c334293a0d6c9d11b83a236a96...47680cb76b068508fd16d052e0a3bed12e38ea5f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aa054d32a8ff69c334293a0d6c9d11b83a236a96...47680cb76b068508fd16d052e0a3bed12e38ea5f You're receiving 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 Jul 28 00:10:26 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 27 Jul 2020 20:10:26 -0400 Subject: [Git][ghc/ghc][master] Eta-expand the Simplifier monad Message-ID: <5f1f6cf23af4b_80b3f849420ad9854016d8@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 1 changed file: - compiler/GHC/Core/Opt/Simplify/Monad.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Monad.hs ===================================== @@ -43,6 +43,7 @@ import GHC.Utils.Panic (throwGhcExceptionIO, GhcException (..)) import GHC.Types.Basic ( IntWithInf, treatZeroAsInf, mkIntWithInf ) import Control.Monad ( ap ) import GHC.Core.Multiplicity ( pattern Many ) +import GHC.Exts( oneShot ) {- ************************************************************************ @@ -56,14 +57,25 @@ For the simplifier monad, we want to {\em thread} a unique supply and a counter. -} newtype SimplM result - = SM { unSM :: SimplTopEnv -- Envt that does not change much - -> UniqSupply -- We thread the unique supply because - -- constantly splitting it is rather expensive - -> SimplCount - -> IO (result, UniqSupply, SimplCount)} - -- we only need IO here for dump output + = SM' { unSM :: SimplTopEnv -- Envt that does not change much + -> UniqSupply -- We thread the unique supply because + -- constantly splitting it is rather expensive + -> SimplCount + -> IO (result, UniqSupply, SimplCount)} + -- We only need IO here for dump output deriving (Functor) +pattern SM :: (SimplTopEnv -> UniqSupply -> SimplCount + -> IO (result, UniqSupply, SimplCount)) + -> SimplM result +-- This pattern synonym makes the simplifier monad eta-expand, +-- which as a very beneficial effect on compiler performance +-- (worth a 1-2% reduction in bytes-allocated). See #18202. +-- See Note [The one-shot state monad trick] in GHC.Core.Unify +pattern SM m <- SM' m + where + SM m = SM' (oneShot m) + data SimplTopEnv = STE { st_flags :: DynFlags , st_max_ticks :: IntWithInf -- Max #ticks in this simplifier run View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d345c9680ab3d766ef43dd8389ccc1eaeca066c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d345c9680ab3d766ef43dd8389ccc1eaeca066c You're receiving 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 Jul 28 00:11:00 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 27 Jul 2020 20:11:00 -0400 Subject: [Git][ghc/ghc][master] 2 commits: gitlab-ci: Ensure that Hadrian jobs don't download artifacts Message-ID: <5f1f6d149c6da_80b3f848a2ebd5c5403349@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -190,6 +190,7 @@ lint-release-changelogs: key: hadrian paths: - cabal-cache + dependencies: [] artifacts: reports: junit: junit.xml @@ -292,8 +293,8 @@ hadrian-ghc-in-ghci: # porting guide [1]. # [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) CONFIGURE_ARGS: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" - GHC_VERSION: 8.10.1 - CABAL_INSTALL_VERSION: 3.2.0.0 + GHC_VERSION: "8.10.1" + CABAL_INSTALL_VERSION: "3.2.0.0" BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" TEST_ENV: "x86_64-freebsd" BUILD_FLAVOUR: "validate" @@ -367,7 +368,7 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: 8.8.3 + GHC_VERSION: 8.8.4 CABAL_INSTALL_VERSION: 3.0.0.0 BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-apple-darwin.tar.xz" MACOSX_DEPLOYMENT_TARGET: "10.7" @@ -395,7 +396,7 @@ validate-x86_64-darwin: tags: - x86_64-darwin variables: - GHC_VERSION: 8.8.3 + GHC_VERSION: 8.8.4 MACOSX_DEPLOYMENT_TARGET: "10.7" ac_cv_func_clock_gettime: "no" LANG: "en_US.UTF-8" @@ -776,8 +777,8 @@ validate-x86_64-linux-fedora27: #FORCE_SYMLINKS: 1 LANG: "en_US.UTF-8" SPHINXBUILD: "/mingw64/bin/sphinx-build.exe" - CABAL_INSTALL_VERSION: 3.0.0.0 - GHC_VERSION: "8.8.3" + CABAL_INSTALL_VERSION: "3.0.0.0" + GHC_VERSION: "8.8.4" cache: paths: - cabal-cache View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3d345c9680ab3d766ef43dd8389ccc1eaeca066c...0a815cea9fa11ce6ef22aec3525dd7a0df541daf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3d345c9680ab3d766ef43dd8389ccc1eaeca066c...0a815cea9fa11ce6ef22aec3525dd7a0df541daf You're receiving 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 Jul 28 00:37:01 2020 From: gitlab at gitlab.haskell.org (Brandon Chinn) Date: Mon, 27 Jul 2020 20:37:01 -0400 Subject: [Git][ghc/ghc][wip/T16341] Minor tweaks Message-ID: <5f1f732dab60f_80b104e15b45407086@gitlab.haskell.org.mail> Brandon Chinn pushed to branch wip/T16341 at Glasgow Haskell Compiler / GHC Commits: 91fa5efa by Brandon Chinn at 2020-07-27T17:36:56-07:00 Minor tweaks - - - - - 2 changed files: - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Infer.hs Changes: ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -35,7 +35,7 @@ module GHC.Tc.Deriv.Generate ( ordOpTbl, boxConTbl, litConTbl, mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr, - getPossibleDataCons, getTyConArgs + getPossibleDataCons, tyConInstArgTys ) where #include "HsVersions.h" @@ -2518,20 +2518,37 @@ newAuxBinderRdrName loc parent occ_fun = do uniq <- newUnique pure $ Exact $ mkSystemNameAt uniq (occ_fun (nameOccName parent)) loc --- | If we're deriving an instance for a GADT, e.g. `Eq (Foo Int)`, we should treat any constructors --- for which it's impossible to match `Foo Int` as not being there at all. +-- | @getPossibleDataCons tycon tycon_args@ returns the constructors of @tycon@ +-- whose return types match when checked against @tycon_args at . -- -- See Note [Filter out impossible GADT data constructors] getPossibleDataCons :: TyCon -> [Type] -> [DataCon] getPossibleDataCons tycon tycon_args = filter isPossible $ tyConDataCons tycon where - isPossible = not . dataConCannotMatch (getTyConArgs tycon tycon_args) + isPossible = not . dataConCannotMatch (tyConInstArgTys tycon tycon_args) --- | Get the full list of TyCon args, given a partial instantiation. +-- | Given a type constructor @tycon@ of arity /n/ and a list of argument types +-- @tycon_args@ of length /m/, -- --- e.g. Given 'tycon: Foo a b' and 'tycon_args: [Int]', return '[Int, b]'. -getTyConArgs :: TyCon -> [Type] -> [Type] -getTyConArgs tycon tycon_args = tycon_args ++ map mkTyVarTy tycon_args_suffix +-- @ +-- tyConInstArgTys tycon tycon_args +-- @ +-- +-- returns +-- +-- @ +-- [tycon_arg_{1}, tycon_arg_{2}, ..., tycon_arg_{m}, extra_arg_{m+1}, ..., extra_arg_{n}] +-- @ +-- +-- where @extra_args@ are distinct type variables. +-- +-- Examples: +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int, Bool]@, return @[Int, Bool]@. +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int]@, return @[Int, b]@. +tyConInstArgTys :: TyCon -> [Type] -> [Type] +tyConInstArgTys tycon tycon_args = chkAppend tycon_args $ map mkTyVarTy tycon_args_suffix where tycon_args_suffix = drop (length tycon_args) $ tyConTyVars tycon @@ -2766,7 +2783,18 @@ data Foo a where ``` when deriving an instance on `Foo Int`, `Y` should be treated as if it didn't -exist in the first place. +exist in the first place. For instance, if we write + +``` +deriving instance Eq (Foo Int) +``` + +it should generate: + +``` +instance Eq (Foo Int) where + X == X = True +``` Classes that filter constructors: ===================================== compiler/GHC/Tc/Deriv/Infer.hs ===================================== @@ -260,7 +260,7 @@ inferConstraintsStock (DerivInstTys { dit_cls_tys = cls_tys -- substitute each type variable with its counterpart in the derived -- instance. rep_tc_args lists each of these counterpart types in -- the same order as the type variables. - all_rep_tc_args = getTyConArgs rep_tc rep_tc_args + all_rep_tc_args = tyConInstArgTys rep_tc rep_tc_args -- Stupid constraints stupid_constraints View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91fa5efabb15b2467296791472c169271bbff455 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91fa5efabb15b2467296791472c169271bbff455 You're receiving 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 Jul 28 00:41:48 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 27 Jul 2020 20:41:48 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Drop 32-bit Windows support Message-ID: <5f1f744c80bb_80b3f849c1caa105410830@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - ddb908e7 by Simon Peyton Jones at 2020-07-27T20:41:40-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - edcc6c60 by Sylvain Henry at 2020-07-27T20:41:44-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - 6dd2d0fa by Peter Trommler at 2020-07-27T20:41:44-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 30 changed files: - .gitlab-ci.yml - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - docs/users_guide/8.12.1-notes.rst - libraries/base/Data/Bits.hs - rts/PrimOps.cmm - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/numeric/should_run/T18499.hs - + testsuite/tests/numeric/should_run/T18499.stdout - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T10421a.hs - + testsuite/tests/perf/compiler/T10421a_Form.hs - + testsuite/tests/perf/compiler/T13253-spj.hs - + testsuite/tests/perf/compiler/T13253.hs - + testsuite/tests/perf/compiler/T18140.hs - testsuite/tests/perf/compiler/all.T - + testsuite/tests/primops/should_run/T12492.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/61e1d542585b5be4e5fe26dc7e9245ff60efd32d...6dd2d0fad175b421a82a1121e0b86f46ee7d2eed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/61e1d542585b5be4e5fe26dc7e9245ff60efd32d...6dd2d0fad175b421a82a1121e0b86f46ee7d2eed You're receiving 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 Jul 28 01:18:57 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Mon, 27 Jul 2020 21:18:57 -0400 Subject: [Git][ghc/ghc][wip/T18470] Move renamer-based validity check to typechecker Message-ID: <5f1f7d01a01c1_80b3f849c1caa1054165e3@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18470 at Glasgow Haskell Compiler / GHC Commits: f6e8c7f2 by Ryan Scott at 2020-07-27T21:18:23-04:00 Move renamer-based validity check to typechecker - - - - - 11 changed files: - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Basic.hs - testsuite/tests/indexed-types/should_fail/Overlap5.stderr - testsuite/tests/rename/should_fail/T16002.stderr - testsuite/tests/th/T15362.hs - testsuite/tests/th/T15362.stderr - testsuite/tests/typecheck/should_fail/T11623.stderr Changes: ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -55,7 +55,7 @@ import GHC.Types.Name.Env import GHC.Types.Avail import GHC.Utils.Outputable import GHC.Data.Bag -import GHC.Types.Basic ( pprRuleName, TypeOrKind(..) ) +import GHC.Types.Basic ( pprRuleName, TypeOrKind(..), ClosedTyFamInfo(..) ) import GHC.Data.FastString import GHC.Types.SrcLoc as SrcLoc import GHC.Driver.Session @@ -763,7 +763,7 @@ rnFamInstEqn doc atfi rhs_kvars ; let eqn_fvs = rhs_fvs `plusFV` pat_fvs -- See Note [Type family equations and occurrences] all_fvs = case atfi of - NonAssocTyFamEqn (ClosedTyFam{}) + NonAssocTyFamEqn ClosedTyFam -> eqn_fvs _ -> eqn_fvs `addOneFV` unLoc tycon' @@ -851,13 +851,6 @@ data AssocTyFamInfo Name -- Name of the parent class [Name] -- Names of the tyvars of the parent instance decl --- | Tracks whether we are renaming an equation in a closed type family --- equation ('ClosedTyFam') or not ('NotClosedTyFam'). -data ClosedTyFamInfo - = NotClosedTyFam - | ClosedTyFam (Located RdrName) Name - -- The names (RdrName and Name) of the closed type family - rnTyFamInstEqn :: AssocTyFamInfo -> TyFamInstEqn GhcPs -> RnM (TyFamInstEqn GhcRn, FreeVars) @@ -865,19 +858,8 @@ rnTyFamInstEqn atfi eqn@(HsIB { hsib_body = FamEqn { feqn_tycon = tycon , feqn_rhs = rhs }}) = do { let rhs_kvs = extractHsTyRdrTyVarsKindVars rhs - ; (eqn'@(HsIB { hsib_body = - FamEqn { feqn_tycon = L _ tycon' }}), fvs) + ; (eqn', fvs) <- rnFamInstEqn (TySynCtx tycon) atfi rhs_kvs eqn rnTySyn - - -- For closed type families, check that each equation is for the - -- right type family. E.g. barf on - -- type family F a where { G Int = Bool } - ; case atfi of - NonAssocTyFamEqn (ClosedTyFam fam_rdr_name fam_name) -> - checkTc (fam_name == tycon') $ - withHsDocContext (TyFamilyCtx fam_rdr_name) $ - wrongTyFamName fam_name tycon' - _ -> pure () ; pure (eqn', fvs) } rnTyFamDefltDecl :: Name @@ -2023,7 +2005,7 @@ rnFamDecl mb_cls (FamilyDecl { fdLName = tycon, fdTyVars = tyvars ; injectivity' <- traverse (rnInjectivityAnn tyvars' res_sig') injectivity ; return ( (tyvars', res_sig', injectivity') , fv_kind ) } - ; (info', fv2) <- rn_info tycon' info + ; (info', fv2) <- rn_info info ; return (FamilyDecl { fdExt = noExtField , fdLName = tycon', fdTyVars = tyvars' , fdFixity = fixity @@ -2035,18 +2017,16 @@ rnFamDecl mb_cls (FamilyDecl { fdLName = tycon, fdTyVars = tyvars kvs = extractRdrKindSigVars res_sig ---------------------- - rn_info :: Located Name - -> FamilyInfo GhcPs -> RnM (FamilyInfo GhcRn, FreeVars) - rn_info (L _ fam_name) (ClosedTypeFamily (Just eqns)) + rn_info :: FamilyInfo GhcPs -> RnM (FamilyInfo GhcRn, FreeVars) + rn_info (ClosedTypeFamily (Just eqns)) = do { (eqns', fvs) - <- rnList (rnTyFamInstEqn (NonAssocTyFamEqn (ClosedTyFam tycon fam_name))) + <- rnList (rnTyFamInstEqn (NonAssocTyFamEqn ClosedTyFam)) eqns -- no class context - eqns ; return (ClosedTypeFamily (Just eqns'), fvs) } - rn_info _ (ClosedTypeFamily Nothing) + rn_info (ClosedTypeFamily Nothing) = return (ClosedTypeFamily Nothing, emptyFVs) - rn_info _ OpenTypeFamily = return (OpenTypeFamily, emptyFVs) - rn_info _ DataFamily = return (DataFamily, emptyFVs) + rn_info OpenTypeFamily = return (OpenTypeFamily, emptyFVs) + rn_info DataFamily = return (DataFamily, emptyFVs) rnFamResultSig :: HsDocContext -> FamilyResultSig GhcPs @@ -2190,13 +2170,6 @@ are no data constructors we allow h98_style = True * * ***************************************************** -} ---------------- -wrongTyFamName :: Name -> Name -> SDoc -wrongTyFamName fam_tc_name eqn_tc_name - = hang (text "Mismatched type name in type family instance.") - 2 (vcat [ text "Expected:" <+> ppr fam_tc_name - , text " Actual:" <+> ppr eqn_tc_name ]) - ----------------- rnConDecls :: [LConDecl GhcPs] -> RnM ([LConDecl GhcRn], FreeVars) rnConDecls = mapFvRn (wrapLocFstM rnConDecl) ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -31,6 +31,7 @@ import GHC.Builtin.Types import GHC.Builtin.Types.Prim( eqPrimTyCon, eqReprPrimTyCon ) import GHC.Builtin.Names +import GHC.Types.Basic ( ClosedTyFamInfo(..) ) import GHC.Types.Id import GHC.Core.Type import GHC.Core.Make ( mkStringExprFS, mkNaturalExpr ) @@ -58,6 +59,7 @@ import Data.Maybe -- The @VarEnv Type@ maps class variables to their instance types. data AssocInstInfo = NotAssociated + ClosedTyFamInfo -- Is this a closed type family? | InClsInst { ai_class :: Class , ai_tyvars :: [TyVar] -- ^ The /scoped/ tyvars of the instance -- Why scoped? See bind_me in @@ -67,8 +69,8 @@ data AssocInstInfo } isNotAssociated :: AssocInstInfo -> Bool -isNotAssociated NotAssociated = True -isNotAssociated (InClsInst {}) = False +isNotAssociated (NotAssociated {}) = True +isNotAssociated (InClsInst {}) = False {- ******************************************************************* ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -2432,7 +2432,7 @@ tcDefaultAssocDecl fam_tc -- at an associated type. But this would be wrong, because an associated -- type default LHS can mention *different* type variables than the -- enclosing class. So it's treated more as a freestanding beast. - ; (qtvs, pats, rhs_ty) <- tcTyFamInstEqnGuts fam_tc NotAssociated + ; (qtvs, pats, rhs_ty) <- tcTyFamInstEqnGuts fam_tc (NotAssociated NotClosedTyFam) imp_vars (mb_expl_bndrs `orElse` []) hs_pats hs_rhs_ty @@ -2639,7 +2639,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info False {- this doesn't matter here -} ClosedTypeFamilyFlavour - ; branches <- mapAndReportM (tcTyFamInstEqn tc_fam_tc NotAssociated) eqns + ; branches <- mapAndReportM (tcTyFamInstEqn tc_fam_tc (NotAssociated ClosedTyFam)) eqns -- Do not attempt to drop equations dominated by earlier -- ones here; in the case of mutual recursion with a data -- type, we get a knot-tying failure. Instead we check @@ -2862,16 +2862,25 @@ tcTyFamInstEqn fam_tc mb_clsinfo , feqn_bndrs = mb_expl_bndrs , feqn_pats = hs_pats , feqn_rhs = hs_rhs_ty }})) - = ASSERT( getName fam_tc == eqn_tc_name ) - setSrcSpan loc $ + = setSrcSpan loc $ do { traceTc "tcTyFamInstEqn" $ vcat [ ppr fam_tc <+> ppr hs_pats , text "fam tc bndrs" <+> pprTyVars (tyConTyVars fam_tc) , case mb_clsinfo of - NotAssociated -> empty + NotAssociated {} -> empty InClsInst { ai_class = cls } -> text "class" <+> ppr cls <+> pprTyVars (classTyVars cls) ] - -- First, check the arity of visible arguments + -- First, check if we're dealing with a closed type family equation, and + -- if so, ensure that each equation's type constructor is for the right + -- type family. E.g. barf on + -- type family F a where { G Int = Bool } + ; case mb_clsinfo of + NotAssociated ClosedTyFam + -> checkTc (fam_tc_name == eqn_tc_name) $ + wrongTyFamName fam_tc_name eqn_tc_name + _ -> pure () + + -- Next, check the arity of visible arguments -- If we wait until validity checking, we'll get kind errors -- below when an arity error will be much easier to understand. ; let vis_arity = length (tyConVisibleTyVars fam_tc) @@ -2886,6 +2895,8 @@ tcTyFamInstEqn fam_tc mb_clsinfo ; return (mkCoAxBranch qtvs [] [] pats rhs_ty (map (const Nominal) qtvs) loc) } + where + fam_tc_name = getName fam_tc {- Kind check type patterns and kind annotate the embedded type variables. @@ -4919,6 +4930,12 @@ incoherentRoles = (text "Roles other than" <+> quotes (text "nominal") <+> text "for class parameters can lead to incoherence.") $$ (text "Use IncoherentInstances to allow this; bad role found") +wrongTyFamName :: Name -> Name -> SDoc +wrongTyFamName fam_tc_name eqn_tc_name + = hang (text "Mismatched type name in type family instance.") + 2 (vcat [ text "Expected:" <+> ppr fam_tc_name + , text " Actual:" <+> ppr eqn_tc_name ]) + addTyConCtxt :: TyCon -> TcM a -> TcM a addTyConCtxt tc = addTyConFlavCtxt name flav where ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -458,11 +458,11 @@ tcLocalInstDecl :: LInstDecl GhcRn -- -- We check for respectable instance type, and context tcLocalInstDecl (L loc (TyFamInstD { tfid_inst = decl })) - = do { fam_inst <- tcTyFamInstDecl NotAssociated (L loc decl) + = do { fam_inst <- tcTyFamInstDecl (NotAssociated NotClosedTyFam) (L loc decl) ; return ([], [fam_inst], []) } tcLocalInstDecl (L loc (DataFamInstD { dfid_inst = decl })) - = do { (fam_inst, m_deriv_info) <- tcDataFamInstDecl NotAssociated emptyVarEnv (L loc decl) + = do { (fam_inst, m_deriv_info) <- tcDataFamInstDecl (NotAssociated NotClosedTyFam) emptyVarEnv (L loc decl) ; return ([], [fam_inst], maybeToList m_deriv_info) } tcLocalInstDecl (L loc (ClsInstD { cid_inst = decl })) ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -2271,7 +2271,7 @@ checkConsistentFamInst :: AssocInstInfo -> TcM () -- See Note [Checking consistent instantiation] -checkConsistentFamInst NotAssociated _ _ +checkConsistentFamInst (NotAssociated {}) _ _ = return () checkConsistentFamInst (InClsInst { ai_class = clas ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -108,7 +108,9 @@ module GHC.Types.Basic ( SpliceExplicitFlag(..), - TypeOrKind(..), isTypeLevel, isKindLevel + TypeOrKind(..), isTypeLevel, isKindLevel, + + ClosedTyFamInfo(..) ) where import GHC.Prelude @@ -1843,3 +1845,16 @@ isTypeLevel KindLevel = False isKindLevel :: TypeOrKind -> Bool isKindLevel TypeLevel = False isKindLevel KindLevel = True + +{- +************************************************************************ +* * + ClosedTyFamInfo +* * +************************************************************************ +-} + +-- | Is a type family closed ('ClosedTyFam') or not ('NotClosedTyFam')? +data ClosedTyFamInfo + = NotClosedTyFam + | ClosedTyFam ===================================== testsuite/tests/indexed-types/should_fail/Overlap5.stderr ===================================== @@ -1,6 +1,6 @@ Overlap5.hs:8:3: error: - Mismatched type name in type family instance. - Expected: F - Actual: G - In the declaration for type family ‘F’ + • Mismatched type name in type family instance. + Expected: F + Actual: G + • In the type family declaration for ‘F’ ===================================== testsuite/tests/rename/should_fail/T16002.stderr ===================================== @@ -1,6 +1,6 @@ T16002.hs:6:3: error: - Mismatched type name in type family instance. - Expected: B - Actual: A - In the declaration for type family ‘B’ + • Mismatched type name in type family instance. + Expected: B + Actual: A + • In the type family declaration for ‘B’ ===================================== testsuite/tests/th/T15362.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds #-} +{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds, TypeFamilies #-} module T15362 where ===================================== testsuite/tests/th/T15362.stderr ===================================== @@ -1,10 +1,6 @@ -T15362.hs:8:10: error: +T15362.hs:7:2: error: • Mismatched type name in type family instance. Expected: + Actual: Maybe - In the declaration for type family ‘+’ - • In the Template Haskell quotation - [d| type family a + b where - Maybe Zero b = b - Succ a + b = Succ (a + b) |] + • In the type family declaration for ‘+’ ===================================== testsuite/tests/typecheck/should_fail/T11623.stderr ===================================== @@ -1,6 +1,4 @@ T11623.hs:5:23: error: - Mismatched type name in type family instance. - Expected: T - Actual: Maybe - In the declaration for type family ‘T’ + • Number of parameters must match family declaration; expected 0 + • In the type family declaration for ‘T’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f6e8c7f27f2871d89797defaa69509995c30fa11 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f6e8c7f27f2871d89797defaa69509995c30fa11 You're receiving 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 Jul 28 04:09:31 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Tue, 28 Jul 2020 00:09:31 -0400 Subject: [Git][ghc/ghc][wip/derived-refactor] Embrace oclose. Message-ID: <5f1fa4fb14d58_80b3f848a37384c5427560@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/derived-refactor at Glasgow Haskell Compiler / GHC Commits: d57c9cdb by Richard Eisenberg at 2020-07-28T00:09:05-04:00 Embrace oclose. - - - - - 19 changed files: - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Instance/FunDeps.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Monad.hs - − testsuite/tests/typecheck/should_compile/T18398.stderr - testsuite/tests/typecheck/should_compile/T7220a.stderr - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/FD1.hs - testsuite/tests/typecheck/should_fail/FD1.stderr - testsuite/tests/typecheck/should_fail/FD2.stderr - testsuite/tests/typecheck/should_fail/T10194.stderr - testsuite/tests/typecheck/should_fail/T11514.stderr - testsuite/tests/typecheck/should_fail/T12563.stderr - testsuite/tests/typecheck/should_fail/T12589.stderr - testsuite/tests/typecheck/should_compile/T18398.hs → testsuite/tests/typecheck/should_fail/T18398.hs - + testsuite/tests/typecheck/should_fail/T18398.stderr - testsuite/tests/typecheck/should_compile/T18406.hs → testsuite/tests/typecheck/should_fail/T18406.hs - + testsuite/tests/typecheck/should_fail/T18406.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -524,8 +524,14 @@ This only matters in instance declarations.. -} -- | A predicate with its arising location; used to encapsulate a constraint --- that will give rise to a warning. +-- that will give rise to a diagnostic. data ErrorItem +-- We could perhaps use Ct here (and indeed used to do exactly that), but +-- having a separate type gives to denote errors-in-formation gives us +-- a nice place to do pre-processing, such as calculating ei_suppress. +-- Perhaps some day, an ErrorItem could eventually evolve to contain +-- the error text (or some representation of it), so we can then have all +-- the errors together when deciding which to report. = EI { ei_pred :: PredType -- report about this -- The ei_pred field will never be an unboxed equality with -- a (casted) tyvar on the right; this is guaranteed by the solver @@ -666,9 +672,6 @@ reportWanteds ctxt tc_lvl (WC { wc_simple = simples, wc_impl = implics suppress item | Wanted _ <- ei_flavour item = is_ww_fundep_item item -{- "RAE" || (not has_gadt_match_here && - is_given_eq item (classifyPredType (ei_pred item))) --} | otherwise = False @@ -747,7 +750,7 @@ reportWanteds ctxt tc_lvl (WC { wc_simple = simples, wc_impl = implics is_irred _ (IrredPred {}) = True is_irred _ _ = False - -- See situation (2) of Note [Suppress confusing errors] + -- See situation (1) of Note [Suppress confusing errors] is_ww_fundep item _ = is_ww_fundep_item item is_ww_fundep_item = isWantedWantedFunDepOrigin . errorItemOrigin @@ -798,7 +801,7 @@ isTyFun_maybe ty = case tcSplitTyConApp_maybe ty of Certain errors we might encounter are potentially confusing to users. If there are any other errors to report, at all, we want to suppress these. -Which errors: +Which errors (only 1 case right now): 1) Errors which arise from the interaction of two Wanted fun-dep constraints. Example: @@ -828,14 +831,6 @@ Which errors: both are givens, the error represents unreachable code. For a Given/Wanted case, see #9612. -2) Errors which arise from given functional dependencies. Functional - dependencies have no evidence, and so they are always Wanted -- we have no - evidence to supply to build a Given. So we can have a Wanted that arises - from Givens. These can be surprising for users. However, we still must - report (in contrast to Note [Given errors]): the (non-existent) evidence - might have been used to rewrite another Wanted. If we fail to report, then - we get an unfilled coercion hole. This happened in typecheck/should_fail/FD1. - Mechanism: We use the `suppress` function within reportWanteds to filter out these two ===================================== compiler/GHC/Tc/Instance/FunDeps.hs ===================================== @@ -551,6 +551,13 @@ oclose preds fixed_tvs | null tv_fds = fixed_tvs -- Fast escape hatch for common case. | otherwise = fixVarSet extend fixed_tvs where + non_ip_preds = filterOut isIPPred preds + -- implicit params don't really determine a type variable, and + -- skipping this causes implicit params to monomorphise too many + -- variables; see Note [Inheriting implicit parameters] in + -- GHC.Tc.Utils.TcType. Skipping causes typecheck/should_compile/tc219 + -- to fail. + extend fixed_tvs = foldl' add fixed_tvs tv_fds where add fixed_tvs (ls,rs) @@ -561,7 +568,7 @@ oclose preds fixed_tvs tv_fds :: [(TyCoVarSet,TyCoVarSet)] tv_fds = [ (tyCoVarsOfTypes ls, fvVarSet $ injectiveVarsOfTypes True rs) -- See Note [Care with type functions] - | pred <- preds + | pred <- non_ip_preds , pred' <- pred : transSuperClasses pred -- Look for fundeps in superclasses too , (ls, rs) <- determined pred' ] ===================================== compiler/GHC/Tc/Solver.hs ===================================== @@ -1063,9 +1063,8 @@ decideMonoTyVars infer_mode name_taus psigs candidates ; tc_lvl <- TcM.getTcLevel ; let psig_tys = mkTyVarTys psig_qtvs ++ psig_theta - all_tys = candidates ++ psig_tys ++ taus - co_vars = coVarsOfTypes all_tys + co_vars = coVarsOfTypes (psig_tys ++ taus) co_var_tvs = closeOverKinds co_vars -- The co_var_tvs are tvs mentioned in the types of covars or -- coercion holes. We can't quantify over these covars, so we @@ -1074,7 +1073,7 @@ decideMonoTyVars infer_mode name_taus psigs candidates -- quantify over k either! Hence closeOverKinds mono_tvs0 = filterVarSet (not . isQuantifiableTv tc_lvl) $ - tyCoVarsOfTypes all_tys + tyCoVarsOfTypes candidates -- We need to grab all the non-quantifiable tyvars in the -- types so that we can grow this set to find other -- non-quantifiable tyvars. This can happen with something @@ -1093,21 +1092,14 @@ decideMonoTyVars infer_mode name_taus psigs candidates -- (that's mono_tvs0) and the set of covars, closed over kinds. -- Given this set of variables we know we will not quantify, -- we want to find any other variables that are determined by this - -- set, by functional dependencies or equalities. But we - -- want to look at only those constraints which we are unlikely - -- to quantify over, in the end. (If we quantify over the constraint - -- itself, then there is no need to avoid quantifying over its - -- variables.) This final determination is done by - -- pickQuantifiablePreds, but it needs to know the set of - -- quantified variables first. So we make an approximation here: - -- we guess that we will not quantify over equalities, but will - -- quantify over everything else. - - eq_constraints = filter isEqPrimPred candidates - mono_tvs2 = oclose eq_constraints mono_tvs1 + -- set, by functional dependencies or equalities. We thus use + -- oclose to find all further variables determined by this root + -- set. + + mono_tvs2 = oclose candidates mono_tvs1 constrained_tvs = filterVarSet (isQuantifiableTv tc_lvl) $ - (oclose eq_constraints (tyCoVarsOfTypes no_quant) + (oclose candidates (tyCoVarsOfTypes no_quant) `minusVarSet` mono_tvs2) `delVarSetList` psig_qtvs -- constrained_tvs: the tyvars that we are not going to ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -1646,7 +1646,8 @@ maybeKickOut ics ct ; return ics' } -- See [Kick out existing binding for implicit parameter] - | CDictCan { cc_class = cls, cc_tyargs = [ip_name_strty, _ip_ty] } <- ct + | isGivenCt ct + , CDictCan { cc_class = cls, cc_tyargs = [ip_name_strty, _ip_ty] } <- ct , isIPClass cls , Just ip_name <- isStrLitTy ip_name_strty -- Would this be more efficient if we used findDictsByClass and then delDict? ===================================== testsuite/tests/typecheck/should_compile/T18398.stderr deleted ===================================== @@ -1,13 +0,0 @@ -TYPE SIGNATURES - f :: forall {p}. C Ex p => Ex -> (p -> (), p -> ()) - meth :: forall a b. C a b => a -> b -> () -TYPE CONSTRUCTORS - class C{2} :: * -> * -> Constraint - data type Ex{0} :: * -COERCION AXIOMS - axiom FloatFDs2.N:C :: C a b = a -> b -> () -DATA CONSTRUCTORS - MkEx :: forall a. a -> Ex -Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.3.0] ===================================== testsuite/tests/typecheck/should_compile/T7220a.stderr ===================================== @@ -1,14 +1,22 @@ T7220a.hs:17:6: error: - • Could not deduce (C a b) - from the context: (C a0 b, TF b ~ Y) - bound by a type expected by the context: - forall b. (C a0 b, TF b ~ Y) => b + • Couldn't match type ‘a0’ with ‘a’ + arising from a functional dependency between constraints: + ‘C a b’ + arising from a type expected by the context: + forall b. (C a b, TF b ~ Y) => b at T7220a.hs:17:6-44 + ‘C a0 b’ + arising from a type expected by the context: + forall b. (C a0 b, TF b ~ Y) => b at T7220a.hs:17:6-44 + ‘a0’ is untouchable + inside the constraints: (C a0 b, TF b ~ Y) + bound by a type expected by the context: + forall b. (C a0 b, TF b ~ Y) => b + at T7220a.hs:17:6-44 + ‘a’ is a rigid type variable bound by + the type signature for: + f :: forall a. (forall b. (C a b, TF b ~ Y) => b) -> X at T7220a.hs:17:6-44 - Possible fix: - add (C a b) to the context of - a type expected by the context: - forall b. (C a0 b, TF b ~ Y) => b • In the ambiguity check for ‘f’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes In the type signature: f :: (forall b. (C a b, TF b ~ Y) => b) -> X ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -704,6 +704,4 @@ test('T18036', normal, compile, ['']) test('T18036a', normal, compile, ['']) test('FunDepOrigin1', normal, compile, ['']) test('FloatFDs', normal, compile, ['']) -test('T18398', normal, compile, ['']) test('ImplicitParamFDs', normal, compile, ['']) -test('T18406', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/FD1.hs ===================================== @@ -14,4 +14,3 @@ instance E a a plus :: (E a (Int -> Int)) => Int -> a plus x y = x + y - ===================================== testsuite/tests/typecheck/should_fail/FD1.stderr ===================================== @@ -1,15 +1,10 @@ -FD1.hs:15:9: error: - • Couldn't match type ‘a’ with ‘Int -> Int’ - arising from a functional dependency between: - constraint ‘E a (Int -> Int)’ - arising from the type signature for: - plus :: forall a. E a (Int -> Int) => Int -> a - instance ‘E a1 a1’ at FD1.hs:13:10-14 +FD1.hs:16:1: error: + • Couldn't match expected type ‘a’ with actual type ‘Int -> Int’ ‘a’ is a rigid type variable bound by the type signature for: plus :: forall a. E a (Int -> Int) => Int -> a - at FD1.hs:15:9-38 - • In the ambiguity check for ‘plus’ - To defer the ambiguity check to use sites, enable AllowAmbiguousTypes - In the type signature: plus :: (E a (Int -> Int)) => Int -> a + at FD1.hs:15:1-38 + • The equation(s) for ‘plus’ have two value arguments, + but its type ‘Int -> a’ has only one + • Relevant bindings include plus :: Int -> a (bound at FD1.hs:16:1) ===================================== testsuite/tests/typecheck/should_fail/FD2.stderr ===================================== @@ -1,17 +1,6 @@ -FD2.hs:24:12: error: - • Couldn't match type ‘e1’ with ‘e’ - arising from a functional dependency between constraints: - ‘Elem a e1’ - arising from the type signature for: - mf :: forall e. - Elem a e => - e -> Maybe e -> Maybe e at FD2.hs:24:12-54 - ‘Elem a e’ - arising from the type signature for: - foldr1 :: forall e. - Elem a e => - (e -> e -> e) -> a -> e at FD2.hs:21:13-47 +FD2.hs:26:36: error: + • Couldn't match expected type ‘e’ with actual type ‘e1’ ‘e1’ is a rigid type variable bound by the type signature for: mf :: forall e1. Elem a e1 => e1 -> Maybe e1 -> Maybe e1 @@ -20,13 +9,12 @@ FD2.hs:24:12: error: the type signature for: foldr1 :: forall e. Elem a e => (e -> e -> e) -> a -> e at FD2.hs:21:13-47 - • In an equation for ‘foldr1’: - foldr1 f xs - = fromMaybe (error "foldr1: empty structure") (foldr mf Nothing xs) - where - mf :: Elem a e => (e -> Maybe e -> Maybe e) - mf x Nothing = Just x - mf x (Just y) = Just (f x y) + • In the first argument of ‘f’, namely ‘x’ + In the first argument of ‘Just’, namely ‘(f x y)’ + In the expression: Just (f x y) • Relevant bindings include + y :: e1 (bound at FD2.hs:26:23) + x :: e1 (bound at FD2.hs:26:15) + mf :: e1 -> Maybe e1 -> Maybe e1 (bound at FD2.hs:25:12) f :: e -> e -> e (bound at FD2.hs:22:10) foldr1 :: (e -> e -> e) -> a -> e (bound at FD2.hs:22:3) ===================================== testsuite/tests/typecheck/should_fail/T10194.stderr ===================================== @@ -2,6 +2,5 @@ T10194.hs:7:8: error: • Cannot instantiate unification variable ‘b0’ with a type involving polytypes: X - GHC doesn't yet support impredicative polymorphism • In the expression: (.) In an equation for ‘comp’: comp = (.) ===================================== testsuite/tests/typecheck/should_fail/T11514.stderr ===================================== @@ -2,7 +2,6 @@ T11514.hs:6:7: error: • Cannot instantiate unification variable ‘a0’ with a type involving polytypes: (Show a => a -> a) -> () - GHC doesn't yet support impredicative polymorphism • In the expression: undefined In an equation for ‘foo’: foo = undefined • Relevant bindings include ===================================== testsuite/tests/typecheck/should_fail/T12563.stderr ===================================== @@ -2,7 +2,6 @@ T12563.hs:7:15: error: • Cannot instantiate unification variable ‘p0’ with a type involving polytypes: (forall a. f0 a) -> f0 r0 - GHC doesn't yet support impredicative polymorphism • In the first argument of ‘foo’, namely ‘g’ In the expression: foo g In the expression: \ g -> foo g ===================================== testsuite/tests/typecheck/should_fail/T12589.stderr ===================================== @@ -5,7 +5,6 @@ T12589.hs:13:5: error: • Cannot instantiate unification variable ‘t1’ with a type involving polytypes: (forall a. Bounded a => f0 a) -> h0 f0 xs0 - GHC doesn't yet support impredicative polymorphism • In the second argument of ‘(&)’, namely ‘hcpure (Proxy @Bounded)’ In the expression: minBound & hcpure (Proxy @Bounded) In an equation for ‘a’: a = minBound & hcpure (Proxy @Bounded) ===================================== testsuite/tests/typecheck/should_compile/T18398.hs → testsuite/tests/typecheck/should_fail/T18398.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T18398.stderr ===================================== @@ -0,0 +1,6 @@ + +T18398.hs:13:70: error: + • No instance for (C Ex p0) arising from a use of ‘meth’ + • In the expression: meth x z + In a case alternative: MkEx _ -> meth x z + In the expression: case x of { MkEx _ -> meth x z } ===================================== testsuite/tests/typecheck/should_compile/T18406.hs → testsuite/tests/typecheck/should_fail/T18406.hs ===================================== @@ -6,3 +6,10 @@ class C a b | a -> b where op :: a -> b -> () f x = op True x + +{- We could accept this, quantifying over a C Bool b constraint. But this is a +bit silly, actually, because the b is fixed by the fundep. We don't know what +it's fix to, but it's definitely fixed. So, in the end, we choose not to +Henry Ford polymorphism ("it works for any b as long as b is ???") and not +to quantify. Users can quantify manually if they want. +-} ===================================== testsuite/tests/typecheck/should_fail/T18406.stderr ===================================== @@ -0,0 +1,5 @@ + +T18406.hs:8:7: error: + • No instance for (C Bool b0) arising from a use of ‘op’ + • In the expression: op True x + In an equation for ‘f’: f x = op True x ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -572,3 +572,5 @@ test('FunDepOrigin1b', normal, compile_fail, ['']) test('FD1', normal, compile_fail, ['']) test('FD2', normal, compile_fail, ['']) test('FD3', normal, compile_fail, ['']) +test('T18398', normal, compile_fail, ['']) +test('T18406', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d57c9cdb2d4d11ecae98c75bb5c5d03abe61374d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d57c9cdb2d4d11ecae98c75bb5c5d03abe61374d You're receiving 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 Jul 28 06:01:54 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 28 Jul 2020 02:01:54 -0400 Subject: [Git][ghc/ghc][master] This patch addresses the exponential blow-up in the simplifier. Message-ID: <5f1fbf522d13f_80b3f848c1e06f45432578@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 30 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T10421a.hs - + testsuite/tests/perf/compiler/T10421a_Form.hs - + testsuite/tests/perf/compiler/T13253-spj.hs - + testsuite/tests/perf/compiler/T13253.hs - + testsuite/tests/perf/compiler/T18140.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T15631.stdout - testsuite/tests/simplCore/should_compile/T17901.stdout - testsuite/tests/simplCore/should_compile/T18355.stderr - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4908.stderr - testsuite/tests/simplCore/should_compile/T4930.stderr - testsuite/tests/simplCore/should_compile/T5366.stdout - testsuite/tests/simplCore/should_compile/T7360.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bd60059b0edfee9e8f66c6817257bbb946656cd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bd60059b0edfee9e8f66c6817257bbb946656cd You're receiving 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 Jul 28 06:02:34 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 28 Jul 2020 02:02:34 -0400 Subject: [Git][ghc/ghc][master] Bignum: add support for negative shifts (fix #18499) Message-ID: <5f1fbf7a4505f_80b3f848a37384c544033e@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - 4 changed files: - libraries/base/Data/Bits.hs - + testsuite/tests/numeric/should_run/T18499.hs - + testsuite/tests/numeric/should_run/T18499.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== libraries/base/Data/Bits.hs ===================================== @@ -537,8 +537,14 @@ instance Bits Integer where (.|.) = integerOr xor = integerXor complement = integerComplement - shiftR x i = integerShiftR x (fromIntegral i) - shiftL x i = integerShiftL x (fromIntegral i) + unsafeShiftR x i = integerShiftR x (fromIntegral i) + unsafeShiftL x i = integerShiftL x (fromIntegral i) + shiftR x i@(I# i#) + | isTrue# (i# >=# 0#) = unsafeShiftR x i + | otherwise = overflowError + shiftL x i@(I# i#) + | isTrue# (i# >=# 0#) = unsafeShiftL x i + | otherwise = overflowError shift x i | i >= 0 = integerShiftL x (fromIntegral i) | otherwise = integerShiftR x (fromIntegral (negate i)) testBit x i = integerTestBit x (fromIntegral i) @@ -560,8 +566,14 @@ instance Bits Natural where xor = naturalXor complement _ = errorWithoutStackTrace "Bits.complement: Natural complement undefined" - shiftR x i = naturalShiftR x (fromIntegral i) - shiftL x i = naturalShiftL x (fromIntegral i) + unsafeShiftR x i = naturalShiftR x (fromIntegral i) + unsafeShiftL x i = naturalShiftL x (fromIntegral i) + shiftR x i@(I# i#) + | isTrue# (i# >=# 0#) = unsafeShiftR x i + | otherwise = overflowError + shiftL x i@(I# i#) + | isTrue# (i# >=# 0#) = unsafeShiftL x i + | otherwise = overflowError shift x i | i >= 0 = naturalShiftL x (fromIntegral i) | otherwise = naturalShiftR x (fromIntegral (negate i)) ===================================== testsuite/tests/numeric/should_run/T18499.hs ===================================== @@ -0,0 +1,27 @@ +import Data.Bits +import Numeric.Natural +import GHC.Exception.Type +import Control.Exception + +main :: IO () +main = do + test ((42 `shiftR` (-1)) :: Integer) + test ((42 `shiftL` (-1)) :: Integer) + test ((42 `shiftR` (-1)) :: Natural) + test ((42 `shiftL` (-1)) :: Natural) + test ((42 `shiftR` (-1)) :: Word) + test ((42 `shiftL` (-1)) :: Word) + test ((42 `shiftR` (-1)) :: Int) + test ((42 `shiftL` (-1)) :: Int) + + test ((42 `unsafeShiftR` 2) :: Integer) + test ((42 `unsafeShiftL` 2) :: Integer) + test ((42 `unsafeShiftR` 2) :: Natural) + test ((42 `unsafeShiftL` 2) :: Natural) + test ((42 `unsafeShiftR` 2) :: Word) + test ((42 `unsafeShiftL` 2) :: Word) + test ((42 `unsafeShiftR` 2) :: Int) + test ((42 `unsafeShiftL` 2) :: Int) + +test :: Show a => a -> IO () +test a = print a `catch` (\Overflow -> putStrLn "Overflow!") ===================================== testsuite/tests/numeric/should_run/T18499.stdout ===================================== @@ -0,0 +1,16 @@ +Overflow! +Overflow! +Overflow! +Overflow! +Overflow! +Overflow! +Overflow! +Overflow! +10 +168 +10 +168 +10 +168 +10 +168 ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -70,3 +70,4 @@ test('T15301', normal, compile_and_run, ['-O2']) test('T497', normal, compile_and_run, ['-O']) test('T17303', normal, compile_and_run, ['']) test('T18359', normal, compile_and_run, ['']) +test('T18499', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6ee07b494ddd0131d53ea2fd6a4bb29cd05f4dd8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6ee07b494ddd0131d53ea2fd6a4bb29cd05f4dd8 You're receiving 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 Jul 28 06:03:09 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 28 Jul 2020 02:03:09 -0400 Subject: [Git][ghc/ghc][master] config: Fix Haskell platform constructor w/ params Message-ID: <5f1fbf9d5c2bb_80b3f849c1caa1054446b5@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 1 changed file: - aclocal.m4 Changes: ===================================== aclocal.m4 ===================================== @@ -190,10 +190,10 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], test -z "[$]2" || eval "[$]2=ArchPPC" ;; powerpc64) - test -z "[$]2" || eval "[$]2=\"ArchPPC_64 {ppc_64ABI = ELF_V1}\"" + test -z "[$]2" || eval "[$]2=\"ArchPPC_64 ELF_V1\"" ;; powerpc64le) - test -z "[$]2" || eval "[$]2=\"ArchPPC_64 {ppc_64ABI = ELF_V2}\"" + test -z "[$]2" || eval "[$]2=\"ArchPPC_64 ELF_V2\"" ;; s390x) test -z "[$]2" || eval "[$]2=ArchS390X" @@ -206,7 +206,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], ;; arm) GET_ARM_ISA() - test -z "[$]2" || eval "[$]2=\"ArchARM {armISA = \$ARM_ISA, armISAExt = \$ARM_ISA_EXT, armABI = \$ARM_ABI}\"" + test -z "[$]2" || eval "[$]2=\"ArchARM \$ARM_ISA \$ARM_ISA_EXT \$ARM_ABI}\"" ;; aarch64) test -z "[$]2" || eval "[$]2=ArchARM64" @@ -1919,7 +1919,7 @@ AC_MSG_CHECKING(for path to top of build tree) # GHC_CONVERT_CPU(cpu, target_var) # -------------------------------- # Converts cpu from gnu to ghc naming, and assigns the result to $target_var. -# Should you modify this list, you are invited to reflect the changes in +# Should you modify this list, you are invited to reflect the changes in # `libraries/base/System/Info.hs`'s documentation. AC_DEFUN([GHC_CONVERT_CPU],[ case "$1" in View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f305bbfd0d7afee8fe7464252fbfc167205220ae -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f305bbfd0d7afee8fe7464252fbfc167205220ae You're receiving 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 Jul 28 06:33:49 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 28 Jul 2020 02:33:49 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: This patch addresses the exponential blow-up in the simplifier. Message-ID: <5f1fc6cd26c25_80b3f849420ad9854461b9@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 4ee614a7 by Oleg Grenrus at 2020-07-28T02:33:46-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 37ba5283 by Simon Peyton Jones at 2020-07-28T02:33:46-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 30 changed files: - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Types/Name/Reader.hs - libraries/base/Data/Bits.hs - libraries/base/GHC/IO.hs - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/numeric/should_run/T18499.hs - + testsuite/tests/numeric/should_run/T18499.stdout - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T10421a.hs - + testsuite/tests/perf/compiler/T10421a_Form.hs - + testsuite/tests/perf/compiler/T13253-spj.hs - + testsuite/tests/perf/compiler/T13253.hs - + testsuite/tests/perf/compiler/T18140.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T15631.stdout The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6dd2d0fad175b421a82a1121e0b86f46ee7d2eed...37ba5283db32b5cae501728e2021d3f7a042a730 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6dd2d0fad175b421a82a1121e0b86f46ee7d2eed...37ba5283db32b5cae501728e2021d3f7a042a730 You're receiving 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 Jul 28 08:26:49 2020 From: gitlab at gitlab.haskell.org (Peter Trommler) Date: Tue, 28 Jul 2020 04:26:49 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18505-fixup Message-ID: <5f1fe149c06bd_80b3f849c1caa10545647@gitlab.haskell.org.mail> Peter Trommler pushed new branch wip/T18505-fixup at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18505-fixup You're receiving 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 Jul 28 09:10:44 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 28 Jul 2020 05:10:44 -0400 Subject: [Git][ghc/ghc][wip/explicit-perf-baseline] gitlab-ci: Use MR base commit as performance baseline Message-ID: <5f1feb94cf61f_80b3f849420ad985464387@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/explicit-perf-baseline at Glasgow Haskell Compiler / GHC Commits: df50f2f7 by Ben Gamari at 2020-07-28T05:10:40-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 3 changed files: - .gitlab-ci.yml - hadrian/src/Settings/Builders/RunTest.hs - testsuite/mk/test.mk Changes: ===================================== .gitlab-ci.yml ===================================== @@ -16,6 +16,9 @@ variables: GIT_SUBMODULE_STRATEGY: "recursive" + # Commit used by testsuite driver as performance baseline. + PERF_BASELINE_COMMIT: "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" + stages: - lint # Source linting - quick-build # A very quick smoke-test to weed out broken commits @@ -26,12 +29,26 @@ stages: - testing # head.hackage correctness and compiler performance testing - deploy # push documentation +# Note [The CI Story] +# ~~~~~~~~~~~~~~~~~~~ +# +# There are roughly three different types of pipelines: +# +# - marge-bot merges to `master`. Here we perform an exhaustive validation +# across all of the platforms which we support. In addition, we push +# performance metric notes upstream, providing a persistant record of the +# performance characteristics of the compiler. +# +# - merge requests. Here we perform a slightly less exhaustive battery of +# testing. Namely we omit some configurations (e.g. the unregisterised job). + + workflow: - # N.B.Don't run on wip/ branches, instead on run on merge requests. + # N.B. Don't run on wip/ branches, instead on run on merge requests. rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG - - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"' - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - if: '$CI_PIPELINE_SOURCE == "web"' ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -78,6 +78,7 @@ runTestBuilderArgs = builder RunTest ? do <*> (maybe False (=="YES") <$> lookupEnv "OS") (testEnv, testMetricsFile) <- expr . liftIO $ (,) <$> lookupEnv "TEST_ENV" <*> lookupEnv "METRICS_FILE" + perfBaseline <- expr . liftIO $ lookupEnv "PERF_BASELINE_COMMIT" threads <- shakeThreads <$> expr getShakeOptions os <- getTestSetting TestHostOS @@ -141,6 +142,9 @@ runTestBuilderArgs = builder RunTest ? do , arg "--config", arg $ "timeout_prog=" ++ show (top -/- timeoutProg) , arg "--config", arg $ "stats_files_dir=" ++ statsFilesDir , arg $ "--threads=" ++ show threads + , case perfBaseline of + Just commit | not (null commit) -> arg ("--perf-baseline=" ++ show commit) + _ -> mempty , emitWhenSet testEnv $ \env -> arg ("--test-env=" ++ show env) , emitWhenSet testMetricsFile $ \file -> arg ("--metrics-file=" ++ file) , getTestArgs -- User-provided arguments from command line. ===================================== testsuite/mk/test.mk ===================================== @@ -232,6 +232,10 @@ ifneq "$(VERBOSE)" "" RUNTEST_OPTS += --verbose=$(VERBOSE) endif +ifneq "$(PERF_TEST_BASELINE_COMMIT)" "" +RUNTEST_OPTS += --perf-baseline=$(PERF_TEST_BASELINE_COMMIT) +endif + ifeq "$(SKIP_PERF_TESTS)" "YES" RUNTEST_OPTS += --skip-perf-tests endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df50f2f7cfffeff6d3be7e45151dc82013c0db66 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df50f2f7cfffeff6d3be7e45151dc82013c0db66 You're receiving 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 Jul 28 09:14:56 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 28 Jul 2020 05:14:56 -0400 Subject: [Git][ghc/ghc][wip/T18502] 13 commits: Improve NegativeLiterals (#18022, GHC Proposal #344) Message-ID: <5f1fec9027ca4_80b3f84901714f854649be@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18502 at Glasgow Haskell Compiler / GHC Commits: aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 49d8597c by Simon Peyton Jones at 2020-07-28T10:14:32+01:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 30 changed files: - .gitlab-ci.yml - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - docs/users_guide/8.12.1-notes.rst - docs/users_guide/exts/negative_literals.rst - docs/users_guide/separate_compilation.rst - libraries/base/Data/Bits.hs - rts/PrimOps.cmm - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/numeric/should_run/T18499.hs - + testsuite/tests/numeric/should_run/T18499.stdout - testsuite/tests/numeric/should_run/all.T - − testsuite/tests/parser/should_compile/LexNegVsNegLit.hs - + testsuite/tests/parser/should_compile/NegativeLiterals.hs - + testsuite/tests/parser/should_compile/NegativeLiteralsNoExt.hs - testsuite/tests/parser/should_compile/all.T - + testsuite/tests/perf/compiler/T10421.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/65ef562cf75fe22b2437af994ec0c8610a85e34b...49d8597c9da32a5b674987cdc6ee227bcb627bb2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/65ef562cf75fe22b2437af994ec0c8610a85e34b...49d8597c9da32a5b674987cdc6ee227bcb627bb2 You're receiving 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 Jul 28 09:29:40 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 28 Jul 2020 05:29:40 -0400 Subject: [Git][ghc/ghc][wip/T18291] 2 commits: Allow unsaturated runRW# applications Message-ID: <5f1ff0047cf95_80b104e15b4546664@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18291 at Glasgow Haskell Compiler / GHC Commits: de986359 by Ben Gamari at 2020-07-28T05:29:34-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 1556ebd3 by Ben Gamari at 2020-07-28T05:29:34-04:00 testsuite: Add test for #18291 - - - - - 4 changed files: - compiler/GHC/Core/Lint.hs - compiler/GHC/CoreToStg/Prep.hs - + testsuite/tests/codeGen/should_compile/T18291.hs - testsuite/tests/codeGen/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -729,8 +729,6 @@ lintJoinLams join_arity enforce rhs where go 0 expr = lintCoreExpr expr go n (Lam var body) = lintLambda var $ go (n-1) body - -- N.B. join points can be cast. e.g. we consider ((\x -> ...) `cast` ...) - -- to be a join point at join arity 1. go n expr | Just bndr <- enforce -- Join point with too few RHS lambdas = failWithL $ mkBadJoinArityMsg bndr join_arity n rhs | otherwise -- Future join point, not yet eta-expanded @@ -779,36 +777,26 @@ hurts us here. Note [Linting of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~ -runRW# has some very peculiar behavior (see Note [runRW magic] in -GHC.CoreToStg.Prep) which CoreLint must accommodate. +runRW# has some very special behavior (see Note [runRW magic] in +GHC.CoreToStg.Prep) which CoreLint must accommodate, by allowing +join points in its argument. For example, this is fine: -As described in Note [Casts and lambdas] in -GHC.Core.Opt.Simplify.Utils, the simplifier pushes casts out of -lambdas. Concretely, the simplifier will transform + join j x = ... + in runRW# (\s. case v of + A -> j 3 + B -> j 4) - runRW# @r @ty (\s -> expr `cast` co) +Usually those calls to the join point 'j' would not be valid tail calls, +because they occur in a function argument. But in the case of runRW# +they are fine, because runRW# (\s.e) behaves operationally just like e. +(runRW# is ultimately inlined in GHC.CoreToStg.Prep.) -into - - runRW# @r @ty ((\s -> expr) `cast` co) - -Consequently we need to handle the case that the continuation is a -cast of a lambda. See Note [Casts and lambdas] in -GHC.Core.Opt.Simplify.Utils. - -In the event that the continuation is headed by a lambda (which -will bind the State# token) we can safely allow calls to join -points since CorePrep is going to apply the continuation to -RealWorld. - -In the case that the continuation is not a lambda we lint the -continuation disallowing join points, to rule out things like, +In the case that the continuation is /not/ a lambda we simply disable this +special behaviour. For example, this is /not/ fine: join j = ... - in runRW# @r @ty ( - let x = jump j - in x - ) + in runRW# @r @ty (jump j) + ************************************************************************ @@ -929,10 +917,6 @@ lintCoreExpr e@(App _ _) ; (fun_ty2, ue2) <- lintCoreArg fun_pair1 arg_ty2 -- See Note [Linting of runRW#] ; let lintRunRWCont :: CoreArg -> LintM (LintedType, UsageEnv) - lintRunRWCont (Cast expr co) = do - (ty, ue) <- lintRunRWCont expr - new_ty <- lintCastExpr expr ty co - return (new_ty, ue) lintRunRWCont expr@(Lam _ _) = do lintJoinLams 1 (Just fun) expr lintRunRWCont other = markAllJoinsBad $ lintCoreExpr other @@ -941,10 +925,6 @@ lintCoreExpr e@(App _ _) ; app_ty <- lintValApp arg3 fun_ty2 arg3_ty ue2 ue3 ; lintCoreArgs app_ty rest } - | Var fun <- fun - , fun `hasKey` runRWKey - = failWithL (text "Invalid runRW# application") - | otherwise = do { pair <- lintCoreFun fun (length args) ; lintCoreArgs pair args } ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -798,10 +798,6 @@ cpeApp top_env expr _ -> cpe_app env arg (CpeApp (Var realWorldPrimId) : rest) (n-1) -- TODO: What about casts? - cpe_app _env (Var f) args n - | f `hasKey` runRWKey - = pprPanic "cpe_app(runRW#)" (ppr args $$ ppr n) - cpe_app env (Var v) args depth = do { v1 <- fiddleCCall v ; let e2 = lookupCorePrepEnv env v1 @@ -923,18 +919,33 @@ optimization (right before lowering to STG, in CorePrep), we can ensure that no further floating will occur. This allows us to safely inline things like @runST@, which are otherwise needlessly expensive (see #10678 and #5916). -'runRW' is defined (for historical reasons) in GHC.Magic, with a NOINLINE -pragma. It is levity-polymorphic. +'runRW' has a variety of quirks: + + * 'runRW' is known-key with a NOINLINE definition (for historical reasons) in + GHC.Magic. However, its correctness needs no special treatment in GHC except + the special late inlining here in CorePrep and GHC.CoreToByteCode. + + * It is levity-polymorphic: runRW# :: forall (r1 :: RuntimeRep). (o :: TYPE r) => (State# RealWorld -> (# State# RealWorld, o #)) - -> (# State# RealWorld, o #) + -> (# State# RealWorld, o #) + + * It has some special simplification logic to allow unboxing of results when + runRW# appears in a strict context. See Note [Simplification of runRW#] + below. -It's correctness needs no special treatment in GHC except this special inlining -here in CorePrep (and in GHC.CoreToByteCode). + * Since its body is inlined, we allow runRW#'s argument to be a join point. + That is, the following is allowed: -However, there are a variety of optimisation opportunities that the simplifier -takes advantage of. See Note [Simplification of runRW#]. + join j = \s -> ... + in runRW# @_ @_ j + + The Core Linter knows about this. See Note [Linting of runRW#] in + GHC.Core.Lint for details. + + The occurrence analyser and SetLevels also know about this, as described in + Note [Simplification of runRW#]. Note [Simplification of runRW#] @@ -950,7 +961,7 @@ contexts into runRW's continuation. That is, it transforms K[ runRW# @r @ty cont ] ~> - runRW# @r @ty K[cont] + runRW# @r @ty (\s -> K[cont s]) This has a few interesting implications. Consider, for instance, this program: @@ -973,10 +984,17 @@ completely fine. Both occurrence analysis and Core Lint have special treatment for runRW# applications. See Note [Linting of runRW#] for details on the latter. Moreover, it's helpful to ensure that runRW's continuation isn't floated out -(since doing so would then require a call, whereas we would otherwise end up -with straight-line). Consequently, GHC.Core.Opt.SetLevels.lvlApp has special -treatment for runRW# applications, ensure the arguments are not floated if -MFEs. +For instance, if we have + + runRW# (\s -> do_something) + +where do_something contains only top-level free variables, we may be tempted to +float the argument to the top-level. However, we must resist this urge as since +doing so would then require that runRW# lower to a call, whereas we would +otherwise end up with straight-line code. Consequently, +GHC.Core.Opt.SetLevels.lvlApp has special treatment for runRW# applications, +ensure the arguments are not floated as MFEs. + Other considered designs ------------------------ ===================================== testsuite/tests/codeGen/should_compile/T18291.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE MagicHash #-} +module T18291 where + +import GHC.Magic + +hi :: Int +hi = runRW# $ \_ -> 42 ===================================== testsuite/tests/codeGen/should_compile/all.T ===================================== @@ -91,6 +91,7 @@ test('T17648', normal, makefile_test, []) test('T17904', normal, compile, ['-O']) test('T18227A', normal, compile, ['']) test('T18227B', normal, compile, ['']) +test('T18291', normal, compile, ['-O0']) test('T15570', when(unregisterised(), skip), compile, ['-Wno-overflowed-literals']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f5b3d7e6010c9c302ab9d8a7474ba89f89d3651...1556ebd389666417630ad833490ad042f58d75f3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f5b3d7e6010c9c302ab9d8a7474ba89f89d3651...1556ebd389666417630ad833490ad042f58d75f3 You're receiving 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 Jul 28 09:56:28 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 28 Jul 2020 05:56:28 -0400 Subject: [Git][ghc/ghc][wip/T18323] Add right-to-left rule for pattern bindings Message-ID: <5f1ff64c28cb4_80b104e15b454725f9@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18323 at Glasgow Haskell Compiler / GHC Commits: 888a920a by Simon Peyton Jones at 2020-07-28T10:55:25+01:00 Add right-to-left rule for pattern bindings Fix #18323 by adding a few lines of code to handle non-recursive pattern bindings. See Note [Special case for non-recursive pattern bindings] in GHC.Tc.Gen.Bind Alas, this confused the pattern-match overlap checker; see #18323. - - - - - 7 changed files: - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/Utils/Zonk.hs Changes: ===================================== compiler/GHC/Hs/Binds.hs ===================================== @@ -315,18 +315,13 @@ data HsBindLR idL idR | XHsBindsLR !(XXHsBindsLR idL idR) -data NPatBindTc = NPatBindTc { - pat_fvs :: NameSet, -- ^ Free variables - pat_rhs_ty :: Type -- ^ Type of the GRHSs - } deriving Data - type instance XFunBind (GhcPass pL) GhcPs = NoExtField type instance XFunBind (GhcPass pL) GhcRn = NameSet -- Free variables type instance XFunBind (GhcPass pL) GhcTc = HsWrapper -- See comments on FunBind.fun_ext type instance XPatBind GhcPs (GhcPass pR) = NoExtField type instance XPatBind GhcRn (GhcPass pR) = NameSet -- Free variables -type instance XPatBind GhcTc (GhcPass pR) = NPatBindTc +type instance XPatBind GhcTc (GhcPass pR) = Type -- Type of the GRHSs type instance XVarBind (GhcPass pL) (GhcPass pR) = NoExtField type instance XAbsBinds (GhcPass pL) (GhcPass pR) = NoExtField ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -181,7 +181,7 @@ dsHsBind dflags b@(FunBind { fun_id = L loc fun return (force_var, [core_binds]) } dsHsBind dflags (PatBind { pat_lhs = pat, pat_rhs = grhss - , pat_ext = NPatBindTc _ ty + , pat_ext = ty , pat_ticks = (rhs_tick, var_ticks) }) = do { rhss_deltas <- checkGuardMatches PatBindGuards grhss ; body_expr <- dsGuarded grhss ty (nonEmpty rhss_deltas) ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -213,7 +213,7 @@ dsUnliftedBind (FunBind { fun_id = L l fun ; return (bindNonRec fun rhs' body) } dsUnliftedBind (PatBind {pat_lhs = pat, pat_rhs = grhss - , pat_ext = NPatBindTc _ ty }) body + , pat_ext = ty }) body = -- let C x# y# = rhs in body -- ==> case rhs of C x# y# -> body do { rhs_deltas <- checkGuardMatches PatBindGuards grhss ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -1273,20 +1273,15 @@ tcMonoBinds :: RecFlag -- Whether the binding is recursive for typechecking pur -> TcSigFun -> LetBndrSpec -> [LHsBind GhcRn] -> TcM (LHsBinds GhcTc, [MonoBindInfo]) + +-- SPECIAL CASE 1: see Note [Inference for non-recursive function bindings] tcMonoBinds is_rec sig_fn no_gen [ L b_loc (FunBind { fun_id = L nm_loc name , fun_matches = matches })] -- Single function binding, | NonRecursive <- is_rec -- ...binder isn't mentioned in RHS , Nothing <- sig_fn name -- ...with no type signature - = -- Note [Single function non-recursive binding special-case] - -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- In this very special case we infer the type of the - -- right hand side first (it may have a higher-rank type) - -- and *then* make the monomorphic Id for the LHS - -- e.g. f = \(x::forall a. a->a) -> - -- We want to infer a higher-rank type for f - setSrcSpan b_loc $ + = setSrcSpan b_loc $ do { ((co_fn, matches'), rhs_ty) <- tcInfer $ \ exp_ty -> tcExtendBinderStack [TcIdBndr_ExpType name exp_ty NotTopLevel] $ @@ -1304,6 +1299,29 @@ tcMonoBinds is_rec sig_fn no_gen , mbi_sig = Nothing , mbi_mono_id = mono_id }]) } +-- SPECIAL CASE 2: see Note [Inference for non-recursive pattern bindings] +tcMonoBinds is_rec sig_fn no_gen + [L b_loc (PatBind { pat_lhs = pat, pat_rhs = grhss })] + | NonRecursive <- is_rec -- ...binder isn't mentioned in RHS + , all (isNothing . sig_fn) bndrs + = addErrCtxt (patMonoBindsCtxt pat grhss) $ + do { (grhss', pat_ty) <- tcInfer $ \ exp_ty -> + tcGRHSsPat grhss exp_ty + + ; let exp_pat_ty :: Scaled ExpSigmaType + exp_pat_ty = unrestricted (mkCheckExpType pat_ty) + ; (pat', mbis) <- tcLetPat (const Nothing) no_gen pat exp_pat_ty $ + mapM lookupMBI bndrs + + ; return ( unitBag $ L b_loc $ + PatBind { pat_lhs = pat', pat_rhs = grhss' + , pat_ext = pat_ty, pat_ticks = ([],[]) } + + , mbis ) } + where + bndrs = collectPatBinders pat + +-- GENERAL CASE tcMonoBinds _ sig_fn no_gen binds = do { tc_binds <- mapM (wrapLocM (tcLhs sig_fn no_gen)) binds @@ -1326,6 +1344,66 @@ tcMonoBinds _ sig_fn no_gen binds ; return (listToBag binds', mono_infos) } +{- Note [Special case for non-recursive function bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In the special case of +* A non-recursive FunBind +* With no type signature +we infer the type of the right hand side first (it may have a +higher-rank type) and *then* make the monomorphic Id for the LHS e.g. + f = \(x::forall a. a->a) -> + +We want to infer a higher-rank type for f + +Note [Special case for non-recursive pattern bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In the special case of +* A pattern binding +* With no type signature for any of the binders +we can /infer/ the type of the RHS, and /check/ the pattern +against that type. For example (#18323) + + ids :: [forall a. a -> a] + combine :: (forall a . [a] -> a) -> [forall a. a -> a] + -> ((forall a . [a] -> a), [forall a. a -> a]) + + (x,y) = combine head ids + +with -XImpredicativeTypes we can infer a good type for +(combine head ids), and use that to tell us the polymorphic +types of x and y. + +We don't need to check -XImpredicativeTypes beucase without it +these types like [forall a. a->a] are illegal anyway, so this +special case code only really has an effect if -XImpredicativeTypes +is on. Small exception: + (x) = e +is currently treated as a pattern binding so, even absent +-XImpredicativeTypes, we will get a small improvement in behaviour. +But I don't think it's worth an extension flag. + +Why do we require no type signatures on /any/ of the binders? +Consider + x :: forall a. a->a + y :: forall a. a->a + (x,y) = (id,id) + +Here we should /check/ the RHS with expected type + (forall a. a->a, forall a. a->a). + +If we have no signatures, we can the approach of this Note +to /infer/ the type of the RHS. + +But what if we have some signatures, but not all? Say this: + p :: forall a. a->a + (p,q) = (id, (\(x::forall b. b->b). x True)) + +Here we want to push p's signature inwards, i.e. /checking/, to +correctly elaborate 'id'. But we want to /infer/ q's higher rank +type. There seems to be no way to do this. So currently we only +switch to inference when we have no signature for any of the binders. +-} + ------------------------ -- tcLhs typechecks the LHS of the bindings, to construct the environment in which @@ -1393,7 +1471,7 @@ tcLhs sig_fn no_gen (PatBind { pat_lhs = pat, pat_rhs = grhss }) -- The above inferred type get an unrestricted multiplicity. It may be -- worth it to try and find a finer-grained multiplicity here -- if examples warrant it. - mapM lookup_info nosig_names + mapM lookupMBI nosig_names ; let mbis = sig_mbis ++ nosig_mbis @@ -1411,19 +1489,19 @@ tcLhs sig_fn no_gen (PatBind { pat_lhs = pat, pat_rhs = grhss }) Just (TcIdSig sig) -> Right (name, sig) _ -> Left name - -- After typechecking the pattern, look up the binder - -- names that lack a signature, which the pattern has brought - -- into scope. - lookup_info :: Name -> TcM MonoBindInfo - lookup_info name - = do { mono_id <- tcLookupId name - ; return (MBI { mbi_poly_name = name - , mbi_sig = Nothing - , mbi_mono_id = mono_id }) } - tcLhs _ _ other_bind = pprPanic "tcLhs" (ppr other_bind) -- AbsBind, VarBind impossible +lookupMBI :: Name -> TcM MonoBindInfo +-- After typechecking the pattern, look up the binder +-- names that lack a signature, which the pattern has brought +-- into scope. +lookupMBI name + = do { mono_id <- tcLookupId name + ; return (MBI { mbi_poly_name = name + , mbi_sig = Nothing + , mbi_mono_id = mono_id }) } + ------------------- tcLhsSigId :: LetBndrSpec -> (Name, TcIdSigInfo) -> TcM MonoBindInfo tcLhsSigId no_gen (name, sig) @@ -1466,15 +1544,9 @@ tcRhs (TcPatBind infos pat' grhss pat_ty) tcExtendIdBinderStackForRhs infos $ do { traceTc "tcRhs: pat bind" (ppr pat' $$ ppr pat_ty) ; grhss' <- addErrCtxt (patMonoBindsCtxt pat' grhss) $ - tcScalingUsage Many $ - -- Like in tcMatchesFun, this scaling happens because all - -- let bindings are unrestricted. A difference, here, is - -- that when this is not the case, any more, we will have to - -- make sure that the pattern is strict, otherwise this will - -- be desugar to incorrect code. - tcGRHSsPat grhss pat_ty + tcGRHSsPat grhss (mkCheckExpType pat_ty) ; return ( PatBind { pat_lhs = pat', pat_rhs = grhss' - , pat_ext = NPatBindTc emptyNameSet pat_ty + , pat_ext = pat_ty , pat_ticks = ([],[]) } )} tcExtendTyVarEnvForRhs :: Maybe TcIdSigInst -> TcM a -> TcM a ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -156,10 +156,17 @@ tcMatchLambda herald match_ctxt match res_ty -- @tcGRHSsPat@ typechecks @[GRHSs]@ that occur in a @PatMonoBind at . -tcGRHSsPat :: GRHSs GhcRn (LHsExpr GhcRn) -> TcRhoType +tcGRHSsPat :: GRHSs GhcRn (LHsExpr GhcRn) -> ExpRhoType -> TcM (GRHSs GhcTc (LHsExpr GhcTc)) -- Used for pattern bindings -tcGRHSsPat grhss res_ty = tcGRHSs match_ctxt grhss (mkCheckExpType res_ty) +tcGRHSsPat grhss res_ty + = tcScalingUsage Many $ + -- Like in tcMatchesFun, this scaling happens because all + -- let bindings are unrestricted. A difference, here, is + -- that when this is not the case, any more, we will have to + -- make sure that the pattern is strict, otherwise this will + -- desugar to incorrect code. + tcGRHSs match_ctxt grhss res_ty where match_ctxt = MC { mc_what = PatBindRhs, mc_body = tcBody } ===================================== compiler/GHC/Tc/Gen/Match.hs-boot ===================================== @@ -2,13 +2,13 @@ module GHC.Tc.Gen.Match where import GHC.Hs ( GRHSs, MatchGroup, LHsExpr ) import GHC.Tc.Types.Evidence ( HsWrapper ) import GHC.Types.Name ( Name ) -import GHC.Tc.Utils.TcType( ExpSigmaType, TcRhoType ) +import GHC.Tc.Utils.TcType( ExpSigmaType, ExpRhoType ) import GHC.Tc.Types ( TcM ) import GHC.Types.SrcLoc ( Located ) import GHC.Hs.Extension ( GhcRn, GhcTc ) tcGRHSsPat :: GRHSs GhcRn (LHsExpr GhcRn) - -> TcRhoType + -> ExpRhoType -> TcM (GRHSs GhcTc (LHsExpr GhcTc)) tcMatchesFun :: Located Name ===================================== compiler/GHC/Tc/Utils/Zonk.hs ===================================== @@ -532,12 +532,12 @@ zonk_lbind env = wrapLocM (zonk_bind env) zonk_bind :: ZonkEnv -> HsBind GhcTc -> TcM (HsBind GhcTc) zonk_bind env bind@(PatBind { pat_lhs = pat, pat_rhs = grhss - , pat_ext = NPatBindTc fvs ty}) + , pat_ext = ty}) = do { (_env, new_pat) <- zonkPat env pat -- Env already extended ; new_grhss <- zonkGRHSs env zonkLExpr grhss ; new_ty <- zonkTcTypeToTypeX env ty ; return (bind { pat_lhs = new_pat, pat_rhs = new_grhss - , pat_ext = NPatBindTc fvs new_ty }) } + , pat_ext = new_ty }) } zonk_bind env (VarBind { var_ext = x , var_id = var, var_rhs = expr }) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/888a920ac84dc57c327abe468b336bea3065c801 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/888a920ac84dc57c327abe468b336bea3065c801 You're receiving 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 Jul 28 11:49:56 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Tue, 28 Jul 2020 07:49:56 -0400 Subject: [Git][ghc/ghc][wip/T18470] Move renamer-based validity check to typechecker Message-ID: <5f2010e4aef7d_80b3f849c1caa10549635e@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18470 at Glasgow Haskell Compiler / GHC Commits: 83187784 by Ryan Scott at 2020-07-28T07:49:33-04:00 Move renamer-based validity check to typechecker - - - - - 11 changed files: - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Basic.hs - testsuite/tests/indexed-types/should_fail/Overlap5.stderr - testsuite/tests/rename/should_fail/T16002.stderr - testsuite/tests/th/T15362.hs - testsuite/tests/th/T15362.stderr - testsuite/tests/typecheck/should_fail/T11623.stderr Changes: ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -55,7 +55,7 @@ import GHC.Types.Name.Env import GHC.Types.Avail import GHC.Utils.Outputable import GHC.Data.Bag -import GHC.Types.Basic ( pprRuleName, TypeOrKind(..) ) +import GHC.Types.Basic ( pprRuleName, TypeOrKind(..), ClosedTyFamInfo(..) ) import GHC.Data.FastString import GHC.Types.SrcLoc as SrcLoc import GHC.Driver.Session @@ -763,7 +763,7 @@ rnFamInstEqn doc atfi rhs_kvars ; let eqn_fvs = rhs_fvs `plusFV` pat_fvs -- See Note [Type family equations and occurrences] all_fvs = case atfi of - NonAssocTyFamEqn (ClosedTyFam{}) + NonAssocTyFamEqn ClosedTyFam -> eqn_fvs _ -> eqn_fvs `addOneFV` unLoc tycon' @@ -851,34 +851,15 @@ data AssocTyFamInfo Name -- Name of the parent class [Name] -- Names of the tyvars of the parent instance decl --- | Tracks whether we are renaming an equation in a closed type family --- equation ('ClosedTyFam') or not ('NotClosedTyFam'). -data ClosedTyFamInfo - = NotClosedTyFam - | ClosedTyFam (Located RdrName) Name - -- The names (RdrName and Name) of the closed type family - rnTyFamInstEqn :: AssocTyFamInfo -> TyFamInstEqn GhcPs -> RnM (TyFamInstEqn GhcRn, FreeVars) rnTyFamInstEqn atfi eqn@(HsIB { hsib_body = FamEqn { feqn_tycon = tycon , feqn_rhs = rhs }}) - = do { let rhs_kvs = extractHsTyRdrTyVarsKindVars rhs - ; (eqn'@(HsIB { hsib_body = - FamEqn { feqn_tycon = L _ tycon' }}), fvs) - <- rnFamInstEqn (TySynCtx tycon) atfi rhs_kvs eqn rnTySyn - - -- For closed type families, check that each equation is for the - -- right type family. E.g. barf on - -- type family F a where { G Int = Bool } - ; case atfi of - NonAssocTyFamEqn (ClosedTyFam fam_rdr_name fam_name) -> - checkTc (fam_name == tycon') $ - withHsDocContext (TyFamilyCtx fam_rdr_name) $ - wrongTyFamName fam_name tycon' - _ -> pure () - ; pure (eqn', fvs) } + = rnFamInstEqn (TySynCtx tycon) atfi rhs_kvs eqn rnTySyn + where + rhs_kvs = extractHsTyRdrTyVarsKindVars rhs rnTyFamDefltDecl :: Name -> TyFamDefltDecl GhcPs @@ -2023,7 +2004,7 @@ rnFamDecl mb_cls (FamilyDecl { fdLName = tycon, fdTyVars = tyvars ; injectivity' <- traverse (rnInjectivityAnn tyvars' res_sig') injectivity ; return ( (tyvars', res_sig', injectivity') , fv_kind ) } - ; (info', fv2) <- rn_info tycon' info + ; (info', fv2) <- rn_info info ; return (FamilyDecl { fdExt = noExtField , fdLName = tycon', fdTyVars = tyvars' , fdFixity = fixity @@ -2035,18 +2016,16 @@ rnFamDecl mb_cls (FamilyDecl { fdLName = tycon, fdTyVars = tyvars kvs = extractRdrKindSigVars res_sig ---------------------- - rn_info :: Located Name - -> FamilyInfo GhcPs -> RnM (FamilyInfo GhcRn, FreeVars) - rn_info (L _ fam_name) (ClosedTypeFamily (Just eqns)) + rn_info :: FamilyInfo GhcPs -> RnM (FamilyInfo GhcRn, FreeVars) + rn_info (ClosedTypeFamily (Just eqns)) = do { (eqns', fvs) - <- rnList (rnTyFamInstEqn (NonAssocTyFamEqn (ClosedTyFam tycon fam_name))) + <- rnList (rnTyFamInstEqn (NonAssocTyFamEqn ClosedTyFam)) eqns -- no class context - eqns ; return (ClosedTypeFamily (Just eqns'), fvs) } - rn_info _ (ClosedTypeFamily Nothing) + rn_info (ClosedTypeFamily Nothing) = return (ClosedTypeFamily Nothing, emptyFVs) - rn_info _ OpenTypeFamily = return (OpenTypeFamily, emptyFVs) - rn_info _ DataFamily = return (DataFamily, emptyFVs) + rn_info OpenTypeFamily = return (OpenTypeFamily, emptyFVs) + rn_info DataFamily = return (DataFamily, emptyFVs) rnFamResultSig :: HsDocContext -> FamilyResultSig GhcPs @@ -2190,13 +2169,6 @@ are no data constructors we allow h98_style = True * * ***************************************************** -} ---------------- -wrongTyFamName :: Name -> Name -> SDoc -wrongTyFamName fam_tc_name eqn_tc_name - = hang (text "Mismatched type name in type family instance.") - 2 (vcat [ text "Expected:" <+> ppr fam_tc_name - , text " Actual:" <+> ppr eqn_tc_name ]) - ----------------- rnConDecls :: [LConDecl GhcPs] -> RnM ([LConDecl GhcRn], FreeVars) rnConDecls = mapFvRn (wrapLocFstM rnConDecl) ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -31,6 +31,7 @@ import GHC.Builtin.Types import GHC.Builtin.Types.Prim( eqPrimTyCon, eqReprPrimTyCon ) import GHC.Builtin.Names +import GHC.Types.Basic ( ClosedTyFamInfo(..) ) import GHC.Types.Id import GHC.Core.Type import GHC.Core.Make ( mkStringExprFS, mkNaturalExpr ) @@ -58,6 +59,7 @@ import Data.Maybe -- The @VarEnv Type@ maps class variables to their instance types. data AssocInstInfo = NotAssociated + ClosedTyFamInfo -- Is this a closed type family? | InClsInst { ai_class :: Class , ai_tyvars :: [TyVar] -- ^ The /scoped/ tyvars of the instance -- Why scoped? See bind_me in @@ -67,8 +69,8 @@ data AssocInstInfo } isNotAssociated :: AssocInstInfo -> Bool -isNotAssociated NotAssociated = True -isNotAssociated (InClsInst {}) = False +isNotAssociated (NotAssociated {}) = True +isNotAssociated (InClsInst {}) = False {- ******************************************************************* ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -2432,7 +2432,7 @@ tcDefaultAssocDecl fam_tc -- at an associated type. But this would be wrong, because an associated -- type default LHS can mention *different* type variables than the -- enclosing class. So it's treated more as a freestanding beast. - ; (qtvs, pats, rhs_ty) <- tcTyFamInstEqnGuts fam_tc NotAssociated + ; (qtvs, pats, rhs_ty) <- tcTyFamInstEqnGuts fam_tc (NotAssociated NotClosedTyFam) imp_vars (mb_expl_bndrs `orElse` []) hs_pats hs_rhs_ty @@ -2639,7 +2639,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info False {- this doesn't matter here -} ClosedTypeFamilyFlavour - ; branches <- mapAndReportM (tcTyFamInstEqn tc_fam_tc NotAssociated) eqns + ; branches <- mapAndReportM (tcTyFamInstEqn tc_fam_tc (NotAssociated ClosedTyFam)) eqns -- Do not attempt to drop equations dominated by earlier -- ones here; in the case of mutual recursion with a data -- type, we get a knot-tying failure. Instead we check @@ -2862,16 +2862,25 @@ tcTyFamInstEqn fam_tc mb_clsinfo , feqn_bndrs = mb_expl_bndrs , feqn_pats = hs_pats , feqn_rhs = hs_rhs_ty }})) - = ASSERT( getName fam_tc == eqn_tc_name ) - setSrcSpan loc $ + = setSrcSpan loc $ do { traceTc "tcTyFamInstEqn" $ vcat [ ppr fam_tc <+> ppr hs_pats , text "fam tc bndrs" <+> pprTyVars (tyConTyVars fam_tc) , case mb_clsinfo of - NotAssociated -> empty + NotAssociated {} -> empty InClsInst { ai_class = cls } -> text "class" <+> ppr cls <+> pprTyVars (classTyVars cls) ] - -- First, check the arity of visible arguments + -- First, check if we're dealing with a closed type family equation, and + -- if so, ensure that each equation's type constructor is for the right + -- type family. E.g. barf on + -- type family F a where { G Int = Bool } + ; case mb_clsinfo of + NotAssociated ClosedTyFam + -> checkTc (fam_tc_name == eqn_tc_name) $ + wrongTyFamName fam_tc_name eqn_tc_name + _ -> pure () + + -- Next, check the arity of visible arguments -- If we wait until validity checking, we'll get kind errors -- below when an arity error will be much easier to understand. ; let vis_arity = length (tyConVisibleTyVars fam_tc) @@ -2886,6 +2895,8 @@ tcTyFamInstEqn fam_tc mb_clsinfo ; return (mkCoAxBranch qtvs [] [] pats rhs_ty (map (const Nominal) qtvs) loc) } + where + fam_tc_name = getName fam_tc {- Kind check type patterns and kind annotate the embedded type variables. @@ -4919,6 +4930,12 @@ incoherentRoles = (text "Roles other than" <+> quotes (text "nominal") <+> text "for class parameters can lead to incoherence.") $$ (text "Use IncoherentInstances to allow this; bad role found") +wrongTyFamName :: Name -> Name -> SDoc +wrongTyFamName fam_tc_name eqn_tc_name + = hang (text "Mismatched type name in type family instance.") + 2 (vcat [ text "Expected:" <+> ppr fam_tc_name + , text " Actual:" <+> ppr eqn_tc_name ]) + addTyConCtxt :: TyCon -> TcM a -> TcM a addTyConCtxt tc = addTyConFlavCtxt name flav where ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -458,11 +458,11 @@ tcLocalInstDecl :: LInstDecl GhcRn -- -- We check for respectable instance type, and context tcLocalInstDecl (L loc (TyFamInstD { tfid_inst = decl })) - = do { fam_inst <- tcTyFamInstDecl NotAssociated (L loc decl) + = do { fam_inst <- tcTyFamInstDecl (NotAssociated NotClosedTyFam) (L loc decl) ; return ([], [fam_inst], []) } tcLocalInstDecl (L loc (DataFamInstD { dfid_inst = decl })) - = do { (fam_inst, m_deriv_info) <- tcDataFamInstDecl NotAssociated emptyVarEnv (L loc decl) + = do { (fam_inst, m_deriv_info) <- tcDataFamInstDecl (NotAssociated NotClosedTyFam) emptyVarEnv (L loc decl) ; return ([], [fam_inst], maybeToList m_deriv_info) } tcLocalInstDecl (L loc (ClsInstD { cid_inst = decl })) ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -2271,7 +2271,7 @@ checkConsistentFamInst :: AssocInstInfo -> TcM () -- See Note [Checking consistent instantiation] -checkConsistentFamInst NotAssociated _ _ +checkConsistentFamInst (NotAssociated {}) _ _ = return () checkConsistentFamInst (InClsInst { ai_class = clas ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -108,7 +108,9 @@ module GHC.Types.Basic ( SpliceExplicitFlag(..), - TypeOrKind(..), isTypeLevel, isKindLevel + TypeOrKind(..), isTypeLevel, isKindLevel, + + ClosedTyFamInfo(..) ) where import GHC.Prelude @@ -1843,3 +1845,16 @@ isTypeLevel KindLevel = False isKindLevel :: TypeOrKind -> Bool isKindLevel TypeLevel = False isKindLevel KindLevel = True + +{- +************************************************************************ +* * + ClosedTyFamInfo +* * +************************************************************************ +-} + +-- | Is a type family closed ('ClosedTyFam') or not ('NotClosedTyFam')? +data ClosedTyFamInfo + = NotClosedTyFam + | ClosedTyFam ===================================== testsuite/tests/indexed-types/should_fail/Overlap5.stderr ===================================== @@ -1,6 +1,6 @@ Overlap5.hs:8:3: error: - Mismatched type name in type family instance. - Expected: F - Actual: G - In the declaration for type family ‘F’ + • Mismatched type name in type family instance. + Expected: F + Actual: G + • In the type family declaration for ‘F’ ===================================== testsuite/tests/rename/should_fail/T16002.stderr ===================================== @@ -1,6 +1,6 @@ T16002.hs:6:3: error: - Mismatched type name in type family instance. - Expected: B - Actual: A - In the declaration for type family ‘B’ + • Mismatched type name in type family instance. + Expected: B + Actual: A + • In the type family declaration for ‘B’ ===================================== testsuite/tests/th/T15362.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds #-} +{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds, TypeFamilies #-} module T15362 where ===================================== testsuite/tests/th/T15362.stderr ===================================== @@ -1,10 +1,6 @@ -T15362.hs:8:10: error: +T15362.hs:7:2: error: • Mismatched type name in type family instance. Expected: + Actual: Maybe - In the declaration for type family ‘+’ - • In the Template Haskell quotation - [d| type family a + b where - Maybe Zero b = b - Succ a + b = Succ (a + b) |] + • In the type family declaration for ‘+’ ===================================== testsuite/tests/typecheck/should_fail/T11623.stderr ===================================== @@ -1,6 +1,4 @@ T11623.hs:5:23: error: - Mismatched type name in type family instance. - Expected: T - Actual: Maybe - In the declaration for type family ‘T’ + • Number of parameters must match family declaration; expected 0 + • In the type family declaration for ‘T’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/83187784fac82b6e8db016cc68e4d8ae07c83856 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/83187784fac82b6e8db016cc68e4d8ae07c83856 You're receiving 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 Jul 28 12:51:49 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 28 Jul 2020 08:51:49 -0400 Subject: [Git][ghc/ghc][wip/spj-wibbles] 10 commits: Drop 32-bit Windows support Message-ID: <5f201f65951de_80b3f848c1e06f45517977@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/spj-wibbles at Glasgow Haskell Compiler / GHC Commits: aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - aecd7ed0 by Simon Peyton Jones at 2020-07-28T13:51:31+01:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 30 changed files: - .gitlab-ci.yml - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Types/Name/Reader.hs - docs/users_guide/8.12.1-notes.rst - libraries/base/Data/Bits.hs - rts/PrimOps.cmm - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/numeric/should_run/T18499.hs - + testsuite/tests/numeric/should_run/T18499.stdout - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T10421a.hs - + testsuite/tests/perf/compiler/T10421a_Form.hs - + testsuite/tests/perf/compiler/T13253-spj.hs - + testsuite/tests/perf/compiler/T13253.hs - + testsuite/tests/perf/compiler/T18140.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b7a902db47e91377b501400c66ab779003ad1182...aecd7ed0a6c5e5640fb68b7bde505c2114db37ac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b7a902db47e91377b501400c66ab779003ad1182...aecd7ed0a6c5e5640fb68b7bde505c2114db37ac You're receiving 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 Jul 28 12:53:54 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 28 Jul 2020 08:53:54 -0400 Subject: [Git][ghc/ghc][wip/T18494] 10 commits: Drop 32-bit Windows support Message-ID: <5f201fe2a2a84_80b3f848a2ebd5c55213c8@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18494 at Glasgow Haskell Compiler / GHC Commits: aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 2921a6e9 by Simon Peyton Jones at 2020-07-28T13:53:15+01:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - 30 changed files: - .gitlab-ci.yml - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - docs/users_guide/8.12.1-notes.rst - libraries/base/Data/Bits.hs - rts/PrimOps.cmm - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/numeric/should_run/T18499.hs - + testsuite/tests/numeric/should_run/T18499.stdout - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T10421a.hs - + testsuite/tests/perf/compiler/T10421a_Form.hs - + testsuite/tests/perf/compiler/T13253-spj.hs - + testsuite/tests/perf/compiler/T13253.hs - + testsuite/tests/perf/compiler/T18140.hs - testsuite/tests/perf/compiler/all.T - + testsuite/tests/primops/should_run/T12492.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c60e07345176f14661fcf67dd15980879848442...2921a6e9a9423505f1cc8785262206c5a9d9ae24 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c60e07345176f14661fcf67dd15980879848442...2921a6e9a9423505f1cc8785262206c5a9d9ae24 You're receiving 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 Jul 28 13:54:05 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 28 Jul 2020 09:54:05 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Fix typo in haddock Message-ID: <5f202dfd65015_80b3f849a2654545531929@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e848c5f7 by Oleg Grenrus at 2020-07-28T09:54:01-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 0c133451 by Sergei Trofimovich at 2020-07-28T09:54:03-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 2 changed files: - ghc.mk - libraries/base/GHC/IO.hs Changes: ===================================== ghc.mk ===================================== @@ -656,7 +656,9 @@ BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE1)) BUILD_DIRS += $(patsubst %, libraries/%, $(filter-out $(PACKAGES_STAGE1),$(PACKAGES_STAGE0))) endif +ifeq "$(BIGNUM_BACKEND)" "gmp" BUILD_DIRS += libraries/ghc-bignum/gmp +endif BUILD_DIRS += utils/haddock BUILD_DIRS += utils/haddock/doc BUILD_DIRS += compiler ===================================== libraries/base/GHC/IO.hs ===================================== @@ -173,7 +173,7 @@ catchException !io handler = catch io handler -- @IO Int -> (ArithException -> IO Int) -> IO Int@ then the handler may -- get run with @DivideByZero@ as an argument, or an @ErrorCall \"urk\"@ -- exception may be propagated further up. If you call it again, you --- might get a the opposite behaviour. This is ok, because 'catch' is an +-- might get the opposite behaviour. This is ok, because 'catch' is an -- 'IO' computation. -- catch :: Exception e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/37ba5283db32b5cae501728e2021d3f7a042a730...0c1334512fe7d51399c3d2668ca5d9d528206398 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/37ba5283db32b5cae501728e2021d3f7a042a730...0c1334512fe7d51399c3d2668ca5d9d528206398 You're receiving 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 Jul 28 17:00:29 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 28 Jul 2020 13:00:29 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/backports Message-ID: <5f2059ad53731_80b3f848a37384c55755da@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/backports at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/backports You're receiving 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 Jul 28 17:08:46 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 28 Jul 2020 13:08:46 -0400 Subject: [Git][ghc/ghc][ghc-9.0] Bump haddock submodule Message-ID: <5f205b9e3c05e_80b3f848c1e06f45577228@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-9.0 at Glasgow Haskell Compiler / GHC Commits: 5f809894 by Ben Gamari at 2020-07-28T13:08:36-04:00 Bump haddock submodule - - - - - 1 changed file: - utils/haddock Changes: ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 22b42eab6ec6b3b321b6d54041b7b3a6e54af3c9 +Subproject commit 5eabbdedf283f4ee8e340326b3d20b62b0e5caad View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f8098943b7977337718890129d22e358a001884 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f8098943b7977337718890129d22e358a001884 You're receiving 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 Jul 28 17:17:23 2020 From: gitlab at gitlab.haskell.org (Brandon Chinn) Date: Tue, 28 Jul 2020 13:17:23 -0400 Subject: [Git][ghc/ghc][wip/T16341] 4 commits: Add regression test for #16341 Message-ID: <5f205da3ab411_80b3f84901714f8557744@gitlab.haskell.org.mail> Brandon Chinn pushed to branch wip/T16341 at Glasgow Haskell Compiler / GHC Commits: cb08e8f3 by Brandon Chinn at 2020-07-28T09:59:42-07:00 Add regression test for #16341 - - - - - e095d091 by Brandon Chinn at 2020-07-28T09:59:43-07:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - 9bcafe7d by Brandon Chinn at 2020-07-28T10:14:49-07:00 Pass tc_args to gen_fn - - - - - 0f934115 by Brandon Chinn at 2020-07-28T10:17:14-07:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - 7 changed files: - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Deriv/Utils.hs - + testsuite/tests/deriving/should_compile/T16341.hs - testsuite/tests/deriving/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/Deriv.hs ===================================== @@ -2038,9 +2038,12 @@ genDerivStuff mechanism loc clas inst_tys tyvars -> gen_newtype_or_via rhs_ty -- Try a stock deriver - DerivSpecStock { dsm_stock_dit = DerivInstTys{dit_rep_tc = rep_tc} + DerivSpecStock { dsm_stock_dit = DerivInstTys + { dit_rep_tc = rep_tc + , dit_rep_tc_args = rep_tc_args + } , dsm_stock_gen_fn = gen_fn } - -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc inst_tys + -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc rep_tc_args inst_tys pure (binds, [], faminsts, field_names) -- Try DeriveAnyClass ===================================== compiler/GHC/Tc/Deriv/Functor.hs ===================================== @@ -151,10 +151,10 @@ is a similar algorithm for generating `p <$ x` (for some constant `p`): $(coreplace 'a '(tb -> tc) x) = \(y:tb[b/a]) -> $(coreplace 'a' 'tc' (x $(replace 'a 'tb y))) -} -gen_Functor_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Functor_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use fmap _ = coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag fmap_bind, emptyBag) where @@ -165,10 +165,10 @@ gen_Functor_binds loc tycon coerce_Expr] fmap_match_ctxt = mkPrefixFunRhs fmap_name -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon tycon_args = (listToBag [fmap_bind, replace_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args fmap_name = L loc fmap_RDR -- See Note [EmptyDataDecls with Functor, Foldable, and Traversable] @@ -787,10 +787,10 @@ could surprise users if they switch to other types, but Ryan Scott seems to think it's okay to do it for now. -} -gen_Foldable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Foldable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the parameter is phantom, we can use foldMap _ _ = mempty -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag foldMap_bind, emptyBag) where @@ -801,7 +801,7 @@ gen_Foldable_binds loc tycon mempty_Expr] foldMap_match_ctxt = mkPrefixFunRhs foldMap_name -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon tycon_args | null data_cons -- There's no real point producing anything but -- foldMap for a type with no constructors. = (unitBag foldMap_bind, emptyBag) @@ -809,7 +809,7 @@ gen_Foldable_binds loc tycon | otherwise = (listToBag [foldr_bind, foldMap_bind, null_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args foldr_bind = mkRdrFunBind (L loc foldable_foldr_RDR) eqns eqns = map foldr_eqn data_cons @@ -1016,10 +1016,10 @@ removes all such types from consideration. See Note [Generated code for DeriveFoldable and DeriveTraversable]. -} -gen_Traversable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Traversable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use traverse = pure . coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag traverse_bind, emptyBag) where @@ -1031,10 +1031,10 @@ gen_Traversable_binds loc tycon (nlHsApps pure_RDR [nlHsApp coerce_Expr z_Expr])] traverse_match_ctxt = mkPrefixFunRhs traverse_name -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon tycon_args = (unitBag traverse_bind, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args traverse_name = L loc traverse_RDR ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -33,7 +33,9 @@ module GHC.Tc.Deriv.Generate ( mkCoerceClassMethEqn, genAuxBinds, ordOpTbl, boxConTbl, litConTbl, - mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr + mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr, + + getPossibleDataCons, tyConInstArgTys ) where #include "HsVersions.h" @@ -212,14 +214,14 @@ for the instance decl, which it probably wasn't, so the decls produced don't get through the typechecker. -} -gen_Eq_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Eq_binds loc tycon = do +gen_Eq_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Eq_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon return (method_binds con2tag_RDR, aux_binds con2tag_RDR) where - all_cons = tyConDataCons tycon + all_cons = getPossibleDataCons tycon tycon_args (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon all_cons -- If there are ten or more (arbitrary number) nullary constructors, @@ -396,8 +398,8 @@ gtResult OrdGE = true_Expr gtResult OrdGT = true_Expr ------------ -gen_Ord_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ord_binds loc tycon = do +gen_Ord_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ord_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon @@ -432,7 +434,7 @@ gen_Ord_binds loc tycon = do -- We want *zero-based* tags, because that's what -- con2Tag returns (generated by untag_Expr)! - tycon_data_cons = tyConDataCons tycon + tycon_data_cons = getPossibleDataCons tycon tycon_args single_con_type = isSingleton tycon_data_cons (first_con : _) = tycon_data_cons (last_con : _) = reverse tycon_data_cons @@ -646,8 +648,8 @@ instance ... Enum (Foo ...) where For @enumFromTo@ and @enumFromThenTo@, we use the default methods. -} -gen_Enum_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Enum_binds loc tycon = do +gen_Enum_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Enum_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -738,8 +740,8 @@ gen_Enum_binds loc tycon = do ************************************************************************ -} -gen_Bounded_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Bounded_binds loc tycon +gen_Bounded_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Bounded_binds loc tycon _ | isEnumerationTyCon tycon = (listToBag [ min_bound_enum, max_bound_enum ], emptyBag) | otherwise @@ -825,9 +827,9 @@ we follow the scheme given in Figure~19 of the Haskell~1.2 report (p.~147). -} -gen_Ix_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ix_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ix_binds loc tycon = do +gen_Ix_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -1028,10 +1030,10 @@ These instances are also useful for Read (Either Int Emp), where we want to be able to parse (Left 3) just fine. -} -gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Read_binds get_fixity loc tycon +gen_Read_binds get_fixity loc tycon _ = (listToBag [read_prec, default_readlist, default_readlistprec], emptyBag) where ----------------------------------------------------------------------- @@ -1212,13 +1214,13 @@ Example -- the most tightly-binding operator -} -gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Show_binds get_fixity loc tycon +gen_Show_binds get_fixity loc tycon tycon_args = (unitBag shows_prec, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args shows_prec = mkFunBindEC 2 loc showsPrec_RDR id (map pats_etc data_cons) comma_space = nlHsVar showCommaSpace_RDR @@ -1385,9 +1387,10 @@ we generate gen_Data_binds :: SrcSpan -> TyCon -- For data families, this is the -- *representation* TyCon + -> [Type] -> TcM (LHsBinds GhcPs, -- The method bindings BagDerivStuff) -- Auxiliary bindings -gen_Data_binds loc rep_tc +gen_Data_binds loc rep_tc _ = do { -- See Note [Auxiliary binders] dataT_RDR <- new_dataT_rdr_name loc rep_tc ; dataC_RDRs <- traverse (new_dataC_rdr_name loc) data_cons @@ -1616,8 +1619,8 @@ Example: -} -gen_Lift_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) +gen_Lift_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Lift_binds loc tycon tycon_args = (listToBag [lift_bind, liftTyped_bind], emptyBag) where lift_bind = mkFunBindEC 1 loc lift_RDR (nlHsApp pure_Expr) (map (pats_etc mk_exp) data_cons) @@ -1626,7 +1629,7 @@ gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) mk_exp = ExpBr noExtField mk_texp = TExpBr noExtField - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args pats_etc mk_bracket data_con = ([con_pat], lift_Expr) @@ -2515,6 +2518,39 @@ newAuxBinderRdrName loc parent occ_fun = do uniq <- newUnique pure $ Exact $ mkSystemNameAt uniq (occ_fun (nameOccName parent)) loc +-- | @getPossibleDataCons tycon tycon_args@ returns the constructors of @tycon@ +-- whose return types match when checked against @tycon_args at . +-- +-- See Note [Filter out impossible GADT data constructors] +getPossibleDataCons :: TyCon -> [Type] -> [DataCon] +getPossibleDataCons tycon tycon_args = filter isPossible $ tyConDataCons tycon + where + isPossible = not . dataConCannotMatch (tyConInstArgTys tycon tycon_args) + +-- | Given a type constructor @tycon@ of arity /n/ and a list of argument types +-- @tycon_args@ of length /m/, +-- +-- @ +-- tyConInstArgTys tycon tycon_args +-- @ +-- +-- returns +-- +-- @ +-- [tycon_arg_{1}, tycon_arg_{2}, ..., tycon_arg_{m}, extra_arg_{m+1}, ..., extra_arg_{n}] +-- @ +-- +-- where @extra_args@ are distinct type variables. +-- +-- Examples: +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int, Bool]@, return @[Int, Bool]@. +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int]@, return @[Int, b]@. +tyConInstArgTys :: TyCon -> [Type] -> [Type] +tyConInstArgTys tycon tycon_args = chkAppend tycon_args $ map mkTyVarTy tycon_args_suffix + where + tycon_args_suffix = drop (length tycon_args) $ tyConTyVars tycon {- Note [Auxiliary binders] @@ -2733,4 +2769,56 @@ derived instances within the same module, not separated by any TH splices. (This is the case described in "Wrinkle: Reducing code duplication".) In situation (1), we can at least fall back on GHC's simplifier to pick up genAuxBinds' slack. + +Note [Filter out impossible GADT data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some stock-derivable classes will filter out impossible GADT data constructors, +to rule out problematic constructors when deriving instances. e.g. + +``` +data Foo a where + X :: Foo Int + Y :: (Bool -> Bool) -> Foo Bool +``` + +when deriving an instance on `Foo Int`, `Y` should be treated as if it didn't +exist in the first place. For instance, if we write + +``` +deriving instance Eq (Foo Int) +``` + +it should generate: + +``` +instance Eq (Foo Int) where + X == X = True +``` + +Classes that filter constructors: + +* Eq +* Ord +* Show +* Lift +* Functor +* Foldable +* Traversable + +Classes that do not filter constructors: + +* Enum: doesn't make sense for GADTs in the first place +* Bounded: only makes sense for GADTs with a single constructor +* Ix: only makes sense for GADTs with a single constructor +* Read: `Read a` returns `a` instead of consumes `a`, so filtering data + constructors would make this function _more_ partial instead of less +* Data: derived implementations of gunfold rely on a constructor-indexing + scheme that wouldn't work if certain constructors were filtered out +* Generic/Generic1: doesn't make sense for GADTs + +Classes that do not currently filter constructors may do so in the future, if +there is a valid use-case and we have requirements for how they should work. + +See #16341 and the T16341.hs test case. -} ===================================== compiler/GHC/Tc/Deriv/Infer.hs ===================================== @@ -260,9 +260,7 @@ inferConstraintsStock (DerivInstTys { dit_cls_tys = cls_tys -- substitute each type variable with its counterpart in the derived -- instance. rep_tc_args lists each of these counterpart types in -- the same order as the type variables. - all_rep_tc_args - = rep_tc_args ++ map mkTyVarTy - (drop (length rep_tc_args) rep_tc_tvs) + all_rep_tc_args = tyConInstArgTys rep_tc rep_tc_args -- Stupid constraints stupid_constraints ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -218,8 +218,9 @@ data DerivSpecMechanism -- instance, including what type constructor the last argument is -- headed by. See @Note [DerivEnv and DerivSpecMechanism]@. , dsm_stock_gen_fn :: - SrcSpan -> TyCon - -> [Type] + SrcSpan -> TyCon -- dit_rep_tc + -> [Type] -- dit_rep_tc_args + -> [Type] -- inst_tys -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]) -- ^ This function returns three things: -- @@ -424,7 +425,7 @@ instance Outputable DerivContext where -- See @Note [Deriving strategies]@ in "GHC.Tc.Deriv". data OriginativeDerivStatus = CanDeriveStock -- Stock class, can derive - (SrcSpan -> TyCon -> [Type] + (SrcSpan -> TyCon -> [Type] -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) | StockClassError SDoc -- Stock class, but can't do it | CanDeriveAnyClass -- See Note [Deriving any class] @@ -563,6 +564,7 @@ hasStockDeriving :: Class -> Maybe (SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) hasStockDeriving clas = assocMaybe gen_list (getUnique clas) @@ -571,6 +573,7 @@ hasStockDeriving clas :: [(Unique, SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))] gen_list = [ (eqClassKey, simpleM gen_Eq_binds) , (ordClassKey, simpleM gen_Ord_binds) @@ -587,25 +590,25 @@ hasStockDeriving clas , (genClassKey, generic (gen_Generic_binds Gen0)) , (gen1ClassKey, generic (gen_Generic_binds Gen1)) ] - simple gen_fn loc tc _ - = let (binds, deriv_stuff) = gen_fn loc tc + simple gen_fn loc tc tc_args _ + = let (binds, deriv_stuff) = gen_fn loc tc tc_args in return (binds, deriv_stuff, []) -- Like `simple`, but monadic. The only monadic thing that these functions -- do is allocate new Uniques, which are used for generating the names of -- auxiliary bindings. -- See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate. - simpleM gen_fn loc tc _ - = do { (binds, deriv_stuff) <- gen_fn loc tc + simpleM gen_fn loc tc tc_args _ + = do { (binds, deriv_stuff) <- gen_fn loc tc tc_args ; return (binds, deriv_stuff, []) } - read_or_show gen_fn loc tc _ + read_or_show gen_fn loc tc tc_args _ = do { fix_env <- getDataConFixityFun tc - ; let (binds, deriv_stuff) = gen_fn fix_env loc tc + ; let (binds, deriv_stuff) = gen_fn fix_env loc tc tc_args field_names = all_field_names tc ; return (binds, deriv_stuff, field_names) } - generic gen_fn _ tc inst_tys + generic gen_fn _ tc _ inst_tys = do { (binds, faminst) <- gen_fn tc inst_tys ; let field_names = all_field_names tc ; return (binds, unitBag (DerivFamInst faminst), field_names) } ===================================== testsuite/tests/deriving/should_compile/T16341.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveLift #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE StandaloneDeriving #-} + +module T16341 where + +import Language.Haskell.TH.Syntax (Lift) + +data Foo a where + Foo1 :: Foo Int + Foo2 :: (Bool -> Bool) -> Foo Bool + +-- These instances should work whether or not `Foo2` is a constructor in +-- `Foo`, because the `Foo Int` designation precludes `Foo2` from being +-- a reachable constructor +deriving instance Show (Foo Int) +deriving instance Eq (Foo Int) +deriving instance Ord (Foo Int) +deriving instance Lift (Foo Int) + +data Bar a b where + Bar1 :: b -> Bar Int b + Bar2 :: (Bool -> Bool) -> b -> Bar Bool b + +deriving instance Functor (Bar Int) +deriving instance Foldable (Bar Int) +deriving instance Traversable (Bar Int) ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -118,6 +118,7 @@ test('T15398', normal, compile, ['']) test('T15637', normal, compile, ['']) test('T15831', normal, compile, ['']) test('T16179', normal, compile, ['']) +test('T16341', normal, compile, ['']) test('T16518', normal, compile, ['']) test('T17324', normal, compile, ['']) test('T17339', normal, compile, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91fa5efabb15b2467296791472c169271bbff455...0f9341151f108915a77f8e5cf8299dc0c6bf322f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91fa5efabb15b2467296791472c169271bbff455...0f9341151f108915a77f8e5cf8299dc0c6bf322f You're receiving 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 Jul 28 17:27:00 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 28 Jul 2020 13:27:00 -0400 Subject: [Git][ghc/ghc][wip/backports] 2 commits: base: Bump version for log1mexp fix Message-ID: <5f205fe46359e_80b3f848c1e06f4558244@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: 9c8c4f25 by Ben Gamari at 2020-07-28T13:26:27-04:00 base: Bump version for log1mexp fix - - - - - ff4544e5 by Ben Gamari at 2020-07-28T13:26:46-04:00 users-guide: Release notes for 8.10.2 - - - - - 3 changed files: - docs/users_guide/8.10.2-notes.rst - libraries/base/base.cabal - libraries/base/changelog.md Changes: ===================================== docs/users_guide/8.10.2-notes.rst ===================================== @@ -11,13 +11,26 @@ Highlights ---------- - A few important correctness fixes for the low-latency garbage collector. + Users of :rts-flag:`--nonmoving-gc` are strongly encouraged to upgrade + promptly. -Full details ------------- +- Fixes a bug in process creation on Windows (:ghc-ticket:`17926`). -Language -~~~~~~~~ +- Works around a Linux kernel bug in the implementation of ``timerfd``\s + (:ghc-ticket:`18033`). + +- Fixes a few specialiser regressions (:ghc-ticket:`17810`, + :ghc-ticket:`18120`) as well introduces a variety of miscellaneous + specialiser improvements (:ghc-ticket:`16473`, :ghc-ticket:`17930`, + :ghc-ticket:`17966`) + +- Fixes a potential loss of sharing due to left operator sections + (:ghc-ticket:`18151`). + +- Fix bootstrapping of GHC with the LLVM backend on x86-64 (:ghc-ticket:`17920`). +Full details +------------ Compiler ~~~~~~~~ @@ -25,20 +38,16 @@ Compiler - A simplifier panic manifesting when DWARF debug information is enabled has been fixed (:ghc-ticket:`18162`, :ghc-ticket:`17619`) -GHC API -~~~~~~~ - - -GHCi -~~~~ - Runtime system ~~~~~~~~~~~~~~ -- The RTS now allows the user to specify a minimum time between idle GCs with - the :rts-flag:`-Iw ⟨seconds⟩` flag. 8.10.1 contained a users guide reference - to this flag but did not include the associated implementation. + - The RTS now supports a flag, :rts-flag:`--copying-gc`, to counter-act the + effect of :rts-flag:`--nonmoving-gc`. + + - The RTS now allows the user to specify a minimum time between idle GCs with + the :rts-flag:`-Iw ⟨seconds⟩` flag. 8.10.1 contained a users guide reference + to this flag but did not include the associated implementation. - A memory leak in the cost-center profiler has been fixed (:ghc-ticket:`18348`) @@ -49,26 +58,40 @@ Runtime system - We now workaround a Linux kernel bug in the implementation of timerfd which could previously result in program crashes (:ghc-ticket:`18033`) -Template Haskell -~~~~~~~~~~~~~~~~ - - + - The cost center profiler's JSON output backend now escapes backslashes + correctly (:ghc-ticket:`18438`) -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ + - A variety of linker issues on ARM platforms have been fixed. - -``ghc`` library -~~~~~~~~~~~~~~~ - ``base`` library ~~~~~~~~~~~~~~~~ +- Fix a precision issue in the implementation of ``log1mexp`` + (:ghc-ticket:`17125`) + + Build system ~~~~~~~~~~~~ + - Fix a bug wherein GHC would link against the non-thread-safe unique supply + implementation when bootstrapping with an unregisterised compiler + (:ghc-ticket:`18024`) + +Known issues +------------ + +- A long-standing bug (:ghc-ticket:`16893`) which can cause some applications + of ``unsafeCoerce`` to segmentation fault is only partially fixed in this + release. This release only avoids this issue in the uses of ``unsafeCoerce`` + in ``Data.Typeable.Internal``, which was the proximate cause of + :ghc-ticket:`16893`. + + However, it is possible that this bug could manifest in user-code using + ``unsafeCoerce`` to perform dynamic type checks. See the :ghc-ticket:`ticket + <16893>` for details. + We expect that this issue will be fixed in the next major release of GHC. Included libraries ------------------ ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.14.0.0 +version: 4.14.1.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,6 +1,13 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.14.1.0* Jul 2020 + + * Bundled with GHC 8.10.2 + + * Fix a precision issue in `log1mexp` (#17125) + ## 4.14.0.0 *Jan 2020 + * Bundled with GHC 8.10.1 * Add a `TestEquality` instance for the `Compose` newtype. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2e4fe92067da5e395daf0822113b3d38293db407...ff4544e5941ce909b91d235fdce42c0b62c2b786 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2e4fe92067da5e395daf0822113b3d38293db407...ff4544e5941ce909b91d235fdce42c0b62c2b786 You're receiving 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 Jul 28 19:24:37 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 28 Jul 2020 15:24:37 -0400 Subject: [Git][ghc/ghc][ghc-9.0] Bump haddock submodule Message-ID: <5f207b75679e7_80b3f849c1caa1055896d5@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-9.0 at Glasgow Haskell Compiler / GHC Commits: a10505e7 by Ben Gamari at 2020-07-28T15:24:29-04:00 Bump haddock submodule - - - - - 1 changed file: - utils/haddock Changes: ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 22b42eab6ec6b3b321b6d54041b7b3a6e54af3c9 +Subproject commit 28b6b667a4f6cfb79d84ce48b6e4a1dd4592cc21 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a10505e74ad9833d37d84afb9bf2cd031fd0ea71 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a10505e74ad9833d37d84afb9bf2cd031fd0ea71 You're receiving 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 Jul 28 23:59:12 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Tue, 28 Jul 2020 19:59:12 -0400 Subject: [Git][ghc/ghc][wip/T18470] Don't mark closed type family equations as occurrences Message-ID: <5f20bbd0e0421_80b116148a456079d9@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18470 at Glasgow Haskell Compiler / GHC Commits: 00e09d27 by Ryan Scott at 2020-07-28T19:57:25-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - 11 changed files: - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/TyCl.hs - testsuite/tests/indexed-types/should_fail/Overlap5.stderr - testsuite/tests/rename/should_fail/T16002.stderr - testsuite/tests/th/T15362.hs - testsuite/tests/th/T15362.stderr - + testsuite/tests/typecheck/should_compile/T18470.hs - + testsuite/tests/typecheck/should_compile/T18470.stderr - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T11623.stderr Changes: ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -424,11 +424,11 @@ patchCCallTarget unit callTarget = rnSrcInstDecl :: InstDecl GhcPs -> RnM (InstDecl GhcRn, FreeVars) rnSrcInstDecl (TyFamInstD { tfid_inst = tfi }) - = do { (tfi', fvs) <- rnTyFamInstDecl NonAssocTyFamEqn tfi + = do { (tfi', fvs) <- rnTyFamInstDecl (NonAssocTyFamEqn NotClosedTyFam) tfi ; return (TyFamInstD { tfid_ext = noExtField, tfid_inst = tfi' }, fvs) } rnSrcInstDecl (DataFamInstD { dfid_inst = dfi }) - = do { (dfi', fvs) <- rnDataFamInstDecl NonAssocTyFamEqn dfi + = do { (dfi', fvs) <- rnDataFamInstDecl (NonAssocTyFamEqn NotClosedTyFam) dfi ; return (DataFamInstD { dfid_ext = noExtField, dfid_inst = dfi' }, fvs) } rnSrcInstDecl (ClsInstD { cid_inst = cid }) @@ -760,8 +760,12 @@ rnFamInstEqn doc atfi rhs_kvars all_nms = all_imp_var_names ++ hsLTyVarNames bndrs' ; warnUnusedTypePatterns all_nms nms_used - ; let all_fvs = (rhs_fvs `plusFV` pat_fvs) `addOneFV` unLoc tycon' - -- type instance => use, hence addOneFV + ; let eqn_fvs = rhs_fvs `plusFV` pat_fvs + -- See Note [Type family equations and occurrences] + all_fvs = case atfi of + NonAssocTyFamEqn ClosedTyFam + -> eqn_fvs + _ -> eqn_fvs `addOneFV` unLoc tycon' ; return (HsIB { hsib_ext = all_imp_var_names -- Note [Wildcards in family instances] , hsib_body @@ -776,14 +780,14 @@ rnFamInstEqn doc atfi rhs_kvars -- The parent class, if we are dealing with an associated type family -- instance. mb_cls = case atfi of - NonAssocTyFamEqn -> Nothing + NonAssocTyFamEqn _ -> Nothing AssocTyFamDeflt cls -> Just cls AssocTyFamInst cls _ -> Just cls -- The type variables from the instance head, if we are dealing with an -- associated type family instance. inst_tvs = case atfi of - NonAssocTyFamEqn -> [] + NonAssocTyFamEqn _ -> [] AssocTyFamDeflt _ -> [] AssocTyFamInst _ inst_tvs -> inst_tvs @@ -806,48 +810,62 @@ rnTyFamInstDecl :: AssocTyFamInfo -> TyFamInstDecl GhcPs -> RnM (TyFamInstDecl GhcRn, FreeVars) rnTyFamInstDecl atfi (TyFamInstDecl { tfid_eqn = eqn }) - = do { (eqn', fvs) <- rnTyFamInstEqn atfi NotClosedTyFam eqn + = do { (eqn', fvs) <- rnTyFamInstEqn atfi eqn ; return (TyFamInstDecl { tfid_eqn = eqn' }, fvs) } -- | Tracks whether we are renaming: -- -- 1. A type family equation that is not associated --- with a parent type class ('NonAssocTyFamEqn') +-- with a parent type class ('NonAssocTyFamEqn'). Examples: -- --- 2. An associated type family default declaration ('AssocTyFamDeflt') +-- @ +-- type family F a +-- type instance F Int = Bool -- NonAssocTyFamEqn NotClosed -- --- 3. An associated type family instance declaration ('AssocTyFamInst') +-- type family G a where +-- G Int = Bool -- NonAssocTyFamEqn Closed +-- @ +-- +-- 2. An associated type family default declaration ('AssocTyFamDeflt'). +-- Example: +-- +-- @ +-- class C a where +-- type A a +-- type instance A a = a -> a -- AssocTyFamDeflt C +-- @ +-- +-- 3. An associated type family instance declaration ('AssocTyFamInst'). +-- Example: +-- +-- @ +-- instance C a => C [a] where +-- type A [a] = Bool -- AssocTyFamInst C [a] +-- @ data AssocTyFamInfo = NonAssocTyFamEqn - | AssocTyFamDeflt Name -- Name of the parent class - | AssocTyFamInst Name -- Name of the parent class - [Name] -- Names of the tyvars of the parent instance decl + ClosedTyFamInfo -- Is this a closed type family? + | AssocTyFamDeflt + Name -- Name of the parent class + | AssocTyFamInst + Name -- Name of the parent class + [Name] -- Names of the tyvars of the parent instance decl -- | Tracks whether we are renaming an equation in a closed type family -- equation ('ClosedTyFam') or not ('NotClosedTyFam'). data ClosedTyFamInfo = NotClosedTyFam - | ClosedTyFam (Located RdrName) Name - -- The names (RdrName and Name) of the closed type family + | ClosedTyFam rnTyFamInstEqn :: AssocTyFamInfo - -> ClosedTyFamInfo -> TyFamInstEqn GhcPs -> RnM (TyFamInstEqn GhcRn, FreeVars) -rnTyFamInstEqn atfi ctf_info +rnTyFamInstEqn atfi eqn@(HsIB { hsib_body = FamEqn { feqn_tycon = tycon , feqn_rhs = rhs }}) - = do { let rhs_kvs = extractHsTyRdrTyVarsKindVars rhs - ; (eqn'@(HsIB { hsib_body = - FamEqn { feqn_tycon = L _ tycon' }}), fvs) - <- rnFamInstEqn (TySynCtx tycon) atfi rhs_kvs eqn rnTySyn - ; case ctf_info of - NotClosedTyFam -> pure () - ClosedTyFam fam_rdr_name fam_name -> - checkTc (fam_name == tycon') $ - withHsDocContext (TyFamilyCtx fam_rdr_name) $ - wrongTyFamName fam_name tycon' - ; pure (eqn', fvs) } + = rnFamInstEqn (TySynCtx tycon) atfi rhs_kvs eqn rnTySyn + where + rhs_kvs = extractHsTyRdrTyVarsKindVars rhs rnTyFamDefltDecl :: Name -> TyFamDefltDecl GhcPs @@ -995,6 +1013,51 @@ was previously bound by the `instance C (Maybe a)` part. (see #16116). In each case, the function which detects improperly bound variables on the RHS is GHC.Tc.Validity.checkValidFamPats. + +Note [Type family equations and occurrences] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In most data/type family equations, the type family name used in the equation +is treated as an occurrence. For example: + + module A where + type family F a + + module B () where + import B (F) + type instance F Int = Bool + +We do not want to warn about `F` being unused in the module `B`, as the +instance constitutes a use site for `F`. The exception to this rule is closed +type families, whose equations constitute a definition, not occurrences. For +example: + + module C () where + type family CF a where + CF Char = Float + +Here, we /do/ want to warn that `CF` is unused in the module `C`, as it is +defined but not used (#18470). + +GHC accomplishes this in rnFamInstEqn when determining the set of free +variables to return at the end. If renaming a data family or open type family +equation, we add the name of the type family constructor to the set of returned +free variables to ensure that the name is marked as an occurrence. If renaming +a closed type family equation, we avoid adding the type family constructor name +to the free variables. This is quite simple, but it is not a perfect solution. +Consider this example: + + module X () where + type family F a where + F Int = Bool + F Double = F Int + +At present, GHC will treat any use of a type family constructor on the RHS of a +type family equation as an occurrence. Since `F` is used on the RHS of the +second equation of `F`, it is treated as an occurrence, causing `F` not to be +warned about. This is not ideal, since `F` isn't exported—it really /should/ +cause a warning to be emitted. There is some discussion in #10089/#12920 about +how this limitation might be overcome, but until then, we stick to the +simplistic solution above, as it fixes the egregious bug in #18470. -} @@ -1947,7 +2010,7 @@ rnFamDecl mb_cls (FamilyDecl { fdLName = tycon, fdTyVars = tyvars ; injectivity' <- traverse (rnInjectivityAnn tyvars' res_sig') injectivity ; return ( (tyvars', res_sig', injectivity') , fv_kind ) } - ; (info', fv2) <- rn_info tycon' info + ; (info', fv2) <- rn_info info ; return (FamilyDecl { fdExt = noExtField , fdLName = tycon', fdTyVars = tyvars' , fdFixity = fixity @@ -1959,18 +2022,16 @@ rnFamDecl mb_cls (FamilyDecl { fdLName = tycon, fdTyVars = tyvars kvs = extractRdrKindSigVars res_sig ---------------------- - rn_info :: Located Name - -> FamilyInfo GhcPs -> RnM (FamilyInfo GhcRn, FreeVars) - rn_info (L _ fam_name) (ClosedTypeFamily (Just eqns)) + rn_info :: FamilyInfo GhcPs -> RnM (FamilyInfo GhcRn, FreeVars) + rn_info (ClosedTypeFamily (Just eqns)) = do { (eqns', fvs) - <- rnList (rnTyFamInstEqn NonAssocTyFamEqn (ClosedTyFam tycon fam_name)) + <- rnList (rnTyFamInstEqn (NonAssocTyFamEqn ClosedTyFam)) eqns -- no class context - eqns ; return (ClosedTypeFamily (Just eqns'), fvs) } - rn_info _ (ClosedTypeFamily Nothing) + rn_info (ClosedTypeFamily Nothing) = return (ClosedTypeFamily Nothing, emptyFVs) - rn_info _ OpenTypeFamily = return (OpenTypeFamily, emptyFVs) - rn_info _ DataFamily = return (DataFamily, emptyFVs) + rn_info OpenTypeFamily = return (OpenTypeFamily, emptyFVs) + rn_info DataFamily = return (DataFamily, emptyFVs) rnFamResultSig :: HsDocContext -> FamilyResultSig GhcPs @@ -2114,13 +2175,6 @@ are no data constructors we allow h98_style = True * * ***************************************************** -} ---------------- -wrongTyFamName :: Name -> Name -> SDoc -wrongTyFamName fam_tc_name eqn_tc_name - = hang (text "Mismatched type name in type family instance.") - 2 (vcat [ text "Expected:" <+> ppr fam_tc_name - , text " Actual:" <+> ppr eqn_tc_name ]) - ----------------- rnConDecls :: [LConDecl GhcPs] -> RnM ([LConDecl GhcRn], FreeVars) rnConDecls = mapFvRn (wrapLocFstM rnConDecl) ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -67,8 +67,8 @@ data AssocInstInfo } isNotAssociated :: AssocInstInfo -> Bool -isNotAssociated NotAssociated = True -isNotAssociated (InClsInst {}) = False +isNotAssociated (NotAssociated {}) = True +isNotAssociated (InClsInst {}) = False {- ******************************************************************* ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -2833,8 +2833,17 @@ kcTyFamInstEqn tc_fam_tc , text "feqn_pats =" <+> ppr hs_pats ]) -- this check reports an arity error instead of a kind error; easier for user ; let vis_pats = numVisibleArgs hs_pats + + -- First, check if we're dealing with a closed type family equation, and + -- if so, ensure that each equation's type constructor is for the right + -- type family. E.g. barf on + -- type family F a where { G Int = Bool } + ; checkTc (tc_fam_tc_name == eqn_tc_name) $ + wrongTyFamName tc_fam_tc_name eqn_tc_name + ; checkTc (vis_pats == vis_arity) $ wrongNumberOfParmsErr vis_arity + ; discardResult $ bindImplicitTKBndrs_Q_Tv imp_vars $ bindExplicitTKBndrs_Q_Tv AnyKind (mb_expl_bndrs `orElse` []) $ @@ -2848,7 +2857,7 @@ kcTyFamInstEqn tc_fam_tc } where vis_arity = length (tyConVisibleTyVars tc_fam_tc) - + tc_fam_tc_name = getName tc_fam_tc -------------------------- tcTyFamInstEqn :: TcTyCon -> AssocInstInfo -> LTyFamInstEqn GhcRn @@ -2858,22 +2867,22 @@ tcTyFamInstEqn :: TcTyCon -> AssocInstInfo -> LTyFamInstEqn GhcRn tcTyFamInstEqn fam_tc mb_clsinfo (L loc (HsIB { hsib_ext = imp_vars - , hsib_body = FamEqn { feqn_tycon = L _ eqn_tc_name - , feqn_bndrs = mb_expl_bndrs + , hsib_body = FamEqn { feqn_bndrs = mb_expl_bndrs , feqn_pats = hs_pats , feqn_rhs = hs_rhs_ty }})) - = ASSERT( getName fam_tc == eqn_tc_name ) - setSrcSpan loc $ + = setSrcSpan loc $ do { traceTc "tcTyFamInstEqn" $ vcat [ ppr fam_tc <+> ppr hs_pats , text "fam tc bndrs" <+> pprTyVars (tyConTyVars fam_tc) , case mb_clsinfo of - NotAssociated -> empty + NotAssociated {} -> empty InClsInst { ai_class = cls } -> text "class" <+> ppr cls <+> pprTyVars (classTyVars cls) ] -- First, check the arity of visible arguments -- If we wait until validity checking, we'll get kind errors -- below when an arity error will be much easier to understand. + -- Note that for closed type families, kcTyFamInstEqn has already + -- checked the arity previously. ; let vis_arity = length (tyConVisibleTyVars fam_tc) vis_pats = numVisibleArgs hs_pats ; checkTc (vis_pats == vis_arity) $ @@ -4919,6 +4928,12 @@ incoherentRoles = (text "Roles other than" <+> quotes (text "nominal") <+> text "for class parameters can lead to incoherence.") $$ (text "Use IncoherentInstances to allow this; bad role found") +wrongTyFamName :: Name -> Name -> SDoc +wrongTyFamName fam_tc_name eqn_tc_name + = hang (text "Mismatched type name in type family instance.") + 2 (vcat [ text "Expected:" <+> ppr fam_tc_name + , text " Actual:" <+> ppr eqn_tc_name ]) + addTyConCtxt :: TyCon -> TcM a -> TcM a addTyConCtxt tc = addTyConFlavCtxt name flav where ===================================== testsuite/tests/indexed-types/should_fail/Overlap5.stderr ===================================== @@ -1,6 +1,6 @@ Overlap5.hs:8:3: error: - Mismatched type name in type family instance. - Expected: F - Actual: G - In the declaration for type family ‘F’ + • Mismatched type name in type family instance. + Expected: F + Actual: G + • In the type family declaration for ‘F’ ===================================== testsuite/tests/rename/should_fail/T16002.stderr ===================================== @@ -1,6 +1,6 @@ T16002.hs:6:3: error: - Mismatched type name in type family instance. - Expected: B - Actual: A - In the declaration for type family ‘B’ + • Mismatched type name in type family instance. + Expected: B + Actual: A + • In the type family declaration for ‘B’ ===================================== testsuite/tests/th/T15362.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds #-} +{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds, TypeFamilies #-} module T15362 where ===================================== testsuite/tests/th/T15362.stderr ===================================== @@ -1,10 +1,6 @@ -T15362.hs:8:10: error: +T15362.hs:7:2: error: • Mismatched type name in type family instance. Expected: + Actual: Maybe - In the declaration for type family ‘+’ - • In the Template Haskell quotation - [d| type family a + b where - Maybe Zero b = b - Succ a + b = Succ (a + b) |] + • In the type family declaration for ‘+’ ===================================== testsuite/tests/typecheck/should_compile/T18470.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC -Wunused-top-binds #-} + +module T18470 () where + +type family Closed x where + Closed Int = Bool ===================================== testsuite/tests/typecheck/should_compile/T18470.stderr ===================================== @@ -0,0 +1,3 @@ + +T18470.hs:6:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] + Defined but not used: type constructor or class ‘Closed’ ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -717,3 +717,4 @@ test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) test('T17775-viewpats-d', normal, compile_fail, ['']) test('T18412', normal, compile, ['']) +test('T18470', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T11623.stderr ===================================== @@ -1,6 +1,6 @@ T11623.hs:5:23: error: - Mismatched type name in type family instance. - Expected: T - Actual: Maybe - In the declaration for type family ‘T’ + • Mismatched type name in type family instance. + Expected: T + Actual: Maybe + • In the type family declaration for ‘T’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/00e09d271aa464246995633cc4cad41358db40ea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/00e09d271aa464246995633cc4cad41358db40ea You're receiving 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 Jul 29 00:54:19 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 28 Jul 2020 20:54:19 -0400 Subject: [Git][ghc/ghc][master] Fix typo in haddock Message-ID: <5f20c8bb58829_80b3f849a25e69056127d3@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 1 changed file: - libraries/base/GHC/IO.hs Changes: ===================================== libraries/base/GHC/IO.hs ===================================== @@ -173,7 +173,7 @@ catchException !io handler = catch io handler -- @IO Int -> (ArithException -> IO Int) -> IO Int@ then the handler may -- get run with @DivideByZero@ as an argument, or an @ErrorCall \"urk\"@ -- exception may be propagated further up. If you call it again, you --- might get a the opposite behaviour. This is ok, because 'catch' is an +-- might get the opposite behaviour. This is ok, because 'catch' is an -- 'IO' computation. -- catch :: Exception e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/318bb17c9d3fbbe68eff706c38eb8e653cea3d83 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/318bb17c9d3fbbe68eff706c38eb8e653cea3d83 You're receiving 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 Jul 29 00:54:56 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 28 Jul 2020 20:54:56 -0400 Subject: [Git][ghc/ghc][master] ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Message-ID: <5f20c8e0488d5_80b3f84901714f856150fb@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 1 changed file: - ghc.mk Changes: ===================================== ghc.mk ===================================== @@ -656,7 +656,9 @@ BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE1)) BUILD_DIRS += $(patsubst %, libraries/%, $(filter-out $(PACKAGES_STAGE1),$(PACKAGES_STAGE0))) endif +ifeq "$(BIGNUM_BACKEND)" "gmp" BUILD_DIRS += libraries/ghc-bignum/gmp +endif BUILD_DIRS += utils/haddock BUILD_DIRS += utils/haddock/doc BUILD_DIRS += compiler View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39c89862161bf488a6aca9372cbb67690f436ce7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39c89862161bf488a6aca9372cbb67690f436ce7 You're receiving 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 Jul 29 01:25:51 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 28 Jul 2020 21:25:51 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 12 commits: Fix typo in haddock Message-ID: <5f20d01f7dbc9_80b3f848a37384c562196b@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - d0e3bbf3 by Felix Wiemuth at 2020-07-28T21:25:38-04:00 Fix typo - - - - - 744f2957 by Brandon Chinn at 2020-07-28T21:25:38-04:00 Add regression test for #16341 - - - - - a6bf1978 by Brandon Chinn at 2020-07-28T21:25:38-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - 8d974a0f by Brandon Chinn at 2020-07-28T21:25:38-04:00 Pass tc_args to gen_fn - - - - - 60465764 by Brandon Chinn at 2020-07-28T21:25:38-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - 9fe59bd5 by Simon Peyton Jones at 2020-07-28T21:25:39-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - caf3add8 by Simon Peyton Jones at 2020-07-28T21:25:39-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - b570bd2c by Simon Peyton Jones at 2020-07-28T21:25:39-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 2ca40e92 by Peter Trommler at 2020-07-28T21:25:39-04:00 configure: Fix build system on ARM - - - - - 8a287593 by Sylvain Henry at 2020-07-28T21:25:44-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - 22 changed files: - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Types/Name/Reader.hs - ghc.mk - libraries/base/Data/Maybe.hs - libraries/base/GHC/IO.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-bignum/src/GHC/Num/Natural.hs - libraries/ghc-bignum/src/GHC/Num/WordArray.hs - + testsuite/tests/deriving/should_compile/T16341.hs - testsuite/tests/deriving/should_compile/all.T - + testsuite/tests/numeric/should_run/T18509.hs - + testsuite/tests/numeric/should_run/T18509.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== aclocal.m4 ===================================== @@ -206,7 +206,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], ;; arm) GET_ARM_ISA() - test -z "[$]2" || eval "[$]2=\"ArchARM \$ARM_ISA \$ARM_ISA_EXT \$ARM_ABI}\"" + test -z "[$]2" || eval "[$]2=\"ArchARM \$ARM_ISA \$ARM_ISA_EXT \$ARM_ABI\"" ;; aarch64) test -z "[$]2" || eval "[$]2=ArchARM64" ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -1891,7 +1891,9 @@ substForAllCoBndrUsingLC sym sco (LC subst lc_env) tv co -- -- For the inverse operation, see 'liftCoMatch' ty_co_subst :: LiftingContext -> Role -> Type -> Coercion -ty_co_subst lc role ty +ty_co_subst !lc role ty + -- !lc: making this function strict in lc allows callers to + -- pass its two components separately, rather than boxing them = go role ty where go :: Role -> Type -> Coercion @@ -2864,9 +2866,9 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs -- need a coercion (kind_co :: old_kind ~ new_kind). -- -- The bangs here have been observed to improve performance - -- significantly in optimized builds. - let kind_co = mkSymCo $ - liftCoSubst Nominal lc (tyCoBinderType binder) + -- significantly in optimized builds; see #18502 + let !kind_co = mkSymCo $ + liftCoSubst Nominal lc (tyCoBinderType binder) !casted_xi = xi `mkCastTy` kind_co casted_co = mkCoherenceLeftCo role xi kind_co co ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -1004,7 +1004,7 @@ simplExprF1 env (App fun arg) cont , sc_hole_ty = hole' , sc_cont = cont } } _ -> - -- crucially, these are /lazy/ bindings. They will + -- Crucially, sc_hole_ty is a /lazy/ binding. It will -- be forced only if we need to run contHoleType. -- When these are forced, we might get quadratic behavior; -- this quadratic blowup could be avoided by drilling down @@ -1012,17 +1012,10 @@ simplExprF1 env (App fun arg) cont -- (instead of one-at-a-time). But in practice, we have not -- observed the quadratic behavior, so this extra entanglement -- seems not worthwhile. - -- - -- But the (exprType fun) is repeated, to push it into two - -- separate, rarely used, thunks; rather than always alloating - -- a shared thunk. Makes a small efficiency difference - let fun_ty = exprType fun - (m, _, _) = splitFunTy fun_ty - in simplExprF env fun $ ApplyToVal { sc_arg = arg, sc_env = env , sc_hole_ty = substTy env (exprType fun) - , sc_dup = NoDup, sc_cont = cont, sc_mult = m } + , sc_dup = NoDup, sc_cont = cont } simplExprF1 env expr@(Lam {}) cont = {-#SCC "simplExprF1-Lam" #-} @@ -1327,8 +1320,8 @@ rebuild env expr cont Select { sc_bndr = bndr, sc_alts = alts, sc_env = se, sc_cont = cont } -> rebuildCase (se `setInScopeFromE` env) expr bndr alts cont - StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty, sc_mult = m } - -> rebuildCall env (addValArgTo fun (m, expr) fun_ty ) cont + StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty } + -> rebuildCall env (addValArgTo fun expr fun_ty ) cont StrictBind { sc_bndr = b, sc_bndrs = bs, sc_body = body , sc_env = se, sc_cont = cont } -> do { (floats1, env') <- simplNonRecX (se `setInScopeFromE` env) b expr @@ -1420,7 +1413,7 @@ simplCast env body co0 cont0 -- co1 :: t1 ~ s1 -- co2 :: s2 ~ t2 addCoerce co cont@(ApplyToVal { sc_arg = arg, sc_env = arg_se - , sc_dup = dup, sc_cont = tail, sc_mult = m }) + , sc_dup = dup, sc_cont = tail }) | Just (co1, m_co2) <- pushCoValArg co , let new_ty = coercionRKind co1 , not (isTypeLevPoly new_ty) -- Without this check, we get a lev-poly arg @@ -1444,8 +1437,7 @@ simplCast env body co0 cont0 , sc_env = arg_se' , sc_dup = dup' , sc_cont = tail' - , sc_hole_ty = coercionLKind co - , sc_mult = m }) } } + , sc_hole_ty = coercionLKind co }) } } addCoerce co cont | isReflexiveCo co = return cont -- Having this at the end makes a huge @@ -1981,17 +1973,18 @@ rebuildCall env info (ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_c -- runRW# :: forall (r :: RuntimeRep) (o :: TYPE r). (State# RealWorld -> o) -> o -- K[ runRW# rr ty body ] --> runRW rr' ty' (\s. K[ body s ]) rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) - (ApplyToVal { sc_arg = arg, sc_env = arg_se, sc_cont = cont, sc_mult = m }) + (ApplyToVal { sc_arg = arg, sc_env = arg_se + , sc_cont = cont, sc_hole_ty = fun_ty }) | fun_id `hasKey` runRWKey , not (contIsStop cont) -- Don't fiddle around if the continuation is boring , [ TyArg {}, TyArg {} ] <- rev_args = do { s <- newId (fsLit "s") Many realWorldStatePrimTy - ; let env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] + ; let (m,_,_) = splitFunTy fun_ty + env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] ty' = contResultType cont cont' = ApplyToVal { sc_dup = Simplified, sc_arg = Var s , sc_env = env', sc_cont = cont - , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' - , sc_mult = m } + , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' } -- cont' applies to s, then K ; body' <- simplExprC env' arg cont' ; let arg' = Lam s body' @@ -2002,10 +1995,10 @@ rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) rebuildCall env fun_info (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_dup = dup_flag, sc_hole_ty = fun_ty - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Argument is already simplified | isSimplified dup_flag -- See Note [Avoid redundant simplification] - = rebuildCall env (addValArgTo fun_info (m, arg) fun_ty) cont + = rebuildCall env (addValArgTo fun_info arg fun_ty) cont -- Strict arguments | isStrictArgInfo fun_info @@ -2014,7 +2007,7 @@ rebuildCall env fun_info simplExprF (arg_se `setInScopeFromE` env) arg (StrictArg { sc_fun = fun_info, sc_fun_ty = fun_ty , sc_dup = Simplified - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Note [Shadowing] -- Lazy arguments @@ -2025,7 +2018,7 @@ rebuildCall env fun_info -- floating a demanded let. = do { arg' <- simplExprC (arg_se `setInScopeFromE` env) arg (mkLazyArgStop arg_ty (lazyArgContext fun_info)) - ; rebuildCall env (addValArgTo fun_info (m, arg') fun_ty) cont } + ; rebuildCall env (addValArgTo fun_info arg' fun_ty) cont } where arg_ty = funArgTy fun_ty @@ -2233,24 +2226,10 @@ trySeqRules in_env scrut rhs cont , as_hole_ty = res2_ty } , ValArg { as_arg = no_cast_scrut , as_dmd = seqDmd - , as_hole_ty = res3_ty - , as_mult = Many } ] - -- The multiplicity of the scrutiny above is Many because the type - -- of seq requires that its first argument is unrestricted. The - -- typing rule of case also guarantees it though. In a more - -- general world, where the first argument of seq would have - -- affine multiplicity, then we could use the multiplicity of - -- the case (held in the case binder) instead. + , as_hole_ty = res3_ty } ] rule_cont = ApplyToVal { sc_dup = NoDup, sc_arg = rhs , sc_env = in_env, sc_cont = cont - , sc_hole_ty = res4_ty, sc_mult = Many } - -- The multiplicity in sc_mult above is the - -- multiplicity of the second argument of seq. Since - -- seq's type, as it stands, imposes that its second - -- argument be unrestricted, so is - -- sc_mult. However, a more precise typing rule, - -- for seq, would be to have it be linear. In which - -- case, sc_mult should be 1. + , sc_hole_ty = res4_ty } -- Lazily evaluated, so we don't do most of this @@ -3304,7 +3283,7 @@ mkDupableContWithDmds env _ mkDupableContWithDmds env _ (StrictArg { sc_fun = fun, sc_cont = cont - , sc_fun_ty = fun_ty, sc_mult = m }) + , sc_fun_ty = fun_ty }) -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable | thumbsUpPlanA cont = -- Use Plan A of Note [Duplicating StrictArg] @@ -3318,18 +3297,17 @@ mkDupableContWithDmds env _ , StrictArg { sc_fun = fun { ai_args = args' } , sc_cont = cont' , sc_fun_ty = fun_ty - , sc_mult = m , sc_dup = OkToDup} ) } | otherwise = -- Use Plan B of Note [Duplicating StrictArg] -- K[ f a b <> ] --> join j x = K[ f a b x ] -- j <> - do { let arg_ty = funArgTy fun_ty - rhs_ty = contResultType cont - ; arg_bndr <- newId (fsLit "arg") m arg_ty -- ToDo: check this linearity argument + do { let rhs_ty = contResultType cont + (m,arg_ty,_) = splitFunTy fun_ty + ; arg_bndr <- newId (fsLit "arg") m arg_ty ; let env' = env `addNewInScopeIds` [arg_bndr] - ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (m, Var arg_bndr) fun_ty) cont + ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (Var arg_bndr) fun_ty) cont ; mkDupableStrictBind env' arg_bndr (wrapFloats floats join_rhs) rhs_ty } where thumbsUpPlanA (StrictArg {}) = False @@ -3349,7 +3327,7 @@ mkDupableContWithDmds env dmds mkDupableContWithDmds env dmds (ApplyToVal { sc_arg = arg, sc_dup = dup, sc_env = se - , sc_cont = cont, sc_hole_ty = hole_ty, sc_mult = mult }) + , sc_cont = cont, sc_hole_ty = hole_ty }) = -- e.g. [...hole...] (...arg...) -- ==> -- let a = ...arg... @@ -3369,7 +3347,7 @@ mkDupableContWithDmds env dmds -- has turned arg'' into a fresh variable -- See Note [StaticEnv invariant] in GHC.Core.Opt.Simplify.Utils , sc_dup = OkToDup, sc_cont = cont' - , sc_hole_ty = hole_ty, sc_mult = mult }) } + , sc_hole_ty = hole_ty }) } mkDupableContWithDmds env _ (Select { sc_bndr = case_bndr, sc_alts = alts, sc_env = se, sc_cont = cont }) @@ -3439,7 +3417,6 @@ mkDupableStrictBind env arg_bndr join_rhs res_ty , sc_fun = arg_info , sc_fun_ty = idType join_bndr , sc_cont = mkBoringStop res_ty - , sc_mult = Many -- ToDo: check this! } ) } mkDupableAlt :: Platform -> OutId ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -125,8 +125,7 @@ data SimplCont -- See Note [The hole type in ApplyToTy/Val] , sc_arg :: InExpr -- The argument, , sc_env :: StaticEnv -- see Note [StaticEnv invariant] - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | ApplyToTy -- (ApplyToTy ty K)[e] = K[ e ty ] { sc_arg_ty :: OutType -- Argument type @@ -160,8 +159,7 @@ data SimplCont , sc_fun_ty :: OutType -- Type of the function (f e1 .. en), -- presumably (arg_ty -> res_ty) -- where res_ty is expected by sc_cont - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | TickIt -- (TickIt t K)[e] = K[ tick t e ] (Tickish Id) -- Tick tickish @@ -282,8 +280,7 @@ data ArgInfo } data ArgSpec - = ValArg { as_mult :: Mult - , as_dmd :: Demand -- Demand placed on this argument + = ValArg { as_dmd :: Demand -- Demand placed on this argument , as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal , as_hole_ty :: OutType } -- Type of the function (presumably t1 -> t2) @@ -300,16 +297,15 @@ instance Outputable ArgInfo where , text "args =" <+> ppr args ]) instance Outputable ArgSpec where - ppr (ValArg { as_mult = mult, as_arg = arg }) = text "ValArg" <+> ppr mult <+> ppr arg + ppr (ValArg { as_arg = arg }) = text "ValArg" <+> ppr arg ppr (TyArg { as_arg_ty = ty }) = text "TyArg" <+> ppr ty ppr (CastBy c) = text "CastBy" <+> ppr c -addValArgTo :: ArgInfo -> (Mult, OutExpr) -> OutType -> ArgInfo -addValArgTo ai (w, arg) hole_ty +addValArgTo :: ArgInfo -> OutExpr -> OutType -> ArgInfo +addValArgTo ai arg hole_ty | ArgInfo { ai_dmds = dmd:dmds, ai_discs = _:discs, ai_rules = rules } <- ai -- Pop the top demand and and discounts off - , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty - , as_mult = w, as_dmd = dmd } + , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty, as_dmd = dmd } = ai { ai_args = arg_spec : ai_args ai , ai_dmds = dmds , ai_discs = discs @@ -345,9 +341,9 @@ pushSimplifiedArgs env (arg : args) k = case arg of TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } -> ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = rest } - ValArg { as_arg = arg, as_hole_ty = hole_ty, as_mult = w } + ValArg { as_arg = arg, as_hole_ty = hole_ty } -> ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified - , sc_hole_ty = hole_ty, sc_cont = rest, sc_mult = w } + , sc_hole_ty = hole_ty, sc_cont = rest } CastBy c -> CastIt c rest where rest = pushSimplifiedArgs env args k @@ -446,7 +442,7 @@ contHoleType (TickIt _ k) = contHoleType k contHoleType (CastIt co _) = coercionLKind co contHoleType (StrictBind { sc_bndr = b, sc_dup = dup, sc_env = se }) = perhapsSubstTy dup se (idType b) -contHoleType (StrictArg { sc_fun_ty = ty, sc_mult = _m }) = funArgTy ty +contHoleType (StrictArg { sc_fun_ty = ty }) = funArgTy ty contHoleType (ApplyToTy { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy] contHoleType (ApplyToVal { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy/Val] contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) @@ -464,12 +460,14 @@ contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) contHoleScaling :: SimplCont -> Mult contHoleScaling (Stop _ _) = One contHoleScaling (CastIt _ k) = contHoleScaling k -contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k -contHoleScaling (StrictArg { sc_mult = w, sc_cont = k }) = - w `mkMultMul` contHoleScaling k -contHoleScaling (Select { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k +contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (Select { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (StrictArg { sc_fun_ty = fun_ty, sc_cont = k }) + = w `mkMultMul` contHoleScaling k + where + (w, _, _) = splitFunTy fun_ty contHoleScaling (ApplyToTy { sc_cont = k }) = contHoleScaling k contHoleScaling (ApplyToVal { sc_cont = k }) = contHoleScaling k contHoleScaling (TickIt _ k) = contHoleScaling k ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -236,19 +236,30 @@ newPatName (LetMk is_top fix_env) rdr_name do { name <- case is_top of NotTopLevel -> newLocalBndrRn rdr_name TopLevel -> newTopSrcBinder rdr_name - ; bindLocalNames [name] $ -- Do *not* use bindLocalNameFV here - -- See Note [View pattern usage] + ; bindLocalNames [name] $ + -- Do *not* use bindLocalNameFV here; + -- see Note [View pattern usage] + -- For the TopLevel case + -- see Note [bindLocalNames for an External name] addLocalFixities fix_env [name] $ thing_inside name }) - -- Note: the bindLocalNames is somewhat suspicious - -- because it binds a top-level name as a local name. - -- however, this binding seems to work, and it only exists for - -- the duration of the patterns and the continuation; - -- then the top-level name is added to the global env - -- before going on to the RHSes (see GHC.Rename.Module). +{- Note [bindLocalNames for an External name] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In the TopLevel case, the use of bindLocalNames here is somewhat +suspicious because it binds a top-level External name in the +LocalRdrEnv. c.f. Note [LocalRdrEnv] in GHC.Types.Name.Reader. + +However, this only happens when renaming the LHS (only) of a top-level +pattern binding. Even though this only the LHS, we need to bring the +binder into scope in the pattern itself in case the binder is used in +subsequent view patterns. A bit bizarre, something like + (x, Just y <- f x) = e + +Anyway, bindLocalNames does work, and the binding only exists for the +duration of the pattern; then the top-level name is added to the +global env before going on to the RHSes (see GHC.Rename.Module). -{- Note [View pattern usage] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== compiler/GHC/Tc/Deriv.hs ===================================== @@ -2038,9 +2038,12 @@ genDerivStuff mechanism loc clas inst_tys tyvars -> gen_newtype_or_via rhs_ty -- Try a stock deriver - DerivSpecStock { dsm_stock_dit = DerivInstTys{dit_rep_tc = rep_tc} + DerivSpecStock { dsm_stock_dit = DerivInstTys + { dit_rep_tc = rep_tc + , dit_rep_tc_args = rep_tc_args + } , dsm_stock_gen_fn = gen_fn } - -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc inst_tys + -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc rep_tc_args inst_tys pure (binds, [], faminsts, field_names) -- Try DeriveAnyClass ===================================== compiler/GHC/Tc/Deriv/Functor.hs ===================================== @@ -151,10 +151,10 @@ is a similar algorithm for generating `p <$ x` (for some constant `p`): $(coreplace 'a '(tb -> tc) x) = \(y:tb[b/a]) -> $(coreplace 'a' 'tc' (x $(replace 'a 'tb y))) -} -gen_Functor_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Functor_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use fmap _ = coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag fmap_bind, emptyBag) where @@ -165,10 +165,10 @@ gen_Functor_binds loc tycon coerce_Expr] fmap_match_ctxt = mkPrefixFunRhs fmap_name -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon tycon_args = (listToBag [fmap_bind, replace_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args fmap_name = L loc fmap_RDR -- See Note [EmptyDataDecls with Functor, Foldable, and Traversable] @@ -787,10 +787,10 @@ could surprise users if they switch to other types, but Ryan Scott seems to think it's okay to do it for now. -} -gen_Foldable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Foldable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the parameter is phantom, we can use foldMap _ _ = mempty -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag foldMap_bind, emptyBag) where @@ -801,7 +801,7 @@ gen_Foldable_binds loc tycon mempty_Expr] foldMap_match_ctxt = mkPrefixFunRhs foldMap_name -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon tycon_args | null data_cons -- There's no real point producing anything but -- foldMap for a type with no constructors. = (unitBag foldMap_bind, emptyBag) @@ -809,7 +809,7 @@ gen_Foldable_binds loc tycon | otherwise = (listToBag [foldr_bind, foldMap_bind, null_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args foldr_bind = mkRdrFunBind (L loc foldable_foldr_RDR) eqns eqns = map foldr_eqn data_cons @@ -1016,10 +1016,10 @@ removes all such types from consideration. See Note [Generated code for DeriveFoldable and DeriveTraversable]. -} -gen_Traversable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Traversable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use traverse = pure . coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag traverse_bind, emptyBag) where @@ -1031,10 +1031,10 @@ gen_Traversable_binds loc tycon (nlHsApps pure_RDR [nlHsApp coerce_Expr z_Expr])] traverse_match_ctxt = mkPrefixFunRhs traverse_name -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon tycon_args = (unitBag traverse_bind, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args traverse_name = L loc traverse_RDR ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -33,7 +33,9 @@ module GHC.Tc.Deriv.Generate ( mkCoerceClassMethEqn, genAuxBinds, ordOpTbl, boxConTbl, litConTbl, - mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr + mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr, + + getPossibleDataCons, tyConInstArgTys ) where #include "HsVersions.h" @@ -212,14 +214,14 @@ for the instance decl, which it probably wasn't, so the decls produced don't get through the typechecker. -} -gen_Eq_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Eq_binds loc tycon = do +gen_Eq_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Eq_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon return (method_binds con2tag_RDR, aux_binds con2tag_RDR) where - all_cons = tyConDataCons tycon + all_cons = getPossibleDataCons tycon tycon_args (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon all_cons -- If there are ten or more (arbitrary number) nullary constructors, @@ -396,8 +398,8 @@ gtResult OrdGE = true_Expr gtResult OrdGT = true_Expr ------------ -gen_Ord_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ord_binds loc tycon = do +gen_Ord_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ord_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon @@ -432,7 +434,7 @@ gen_Ord_binds loc tycon = do -- We want *zero-based* tags, because that's what -- con2Tag returns (generated by untag_Expr)! - tycon_data_cons = tyConDataCons tycon + tycon_data_cons = getPossibleDataCons tycon tycon_args single_con_type = isSingleton tycon_data_cons (first_con : _) = tycon_data_cons (last_con : _) = reverse tycon_data_cons @@ -646,8 +648,8 @@ instance ... Enum (Foo ...) where For @enumFromTo@ and @enumFromThenTo@, we use the default methods. -} -gen_Enum_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Enum_binds loc tycon = do +gen_Enum_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Enum_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -738,8 +740,8 @@ gen_Enum_binds loc tycon = do ************************************************************************ -} -gen_Bounded_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Bounded_binds loc tycon +gen_Bounded_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Bounded_binds loc tycon _ | isEnumerationTyCon tycon = (listToBag [ min_bound_enum, max_bound_enum ], emptyBag) | otherwise @@ -825,9 +827,9 @@ we follow the scheme given in Figure~19 of the Haskell~1.2 report (p.~147). -} -gen_Ix_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ix_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ix_binds loc tycon = do +gen_Ix_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -1028,10 +1030,10 @@ These instances are also useful for Read (Either Int Emp), where we want to be able to parse (Left 3) just fine. -} -gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Read_binds get_fixity loc tycon +gen_Read_binds get_fixity loc tycon _ = (listToBag [read_prec, default_readlist, default_readlistprec], emptyBag) where ----------------------------------------------------------------------- @@ -1212,13 +1214,13 @@ Example -- the most tightly-binding operator -} -gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Show_binds get_fixity loc tycon +gen_Show_binds get_fixity loc tycon tycon_args = (unitBag shows_prec, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args shows_prec = mkFunBindEC 2 loc showsPrec_RDR id (map pats_etc data_cons) comma_space = nlHsVar showCommaSpace_RDR @@ -1385,9 +1387,10 @@ we generate gen_Data_binds :: SrcSpan -> TyCon -- For data families, this is the -- *representation* TyCon + -> [Type] -> TcM (LHsBinds GhcPs, -- The method bindings BagDerivStuff) -- Auxiliary bindings -gen_Data_binds loc rep_tc +gen_Data_binds loc rep_tc _ = do { -- See Note [Auxiliary binders] dataT_RDR <- new_dataT_rdr_name loc rep_tc ; dataC_RDRs <- traverse (new_dataC_rdr_name loc) data_cons @@ -1616,8 +1619,8 @@ Example: -} -gen_Lift_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) +gen_Lift_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Lift_binds loc tycon tycon_args = (listToBag [lift_bind, liftTyped_bind], emptyBag) where lift_bind = mkFunBindEC 1 loc lift_RDR (nlHsApp pure_Expr) (map (pats_etc mk_exp) data_cons) @@ -1626,7 +1629,7 @@ gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) mk_exp = ExpBr noExtField mk_texp = TExpBr noExtField - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args pats_etc mk_bracket data_con = ([con_pat], lift_Expr) @@ -2515,6 +2518,39 @@ newAuxBinderRdrName loc parent occ_fun = do uniq <- newUnique pure $ Exact $ mkSystemNameAt uniq (occ_fun (nameOccName parent)) loc +-- | @getPossibleDataCons tycon tycon_args@ returns the constructors of @tycon@ +-- whose return types match when checked against @tycon_args at . +-- +-- See Note [Filter out impossible GADT data constructors] +getPossibleDataCons :: TyCon -> [Type] -> [DataCon] +getPossibleDataCons tycon tycon_args = filter isPossible $ tyConDataCons tycon + where + isPossible = not . dataConCannotMatch (tyConInstArgTys tycon tycon_args) + +-- | Given a type constructor @tycon@ of arity /n/ and a list of argument types +-- @tycon_args@ of length /m/, +-- +-- @ +-- tyConInstArgTys tycon tycon_args +-- @ +-- +-- returns +-- +-- @ +-- [tycon_arg_{1}, tycon_arg_{2}, ..., tycon_arg_{m}, extra_arg_{m+1}, ..., extra_arg_{n}] +-- @ +-- +-- where @extra_args@ are distinct type variables. +-- +-- Examples: +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int, Bool]@, return @[Int, Bool]@. +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int]@, return @[Int, b]@. +tyConInstArgTys :: TyCon -> [Type] -> [Type] +tyConInstArgTys tycon tycon_args = chkAppend tycon_args $ map mkTyVarTy tycon_args_suffix + where + tycon_args_suffix = drop (length tycon_args) $ tyConTyVars tycon {- Note [Auxiliary binders] @@ -2733,4 +2769,56 @@ derived instances within the same module, not separated by any TH splices. (This is the case described in "Wrinkle: Reducing code duplication".) In situation (1), we can at least fall back on GHC's simplifier to pick up genAuxBinds' slack. + +Note [Filter out impossible GADT data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some stock-derivable classes will filter out impossible GADT data constructors, +to rule out problematic constructors when deriving instances. e.g. + +``` +data Foo a where + X :: Foo Int + Y :: (Bool -> Bool) -> Foo Bool +``` + +when deriving an instance on `Foo Int`, `Y` should be treated as if it didn't +exist in the first place. For instance, if we write + +``` +deriving instance Eq (Foo Int) +``` + +it should generate: + +``` +instance Eq (Foo Int) where + X == X = True +``` + +Classes that filter constructors: + +* Eq +* Ord +* Show +* Lift +* Functor +* Foldable +* Traversable + +Classes that do not filter constructors: + +* Enum: doesn't make sense for GADTs in the first place +* Bounded: only makes sense for GADTs with a single constructor +* Ix: only makes sense for GADTs with a single constructor +* Read: `Read a` returns `a` instead of consumes `a`, so filtering data + constructors would make this function _more_ partial instead of less +* Data: derived implementations of gunfold rely on a constructor-indexing + scheme that wouldn't work if certain constructors were filtered out +* Generic/Generic1: doesn't make sense for GADTs + +Classes that do not currently filter constructors may do so in the future, if +there is a valid use-case and we have requirements for how they should work. + +See #16341 and the T16341.hs test case. -} ===================================== compiler/GHC/Tc/Deriv/Infer.hs ===================================== @@ -260,9 +260,7 @@ inferConstraintsStock (DerivInstTys { dit_cls_tys = cls_tys -- substitute each type variable with its counterpart in the derived -- instance. rep_tc_args lists each of these counterpart types in -- the same order as the type variables. - all_rep_tc_args - = rep_tc_args ++ map mkTyVarTy - (drop (length rep_tc_args) rep_tc_tvs) + all_rep_tc_args = tyConInstArgTys rep_tc rep_tc_args -- Stupid constraints stupid_constraints ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -218,8 +218,9 @@ data DerivSpecMechanism -- instance, including what type constructor the last argument is -- headed by. See @Note [DerivEnv and DerivSpecMechanism]@. , dsm_stock_gen_fn :: - SrcSpan -> TyCon - -> [Type] + SrcSpan -> TyCon -- dit_rep_tc + -> [Type] -- dit_rep_tc_args + -> [Type] -- inst_tys -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]) -- ^ This function returns three things: -- @@ -424,7 +425,7 @@ instance Outputable DerivContext where -- See @Note [Deriving strategies]@ in "GHC.Tc.Deriv". data OriginativeDerivStatus = CanDeriveStock -- Stock class, can derive - (SrcSpan -> TyCon -> [Type] + (SrcSpan -> TyCon -> [Type] -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) | StockClassError SDoc -- Stock class, but can't do it | CanDeriveAnyClass -- See Note [Deriving any class] @@ -563,6 +564,7 @@ hasStockDeriving :: Class -> Maybe (SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) hasStockDeriving clas = assocMaybe gen_list (getUnique clas) @@ -571,6 +573,7 @@ hasStockDeriving clas :: [(Unique, SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))] gen_list = [ (eqClassKey, simpleM gen_Eq_binds) , (ordClassKey, simpleM gen_Ord_binds) @@ -587,25 +590,25 @@ hasStockDeriving clas , (genClassKey, generic (gen_Generic_binds Gen0)) , (gen1ClassKey, generic (gen_Generic_binds Gen1)) ] - simple gen_fn loc tc _ - = let (binds, deriv_stuff) = gen_fn loc tc + simple gen_fn loc tc tc_args _ + = let (binds, deriv_stuff) = gen_fn loc tc tc_args in return (binds, deriv_stuff, []) -- Like `simple`, but monadic. The only monadic thing that these functions -- do is allocate new Uniques, which are used for generating the names of -- auxiliary bindings. -- See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate. - simpleM gen_fn loc tc _ - = do { (binds, deriv_stuff) <- gen_fn loc tc + simpleM gen_fn loc tc tc_args _ + = do { (binds, deriv_stuff) <- gen_fn loc tc tc_args ; return (binds, deriv_stuff, []) } - read_or_show gen_fn loc tc _ + read_or_show gen_fn loc tc tc_args _ = do { fix_env <- getDataConFixityFun tc - ; let (binds, deriv_stuff) = gen_fn fix_env loc tc + ; let (binds, deriv_stuff) = gen_fn fix_env loc tc tc_args field_names = all_field_names tc ; return (binds, deriv_stuff, field_names) } - generic gen_fn _ tc inst_tys + generic gen_fn _ tc _ inst_tys = do { (binds, faminst) <- gen_fn tc inst_tys ; let field_names = all_field_names tc ; return (binds, unitBag (DerivFamInst faminst), field_names) } ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -338,13 +338,24 @@ instance Ord RdrName where ************************************************************************ -} +{- Note [LocalRdrEnv] +~~~~~~~~~~~~~~~~~~~~~ +The LocalRdrEnv is used to store local bindings (let, where, lambda, case). + +* It is keyed by OccName, because we never use it for qualified names. + +* It maps the OccName to a Name. That Name is almost always an + Internal Name, but (hackily) it can be External too for top-level + pattern bindings. See Note [bindLocalNames for an External name] + in GHC.Rename.Pat + +* We keep the current mapping (lre_env), *and* the set of all Names in + scope (lre_in_scope). Reason: see Note [Splicing Exact names] in + GHC.Rename.Env. +-} + -- | Local Reader Environment --- --- This environment is used to store local bindings --- (@let@, @where@, lambda, @case@). --- It is keyed by OccName, because we never use it for qualified names --- We keep the current mapping, *and* the set of all Names in scope --- Reason: see Note [Splicing Exact names] in "GHC.Rename.Env" +-- See Note [LocalRdrEnv] data LocalRdrEnv = LRE { lre_env :: OccEnv Name , lre_in_scope :: NameSet } @@ -364,16 +375,15 @@ emptyLocalRdrEnv = LRE { lre_env = emptyOccEnv , lre_in_scope = emptyNameSet } extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv --- The Name should be a non-top-level thing +-- See Note [LocalRdrEnv] extendLocalRdrEnv lre@(LRE { lre_env = env, lre_in_scope = ns }) name - = WARN( isExternalName name, ppr name ) - lre { lre_env = extendOccEnv env (nameOccName name) name + = lre { lre_env = extendOccEnv env (nameOccName name) name , lre_in_scope = extendNameSet ns name } extendLocalRdrEnvList :: LocalRdrEnv -> [Name] -> LocalRdrEnv +-- See Note [LocalRdrEnv] extendLocalRdrEnvList lre@(LRE { lre_env = env, lre_in_scope = ns }) names - = WARN( any isExternalName names, ppr names ) - lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] + = lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] , lre_in_scope = extendNameSetList ns names } lookupLocalRdrEnv :: LocalRdrEnv -> RdrName -> Maybe Name ===================================== ghc.mk ===================================== @@ -656,7 +656,9 @@ BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE1)) BUILD_DIRS += $(patsubst %, libraries/%, $(filter-out $(PACKAGES_STAGE1),$(PACKAGES_STAGE0))) endif +ifeq "$(BIGNUM_BACKEND)" "gmp" BUILD_DIRS += libraries/ghc-bignum/gmp +endif BUILD_DIRS += utils/haddock BUILD_DIRS += utils/haddock/doc BUILD_DIRS += compiler ===================================== libraries/base/Data/Maybe.hs ===================================== @@ -149,7 +149,7 @@ fromJust Nothing = error "Maybe.fromJust: Nothing" -- yuck fromJust (Just x) = x -- | The 'fromMaybe' function takes a default value and a 'Maybe' --- value. If the 'Maybe' is 'Nothing', it returns the default values; +-- value. If the 'Maybe' is 'Nothing', it returns the default value; -- otherwise, it returns the value contained in the 'Maybe'. -- -- ==== __Examples__ ===================================== libraries/base/GHC/IO.hs ===================================== @@ -173,7 +173,7 @@ catchException !io handler = catch io handler -- @IO Int -> (ArithException -> IO Int) -> IO Int@ then the handler may -- get run with @DivideByZero@ as an argument, or an @ErrorCall \"urk\"@ -- exception may be propagated further up. If you call it again, you --- might get a the opposite behaviour. This is ok, because 'catch' is an +-- might get the opposite behaviour. This is ok, because 'catch' is an -- 'IO' computation. -- catch :: Exception e ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -228,8 +228,8 @@ bigNatToWordList bn = go (bigNatSize# bn) -- | Convert two Word# (most-significant first) into a BigNat bigNatFromWord2# :: Word# -> Word# -> BigNat# bigNatFromWord2# 0## 0## = bigNatZero# (# #) -bigNatFromWord2# 0## n = bigNatFromWord# n -bigNatFromWord2# w1 w2 = wordArrayFromWord2# w1 w2 +bigNatFromWord2# 0## l = bigNatFromWord# l +bigNatFromWord2# h l = wordArrayFromWord2# h l -- | Convert a BigNat into a Word# bigNatToWord# :: BigNat# -> Word# ===================================== libraries/ghc-bignum/src/GHC/Num/Natural.hs ===================================== @@ -86,8 +86,8 @@ naturalFromWord# x = NS x -- | Convert two Word# (most-significant first) into a Natural naturalFromWord2# :: Word# -> Word# -> Natural naturalFromWord2# 0## 0## = naturalZero -naturalFromWord2# 0## n = NS n -naturalFromWord2# w1 w2 = NB (bigNatFromWord2# w2 w1) +naturalFromWord2# 0## l = NS l +naturalFromWord2# h l = NB (bigNatFromWord2# h l) -- | Create a Natural from a Word naturalFromWord :: Word -> Natural ===================================== libraries/ghc-bignum/src/GHC/Num/WordArray.hs ===================================== @@ -121,12 +121,14 @@ withNewWordArrayTrimedMaybe# sz act = case runRW# io of (# _, a #) -> a -- | Create a WordArray# from two Word# -- --- `byteArrayFromWord2# msw lsw = lsw:msw` +-- `wordArrayFromWord2# h l +-- where h is the most significant word +-- l is the least significant word wordArrayFromWord2# :: Word# -> Word# -> WordArray# -wordArrayFromWord2# msw lsw = +wordArrayFromWord2# h l = withNewWordArray# 2# \mwa s -> - case mwaWrite# mwa 0# lsw s of - s -> mwaWrite# mwa 1# msw s + case mwaWrite# mwa 0# l s of + s -> mwaWrite# mwa 1# h s -- | Create a WordArray# from one Word# wordArrayFromWord# :: Word# -> WordArray# ===================================== testsuite/tests/deriving/should_compile/T16341.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveLift #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE StandaloneDeriving #-} + +module T16341 where + +import Language.Haskell.TH.Syntax (Lift) + +data Foo a where + Foo1 :: Foo Int + Foo2 :: (Bool -> Bool) -> Foo Bool + +-- These instances should work whether or not `Foo2` is a constructor in +-- `Foo`, because the `Foo Int` designation precludes `Foo2` from being +-- a reachable constructor +deriving instance Show (Foo Int) +deriving instance Eq (Foo Int) +deriving instance Ord (Foo Int) +deriving instance Lift (Foo Int) + +data Bar a b where + Bar1 :: b -> Bar Int b + Bar2 :: (Bool -> Bool) -> b -> Bar Bool b + +deriving instance Functor (Bar Int) +deriving instance Foldable (Bar Int) +deriving instance Traversable (Bar Int) ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -118,6 +118,7 @@ test('T15398', normal, compile, ['']) test('T15637', normal, compile, ['']) test('T15831', normal, compile, ['']) test('T16179', normal, compile, ['']) +test('T16341', normal, compile, ['']) test('T16518', normal, compile, ['']) test('T17324', normal, compile, ['']) test('T17339', normal, compile, ===================================== testsuite/tests/numeric/should_run/T18509.hs ===================================== @@ -0,0 +1,6 @@ +import Numeric.Natural + +main :: IO () +main = do + print $ (0xFFFFFFFF0 * 0xFFFFFFFF0 :: Natural) + print $ (2 :: Natural) ^ (190 :: Int) ===================================== testsuite/tests/numeric/should_run/T18509.stdout ===================================== @@ -0,0 +1,2 @@ +4722366480670621958400 +1569275433846670190958947355801916604025588861116008628224 ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -71,3 +71,4 @@ test('T497', normal, compile_and_run, ['-O']) test('T17303', normal, compile_and_run, ['']) test('T18359', normal, compile_and_run, ['']) test('T18499', normal, compile_and_run, ['']) +test('T18509', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0c1334512fe7d51399c3d2668ca5d9d528206398...8a287593a7cf9691278d566da1a8523ccdcf612b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0c1334512fe7d51399c3d2668ca5d9d528206398...8a287593a7cf9691278d566da1a8523ccdcf612b You're receiving 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 Jul 29 06:56:08 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 29 Jul 2020 02:56:08 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: Fix typo Message-ID: <5f211d8831918_80b3f848a2ebd5c564443@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 4a1ec062 by Felix Wiemuth at 2020-07-29T02:55:58-04:00 Fix typo - - - - - 6576b14b by Brandon Chinn at 2020-07-29T02:55:59-04:00 Add regression test for #16341 - - - - - eed839ac by Brandon Chinn at 2020-07-29T02:55:59-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - ad830c27 by Brandon Chinn at 2020-07-29T02:55:59-04:00 Pass tc_args to gen_fn - - - - - 14d36e24 by Brandon Chinn at 2020-07-29T02:55:59-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - 86573c06 by Simon Peyton Jones at 2020-07-29T02:55:59-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 87826dae by Simon Peyton Jones at 2020-07-29T02:56:00-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - 2e870739 by Simon Peyton Jones at 2020-07-29T02:56:00-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 4ea13e02 by Peter Trommler at 2020-07-29T02:56:00-04:00 configure: Fix build system on ARM - - - - - f0537a5c by Sylvain Henry at 2020-07-29T02:56:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - 20 changed files: - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Types/Name/Reader.hs - libraries/base/Data/Maybe.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-bignum/src/GHC/Num/Natural.hs - libraries/ghc-bignum/src/GHC/Num/WordArray.hs - + testsuite/tests/deriving/should_compile/T16341.hs - testsuite/tests/deriving/should_compile/all.T - + testsuite/tests/numeric/should_run/T18509.hs - + testsuite/tests/numeric/should_run/T18509.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== aclocal.m4 ===================================== @@ -206,7 +206,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], ;; arm) GET_ARM_ISA() - test -z "[$]2" || eval "[$]2=\"ArchARM \$ARM_ISA \$ARM_ISA_EXT \$ARM_ABI}\"" + test -z "[$]2" || eval "[$]2=\"ArchARM \$ARM_ISA \$ARM_ISA_EXT \$ARM_ABI\"" ;; aarch64) test -z "[$]2" || eval "[$]2=ArchARM64" ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -1891,7 +1891,9 @@ substForAllCoBndrUsingLC sym sco (LC subst lc_env) tv co -- -- For the inverse operation, see 'liftCoMatch' ty_co_subst :: LiftingContext -> Role -> Type -> Coercion -ty_co_subst lc role ty +ty_co_subst !lc role ty + -- !lc: making this function strict in lc allows callers to + -- pass its two components separately, rather than boxing them = go role ty where go :: Role -> Type -> Coercion @@ -2864,9 +2866,9 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs -- need a coercion (kind_co :: old_kind ~ new_kind). -- -- The bangs here have been observed to improve performance - -- significantly in optimized builds. - let kind_co = mkSymCo $ - liftCoSubst Nominal lc (tyCoBinderType binder) + -- significantly in optimized builds; see #18502 + let !kind_co = mkSymCo $ + liftCoSubst Nominal lc (tyCoBinderType binder) !casted_xi = xi `mkCastTy` kind_co casted_co = mkCoherenceLeftCo role xi kind_co co ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -1004,7 +1004,7 @@ simplExprF1 env (App fun arg) cont , sc_hole_ty = hole' , sc_cont = cont } } _ -> - -- crucially, these are /lazy/ bindings. They will + -- Crucially, sc_hole_ty is a /lazy/ binding. It will -- be forced only if we need to run contHoleType. -- When these are forced, we might get quadratic behavior; -- this quadratic blowup could be avoided by drilling down @@ -1012,17 +1012,10 @@ simplExprF1 env (App fun arg) cont -- (instead of one-at-a-time). But in practice, we have not -- observed the quadratic behavior, so this extra entanglement -- seems not worthwhile. - -- - -- But the (exprType fun) is repeated, to push it into two - -- separate, rarely used, thunks; rather than always alloating - -- a shared thunk. Makes a small efficiency difference - let fun_ty = exprType fun - (m, _, _) = splitFunTy fun_ty - in simplExprF env fun $ ApplyToVal { sc_arg = arg, sc_env = env , sc_hole_ty = substTy env (exprType fun) - , sc_dup = NoDup, sc_cont = cont, sc_mult = m } + , sc_dup = NoDup, sc_cont = cont } simplExprF1 env expr@(Lam {}) cont = {-#SCC "simplExprF1-Lam" #-} @@ -1327,8 +1320,8 @@ rebuild env expr cont Select { sc_bndr = bndr, sc_alts = alts, sc_env = se, sc_cont = cont } -> rebuildCase (se `setInScopeFromE` env) expr bndr alts cont - StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty, sc_mult = m } - -> rebuildCall env (addValArgTo fun (m, expr) fun_ty ) cont + StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty } + -> rebuildCall env (addValArgTo fun expr fun_ty ) cont StrictBind { sc_bndr = b, sc_bndrs = bs, sc_body = body , sc_env = se, sc_cont = cont } -> do { (floats1, env') <- simplNonRecX (se `setInScopeFromE` env) b expr @@ -1420,7 +1413,7 @@ simplCast env body co0 cont0 -- co1 :: t1 ~ s1 -- co2 :: s2 ~ t2 addCoerce co cont@(ApplyToVal { sc_arg = arg, sc_env = arg_se - , sc_dup = dup, sc_cont = tail, sc_mult = m }) + , sc_dup = dup, sc_cont = tail }) | Just (co1, m_co2) <- pushCoValArg co , let new_ty = coercionRKind co1 , not (isTypeLevPoly new_ty) -- Without this check, we get a lev-poly arg @@ -1444,8 +1437,7 @@ simplCast env body co0 cont0 , sc_env = arg_se' , sc_dup = dup' , sc_cont = tail' - , sc_hole_ty = coercionLKind co - , sc_mult = m }) } } + , sc_hole_ty = coercionLKind co }) } } addCoerce co cont | isReflexiveCo co = return cont -- Having this at the end makes a huge @@ -1981,17 +1973,18 @@ rebuildCall env info (ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_c -- runRW# :: forall (r :: RuntimeRep) (o :: TYPE r). (State# RealWorld -> o) -> o -- K[ runRW# rr ty body ] --> runRW rr' ty' (\s. K[ body s ]) rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) - (ApplyToVal { sc_arg = arg, sc_env = arg_se, sc_cont = cont, sc_mult = m }) + (ApplyToVal { sc_arg = arg, sc_env = arg_se + , sc_cont = cont, sc_hole_ty = fun_ty }) | fun_id `hasKey` runRWKey , not (contIsStop cont) -- Don't fiddle around if the continuation is boring , [ TyArg {}, TyArg {} ] <- rev_args = do { s <- newId (fsLit "s") Many realWorldStatePrimTy - ; let env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] + ; let (m,_,_) = splitFunTy fun_ty + env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] ty' = contResultType cont cont' = ApplyToVal { sc_dup = Simplified, sc_arg = Var s , sc_env = env', sc_cont = cont - , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' - , sc_mult = m } + , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' } -- cont' applies to s, then K ; body' <- simplExprC env' arg cont' ; let arg' = Lam s body' @@ -2002,10 +1995,10 @@ rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) rebuildCall env fun_info (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_dup = dup_flag, sc_hole_ty = fun_ty - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Argument is already simplified | isSimplified dup_flag -- See Note [Avoid redundant simplification] - = rebuildCall env (addValArgTo fun_info (m, arg) fun_ty) cont + = rebuildCall env (addValArgTo fun_info arg fun_ty) cont -- Strict arguments | isStrictArgInfo fun_info @@ -2014,7 +2007,7 @@ rebuildCall env fun_info simplExprF (arg_se `setInScopeFromE` env) arg (StrictArg { sc_fun = fun_info, sc_fun_ty = fun_ty , sc_dup = Simplified - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Note [Shadowing] -- Lazy arguments @@ -2025,7 +2018,7 @@ rebuildCall env fun_info -- floating a demanded let. = do { arg' <- simplExprC (arg_se `setInScopeFromE` env) arg (mkLazyArgStop arg_ty (lazyArgContext fun_info)) - ; rebuildCall env (addValArgTo fun_info (m, arg') fun_ty) cont } + ; rebuildCall env (addValArgTo fun_info arg' fun_ty) cont } where arg_ty = funArgTy fun_ty @@ -2233,24 +2226,10 @@ trySeqRules in_env scrut rhs cont , as_hole_ty = res2_ty } , ValArg { as_arg = no_cast_scrut , as_dmd = seqDmd - , as_hole_ty = res3_ty - , as_mult = Many } ] - -- The multiplicity of the scrutiny above is Many because the type - -- of seq requires that its first argument is unrestricted. The - -- typing rule of case also guarantees it though. In a more - -- general world, where the first argument of seq would have - -- affine multiplicity, then we could use the multiplicity of - -- the case (held in the case binder) instead. + , as_hole_ty = res3_ty } ] rule_cont = ApplyToVal { sc_dup = NoDup, sc_arg = rhs , sc_env = in_env, sc_cont = cont - , sc_hole_ty = res4_ty, sc_mult = Many } - -- The multiplicity in sc_mult above is the - -- multiplicity of the second argument of seq. Since - -- seq's type, as it stands, imposes that its second - -- argument be unrestricted, so is - -- sc_mult. However, a more precise typing rule, - -- for seq, would be to have it be linear. In which - -- case, sc_mult should be 1. + , sc_hole_ty = res4_ty } -- Lazily evaluated, so we don't do most of this @@ -3304,7 +3283,7 @@ mkDupableContWithDmds env _ mkDupableContWithDmds env _ (StrictArg { sc_fun = fun, sc_cont = cont - , sc_fun_ty = fun_ty, sc_mult = m }) + , sc_fun_ty = fun_ty }) -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable | thumbsUpPlanA cont = -- Use Plan A of Note [Duplicating StrictArg] @@ -3318,18 +3297,17 @@ mkDupableContWithDmds env _ , StrictArg { sc_fun = fun { ai_args = args' } , sc_cont = cont' , sc_fun_ty = fun_ty - , sc_mult = m , sc_dup = OkToDup} ) } | otherwise = -- Use Plan B of Note [Duplicating StrictArg] -- K[ f a b <> ] --> join j x = K[ f a b x ] -- j <> - do { let arg_ty = funArgTy fun_ty - rhs_ty = contResultType cont - ; arg_bndr <- newId (fsLit "arg") m arg_ty -- ToDo: check this linearity argument + do { let rhs_ty = contResultType cont + (m,arg_ty,_) = splitFunTy fun_ty + ; arg_bndr <- newId (fsLit "arg") m arg_ty ; let env' = env `addNewInScopeIds` [arg_bndr] - ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (m, Var arg_bndr) fun_ty) cont + ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (Var arg_bndr) fun_ty) cont ; mkDupableStrictBind env' arg_bndr (wrapFloats floats join_rhs) rhs_ty } where thumbsUpPlanA (StrictArg {}) = False @@ -3349,7 +3327,7 @@ mkDupableContWithDmds env dmds mkDupableContWithDmds env dmds (ApplyToVal { sc_arg = arg, sc_dup = dup, sc_env = se - , sc_cont = cont, sc_hole_ty = hole_ty, sc_mult = mult }) + , sc_cont = cont, sc_hole_ty = hole_ty }) = -- e.g. [...hole...] (...arg...) -- ==> -- let a = ...arg... @@ -3369,7 +3347,7 @@ mkDupableContWithDmds env dmds -- has turned arg'' into a fresh variable -- See Note [StaticEnv invariant] in GHC.Core.Opt.Simplify.Utils , sc_dup = OkToDup, sc_cont = cont' - , sc_hole_ty = hole_ty, sc_mult = mult }) } + , sc_hole_ty = hole_ty }) } mkDupableContWithDmds env _ (Select { sc_bndr = case_bndr, sc_alts = alts, sc_env = se, sc_cont = cont }) @@ -3439,7 +3417,6 @@ mkDupableStrictBind env arg_bndr join_rhs res_ty , sc_fun = arg_info , sc_fun_ty = idType join_bndr , sc_cont = mkBoringStop res_ty - , sc_mult = Many -- ToDo: check this! } ) } mkDupableAlt :: Platform -> OutId ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -125,8 +125,7 @@ data SimplCont -- See Note [The hole type in ApplyToTy/Val] , sc_arg :: InExpr -- The argument, , sc_env :: StaticEnv -- see Note [StaticEnv invariant] - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | ApplyToTy -- (ApplyToTy ty K)[e] = K[ e ty ] { sc_arg_ty :: OutType -- Argument type @@ -160,8 +159,7 @@ data SimplCont , sc_fun_ty :: OutType -- Type of the function (f e1 .. en), -- presumably (arg_ty -> res_ty) -- where res_ty is expected by sc_cont - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | TickIt -- (TickIt t K)[e] = K[ tick t e ] (Tickish Id) -- Tick tickish @@ -282,8 +280,7 @@ data ArgInfo } data ArgSpec - = ValArg { as_mult :: Mult - , as_dmd :: Demand -- Demand placed on this argument + = ValArg { as_dmd :: Demand -- Demand placed on this argument , as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal , as_hole_ty :: OutType } -- Type of the function (presumably t1 -> t2) @@ -300,16 +297,15 @@ instance Outputable ArgInfo where , text "args =" <+> ppr args ]) instance Outputable ArgSpec where - ppr (ValArg { as_mult = mult, as_arg = arg }) = text "ValArg" <+> ppr mult <+> ppr arg + ppr (ValArg { as_arg = arg }) = text "ValArg" <+> ppr arg ppr (TyArg { as_arg_ty = ty }) = text "TyArg" <+> ppr ty ppr (CastBy c) = text "CastBy" <+> ppr c -addValArgTo :: ArgInfo -> (Mult, OutExpr) -> OutType -> ArgInfo -addValArgTo ai (w, arg) hole_ty +addValArgTo :: ArgInfo -> OutExpr -> OutType -> ArgInfo +addValArgTo ai arg hole_ty | ArgInfo { ai_dmds = dmd:dmds, ai_discs = _:discs, ai_rules = rules } <- ai -- Pop the top demand and and discounts off - , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty - , as_mult = w, as_dmd = dmd } + , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty, as_dmd = dmd } = ai { ai_args = arg_spec : ai_args ai , ai_dmds = dmds , ai_discs = discs @@ -345,9 +341,9 @@ pushSimplifiedArgs env (arg : args) k = case arg of TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } -> ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = rest } - ValArg { as_arg = arg, as_hole_ty = hole_ty, as_mult = w } + ValArg { as_arg = arg, as_hole_ty = hole_ty } -> ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified - , sc_hole_ty = hole_ty, sc_cont = rest, sc_mult = w } + , sc_hole_ty = hole_ty, sc_cont = rest } CastBy c -> CastIt c rest where rest = pushSimplifiedArgs env args k @@ -446,7 +442,7 @@ contHoleType (TickIt _ k) = contHoleType k contHoleType (CastIt co _) = coercionLKind co contHoleType (StrictBind { sc_bndr = b, sc_dup = dup, sc_env = se }) = perhapsSubstTy dup se (idType b) -contHoleType (StrictArg { sc_fun_ty = ty, sc_mult = _m }) = funArgTy ty +contHoleType (StrictArg { sc_fun_ty = ty }) = funArgTy ty contHoleType (ApplyToTy { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy] contHoleType (ApplyToVal { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy/Val] contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) @@ -464,12 +460,14 @@ contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) contHoleScaling :: SimplCont -> Mult contHoleScaling (Stop _ _) = One contHoleScaling (CastIt _ k) = contHoleScaling k -contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k -contHoleScaling (StrictArg { sc_mult = w, sc_cont = k }) = - w `mkMultMul` contHoleScaling k -contHoleScaling (Select { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k +contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (Select { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (StrictArg { sc_fun_ty = fun_ty, sc_cont = k }) + = w `mkMultMul` contHoleScaling k + where + (w, _, _) = splitFunTy fun_ty contHoleScaling (ApplyToTy { sc_cont = k }) = contHoleScaling k contHoleScaling (ApplyToVal { sc_cont = k }) = contHoleScaling k contHoleScaling (TickIt _ k) = contHoleScaling k ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -236,19 +236,30 @@ newPatName (LetMk is_top fix_env) rdr_name do { name <- case is_top of NotTopLevel -> newLocalBndrRn rdr_name TopLevel -> newTopSrcBinder rdr_name - ; bindLocalNames [name] $ -- Do *not* use bindLocalNameFV here - -- See Note [View pattern usage] + ; bindLocalNames [name] $ + -- Do *not* use bindLocalNameFV here; + -- see Note [View pattern usage] + -- For the TopLevel case + -- see Note [bindLocalNames for an External name] addLocalFixities fix_env [name] $ thing_inside name }) - -- Note: the bindLocalNames is somewhat suspicious - -- because it binds a top-level name as a local name. - -- however, this binding seems to work, and it only exists for - -- the duration of the patterns and the continuation; - -- then the top-level name is added to the global env - -- before going on to the RHSes (see GHC.Rename.Module). +{- Note [bindLocalNames for an External name] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In the TopLevel case, the use of bindLocalNames here is somewhat +suspicious because it binds a top-level External name in the +LocalRdrEnv. c.f. Note [LocalRdrEnv] in GHC.Types.Name.Reader. + +However, this only happens when renaming the LHS (only) of a top-level +pattern binding. Even though this only the LHS, we need to bring the +binder into scope in the pattern itself in case the binder is used in +subsequent view patterns. A bit bizarre, something like + (x, Just y <- f x) = e + +Anyway, bindLocalNames does work, and the binding only exists for the +duration of the pattern; then the top-level name is added to the +global env before going on to the RHSes (see GHC.Rename.Module). -{- Note [View pattern usage] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== compiler/GHC/Tc/Deriv.hs ===================================== @@ -2038,9 +2038,12 @@ genDerivStuff mechanism loc clas inst_tys tyvars -> gen_newtype_or_via rhs_ty -- Try a stock deriver - DerivSpecStock { dsm_stock_dit = DerivInstTys{dit_rep_tc = rep_tc} + DerivSpecStock { dsm_stock_dit = DerivInstTys + { dit_rep_tc = rep_tc + , dit_rep_tc_args = rep_tc_args + } , dsm_stock_gen_fn = gen_fn } - -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc inst_tys + -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc rep_tc_args inst_tys pure (binds, [], faminsts, field_names) -- Try DeriveAnyClass ===================================== compiler/GHC/Tc/Deriv/Functor.hs ===================================== @@ -151,10 +151,10 @@ is a similar algorithm for generating `p <$ x` (for some constant `p`): $(coreplace 'a '(tb -> tc) x) = \(y:tb[b/a]) -> $(coreplace 'a' 'tc' (x $(replace 'a 'tb y))) -} -gen_Functor_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Functor_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use fmap _ = coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag fmap_bind, emptyBag) where @@ -165,10 +165,10 @@ gen_Functor_binds loc tycon coerce_Expr] fmap_match_ctxt = mkPrefixFunRhs fmap_name -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon tycon_args = (listToBag [fmap_bind, replace_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args fmap_name = L loc fmap_RDR -- See Note [EmptyDataDecls with Functor, Foldable, and Traversable] @@ -787,10 +787,10 @@ could surprise users if they switch to other types, but Ryan Scott seems to think it's okay to do it for now. -} -gen_Foldable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Foldable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the parameter is phantom, we can use foldMap _ _ = mempty -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag foldMap_bind, emptyBag) where @@ -801,7 +801,7 @@ gen_Foldable_binds loc tycon mempty_Expr] foldMap_match_ctxt = mkPrefixFunRhs foldMap_name -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon tycon_args | null data_cons -- There's no real point producing anything but -- foldMap for a type with no constructors. = (unitBag foldMap_bind, emptyBag) @@ -809,7 +809,7 @@ gen_Foldable_binds loc tycon | otherwise = (listToBag [foldr_bind, foldMap_bind, null_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args foldr_bind = mkRdrFunBind (L loc foldable_foldr_RDR) eqns eqns = map foldr_eqn data_cons @@ -1016,10 +1016,10 @@ removes all such types from consideration. See Note [Generated code for DeriveFoldable and DeriveTraversable]. -} -gen_Traversable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Traversable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use traverse = pure . coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag traverse_bind, emptyBag) where @@ -1031,10 +1031,10 @@ gen_Traversable_binds loc tycon (nlHsApps pure_RDR [nlHsApp coerce_Expr z_Expr])] traverse_match_ctxt = mkPrefixFunRhs traverse_name -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon tycon_args = (unitBag traverse_bind, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args traverse_name = L loc traverse_RDR ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -33,7 +33,9 @@ module GHC.Tc.Deriv.Generate ( mkCoerceClassMethEqn, genAuxBinds, ordOpTbl, boxConTbl, litConTbl, - mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr + mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr, + + getPossibleDataCons, tyConInstArgTys ) where #include "HsVersions.h" @@ -212,14 +214,14 @@ for the instance decl, which it probably wasn't, so the decls produced don't get through the typechecker. -} -gen_Eq_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Eq_binds loc tycon = do +gen_Eq_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Eq_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon return (method_binds con2tag_RDR, aux_binds con2tag_RDR) where - all_cons = tyConDataCons tycon + all_cons = getPossibleDataCons tycon tycon_args (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon all_cons -- If there are ten or more (arbitrary number) nullary constructors, @@ -396,8 +398,8 @@ gtResult OrdGE = true_Expr gtResult OrdGT = true_Expr ------------ -gen_Ord_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ord_binds loc tycon = do +gen_Ord_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ord_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon @@ -432,7 +434,7 @@ gen_Ord_binds loc tycon = do -- We want *zero-based* tags, because that's what -- con2Tag returns (generated by untag_Expr)! - tycon_data_cons = tyConDataCons tycon + tycon_data_cons = getPossibleDataCons tycon tycon_args single_con_type = isSingleton tycon_data_cons (first_con : _) = tycon_data_cons (last_con : _) = reverse tycon_data_cons @@ -646,8 +648,8 @@ instance ... Enum (Foo ...) where For @enumFromTo@ and @enumFromThenTo@, we use the default methods. -} -gen_Enum_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Enum_binds loc tycon = do +gen_Enum_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Enum_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -738,8 +740,8 @@ gen_Enum_binds loc tycon = do ************************************************************************ -} -gen_Bounded_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Bounded_binds loc tycon +gen_Bounded_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Bounded_binds loc tycon _ | isEnumerationTyCon tycon = (listToBag [ min_bound_enum, max_bound_enum ], emptyBag) | otherwise @@ -825,9 +827,9 @@ we follow the scheme given in Figure~19 of the Haskell~1.2 report (p.~147). -} -gen_Ix_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ix_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ix_binds loc tycon = do +gen_Ix_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -1028,10 +1030,10 @@ These instances are also useful for Read (Either Int Emp), where we want to be able to parse (Left 3) just fine. -} -gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Read_binds get_fixity loc tycon +gen_Read_binds get_fixity loc tycon _ = (listToBag [read_prec, default_readlist, default_readlistprec], emptyBag) where ----------------------------------------------------------------------- @@ -1212,13 +1214,13 @@ Example -- the most tightly-binding operator -} -gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Show_binds get_fixity loc tycon +gen_Show_binds get_fixity loc tycon tycon_args = (unitBag shows_prec, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args shows_prec = mkFunBindEC 2 loc showsPrec_RDR id (map pats_etc data_cons) comma_space = nlHsVar showCommaSpace_RDR @@ -1385,9 +1387,10 @@ we generate gen_Data_binds :: SrcSpan -> TyCon -- For data families, this is the -- *representation* TyCon + -> [Type] -> TcM (LHsBinds GhcPs, -- The method bindings BagDerivStuff) -- Auxiliary bindings -gen_Data_binds loc rep_tc +gen_Data_binds loc rep_tc _ = do { -- See Note [Auxiliary binders] dataT_RDR <- new_dataT_rdr_name loc rep_tc ; dataC_RDRs <- traverse (new_dataC_rdr_name loc) data_cons @@ -1616,8 +1619,8 @@ Example: -} -gen_Lift_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) +gen_Lift_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Lift_binds loc tycon tycon_args = (listToBag [lift_bind, liftTyped_bind], emptyBag) where lift_bind = mkFunBindEC 1 loc lift_RDR (nlHsApp pure_Expr) (map (pats_etc mk_exp) data_cons) @@ -1626,7 +1629,7 @@ gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) mk_exp = ExpBr noExtField mk_texp = TExpBr noExtField - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args pats_etc mk_bracket data_con = ([con_pat], lift_Expr) @@ -2515,6 +2518,39 @@ newAuxBinderRdrName loc parent occ_fun = do uniq <- newUnique pure $ Exact $ mkSystemNameAt uniq (occ_fun (nameOccName parent)) loc +-- | @getPossibleDataCons tycon tycon_args@ returns the constructors of @tycon@ +-- whose return types match when checked against @tycon_args at . +-- +-- See Note [Filter out impossible GADT data constructors] +getPossibleDataCons :: TyCon -> [Type] -> [DataCon] +getPossibleDataCons tycon tycon_args = filter isPossible $ tyConDataCons tycon + where + isPossible = not . dataConCannotMatch (tyConInstArgTys tycon tycon_args) + +-- | Given a type constructor @tycon@ of arity /n/ and a list of argument types +-- @tycon_args@ of length /m/, +-- +-- @ +-- tyConInstArgTys tycon tycon_args +-- @ +-- +-- returns +-- +-- @ +-- [tycon_arg_{1}, tycon_arg_{2}, ..., tycon_arg_{m}, extra_arg_{m+1}, ..., extra_arg_{n}] +-- @ +-- +-- where @extra_args@ are distinct type variables. +-- +-- Examples: +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int, Bool]@, return @[Int, Bool]@. +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int]@, return @[Int, b]@. +tyConInstArgTys :: TyCon -> [Type] -> [Type] +tyConInstArgTys tycon tycon_args = chkAppend tycon_args $ map mkTyVarTy tycon_args_suffix + where + tycon_args_suffix = drop (length tycon_args) $ tyConTyVars tycon {- Note [Auxiliary binders] @@ -2733,4 +2769,56 @@ derived instances within the same module, not separated by any TH splices. (This is the case described in "Wrinkle: Reducing code duplication".) In situation (1), we can at least fall back on GHC's simplifier to pick up genAuxBinds' slack. + +Note [Filter out impossible GADT data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some stock-derivable classes will filter out impossible GADT data constructors, +to rule out problematic constructors when deriving instances. e.g. + +``` +data Foo a where + X :: Foo Int + Y :: (Bool -> Bool) -> Foo Bool +``` + +when deriving an instance on `Foo Int`, `Y` should be treated as if it didn't +exist in the first place. For instance, if we write + +``` +deriving instance Eq (Foo Int) +``` + +it should generate: + +``` +instance Eq (Foo Int) where + X == X = True +``` + +Classes that filter constructors: + +* Eq +* Ord +* Show +* Lift +* Functor +* Foldable +* Traversable + +Classes that do not filter constructors: + +* Enum: doesn't make sense for GADTs in the first place +* Bounded: only makes sense for GADTs with a single constructor +* Ix: only makes sense for GADTs with a single constructor +* Read: `Read a` returns `a` instead of consumes `a`, so filtering data + constructors would make this function _more_ partial instead of less +* Data: derived implementations of gunfold rely on a constructor-indexing + scheme that wouldn't work if certain constructors were filtered out +* Generic/Generic1: doesn't make sense for GADTs + +Classes that do not currently filter constructors may do so in the future, if +there is a valid use-case and we have requirements for how they should work. + +See #16341 and the T16341.hs test case. -} ===================================== compiler/GHC/Tc/Deriv/Infer.hs ===================================== @@ -260,9 +260,7 @@ inferConstraintsStock (DerivInstTys { dit_cls_tys = cls_tys -- substitute each type variable with its counterpart in the derived -- instance. rep_tc_args lists each of these counterpart types in -- the same order as the type variables. - all_rep_tc_args - = rep_tc_args ++ map mkTyVarTy - (drop (length rep_tc_args) rep_tc_tvs) + all_rep_tc_args = tyConInstArgTys rep_tc rep_tc_args -- Stupid constraints stupid_constraints ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -218,8 +218,9 @@ data DerivSpecMechanism -- instance, including what type constructor the last argument is -- headed by. See @Note [DerivEnv and DerivSpecMechanism]@. , dsm_stock_gen_fn :: - SrcSpan -> TyCon - -> [Type] + SrcSpan -> TyCon -- dit_rep_tc + -> [Type] -- dit_rep_tc_args + -> [Type] -- inst_tys -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]) -- ^ This function returns three things: -- @@ -424,7 +425,7 @@ instance Outputable DerivContext where -- See @Note [Deriving strategies]@ in "GHC.Tc.Deriv". data OriginativeDerivStatus = CanDeriveStock -- Stock class, can derive - (SrcSpan -> TyCon -> [Type] + (SrcSpan -> TyCon -> [Type] -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) | StockClassError SDoc -- Stock class, but can't do it | CanDeriveAnyClass -- See Note [Deriving any class] @@ -563,6 +564,7 @@ hasStockDeriving :: Class -> Maybe (SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) hasStockDeriving clas = assocMaybe gen_list (getUnique clas) @@ -571,6 +573,7 @@ hasStockDeriving clas :: [(Unique, SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))] gen_list = [ (eqClassKey, simpleM gen_Eq_binds) , (ordClassKey, simpleM gen_Ord_binds) @@ -587,25 +590,25 @@ hasStockDeriving clas , (genClassKey, generic (gen_Generic_binds Gen0)) , (gen1ClassKey, generic (gen_Generic_binds Gen1)) ] - simple gen_fn loc tc _ - = let (binds, deriv_stuff) = gen_fn loc tc + simple gen_fn loc tc tc_args _ + = let (binds, deriv_stuff) = gen_fn loc tc tc_args in return (binds, deriv_stuff, []) -- Like `simple`, but monadic. The only monadic thing that these functions -- do is allocate new Uniques, which are used for generating the names of -- auxiliary bindings. -- See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate. - simpleM gen_fn loc tc _ - = do { (binds, deriv_stuff) <- gen_fn loc tc + simpleM gen_fn loc tc tc_args _ + = do { (binds, deriv_stuff) <- gen_fn loc tc tc_args ; return (binds, deriv_stuff, []) } - read_or_show gen_fn loc tc _ + read_or_show gen_fn loc tc tc_args _ = do { fix_env <- getDataConFixityFun tc - ; let (binds, deriv_stuff) = gen_fn fix_env loc tc + ; let (binds, deriv_stuff) = gen_fn fix_env loc tc tc_args field_names = all_field_names tc ; return (binds, deriv_stuff, field_names) } - generic gen_fn _ tc inst_tys + generic gen_fn _ tc _ inst_tys = do { (binds, faminst) <- gen_fn tc inst_tys ; let field_names = all_field_names tc ; return (binds, unitBag (DerivFamInst faminst), field_names) } ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -338,13 +338,24 @@ instance Ord RdrName where ************************************************************************ -} +{- Note [LocalRdrEnv] +~~~~~~~~~~~~~~~~~~~~~ +The LocalRdrEnv is used to store local bindings (let, where, lambda, case). + +* It is keyed by OccName, because we never use it for qualified names. + +* It maps the OccName to a Name. That Name is almost always an + Internal Name, but (hackily) it can be External too for top-level + pattern bindings. See Note [bindLocalNames for an External name] + in GHC.Rename.Pat + +* We keep the current mapping (lre_env), *and* the set of all Names in + scope (lre_in_scope). Reason: see Note [Splicing Exact names] in + GHC.Rename.Env. +-} + -- | Local Reader Environment --- --- This environment is used to store local bindings --- (@let@, @where@, lambda, @case@). --- It is keyed by OccName, because we never use it for qualified names --- We keep the current mapping, *and* the set of all Names in scope --- Reason: see Note [Splicing Exact names] in "GHC.Rename.Env" +-- See Note [LocalRdrEnv] data LocalRdrEnv = LRE { lre_env :: OccEnv Name , lre_in_scope :: NameSet } @@ -364,16 +375,15 @@ emptyLocalRdrEnv = LRE { lre_env = emptyOccEnv , lre_in_scope = emptyNameSet } extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv --- The Name should be a non-top-level thing +-- See Note [LocalRdrEnv] extendLocalRdrEnv lre@(LRE { lre_env = env, lre_in_scope = ns }) name - = WARN( isExternalName name, ppr name ) - lre { lre_env = extendOccEnv env (nameOccName name) name + = lre { lre_env = extendOccEnv env (nameOccName name) name , lre_in_scope = extendNameSet ns name } extendLocalRdrEnvList :: LocalRdrEnv -> [Name] -> LocalRdrEnv +-- See Note [LocalRdrEnv] extendLocalRdrEnvList lre@(LRE { lre_env = env, lre_in_scope = ns }) names - = WARN( any isExternalName names, ppr names ) - lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] + = lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] , lre_in_scope = extendNameSetList ns names } lookupLocalRdrEnv :: LocalRdrEnv -> RdrName -> Maybe Name ===================================== libraries/base/Data/Maybe.hs ===================================== @@ -149,7 +149,7 @@ fromJust Nothing = error "Maybe.fromJust: Nothing" -- yuck fromJust (Just x) = x -- | The 'fromMaybe' function takes a default value and a 'Maybe' --- value. If the 'Maybe' is 'Nothing', it returns the default values; +-- value. If the 'Maybe' is 'Nothing', it returns the default value; -- otherwise, it returns the value contained in the 'Maybe'. -- -- ==== __Examples__ ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -228,8 +228,8 @@ bigNatToWordList bn = go (bigNatSize# bn) -- | Convert two Word# (most-significant first) into a BigNat bigNatFromWord2# :: Word# -> Word# -> BigNat# bigNatFromWord2# 0## 0## = bigNatZero# (# #) -bigNatFromWord2# 0## n = bigNatFromWord# n -bigNatFromWord2# w1 w2 = wordArrayFromWord2# w1 w2 +bigNatFromWord2# 0## l = bigNatFromWord# l +bigNatFromWord2# h l = wordArrayFromWord2# h l -- | Convert a BigNat into a Word# bigNatToWord# :: BigNat# -> Word# ===================================== libraries/ghc-bignum/src/GHC/Num/Natural.hs ===================================== @@ -86,8 +86,8 @@ naturalFromWord# x = NS x -- | Convert two Word# (most-significant first) into a Natural naturalFromWord2# :: Word# -> Word# -> Natural naturalFromWord2# 0## 0## = naturalZero -naturalFromWord2# 0## n = NS n -naturalFromWord2# w1 w2 = NB (bigNatFromWord2# w2 w1) +naturalFromWord2# 0## l = NS l +naturalFromWord2# h l = NB (bigNatFromWord2# h l) -- | Create a Natural from a Word naturalFromWord :: Word -> Natural ===================================== libraries/ghc-bignum/src/GHC/Num/WordArray.hs ===================================== @@ -121,12 +121,14 @@ withNewWordArrayTrimedMaybe# sz act = case runRW# io of (# _, a #) -> a -- | Create a WordArray# from two Word# -- --- `byteArrayFromWord2# msw lsw = lsw:msw` +-- `wordArrayFromWord2# h l +-- where h is the most significant word +-- l is the least significant word wordArrayFromWord2# :: Word# -> Word# -> WordArray# -wordArrayFromWord2# msw lsw = +wordArrayFromWord2# h l = withNewWordArray# 2# \mwa s -> - case mwaWrite# mwa 0# lsw s of - s -> mwaWrite# mwa 1# msw s + case mwaWrite# mwa 0# l s of + s -> mwaWrite# mwa 1# h s -- | Create a WordArray# from one Word# wordArrayFromWord# :: Word# -> WordArray# ===================================== testsuite/tests/deriving/should_compile/T16341.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveLift #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE StandaloneDeriving #-} + +module T16341 where + +import Language.Haskell.TH.Syntax (Lift) + +data Foo a where + Foo1 :: Foo Int + Foo2 :: (Bool -> Bool) -> Foo Bool + +-- These instances should work whether or not `Foo2` is a constructor in +-- `Foo`, because the `Foo Int` designation precludes `Foo2` from being +-- a reachable constructor +deriving instance Show (Foo Int) +deriving instance Eq (Foo Int) +deriving instance Ord (Foo Int) +deriving instance Lift (Foo Int) + +data Bar a b where + Bar1 :: b -> Bar Int b + Bar2 :: (Bool -> Bool) -> b -> Bar Bool b + +deriving instance Functor (Bar Int) +deriving instance Foldable (Bar Int) +deriving instance Traversable (Bar Int) ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -118,6 +118,7 @@ test('T15398', normal, compile, ['']) test('T15637', normal, compile, ['']) test('T15831', normal, compile, ['']) test('T16179', normal, compile, ['']) +test('T16341', normal, compile, ['']) test('T16518', normal, compile, ['']) test('T17324', normal, compile, ['']) test('T17339', normal, compile, ===================================== testsuite/tests/numeric/should_run/T18509.hs ===================================== @@ -0,0 +1,6 @@ +import Numeric.Natural + +main :: IO () +main = do + print $ (0xFFFFFFFF0 * 0xFFFFFFFF0 :: Natural) + print $ (2 :: Natural) ^ (190 :: Int) ===================================== testsuite/tests/numeric/should_run/T18509.stdout ===================================== @@ -0,0 +1,2 @@ +4722366480670621958400 +1569275433846670190958947355801916604025588861116008628224 ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -71,3 +71,4 @@ test('T497', normal, compile_and_run, ['-O']) test('T17303', normal, compile_and_run, ['']) test('T18359', normal, compile_and_run, ['']) test('T18499', normal, compile_and_run, ['']) +test('T18509', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a287593a7cf9691278d566da1a8523ccdcf612b...f0537a5cfb2cd8078109a64d1c866433974b391c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a287593a7cf9691278d566da1a8523ccdcf612b...f0537a5cfb2cd8078109a64d1c866433974b391c You're receiving 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 Jul 29 07:17:30 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Wed, 29 Jul 2020 03:17:30 -0400 Subject: [Git][ghc/ghc][wip/spj-wibbles] 3 commits: Fix typo in haddock Message-ID: <5f21228a613d_80b3f849a26545456553e7@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/spj-wibbles at Glasgow Haskell Compiler / GHC Commits: 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 4f7cb81b by Simon Peyton Jones at 2020-07-29T08:17:12+01:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 4 changed files: - compiler/GHC/Rename/Pat.hs - compiler/GHC/Types/Name/Reader.hs - ghc.mk - libraries/base/GHC/IO.hs Changes: ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -236,19 +236,30 @@ newPatName (LetMk is_top fix_env) rdr_name do { name <- case is_top of NotTopLevel -> newLocalBndrRn rdr_name TopLevel -> newTopSrcBinder rdr_name - ; bindLocalNames [name] $ -- Do *not* use bindLocalNameFV here - -- See Note [View pattern usage] + ; bindLocalNames [name] $ + -- Do *not* use bindLocalNameFV here; + -- see Note [View pattern usage] + -- For the TopLevel case + -- see Note [bindLocalNames for an External name] addLocalFixities fix_env [name] $ thing_inside name }) - -- Note: the bindLocalNames is somewhat suspicious - -- because it binds a top-level name as a local name. - -- however, this binding seems to work, and it only exists for - -- the duration of the patterns and the continuation; - -- then the top-level name is added to the global env - -- before going on to the RHSes (see GHC.Rename.Module). +{- Note [bindLocalNames for an External name] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In the TopLevel case, the use of bindLocalNames here is somewhat +suspicious because it binds a top-level External name in the +LocalRdrEnv. c.f. Note [LocalRdrEnv] in GHC.Types.Name.Reader. + +However, this only happens when renaming the LHS (only) of a top-level +pattern binding. Even though this only the LHS, we need to bring the +binder into scope in the pattern itself in case the binder is used in +subsequent view patterns. A bit bizarre, something like + (x, Just y <- f x) = e + +Anyway, bindLocalNames does work, and the binding only exists for the +duration of the pattern; then the top-level name is added to the +global env before going on to the RHSes (see GHC.Rename.Module). -{- Note [View pattern usage] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -338,13 +338,24 @@ instance Ord RdrName where ************************************************************************ -} +{- Note [LocalRdrEnv] +~~~~~~~~~~~~~~~~~~~~~ +The LocalRdrEnv is used to store local bindings (let, where, lambda, case). + +* It is keyed by OccName, because we never use it for qualified names. + +* It maps the OccName to a Name. That Name is almost always an + Internal Name, but (hackily) it can be External too for top-level + pattern bindings. See Note [bindLocalNames for an External name] + in GHC.Rename.Pat + +* We keep the current mapping (lre_env), *and* the set of all Names in + scope (lre_in_scope). Reason: see Note [Splicing Exact names] in + GHC.Rename.Env. +-} + -- | Local Reader Environment --- --- This environment is used to store local bindings --- (@let@, @where@, lambda, @case@). --- It is keyed by OccName, because we never use it for qualified names --- We keep the current mapping, *and* the set of all Names in scope --- Reason: see Note [Splicing Exact names] in "GHC.Rename.Env" +-- See Note [LocalRdrEnv] data LocalRdrEnv = LRE { lre_env :: OccEnv Name , lre_in_scope :: NameSet } @@ -364,16 +375,15 @@ emptyLocalRdrEnv = LRE { lre_env = emptyOccEnv , lre_in_scope = emptyNameSet } extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv --- The Name should be a non-top-level thing +-- See Note [LocalRdrEnv] extendLocalRdrEnv lre@(LRE { lre_env = env, lre_in_scope = ns }) name - = WARN( isExternalName name, ppr name ) - lre { lre_env = extendOccEnv env (nameOccName name) name + = lre { lre_env = extendOccEnv env (nameOccName name) name , lre_in_scope = extendNameSet ns name } extendLocalRdrEnvList :: LocalRdrEnv -> [Name] -> LocalRdrEnv +-- See Note [LocalRdrEnv] extendLocalRdrEnvList lre@(LRE { lre_env = env, lre_in_scope = ns }) names - = WARN( any isExternalName names, ppr names ) - lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] + = lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] , lre_in_scope = extendNameSetList ns names } lookupLocalRdrEnv :: LocalRdrEnv -> RdrName -> Maybe Name ===================================== ghc.mk ===================================== @@ -656,7 +656,9 @@ BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE1)) BUILD_DIRS += $(patsubst %, libraries/%, $(filter-out $(PACKAGES_STAGE1),$(PACKAGES_STAGE0))) endif +ifeq "$(BIGNUM_BACKEND)" "gmp" BUILD_DIRS += libraries/ghc-bignum/gmp +endif BUILD_DIRS += utils/haddock BUILD_DIRS += utils/haddock/doc BUILD_DIRS += compiler ===================================== libraries/base/GHC/IO.hs ===================================== @@ -173,7 +173,7 @@ catchException !io handler = catch io handler -- @IO Int -> (ArithException -> IO Int) -> IO Int@ then the handler may -- get run with @DivideByZero@ as an argument, or an @ErrorCall \"urk\"@ -- exception may be propagated further up. If you call it again, you --- might get a the opposite behaviour. This is ok, because 'catch' is an +-- might get the opposite behaviour. This is ok, because 'catch' is an -- 'IO' computation. -- catch :: Exception e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aecd7ed0a6c5e5640fb68b7bde505c2114db37ac...4f7cb81ba6c3e80245bec256eeb1bbbc82a9a74c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aecd7ed0a6c5e5640fb68b7bde505c2114db37ac...4f7cb81ba6c3e80245bec256eeb1bbbc82a9a74c You're receiving 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 Jul 29 07:20:20 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Wed, 29 Jul 2020 03:20:20 -0400 Subject: [Git][ghc/ghc][wip/T18494] 3 commits: Fix typo in haddock Message-ID: <5f212334cc970_80b3f848a2ebd5c56574b7@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18494 at Glasgow Haskell Compiler / GHC Commits: 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 958310ce by Simon Peyton Jones at 2020-07-29T08:20:00+01:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - 4 changed files: - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - ghc.mk - libraries/base/GHC/IO.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -1004,7 +1004,7 @@ simplExprF1 env (App fun arg) cont , sc_hole_ty = hole' , sc_cont = cont } } _ -> - -- crucially, these are /lazy/ bindings. They will + -- Crucially, sc_hole_ty is a /lazy/ binding. It will -- be forced only if we need to run contHoleType. -- When these are forced, we might get quadratic behavior; -- this quadratic blowup could be avoided by drilling down @@ -1012,17 +1012,10 @@ simplExprF1 env (App fun arg) cont -- (instead of one-at-a-time). But in practice, we have not -- observed the quadratic behavior, so this extra entanglement -- seems not worthwhile. - -- - -- But the (exprType fun) is repeated, to push it into two - -- separate, rarely used, thunks; rather than always alloating - -- a shared thunk. Makes a small efficiency difference - let fun_ty = exprType fun - (m, _, _) = splitFunTy fun_ty - in simplExprF env fun $ ApplyToVal { sc_arg = arg, sc_env = env , sc_hole_ty = substTy env (exprType fun) - , sc_dup = NoDup, sc_cont = cont, sc_mult = m } + , sc_dup = NoDup, sc_cont = cont } simplExprF1 env expr@(Lam {}) cont = {-#SCC "simplExprF1-Lam" #-} @@ -1327,8 +1320,8 @@ rebuild env expr cont Select { sc_bndr = bndr, sc_alts = alts, sc_env = se, sc_cont = cont } -> rebuildCase (se `setInScopeFromE` env) expr bndr alts cont - StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty, sc_mult = m } - -> rebuildCall env (addValArgTo fun (m, expr) fun_ty ) cont + StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty } + -> rebuildCall env (addValArgTo fun expr fun_ty ) cont StrictBind { sc_bndr = b, sc_bndrs = bs, sc_body = body , sc_env = se, sc_cont = cont } -> do { (floats1, env') <- simplNonRecX (se `setInScopeFromE` env) b expr @@ -1420,7 +1413,7 @@ simplCast env body co0 cont0 -- co1 :: t1 ~ s1 -- co2 :: s2 ~ t2 addCoerce co cont@(ApplyToVal { sc_arg = arg, sc_env = arg_se - , sc_dup = dup, sc_cont = tail, sc_mult = m }) + , sc_dup = dup, sc_cont = tail }) | Just (co1, m_co2) <- pushCoValArg co , let new_ty = coercionRKind co1 , not (isTypeLevPoly new_ty) -- Without this check, we get a lev-poly arg @@ -1444,8 +1437,7 @@ simplCast env body co0 cont0 , sc_env = arg_se' , sc_dup = dup' , sc_cont = tail' - , sc_hole_ty = coercionLKind co - , sc_mult = m }) } } + , sc_hole_ty = coercionLKind co }) } } addCoerce co cont | isReflexiveCo co = return cont -- Having this at the end makes a huge @@ -1981,17 +1973,18 @@ rebuildCall env info (ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_c -- runRW# :: forall (r :: RuntimeRep) (o :: TYPE r). (State# RealWorld -> o) -> o -- K[ runRW# rr ty body ] --> runRW rr' ty' (\s. K[ body s ]) rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) - (ApplyToVal { sc_arg = arg, sc_env = arg_se, sc_cont = cont, sc_mult = m }) + (ApplyToVal { sc_arg = arg, sc_env = arg_se + , sc_cont = cont, sc_hole_ty = fun_ty }) | fun_id `hasKey` runRWKey , not (contIsStop cont) -- Don't fiddle around if the continuation is boring , [ TyArg {}, TyArg {} ] <- rev_args = do { s <- newId (fsLit "s") Many realWorldStatePrimTy - ; let env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] + ; let (m,_,_) = splitFunTy fun_ty + env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] ty' = contResultType cont cont' = ApplyToVal { sc_dup = Simplified, sc_arg = Var s , sc_env = env', sc_cont = cont - , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' - , sc_mult = m } + , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' } -- cont' applies to s, then K ; body' <- simplExprC env' arg cont' ; let arg' = Lam s body' @@ -2002,10 +1995,10 @@ rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) rebuildCall env fun_info (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_dup = dup_flag, sc_hole_ty = fun_ty - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Argument is already simplified | isSimplified dup_flag -- See Note [Avoid redundant simplification] - = rebuildCall env (addValArgTo fun_info (m, arg) fun_ty) cont + = rebuildCall env (addValArgTo fun_info arg fun_ty) cont -- Strict arguments | isStrictArgInfo fun_info @@ -2014,7 +2007,7 @@ rebuildCall env fun_info simplExprF (arg_se `setInScopeFromE` env) arg (StrictArg { sc_fun = fun_info, sc_fun_ty = fun_ty , sc_dup = Simplified - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Note [Shadowing] -- Lazy arguments @@ -2025,7 +2018,7 @@ rebuildCall env fun_info -- floating a demanded let. = do { arg' <- simplExprC (arg_se `setInScopeFromE` env) arg (mkLazyArgStop arg_ty (lazyArgContext fun_info)) - ; rebuildCall env (addValArgTo fun_info (m, arg') fun_ty) cont } + ; rebuildCall env (addValArgTo fun_info arg' fun_ty) cont } where arg_ty = funArgTy fun_ty @@ -2233,24 +2226,10 @@ trySeqRules in_env scrut rhs cont , as_hole_ty = res2_ty } , ValArg { as_arg = no_cast_scrut , as_dmd = seqDmd - , as_hole_ty = res3_ty - , as_mult = Many } ] - -- The multiplicity of the scrutiny above is Many because the type - -- of seq requires that its first argument is unrestricted. The - -- typing rule of case also guarantees it though. In a more - -- general world, where the first argument of seq would have - -- affine multiplicity, then we could use the multiplicity of - -- the case (held in the case binder) instead. + , as_hole_ty = res3_ty } ] rule_cont = ApplyToVal { sc_dup = NoDup, sc_arg = rhs , sc_env = in_env, sc_cont = cont - , sc_hole_ty = res4_ty, sc_mult = Many } - -- The multiplicity in sc_mult above is the - -- multiplicity of the second argument of seq. Since - -- seq's type, as it stands, imposes that its second - -- argument be unrestricted, so is - -- sc_mult. However, a more precise typing rule, - -- for seq, would be to have it be linear. In which - -- case, sc_mult should be 1. + , sc_hole_ty = res4_ty } -- Lazily evaluated, so we don't do most of this @@ -3304,7 +3283,7 @@ mkDupableContWithDmds env _ mkDupableContWithDmds env _ (StrictArg { sc_fun = fun, sc_cont = cont - , sc_fun_ty = fun_ty, sc_mult = m }) + , sc_fun_ty = fun_ty }) -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable | thumbsUpPlanA cont = -- Use Plan A of Note [Duplicating StrictArg] @@ -3318,18 +3297,17 @@ mkDupableContWithDmds env _ , StrictArg { sc_fun = fun { ai_args = args' } , sc_cont = cont' , sc_fun_ty = fun_ty - , sc_mult = m , sc_dup = OkToDup} ) } | otherwise = -- Use Plan B of Note [Duplicating StrictArg] -- K[ f a b <> ] --> join j x = K[ f a b x ] -- j <> - do { let arg_ty = funArgTy fun_ty - rhs_ty = contResultType cont - ; arg_bndr <- newId (fsLit "arg") m arg_ty -- ToDo: check this linearity argument + do { let rhs_ty = contResultType cont + (m,arg_ty,_) = splitFunTy fun_ty + ; arg_bndr <- newId (fsLit "arg") m arg_ty ; let env' = env `addNewInScopeIds` [arg_bndr] - ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (m, Var arg_bndr) fun_ty) cont + ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (Var arg_bndr) fun_ty) cont ; mkDupableStrictBind env' arg_bndr (wrapFloats floats join_rhs) rhs_ty } where thumbsUpPlanA (StrictArg {}) = False @@ -3349,7 +3327,7 @@ mkDupableContWithDmds env dmds mkDupableContWithDmds env dmds (ApplyToVal { sc_arg = arg, sc_dup = dup, sc_env = se - , sc_cont = cont, sc_hole_ty = hole_ty, sc_mult = mult }) + , sc_cont = cont, sc_hole_ty = hole_ty }) = -- e.g. [...hole...] (...arg...) -- ==> -- let a = ...arg... @@ -3369,7 +3347,7 @@ mkDupableContWithDmds env dmds -- has turned arg'' into a fresh variable -- See Note [StaticEnv invariant] in GHC.Core.Opt.Simplify.Utils , sc_dup = OkToDup, sc_cont = cont' - , sc_hole_ty = hole_ty, sc_mult = mult }) } + , sc_hole_ty = hole_ty }) } mkDupableContWithDmds env _ (Select { sc_bndr = case_bndr, sc_alts = alts, sc_env = se, sc_cont = cont }) @@ -3439,7 +3417,6 @@ mkDupableStrictBind env arg_bndr join_rhs res_ty , sc_fun = arg_info , sc_fun_ty = idType join_bndr , sc_cont = mkBoringStop res_ty - , sc_mult = Many -- ToDo: check this! } ) } mkDupableAlt :: Platform -> OutId ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -125,8 +125,7 @@ data SimplCont -- See Note [The hole type in ApplyToTy/Val] , sc_arg :: InExpr -- The argument, , sc_env :: StaticEnv -- see Note [StaticEnv invariant] - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | ApplyToTy -- (ApplyToTy ty K)[e] = K[ e ty ] { sc_arg_ty :: OutType -- Argument type @@ -160,8 +159,7 @@ data SimplCont , sc_fun_ty :: OutType -- Type of the function (f e1 .. en), -- presumably (arg_ty -> res_ty) -- where res_ty is expected by sc_cont - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | TickIt -- (TickIt t K)[e] = K[ tick t e ] (Tickish Id) -- Tick tickish @@ -282,8 +280,7 @@ data ArgInfo } data ArgSpec - = ValArg { as_mult :: Mult - , as_dmd :: Demand -- Demand placed on this argument + = ValArg { as_dmd :: Demand -- Demand placed on this argument , as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal , as_hole_ty :: OutType } -- Type of the function (presumably t1 -> t2) @@ -300,16 +297,15 @@ instance Outputable ArgInfo where , text "args =" <+> ppr args ]) instance Outputable ArgSpec where - ppr (ValArg { as_mult = mult, as_arg = arg }) = text "ValArg" <+> ppr mult <+> ppr arg + ppr (ValArg { as_arg = arg }) = text "ValArg" <+> ppr arg ppr (TyArg { as_arg_ty = ty }) = text "TyArg" <+> ppr ty ppr (CastBy c) = text "CastBy" <+> ppr c -addValArgTo :: ArgInfo -> (Mult, OutExpr) -> OutType -> ArgInfo -addValArgTo ai (w, arg) hole_ty +addValArgTo :: ArgInfo -> OutExpr -> OutType -> ArgInfo +addValArgTo ai arg hole_ty | ArgInfo { ai_dmds = dmd:dmds, ai_discs = _:discs, ai_rules = rules } <- ai -- Pop the top demand and and discounts off - , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty - , as_mult = w, as_dmd = dmd } + , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty, as_dmd = dmd } = ai { ai_args = arg_spec : ai_args ai , ai_dmds = dmds , ai_discs = discs @@ -345,9 +341,9 @@ pushSimplifiedArgs env (arg : args) k = case arg of TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } -> ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = rest } - ValArg { as_arg = arg, as_hole_ty = hole_ty, as_mult = w } + ValArg { as_arg = arg, as_hole_ty = hole_ty } -> ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified - , sc_hole_ty = hole_ty, sc_cont = rest, sc_mult = w } + , sc_hole_ty = hole_ty, sc_cont = rest } CastBy c -> CastIt c rest where rest = pushSimplifiedArgs env args k @@ -446,7 +442,7 @@ contHoleType (TickIt _ k) = contHoleType k contHoleType (CastIt co _) = coercionLKind co contHoleType (StrictBind { sc_bndr = b, sc_dup = dup, sc_env = se }) = perhapsSubstTy dup se (idType b) -contHoleType (StrictArg { sc_fun_ty = ty, sc_mult = _m }) = funArgTy ty +contHoleType (StrictArg { sc_fun_ty = ty }) = funArgTy ty contHoleType (ApplyToTy { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy] contHoleType (ApplyToVal { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy/Val] contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) @@ -464,12 +460,14 @@ contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) contHoleScaling :: SimplCont -> Mult contHoleScaling (Stop _ _) = One contHoleScaling (CastIt _ k) = contHoleScaling k -contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k -contHoleScaling (StrictArg { sc_mult = w, sc_cont = k }) = - w `mkMultMul` contHoleScaling k -contHoleScaling (Select { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k +contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (Select { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (StrictArg { sc_fun_ty = fun_ty, sc_cont = k }) + = w `mkMultMul` contHoleScaling k + where + (w, _, _) = splitFunTy fun_ty contHoleScaling (ApplyToTy { sc_cont = k }) = contHoleScaling k contHoleScaling (ApplyToVal { sc_cont = k }) = contHoleScaling k contHoleScaling (TickIt _ k) = contHoleScaling k ===================================== ghc.mk ===================================== @@ -656,7 +656,9 @@ BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE1)) BUILD_DIRS += $(patsubst %, libraries/%, $(filter-out $(PACKAGES_STAGE1),$(PACKAGES_STAGE0))) endif +ifeq "$(BIGNUM_BACKEND)" "gmp" BUILD_DIRS += libraries/ghc-bignum/gmp +endif BUILD_DIRS += utils/haddock BUILD_DIRS += utils/haddock/doc BUILD_DIRS += compiler ===================================== libraries/base/GHC/IO.hs ===================================== @@ -173,7 +173,7 @@ catchException !io handler = catch io handler -- @IO Int -> (ArithException -> IO Int) -> IO Int@ then the handler may -- get run with @DivideByZero@ as an argument, or an @ErrorCall \"urk\"@ -- exception may be propagated further up. If you call it again, you --- might get a the opposite behaviour. This is ok, because 'catch' is an +-- might get the opposite behaviour. This is ok, because 'catch' is an -- 'IO' computation. -- catch :: Exception e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2921a6e9a9423505f1cc8785262206c5a9d9ae24...958310ceb8dacde2af1eeb7a0ee439fd240f6b7b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2921a6e9a9423505f1cc8785262206c5a9d9ae24...958310ceb8dacde2af1eeb7a0ee439fd240f6b7b You're receiving 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 Jul 29 07:21:37 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Wed, 29 Jul 2020 03:21:37 -0400 Subject: [Git][ghc/ghc][wip/T18502] 3 commits: Fix typo in haddock Message-ID: <5f21238164ec0_80b116148a4565811@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18502 at Glasgow Haskell Compiler / GHC Commits: 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 749ec85e by Simon Peyton Jones at 2020-07-29T08:21:12+01:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 3 changed files: - compiler/GHC/Core/Coercion.hs - ghc.mk - libraries/base/GHC/IO.hs Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -1891,7 +1891,9 @@ substForAllCoBndrUsingLC sym sco (LC subst lc_env) tv co -- -- For the inverse operation, see 'liftCoMatch' ty_co_subst :: LiftingContext -> Role -> Type -> Coercion -ty_co_subst lc role ty +ty_co_subst !lc role ty + -- !lc: making this function strict in lc allows callers to + -- pass its two components separately, rather than boxing them = go role ty where go :: Role -> Type -> Coercion @@ -2864,9 +2866,9 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs -- need a coercion (kind_co :: old_kind ~ new_kind). -- -- The bangs here have been observed to improve performance - -- significantly in optimized builds. - let kind_co = mkSymCo $ - liftCoSubst Nominal lc (tyCoBinderType binder) + -- significantly in optimized builds; see #18502 + let !kind_co = mkSymCo $ + liftCoSubst Nominal lc (tyCoBinderType binder) !casted_xi = xi `mkCastTy` kind_co casted_co = mkCoherenceLeftCo role xi kind_co co ===================================== ghc.mk ===================================== @@ -656,7 +656,9 @@ BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE1)) BUILD_DIRS += $(patsubst %, libraries/%, $(filter-out $(PACKAGES_STAGE1),$(PACKAGES_STAGE0))) endif +ifeq "$(BIGNUM_BACKEND)" "gmp" BUILD_DIRS += libraries/ghc-bignum/gmp +endif BUILD_DIRS += utils/haddock BUILD_DIRS += utils/haddock/doc BUILD_DIRS += compiler ===================================== libraries/base/GHC/IO.hs ===================================== @@ -173,7 +173,7 @@ catchException !io handler = catch io handler -- @IO Int -> (ArithException -> IO Int) -> IO Int@ then the handler may -- get run with @DivideByZero@ as an argument, or an @ErrorCall \"urk\"@ -- exception may be propagated further up. If you call it again, you --- might get a the opposite behaviour. This is ok, because 'catch' is an +-- might get the opposite behaviour. This is ok, because 'catch' is an -- 'IO' computation. -- catch :: Exception e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/49d8597c9da32a5b674987cdc6ee227bcb627bb2...749ec85e74b98d70ba3aeed9440482e6000169c8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/49d8597c9da32a5b674987cdc6ee227bcb627bb2...749ec85e74b98d70ba3aeed9440482e6000169c8 You're receiving 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 Jul 29 09:47:15 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Wed, 29 Jul 2020 05:47:15 -0400 Subject: [Git][ghc/ghc][wip/T18323] 12 commits: Drop 32-bit Windows support Message-ID: <5f2145a3d75ec_80b3f848a2ebd5c56668a7@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18323 at Glasgow Haskell Compiler / GHC Commits: aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 3f406c0f by Simon Peyton Jones at 2020-07-29T10:46:50+01:00 Add right-to-left rule for pattern bindings Fix #18323 by adding a few lines of code to handle non-recursive pattern bindings. see GHC.Tc.Gen.Bind Note [Special case for non-recursive pattern bindings] Alas, this confused the pattern-match overlap checker; see #18323. Note that this patch only affects pattern bindings like that for (x,y) in this program combine :: (forall a . [a] -> a) -> [forall a. a -> a] -> ((forall a . [a] -> a), [forall a. a -> a]) breaks = let (x,y) = combine head ids in x y True We need ImpredicativeTypes for those [forall a. a->a] types to be valid. And with ImpredicativeTypes the old, unprincipled "allow unification variables to unify with a polytype" story actually works quite well. So this test compiles fine (if delicatedly) with old GHCs; but not with QuickLook unless we add this patch - - - - - 30 changed files: - .gitlab-ci.yml - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/Utils/Zonk.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - docs/users_guide/8.12.1-notes.rst - ghc.mk - libraries/base/Data/Bits.hs - libraries/base/GHC/IO.hs - rts/PrimOps.cmm - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/numeric/should_run/T18499.hs - + testsuite/tests/numeric/should_run/T18499.stdout - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/perf/compiler/T10421.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/888a920ac84dc57c327abe468b336bea3065c801...3f406c0fabfc84a3044451f6fcbae4ba0d04f647 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/888a920ac84dc57c327abe468b336bea3065c801...3f406c0fabfc84a3044451f6fcbae4ba0d04f647 You're receiving 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 Jul 29 10:41:59 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Wed, 29 Jul 2020 06:41:59 -0400 Subject: [Git][ghc/ghc][wip/T18470] 72 commits: Revert "AArch32 symbols only on aarch32." Message-ID: <5f21527712cd_80b3f848c1e06f456770a6@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18470 at Glasgow Haskell Compiler / GHC Commits: 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 4f83e9ad by Ryan Scott at 2020-07-29T06:40:25-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/test-metrics.sh - CODEOWNERS - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00e09d271aa464246995633cc4cad41358db40ea...4f83e9ad76b1e7c67a440ea89f22f6fc03921b5d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00e09d271aa464246995633cc4cad41358db40ea...4f83e9ad76b1e7c67a440ea89f22f6fc03921b5d You're receiving 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 Jul 29 10:43:26 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Wed, 29 Jul 2020 06:43:26 -0400 Subject: [Git][ghc/ghc][wip/T18432-T18455] 72 commits: Revert "AArch32 symbols only on aarch32." Message-ID: <5f2152cef0394_80b3f848a2ebd5c5678756@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18432-T18455 at Glasgow Haskell Compiler / GHC Commits: 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 90cf70c7 by Ryan Scott at 2020-07-29T06:43:07-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/test-metrics.sh - CODEOWNERS - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Switch/Implement.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a939e8cf4c60b3edbe0dcc5b5d47c68d36e75ade...90cf70c73f6f07e559e98ebe369f7c6039b545d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a939e8cf4c60b3edbe0dcc5b5d47c68d36e75ade...90cf70c73f6f07e559e98ebe369f7c6039b545d6 You're receiving 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 Jul 29 11:58:09 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Wed, 29 Jul 2020 07:58:09 -0400 Subject: [Git][ghc/ghc][wip/T18432-T18455] Clean up the inferred type variable restriction Message-ID: <5f216451be6f3_80b3f848a37384c56925a2@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18432-T18455 at Glasgow Haskell Compiler / GHC Commits: 502605f7 by Ryan Scott at 2020-07-29T07:57:52-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - 14 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - + testsuite/tests/quantified-constraints/T18432.hs - testsuite/tests/quantified-constraints/all.T - testsuite/tests/typecheck/should_fail/ExplicitSpecificity4.hs → testsuite/tests/typecheck/should_compile/ExplicitSpecificity4.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T18455.hs - + testsuite/tests/typecheck/should_fail/T18455.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1628,6 +1628,12 @@ instance types, which makes things like the instance above become illegal. For the sake of consistency, we also disallow nested contexts, even though they don't have the same strange interaction with ScopedTypeVariables. +Just as we forbid nested `forall`s and contexts in normal instance +declarations, we also forbid them in SPECIALISE instance pragmas (#18455). +Unlike normal instance declarations, ScopedTypeVariables don't have any impact +on SPECIALISE instance pragmas, but we use the same validity checks for +SPECIALISE instance pragmas anyway to be consistent. + ----- -- Wrinkle: Derived instances ----- ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -43,7 +43,8 @@ import GHC.Rename.Fixity import GHC.Rename.Utils ( HsDocContext(..), mapFvRn, extendTyVarEnvFVRn , checkDupRdrNames, warnUnusedLocalBinds , checkUnusedRecordWildcard - , checkDupAndShadowedNames, bindLocalNamesFV ) + , checkDupAndShadowedNames, bindLocalNamesFV + , addNoNestedForallsContextsErr, checkInferredVars ) import GHC.Driver.Session import GHC.Unit.Module import GHC.Types.Name @@ -955,7 +956,7 @@ renameSig _ (IdSig _ x) renameSig ctxt sig@(TypeSig _ vs ty) = do { new_vs <- mapM (lookupSigOccRn ctxt sig) vs ; let doc = TypeSigCtx (ppr_sig_bndrs vs) - ; (new_ty, fvs) <- rnHsSigWcType doc Nothing ty + ; (new_ty, fvs) <- rnHsSigWcType doc ty ; return (TypeSig noExtField new_vs new_ty, fvs) } renameSig ctxt sig@(ClassOpSig _ is_deflt vs ty) @@ -963,20 +964,25 @@ renameSig ctxt sig@(ClassOpSig _ is_deflt vs ty) ; when (is_deflt && not defaultSigs_on) $ addErr (defaultSigErr sig) ; new_v <- mapM (lookupSigOccRn ctxt sig) vs - ; (new_ty, fvs) <- rnHsSigType ty_ctxt TypeLevel inf_msg ty + ; (new_ty, fvs) <- rnHsSigType ty_ctxt TypeLevel ty ; return (ClassOpSig noExtField is_deflt new_v new_ty, fvs) } where (v1:_) = vs ty_ctxt = GenericCtx (text "a class method signature for" <+> quotes (ppr v1)) - inf_msg = if is_deflt - then Just (text "A default type signature cannot contain inferred type variables") - else Nothing renameSig _ (SpecInstSig _ src ty) - = do { (new_ty, fvs) <- rnHsSigType SpecInstSigCtx TypeLevel inf_msg ty + = do { checkInferredVars doc inf_msg ty + ; (new_ty, fvs) <- rnHsSigType doc TypeLevel ty + -- Check if there are any nested `forall`s or contexts, which are + -- illegal in the type of an instance declaration (see + -- Note [No nested foralls or contexts in instance types] in + -- GHC.Hs.Type). + ; addNoNestedForallsContextsErr doc (text "SPECIALISE instance type") + (getLHsInstDeclHead new_ty) ; return (SpecInstSig noExtField src new_ty,fvs) } where + doc = SpecInstSigCtx inf_msg = Just (text "Inferred type variables are not allowed") -- {-# SPECIALISE #-} pragmas can refer to imported Ids @@ -993,7 +999,7 @@ renameSig ctxt sig@(SpecSig _ v tys inl) ty_ctxt = GenericCtx (text "a SPECIALISE signature for" <+> quotes (ppr v)) do_one (tys,fvs) ty - = do { (new_ty, fvs_ty) <- rnHsSigType ty_ctxt TypeLevel Nothing ty + = do { (new_ty, fvs_ty) <- rnHsSigType ty_ctxt TypeLevel ty ; return ( new_ty:tys, fvs_ty `plusFV` fvs) } renameSig ctxt sig@(InlineSig _ v s) @@ -1010,7 +1016,7 @@ renameSig ctxt sig@(MinimalSig _ s (L l bf)) renameSig ctxt sig@(PatSynSig _ vs ty) = do { new_vs <- mapM (lookupSigOccRn ctxt sig) vs - ; (ty', fvs) <- rnHsSigType ty_ctxt TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType ty_ctxt TypeLevel ty ; return (PatSynSig noExtField new_vs ty', fvs) } where ty_ctxt = GenericCtx (text "a pattern synonym signature for" ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -317,7 +317,7 @@ rnExpr (RecordUpd { rupd_expr = expr, rupd_flds = rbinds }) , fvExpr `plusFV` fvRbinds) } rnExpr (ExprWithTySig _ expr pty) - = do { (pty', fvTy) <- rnHsSigWcType ExprWithTySigCtx Nothing pty + = do { (pty', fvTy) <- rnHsSigWcType ExprWithTySigCtx pty ; (expr', fvExpr) <- bindSigTyVarsFV (hsWcScopedTvs pty') $ rnLExpr expr ; return (ExprWithTySig noExtField expr' pty', fvExpr `plusFV` fvTy) } ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -39,7 +39,6 @@ import GHC.Prelude import {-# SOURCE #-} GHC.Rename.Splice( rnSpliceType ) -import GHC.Core.Type import GHC.Driver.Session import GHC.Hs import GHC.Rename.Doc ( rnLHsDoc, rnMbLHsDoc ) @@ -68,7 +67,7 @@ import GHC.Data.FastString import GHC.Data.Maybe import qualified GHC.LanguageExtensions as LangExt -import Data.List ( nubBy, partition, find ) +import Data.List ( nubBy, partition ) import Control.Monad ( unless, when ) #include "HsVersions.h" @@ -124,19 +123,16 @@ data HsSigWcTypeScoping -- "GHC.Hs.Type". rnHsSigWcType :: HsDocContext - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. -> LHsSigWcType GhcPs -> RnM (LHsSigWcType GhcRn, FreeVars) -rnHsSigWcType doc inf_err (HsWC { hswc_body = HsIB { hsib_body = hs_ty }}) - = rn_hs_sig_wc_type BindUnlessForall doc inf_err hs_ty $ \nwcs imp_tvs body -> +rnHsSigWcType doc (HsWC { hswc_body = HsIB { hsib_body = hs_ty }}) + = rn_hs_sig_wc_type BindUnlessForall doc hs_ty $ \nwcs imp_tvs body -> let ib_ty = HsIB { hsib_ext = imp_tvs, hsib_body = body } wc_ty = HsWC { hswc_ext = nwcs, hswc_body = ib_ty } in pure (wc_ty, emptyFVs) rnHsPatSigType :: HsSigWcTypeScoping - -> HsDocContext -> Maybe SDoc + -> HsDocContext -> HsPatSigType GhcPs -> (HsPatSigType GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) @@ -147,10 +143,10 @@ rnHsPatSigType :: HsSigWcTypeScoping -- Wildcards are allowed -- -- See Note [Pattern signature binders and scoping] in GHC.Hs.Type -rnHsPatSigType scoping ctx inf_err sig_ty thing_inside +rnHsPatSigType scoping ctx sig_ty thing_inside = do { ty_sig_okay <- xoptM LangExt.ScopedTypeVariables ; checkErr ty_sig_okay (unexpectedPatSigTypeErr sig_ty) - ; rn_hs_sig_wc_type scoping ctx inf_err (hsPatSigType sig_ty) $ + ; rn_hs_sig_wc_type scoping ctx (hsPatSigType sig_ty) $ \nwcs imp_tvs body -> do { let sig_names = HsPSRn { hsps_nwcs = nwcs, hsps_imp_tvs = imp_tvs } sig_ty' = HsPS { hsps_ext = sig_names, hsps_body = body } @@ -158,16 +154,15 @@ rnHsPatSigType scoping ctx inf_err sig_ty thing_inside } } -- The workhorse for rnHsSigWcType and rnHsPatSigType. -rn_hs_sig_wc_type :: HsSigWcTypeScoping -> HsDocContext -> Maybe SDoc +rn_hs_sig_wc_type :: HsSigWcTypeScoping -> HsDocContext -> LHsType GhcPs -> ([Name] -- Wildcard names -> [Name] -- Implicitly bound type variable names -> LHsType GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) -rn_hs_sig_wc_type scoping ctxt inf_err hs_ty thing_inside - = do { check_inferred_vars ctxt inf_err hs_ty - ; free_vars <- filterInScopeM (extractHsTyRdrTyVars hs_ty) +rn_hs_sig_wc_type scoping ctxt hs_ty thing_inside + = do { free_vars <- filterInScopeM (extractHsTyRdrTyVars hs_ty) ; (nwc_rdrs', tv_rdrs) <- partition_nwcs free_vars ; let nwc_rdrs = nubL nwc_rdrs' ; implicit_bndrs <- case scoping of @@ -318,17 +313,13 @@ of the HsWildCardBndrs structure, and we are done. rnHsSigType :: HsDocContext -> TypeOrKind - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. -> LHsSigType GhcPs -> RnM (LHsSigType GhcRn, FreeVars) -- Used for source-language type signatures -- that cannot have wildcards -rnHsSigType ctx level inf_err (HsIB { hsib_body = hs_ty }) +rnHsSigType ctx level (HsIB { hsib_body = hs_ty }) = do { traceRn "rnHsSigType" (ppr hs_ty) ; rdr_env <- getLocalRdrEnv - ; check_inferred_vars ctx inf_err hs_ty ; vars0 <- forAllOrNothing (isLHsForAllTy hs_ty) $ filterInScope rdr_env $ extractHsTyRdrTyVars hs_ty @@ -415,26 +406,6 @@ type signature, since the type signature implicitly carries their binding sites. This is less precise, but more accurate. -} -check_inferred_vars :: HsDocContext - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. - -> LHsType GhcPs - -> RnM () -check_inferred_vars _ Nothing _ = return () -check_inferred_vars ctxt (Just msg) ty = - let bndrs = forallty_bndrs ty - in case find ((==) InferredSpec . hsTyVarBndrFlag) bndrs of - Nothing -> return () - Just _ -> addErr $ withHsDocContext ctxt msg - where - forallty_bndrs :: LHsType GhcPs -> [HsTyVarBndr Specificity GhcPs] - forallty_bndrs (L _ ty) = case ty of - HsParTy _ ty' -> forallty_bndrs ty' - HsForAllTy { hst_tele = HsForAllInvis { hsf_invis_bndrs = tvs }} - -> map unLoc tvs - _ -> [] - {- ****************************************************** * * LHsType and HsType ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -34,7 +34,8 @@ import GHC.Rename.Utils ( HsDocContext(..), mapFvRn, bindLocalNames , checkDupRdrNames, bindLocalNamesFV , checkShadowedRdrNames, warnUnusedTypePatterns , extendTyVarEnvFVRn, newLocalBndrsRn - , withHsDocContext ) + , withHsDocContext, noNestedForallsContextsErr + , addNoNestedForallsContextsErr, checkInferredVars ) import GHC.Rename.Unbound ( mkUnboundName, notInScopeErr ) import GHC.Rename.Names import GHC.Rename.Doc ( rnHsDoc, rnMbLHsDoc ) @@ -65,7 +66,6 @@ import GHC.Data.List.SetOps ( findDupsEq, removeDups, equivClasses ) import GHC.Data.Graph.Directed ( SCC, flattenSCC, flattenSCCs, Node(..) , stronglyConnCompFromEdgedVerticesUniq ) import GHC.Types.Unique.Set -import GHC.Data.Maybe ( whenIsJust ) import GHC.Data.OrdList import qualified GHC.LanguageExtensions as LangExt @@ -371,7 +371,7 @@ rnHsForeignDecl :: ForeignDecl GhcPs -> RnM (ForeignDecl GhcRn, FreeVars) rnHsForeignDecl (ForeignImport { fd_name = name, fd_sig_ty = ty, fd_fi = spec }) = do { topEnv :: HscEnv <- getTopEnv ; name' <- lookupLocatedTopBndrRn name - ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel ty -- Mark any PackageTarget style imports as coming from the current package ; let unitId = homeUnit $ hsc_dflags topEnv @@ -383,7 +383,7 @@ rnHsForeignDecl (ForeignImport { fd_name = name, fd_sig_ty = ty, fd_fi = spec }) rnHsForeignDecl (ForeignExport { fd_name = name, fd_sig_ty = ty, fd_fe = spec }) = do { name' <- lookupLocatedOccRn name - ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel ty ; return (ForeignExport { fd_e_ext = noExtField , fd_name = name', fd_sig_ty = ty' , fd_fe = spec } @@ -602,13 +602,14 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds , cid_sigs = uprags, cid_tyfam_insts = ats , cid_overlap_mode = oflag , cid_datafam_insts = adts }) - = do { (inst_ty', inst_fvs) <- rnHsSigType ctxt TypeLevel inf_err inst_ty + = do { checkInferredVars ctxt inf_err inst_ty + ; (inst_ty', inst_fvs) <- rnHsSigType ctxt TypeLevel inst_ty ; let (ktv_names, _, head_ty') = splitLHsInstDeclTy inst_ty' -- Check if there are any nested `forall`s or contexts, which are -- illegal in the type of an instance declaration (see -- Note [No nested foralls or contexts in instance types] in -- GHC.Hs.Type)... - mb_nested_msg = no_nested_foralls_contexts_err + mb_nested_msg = noNestedForallsContextsErr (text "Instance head") head_ty' -- ...then check if the instance head is actually headed by a -- class type constructor... @@ -628,17 +629,10 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds -- with an error message if there isn't one. To avoid excessive -- amounts of error messages, we will only report one of the errors -- from mb_nested_msg or eith_cls at a time. - ; cls <- case maybe eith_cls Left mb_nested_msg of - Right cls -> pure cls - Left (l, err_msg) -> do - -- The instance is malformed. We'd still like - -- to make *some* progress (rather than failing outright), so - -- we report an error and continue for as long as we can. - -- Importantly, this error should be thrown before we reach the - -- typechecker, lest we encounter different errors that are - -- hopelessly confusing (such as the one in #16114). - addErrAt l $ withHsDocContext ctxt err_msg - pure $ mkUnboundName (mkTcOccFS (fsLit "")) + ; cls <- case (mb_nested_msg, eith_cls) of + (Nothing, Right cls) -> pure cls + (Just err1, _) -> bail_out err1 + (_, Left err2) -> bail_out err2 -- Rename the bindings -- The typechecker (not the renamer) checks that all @@ -680,6 +674,15 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds ctxt = GenericCtx $ text "an instance declaration" inf_err = Just (text "Inferred type variables are not allowed") + -- The instance is malformed. We'd still like to make *some* progress + -- (rather than failing outright), so we report an error and continue for + -- as long as we can. Importantly, this error should be thrown before we + -- reach the typechecker, lest we encounter different errors that are + -- hopelessly confusing (such as the one in #16114). + bail_out (l, err_msg) = do + addErrAt l $ withHsDocContext ctxt err_msg + pure $ mkUnboundName (mkTcOccFS (fsLit "")) + rnFamInstEqn :: HsDocContext -> AssocTyFamInfo -> FreeKiTyVars @@ -1010,22 +1013,22 @@ rnSrcDerivDecl :: DerivDecl GhcPs -> RnM (DerivDecl GhcRn, FreeVars) rnSrcDerivDecl (DerivDecl _ ty mds overlap) = do { standalone_deriv_ok <- xoptM LangExt.StandaloneDeriving ; unless standalone_deriv_ok (addErr standaloneDerivErr) - ; (mds', ty', fvs) - <- rnLDerivStrategy ctxt mds $ rnHsSigWcType ctxt inf_err ty + ; checkInferredVars ctxt inf_err nowc_ty + ; (mds', ty', fvs) <- rnLDerivStrategy ctxt mds $ rnHsSigWcType ctxt ty -- Check if there are any nested `forall`s or contexts, which are -- illegal in the type of an instance declaration (see -- Note [No nested foralls or contexts in instance types] in -- GHC.Hs.Type). - ; whenIsJust (no_nested_foralls_contexts_err - (text "Standalone-derived instance head") - (getLHsInstDeclHead $ dropWildCards ty')) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext ctxt err_msg + ; addNoNestedForallsContextsErr ctxt + (text "Standalone-derived instance head") + (getLHsInstDeclHead $ dropWildCards ty') ; warnNoDerivStrat mds' loc ; return (DerivDecl noExtField ty' mds' overlap, fvs) } where ctxt = DerivDeclCtx inf_err = Just (text "Inferred type variables are not allowed") - loc = getLoc $ hsib_body $ hswc_body ty + loc = getLoc $ hsib_body nowc_ty + nowc_ty = dropWildCards ty standaloneDerivErr :: SDoc standaloneDerivErr @@ -1091,7 +1094,7 @@ bindRuleTmVars doc tyvs vars names thing_inside go ((L l (RuleBndrSig _ (L loc _) bsig)) : vars) (n : ns) thing_inside - = rnHsPatSigType bind_free_tvs doc Nothing bsig $ \ bsig' -> + = rnHsPatSigType bind_free_tvs doc bsig $ \ bsig' -> go vars ns $ \ vars' -> thing_inside (L l (RuleBndrSig noExtField (L loc n) bsig') : vars') @@ -1431,7 +1434,7 @@ rnStandaloneKindSignature tc_names (StandaloneKindSig _ v ki) ; unless standalone_ki_sig_ok $ addErr standaloneKiSigErr ; new_v <- lookupSigCtxtOccRn (TopSigCtxt tc_names) (text "standalone kind signature") v ; let doc = StandaloneKindSigCtx (ppr v) - ; (new_ki, fvs) <- rnHsSigType doc KindLevel Nothing ki + ; (new_ki, fvs) <- rnHsSigType doc KindLevel ki ; return (StandaloneKindSig noExtField new_v new_ki, fvs) } where @@ -1841,15 +1844,14 @@ rnLHsDerivingClause doc rn_clause_pred :: LHsSigType GhcPs -> RnM (LHsSigType GhcRn, FreeVars) rn_clause_pred pred_ty = do let inf_err = Just (text "Inferred type variables are not allowed") - ret@(pred_ty', _) <- rnHsSigType doc TypeLevel inf_err pred_ty + checkInferredVars doc inf_err pred_ty + ret@(pred_ty', _) <- rnHsSigType doc TypeLevel pred_ty -- Check if there are any nested `forall`s, which are illegal in a -- `deriving` clause. -- See Note [No nested foralls or contexts in instance types] -- (Wrinkle: Derived instances) in GHC.Hs.Type. - whenIsJust (no_nested_foralls_contexts_err - (text "Derived class type") - (getLHsInstDeclHead pred_ty')) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext doc err_msg + addNoNestedForallsContextsErr doc (text "Derived class type") + (getLHsInstDeclHead pred_ty') pure ret rnLDerivStrategy :: forall a. @@ -1883,7 +1885,8 @@ rnLDerivStrategy doc mds thing_inside AnyclassStrategy -> boring_case AnyclassStrategy NewtypeStrategy -> boring_case NewtypeStrategy ViaStrategy via_ty -> - do (via_ty', fvs1) <- rnHsSigType doc TypeLevel inf_err via_ty + do checkInferredVars doc inf_err via_ty + (via_ty', fvs1) <- rnHsSigType doc TypeLevel via_ty let HsIB { hsib_ext = via_imp_tvs , hsib_body = via_body } = via_ty' (via_exp_tv_bndrs, via_rho) = splitLHsForAllTyInvis_KP via_body @@ -1893,10 +1896,8 @@ rnLDerivStrategy doc mds thing_inside -- `via` type. -- See Note [No nested foralls or contexts in instance types] -- (Wrinkle: Derived instances) in GHC.Hs.Type. - whenIsJust (no_nested_foralls_contexts_err - (quotes (text "via") <+> text "type") - via_rho) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext doc err_msg + addNoNestedForallsContextsErr doc + (quotes (text "via") <+> text "type") via_rho (thing, fvs2) <- extendTyVarEnvFVRn via_tvs thing_inside pure (ViaStrategy via_ty', thing, fvs1 `plusFV` fvs2) @@ -2213,7 +2214,7 @@ rnConDecl (XConDecl (ConDeclGADTPrefixPs { con_gp_names = names, con_gp_ty = ty ; mb_doc' <- rnMbLHsDoc mb_doc ; let ctxt = ConDeclCtx new_names - ; (ty', fvs) <- rnHsSigType ctxt TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType ctxt TypeLevel ty ; linearTypes <- xopt LangExt.LinearTypes <$> getDynFlags -- Now that operator precedence has been resolved, we can split the @@ -2232,10 +2233,8 @@ rnConDecl (XConDecl (ConDeclGADTPrefixPs { con_gp_names = names, con_gp_ty = ty -- Ensure that there are no nested `forall`s or contexts, per -- Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts) -- in GHC.Hs.Type. - ; whenIsJust (no_nested_foralls_contexts_err - (text "GADT constructor type signature") - res_ty) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext ctxt err_msg + ; addNoNestedForallsContextsErr ctxt + (text "GADT constructor type signature") res_ty ; traceRn "rnConDecl (ConDeclGADTPrefixPs)" (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) @@ -2273,41 +2272,6 @@ rnConDeclDetails con doc (RecCon (L l fields)) -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn ; return (RecCon (L l new_fields), fvs) } --- | Examines a non-outermost type for @forall at s or contexts, which are assumed --- to be nested. Returns @'Just' err_msg@ if such a @forall@ or context is --- found, and returns @Nothing@ otherwise. --- --- This is currently used in two places: --- --- * In GADT constructor types (in 'rnConDecl'). --- See @Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts)@ --- in "GHC.Hs.Type". --- --- * In instance declaration types (in 'rnClsIntDecl' and 'rnSrcDerivDecl'). --- See @Note [No nested foralls or contexts in instance types]@ in --- "GHC.Hs.Type". -no_nested_foralls_contexts_err :: SDoc -> LHsType GhcRn -> Maybe (SrcSpan, SDoc) -no_nested_foralls_contexts_err what lty = - case ignoreParens lty of - L l (HsForAllTy { hst_tele = tele }) - | HsForAllVis{} <- tele - -- The only two places where this function is called correspond to - -- types of terms, so we give a slightly more descriptive error - -- message in the event that they contain visible dependent - -- quantification (currently only allowed in kinds). - -> Just (l, vcat [ text "Illegal visible, dependent quantification" <+> - text "in the type of a term" - , text "(GHC does not yet support this)" ]) - | HsForAllInvis{} <- tele - -> Just (l, nested_foralls_contexts_err) - L l (HsQualTy {}) - -> Just (l, nested_foralls_contexts_err) - _ -> Nothing - where - nested_foralls_contexts_err = - what <+> text "cannot contain nested" - <+> quotes forAllLit <> text "s or contexts" - ------------------------------------------------- -- | Brings pattern synonym names and also pattern synonym selectors ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -412,7 +412,7 @@ rnPatAndThen mk (SigPat x pat sig) ; return (SigPat x pat' sig' ) } where rnHsPatSigTypeAndThen :: HsPatSigType GhcPs -> CpsRn (HsPatSigType GhcRn) - rnHsPatSigTypeAndThen sig = CpsRn (rnHsPatSigType AlwaysBind PatCtx Nothing sig) + rnHsPatSigTypeAndThen sig = CpsRn (rnHsPatSigType AlwaysBind PatCtx sig) rnPatAndThen mk (LitPat x lit) | HsString src s <- lit ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -26,8 +26,10 @@ module GHC.Rename.Utils ( bindLocalNames, bindLocalNamesFV, - addNameClashErrRn, extendTyVarEnvFVRn + addNameClashErrRn, extendTyVarEnvFVRn, + checkInferredVars, + noNestedForallsContextsErr, addNoNestedForallsContextsErr ) where @@ -35,6 +37,7 @@ where import GHC.Prelude +import GHC.Core.Type import GHC.Hs import GHC.Types.Name.Reader import GHC.Driver.Types @@ -49,6 +52,7 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Types.Basic ( TopLevelFlag(..) ) import GHC.Data.List.SetOps ( removeDups ) +import GHC.Data.Maybe ( whenIsJust ) import GHC.Driver.Session import GHC.Data.FastString import Control.Monad @@ -176,6 +180,136 @@ checkShadowedOccs (global_env,local_env) get_loc_occ ns || xopt LangExt.RecordWildCards dflags) } is_shadowed_gre _other = return True +------------------------------------- +-- | Throw an error message if a user attempts to quantify an inferred type +-- variable in a place where specificity cannot be observed. For example, +-- @forall {a}. [a] -> [a]@ would be rejected to the inferred type variable +-- @{a}@, but @forall a. [a] -> [a]@ would be accepted. +-- See @Note [Unobservably inferred type variables]@. +checkInferredVars :: HsDocContext + -> Maybe SDoc + -- ^ The error msg if the signature is not allowed to contain + -- manually written inferred variables. + -> LHsSigType GhcPs + -> RnM () +checkInferredVars _ Nothing _ = return () +checkInferredVars ctxt (Just msg) ty = + let bndrs = forallty_bndrs (hsSigType ty) + in case find ((==) InferredSpec . hsTyVarBndrFlag) bndrs of + Nothing -> return () + Just _ -> addErr $ withHsDocContext ctxt msg + where + forallty_bndrs :: LHsType GhcPs -> [HsTyVarBndr Specificity GhcPs] + forallty_bndrs (L _ ty) = case ty of + HsParTy _ ty' -> forallty_bndrs ty' + HsForAllTy { hst_tele = HsForAllInvis { hsf_invis_bndrs = tvs }} + -> map unLoc tvs + _ -> [] + +{- +Note [Unobservably inferred type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +While GHC's parser allows the use of inferred type variables +(e.g., `forall {a}. <...>`) just about anywhere that type variable binders can +appear, there are some situations where the distinction between inferred and +specified type variables cannot be observed. For example, consider this +instance declaration: + + instance forall {a}. Eq (T a) where ... + +Making {a} inferred is pointless, as there is no way for user code to +"apply" an instance declaration in a way where the inferred/specified +distinction would make a difference. (Notably, there is no opportunity +for visible type application of an instance declaration.) Anyone who +writes such code is likely confused, so in an attempt to be helpful, +we emit an error message if a user writes code like this. The +checkInferredVars function is responsible for implementing this +restriction. + +It turns out to be somewhat cumbersome to enforce this restriction in +certain cases. Specifically: + +* Quantified constraints. In the type `f :: (forall {a}. C a) => Proxy Int`, + there is no way to observe that {a} is inferred. Nevertheless, actually + rejecting this code would be tricky, as we would need to reject + `forall {a}. <...>` as a constraint but *accept* other uses of + `forall {a}. <...>` as a type (e.g., `g :: (forall {a}. a -> a) -> b -> b`). + This is quite tedious to do in practice, so we don't bother. + +* Default method type signatures (#18432). These are tricky because inferred + type variables can appear nested, e.g., + + class C a where + m :: forall b. a -> b -> forall c. c -> c + default m :: forall b. a -> b -> forall {c}. c -> c + m _ _ = id + + Robustly checking for nested, inferred type variables ends up being a pain, + so we don't try to do this. + +For now, we simply allow inferred quantifiers to be specified here, +even though doing so is pointless. All we lose is a warning. + +Aside from the places where we already use checkInferredVars, most of +the other places where inferred vars don't make sense are in any case +already prohibited from having foralls /at all/. For example: + + instance forall a. forall {b}. Eq (Either a b) where ... + +Here the nested `forall {b}` is already prohibited. (See +Note [No nested foralls or contexts in instance types] in GHC.Hs.Type). +-} + +-- | Examines a non-outermost type for @forall at s or contexts, which are assumed +-- to be nested. For example, in the following declaration: +-- +-- @ +-- instance forall a. forall b. C (Either a b) +-- @ +-- +-- The outermost @forall a@ is fine, but the nested @forall b@ is not. We +-- invoke 'noNestedForallsContextsErr' on the type @forall b. C (Either a b)@ +-- to catch the nested @forall@ and create a suitable error message. +-- 'noNestedForallsContextsErr' returns @'Just' err_msg@ if such a @forall@ or +-- context is found, and returns @Nothing@ otherwise. +-- +-- This is currently used in the following places: +-- +-- * In GADT constructor types (in 'rnConDecl'). +-- See @Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts)@ +-- in "GHC.Hs.Type". +-- +-- * In instance declaration types (in 'rnClsIntDecl' and 'rnSrcDerivDecl' in +-- "GHC.Rename.Module" and 'renameSig' in "GHC.Rename.Bind"). +-- See @Note [No nested foralls or contexts in instance types]@ in +-- "GHC.Hs.Type". +noNestedForallsContextsErr :: SDoc -> LHsType GhcRn -> Maybe (SrcSpan, SDoc) +noNestedForallsContextsErr what lty = + case ignoreParens lty of + L l (HsForAllTy { hst_tele = tele }) + | HsForAllVis{} <- tele + -- The only two places where this function is called correspond to + -- types of terms, so we give a slightly more descriptive error + -- message in the event that they contain visible dependent + -- quantification (currently only allowed in kinds). + -> Just (l, vcat [ text "Illegal visible, dependent quantification" <+> + text "in the type of a term" + , text "(GHC does not yet support this)" ]) + | HsForAllInvis{} <- tele + -> Just (l, nested_foralls_contexts_err) + L l (HsQualTy {}) + -> Just (l, nested_foralls_contexts_err) + _ -> Nothing + where + nested_foralls_contexts_err = + what <+> text "cannot contain nested" + <+> quotes forAllLit <> text "s or contexts" + +-- | A common way to invoke 'noNestedForallsContextsErr'. +addNoNestedForallsContextsErr :: HsDocContext -> SDoc -> LHsType GhcRn -> RnM () +addNoNestedForallsContextsErr ctxt what lty = + whenIsJust (noNestedForallsContextsErr what lty) $ \(l, err_msg) -> + addErrAt l $ withHsDocContext ctxt err_msg {- ************************************************************************ ===================================== testsuite/tests/quantified-constraints/T18432.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE QuantifiedConstraints #-} +module Bug where + +import Data.Proxy + +class C a where + m :: Proxy a + +f :: (forall {a}. C a) => Proxy Int +f = m ===================================== testsuite/tests/quantified-constraints/all.T ===================================== @@ -29,3 +29,4 @@ test('T17267c', normal, compile_fail, ['']) test('T17267d', normal, compile_and_run, ['']) test('T17267e', normal, compile_fail, ['']) test('T17458', normal, compile_fail, ['']) +test('T18432', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/ExplicitSpecificity4.hs → testsuite/tests/typecheck/should_compile/ExplicitSpecificity4.hs ===================================== ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -712,6 +712,7 @@ test('T18129', expect_broken(18129), compile, ['']) test('T18185', normal, compile, ['']) test('ExplicitSpecificityA1', normal, compile, ['']) test('ExplicitSpecificityA2', normal, compile, ['']) +test('ExplicitSpecificity4', normal, compile, ['']) test('T17775-viewpats-a', normal, compile, ['']) test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_fail/T18455.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE RankNTypes #-} +module T18455 where + +class C a + +instance C (Either a b) where + {-# SPECIALISE instance forall a. forall b. C (Either a b) #-} ===================================== testsuite/tests/typecheck/should_fail/T18455.stderr ===================================== @@ -0,0 +1,4 @@ + +T18455.hs:7:37: error: + SPECIALISE instance type cannot contain nested ‘forall’s or contexts + In a SPECIALISE instance pragma ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -568,7 +568,6 @@ test('T18127a', normal, compile_fail, ['']) test('ExplicitSpecificity1', normal, compile_fail, ['']) test('ExplicitSpecificity2', normal, compile_fail, ['']) test('ExplicitSpecificity3', normal, compile_fail, ['']) -test('ExplicitSpecificity4', normal, compile_fail, ['']) test('ExplicitSpecificity5', normal, compile_fail, ['']) test('ExplicitSpecificity6', normal, compile_fail, ['']) test('ExplicitSpecificity7', normal, compile_fail, ['']) @@ -578,3 +577,4 @@ test('ExplicitSpecificity10', normal, compile_fail, ['']) test('T18357', normal, compile_fail, ['']) test('T18357a', normal, compile_fail, ['']) test('T18357b', normal, compile_fail, ['']) +test('T18455', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/502605f7ae9907a6b0b9823e8f055ae390c57b1d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/502605f7ae9907a6b0b9823e8f055ae390c57b1d You're receiving 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 Jul 29 13:06:34 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 29 Jul 2020 09:06:34 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Fix typo Message-ID: <5f21745a343c7_80b3f84901714f8571058@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8564c126 by Felix Wiemuth at 2020-07-29T09:06:20-04:00 Fix typo - - - - - ed6708c5 by Brandon Chinn at 2020-07-29T09:06:21-04:00 Add regression test for #16341 - - - - - 7c572aaf by Brandon Chinn at 2020-07-29T09:06:21-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - dbeb7ac9 by Brandon Chinn at 2020-07-29T09:06:21-04:00 Pass tc_args to gen_fn - - - - - 21758dc1 by Brandon Chinn at 2020-07-29T09:06:21-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - 52743a79 by Simon Peyton Jones at 2020-07-29T09:06:21-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - 2f8abb0b by Peter Trommler at 2020-07-29T09:06:22-04:00 configure: Fix build system on ARM - - - - - 375c5882 by Sylvain Henry at 2020-07-29T09:06:23-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - 6600e4c9 by Krzysztof Gogolewski at 2020-07-29T09:06:28-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 22 changed files: - aclocal.m4 - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Deriv/Utils.hs - libraries/base/Data/Maybe.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-bignum/src/GHC/Num/Natural.hs - libraries/ghc-bignum/src/GHC/Num/WordArray.hs - + testsuite/tests/deriving/should_compile/T16341.hs - testsuite/tests/deriving/should_compile/all.T - testsuite/tests/driver/T16318/Makefile - testsuite/tests/driver/T18125/Makefile - testsuite/tests/haddock/haddock_testsuite/Makefile - testsuite/tests/hpc/Makefile - + testsuite/tests/numeric/should_run/T18509.hs - + testsuite/tests/numeric/should_run/T18509.stdout - testsuite/tests/numeric/should_run/all.T - testsuite/tests/stage1/T2632.hs Changes: ===================================== aclocal.m4 ===================================== @@ -206,7 +206,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], ;; arm) GET_ARM_ISA() - test -z "[$]2" || eval "[$]2=\"ArchARM \$ARM_ISA \$ARM_ISA_EXT \$ARM_ABI}\"" + test -z "[$]2" || eval "[$]2=\"ArchARM \$ARM_ISA \$ARM_ISA_EXT \$ARM_ABI\"" ;; aarch64) test -z "[$]2" || eval "[$]2=ArchARM64" ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -1004,7 +1004,7 @@ simplExprF1 env (App fun arg) cont , sc_hole_ty = hole' , sc_cont = cont } } _ -> - -- crucially, these are /lazy/ bindings. They will + -- Crucially, sc_hole_ty is a /lazy/ binding. It will -- be forced only if we need to run contHoleType. -- When these are forced, we might get quadratic behavior; -- this quadratic blowup could be avoided by drilling down @@ -1012,17 +1012,10 @@ simplExprF1 env (App fun arg) cont -- (instead of one-at-a-time). But in practice, we have not -- observed the quadratic behavior, so this extra entanglement -- seems not worthwhile. - -- - -- But the (exprType fun) is repeated, to push it into two - -- separate, rarely used, thunks; rather than always alloating - -- a shared thunk. Makes a small efficiency difference - let fun_ty = exprType fun - (m, _, _) = splitFunTy fun_ty - in simplExprF env fun $ ApplyToVal { sc_arg = arg, sc_env = env , sc_hole_ty = substTy env (exprType fun) - , sc_dup = NoDup, sc_cont = cont, sc_mult = m } + , sc_dup = NoDup, sc_cont = cont } simplExprF1 env expr@(Lam {}) cont = {-#SCC "simplExprF1-Lam" #-} @@ -1327,8 +1320,8 @@ rebuild env expr cont Select { sc_bndr = bndr, sc_alts = alts, sc_env = se, sc_cont = cont } -> rebuildCase (se `setInScopeFromE` env) expr bndr alts cont - StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty, sc_mult = m } - -> rebuildCall env (addValArgTo fun (m, expr) fun_ty ) cont + StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty } + -> rebuildCall env (addValArgTo fun expr fun_ty ) cont StrictBind { sc_bndr = b, sc_bndrs = bs, sc_body = body , sc_env = se, sc_cont = cont } -> do { (floats1, env') <- simplNonRecX (se `setInScopeFromE` env) b expr @@ -1420,7 +1413,7 @@ simplCast env body co0 cont0 -- co1 :: t1 ~ s1 -- co2 :: s2 ~ t2 addCoerce co cont@(ApplyToVal { sc_arg = arg, sc_env = arg_se - , sc_dup = dup, sc_cont = tail, sc_mult = m }) + , sc_dup = dup, sc_cont = tail }) | Just (co1, m_co2) <- pushCoValArg co , let new_ty = coercionRKind co1 , not (isTypeLevPoly new_ty) -- Without this check, we get a lev-poly arg @@ -1444,8 +1437,7 @@ simplCast env body co0 cont0 , sc_env = arg_se' , sc_dup = dup' , sc_cont = tail' - , sc_hole_ty = coercionLKind co - , sc_mult = m }) } } + , sc_hole_ty = coercionLKind co }) } } addCoerce co cont | isReflexiveCo co = return cont -- Having this at the end makes a huge @@ -1981,17 +1973,18 @@ rebuildCall env info (ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_c -- runRW# :: forall (r :: RuntimeRep) (o :: TYPE r). (State# RealWorld -> o) -> o -- K[ runRW# rr ty body ] --> runRW rr' ty' (\s. K[ body s ]) rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) - (ApplyToVal { sc_arg = arg, sc_env = arg_se, sc_cont = cont, sc_mult = m }) + (ApplyToVal { sc_arg = arg, sc_env = arg_se + , sc_cont = cont, sc_hole_ty = fun_ty }) | fun_id `hasKey` runRWKey , not (contIsStop cont) -- Don't fiddle around if the continuation is boring , [ TyArg {}, TyArg {} ] <- rev_args = do { s <- newId (fsLit "s") Many realWorldStatePrimTy - ; let env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] + ; let (m,_,_) = splitFunTy fun_ty + env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] ty' = contResultType cont cont' = ApplyToVal { sc_dup = Simplified, sc_arg = Var s , sc_env = env', sc_cont = cont - , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' - , sc_mult = m } + , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' } -- cont' applies to s, then K ; body' <- simplExprC env' arg cont' ; let arg' = Lam s body' @@ -2002,10 +1995,10 @@ rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) rebuildCall env fun_info (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_dup = dup_flag, sc_hole_ty = fun_ty - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Argument is already simplified | isSimplified dup_flag -- See Note [Avoid redundant simplification] - = rebuildCall env (addValArgTo fun_info (m, arg) fun_ty) cont + = rebuildCall env (addValArgTo fun_info arg fun_ty) cont -- Strict arguments | isStrictArgInfo fun_info @@ -2014,7 +2007,7 @@ rebuildCall env fun_info simplExprF (arg_se `setInScopeFromE` env) arg (StrictArg { sc_fun = fun_info, sc_fun_ty = fun_ty , sc_dup = Simplified - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Note [Shadowing] -- Lazy arguments @@ -2025,7 +2018,7 @@ rebuildCall env fun_info -- floating a demanded let. = do { arg' <- simplExprC (arg_se `setInScopeFromE` env) arg (mkLazyArgStop arg_ty (lazyArgContext fun_info)) - ; rebuildCall env (addValArgTo fun_info (m, arg') fun_ty) cont } + ; rebuildCall env (addValArgTo fun_info arg' fun_ty) cont } where arg_ty = funArgTy fun_ty @@ -2233,24 +2226,10 @@ trySeqRules in_env scrut rhs cont , as_hole_ty = res2_ty } , ValArg { as_arg = no_cast_scrut , as_dmd = seqDmd - , as_hole_ty = res3_ty - , as_mult = Many } ] - -- The multiplicity of the scrutiny above is Many because the type - -- of seq requires that its first argument is unrestricted. The - -- typing rule of case also guarantees it though. In a more - -- general world, where the first argument of seq would have - -- affine multiplicity, then we could use the multiplicity of - -- the case (held in the case binder) instead. + , as_hole_ty = res3_ty } ] rule_cont = ApplyToVal { sc_dup = NoDup, sc_arg = rhs , sc_env = in_env, sc_cont = cont - , sc_hole_ty = res4_ty, sc_mult = Many } - -- The multiplicity in sc_mult above is the - -- multiplicity of the second argument of seq. Since - -- seq's type, as it stands, imposes that its second - -- argument be unrestricted, so is - -- sc_mult. However, a more precise typing rule, - -- for seq, would be to have it be linear. In which - -- case, sc_mult should be 1. + , sc_hole_ty = res4_ty } -- Lazily evaluated, so we don't do most of this @@ -3304,7 +3283,7 @@ mkDupableContWithDmds env _ mkDupableContWithDmds env _ (StrictArg { sc_fun = fun, sc_cont = cont - , sc_fun_ty = fun_ty, sc_mult = m }) + , sc_fun_ty = fun_ty }) -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable | thumbsUpPlanA cont = -- Use Plan A of Note [Duplicating StrictArg] @@ -3318,18 +3297,17 @@ mkDupableContWithDmds env _ , StrictArg { sc_fun = fun { ai_args = args' } , sc_cont = cont' , sc_fun_ty = fun_ty - , sc_mult = m , sc_dup = OkToDup} ) } | otherwise = -- Use Plan B of Note [Duplicating StrictArg] -- K[ f a b <> ] --> join j x = K[ f a b x ] -- j <> - do { let arg_ty = funArgTy fun_ty - rhs_ty = contResultType cont - ; arg_bndr <- newId (fsLit "arg") m arg_ty -- ToDo: check this linearity argument + do { let rhs_ty = contResultType cont + (m,arg_ty,_) = splitFunTy fun_ty + ; arg_bndr <- newId (fsLit "arg") m arg_ty ; let env' = env `addNewInScopeIds` [arg_bndr] - ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (m, Var arg_bndr) fun_ty) cont + ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (Var arg_bndr) fun_ty) cont ; mkDupableStrictBind env' arg_bndr (wrapFloats floats join_rhs) rhs_ty } where thumbsUpPlanA (StrictArg {}) = False @@ -3349,7 +3327,7 @@ mkDupableContWithDmds env dmds mkDupableContWithDmds env dmds (ApplyToVal { sc_arg = arg, sc_dup = dup, sc_env = se - , sc_cont = cont, sc_hole_ty = hole_ty, sc_mult = mult }) + , sc_cont = cont, sc_hole_ty = hole_ty }) = -- e.g. [...hole...] (...arg...) -- ==> -- let a = ...arg... @@ -3369,7 +3347,7 @@ mkDupableContWithDmds env dmds -- has turned arg'' into a fresh variable -- See Note [StaticEnv invariant] in GHC.Core.Opt.Simplify.Utils , sc_dup = OkToDup, sc_cont = cont' - , sc_hole_ty = hole_ty, sc_mult = mult }) } + , sc_hole_ty = hole_ty }) } mkDupableContWithDmds env _ (Select { sc_bndr = case_bndr, sc_alts = alts, sc_env = se, sc_cont = cont }) @@ -3439,7 +3417,6 @@ mkDupableStrictBind env arg_bndr join_rhs res_ty , sc_fun = arg_info , sc_fun_ty = idType join_bndr , sc_cont = mkBoringStop res_ty - , sc_mult = Many -- ToDo: check this! } ) } mkDupableAlt :: Platform -> OutId ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -125,8 +125,7 @@ data SimplCont -- See Note [The hole type in ApplyToTy/Val] , sc_arg :: InExpr -- The argument, , sc_env :: StaticEnv -- see Note [StaticEnv invariant] - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | ApplyToTy -- (ApplyToTy ty K)[e] = K[ e ty ] { sc_arg_ty :: OutType -- Argument type @@ -160,8 +159,7 @@ data SimplCont , sc_fun_ty :: OutType -- Type of the function (f e1 .. en), -- presumably (arg_ty -> res_ty) -- where res_ty is expected by sc_cont - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | TickIt -- (TickIt t K)[e] = K[ tick t e ] (Tickish Id) -- Tick tickish @@ -282,8 +280,7 @@ data ArgInfo } data ArgSpec - = ValArg { as_mult :: Mult - , as_dmd :: Demand -- Demand placed on this argument + = ValArg { as_dmd :: Demand -- Demand placed on this argument , as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal , as_hole_ty :: OutType } -- Type of the function (presumably t1 -> t2) @@ -300,16 +297,15 @@ instance Outputable ArgInfo where , text "args =" <+> ppr args ]) instance Outputable ArgSpec where - ppr (ValArg { as_mult = mult, as_arg = arg }) = text "ValArg" <+> ppr mult <+> ppr arg + ppr (ValArg { as_arg = arg }) = text "ValArg" <+> ppr arg ppr (TyArg { as_arg_ty = ty }) = text "TyArg" <+> ppr ty ppr (CastBy c) = text "CastBy" <+> ppr c -addValArgTo :: ArgInfo -> (Mult, OutExpr) -> OutType -> ArgInfo -addValArgTo ai (w, arg) hole_ty +addValArgTo :: ArgInfo -> OutExpr -> OutType -> ArgInfo +addValArgTo ai arg hole_ty | ArgInfo { ai_dmds = dmd:dmds, ai_discs = _:discs, ai_rules = rules } <- ai -- Pop the top demand and and discounts off - , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty - , as_mult = w, as_dmd = dmd } + , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty, as_dmd = dmd } = ai { ai_args = arg_spec : ai_args ai , ai_dmds = dmds , ai_discs = discs @@ -345,9 +341,9 @@ pushSimplifiedArgs env (arg : args) k = case arg of TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } -> ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = rest } - ValArg { as_arg = arg, as_hole_ty = hole_ty, as_mult = w } + ValArg { as_arg = arg, as_hole_ty = hole_ty } -> ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified - , sc_hole_ty = hole_ty, sc_cont = rest, sc_mult = w } + , sc_hole_ty = hole_ty, sc_cont = rest } CastBy c -> CastIt c rest where rest = pushSimplifiedArgs env args k @@ -446,7 +442,7 @@ contHoleType (TickIt _ k) = contHoleType k contHoleType (CastIt co _) = coercionLKind co contHoleType (StrictBind { sc_bndr = b, sc_dup = dup, sc_env = se }) = perhapsSubstTy dup se (idType b) -contHoleType (StrictArg { sc_fun_ty = ty, sc_mult = _m }) = funArgTy ty +contHoleType (StrictArg { sc_fun_ty = ty }) = funArgTy ty contHoleType (ApplyToTy { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy] contHoleType (ApplyToVal { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy/Val] contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) @@ -464,12 +460,14 @@ contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) contHoleScaling :: SimplCont -> Mult contHoleScaling (Stop _ _) = One contHoleScaling (CastIt _ k) = contHoleScaling k -contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k -contHoleScaling (StrictArg { sc_mult = w, sc_cont = k }) = - w `mkMultMul` contHoleScaling k -contHoleScaling (Select { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k +contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (Select { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (StrictArg { sc_fun_ty = fun_ty, sc_cont = k }) + = w `mkMultMul` contHoleScaling k + where + (w, _, _) = splitFunTy fun_ty contHoleScaling (ApplyToTy { sc_cont = k }) = contHoleScaling k contHoleScaling (ApplyToVal { sc_cont = k }) = contHoleScaling k contHoleScaling (TickIt _ k) = contHoleScaling k ===================================== compiler/GHC/Tc/Deriv.hs ===================================== @@ -2038,9 +2038,12 @@ genDerivStuff mechanism loc clas inst_tys tyvars -> gen_newtype_or_via rhs_ty -- Try a stock deriver - DerivSpecStock { dsm_stock_dit = DerivInstTys{dit_rep_tc = rep_tc} + DerivSpecStock { dsm_stock_dit = DerivInstTys + { dit_rep_tc = rep_tc + , dit_rep_tc_args = rep_tc_args + } , dsm_stock_gen_fn = gen_fn } - -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc inst_tys + -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc rep_tc_args inst_tys pure (binds, [], faminsts, field_names) -- Try DeriveAnyClass ===================================== compiler/GHC/Tc/Deriv/Functor.hs ===================================== @@ -151,10 +151,10 @@ is a similar algorithm for generating `p <$ x` (for some constant `p`): $(coreplace 'a '(tb -> tc) x) = \(y:tb[b/a]) -> $(coreplace 'a' 'tc' (x $(replace 'a 'tb y))) -} -gen_Functor_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Functor_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use fmap _ = coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag fmap_bind, emptyBag) where @@ -165,10 +165,10 @@ gen_Functor_binds loc tycon coerce_Expr] fmap_match_ctxt = mkPrefixFunRhs fmap_name -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon tycon_args = (listToBag [fmap_bind, replace_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args fmap_name = L loc fmap_RDR -- See Note [EmptyDataDecls with Functor, Foldable, and Traversable] @@ -787,10 +787,10 @@ could surprise users if they switch to other types, but Ryan Scott seems to think it's okay to do it for now. -} -gen_Foldable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Foldable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the parameter is phantom, we can use foldMap _ _ = mempty -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag foldMap_bind, emptyBag) where @@ -801,7 +801,7 @@ gen_Foldable_binds loc tycon mempty_Expr] foldMap_match_ctxt = mkPrefixFunRhs foldMap_name -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon tycon_args | null data_cons -- There's no real point producing anything but -- foldMap for a type with no constructors. = (unitBag foldMap_bind, emptyBag) @@ -809,7 +809,7 @@ gen_Foldable_binds loc tycon | otherwise = (listToBag [foldr_bind, foldMap_bind, null_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args foldr_bind = mkRdrFunBind (L loc foldable_foldr_RDR) eqns eqns = map foldr_eqn data_cons @@ -1016,10 +1016,10 @@ removes all such types from consideration. See Note [Generated code for DeriveFoldable and DeriveTraversable]. -} -gen_Traversable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Traversable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use traverse = pure . coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag traverse_bind, emptyBag) where @@ -1031,10 +1031,10 @@ gen_Traversable_binds loc tycon (nlHsApps pure_RDR [nlHsApp coerce_Expr z_Expr])] traverse_match_ctxt = mkPrefixFunRhs traverse_name -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon tycon_args = (unitBag traverse_bind, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args traverse_name = L loc traverse_RDR ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -33,7 +33,9 @@ module GHC.Tc.Deriv.Generate ( mkCoerceClassMethEqn, genAuxBinds, ordOpTbl, boxConTbl, litConTbl, - mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr + mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr, + + getPossibleDataCons, tyConInstArgTys ) where #include "HsVersions.h" @@ -212,14 +214,14 @@ for the instance decl, which it probably wasn't, so the decls produced don't get through the typechecker. -} -gen_Eq_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Eq_binds loc tycon = do +gen_Eq_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Eq_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon return (method_binds con2tag_RDR, aux_binds con2tag_RDR) where - all_cons = tyConDataCons tycon + all_cons = getPossibleDataCons tycon tycon_args (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon all_cons -- If there are ten or more (arbitrary number) nullary constructors, @@ -396,8 +398,8 @@ gtResult OrdGE = true_Expr gtResult OrdGT = true_Expr ------------ -gen_Ord_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ord_binds loc tycon = do +gen_Ord_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ord_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon @@ -432,7 +434,7 @@ gen_Ord_binds loc tycon = do -- We want *zero-based* tags, because that's what -- con2Tag returns (generated by untag_Expr)! - tycon_data_cons = tyConDataCons tycon + tycon_data_cons = getPossibleDataCons tycon tycon_args single_con_type = isSingleton tycon_data_cons (first_con : _) = tycon_data_cons (last_con : _) = reverse tycon_data_cons @@ -646,8 +648,8 @@ instance ... Enum (Foo ...) where For @enumFromTo@ and @enumFromThenTo@, we use the default methods. -} -gen_Enum_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Enum_binds loc tycon = do +gen_Enum_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Enum_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -738,8 +740,8 @@ gen_Enum_binds loc tycon = do ************************************************************************ -} -gen_Bounded_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Bounded_binds loc tycon +gen_Bounded_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Bounded_binds loc tycon _ | isEnumerationTyCon tycon = (listToBag [ min_bound_enum, max_bound_enum ], emptyBag) | otherwise @@ -825,9 +827,9 @@ we follow the scheme given in Figure~19 of the Haskell~1.2 report (p.~147). -} -gen_Ix_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ix_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ix_binds loc tycon = do +gen_Ix_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -1028,10 +1030,10 @@ These instances are also useful for Read (Either Int Emp), where we want to be able to parse (Left 3) just fine. -} -gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Read_binds get_fixity loc tycon +gen_Read_binds get_fixity loc tycon _ = (listToBag [read_prec, default_readlist, default_readlistprec], emptyBag) where ----------------------------------------------------------------------- @@ -1212,13 +1214,13 @@ Example -- the most tightly-binding operator -} -gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Show_binds get_fixity loc tycon +gen_Show_binds get_fixity loc tycon tycon_args = (unitBag shows_prec, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args shows_prec = mkFunBindEC 2 loc showsPrec_RDR id (map pats_etc data_cons) comma_space = nlHsVar showCommaSpace_RDR @@ -1385,9 +1387,10 @@ we generate gen_Data_binds :: SrcSpan -> TyCon -- For data families, this is the -- *representation* TyCon + -> [Type] -> TcM (LHsBinds GhcPs, -- The method bindings BagDerivStuff) -- Auxiliary bindings -gen_Data_binds loc rep_tc +gen_Data_binds loc rep_tc _ = do { -- See Note [Auxiliary binders] dataT_RDR <- new_dataT_rdr_name loc rep_tc ; dataC_RDRs <- traverse (new_dataC_rdr_name loc) data_cons @@ -1616,8 +1619,8 @@ Example: -} -gen_Lift_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) +gen_Lift_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Lift_binds loc tycon tycon_args = (listToBag [lift_bind, liftTyped_bind], emptyBag) where lift_bind = mkFunBindEC 1 loc lift_RDR (nlHsApp pure_Expr) (map (pats_etc mk_exp) data_cons) @@ -1626,7 +1629,7 @@ gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) mk_exp = ExpBr noExtField mk_texp = TExpBr noExtField - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args pats_etc mk_bracket data_con = ([con_pat], lift_Expr) @@ -2515,6 +2518,39 @@ newAuxBinderRdrName loc parent occ_fun = do uniq <- newUnique pure $ Exact $ mkSystemNameAt uniq (occ_fun (nameOccName parent)) loc +-- | @getPossibleDataCons tycon tycon_args@ returns the constructors of @tycon@ +-- whose return types match when checked against @tycon_args at . +-- +-- See Note [Filter out impossible GADT data constructors] +getPossibleDataCons :: TyCon -> [Type] -> [DataCon] +getPossibleDataCons tycon tycon_args = filter isPossible $ tyConDataCons tycon + where + isPossible = not . dataConCannotMatch (tyConInstArgTys tycon tycon_args) + +-- | Given a type constructor @tycon@ of arity /n/ and a list of argument types +-- @tycon_args@ of length /m/, +-- +-- @ +-- tyConInstArgTys tycon tycon_args +-- @ +-- +-- returns +-- +-- @ +-- [tycon_arg_{1}, tycon_arg_{2}, ..., tycon_arg_{m}, extra_arg_{m+1}, ..., extra_arg_{n}] +-- @ +-- +-- where @extra_args@ are distinct type variables. +-- +-- Examples: +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int, Bool]@, return @[Int, Bool]@. +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int]@, return @[Int, b]@. +tyConInstArgTys :: TyCon -> [Type] -> [Type] +tyConInstArgTys tycon tycon_args = chkAppend tycon_args $ map mkTyVarTy tycon_args_suffix + where + tycon_args_suffix = drop (length tycon_args) $ tyConTyVars tycon {- Note [Auxiliary binders] @@ -2733,4 +2769,56 @@ derived instances within the same module, not separated by any TH splices. (This is the case described in "Wrinkle: Reducing code duplication".) In situation (1), we can at least fall back on GHC's simplifier to pick up genAuxBinds' slack. + +Note [Filter out impossible GADT data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some stock-derivable classes will filter out impossible GADT data constructors, +to rule out problematic constructors when deriving instances. e.g. + +``` +data Foo a where + X :: Foo Int + Y :: (Bool -> Bool) -> Foo Bool +``` + +when deriving an instance on `Foo Int`, `Y` should be treated as if it didn't +exist in the first place. For instance, if we write + +``` +deriving instance Eq (Foo Int) +``` + +it should generate: + +``` +instance Eq (Foo Int) where + X == X = True +``` + +Classes that filter constructors: + +* Eq +* Ord +* Show +* Lift +* Functor +* Foldable +* Traversable + +Classes that do not filter constructors: + +* Enum: doesn't make sense for GADTs in the first place +* Bounded: only makes sense for GADTs with a single constructor +* Ix: only makes sense for GADTs with a single constructor +* Read: `Read a` returns `a` instead of consumes `a`, so filtering data + constructors would make this function _more_ partial instead of less +* Data: derived implementations of gunfold rely on a constructor-indexing + scheme that wouldn't work if certain constructors were filtered out +* Generic/Generic1: doesn't make sense for GADTs + +Classes that do not currently filter constructors may do so in the future, if +there is a valid use-case and we have requirements for how they should work. + +See #16341 and the T16341.hs test case. -} ===================================== compiler/GHC/Tc/Deriv/Infer.hs ===================================== @@ -260,9 +260,7 @@ inferConstraintsStock (DerivInstTys { dit_cls_tys = cls_tys -- substitute each type variable with its counterpart in the derived -- instance. rep_tc_args lists each of these counterpart types in -- the same order as the type variables. - all_rep_tc_args - = rep_tc_args ++ map mkTyVarTy - (drop (length rep_tc_args) rep_tc_tvs) + all_rep_tc_args = tyConInstArgTys rep_tc rep_tc_args -- Stupid constraints stupid_constraints ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -218,8 +218,9 @@ data DerivSpecMechanism -- instance, including what type constructor the last argument is -- headed by. See @Note [DerivEnv and DerivSpecMechanism]@. , dsm_stock_gen_fn :: - SrcSpan -> TyCon - -> [Type] + SrcSpan -> TyCon -- dit_rep_tc + -> [Type] -- dit_rep_tc_args + -> [Type] -- inst_tys -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]) -- ^ This function returns three things: -- @@ -424,7 +425,7 @@ instance Outputable DerivContext where -- See @Note [Deriving strategies]@ in "GHC.Tc.Deriv". data OriginativeDerivStatus = CanDeriveStock -- Stock class, can derive - (SrcSpan -> TyCon -> [Type] + (SrcSpan -> TyCon -> [Type] -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) | StockClassError SDoc -- Stock class, but can't do it | CanDeriveAnyClass -- See Note [Deriving any class] @@ -563,6 +564,7 @@ hasStockDeriving :: Class -> Maybe (SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) hasStockDeriving clas = assocMaybe gen_list (getUnique clas) @@ -571,6 +573,7 @@ hasStockDeriving clas :: [(Unique, SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))] gen_list = [ (eqClassKey, simpleM gen_Eq_binds) , (ordClassKey, simpleM gen_Ord_binds) @@ -587,25 +590,25 @@ hasStockDeriving clas , (genClassKey, generic (gen_Generic_binds Gen0)) , (gen1ClassKey, generic (gen_Generic_binds Gen1)) ] - simple gen_fn loc tc _ - = let (binds, deriv_stuff) = gen_fn loc tc + simple gen_fn loc tc tc_args _ + = let (binds, deriv_stuff) = gen_fn loc tc tc_args in return (binds, deriv_stuff, []) -- Like `simple`, but monadic. The only monadic thing that these functions -- do is allocate new Uniques, which are used for generating the names of -- auxiliary bindings. -- See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate. - simpleM gen_fn loc tc _ - = do { (binds, deriv_stuff) <- gen_fn loc tc + simpleM gen_fn loc tc tc_args _ + = do { (binds, deriv_stuff) <- gen_fn loc tc tc_args ; return (binds, deriv_stuff, []) } - read_or_show gen_fn loc tc _ + read_or_show gen_fn loc tc tc_args _ = do { fix_env <- getDataConFixityFun tc - ; let (binds, deriv_stuff) = gen_fn fix_env loc tc + ; let (binds, deriv_stuff) = gen_fn fix_env loc tc tc_args field_names = all_field_names tc ; return (binds, deriv_stuff, field_names) } - generic gen_fn _ tc inst_tys + generic gen_fn _ tc _ inst_tys = do { (binds, faminst) <- gen_fn tc inst_tys ; let field_names = all_field_names tc ; return (binds, unitBag (DerivFamInst faminst), field_names) } ===================================== libraries/base/Data/Maybe.hs ===================================== @@ -149,7 +149,7 @@ fromJust Nothing = error "Maybe.fromJust: Nothing" -- yuck fromJust (Just x) = x -- | The 'fromMaybe' function takes a default value and a 'Maybe' --- value. If the 'Maybe' is 'Nothing', it returns the default values; +-- value. If the 'Maybe' is 'Nothing', it returns the default value; -- otherwise, it returns the value contained in the 'Maybe'. -- -- ==== __Examples__ ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -228,8 +228,8 @@ bigNatToWordList bn = go (bigNatSize# bn) -- | Convert two Word# (most-significant first) into a BigNat bigNatFromWord2# :: Word# -> Word# -> BigNat# bigNatFromWord2# 0## 0## = bigNatZero# (# #) -bigNatFromWord2# 0## n = bigNatFromWord# n -bigNatFromWord2# w1 w2 = wordArrayFromWord2# w1 w2 +bigNatFromWord2# 0## l = bigNatFromWord# l +bigNatFromWord2# h l = wordArrayFromWord2# h l -- | Convert a BigNat into a Word# bigNatToWord# :: BigNat# -> Word# ===================================== libraries/ghc-bignum/src/GHC/Num/Natural.hs ===================================== @@ -86,8 +86,8 @@ naturalFromWord# x = NS x -- | Convert two Word# (most-significant first) into a Natural naturalFromWord2# :: Word# -> Word# -> Natural naturalFromWord2# 0## 0## = naturalZero -naturalFromWord2# 0## n = NS n -naturalFromWord2# w1 w2 = NB (bigNatFromWord2# w2 w1) +naturalFromWord2# 0## l = NS l +naturalFromWord2# h l = NB (bigNatFromWord2# h l) -- | Create a Natural from a Word naturalFromWord :: Word -> Natural ===================================== libraries/ghc-bignum/src/GHC/Num/WordArray.hs ===================================== @@ -121,12 +121,14 @@ withNewWordArrayTrimedMaybe# sz act = case runRW# io of (# _, a #) -> a -- | Create a WordArray# from two Word# -- --- `byteArrayFromWord2# msw lsw = lsw:msw` +-- `wordArrayFromWord2# h l +-- where h is the most significant word +-- l is the least significant word wordArrayFromWord2# :: Word# -> Word# -> WordArray# -wordArrayFromWord2# msw lsw = +wordArrayFromWord2# h l = withNewWordArray# 2# \mwa s -> - case mwaWrite# mwa 0# lsw s of - s -> mwaWrite# mwa 1# msw s + case mwaWrite# mwa 0# l s of + s -> mwaWrite# mwa 1# h s -- | Create a WordArray# from one Word# wordArrayFromWord# :: Word# -> WordArray# ===================================== testsuite/tests/deriving/should_compile/T16341.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveLift #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE StandaloneDeriving #-} + +module T16341 where + +import Language.Haskell.TH.Syntax (Lift) + +data Foo a where + Foo1 :: Foo Int + Foo2 :: (Bool -> Bool) -> Foo Bool + +-- These instances should work whether or not `Foo2` is a constructor in +-- `Foo`, because the `Foo Int` designation precludes `Foo2` from being +-- a reachable constructor +deriving instance Show (Foo Int) +deriving instance Eq (Foo Int) +deriving instance Ord (Foo Int) +deriving instance Lift (Foo Int) + +data Bar a b where + Bar1 :: b -> Bar Int b + Bar2 :: (Bool -> Bool) -> b -> Bar Bool b + +deriving instance Functor (Bar Int) +deriving instance Foldable (Bar Int) +deriving instance Traversable (Bar Int) ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -118,6 +118,7 @@ test('T15398', normal, compile, ['']) test('T15637', normal, compile, ['']) test('T15831', normal, compile, ['']) test('T16179', normal, compile, ['']) +test('T16341', normal, compile, ['']) test('T16518', normal, compile, ['']) test('T17324', normal, compile, ['']) test('T17339', normal, compile, ===================================== testsuite/tests/driver/T16318/Makefile ===================================== @@ -5,7 +5,7 @@ include $(TOP)/mk/test.mk test_pe = test-package-environment T16318: - $(GHC_PKG) latest base > $(test_pe) + "$(GHC_PKG)" latest base > $(test_pe) "$(TEST_HC)" $(TEST_HC_OPTS) -v1 -package-env $(test_pe) -e "putStrLn \"Hello\"" > out 2>&1 C=`cat out | grep "Loaded package environment" -c` ; \ if [ $$C != "1" ]; then false; fi ===================================== testsuite/tests/driver/T18125/Makefile ===================================== @@ -6,8 +6,8 @@ test_pe = test-package-environment test_lib = containers T18125: - $(GHC_PKG) latest base > $(test_pe) - $(GHC_PKG) latest $(test_lib) >> $(test_pe) + "$(GHC_PKG)" latest base > $(test_pe) + "$(GHC_PKG)" latest $(test_lib) >> $(test_pe) "$(TEST_HC)" $(TEST_HC_OPTS) -Wunused-packages -package-env $(test_pe) T18125.hs > out 2>&1 C=`cat out | grep "$(test_lib)" -c` ; \ if [ $$C != "1" ]; then false; fi ===================================== testsuite/tests/haddock/haddock_testsuite/Makefile ===================================== @@ -25,7 +25,7 @@ htmlTest: $(TOP)/../utils/haddock/html-test/Main.hs ./html-test \ $(ACCEPT) \ - --ghc-path=$(TEST_HC) \ + --ghc-path='$(TEST_HC)' \ --haddock-path=$(HADDOCK) \ --haddock-stdout=haddock-out.log @@ -41,7 +41,7 @@ latexTest: $(TOP)/../utils/haddock/latex-test/Main.hs ./latex-test \ $(ACCEPT) \ - --ghc-path=$(TEST_HC) \ + --ghc-path='$(TEST_HC)' \ --haddock-path=$(HADDOCK) \ --haddock-stdout=haddock-out.log @@ -57,7 +57,7 @@ hoogleTest: $(TOP)/../utils/haddock/hoogle-test/Main.hs ./hoogle-test \ $(ACCEPT) \ - --ghc-path=$(TEST_HC) \ + --ghc-path='$(TEST_HC)' \ --haddock-path=$(HADDOCK) \ --haddock-stdout=haddock-out.log @@ -73,6 +73,6 @@ hypsrcTest: $(TOP)/../utils/haddock/hypsrc-test/Main.hs ./hypsrc-test \ $(ACCEPT) \ - --ghc-path=$(TEST_HC) \ + --ghc-path='$(TEST_HC)' \ --haddock-path=$(HADDOCK) \ --haddock-stdout=haddock-out.log ===================================== testsuite/tests/hpc/Makefile ===================================== @@ -11,7 +11,7 @@ T11798: T17073: LANG=ASCII "$(TEST_HC)" $(TEST_HC_ARGS) T17073.hs -fhpc -v0 ./T17073 - $(HPC) report T17073 - $(HPC) version - LANG=ASCII $(HPC) markup T17073 + "$(HPC)" report T17073 + "$(HPC)" version + LANG=ASCII "$(HPC)" markup T17073 ===================================== testsuite/tests/numeric/should_run/T18509.hs ===================================== @@ -0,0 +1,6 @@ +import Numeric.Natural + +main :: IO () +main = do + print $ (0xFFFFFFFF0 * 0xFFFFFFFF0 :: Natural) + print $ (2 :: Natural) ^ (190 :: Int) ===================================== testsuite/tests/numeric/should_run/T18509.stdout ===================================== @@ -0,0 +1,2 @@ +4722366480670621958400 +1569275433846670190958947355801916604025588861116008628224 ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -71,3 +71,4 @@ test('T497', normal, compile_and_run, ['-O']) test('T17303', normal, compile_and_run, ['']) test('T18359', normal, compile_and_run, ['']) test('T18499', normal, compile_and_run, ['']) +test('T18509', normal, compile_and_run, ['']) ===================================== testsuite/tests/stage1/T2632.hs ===================================== @@ -7,8 +7,10 @@ import Language.Haskell.TH op :: Num v => v -> v -> v op a b = a + b +decl1 :: Q [Dec] decl1 = [d| func = 0 `op` 3 |] +decl2 :: Q [Dec] decl2 = [d| op x y = x func = 0 `op` 3 |] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f0537a5cfb2cd8078109a64d1c866433974b391c...6600e4c9d866aa11975b6e10fac490c232515aec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f0537a5cfb2cd8078109a64d1c866433974b391c...6600e4c9d866aa11975b6e10fac490c232515aec You're receiving 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 Jul 29 15:22:47 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 29 Jul 2020 11:22:47 -0400 Subject: [Git][ghc/ghc][wip/backports] 2 commits: base: Bump version for log1mexp fix Message-ID: <5f21944712779_80b3f848a37384c573319@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: 17f1bd51 by Ben Gamari at 2020-07-29T15:22:33+00:00 base: Bump version for log1mexp fix - - - - - e9f12058 by Ben Gamari at 2020-07-29T15:22:33+00:00 users-guide: Release notes for 8.10.2 - - - - - 12 changed files: - docs/users_guide/8.10.2-notes.rst - libraries/base/base.cabal - libraries/base/changelog.md - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - testsuite/tests/polykinds/T15592.stderr - testsuite/tests/polykinds/T15592b.stderr - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr Changes: ===================================== docs/users_guide/8.10.2-notes.rst ===================================== @@ -11,13 +11,26 @@ Highlights ---------- - A few important correctness fixes for the low-latency garbage collector. + Users of :rts-flag:`--nonmoving-gc` are strongly encouraged to upgrade + promptly. -Full details ------------- +- Fixes a bug in process creation on Windows (:ghc-ticket:`17926`). -Language -~~~~~~~~ +- Works around a Linux kernel bug in the implementation of ``timerfd``\s + (:ghc-ticket:`18033`). + +- Fixes a few specialiser regressions (:ghc-ticket:`17810`, + :ghc-ticket:`18120`) as well introduces a variety of miscellaneous + specialiser improvements (:ghc-ticket:`16473`, :ghc-ticket:`17930`, + :ghc-ticket:`17966`) + +- Fixes a potential loss of sharing due to left operator sections + (:ghc-ticket:`18151`). + +- Fix bootstrapping of GHC with the LLVM backend on x86-64 (:ghc-ticket:`17920`). +Full details +------------ Compiler ~~~~~~~~ @@ -25,20 +38,16 @@ Compiler - A simplifier panic manifesting when DWARF debug information is enabled has been fixed (:ghc-ticket:`18162`, :ghc-ticket:`17619`) -GHC API -~~~~~~~ - - -GHCi -~~~~ - Runtime system ~~~~~~~~~~~~~~ -- The RTS now allows the user to specify a minimum time between idle GCs with - the :rts-flag:`-Iw ⟨seconds⟩` flag. 8.10.1 contained a users guide reference - to this flag but did not include the associated implementation. + - The RTS now supports a flag, :rts-flag:`--copying-gc`, to counter-act the + effect of :rts-flag:`--nonmoving-gc`. + + - The RTS now allows the user to specify a minimum time between idle GCs with + the :rts-flag:`-Iw ⟨seconds⟩` flag. 8.10.1 contained a users guide reference + to this flag but did not include the associated implementation. - A memory leak in the cost-center profiler has been fixed (:ghc-ticket:`18348`) @@ -49,26 +58,40 @@ Runtime system - We now workaround a Linux kernel bug in the implementation of timerfd which could previously result in program crashes (:ghc-ticket:`18033`) -Template Haskell -~~~~~~~~~~~~~~~~ - - + - The cost center profiler's JSON output backend now escapes backslashes + correctly (:ghc-ticket:`18438`) -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ + - A variety of linker issues on ARM platforms have been fixed. - -``ghc`` library -~~~~~~~~~~~~~~~ - ``base`` library ~~~~~~~~~~~~~~~~ +- Fix a precision issue in the implementation of ``log1mexp`` + (:ghc-ticket:`17125`) + + Build system ~~~~~~~~~~~~ + - Fix a bug wherein GHC would link against the non-thread-safe unique supply + implementation when bootstrapping with an unregisterised compiler + (:ghc-ticket:`18024`) + +Known issues +------------ + +- A long-standing bug (:ghc-ticket:`16893`) which can cause some applications + of ``unsafeCoerce`` to segmentation fault is only partially fixed in this + release. This release only avoids this issue in the uses of ``unsafeCoerce`` + in ``Data.Typeable.Internal``, which was the proximate cause of + :ghc-ticket:`16893`. + + However, it is possible that this bug could manifest in user-code using + ``unsafeCoerce`` to perform dynamic type checks. See the :ghc-ticket:`ticket + <16893>` for details. + We expect that this issue will be fixed in the next major release of GHC. Included libraries ------------------ ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.14.0.0 +version: 4.14.1.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,6 +1,13 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.14.1.0* Jul 2020 + + * Bundled with GHC 8.10.2 + + * Fix a precision issue in `log1mexp` (#17125) + ## 4.14.0.0 *Jan 2020 + * Bundled with GHC 8.10.1 * Add a `TestEquality` instance for the `Compose` newtype. ===================================== testsuite/tests/dependent/should_compile/T14729.stderr ===================================== @@ -11,5 +11,5 @@ COERCION AXIOMS FAMILY INSTANCES type instance F Int = Bool -- Defined at T14729.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/dependent/should_compile/T15743.stderr ===================================== @@ -3,5 +3,5 @@ TYPE CONSTRUCTORS forall {k1} k2 (k3 :: k2). Proxy k3 -> k1 -> k2 -> * roles nominal nominal nominal phantom phantom phantom Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/dependent/should_compile/T15743e.stderr ===================================== @@ -52,5 +52,5 @@ DATA CONSTRUCTORS (d :: Proxy k5) (e :: Proxy k7). f c -> T k8 a b f c d e Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/indexed-types/should_compile/T15711.stderr ===================================== @@ -3,5 +3,5 @@ TYPE CONSTRUCTORS associated type family F{2} :: forall a. Maybe a -> * roles nominal nominal Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/indexed-types/should_compile/T15852.stderr ===================================== @@ -9,5 +9,5 @@ FAMILY INSTANCES data instance forall k1 k2 (j :: k1) (c :: k2). DF (Proxy c) -- Defined at T15852.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/polykinds/T15592.stderr ===================================== @@ -5,5 +5,5 @@ DATA CONSTRUCTORS MkT :: forall {k} k1 (f :: k1 -> k -> *) (a :: k1) (b :: k). f a b -> T f a b -> T f a b Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/polykinds/T15592b.stderr ===================================== @@ -4,5 +4,5 @@ TYPE CONSTRUCTORS forall k (f :: k -> *) (a :: k). f a -> * roles nominal nominal nominal nominal Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/typecheck/should_compile/T12763.stderr ===================================== @@ -8,5 +8,5 @@ COERCION AXIOMS CLASS INSTANCES instance C Int -- Defined at T12763.hs:9:10 Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr ===================================== @@ -9,10 +9,10 @@ subsumption_sort_hole_fits.hs:2:5: warning: [-Wtyped-holes (in -Wdefault)] Valid hole fits include lines :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.14.0.0:Data.OldList’)) + (and originally defined in ‘base-4.14.1.0:Data.OldList’)) words :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.14.0.0:Data.OldList’)) + (and originally defined in ‘base-4.14.1.0:Data.OldList’)) read :: forall a. Read a => String -> a with read @[String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ff4544e5941ce909b91d235fdce42c0b62c2b786...e9f1205801f331a058a1490372f14a4ad3cd9bdc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ff4544e5941ce909b91d235fdce42c0b62c2b786...e9f1205801f331a058a1490372f14a4ad3cd9bdc You're receiving 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 Jul 29 16:09:25 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 29 Jul 2020 12:09:25 -0400 Subject: [Git][ghc/ghc][wip/T18291] 11 commits: Drop 32-bit Windows support Message-ID: <5f219f35f0764_80b3f849c1caa105736954@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18291 at Glasgow Haskell Compiler / GHC Commits: aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - a31689fe by Ben Gamari at 2020-07-29T12:09:19-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 47d3683d by Ben Gamari at 2020-07-29T12:09:19-04:00 testsuite: Add test for #18291 - - - - - 30 changed files: - .gitlab-ci.yml - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - docs/users_guide/8.12.1-notes.rst - libraries/base/Data/Bits.hs - rts/PrimOps.cmm - + testsuite/tests/codeGen/should_compile/T18291.hs - testsuite/tests/codeGen/should_compile/all.T - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/numeric/should_run/T18499.hs - + testsuite/tests/numeric/should_run/T18499.stdout - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T10421a.hs - + testsuite/tests/perf/compiler/T10421a_Form.hs - + testsuite/tests/perf/compiler/T13253-spj.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1556ebd389666417630ad833490ad042f58d75f3...47d3683d752a340ff89a2097307e0042d30ba603 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1556ebd389666417630ad833490ad042f58d75f3...47d3683d752a340ff89a2097307e0042d30ba603 You're receiving 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 Jul 29 16:39:23 2020 From: gitlab at gitlab.haskell.org (cgibbard) Date: Wed, 29 Jul 2020 12:39:23 -0400 Subject: [Git][ghc/ghc][wip/keep-going-hs-boot] Add haddock comment for unfilteredEdges Message-ID: <5f21a63bbef56_80b3f849a265454574111f@gitlab.haskell.org.mail> cgibbard pushed to branch wip/keep-going-hs-boot at Glasgow Haskell Compiler / GHC Commits: a15fa25e by cgibbard at 2020-07-29T12:39:22-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 1 changed file: - compiler/GHC/Driver/Make.hs Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1981,23 +1981,22 @@ summaryNodeKey = node_key summaryNodeSummary :: SummaryNode -> ModSummary summaryNodeSummary = node_payload +-- | Collect the immediate dependencies of a module from its ModSummary, +-- optionally avoiding hs-boot dependencies. +-- If the drop_hs_boot_nodes flag is False, and if this is a .hs and there is +-- an equivalent .hs-boot, add a link from the former to the latter. This +-- has the effect of detecting bogus cases where the .hs-boot depends on the +-- .hs, by introducing a cycle. Additionally, it ensures that we will always +-- process the .hs-boot before the .hs, and so the HomePackageTable will always +-- have the most up to date information. unfilteredEdges :: Bool -> ModSummary -> [ModuleNameWithIsBoot] unfilteredEdges drop_hs_boot_nodes ms = (flip GWIB hs_boot_key . unLoc <$> ms_home_srcimps ms) ++ (flip GWIB NotBoot . unLoc <$> ms_home_imps ms) ++ [ GWIB (ms_mod_name ms) IsBoot | not $ drop_hs_boot_nodes || ms_hsc_src ms == HsBootFile - -- see [boot-edges] below ] where - -- [boot-edges] if this is a .hs and there is an equivalent - -- .hs-boot, add a link from the former to the latter. This - -- has the effect of detecting bogus cases where the .hs-boot - -- depends on the .hs, by introducing a cycle. Additionally, - -- it ensures that we will always process the .hs-boot before - -- the .hs, and so the HomePackageTable will always have the - -- most up to date information. - -- Drop hs-boot nodes by using HsSrcFile as the key hs_boot_key | drop_hs_boot_nodes = NotBoot -- is regular mod or signature | otherwise = IsBoot View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a15fa25ec3c152a3dcf2b78e62a5e2b2cb371254 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a15fa25ec3c152a3dcf2b78e62a5e2b2cb371254 You're receiving 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 Jul 29 16:50:44 2020 From: gitlab at gitlab.haskell.org (Josh Meredith) Date: Wed, 29 Jul 2020 12:50:44 -0400 Subject: [Git][ghc/ghc][wip/pluginExtFields] 13 commits: Drop 32-bit Windows support Message-ID: <5f21a8e472fb6_80b3f84901714f85751045@gitlab.haskell.org.mail> Josh Meredith pushed to branch wip/pluginExtFields at Glasgow Haskell Compiler / GHC Commits: aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c487a86f by Josh Meredith at 2020-07-29T12:50:41-04:00 Add machinery for plugins to write data to extensible interface fields - - - - - 9622de46 by Josh Meredith at 2020-07-29T12:50:41-04:00 Add function to remove plugin interface fields - - - - - 30 changed files: - .gitlab-ci.yml - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - docs/users_guide/8.12.1-notes.rst - ghc.mk - libraries/base/Data/Bits.hs - libraries/base/GHC/IO.hs - rts/PrimOps.cmm - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/numeric/should_run/T18499.hs - + testsuite/tests/numeric/should_run/T18499.stdout - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/perf/compiler/T10421.hs - + testsuite/tests/perf/compiler/T10421_Form.hs - + testsuite/tests/perf/compiler/T10421_Y.hs - + testsuite/tests/perf/compiler/T10421a.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b5693b5f633faf0b6a1452f7214e28eedb04dc63...9622de46a83374456a24c5e67957e4ce69de9e87 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b5693b5f633faf0b6a1452f7214e28eedb04dc63...9622de46a83374456a24c5e67957e4ce69de9e87 You're receiving 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 Jul 29 19:06:41 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 29 Jul 2020 15:06:41 -0400 Subject: [Git][ghc/ghc][master] Fix typo Message-ID: <5f21c8c1b0157_80b3f84901714f857794ec@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - 1 changed file: - libraries/base/Data/Maybe.hs Changes: ===================================== libraries/base/Data/Maybe.hs ===================================== @@ -149,7 +149,7 @@ fromJust Nothing = error "Maybe.fromJust: Nothing" -- yuck fromJust (Just x) = x -- | The 'fromMaybe' function takes a default value and a 'Maybe' --- value. If the 'Maybe' is 'Nothing', it returns the default values; +-- value. If the 'Maybe' is 'Nothing', it returns the default value; -- otherwise, it returns the value contained in the 'Maybe'. -- -- ==== __Examples__ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b9a880fce484d0a87bb794b9d2d8a73e54819011 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b9a880fce484d0a87bb794b9d2d8a73e54819011 You're receiving 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 Jul 29 19:07:19 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 29 Jul 2020 15:07:19 -0400 Subject: [Git][ghc/ghc][master] 4 commits: Add regression test for #16341 Message-ID: <5f21c8e7a14ca_80b104e15b45782559@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - 7 changed files: - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Deriv/Utils.hs - + testsuite/tests/deriving/should_compile/T16341.hs - testsuite/tests/deriving/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/Deriv.hs ===================================== @@ -2038,9 +2038,12 @@ genDerivStuff mechanism loc clas inst_tys tyvars -> gen_newtype_or_via rhs_ty -- Try a stock deriver - DerivSpecStock { dsm_stock_dit = DerivInstTys{dit_rep_tc = rep_tc} + DerivSpecStock { dsm_stock_dit = DerivInstTys + { dit_rep_tc = rep_tc + , dit_rep_tc_args = rep_tc_args + } , dsm_stock_gen_fn = gen_fn } - -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc inst_tys + -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc rep_tc_args inst_tys pure (binds, [], faminsts, field_names) -- Try DeriveAnyClass ===================================== compiler/GHC/Tc/Deriv/Functor.hs ===================================== @@ -151,10 +151,10 @@ is a similar algorithm for generating `p <$ x` (for some constant `p`): $(coreplace 'a '(tb -> tc) x) = \(y:tb[b/a]) -> $(coreplace 'a' 'tc' (x $(replace 'a 'tb y))) -} -gen_Functor_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Functor_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use fmap _ = coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag fmap_bind, emptyBag) where @@ -165,10 +165,10 @@ gen_Functor_binds loc tycon coerce_Expr] fmap_match_ctxt = mkPrefixFunRhs fmap_name -gen_Functor_binds loc tycon +gen_Functor_binds loc tycon tycon_args = (listToBag [fmap_bind, replace_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args fmap_name = L loc fmap_RDR -- See Note [EmptyDataDecls with Functor, Foldable, and Traversable] @@ -787,10 +787,10 @@ could surprise users if they switch to other types, but Ryan Scott seems to think it's okay to do it for now. -} -gen_Foldable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Foldable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the parameter is phantom, we can use foldMap _ _ = mempty -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag foldMap_bind, emptyBag) where @@ -801,7 +801,7 @@ gen_Foldable_binds loc tycon mempty_Expr] foldMap_match_ctxt = mkPrefixFunRhs foldMap_name -gen_Foldable_binds loc tycon +gen_Foldable_binds loc tycon tycon_args | null data_cons -- There's no real point producing anything but -- foldMap for a type with no constructors. = (unitBag foldMap_bind, emptyBag) @@ -809,7 +809,7 @@ gen_Foldable_binds loc tycon | otherwise = (listToBag [foldr_bind, foldMap_bind, null_bind], emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args foldr_bind = mkRdrFunBind (L loc foldable_foldr_RDR) eqns eqns = map foldr_eqn data_cons @@ -1016,10 +1016,10 @@ removes all such types from consideration. See Note [Generated code for DeriveFoldable and DeriveTraversable]. -} -gen_Traversable_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) +gen_Traversable_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -- When the argument is phantom, we can use traverse = pure . coerce -- See Note [Phantom types with Functor, Foldable, and Traversable] -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon _ | Phantom <- last (tyConRoles tycon) = (unitBag traverse_bind, emptyBag) where @@ -1031,10 +1031,10 @@ gen_Traversable_binds loc tycon (nlHsApps pure_RDR [nlHsApp coerce_Expr z_Expr])] traverse_match_ctxt = mkPrefixFunRhs traverse_name -gen_Traversable_binds loc tycon +gen_Traversable_binds loc tycon tycon_args = (unitBag traverse_bind, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args traverse_name = L loc traverse_RDR ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -33,7 +33,9 @@ module GHC.Tc.Deriv.Generate ( mkCoerceClassMethEqn, genAuxBinds, ordOpTbl, boxConTbl, litConTbl, - mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr + mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr, + + getPossibleDataCons, tyConInstArgTys ) where #include "HsVersions.h" @@ -212,14 +214,14 @@ for the instance decl, which it probably wasn't, so the decls produced don't get through the typechecker. -} -gen_Eq_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Eq_binds loc tycon = do +gen_Eq_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Eq_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon return (method_binds con2tag_RDR, aux_binds con2tag_RDR) where - all_cons = tyConDataCons tycon + all_cons = getPossibleDataCons tycon tycon_args (nullary_cons, non_nullary_cons) = partition isNullarySrcDataCon all_cons -- If there are ten or more (arbitrary number) nullary constructors, @@ -396,8 +398,8 @@ gtResult OrdGE = true_Expr gtResult OrdGT = true_Expr ------------ -gen_Ord_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ord_binds loc tycon = do +gen_Ord_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ord_binds loc tycon tycon_args = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon @@ -432,7 +434,7 @@ gen_Ord_binds loc tycon = do -- We want *zero-based* tags, because that's what -- con2Tag returns (generated by untag_Expr)! - tycon_data_cons = tyConDataCons tycon + tycon_data_cons = getPossibleDataCons tycon tycon_args single_con_type = isSingleton tycon_data_cons (first_con : _) = tycon_data_cons (last_con : _) = reverse tycon_data_cons @@ -646,8 +648,8 @@ instance ... Enum (Foo ...) where For @enumFromTo@ and @enumFromThenTo@, we use the default methods. -} -gen_Enum_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Enum_binds loc tycon = do +gen_Enum_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Enum_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -738,8 +740,8 @@ gen_Enum_binds loc tycon = do ************************************************************************ -} -gen_Bounded_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Bounded_binds loc tycon +gen_Bounded_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Bounded_binds loc tycon _ | isEnumerationTyCon tycon = (listToBag [ min_bound_enum, max_bound_enum ], emptyBag) | otherwise @@ -825,9 +827,9 @@ we follow the scheme given in Figure~19 of the Haskell~1.2 report (p.~147). -} -gen_Ix_binds :: SrcSpan -> TyCon -> TcM (LHsBinds GhcPs, BagDerivStuff) +gen_Ix_binds :: SrcSpan -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff) -gen_Ix_binds loc tycon = do +gen_Ix_binds loc tycon _ = do -- See Note [Auxiliary binders] con2tag_RDR <- new_con2tag_rdr_name loc tycon tag2con_RDR <- new_tag2con_rdr_name loc tycon @@ -1028,10 +1030,10 @@ These instances are also useful for Read (Either Int Emp), where we want to be able to parse (Left 3) just fine. -} -gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Read_binds get_fixity loc tycon +gen_Read_binds get_fixity loc tycon _ = (listToBag [read_prec, default_readlist, default_readlistprec], emptyBag) where ----------------------------------------------------------------------- @@ -1212,13 +1214,13 @@ Example -- the most tightly-binding operator -} -gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon +gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) -gen_Show_binds get_fixity loc tycon +gen_Show_binds get_fixity loc tycon tycon_args = (unitBag shows_prec, emptyBag) where - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args shows_prec = mkFunBindEC 2 loc showsPrec_RDR id (map pats_etc data_cons) comma_space = nlHsVar showCommaSpace_RDR @@ -1385,9 +1387,10 @@ we generate gen_Data_binds :: SrcSpan -> TyCon -- For data families, this is the -- *representation* TyCon + -> [Type] -> TcM (LHsBinds GhcPs, -- The method bindings BagDerivStuff) -- Auxiliary bindings -gen_Data_binds loc rep_tc +gen_Data_binds loc rep_tc _ = do { -- See Note [Auxiliary binders] dataT_RDR <- new_dataT_rdr_name loc rep_tc ; dataC_RDRs <- traverse (new_dataC_rdr_name loc) data_cons @@ -1616,8 +1619,8 @@ Example: -} -gen_Lift_binds :: SrcSpan -> TyCon -> (LHsBinds GhcPs, BagDerivStuff) -gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) +gen_Lift_binds :: SrcSpan -> TyCon -> [Type] -> (LHsBinds GhcPs, BagDerivStuff) +gen_Lift_binds loc tycon tycon_args = (listToBag [lift_bind, liftTyped_bind], emptyBag) where lift_bind = mkFunBindEC 1 loc lift_RDR (nlHsApp pure_Expr) (map (pats_etc mk_exp) data_cons) @@ -1626,7 +1629,7 @@ gen_Lift_binds loc tycon = (listToBag [lift_bind, liftTyped_bind], emptyBag) mk_exp = ExpBr noExtField mk_texp = TExpBr noExtField - data_cons = tyConDataCons tycon + data_cons = getPossibleDataCons tycon tycon_args pats_etc mk_bracket data_con = ([con_pat], lift_Expr) @@ -2515,6 +2518,39 @@ newAuxBinderRdrName loc parent occ_fun = do uniq <- newUnique pure $ Exact $ mkSystemNameAt uniq (occ_fun (nameOccName parent)) loc +-- | @getPossibleDataCons tycon tycon_args@ returns the constructors of @tycon@ +-- whose return types match when checked against @tycon_args at . +-- +-- See Note [Filter out impossible GADT data constructors] +getPossibleDataCons :: TyCon -> [Type] -> [DataCon] +getPossibleDataCons tycon tycon_args = filter isPossible $ tyConDataCons tycon + where + isPossible = not . dataConCannotMatch (tyConInstArgTys tycon tycon_args) + +-- | Given a type constructor @tycon@ of arity /n/ and a list of argument types +-- @tycon_args@ of length /m/, +-- +-- @ +-- tyConInstArgTys tycon tycon_args +-- @ +-- +-- returns +-- +-- @ +-- [tycon_arg_{1}, tycon_arg_{2}, ..., tycon_arg_{m}, extra_arg_{m+1}, ..., extra_arg_{n}] +-- @ +-- +-- where @extra_args@ are distinct type variables. +-- +-- Examples: +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int, Bool]@, return @[Int, Bool]@. +-- +-- * Given @tycon: Foo a b@ and @tycon_args: [Int]@, return @[Int, b]@. +tyConInstArgTys :: TyCon -> [Type] -> [Type] +tyConInstArgTys tycon tycon_args = chkAppend tycon_args $ map mkTyVarTy tycon_args_suffix + where + tycon_args_suffix = drop (length tycon_args) $ tyConTyVars tycon {- Note [Auxiliary binders] @@ -2733,4 +2769,56 @@ derived instances within the same module, not separated by any TH splices. (This is the case described in "Wrinkle: Reducing code duplication".) In situation (1), we can at least fall back on GHC's simplifier to pick up genAuxBinds' slack. + +Note [Filter out impossible GADT data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some stock-derivable classes will filter out impossible GADT data constructors, +to rule out problematic constructors when deriving instances. e.g. + +``` +data Foo a where + X :: Foo Int + Y :: (Bool -> Bool) -> Foo Bool +``` + +when deriving an instance on `Foo Int`, `Y` should be treated as if it didn't +exist in the first place. For instance, if we write + +``` +deriving instance Eq (Foo Int) +``` + +it should generate: + +``` +instance Eq (Foo Int) where + X == X = True +``` + +Classes that filter constructors: + +* Eq +* Ord +* Show +* Lift +* Functor +* Foldable +* Traversable + +Classes that do not filter constructors: + +* Enum: doesn't make sense for GADTs in the first place +* Bounded: only makes sense for GADTs with a single constructor +* Ix: only makes sense for GADTs with a single constructor +* Read: `Read a` returns `a` instead of consumes `a`, so filtering data + constructors would make this function _more_ partial instead of less +* Data: derived implementations of gunfold rely on a constructor-indexing + scheme that wouldn't work if certain constructors were filtered out +* Generic/Generic1: doesn't make sense for GADTs + +Classes that do not currently filter constructors may do so in the future, if +there is a valid use-case and we have requirements for how they should work. + +See #16341 and the T16341.hs test case. -} ===================================== compiler/GHC/Tc/Deriv/Infer.hs ===================================== @@ -260,9 +260,7 @@ inferConstraintsStock (DerivInstTys { dit_cls_tys = cls_tys -- substitute each type variable with its counterpart in the derived -- instance. rep_tc_args lists each of these counterpart types in -- the same order as the type variables. - all_rep_tc_args - = rep_tc_args ++ map mkTyVarTy - (drop (length rep_tc_args) rep_tc_tvs) + all_rep_tc_args = tyConInstArgTys rep_tc rep_tc_args -- Stupid constraints stupid_constraints ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -218,8 +218,9 @@ data DerivSpecMechanism -- instance, including what type constructor the last argument is -- headed by. See @Note [DerivEnv and DerivSpecMechanism]@. , dsm_stock_gen_fn :: - SrcSpan -> TyCon - -> [Type] + SrcSpan -> TyCon -- dit_rep_tc + -> [Type] -- dit_rep_tc_args + -> [Type] -- inst_tys -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]) -- ^ This function returns three things: -- @@ -424,7 +425,7 @@ instance Outputable DerivContext where -- See @Note [Deriving strategies]@ in "GHC.Tc.Deriv". data OriginativeDerivStatus = CanDeriveStock -- Stock class, can derive - (SrcSpan -> TyCon -> [Type] + (SrcSpan -> TyCon -> [Type] -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) | StockClassError SDoc -- Stock class, but can't do it | CanDeriveAnyClass -- See Note [Deriving any class] @@ -563,6 +564,7 @@ hasStockDeriving :: Class -> Maybe (SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) hasStockDeriving clas = assocMaybe gen_list (getUnique clas) @@ -571,6 +573,7 @@ hasStockDeriving clas :: [(Unique, SrcSpan -> TyCon -> [Type] + -> [Type] -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))] gen_list = [ (eqClassKey, simpleM gen_Eq_binds) , (ordClassKey, simpleM gen_Ord_binds) @@ -587,25 +590,25 @@ hasStockDeriving clas , (genClassKey, generic (gen_Generic_binds Gen0)) , (gen1ClassKey, generic (gen_Generic_binds Gen1)) ] - simple gen_fn loc tc _ - = let (binds, deriv_stuff) = gen_fn loc tc + simple gen_fn loc tc tc_args _ + = let (binds, deriv_stuff) = gen_fn loc tc tc_args in return (binds, deriv_stuff, []) -- Like `simple`, but monadic. The only monadic thing that these functions -- do is allocate new Uniques, which are used for generating the names of -- auxiliary bindings. -- See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate. - simpleM gen_fn loc tc _ - = do { (binds, deriv_stuff) <- gen_fn loc tc + simpleM gen_fn loc tc tc_args _ + = do { (binds, deriv_stuff) <- gen_fn loc tc tc_args ; return (binds, deriv_stuff, []) } - read_or_show gen_fn loc tc _ + read_or_show gen_fn loc tc tc_args _ = do { fix_env <- getDataConFixityFun tc - ; let (binds, deriv_stuff) = gen_fn fix_env loc tc + ; let (binds, deriv_stuff) = gen_fn fix_env loc tc tc_args field_names = all_field_names tc ; return (binds, deriv_stuff, field_names) } - generic gen_fn _ tc inst_tys + generic gen_fn _ tc _ inst_tys = do { (binds, faminst) <- gen_fn tc inst_tys ; let field_names = all_field_names tc ; return (binds, unitBag (DerivFamInst faminst), field_names) } ===================================== testsuite/tests/deriving/should_compile/T16341.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveLift #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE StandaloneDeriving #-} + +module T16341 where + +import Language.Haskell.TH.Syntax (Lift) + +data Foo a where + Foo1 :: Foo Int + Foo2 :: (Bool -> Bool) -> Foo Bool + +-- These instances should work whether or not `Foo2` is a constructor in +-- `Foo`, because the `Foo Int` designation precludes `Foo2` from being +-- a reachable constructor +deriving instance Show (Foo Int) +deriving instance Eq (Foo Int) +deriving instance Ord (Foo Int) +deriving instance Lift (Foo Int) + +data Bar a b where + Bar1 :: b -> Bar Int b + Bar2 :: (Bool -> Bool) -> b -> Bar Bool b + +deriving instance Functor (Bar Int) +deriving instance Foldable (Bar Int) +deriving instance Traversable (Bar Int) ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -118,6 +118,7 @@ test('T15398', normal, compile, ['']) test('T15637', normal, compile, ['']) test('T15831', normal, compile, ['']) test('T16179', normal, compile, ['']) +test('T16341', normal, compile, ['']) test('T16518', normal, compile, ['']) test('T17324', normal, compile, ['']) test('T17339', normal, compile, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b9a880fce484d0a87bb794b9d2d8a73e54819011...44b11bad052eabf43246acba6aab814376b08713 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b9a880fce484d0a87bb794b9d2d8a73e54819011...44b11bad052eabf43246acba6aab814376b08713 You're receiving 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 Jul 29 19:08:28 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 29 Jul 2020 15:08:28 -0400 Subject: [Git][ghc/ghc][master] configure: Fix build system on ARM Message-ID: <5f21c92c13755_80b104e15b457906c3@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 1 changed file: - aclocal.m4 Changes: ===================================== aclocal.m4 ===================================== @@ -206,7 +206,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], ;; arm) GET_ARM_ISA() - test -z "[$]2" || eval "[$]2=\"ArchARM \$ARM_ISA \$ARM_ISA_EXT \$ARM_ABI}\"" + test -z "[$]2" || eval "[$]2=\"ArchARM \$ARM_ISA \$ARM_ISA_EXT \$ARM_ABI\"" ;; aarch64) test -z "[$]2" || eval "[$]2=ArchARM64" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3db4b4c5b7f5d2a62ebd88e174fca07d04c4e18 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3db4b4c5b7f5d2a62ebd88e174fca07d04c4e18 You're receiving 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 Jul 29 19:07:54 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 29 Jul 2020 15:07:54 -0400 Subject: [Git][ghc/ghc][master] Kill off sc_mult and as_mult fields Message-ID: <5f21c90aa349a_80b116148a4578863@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - 2 changed files: - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -1004,7 +1004,7 @@ simplExprF1 env (App fun arg) cont , sc_hole_ty = hole' , sc_cont = cont } } _ -> - -- crucially, these are /lazy/ bindings. They will + -- Crucially, sc_hole_ty is a /lazy/ binding. It will -- be forced only if we need to run contHoleType. -- When these are forced, we might get quadratic behavior; -- this quadratic blowup could be avoided by drilling down @@ -1012,17 +1012,10 @@ simplExprF1 env (App fun arg) cont -- (instead of one-at-a-time). But in practice, we have not -- observed the quadratic behavior, so this extra entanglement -- seems not worthwhile. - -- - -- But the (exprType fun) is repeated, to push it into two - -- separate, rarely used, thunks; rather than always alloating - -- a shared thunk. Makes a small efficiency difference - let fun_ty = exprType fun - (m, _, _) = splitFunTy fun_ty - in simplExprF env fun $ ApplyToVal { sc_arg = arg, sc_env = env , sc_hole_ty = substTy env (exprType fun) - , sc_dup = NoDup, sc_cont = cont, sc_mult = m } + , sc_dup = NoDup, sc_cont = cont } simplExprF1 env expr@(Lam {}) cont = {-#SCC "simplExprF1-Lam" #-} @@ -1327,8 +1320,8 @@ rebuild env expr cont Select { sc_bndr = bndr, sc_alts = alts, sc_env = se, sc_cont = cont } -> rebuildCase (se `setInScopeFromE` env) expr bndr alts cont - StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty, sc_mult = m } - -> rebuildCall env (addValArgTo fun (m, expr) fun_ty ) cont + StrictArg { sc_fun = fun, sc_cont = cont, sc_fun_ty = fun_ty } + -> rebuildCall env (addValArgTo fun expr fun_ty ) cont StrictBind { sc_bndr = b, sc_bndrs = bs, sc_body = body , sc_env = se, sc_cont = cont } -> do { (floats1, env') <- simplNonRecX (se `setInScopeFromE` env) b expr @@ -1420,7 +1413,7 @@ simplCast env body co0 cont0 -- co1 :: t1 ~ s1 -- co2 :: s2 ~ t2 addCoerce co cont@(ApplyToVal { sc_arg = arg, sc_env = arg_se - , sc_dup = dup, sc_cont = tail, sc_mult = m }) + , sc_dup = dup, sc_cont = tail }) | Just (co1, m_co2) <- pushCoValArg co , let new_ty = coercionRKind co1 , not (isTypeLevPoly new_ty) -- Without this check, we get a lev-poly arg @@ -1444,8 +1437,7 @@ simplCast env body co0 cont0 , sc_env = arg_se' , sc_dup = dup' , sc_cont = tail' - , sc_hole_ty = coercionLKind co - , sc_mult = m }) } } + , sc_hole_ty = coercionLKind co }) } } addCoerce co cont | isReflexiveCo co = return cont -- Having this at the end makes a huge @@ -1981,17 +1973,18 @@ rebuildCall env info (ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_c -- runRW# :: forall (r :: RuntimeRep) (o :: TYPE r). (State# RealWorld -> o) -> o -- K[ runRW# rr ty body ] --> runRW rr' ty' (\s. K[ body s ]) rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) - (ApplyToVal { sc_arg = arg, sc_env = arg_se, sc_cont = cont, sc_mult = m }) + (ApplyToVal { sc_arg = arg, sc_env = arg_se + , sc_cont = cont, sc_hole_ty = fun_ty }) | fun_id `hasKey` runRWKey , not (contIsStop cont) -- Don't fiddle around if the continuation is boring , [ TyArg {}, TyArg {} ] <- rev_args = do { s <- newId (fsLit "s") Many realWorldStatePrimTy - ; let env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] + ; let (m,_,_) = splitFunTy fun_ty + env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] ty' = contResultType cont cont' = ApplyToVal { sc_dup = Simplified, sc_arg = Var s , sc_env = env', sc_cont = cont - , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' - , sc_mult = m } + , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' } -- cont' applies to s, then K ; body' <- simplExprC env' arg cont' ; let arg' = Lam s body' @@ -2002,10 +1995,10 @@ rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) rebuildCall env fun_info (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_dup = dup_flag, sc_hole_ty = fun_ty - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Argument is already simplified | isSimplified dup_flag -- See Note [Avoid redundant simplification] - = rebuildCall env (addValArgTo fun_info (m, arg) fun_ty) cont + = rebuildCall env (addValArgTo fun_info arg fun_ty) cont -- Strict arguments | isStrictArgInfo fun_info @@ -2014,7 +2007,7 @@ rebuildCall env fun_info simplExprF (arg_se `setInScopeFromE` env) arg (StrictArg { sc_fun = fun_info, sc_fun_ty = fun_ty , sc_dup = Simplified - , sc_cont = cont, sc_mult = m }) + , sc_cont = cont }) -- Note [Shadowing] -- Lazy arguments @@ -2025,7 +2018,7 @@ rebuildCall env fun_info -- floating a demanded let. = do { arg' <- simplExprC (arg_se `setInScopeFromE` env) arg (mkLazyArgStop arg_ty (lazyArgContext fun_info)) - ; rebuildCall env (addValArgTo fun_info (m, arg') fun_ty) cont } + ; rebuildCall env (addValArgTo fun_info arg' fun_ty) cont } where arg_ty = funArgTy fun_ty @@ -2233,24 +2226,10 @@ trySeqRules in_env scrut rhs cont , as_hole_ty = res2_ty } , ValArg { as_arg = no_cast_scrut , as_dmd = seqDmd - , as_hole_ty = res3_ty - , as_mult = Many } ] - -- The multiplicity of the scrutiny above is Many because the type - -- of seq requires that its first argument is unrestricted. The - -- typing rule of case also guarantees it though. In a more - -- general world, where the first argument of seq would have - -- affine multiplicity, then we could use the multiplicity of - -- the case (held in the case binder) instead. + , as_hole_ty = res3_ty } ] rule_cont = ApplyToVal { sc_dup = NoDup, sc_arg = rhs , sc_env = in_env, sc_cont = cont - , sc_hole_ty = res4_ty, sc_mult = Many } - -- The multiplicity in sc_mult above is the - -- multiplicity of the second argument of seq. Since - -- seq's type, as it stands, imposes that its second - -- argument be unrestricted, so is - -- sc_mult. However, a more precise typing rule, - -- for seq, would be to have it be linear. In which - -- case, sc_mult should be 1. + , sc_hole_ty = res4_ty } -- Lazily evaluated, so we don't do most of this @@ -3304,7 +3283,7 @@ mkDupableContWithDmds env _ mkDupableContWithDmds env _ (StrictArg { sc_fun = fun, sc_cont = cont - , sc_fun_ty = fun_ty, sc_mult = m }) + , sc_fun_ty = fun_ty }) -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable | thumbsUpPlanA cont = -- Use Plan A of Note [Duplicating StrictArg] @@ -3318,18 +3297,17 @@ mkDupableContWithDmds env _ , StrictArg { sc_fun = fun { ai_args = args' } , sc_cont = cont' , sc_fun_ty = fun_ty - , sc_mult = m , sc_dup = OkToDup} ) } | otherwise = -- Use Plan B of Note [Duplicating StrictArg] -- K[ f a b <> ] --> join j x = K[ f a b x ] -- j <> - do { let arg_ty = funArgTy fun_ty - rhs_ty = contResultType cont - ; arg_bndr <- newId (fsLit "arg") m arg_ty -- ToDo: check this linearity argument + do { let rhs_ty = contResultType cont + (m,arg_ty,_) = splitFunTy fun_ty + ; arg_bndr <- newId (fsLit "arg") m arg_ty ; let env' = env `addNewInScopeIds` [arg_bndr] - ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (m, Var arg_bndr) fun_ty) cont + ; (floats, join_rhs) <- rebuildCall env' (addValArgTo fun (Var arg_bndr) fun_ty) cont ; mkDupableStrictBind env' arg_bndr (wrapFloats floats join_rhs) rhs_ty } where thumbsUpPlanA (StrictArg {}) = False @@ -3349,7 +3327,7 @@ mkDupableContWithDmds env dmds mkDupableContWithDmds env dmds (ApplyToVal { sc_arg = arg, sc_dup = dup, sc_env = se - , sc_cont = cont, sc_hole_ty = hole_ty, sc_mult = mult }) + , sc_cont = cont, sc_hole_ty = hole_ty }) = -- e.g. [...hole...] (...arg...) -- ==> -- let a = ...arg... @@ -3369,7 +3347,7 @@ mkDupableContWithDmds env dmds -- has turned arg'' into a fresh variable -- See Note [StaticEnv invariant] in GHC.Core.Opt.Simplify.Utils , sc_dup = OkToDup, sc_cont = cont' - , sc_hole_ty = hole_ty, sc_mult = mult }) } + , sc_hole_ty = hole_ty }) } mkDupableContWithDmds env _ (Select { sc_bndr = case_bndr, sc_alts = alts, sc_env = se, sc_cont = cont }) @@ -3439,7 +3417,6 @@ mkDupableStrictBind env arg_bndr join_rhs res_ty , sc_fun = arg_info , sc_fun_ty = idType join_bndr , sc_cont = mkBoringStop res_ty - , sc_mult = Many -- ToDo: check this! } ) } mkDupableAlt :: Platform -> OutId ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -125,8 +125,7 @@ data SimplCont -- See Note [The hole type in ApplyToTy/Val] , sc_arg :: InExpr -- The argument, , sc_env :: StaticEnv -- see Note [StaticEnv invariant] - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | ApplyToTy -- (ApplyToTy ty K)[e] = K[ e ty ] { sc_arg_ty :: OutType -- Argument type @@ -160,8 +159,7 @@ data SimplCont , sc_fun_ty :: OutType -- Type of the function (f e1 .. en), -- presumably (arg_ty -> res_ty) -- where res_ty is expected by sc_cont - , sc_cont :: SimplCont - , sc_mult :: Mult } + , sc_cont :: SimplCont } | TickIt -- (TickIt t K)[e] = K[ tick t e ] (Tickish Id) -- Tick tickish @@ -282,8 +280,7 @@ data ArgInfo } data ArgSpec - = ValArg { as_mult :: Mult - , as_dmd :: Demand -- Demand placed on this argument + = ValArg { as_dmd :: Demand -- Demand placed on this argument , as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal , as_hole_ty :: OutType } -- Type of the function (presumably t1 -> t2) @@ -300,16 +297,15 @@ instance Outputable ArgInfo where , text "args =" <+> ppr args ]) instance Outputable ArgSpec where - ppr (ValArg { as_mult = mult, as_arg = arg }) = text "ValArg" <+> ppr mult <+> ppr arg + ppr (ValArg { as_arg = arg }) = text "ValArg" <+> ppr arg ppr (TyArg { as_arg_ty = ty }) = text "TyArg" <+> ppr ty ppr (CastBy c) = text "CastBy" <+> ppr c -addValArgTo :: ArgInfo -> (Mult, OutExpr) -> OutType -> ArgInfo -addValArgTo ai (w, arg) hole_ty +addValArgTo :: ArgInfo -> OutExpr -> OutType -> ArgInfo +addValArgTo ai arg hole_ty | ArgInfo { ai_dmds = dmd:dmds, ai_discs = _:discs, ai_rules = rules } <- ai -- Pop the top demand and and discounts off - , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty - , as_mult = w, as_dmd = dmd } + , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty, as_dmd = dmd } = ai { ai_args = arg_spec : ai_args ai , ai_dmds = dmds , ai_discs = discs @@ -345,9 +341,9 @@ pushSimplifiedArgs env (arg : args) k = case arg of TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } -> ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = rest } - ValArg { as_arg = arg, as_hole_ty = hole_ty, as_mult = w } + ValArg { as_arg = arg, as_hole_ty = hole_ty } -> ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified - , sc_hole_ty = hole_ty, sc_cont = rest, sc_mult = w } + , sc_hole_ty = hole_ty, sc_cont = rest } CastBy c -> CastIt c rest where rest = pushSimplifiedArgs env args k @@ -446,7 +442,7 @@ contHoleType (TickIt _ k) = contHoleType k contHoleType (CastIt co _) = coercionLKind co contHoleType (StrictBind { sc_bndr = b, sc_dup = dup, sc_env = se }) = perhapsSubstTy dup se (idType b) -contHoleType (StrictArg { sc_fun_ty = ty, sc_mult = _m }) = funArgTy ty +contHoleType (StrictArg { sc_fun_ty = ty }) = funArgTy ty contHoleType (ApplyToTy { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy] contHoleType (ApplyToVal { sc_hole_ty = ty }) = ty -- See Note [The hole type in ApplyToTy/Val] contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) @@ -464,12 +460,14 @@ contHoleType (Select { sc_dup = d, sc_bndr = b, sc_env = se }) contHoleScaling :: SimplCont -> Mult contHoleScaling (Stop _ _) = One contHoleScaling (CastIt _ k) = contHoleScaling k -contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k -contHoleScaling (StrictArg { sc_mult = w, sc_cont = k }) = - w `mkMultMul` contHoleScaling k -contHoleScaling (Select { sc_bndr = id, sc_cont = k }) = - (idMult id) `mkMultMul` contHoleScaling k +contHoleScaling (StrictBind { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (Select { sc_bndr = id, sc_cont = k }) + = idMult id `mkMultMul` contHoleScaling k +contHoleScaling (StrictArg { sc_fun_ty = fun_ty, sc_cont = k }) + = w `mkMultMul` contHoleScaling k + where + (w, _, _) = splitFunTy fun_ty contHoleScaling (ApplyToTy { sc_cont = k }) = contHoleScaling k contHoleScaling (ApplyToVal { sc_cont = k }) = contHoleScaling k contHoleScaling (TickIt _ k) = contHoleScaling k View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bbc5191640761ca9773abc898c077363b7beb4e7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bbc5191640761ca9773abc898c077363b7beb4e7 You're receiving 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 Jul 29 19:09:09 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 29 Jul 2020 15:09:09 -0400 Subject: [Git][ghc/ghc][master] Fix bug in Natural multiplication (fix #18509) Message-ID: <5f21c9557ae6b_80b116148a457952a2@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - 6 changed files: - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-bignum/src/GHC/Num/Natural.hs - libraries/ghc-bignum/src/GHC/Num/WordArray.hs - + testsuite/tests/numeric/should_run/T18509.hs - + testsuite/tests/numeric/should_run/T18509.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -228,8 +228,8 @@ bigNatToWordList bn = go (bigNatSize# bn) -- | Convert two Word# (most-significant first) into a BigNat bigNatFromWord2# :: Word# -> Word# -> BigNat# bigNatFromWord2# 0## 0## = bigNatZero# (# #) -bigNatFromWord2# 0## n = bigNatFromWord# n -bigNatFromWord2# w1 w2 = wordArrayFromWord2# w1 w2 +bigNatFromWord2# 0## l = bigNatFromWord# l +bigNatFromWord2# h l = wordArrayFromWord2# h l -- | Convert a BigNat into a Word# bigNatToWord# :: BigNat# -> Word# ===================================== libraries/ghc-bignum/src/GHC/Num/Natural.hs ===================================== @@ -86,8 +86,8 @@ naturalFromWord# x = NS x -- | Convert two Word# (most-significant first) into a Natural naturalFromWord2# :: Word# -> Word# -> Natural naturalFromWord2# 0## 0## = naturalZero -naturalFromWord2# 0## n = NS n -naturalFromWord2# w1 w2 = NB (bigNatFromWord2# w2 w1) +naturalFromWord2# 0## l = NS l +naturalFromWord2# h l = NB (bigNatFromWord2# h l) -- | Create a Natural from a Word naturalFromWord :: Word -> Natural ===================================== libraries/ghc-bignum/src/GHC/Num/WordArray.hs ===================================== @@ -121,12 +121,14 @@ withNewWordArrayTrimedMaybe# sz act = case runRW# io of (# _, a #) -> a -- | Create a WordArray# from two Word# -- --- `byteArrayFromWord2# msw lsw = lsw:msw` +-- `wordArrayFromWord2# h l +-- where h is the most significant word +-- l is the least significant word wordArrayFromWord2# :: Word# -> Word# -> WordArray# -wordArrayFromWord2# msw lsw = +wordArrayFromWord2# h l = withNewWordArray# 2# \mwa s -> - case mwaWrite# mwa 0# lsw s of - s -> mwaWrite# mwa 1# msw s + case mwaWrite# mwa 0# l s of + s -> mwaWrite# mwa 1# h s -- | Create a WordArray# from one Word# wordArrayFromWord# :: Word# -> WordArray# ===================================== testsuite/tests/numeric/should_run/T18509.hs ===================================== @@ -0,0 +1,6 @@ +import Numeric.Natural + +main :: IO () +main = do + print $ (0xFFFFFFFF0 * 0xFFFFFFFF0 :: Natural) + print $ (2 :: Natural) ^ (190 :: Int) ===================================== testsuite/tests/numeric/should_run/T18509.stdout ===================================== @@ -0,0 +1,2 @@ +4722366480670621958400 +1569275433846670190958947355801916604025588861116008628224 ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -71,3 +71,4 @@ test('T497', normal, compile_and_run, ['-O']) test('T17303', normal, compile_and_run, ['']) test('T18359', normal, compile_and_run, ['']) test('T18499', normal, compile_and_run, ['']) +test('T18509', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96c31ea1f0303ebabc59edccff2e88444fe02722 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96c31ea1f0303ebabc59edccff2e88444fe02722 You're receiving 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 Jul 29 19:09:45 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 29 Jul 2020 15:09:45 -0400 Subject: [Git][ghc/ghc][master] Fix validation errors (#18510) Message-ID: <5f21c9798e28a_80b104e15b45797841@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 5 changed files: - testsuite/tests/driver/T16318/Makefile - testsuite/tests/driver/T18125/Makefile - testsuite/tests/haddock/haddock_testsuite/Makefile - testsuite/tests/hpc/Makefile - testsuite/tests/stage1/T2632.hs Changes: ===================================== testsuite/tests/driver/T16318/Makefile ===================================== @@ -5,7 +5,7 @@ include $(TOP)/mk/test.mk test_pe = test-package-environment T16318: - $(GHC_PKG) latest base > $(test_pe) + "$(GHC_PKG)" latest base > $(test_pe) "$(TEST_HC)" $(TEST_HC_OPTS) -v1 -package-env $(test_pe) -e "putStrLn \"Hello\"" > out 2>&1 C=`cat out | grep "Loaded package environment" -c` ; \ if [ $$C != "1" ]; then false; fi ===================================== testsuite/tests/driver/T18125/Makefile ===================================== @@ -6,8 +6,8 @@ test_pe = test-package-environment test_lib = containers T18125: - $(GHC_PKG) latest base > $(test_pe) - $(GHC_PKG) latest $(test_lib) >> $(test_pe) + "$(GHC_PKG)" latest base > $(test_pe) + "$(GHC_PKG)" latest $(test_lib) >> $(test_pe) "$(TEST_HC)" $(TEST_HC_OPTS) -Wunused-packages -package-env $(test_pe) T18125.hs > out 2>&1 C=`cat out | grep "$(test_lib)" -c` ; \ if [ $$C != "1" ]; then false; fi ===================================== testsuite/tests/haddock/haddock_testsuite/Makefile ===================================== @@ -25,7 +25,7 @@ htmlTest: $(TOP)/../utils/haddock/html-test/Main.hs ./html-test \ $(ACCEPT) \ - --ghc-path=$(TEST_HC) \ + --ghc-path='$(TEST_HC)' \ --haddock-path=$(HADDOCK) \ --haddock-stdout=haddock-out.log @@ -41,7 +41,7 @@ latexTest: $(TOP)/../utils/haddock/latex-test/Main.hs ./latex-test \ $(ACCEPT) \ - --ghc-path=$(TEST_HC) \ + --ghc-path='$(TEST_HC)' \ --haddock-path=$(HADDOCK) \ --haddock-stdout=haddock-out.log @@ -57,7 +57,7 @@ hoogleTest: $(TOP)/../utils/haddock/hoogle-test/Main.hs ./hoogle-test \ $(ACCEPT) \ - --ghc-path=$(TEST_HC) \ + --ghc-path='$(TEST_HC)' \ --haddock-path=$(HADDOCK) \ --haddock-stdout=haddock-out.log @@ -73,6 +73,6 @@ hypsrcTest: $(TOP)/../utils/haddock/hypsrc-test/Main.hs ./hypsrc-test \ $(ACCEPT) \ - --ghc-path=$(TEST_HC) \ + --ghc-path='$(TEST_HC)' \ --haddock-path=$(HADDOCK) \ --haddock-stdout=haddock-out.log ===================================== testsuite/tests/hpc/Makefile ===================================== @@ -11,7 +11,7 @@ T11798: T17073: LANG=ASCII "$(TEST_HC)" $(TEST_HC_ARGS) T17073.hs -fhpc -v0 ./T17073 - $(HPC) report T17073 - $(HPC) version - LANG=ASCII $(HPC) markup T17073 + "$(HPC)" report T17073 + "$(HPC)" version + LANG=ASCII "$(HPC)" markup T17073 ===================================== testsuite/tests/stage1/T2632.hs ===================================== @@ -7,8 +7,10 @@ import Language.Haskell.TH op :: Num v => v -> v -> v op a b = a + b +decl1 :: Q [Dec] decl1 = [d| func = 0 `op` 3 |] +decl2 :: Q [Dec] decl2 = [d| op x y = x func = 0 `op` 3 |] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e1dc3d7b89ea79aea158ee487234d3730e857f04 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e1dc3d7b89ea79aea158ee487234d3730e857f04 You're receiving 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 Jul 29 19:40:25 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 29 Jul 2020 15:40:25 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 13 commits: Fix typo Message-ID: <5f21d0a91c572_80b3f848a37384c5803441@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - f1f94aff by Ryan Scott at 2020-07-29T15:40:20-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - 042efab8 by Ryan Scott at 2020-07-29T15:40:21-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - 00b845bb by Simon Peyton Jones at 2020-07-29T15:40:21-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - fc451e3b by Simon Peyton Jones at 2020-07-29T15:40:21-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 30 changed files: - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Types/Name/Reader.hs - libraries/base/Data/Maybe.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-bignum/src/GHC/Num/Natural.hs - libraries/ghc-bignum/src/GHC/Num/WordArray.hs - + testsuite/tests/deriving/should_compile/T16341.hs - testsuite/tests/deriving/should_compile/all.T - testsuite/tests/driver/T16318/Makefile - testsuite/tests/driver/T18125/Makefile - testsuite/tests/haddock/haddock_testsuite/Makefile - testsuite/tests/hpc/Makefile - testsuite/tests/indexed-types/should_fail/Overlap5.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6600e4c9d866aa11975b6e10fac490c232515aec...fc451e3bf0b1b1dd466fd373e7b4a30dd69ec769 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6600e4c9d866aa11975b6e10fac490c232515aec...fc451e3bf0b1b1dd466fd373e7b4a30dd69ec769 You're receiving 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 Jul 29 19:47:16 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 29 Jul 2020 15:47:16 -0400 Subject: [Git][ghc/ghc] Pushed new tag ghc-8.10.2-rc1 Message-ID: <5f21d244b81cb_80b3f84901714f858113ba@gitlab.haskell.org.mail> Ben Gamari pushed new tag ghc-8.10.2-rc1 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-8.10.2-rc1 You're receiving 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 Jul 29 19:51:59 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 29 Jul 2020 15:51:59 -0400 Subject: [Git][ghc/ghc][wip/backports] 5 commits: base: Bump version for log1mexp fix Message-ID: <5f21d35f3f34c_80b3f849c1caa1058140bf@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: 9c8c4f25 by Ben Gamari at 2020-07-28T13:26:27-04:00 base: Bump version for log1mexp fix - - - - - ff4544e5 by Ben Gamari at 2020-07-28T13:26:46-04:00 users-guide: Release notes for 8.10.2 - - - - - 7bc989ea by Ben Gamari at 2020-07-29T15:45:38-04:00 Bump Cabal submodule - - - - - 0006f59b by Ben Gamari at 2020-07-29T15:45:38-04:00 Bump hsc2hs submodule to 0.68.7 - - - - - 3c0e20d8 by Ben Gamari at 2020-07-29T15:45:38-04:00 Release GHC 8.10.2 - - - - - 6 changed files: - configure.ac - docs/users_guide/8.10.2-notes.rst - libraries/Cabal - libraries/base/base.cabal - libraries/base/changelog.md - utils/hsc2hs Changes: ===================================== configure.ac ===================================== @@ -13,10 +13,10 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.10.1], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.10.2], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # 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 ===================================== docs/users_guide/8.10.2-notes.rst ===================================== @@ -11,13 +11,26 @@ Highlights ---------- - A few important correctness fixes for the low-latency garbage collector. + Users of :rts-flag:`--nonmoving-gc` are strongly encouraged to upgrade + promptly. -Full details ------------- +- Fixes a bug in process creation on Windows (:ghc-ticket:`17926`). -Language -~~~~~~~~ +- Works around a Linux kernel bug in the implementation of ``timerfd``\s + (:ghc-ticket:`18033`). + +- Fixes a few specialiser regressions (:ghc-ticket:`17810`, + :ghc-ticket:`18120`) as well introduces a variety of miscellaneous + specialiser improvements (:ghc-ticket:`16473`, :ghc-ticket:`17930`, + :ghc-ticket:`17966`) + +- Fixes a potential loss of sharing due to left operator sections + (:ghc-ticket:`18151`). + +- Fix bootstrapping of GHC with the LLVM backend on x86-64 (:ghc-ticket:`17920`). +Full details +------------ Compiler ~~~~~~~~ @@ -25,20 +38,16 @@ Compiler - A simplifier panic manifesting when DWARF debug information is enabled has been fixed (:ghc-ticket:`18162`, :ghc-ticket:`17619`) -GHC API -~~~~~~~ - - -GHCi -~~~~ - Runtime system ~~~~~~~~~~~~~~ -- The RTS now allows the user to specify a minimum time between idle GCs with - the :rts-flag:`-Iw ⟨seconds⟩` flag. 8.10.1 contained a users guide reference - to this flag but did not include the associated implementation. + - The RTS now supports a flag, :rts-flag:`--copying-gc`, to counter-act the + effect of :rts-flag:`--nonmoving-gc`. + + - The RTS now allows the user to specify a minimum time between idle GCs with + the :rts-flag:`-Iw ⟨seconds⟩` flag. 8.10.1 contained a users guide reference + to this flag but did not include the associated implementation. - A memory leak in the cost-center profiler has been fixed (:ghc-ticket:`18348`) @@ -49,26 +58,40 @@ Runtime system - We now workaround a Linux kernel bug in the implementation of timerfd which could previously result in program crashes (:ghc-ticket:`18033`) -Template Haskell -~~~~~~~~~~~~~~~~ - - + - The cost center profiler's JSON output backend now escapes backslashes + correctly (:ghc-ticket:`18438`) -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ + - A variety of linker issues on ARM platforms have been fixed. - -``ghc`` library -~~~~~~~~~~~~~~~ - ``base`` library ~~~~~~~~~~~~~~~~ +- Fix a precision issue in the implementation of ``log1mexp`` + (:ghc-ticket:`17125`) + + Build system ~~~~~~~~~~~~ + - Fix a bug wherein GHC would link against the non-thread-safe unique supply + implementation when bootstrapping with an unregisterised compiler + (:ghc-ticket:`18024`) + +Known issues +------------ + +- A long-standing bug (:ghc-ticket:`16893`) which can cause some applications + of ``unsafeCoerce`` to segmentation fault is only partially fixed in this + release. This release only avoids this issue in the uses of ``unsafeCoerce`` + in ``Data.Typeable.Internal``, which was the proximate cause of + :ghc-ticket:`16893`. + + However, it is possible that this bug could manifest in user-code using + ``unsafeCoerce`` to perform dynamic type checks. See the :ghc-ticket:`ticket + <16893>` for details. + We expect that this issue will be fixed in the next major release of GHC. Included libraries ------------------ ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit b353baafe080e6aa6d542dd95658487b41e2254b +Subproject commit df65caf90ff79894dacecf73a642452aaabcc0a5 ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.14.0.0 +version: 4.14.1.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,6 +1,13 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.14.1.0* Jul 2020 + + * Bundled with GHC 8.10.2 + + * Fix a precision issue in `log1mexp` (#17125) + ## 4.14.0.0 *Jan 2020 + * Bundled with GHC 8.10.1 * Add a `TestEquality` instance for the `Compose` newtype. ===================================== utils/hsc2hs ===================================== @@ -1 +1 @@ -Subproject commit ed109c719925e358f68b95970199c4b961de6817 +Subproject commit 24100ea521596922d3edc8370b3d9f7b845ae4cf View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e9f1205801f331a058a1490372f14a4ad3cd9bdc...3c0e20d81b67645fb402cbedacbb31480721fb02 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e9f1205801f331a058a1490372f14a4ad3cd9bdc...3c0e20d81b67645fb402cbedacbb31480721fb02 You're receiving 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 Jul 29 21:22:35 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 29 Jul 2020 17:22:35 -0400 Subject: [Git][ghc/ghc][wip/gc/nonmoving-pinned] 37 commits: winio: restore console cp on exit Message-ID: <5f21e89b21b17_80b3f849a25e6905832999@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/gc/nonmoving-pinned at Glasgow Haskell Compiler / GHC Commits: cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - c74a76b6 by Ben Gamari at 2020-07-29T17:22:30-04:00 nonmoving: Teach allocatePinned() to allocate into nonmoving heap The allocatePinned() function is used to allocate pinned memory (e.g. for newPinnedByteArray#) - - - - - d8a0cb88 by Ben Gamari at 2020-07-29T17:22:30-04:00 gitlab-ci: Respect TEST_TYPE It seems that this was dropped in the refactoring of the CI driver. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/test-metrics.sh - CODEOWNERS - aclocal.m4 - compiler/GHC.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f16461d354a0e11954a350c7a23cbe33c1032e6e...d8a0cb88f45f9c9a3490472e77cf8e6071e7693a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f16461d354a0e11954a350c7a23cbe33c1032e6e...d8a0cb88f45f9c9a3490472e77cf8e6071e7693a You're receiving 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 Jul 30 02:59:59 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 29 Jul 2020 22:59:59 -0400 Subject: [Git][ghc/ghc][wip/backports] 5 commits: base: Bump version for log1mexp fix Message-ID: <5f2237af8e033_80b3f849a25e6905839918@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: 4672b93e by Ben Gamari at 2020-07-29T22:59:54-04:00 base: Bump version for log1mexp fix - - - - - 9aa91006 by Ben Gamari at 2020-07-29T22:59:54-04:00 users-guide: Release notes for 8.10.2 - - - - - 7b82011a by Ben Gamari at 2020-07-29T22:59:54-04:00 Bump Cabal submodule - - - - - 750c51ba by Ben Gamari at 2020-07-29T22:59:54-04:00 Bump hsc2hs submodule to 0.68.7 - - - - - dbe09a23 by Ben Gamari at 2020-07-29T22:59:54-04:00 Release GHC 8.10.2 - - - - - 15 changed files: - configure.ac - docs/users_guide/8.10.2-notes.rst - libraries/Cabal - libraries/base/base.cabal - libraries/base/changelog.md - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - testsuite/tests/polykinds/T15592.stderr - testsuite/tests/polykinds/T15592b.stderr - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr - utils/hsc2hs Changes: ===================================== configure.ac ===================================== @@ -13,10 +13,10 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.10.1], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.10.2], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # 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 ===================================== docs/users_guide/8.10.2-notes.rst ===================================== @@ -11,13 +11,26 @@ Highlights ---------- - A few important correctness fixes for the low-latency garbage collector. + Users of :rts-flag:`--nonmoving-gc` are strongly encouraged to upgrade + promptly. -Full details ------------- +- Fixes a bug in process creation on Windows (:ghc-ticket:`17926`). -Language -~~~~~~~~ +- Works around a Linux kernel bug in the implementation of ``timerfd``\s + (:ghc-ticket:`18033`). + +- Fixes a few specialiser regressions (:ghc-ticket:`17810`, + :ghc-ticket:`18120`) as well introduces a variety of miscellaneous + specialiser improvements (:ghc-ticket:`16473`, :ghc-ticket:`17930`, + :ghc-ticket:`17966`) + +- Fixes a potential loss of sharing due to left operator sections + (:ghc-ticket:`18151`). + +- Fix bootstrapping of GHC with the LLVM backend on x86-64 (:ghc-ticket:`17920`). +Full details +------------ Compiler ~~~~~~~~ @@ -25,20 +38,16 @@ Compiler - A simplifier panic manifesting when DWARF debug information is enabled has been fixed (:ghc-ticket:`18162`, :ghc-ticket:`17619`) -GHC API -~~~~~~~ - - -GHCi -~~~~ - Runtime system ~~~~~~~~~~~~~~ -- The RTS now allows the user to specify a minimum time between idle GCs with - the :rts-flag:`-Iw ⟨seconds⟩` flag. 8.10.1 contained a users guide reference - to this flag but did not include the associated implementation. + - The RTS now supports a flag, :rts-flag:`--copying-gc`, to counter-act the + effect of :rts-flag:`--nonmoving-gc`. + + - The RTS now allows the user to specify a minimum time between idle GCs with + the :rts-flag:`-Iw ⟨seconds⟩` flag. 8.10.1 contained a users guide reference + to this flag but did not include the associated implementation. - A memory leak in the cost-center profiler has been fixed (:ghc-ticket:`18348`) @@ -49,26 +58,40 @@ Runtime system - We now workaround a Linux kernel bug in the implementation of timerfd which could previously result in program crashes (:ghc-ticket:`18033`) -Template Haskell -~~~~~~~~~~~~~~~~ - - + - The cost center profiler's JSON output backend now escapes backslashes + correctly (:ghc-ticket:`18438`) -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ + - A variety of linker issues on ARM platforms have been fixed. - -``ghc`` library -~~~~~~~~~~~~~~~ - ``base`` library ~~~~~~~~~~~~~~~~ +- Fix a precision issue in the implementation of ``log1mexp`` + (:ghc-ticket:`17125`) + + Build system ~~~~~~~~~~~~ + - Fix a bug wherein GHC would link against the non-thread-safe unique supply + implementation when bootstrapping with an unregisterised compiler + (:ghc-ticket:`18024`) + +Known issues +------------ + +- A long-standing bug (:ghc-ticket:`16893`) which can cause some applications + of ``unsafeCoerce`` to segmentation fault is only partially fixed in this + release. This release only avoids this issue in the uses of ``unsafeCoerce`` + in ``Data.Typeable.Internal``, which was the proximate cause of + :ghc-ticket:`16893`. + + However, it is possible that this bug could manifest in user-code using + ``unsafeCoerce`` to perform dynamic type checks. See the :ghc-ticket:`ticket + <16893>` for details. + We expect that this issue will be fixed in the next major release of GHC. Included libraries ------------------ ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit b353baafe080e6aa6d542dd95658487b41e2254b +Subproject commit df65caf90ff79894dacecf73a642452aaabcc0a5 ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.14.0.0 +version: 4.14.1.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,6 +1,13 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.14.1.0* Jul 2020 + + * Bundled with GHC 8.10.2 + + * Fix a precision issue in `log1mexp` (#17125) + ## 4.14.0.0 *Jan 2020 + * Bundled with GHC 8.10.1 * Add a `TestEquality` instance for the `Compose` newtype. ===================================== testsuite/tests/dependent/should_compile/T14729.stderr ===================================== @@ -11,5 +11,5 @@ COERCION AXIOMS FAMILY INSTANCES type instance F Int = Bool -- Defined at T14729.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/dependent/should_compile/T15743.stderr ===================================== @@ -3,5 +3,5 @@ TYPE CONSTRUCTORS forall {k1} k2 (k3 :: k2). Proxy k3 -> k1 -> k2 -> * roles nominal nominal nominal phantom phantom phantom Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/dependent/should_compile/T15743e.stderr ===================================== @@ -52,5 +52,5 @@ DATA CONSTRUCTORS (d :: Proxy k5) (e :: Proxy k7). f c -> T k8 a b f c d e Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/indexed-types/should_compile/T15711.stderr ===================================== @@ -3,5 +3,5 @@ TYPE CONSTRUCTORS associated type family F{2} :: forall a. Maybe a -> * roles nominal nominal Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/indexed-types/should_compile/T15852.stderr ===================================== @@ -9,5 +9,5 @@ FAMILY INSTANCES data instance forall k1 k2 (j :: k1) (c :: k2). DF (Proxy c) -- Defined at T15852.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/polykinds/T15592.stderr ===================================== @@ -5,5 +5,5 @@ DATA CONSTRUCTORS MkT :: forall {k} k1 (f :: k1 -> k -> *) (a :: k1) (b :: k). f a b -> T f a b -> T f a b Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/polykinds/T15592b.stderr ===================================== @@ -4,5 +4,5 @@ TYPE CONSTRUCTORS forall k (f :: k -> *) (a :: k). f a -> * roles nominal nominal nominal nominal Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/typecheck/should_compile/T12763.stderr ===================================== @@ -8,5 +8,5 @@ COERCION AXIOMS CLASS INSTANCES instance C Int -- Defined at T12763.hs:9:10 Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr ===================================== @@ -9,10 +9,10 @@ subsumption_sort_hole_fits.hs:2:5: warning: [-Wtyped-holes (in -Wdefault)] Valid hole fits include lines :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.14.0.0:Data.OldList’)) + (and originally defined in ‘base-4.14.1.0:Data.OldList’)) words :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.14.0.0:Data.OldList’)) + (and originally defined in ‘base-4.14.1.0:Data.OldList’)) read :: forall a. Read a => String -> a with read @[String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 ===================================== utils/hsc2hs ===================================== @@ -1 +1 @@ -Subproject commit ed109c719925e358f68b95970199c4b961de6817 +Subproject commit 24100ea521596922d3edc8370b3d9f7b845ae4cf View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c0e20d81b67645fb402cbedacbb31480721fb02...dbe09a235cc1cd94215bbf7a43bcad01b253396f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c0e20d81b67645fb402cbedacbb31480721fb02...dbe09a235cc1cd94215bbf7a43bcad01b253396f You're receiving 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 Jul 30 04:51:04 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 30 Jul 2020 00:51:04 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: For `-fkeep-going` do not duplicate dependency edge code Message-ID: <5f2251b8c2d62_80bf016abc58486c1@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: fe859d16 by John Ericson at 2020-07-30T00:50:55-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 470d6238 by cgibbard at 2020-07-30T00:50:55-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 6773fe0d by Ryan Scott at 2020-07-30T00:50:55-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - 69e70055 by Ryan Scott at 2020-07-30T00:50:56-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - 82118f84 by Simon Peyton Jones at 2020-07-30T00:50:56-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 25455831 by Simon Peyton Jones at 2020-07-30T00:50:56-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 26 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/indexed-types/should_fail/Overlap5.stderr - + testsuite/tests/quantified-constraints/T18432.hs - testsuite/tests/quantified-constraints/all.T - testsuite/tests/rename/should_fail/T16002.stderr - testsuite/tests/th/T15362.hs - testsuite/tests/th/T15362.stderr - testsuite/tests/typecheck/should_fail/ExplicitSpecificity4.hs → testsuite/tests/typecheck/should_compile/ExplicitSpecificity4.hs - + testsuite/tests/typecheck/should_compile/T18470.hs - + testsuite/tests/typecheck/should_compile/T18470.stderr - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T11623.stderr - + testsuite/tests/typecheck/should_fail/T18455.hs - + testsuite/tests/typecheck/should_fail/T18455.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -1891,7 +1891,9 @@ substForAllCoBndrUsingLC sym sco (LC subst lc_env) tv co -- -- For the inverse operation, see 'liftCoMatch' ty_co_subst :: LiftingContext -> Role -> Type -> Coercion -ty_co_subst lc role ty +ty_co_subst !lc role ty + -- !lc: making this function strict in lc allows callers to + -- pass its two components separately, rather than boxing them = go role ty where go :: Role -> Type -> Coercion @@ -2864,9 +2866,9 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs -- need a coercion (kind_co :: old_kind ~ new_kind). -- -- The bangs here have been observed to improve performance - -- significantly in optimized builds. - let kind_co = mkSymCo $ - liftCoSubst Nominal lc (tyCoBinderType binder) + -- significantly in optimized builds; see #18502 + let !kind_co = mkSymCo $ + liftCoSubst Nominal lc (tyCoBinderType binder) !casted_xi = xi `mkCastTy` kind_co casted_co = mkCoherenceLeftCo role xi kind_co co ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -953,6 +953,12 @@ mkBuildModule ms = GWIB , gwib_isBoot = isBootSummary ms } +mkHomeBuildModule :: ModSummary -> ModuleNameWithIsBoot +mkHomeBuildModule ms = GWIB + { gwib_mod = moduleName $ ms_mod ms + , gwib_isBoot = isBootSummary ms + } + -- | The entry point to the parallel upsweep. -- -- See also the simpler, sequential 'upsweep'. @@ -1391,20 +1397,20 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do keep_going this_mods old_hpt done mods mod_index nmods uids_to_check done_holes = do let sum_deps ms (AcyclicSCC mod) = - if any (flip elem . map (unLoc . snd) $ ms_imps mod) ms - then ms_mod_name mod:ms + if any (flip elem $ unfilteredEdges False mod) ms + then mkHomeBuildModule mod:ms else ms sum_deps ms _ = ms dep_closure = foldl' sum_deps this_mods mods dropped_ms = drop (length this_mods) (reverse dep_closure) - prunable (AcyclicSCC mod) = elem (ms_mod_name mod) dep_closure + prunable (AcyclicSCC mod) = elem (mkHomeBuildModule mod) dep_closure prunable _ = False mods' = filter (not . prunable) mods nmods' = nmods - length dropped_ms when (not $ null dropped_ms) $ do dflags <- getSessionDynFlags - liftIO $ fatalErrorMsg dflags (keepGoingPruneErr dropped_ms) + liftIO $ fatalErrorMsg dflags (keepGoingPruneErr $ gwib_mod <$> dropped_ms) (_, done') <- upsweep' old_hpt done mods' (mod_index+1) nmods' uids_to_check done_holes return (Failed, done') @@ -1429,7 +1435,7 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do = do dflags <- getSessionDynFlags liftIO $ fatalErrorMsg dflags (cyclicModuleErr ms) if gopt Opt_KeepGoing dflags - then keep_going (map ms_mod_name ms) old_hpt done mods mod_index nmods + then keep_going (mkHomeBuildModule <$> ms) old_hpt done mods mod_index nmods uids_to_check done_holes else return (Failed, done) @@ -1483,7 +1489,7 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do Nothing -> do dflags <- getSessionDynFlags if gopt Opt_KeepGoing dflags - then keep_going [ms_mod_name mod] old_hpt done mods mod_index nmods + then keep_going [mkHomeBuildModule mod] old_hpt done mods mod_index nmods uids_to_check done_holes else return (Failed, done) Just mod_info -> do @@ -1919,7 +1925,7 @@ reachableBackwards mod summaries = [ node_payload node | node <- reachableG (transposeG graph) root ] where -- the rest just sets up the graph: (graph, lookup_node) = moduleGraphNodes False summaries - root = expectJust "reachableBackwards" (lookup_node IsBoot mod) + root = expectJust "reachableBackwards" (lookup_node $ GWIB mod IsBoot) -- --------------------------------------------------------------------------- -- @@ -1962,7 +1968,7 @@ topSortModuleGraph drop_hs_boot_nodes module_graph mb_root_mod -- the specified module. We do this by building a graph with -- the full set of nodes, and determining the reachable set from -- the specified node. - let root | Just node <- lookup_node NotBoot root_mod + let root | Just node <- lookup_node $ GWIB root_mod NotBoot , graph `hasVertexG` node = node | otherwise @@ -1977,60 +1983,55 @@ summaryNodeKey = node_key summaryNodeSummary :: SummaryNode -> ModSummary summaryNodeSummary = node_payload +-- | Collect the immediate dependencies of a module from its ModSummary, +-- optionally avoiding hs-boot dependencies. +-- If the drop_hs_boot_nodes flag is False, and if this is a .hs and there is +-- an equivalent .hs-boot, add a link from the former to the latter. This +-- has the effect of detecting bogus cases where the .hs-boot depends on the +-- .hs, by introducing a cycle. Additionally, it ensures that we will always +-- process the .hs-boot before the .hs, and so the HomePackageTable will always +-- have the most up to date information. +unfilteredEdges :: Bool -> ModSummary -> [ModuleNameWithIsBoot] +unfilteredEdges drop_hs_boot_nodes ms = + (flip GWIB hs_boot_key . unLoc <$> ms_home_srcimps ms) ++ + (flip GWIB NotBoot . unLoc <$> ms_home_imps ms) ++ + [ GWIB (ms_mod_name ms) IsBoot + | not $ drop_hs_boot_nodes || ms_hsc_src ms == HsBootFile + ] + where + -- Drop hs-boot nodes by using HsSrcFile as the key + hs_boot_key | drop_hs_boot_nodes = NotBoot -- is regular mod or signature + | otherwise = IsBoot + moduleGraphNodes :: Bool -> [ModSummary] - -> (Graph SummaryNode, IsBootInterface -> ModuleName -> Maybe SummaryNode) + -> (Graph SummaryNode, ModuleNameWithIsBoot -> Maybe SummaryNode) moduleGraphNodes drop_hs_boot_nodes summaries = (graphFromEdgedVerticesUniq nodes, lookup_node) where numbered_summaries = zip summaries [1..] - lookup_node :: IsBootInterface -> ModuleName -> Maybe SummaryNode - lookup_node hs_src mod = Map.lookup - (GWIB { gwib_mod = mod, gwib_isBoot = hs_src }) - node_map + lookup_node :: ModuleNameWithIsBoot -> Maybe SummaryNode + lookup_node mnwib = Map.lookup mnwib node_map - lookup_key :: IsBootInterface -> ModuleName -> Maybe Int - lookup_key hs_src mod = fmap summaryNodeKey (lookup_node hs_src mod) + lookup_key :: ModuleNameWithIsBoot -> Maybe Int + lookup_key = fmap summaryNodeKey . lookup_node node_map :: NodeMap SummaryNode - node_map = Map.fromList [ ( GWIB - { gwib_mod = moduleName $ ms_mod s - , gwib_isBoot = hscSourceToIsBoot $ ms_hsc_src s - } - , node - ) + node_map = Map.fromList [ (mkHomeBuildModule s, node) | node <- nodes - , let s = summaryNodeSummary node ] + , let s = summaryNodeSummary node + ] -- We use integers as the keys for the SCC algorithm nodes :: [SummaryNode] - nodes = [ DigraphNode s key out_keys + nodes = [ DigraphNode s key $ out_edge_keys $ unfilteredEdges drop_hs_boot_nodes s | (s, key) <- numbered_summaries -- Drop the hi-boot ones if told to do so , not (isBootSummary s == IsBoot && drop_hs_boot_nodes) - , let out_keys = out_edge_keys hs_boot_key (map unLoc (ms_home_srcimps s)) ++ - out_edge_keys NotBoot (map unLoc (ms_home_imps s)) ++ - (-- see [boot-edges] below - if drop_hs_boot_nodes || ms_hsc_src s == HsBootFile - then [] - else case lookup_key IsBoot (ms_mod_name s) of - Nothing -> [] - Just k -> [k]) ] - - -- [boot-edges] if this is a .hs and there is an equivalent - -- .hs-boot, add a link from the former to the latter. This - -- has the effect of detecting bogus cases where the .hs-boot - -- depends on the .hs, by introducing a cycle. Additionally, - -- it ensures that we will always process the .hs-boot before - -- the .hs, and so the HomePackageTable will always have the - -- most up to date information. - - -- Drop hs-boot nodes by using HsSrcFile as the key - hs_boot_key | drop_hs_boot_nodes = NotBoot -- is regular mod or signature - | otherwise = IsBoot + ] - out_edge_keys :: IsBootInterface -> [ModuleName] -> [Int] - out_edge_keys hi_boot ms = mapMaybe (lookup_key hi_boot) ms + out_edge_keys :: [ModuleNameWithIsBoot] -> [Int] + out_edge_keys = mapMaybe lookup_key -- If we want keep_hi_boot_nodes, then we do lookup_key with -- IsBoot; else False ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1628,6 +1628,12 @@ instance types, which makes things like the instance above become illegal. For the sake of consistency, we also disallow nested contexts, even though they don't have the same strange interaction with ScopedTypeVariables. +Just as we forbid nested `forall`s and contexts in normal instance +declarations, we also forbid them in SPECIALISE instance pragmas (#18455). +Unlike normal instance declarations, ScopedTypeVariables don't have any impact +on SPECIALISE instance pragmas, but we use the same validity checks for +SPECIALISE instance pragmas anyway to be consistent. + ----- -- Wrinkle: Derived instances ----- ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -43,7 +43,8 @@ import GHC.Rename.Fixity import GHC.Rename.Utils ( HsDocContext(..), mapFvRn, extendTyVarEnvFVRn , checkDupRdrNames, warnUnusedLocalBinds , checkUnusedRecordWildcard - , checkDupAndShadowedNames, bindLocalNamesFV ) + , checkDupAndShadowedNames, bindLocalNamesFV + , addNoNestedForallsContextsErr, checkInferredVars ) import GHC.Driver.Session import GHC.Unit.Module import GHC.Types.Name @@ -955,7 +956,7 @@ renameSig _ (IdSig _ x) renameSig ctxt sig@(TypeSig _ vs ty) = do { new_vs <- mapM (lookupSigOccRn ctxt sig) vs ; let doc = TypeSigCtx (ppr_sig_bndrs vs) - ; (new_ty, fvs) <- rnHsSigWcType doc Nothing ty + ; (new_ty, fvs) <- rnHsSigWcType doc ty ; return (TypeSig noExtField new_vs new_ty, fvs) } renameSig ctxt sig@(ClassOpSig _ is_deflt vs ty) @@ -963,20 +964,25 @@ renameSig ctxt sig@(ClassOpSig _ is_deflt vs ty) ; when (is_deflt && not defaultSigs_on) $ addErr (defaultSigErr sig) ; new_v <- mapM (lookupSigOccRn ctxt sig) vs - ; (new_ty, fvs) <- rnHsSigType ty_ctxt TypeLevel inf_msg ty + ; (new_ty, fvs) <- rnHsSigType ty_ctxt TypeLevel ty ; return (ClassOpSig noExtField is_deflt new_v new_ty, fvs) } where (v1:_) = vs ty_ctxt = GenericCtx (text "a class method signature for" <+> quotes (ppr v1)) - inf_msg = if is_deflt - then Just (text "A default type signature cannot contain inferred type variables") - else Nothing renameSig _ (SpecInstSig _ src ty) - = do { (new_ty, fvs) <- rnHsSigType SpecInstSigCtx TypeLevel inf_msg ty + = do { checkInferredVars doc inf_msg ty + ; (new_ty, fvs) <- rnHsSigType doc TypeLevel ty + -- Check if there are any nested `forall`s or contexts, which are + -- illegal in the type of an instance declaration (see + -- Note [No nested foralls or contexts in instance types] in + -- GHC.Hs.Type). + ; addNoNestedForallsContextsErr doc (text "SPECIALISE instance type") + (getLHsInstDeclHead new_ty) ; return (SpecInstSig noExtField src new_ty,fvs) } where + doc = SpecInstSigCtx inf_msg = Just (text "Inferred type variables are not allowed") -- {-# SPECIALISE #-} pragmas can refer to imported Ids @@ -993,7 +999,7 @@ renameSig ctxt sig@(SpecSig _ v tys inl) ty_ctxt = GenericCtx (text "a SPECIALISE signature for" <+> quotes (ppr v)) do_one (tys,fvs) ty - = do { (new_ty, fvs_ty) <- rnHsSigType ty_ctxt TypeLevel Nothing ty + = do { (new_ty, fvs_ty) <- rnHsSigType ty_ctxt TypeLevel ty ; return ( new_ty:tys, fvs_ty `plusFV` fvs) } renameSig ctxt sig@(InlineSig _ v s) @@ -1010,7 +1016,7 @@ renameSig ctxt sig@(MinimalSig _ s (L l bf)) renameSig ctxt sig@(PatSynSig _ vs ty) = do { new_vs <- mapM (lookupSigOccRn ctxt sig) vs - ; (ty', fvs) <- rnHsSigType ty_ctxt TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType ty_ctxt TypeLevel ty ; return (PatSynSig noExtField new_vs ty', fvs) } where ty_ctxt = GenericCtx (text "a pattern synonym signature for" ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -317,7 +317,7 @@ rnExpr (RecordUpd { rupd_expr = expr, rupd_flds = rbinds }) , fvExpr `plusFV` fvRbinds) } rnExpr (ExprWithTySig _ expr pty) - = do { (pty', fvTy) <- rnHsSigWcType ExprWithTySigCtx Nothing pty + = do { (pty', fvTy) <- rnHsSigWcType ExprWithTySigCtx pty ; (expr', fvExpr) <- bindSigTyVarsFV (hsWcScopedTvs pty') $ rnLExpr expr ; return (ExprWithTySig noExtField expr' pty', fvExpr `plusFV` fvTy) } ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -39,7 +39,6 @@ import GHC.Prelude import {-# SOURCE #-} GHC.Rename.Splice( rnSpliceType ) -import GHC.Core.Type import GHC.Driver.Session import GHC.Hs import GHC.Rename.Doc ( rnLHsDoc, rnMbLHsDoc ) @@ -68,7 +67,7 @@ import GHC.Data.FastString import GHC.Data.Maybe import qualified GHC.LanguageExtensions as LangExt -import Data.List ( nubBy, partition, find ) +import Data.List ( nubBy, partition ) import Control.Monad ( unless, when ) #include "HsVersions.h" @@ -124,19 +123,16 @@ data HsSigWcTypeScoping -- "GHC.Hs.Type". rnHsSigWcType :: HsDocContext - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. -> LHsSigWcType GhcPs -> RnM (LHsSigWcType GhcRn, FreeVars) -rnHsSigWcType doc inf_err (HsWC { hswc_body = HsIB { hsib_body = hs_ty }}) - = rn_hs_sig_wc_type BindUnlessForall doc inf_err hs_ty $ \nwcs imp_tvs body -> +rnHsSigWcType doc (HsWC { hswc_body = HsIB { hsib_body = hs_ty }}) + = rn_hs_sig_wc_type BindUnlessForall doc hs_ty $ \nwcs imp_tvs body -> let ib_ty = HsIB { hsib_ext = imp_tvs, hsib_body = body } wc_ty = HsWC { hswc_ext = nwcs, hswc_body = ib_ty } in pure (wc_ty, emptyFVs) rnHsPatSigType :: HsSigWcTypeScoping - -> HsDocContext -> Maybe SDoc + -> HsDocContext -> HsPatSigType GhcPs -> (HsPatSigType GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) @@ -147,10 +143,10 @@ rnHsPatSigType :: HsSigWcTypeScoping -- Wildcards are allowed -- -- See Note [Pattern signature binders and scoping] in GHC.Hs.Type -rnHsPatSigType scoping ctx inf_err sig_ty thing_inside +rnHsPatSigType scoping ctx sig_ty thing_inside = do { ty_sig_okay <- xoptM LangExt.ScopedTypeVariables ; checkErr ty_sig_okay (unexpectedPatSigTypeErr sig_ty) - ; rn_hs_sig_wc_type scoping ctx inf_err (hsPatSigType sig_ty) $ + ; rn_hs_sig_wc_type scoping ctx (hsPatSigType sig_ty) $ \nwcs imp_tvs body -> do { let sig_names = HsPSRn { hsps_nwcs = nwcs, hsps_imp_tvs = imp_tvs } sig_ty' = HsPS { hsps_ext = sig_names, hsps_body = body } @@ -158,16 +154,15 @@ rnHsPatSigType scoping ctx inf_err sig_ty thing_inside } } -- The workhorse for rnHsSigWcType and rnHsPatSigType. -rn_hs_sig_wc_type :: HsSigWcTypeScoping -> HsDocContext -> Maybe SDoc +rn_hs_sig_wc_type :: HsSigWcTypeScoping -> HsDocContext -> LHsType GhcPs -> ([Name] -- Wildcard names -> [Name] -- Implicitly bound type variable names -> LHsType GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) -rn_hs_sig_wc_type scoping ctxt inf_err hs_ty thing_inside - = do { check_inferred_vars ctxt inf_err hs_ty - ; free_vars <- filterInScopeM (extractHsTyRdrTyVars hs_ty) +rn_hs_sig_wc_type scoping ctxt hs_ty thing_inside + = do { free_vars <- filterInScopeM (extractHsTyRdrTyVars hs_ty) ; (nwc_rdrs', tv_rdrs) <- partition_nwcs free_vars ; let nwc_rdrs = nubL nwc_rdrs' ; implicit_bndrs <- case scoping of @@ -318,17 +313,13 @@ of the HsWildCardBndrs structure, and we are done. rnHsSigType :: HsDocContext -> TypeOrKind - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. -> LHsSigType GhcPs -> RnM (LHsSigType GhcRn, FreeVars) -- Used for source-language type signatures -- that cannot have wildcards -rnHsSigType ctx level inf_err (HsIB { hsib_body = hs_ty }) +rnHsSigType ctx level (HsIB { hsib_body = hs_ty }) = do { traceRn "rnHsSigType" (ppr hs_ty) ; rdr_env <- getLocalRdrEnv - ; check_inferred_vars ctx inf_err hs_ty ; vars0 <- forAllOrNothing (isLHsForAllTy hs_ty) $ filterInScope rdr_env $ extractHsTyRdrTyVars hs_ty @@ -415,26 +406,6 @@ type signature, since the type signature implicitly carries their binding sites. This is less precise, but more accurate. -} -check_inferred_vars :: HsDocContext - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. - -> LHsType GhcPs - -> RnM () -check_inferred_vars _ Nothing _ = return () -check_inferred_vars ctxt (Just msg) ty = - let bndrs = forallty_bndrs ty - in case find ((==) InferredSpec . hsTyVarBndrFlag) bndrs of - Nothing -> return () - Just _ -> addErr $ withHsDocContext ctxt msg - where - forallty_bndrs :: LHsType GhcPs -> [HsTyVarBndr Specificity GhcPs] - forallty_bndrs (L _ ty) = case ty of - HsParTy _ ty' -> forallty_bndrs ty' - HsForAllTy { hst_tele = HsForAllInvis { hsf_invis_bndrs = tvs }} - -> map unLoc tvs - _ -> [] - {- ****************************************************** * * LHsType and HsType ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -34,7 +34,8 @@ import GHC.Rename.Utils ( HsDocContext(..), mapFvRn, bindLocalNames , checkDupRdrNames, bindLocalNamesFV , checkShadowedRdrNames, warnUnusedTypePatterns , extendTyVarEnvFVRn, newLocalBndrsRn - , withHsDocContext ) + , withHsDocContext, noNestedForallsContextsErr + , addNoNestedForallsContextsErr, checkInferredVars ) import GHC.Rename.Unbound ( mkUnboundName, notInScopeErr ) import GHC.Rename.Names import GHC.Rename.Doc ( rnHsDoc, rnMbLHsDoc ) @@ -65,7 +66,6 @@ import GHC.Data.List.SetOps ( findDupsEq, removeDups, equivClasses ) import GHC.Data.Graph.Directed ( SCC, flattenSCC, flattenSCCs, Node(..) , stronglyConnCompFromEdgedVerticesUniq ) import GHC.Types.Unique.Set -import GHC.Data.Maybe ( whenIsJust ) import GHC.Data.OrdList import qualified GHC.LanguageExtensions as LangExt @@ -371,7 +371,7 @@ rnHsForeignDecl :: ForeignDecl GhcPs -> RnM (ForeignDecl GhcRn, FreeVars) rnHsForeignDecl (ForeignImport { fd_name = name, fd_sig_ty = ty, fd_fi = spec }) = do { topEnv :: HscEnv <- getTopEnv ; name' <- lookupLocatedTopBndrRn name - ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel ty -- Mark any PackageTarget style imports as coming from the current package ; let unitId = homeUnit $ hsc_dflags topEnv @@ -383,7 +383,7 @@ rnHsForeignDecl (ForeignImport { fd_name = name, fd_sig_ty = ty, fd_fi = spec }) rnHsForeignDecl (ForeignExport { fd_name = name, fd_sig_ty = ty, fd_fe = spec }) = do { name' <- lookupLocatedOccRn name - ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel ty ; return (ForeignExport { fd_e_ext = noExtField , fd_name = name', fd_sig_ty = ty' , fd_fe = spec } @@ -424,11 +424,11 @@ patchCCallTarget unit callTarget = rnSrcInstDecl :: InstDecl GhcPs -> RnM (InstDecl GhcRn, FreeVars) rnSrcInstDecl (TyFamInstD { tfid_inst = tfi }) - = do { (tfi', fvs) <- rnTyFamInstDecl NonAssocTyFamEqn tfi + = do { (tfi', fvs) <- rnTyFamInstDecl (NonAssocTyFamEqn NotClosedTyFam) tfi ; return (TyFamInstD { tfid_ext = noExtField, tfid_inst = tfi' }, fvs) } rnSrcInstDecl (DataFamInstD { dfid_inst = dfi }) - = do { (dfi', fvs) <- rnDataFamInstDecl NonAssocTyFamEqn dfi + = do { (dfi', fvs) <- rnDataFamInstDecl (NonAssocTyFamEqn NotClosedTyFam) dfi ; return (DataFamInstD { dfid_ext = noExtField, dfid_inst = dfi' }, fvs) } rnSrcInstDecl (ClsInstD { cid_inst = cid }) @@ -602,13 +602,14 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds , cid_sigs = uprags, cid_tyfam_insts = ats , cid_overlap_mode = oflag , cid_datafam_insts = adts }) - = do { (inst_ty', inst_fvs) <- rnHsSigType ctxt TypeLevel inf_err inst_ty + = do { checkInferredVars ctxt inf_err inst_ty + ; (inst_ty', inst_fvs) <- rnHsSigType ctxt TypeLevel inst_ty ; let (ktv_names, _, head_ty') = splitLHsInstDeclTy inst_ty' -- Check if there are any nested `forall`s or contexts, which are -- illegal in the type of an instance declaration (see -- Note [No nested foralls or contexts in instance types] in -- GHC.Hs.Type)... - mb_nested_msg = no_nested_foralls_contexts_err + mb_nested_msg = noNestedForallsContextsErr (text "Instance head") head_ty' -- ...then check if the instance head is actually headed by a -- class type constructor... @@ -628,17 +629,10 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds -- with an error message if there isn't one. To avoid excessive -- amounts of error messages, we will only report one of the errors -- from mb_nested_msg or eith_cls at a time. - ; cls <- case maybe eith_cls Left mb_nested_msg of - Right cls -> pure cls - Left (l, err_msg) -> do - -- The instance is malformed. We'd still like - -- to make *some* progress (rather than failing outright), so - -- we report an error and continue for as long as we can. - -- Importantly, this error should be thrown before we reach the - -- typechecker, lest we encounter different errors that are - -- hopelessly confusing (such as the one in #16114). - addErrAt l $ withHsDocContext ctxt err_msg - pure $ mkUnboundName (mkTcOccFS (fsLit "")) + ; cls <- case (mb_nested_msg, eith_cls) of + (Nothing, Right cls) -> pure cls + (Just err1, _) -> bail_out err1 + (_, Left err2) -> bail_out err2 -- Rename the bindings -- The typechecker (not the renamer) checks that all @@ -680,6 +674,15 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds ctxt = GenericCtx $ text "an instance declaration" inf_err = Just (text "Inferred type variables are not allowed") + -- The instance is malformed. We'd still like to make *some* progress + -- (rather than failing outright), so we report an error and continue for + -- as long as we can. Importantly, this error should be thrown before we + -- reach the typechecker, lest we encounter different errors that are + -- hopelessly confusing (such as the one in #16114). + bail_out (l, err_msg) = do + addErrAt l $ withHsDocContext ctxt err_msg + pure $ mkUnboundName (mkTcOccFS (fsLit "")) + rnFamInstEqn :: HsDocContext -> AssocTyFamInfo -> FreeKiTyVars @@ -760,8 +763,12 @@ rnFamInstEqn doc atfi rhs_kvars all_nms = all_imp_var_names ++ hsLTyVarNames bndrs' ; warnUnusedTypePatterns all_nms nms_used - ; let all_fvs = (rhs_fvs `plusFV` pat_fvs) `addOneFV` unLoc tycon' - -- type instance => use, hence addOneFV + ; let eqn_fvs = rhs_fvs `plusFV` pat_fvs + -- See Note [Type family equations and occurrences] + all_fvs = case atfi of + NonAssocTyFamEqn ClosedTyFam + -> eqn_fvs + _ -> eqn_fvs `addOneFV` unLoc tycon' ; return (HsIB { hsib_ext = all_imp_var_names -- Note [Wildcards in family instances] , hsib_body @@ -776,14 +783,14 @@ rnFamInstEqn doc atfi rhs_kvars -- The parent class, if we are dealing with an associated type family -- instance. mb_cls = case atfi of - NonAssocTyFamEqn -> Nothing + NonAssocTyFamEqn _ -> Nothing AssocTyFamDeflt cls -> Just cls AssocTyFamInst cls _ -> Just cls -- The type variables from the instance head, if we are dealing with an -- associated type family instance. inst_tvs = case atfi of - NonAssocTyFamEqn -> [] + NonAssocTyFamEqn _ -> [] AssocTyFamDeflt _ -> [] AssocTyFamInst _ inst_tvs -> inst_tvs @@ -806,48 +813,62 @@ rnTyFamInstDecl :: AssocTyFamInfo -> TyFamInstDecl GhcPs -> RnM (TyFamInstDecl GhcRn, FreeVars) rnTyFamInstDecl atfi (TyFamInstDecl { tfid_eqn = eqn }) - = do { (eqn', fvs) <- rnTyFamInstEqn atfi NotClosedTyFam eqn + = do { (eqn', fvs) <- rnTyFamInstEqn atfi eqn ; return (TyFamInstDecl { tfid_eqn = eqn' }, fvs) } -- | Tracks whether we are renaming: -- -- 1. A type family equation that is not associated --- with a parent type class ('NonAssocTyFamEqn') +-- with a parent type class ('NonAssocTyFamEqn'). Examples: +-- +-- @ +-- type family F a +-- type instance F Int = Bool -- NonAssocTyFamEqn NotClosed +-- +-- type family G a where +-- G Int = Bool -- NonAssocTyFamEqn Closed +-- @ +-- +-- 2. An associated type family default declaration ('AssocTyFamDeflt'). +-- Example: -- --- 2. An associated type family default declaration ('AssocTyFamDeflt') +-- @ +-- class C a where +-- type A a +-- type instance A a = a -> a -- AssocTyFamDeflt C +-- @ -- --- 3. An associated type family instance declaration ('AssocTyFamInst') +-- 3. An associated type family instance declaration ('AssocTyFamInst'). +-- Example: +-- +-- @ +-- instance C a => C [a] where +-- type A [a] = Bool -- AssocTyFamInst C [a] +-- @ data AssocTyFamInfo = NonAssocTyFamEqn - | AssocTyFamDeflt Name -- Name of the parent class - | AssocTyFamInst Name -- Name of the parent class - [Name] -- Names of the tyvars of the parent instance decl + ClosedTyFamInfo -- Is this a closed type family? + | AssocTyFamDeflt + Name -- Name of the parent class + | AssocTyFamInst + Name -- Name of the parent class + [Name] -- Names of the tyvars of the parent instance decl -- | Tracks whether we are renaming an equation in a closed type family -- equation ('ClosedTyFam') or not ('NotClosedTyFam'). data ClosedTyFamInfo = NotClosedTyFam - | ClosedTyFam (Located RdrName) Name - -- The names (RdrName and Name) of the closed type family + | ClosedTyFam rnTyFamInstEqn :: AssocTyFamInfo - -> ClosedTyFamInfo -> TyFamInstEqn GhcPs -> RnM (TyFamInstEqn GhcRn, FreeVars) -rnTyFamInstEqn atfi ctf_info +rnTyFamInstEqn atfi eqn@(HsIB { hsib_body = FamEqn { feqn_tycon = tycon , feqn_rhs = rhs }}) - = do { let rhs_kvs = extractHsTyRdrTyVarsKindVars rhs - ; (eqn'@(HsIB { hsib_body = - FamEqn { feqn_tycon = L _ tycon' }}), fvs) - <- rnFamInstEqn (TySynCtx tycon) atfi rhs_kvs eqn rnTySyn - ; case ctf_info of - NotClosedTyFam -> pure () - ClosedTyFam fam_rdr_name fam_name -> - checkTc (fam_name == tycon') $ - withHsDocContext (TyFamilyCtx fam_rdr_name) $ - wrongTyFamName fam_name tycon' - ; pure (eqn', fvs) } + = rnFamInstEqn (TySynCtx tycon) atfi rhs_kvs eqn rnTySyn + where + rhs_kvs = extractHsTyRdrTyVarsKindVars rhs rnTyFamDefltDecl :: Name -> TyFamDefltDecl GhcPs @@ -995,6 +1016,51 @@ was previously bound by the `instance C (Maybe a)` part. (see #16116). In each case, the function which detects improperly bound variables on the RHS is GHC.Tc.Validity.checkValidFamPats. + +Note [Type family equations and occurrences] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In most data/type family equations, the type family name used in the equation +is treated as an occurrence. For example: + + module A where + type family F a + + module B () where + import B (F) + type instance F Int = Bool + +We do not want to warn about `F` being unused in the module `B`, as the +instance constitutes a use site for `F`. The exception to this rule is closed +type families, whose equations constitute a definition, not occurrences. For +example: + + module C () where + type family CF a where + CF Char = Float + +Here, we /do/ want to warn that `CF` is unused in the module `C`, as it is +defined but not used (#18470). + +GHC accomplishes this in rnFamInstEqn when determining the set of free +variables to return at the end. If renaming a data family or open type family +equation, we add the name of the type family constructor to the set of returned +free variables to ensure that the name is marked as an occurrence. If renaming +a closed type family equation, we avoid adding the type family constructor name +to the free variables. This is quite simple, but it is not a perfect solution. +Consider this example: + + module X () where + type family F a where + F Int = Bool + F Double = F Int + +At present, GHC will treat any use of a type family constructor on the RHS of a +type family equation as an occurrence. Since `F` is used on the RHS of the +second equation of `F`, it is treated as an occurrence, causing `F` not to be +warned about. This is not ideal, since `F` isn't exported—it really /should/ +cause a warning to be emitted. There is some discussion in #10089/#12920 about +how this limitation might be overcome, but until then, we stick to the +simplistic solution above, as it fixes the egregious bug in #18470. -} @@ -1010,22 +1076,22 @@ rnSrcDerivDecl :: DerivDecl GhcPs -> RnM (DerivDecl GhcRn, FreeVars) rnSrcDerivDecl (DerivDecl _ ty mds overlap) = do { standalone_deriv_ok <- xoptM LangExt.StandaloneDeriving ; unless standalone_deriv_ok (addErr standaloneDerivErr) - ; (mds', ty', fvs) - <- rnLDerivStrategy ctxt mds $ rnHsSigWcType ctxt inf_err ty + ; checkInferredVars ctxt inf_err nowc_ty + ; (mds', ty', fvs) <- rnLDerivStrategy ctxt mds $ rnHsSigWcType ctxt ty -- Check if there are any nested `forall`s or contexts, which are -- illegal in the type of an instance declaration (see -- Note [No nested foralls or contexts in instance types] in -- GHC.Hs.Type). - ; whenIsJust (no_nested_foralls_contexts_err - (text "Standalone-derived instance head") - (getLHsInstDeclHead $ dropWildCards ty')) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext ctxt err_msg + ; addNoNestedForallsContextsErr ctxt + (text "Standalone-derived instance head") + (getLHsInstDeclHead $ dropWildCards ty') ; warnNoDerivStrat mds' loc ; return (DerivDecl noExtField ty' mds' overlap, fvs) } where ctxt = DerivDeclCtx inf_err = Just (text "Inferred type variables are not allowed") - loc = getLoc $ hsib_body $ hswc_body ty + loc = getLoc $ hsib_body nowc_ty + nowc_ty = dropWildCards ty standaloneDerivErr :: SDoc standaloneDerivErr @@ -1091,7 +1157,7 @@ bindRuleTmVars doc tyvs vars names thing_inside go ((L l (RuleBndrSig _ (L loc _) bsig)) : vars) (n : ns) thing_inside - = rnHsPatSigType bind_free_tvs doc Nothing bsig $ \ bsig' -> + = rnHsPatSigType bind_free_tvs doc bsig $ \ bsig' -> go vars ns $ \ vars' -> thing_inside (L l (RuleBndrSig noExtField (L loc n) bsig') : vars') @@ -1431,7 +1497,7 @@ rnStandaloneKindSignature tc_names (StandaloneKindSig _ v ki) ; unless standalone_ki_sig_ok $ addErr standaloneKiSigErr ; new_v <- lookupSigCtxtOccRn (TopSigCtxt tc_names) (text "standalone kind signature") v ; let doc = StandaloneKindSigCtx (ppr v) - ; (new_ki, fvs) <- rnHsSigType doc KindLevel Nothing ki + ; (new_ki, fvs) <- rnHsSigType doc KindLevel ki ; return (StandaloneKindSig noExtField new_v new_ki, fvs) } where @@ -1841,15 +1907,14 @@ rnLHsDerivingClause doc rn_clause_pred :: LHsSigType GhcPs -> RnM (LHsSigType GhcRn, FreeVars) rn_clause_pred pred_ty = do let inf_err = Just (text "Inferred type variables are not allowed") - ret@(pred_ty', _) <- rnHsSigType doc TypeLevel inf_err pred_ty + checkInferredVars doc inf_err pred_ty + ret@(pred_ty', _) <- rnHsSigType doc TypeLevel pred_ty -- Check if there are any nested `forall`s, which are illegal in a -- `deriving` clause. -- See Note [No nested foralls or contexts in instance types] -- (Wrinkle: Derived instances) in GHC.Hs.Type. - whenIsJust (no_nested_foralls_contexts_err - (text "Derived class type") - (getLHsInstDeclHead pred_ty')) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext doc err_msg + addNoNestedForallsContextsErr doc (text "Derived class type") + (getLHsInstDeclHead pred_ty') pure ret rnLDerivStrategy :: forall a. @@ -1883,7 +1948,8 @@ rnLDerivStrategy doc mds thing_inside AnyclassStrategy -> boring_case AnyclassStrategy NewtypeStrategy -> boring_case NewtypeStrategy ViaStrategy via_ty -> - do (via_ty', fvs1) <- rnHsSigType doc TypeLevel inf_err via_ty + do checkInferredVars doc inf_err via_ty + (via_ty', fvs1) <- rnHsSigType doc TypeLevel via_ty let HsIB { hsib_ext = via_imp_tvs , hsib_body = via_body } = via_ty' (via_exp_tv_bndrs, via_rho) = splitLHsForAllTyInvis_KP via_body @@ -1893,10 +1959,8 @@ rnLDerivStrategy doc mds thing_inside -- `via` type. -- See Note [No nested foralls or contexts in instance types] -- (Wrinkle: Derived instances) in GHC.Hs.Type. - whenIsJust (no_nested_foralls_contexts_err - (quotes (text "via") <+> text "type") - via_rho) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext doc err_msg + addNoNestedForallsContextsErr doc + (quotes (text "via") <+> text "type") via_rho (thing, fvs2) <- extendTyVarEnvFVRn via_tvs thing_inside pure (ViaStrategy via_ty', thing, fvs1 `plusFV` fvs2) @@ -1947,7 +2011,7 @@ rnFamDecl mb_cls (FamilyDecl { fdLName = tycon, fdTyVars = tyvars ; injectivity' <- traverse (rnInjectivityAnn tyvars' res_sig') injectivity ; return ( (tyvars', res_sig', injectivity') , fv_kind ) } - ; (info', fv2) <- rn_info tycon' info + ; (info', fv2) <- rn_info info ; return (FamilyDecl { fdExt = noExtField , fdLName = tycon', fdTyVars = tyvars' , fdFixity = fixity @@ -1959,18 +2023,16 @@ rnFamDecl mb_cls (FamilyDecl { fdLName = tycon, fdTyVars = tyvars kvs = extractRdrKindSigVars res_sig ---------------------- - rn_info :: Located Name - -> FamilyInfo GhcPs -> RnM (FamilyInfo GhcRn, FreeVars) - rn_info (L _ fam_name) (ClosedTypeFamily (Just eqns)) + rn_info :: FamilyInfo GhcPs -> RnM (FamilyInfo GhcRn, FreeVars) + rn_info (ClosedTypeFamily (Just eqns)) = do { (eqns', fvs) - <- rnList (rnTyFamInstEqn NonAssocTyFamEqn (ClosedTyFam tycon fam_name)) + <- rnList (rnTyFamInstEqn (NonAssocTyFamEqn ClosedTyFam)) eqns -- no class context - eqns ; return (ClosedTypeFamily (Just eqns'), fvs) } - rn_info _ (ClosedTypeFamily Nothing) + rn_info (ClosedTypeFamily Nothing) = return (ClosedTypeFamily Nothing, emptyFVs) - rn_info _ OpenTypeFamily = return (OpenTypeFamily, emptyFVs) - rn_info _ DataFamily = return (DataFamily, emptyFVs) + rn_info OpenTypeFamily = return (OpenTypeFamily, emptyFVs) + rn_info DataFamily = return (DataFamily, emptyFVs) rnFamResultSig :: HsDocContext -> FamilyResultSig GhcPs @@ -2114,13 +2176,6 @@ are no data constructors we allow h98_style = True * * ***************************************************** -} ---------------- -wrongTyFamName :: Name -> Name -> SDoc -wrongTyFamName fam_tc_name eqn_tc_name - = hang (text "Mismatched type name in type family instance.") - 2 (vcat [ text "Expected:" <+> ppr fam_tc_name - , text " Actual:" <+> ppr eqn_tc_name ]) - ----------------- rnConDecls :: [LConDecl GhcPs] -> RnM ([LConDecl GhcRn], FreeVars) rnConDecls = mapFvRn (wrapLocFstM rnConDecl) @@ -2213,7 +2268,7 @@ rnConDecl (XConDecl (ConDeclGADTPrefixPs { con_gp_names = names, con_gp_ty = ty ; mb_doc' <- rnMbLHsDoc mb_doc ; let ctxt = ConDeclCtx new_names - ; (ty', fvs) <- rnHsSigType ctxt TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType ctxt TypeLevel ty ; linearTypes <- xopt LangExt.LinearTypes <$> getDynFlags -- Now that operator precedence has been resolved, we can split the @@ -2232,10 +2287,8 @@ rnConDecl (XConDecl (ConDeclGADTPrefixPs { con_gp_names = names, con_gp_ty = ty -- Ensure that there are no nested `forall`s or contexts, per -- Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts) -- in GHC.Hs.Type. - ; whenIsJust (no_nested_foralls_contexts_err - (text "GADT constructor type signature") - res_ty) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext ctxt err_msg + ; addNoNestedForallsContextsErr ctxt + (text "GADT constructor type signature") res_ty ; traceRn "rnConDecl (ConDeclGADTPrefixPs)" (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) @@ -2273,41 +2326,6 @@ rnConDeclDetails con doc (RecCon (L l fields)) -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn ; return (RecCon (L l new_fields), fvs) } --- | Examines a non-outermost type for @forall at s or contexts, which are assumed --- to be nested. Returns @'Just' err_msg@ if such a @forall@ or context is --- found, and returns @Nothing@ otherwise. --- --- This is currently used in two places: --- --- * In GADT constructor types (in 'rnConDecl'). --- See @Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts)@ --- in "GHC.Hs.Type". --- --- * In instance declaration types (in 'rnClsIntDecl' and 'rnSrcDerivDecl'). --- See @Note [No nested foralls or contexts in instance types]@ in --- "GHC.Hs.Type". -no_nested_foralls_contexts_err :: SDoc -> LHsType GhcRn -> Maybe (SrcSpan, SDoc) -no_nested_foralls_contexts_err what lty = - case ignoreParens lty of - L l (HsForAllTy { hst_tele = tele }) - | HsForAllVis{} <- tele - -- The only two places where this function is called correspond to - -- types of terms, so we give a slightly more descriptive error - -- message in the event that they contain visible dependent - -- quantification (currently only allowed in kinds). - -> Just (l, vcat [ text "Illegal visible, dependent quantification" <+> - text "in the type of a term" - , text "(GHC does not yet support this)" ]) - | HsForAllInvis{} <- tele - -> Just (l, nested_foralls_contexts_err) - L l (HsQualTy {}) - -> Just (l, nested_foralls_contexts_err) - _ -> Nothing - where - nested_foralls_contexts_err = - what <+> text "cannot contain nested" - <+> quotes forAllLit <> text "s or contexts" - ------------------------------------------------- -- | Brings pattern synonym names and also pattern synonym selectors ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -236,19 +236,30 @@ newPatName (LetMk is_top fix_env) rdr_name do { name <- case is_top of NotTopLevel -> newLocalBndrRn rdr_name TopLevel -> newTopSrcBinder rdr_name - ; bindLocalNames [name] $ -- Do *not* use bindLocalNameFV here - -- See Note [View pattern usage] + ; bindLocalNames [name] $ + -- Do *not* use bindLocalNameFV here; + -- see Note [View pattern usage] + -- For the TopLevel case + -- see Note [bindLocalNames for an External name] addLocalFixities fix_env [name] $ thing_inside name }) - -- Note: the bindLocalNames is somewhat suspicious - -- because it binds a top-level name as a local name. - -- however, this binding seems to work, and it only exists for - -- the duration of the patterns and the continuation; - -- then the top-level name is added to the global env - -- before going on to the RHSes (see GHC.Rename.Module). +{- Note [bindLocalNames for an External name] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In the TopLevel case, the use of bindLocalNames here is somewhat +suspicious because it binds a top-level External name in the +LocalRdrEnv. c.f. Note [LocalRdrEnv] in GHC.Types.Name.Reader. + +However, this only happens when renaming the LHS (only) of a top-level +pattern binding. Even though this only the LHS, we need to bring the +binder into scope in the pattern itself in case the binder is used in +subsequent view patterns. A bit bizarre, something like + (x, Just y <- f x) = e + +Anyway, bindLocalNames does work, and the binding only exists for the +duration of the pattern; then the top-level name is added to the +global env before going on to the RHSes (see GHC.Rename.Module). -{- Note [View pattern usage] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -412,7 +423,7 @@ rnPatAndThen mk (SigPat x pat sig) ; return (SigPat x pat' sig' ) } where rnHsPatSigTypeAndThen :: HsPatSigType GhcPs -> CpsRn (HsPatSigType GhcRn) - rnHsPatSigTypeAndThen sig = CpsRn (rnHsPatSigType AlwaysBind PatCtx Nothing sig) + rnHsPatSigTypeAndThen sig = CpsRn (rnHsPatSigType AlwaysBind PatCtx sig) rnPatAndThen mk (LitPat x lit) | HsString src s <- lit ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -26,8 +26,10 @@ module GHC.Rename.Utils ( bindLocalNames, bindLocalNamesFV, - addNameClashErrRn, extendTyVarEnvFVRn + addNameClashErrRn, extendTyVarEnvFVRn, + checkInferredVars, + noNestedForallsContextsErr, addNoNestedForallsContextsErr ) where @@ -35,6 +37,7 @@ where import GHC.Prelude +import GHC.Core.Type import GHC.Hs import GHC.Types.Name.Reader import GHC.Driver.Types @@ -49,6 +52,7 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Types.Basic ( TopLevelFlag(..) ) import GHC.Data.List.SetOps ( removeDups ) +import GHC.Data.Maybe ( whenIsJust ) import GHC.Driver.Session import GHC.Data.FastString import Control.Monad @@ -176,6 +180,136 @@ checkShadowedOccs (global_env,local_env) get_loc_occ ns || xopt LangExt.RecordWildCards dflags) } is_shadowed_gre _other = return True +------------------------------------- +-- | Throw an error message if a user attempts to quantify an inferred type +-- variable in a place where specificity cannot be observed. For example, +-- @forall {a}. [a] -> [a]@ would be rejected to the inferred type variable +-- @{a}@, but @forall a. [a] -> [a]@ would be accepted. +-- See @Note [Unobservably inferred type variables]@. +checkInferredVars :: HsDocContext + -> Maybe SDoc + -- ^ The error msg if the signature is not allowed to contain + -- manually written inferred variables. + -> LHsSigType GhcPs + -> RnM () +checkInferredVars _ Nothing _ = return () +checkInferredVars ctxt (Just msg) ty = + let bndrs = forallty_bndrs (hsSigType ty) + in case find ((==) InferredSpec . hsTyVarBndrFlag) bndrs of + Nothing -> return () + Just _ -> addErr $ withHsDocContext ctxt msg + where + forallty_bndrs :: LHsType GhcPs -> [HsTyVarBndr Specificity GhcPs] + forallty_bndrs (L _ ty) = case ty of + HsParTy _ ty' -> forallty_bndrs ty' + HsForAllTy { hst_tele = HsForAllInvis { hsf_invis_bndrs = tvs }} + -> map unLoc tvs + _ -> [] + +{- +Note [Unobservably inferred type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +While GHC's parser allows the use of inferred type variables +(e.g., `forall {a}. <...>`) just about anywhere that type variable binders can +appear, there are some situations where the distinction between inferred and +specified type variables cannot be observed. For example, consider this +instance declaration: + + instance forall {a}. Eq (T a) where ... + +Making {a} inferred is pointless, as there is no way for user code to +"apply" an instance declaration in a way where the inferred/specified +distinction would make a difference. (Notably, there is no opportunity +for visible type application of an instance declaration.) Anyone who +writes such code is likely confused, so in an attempt to be helpful, +we emit an error message if a user writes code like this. The +checkInferredVars function is responsible for implementing this +restriction. + +It turns out to be somewhat cumbersome to enforce this restriction in +certain cases. Specifically: + +* Quantified constraints. In the type `f :: (forall {a}. C a) => Proxy Int`, + there is no way to observe that {a} is inferred. Nevertheless, actually + rejecting this code would be tricky, as we would need to reject + `forall {a}. <...>` as a constraint but *accept* other uses of + `forall {a}. <...>` as a type (e.g., `g :: (forall {a}. a -> a) -> b -> b`). + This is quite tedious to do in practice, so we don't bother. + +* Default method type signatures (#18432). These are tricky because inferred + type variables can appear nested, e.g., + + class C a where + m :: forall b. a -> b -> forall c. c -> c + default m :: forall b. a -> b -> forall {c}. c -> c + m _ _ = id + + Robustly checking for nested, inferred type variables ends up being a pain, + so we don't try to do this. + +For now, we simply allow inferred quantifiers to be specified here, +even though doing so is pointless. All we lose is a warning. + +Aside from the places where we already use checkInferredVars, most of +the other places where inferred vars don't make sense are in any case +already prohibited from having foralls /at all/. For example: + + instance forall a. forall {b}. Eq (Either a b) where ... + +Here the nested `forall {b}` is already prohibited. (See +Note [No nested foralls or contexts in instance types] in GHC.Hs.Type). +-} + +-- | Examines a non-outermost type for @forall at s or contexts, which are assumed +-- to be nested. For example, in the following declaration: +-- +-- @ +-- instance forall a. forall b. C (Either a b) +-- @ +-- +-- The outermost @forall a@ is fine, but the nested @forall b@ is not. We +-- invoke 'noNestedForallsContextsErr' on the type @forall b. C (Either a b)@ +-- to catch the nested @forall@ and create a suitable error message. +-- 'noNestedForallsContextsErr' returns @'Just' err_msg@ if such a @forall@ or +-- context is found, and returns @Nothing@ otherwise. +-- +-- This is currently used in the following places: +-- +-- * In GADT constructor types (in 'rnConDecl'). +-- See @Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts)@ +-- in "GHC.Hs.Type". +-- +-- * In instance declaration types (in 'rnClsIntDecl' and 'rnSrcDerivDecl' in +-- "GHC.Rename.Module" and 'renameSig' in "GHC.Rename.Bind"). +-- See @Note [No nested foralls or contexts in instance types]@ in +-- "GHC.Hs.Type". +noNestedForallsContextsErr :: SDoc -> LHsType GhcRn -> Maybe (SrcSpan, SDoc) +noNestedForallsContextsErr what lty = + case ignoreParens lty of + L l (HsForAllTy { hst_tele = tele }) + | HsForAllVis{} <- tele + -- The only two places where this function is called correspond to + -- types of terms, so we give a slightly more descriptive error + -- message in the event that they contain visible dependent + -- quantification (currently only allowed in kinds). + -> Just (l, vcat [ text "Illegal visible, dependent quantification" <+> + text "in the type of a term" + , text "(GHC does not yet support this)" ]) + | HsForAllInvis{} <- tele + -> Just (l, nested_foralls_contexts_err) + L l (HsQualTy {}) + -> Just (l, nested_foralls_contexts_err) + _ -> Nothing + where + nested_foralls_contexts_err = + what <+> text "cannot contain nested" + <+> quotes forAllLit <> text "s or contexts" + +-- | A common way to invoke 'noNestedForallsContextsErr'. +addNoNestedForallsContextsErr :: HsDocContext -> SDoc -> LHsType GhcRn -> RnM () +addNoNestedForallsContextsErr ctxt what lty = + whenIsJust (noNestedForallsContextsErr what lty) $ \(l, err_msg) -> + addErrAt l $ withHsDocContext ctxt err_msg {- ************************************************************************ ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -67,8 +67,8 @@ data AssocInstInfo } isNotAssociated :: AssocInstInfo -> Bool -isNotAssociated NotAssociated = True -isNotAssociated (InClsInst {}) = False +isNotAssociated (NotAssociated {}) = True +isNotAssociated (InClsInst {}) = False {- ******************************************************************* ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -2833,8 +2833,17 @@ kcTyFamInstEqn tc_fam_tc , text "feqn_pats =" <+> ppr hs_pats ]) -- this check reports an arity error instead of a kind error; easier for user ; let vis_pats = numVisibleArgs hs_pats + + -- First, check if we're dealing with a closed type family equation, and + -- if so, ensure that each equation's type constructor is for the right + -- type family. E.g. barf on + -- type family F a where { G Int = Bool } + ; checkTc (tc_fam_tc_name == eqn_tc_name) $ + wrongTyFamName tc_fam_tc_name eqn_tc_name + ; checkTc (vis_pats == vis_arity) $ wrongNumberOfParmsErr vis_arity + ; discardResult $ bindImplicitTKBndrs_Q_Tv imp_vars $ bindExplicitTKBndrs_Q_Tv AnyKind (mb_expl_bndrs `orElse` []) $ @@ -2848,7 +2857,7 @@ kcTyFamInstEqn tc_fam_tc } where vis_arity = length (tyConVisibleTyVars tc_fam_tc) - + tc_fam_tc_name = getName tc_fam_tc -------------------------- tcTyFamInstEqn :: TcTyCon -> AssocInstInfo -> LTyFamInstEqn GhcRn @@ -2858,22 +2867,22 @@ tcTyFamInstEqn :: TcTyCon -> AssocInstInfo -> LTyFamInstEqn GhcRn tcTyFamInstEqn fam_tc mb_clsinfo (L loc (HsIB { hsib_ext = imp_vars - , hsib_body = FamEqn { feqn_tycon = L _ eqn_tc_name - , feqn_bndrs = mb_expl_bndrs + , hsib_body = FamEqn { feqn_bndrs = mb_expl_bndrs , feqn_pats = hs_pats , feqn_rhs = hs_rhs_ty }})) - = ASSERT( getName fam_tc == eqn_tc_name ) - setSrcSpan loc $ + = setSrcSpan loc $ do { traceTc "tcTyFamInstEqn" $ vcat [ ppr fam_tc <+> ppr hs_pats , text "fam tc bndrs" <+> pprTyVars (tyConTyVars fam_tc) , case mb_clsinfo of - NotAssociated -> empty + NotAssociated {} -> empty InClsInst { ai_class = cls } -> text "class" <+> ppr cls <+> pprTyVars (classTyVars cls) ] -- First, check the arity of visible arguments -- If we wait until validity checking, we'll get kind errors -- below when an arity error will be much easier to understand. + -- Note that for closed type families, kcTyFamInstEqn has already + -- checked the arity previously. ; let vis_arity = length (tyConVisibleTyVars fam_tc) vis_pats = numVisibleArgs hs_pats ; checkTc (vis_pats == vis_arity) $ @@ -4919,6 +4928,12 @@ incoherentRoles = (text "Roles other than" <+> quotes (text "nominal") <+> text "for class parameters can lead to incoherence.") $$ (text "Use IncoherentInstances to allow this; bad role found") +wrongTyFamName :: Name -> Name -> SDoc +wrongTyFamName fam_tc_name eqn_tc_name + = hang (text "Mismatched type name in type family instance.") + 2 (vcat [ text "Expected:" <+> ppr fam_tc_name + , text " Actual:" <+> ppr eqn_tc_name ]) + addTyConCtxt :: TyCon -> TcM a -> TcM a addTyConCtxt tc = addTyConFlavCtxt name flav where ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -338,13 +338,24 @@ instance Ord RdrName where ************************************************************************ -} +{- Note [LocalRdrEnv] +~~~~~~~~~~~~~~~~~~~~~ +The LocalRdrEnv is used to store local bindings (let, where, lambda, case). + +* It is keyed by OccName, because we never use it for qualified names. + +* It maps the OccName to a Name. That Name is almost always an + Internal Name, but (hackily) it can be External too for top-level + pattern bindings. See Note [bindLocalNames for an External name] + in GHC.Rename.Pat + +* We keep the current mapping (lre_env), *and* the set of all Names in + scope (lre_in_scope). Reason: see Note [Splicing Exact names] in + GHC.Rename.Env. +-} + -- | Local Reader Environment --- --- This environment is used to store local bindings --- (@let@, @where@, lambda, @case@). --- It is keyed by OccName, because we never use it for qualified names --- We keep the current mapping, *and* the set of all Names in scope --- Reason: see Note [Splicing Exact names] in "GHC.Rename.Env" +-- See Note [LocalRdrEnv] data LocalRdrEnv = LRE { lre_env :: OccEnv Name , lre_in_scope :: NameSet } @@ -364,16 +375,15 @@ emptyLocalRdrEnv = LRE { lre_env = emptyOccEnv , lre_in_scope = emptyNameSet } extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv --- The Name should be a non-top-level thing +-- See Note [LocalRdrEnv] extendLocalRdrEnv lre@(LRE { lre_env = env, lre_in_scope = ns }) name - = WARN( isExternalName name, ppr name ) - lre { lre_env = extendOccEnv env (nameOccName name) name + = lre { lre_env = extendOccEnv env (nameOccName name) name , lre_in_scope = extendNameSet ns name } extendLocalRdrEnvList :: LocalRdrEnv -> [Name] -> LocalRdrEnv +-- See Note [LocalRdrEnv] extendLocalRdrEnvList lre@(LRE { lre_env = env, lre_in_scope = ns }) names - = WARN( any isExternalName names, ppr names ) - lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] + = lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] , lre_in_scope = extendNameSetList ns names } lookupLocalRdrEnv :: LocalRdrEnv -> RdrName -> Maybe Name ===================================== testsuite/tests/indexed-types/should_fail/Overlap5.stderr ===================================== @@ -1,6 +1,6 @@ Overlap5.hs:8:3: error: - Mismatched type name in type family instance. - Expected: F - Actual: G - In the declaration for type family ‘F’ + • Mismatched type name in type family instance. + Expected: F + Actual: G + • In the type family declaration for ‘F’ ===================================== testsuite/tests/quantified-constraints/T18432.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE QuantifiedConstraints #-} +module Bug where + +import Data.Proxy + +class C a where + m :: Proxy a + +f :: (forall {a}. C a) => Proxy Int +f = m ===================================== testsuite/tests/quantified-constraints/all.T ===================================== @@ -29,3 +29,4 @@ test('T17267c', normal, compile_fail, ['']) test('T17267d', normal, compile_and_run, ['']) test('T17267e', normal, compile_fail, ['']) test('T17458', normal, compile_fail, ['']) +test('T18432', normal, compile, ['']) ===================================== testsuite/tests/rename/should_fail/T16002.stderr ===================================== @@ -1,6 +1,6 @@ T16002.hs:6:3: error: - Mismatched type name in type family instance. - Expected: B - Actual: A - In the declaration for type family ‘B’ + • Mismatched type name in type family instance. + Expected: B + Actual: A + • In the type family declaration for ‘B’ ===================================== testsuite/tests/th/T15362.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds #-} +{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds, TypeFamilies #-} module T15362 where ===================================== testsuite/tests/th/T15362.stderr ===================================== @@ -1,10 +1,6 @@ -T15362.hs:8:10: error: +T15362.hs:7:2: error: • Mismatched type name in type family instance. Expected: + Actual: Maybe - In the declaration for type family ‘+’ - • In the Template Haskell quotation - [d| type family a + b where - Maybe Zero b = b - Succ a + b = Succ (a + b) |] + • In the type family declaration for ‘+’ ===================================== testsuite/tests/typecheck/should_fail/ExplicitSpecificity4.hs → testsuite/tests/typecheck/should_compile/ExplicitSpecificity4.hs ===================================== ===================================== testsuite/tests/typecheck/should_compile/T18470.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC -Wunused-top-binds #-} + +module T18470 () where + +type family Closed x where + Closed Int = Bool ===================================== testsuite/tests/typecheck/should_compile/T18470.stderr ===================================== @@ -0,0 +1,3 @@ + +T18470.hs:6:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] + Defined but not used: type constructor or class ‘Closed’ ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -712,8 +712,10 @@ test('T18129', expect_broken(18129), compile, ['']) test('T18185', normal, compile, ['']) test('ExplicitSpecificityA1', normal, compile, ['']) test('ExplicitSpecificityA2', normal, compile, ['']) +test('ExplicitSpecificity4', normal, compile, ['']) test('T17775-viewpats-a', normal, compile, ['']) test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) test('T17775-viewpats-d', normal, compile_fail, ['']) test('T18412', normal, compile, ['']) +test('T18470', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T11623.stderr ===================================== @@ -1,6 +1,6 @@ T11623.hs:5:23: error: - Mismatched type name in type family instance. - Expected: T - Actual: Maybe - In the declaration for type family ‘T’ + • Mismatched type name in type family instance. + Expected: T + Actual: Maybe + • In the type family declaration for ‘T’ ===================================== testsuite/tests/typecheck/should_fail/T18455.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE RankNTypes #-} +module T18455 where + +class C a + +instance C (Either a b) where + {-# SPECIALISE instance forall a. forall b. C (Either a b) #-} ===================================== testsuite/tests/typecheck/should_fail/T18455.stderr ===================================== @@ -0,0 +1,4 @@ + +T18455.hs:7:37: error: + SPECIALISE instance type cannot contain nested ‘forall’s or contexts + In a SPECIALISE instance pragma ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -568,7 +568,6 @@ test('T18127a', normal, compile_fail, ['']) test('ExplicitSpecificity1', normal, compile_fail, ['']) test('ExplicitSpecificity2', normal, compile_fail, ['']) test('ExplicitSpecificity3', normal, compile_fail, ['']) -test('ExplicitSpecificity4', normal, compile_fail, ['']) test('ExplicitSpecificity5', normal, compile_fail, ['']) test('ExplicitSpecificity6', normal, compile_fail, ['']) test('ExplicitSpecificity7', normal, compile_fail, ['']) @@ -578,3 +577,4 @@ test('ExplicitSpecificity10', normal, compile_fail, ['']) test('T18357', normal, compile_fail, ['']) test('T18357a', normal, compile_fail, ['']) test('T18357b', normal, compile_fail, ['']) +test('T18455', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc451e3bf0b1b1dd466fd373e7b4a30dd69ec769...2545583198d1eda0c21f62ebf704ee113df56bb8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc451e3bf0b1b1dd466fd373e7b4a30dd69ec769...2545583198d1eda0c21f62ebf704ee113df56bb8 You're receiving 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 Jul 30 11:11:07 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 30 Jul 2020 07:11:07 -0400 Subject: [Git][ghc/ghc][master] 2 commits: For `-fkeep-going` do not duplicate dependency edge code Message-ID: <5f22aacba56ba_80b3f849a25e69058707e7@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 1 changed file: - compiler/GHC/Driver/Make.hs Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -953,6 +953,12 @@ mkBuildModule ms = GWIB , gwib_isBoot = isBootSummary ms } +mkHomeBuildModule :: ModSummary -> ModuleNameWithIsBoot +mkHomeBuildModule ms = GWIB + { gwib_mod = moduleName $ ms_mod ms + , gwib_isBoot = isBootSummary ms + } + -- | The entry point to the parallel upsweep. -- -- See also the simpler, sequential 'upsweep'. @@ -1391,20 +1397,20 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do keep_going this_mods old_hpt done mods mod_index nmods uids_to_check done_holes = do let sum_deps ms (AcyclicSCC mod) = - if any (flip elem . map (unLoc . snd) $ ms_imps mod) ms - then ms_mod_name mod:ms + if any (flip elem $ unfilteredEdges False mod) ms + then mkHomeBuildModule mod:ms else ms sum_deps ms _ = ms dep_closure = foldl' sum_deps this_mods mods dropped_ms = drop (length this_mods) (reverse dep_closure) - prunable (AcyclicSCC mod) = elem (ms_mod_name mod) dep_closure + prunable (AcyclicSCC mod) = elem (mkHomeBuildModule mod) dep_closure prunable _ = False mods' = filter (not . prunable) mods nmods' = nmods - length dropped_ms when (not $ null dropped_ms) $ do dflags <- getSessionDynFlags - liftIO $ fatalErrorMsg dflags (keepGoingPruneErr dropped_ms) + liftIO $ fatalErrorMsg dflags (keepGoingPruneErr $ gwib_mod <$> dropped_ms) (_, done') <- upsweep' old_hpt done mods' (mod_index+1) nmods' uids_to_check done_holes return (Failed, done') @@ -1429,7 +1435,7 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do = do dflags <- getSessionDynFlags liftIO $ fatalErrorMsg dflags (cyclicModuleErr ms) if gopt Opt_KeepGoing dflags - then keep_going (map ms_mod_name ms) old_hpt done mods mod_index nmods + then keep_going (mkHomeBuildModule <$> ms) old_hpt done mods mod_index nmods uids_to_check done_holes else return (Failed, done) @@ -1483,7 +1489,7 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do Nothing -> do dflags <- getSessionDynFlags if gopt Opt_KeepGoing dflags - then keep_going [ms_mod_name mod] old_hpt done mods mod_index nmods + then keep_going [mkHomeBuildModule mod] old_hpt done mods mod_index nmods uids_to_check done_holes else return (Failed, done) Just mod_info -> do @@ -1919,7 +1925,7 @@ reachableBackwards mod summaries = [ node_payload node | node <- reachableG (transposeG graph) root ] where -- the rest just sets up the graph: (graph, lookup_node) = moduleGraphNodes False summaries - root = expectJust "reachableBackwards" (lookup_node IsBoot mod) + root = expectJust "reachableBackwards" (lookup_node $ GWIB mod IsBoot) -- --------------------------------------------------------------------------- -- @@ -1962,7 +1968,7 @@ topSortModuleGraph drop_hs_boot_nodes module_graph mb_root_mod -- the specified module. We do this by building a graph with -- the full set of nodes, and determining the reachable set from -- the specified node. - let root | Just node <- lookup_node NotBoot root_mod + let root | Just node <- lookup_node $ GWIB root_mod NotBoot , graph `hasVertexG` node = node | otherwise @@ -1977,60 +1983,55 @@ summaryNodeKey = node_key summaryNodeSummary :: SummaryNode -> ModSummary summaryNodeSummary = node_payload +-- | Collect the immediate dependencies of a module from its ModSummary, +-- optionally avoiding hs-boot dependencies. +-- If the drop_hs_boot_nodes flag is False, and if this is a .hs and there is +-- an equivalent .hs-boot, add a link from the former to the latter. This +-- has the effect of detecting bogus cases where the .hs-boot depends on the +-- .hs, by introducing a cycle. Additionally, it ensures that we will always +-- process the .hs-boot before the .hs, and so the HomePackageTable will always +-- have the most up to date information. +unfilteredEdges :: Bool -> ModSummary -> [ModuleNameWithIsBoot] +unfilteredEdges drop_hs_boot_nodes ms = + (flip GWIB hs_boot_key . unLoc <$> ms_home_srcimps ms) ++ + (flip GWIB NotBoot . unLoc <$> ms_home_imps ms) ++ + [ GWIB (ms_mod_name ms) IsBoot + | not $ drop_hs_boot_nodes || ms_hsc_src ms == HsBootFile + ] + where + -- Drop hs-boot nodes by using HsSrcFile as the key + hs_boot_key | drop_hs_boot_nodes = NotBoot -- is regular mod or signature + | otherwise = IsBoot + moduleGraphNodes :: Bool -> [ModSummary] - -> (Graph SummaryNode, IsBootInterface -> ModuleName -> Maybe SummaryNode) + -> (Graph SummaryNode, ModuleNameWithIsBoot -> Maybe SummaryNode) moduleGraphNodes drop_hs_boot_nodes summaries = (graphFromEdgedVerticesUniq nodes, lookup_node) where numbered_summaries = zip summaries [1..] - lookup_node :: IsBootInterface -> ModuleName -> Maybe SummaryNode - lookup_node hs_src mod = Map.lookup - (GWIB { gwib_mod = mod, gwib_isBoot = hs_src }) - node_map + lookup_node :: ModuleNameWithIsBoot -> Maybe SummaryNode + lookup_node mnwib = Map.lookup mnwib node_map - lookup_key :: IsBootInterface -> ModuleName -> Maybe Int - lookup_key hs_src mod = fmap summaryNodeKey (lookup_node hs_src mod) + lookup_key :: ModuleNameWithIsBoot -> Maybe Int + lookup_key = fmap summaryNodeKey . lookup_node node_map :: NodeMap SummaryNode - node_map = Map.fromList [ ( GWIB - { gwib_mod = moduleName $ ms_mod s - , gwib_isBoot = hscSourceToIsBoot $ ms_hsc_src s - } - , node - ) + node_map = Map.fromList [ (mkHomeBuildModule s, node) | node <- nodes - , let s = summaryNodeSummary node ] + , let s = summaryNodeSummary node + ] -- We use integers as the keys for the SCC algorithm nodes :: [SummaryNode] - nodes = [ DigraphNode s key out_keys + nodes = [ DigraphNode s key $ out_edge_keys $ unfilteredEdges drop_hs_boot_nodes s | (s, key) <- numbered_summaries -- Drop the hi-boot ones if told to do so , not (isBootSummary s == IsBoot && drop_hs_boot_nodes) - , let out_keys = out_edge_keys hs_boot_key (map unLoc (ms_home_srcimps s)) ++ - out_edge_keys NotBoot (map unLoc (ms_home_imps s)) ++ - (-- see [boot-edges] below - if drop_hs_boot_nodes || ms_hsc_src s == HsBootFile - then [] - else case lookup_key IsBoot (ms_mod_name s) of - Nothing -> [] - Just k -> [k]) ] - - -- [boot-edges] if this is a .hs and there is an equivalent - -- .hs-boot, add a link from the former to the latter. This - -- has the effect of detecting bogus cases where the .hs-boot - -- depends on the .hs, by introducing a cycle. Additionally, - -- it ensures that we will always process the .hs-boot before - -- the .hs, and so the HomePackageTable will always have the - -- most up to date information. - - -- Drop hs-boot nodes by using HsSrcFile as the key - hs_boot_key | drop_hs_boot_nodes = NotBoot -- is regular mod or signature - | otherwise = IsBoot + ] - out_edge_keys :: IsBootInterface -> [ModuleName] -> [Int] - out_edge_keys hi_boot ms = mapMaybe (lookup_key hi_boot) ms + out_edge_keys :: [ModuleNameWithIsBoot] -> [Int] + out_edge_keys = mapMaybe lookup_key -- If we want keep_hi_boot_nodes, then we do lookup_key with -- IsBoot; else False View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e1dc3d7b89ea79aea158ee487234d3730e857f04...502de55676a38572db60848c13392f5f115e1c8a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e1dc3d7b89ea79aea158ee487234d3730e857f04...502de55676a38572db60848c13392f5f115e1c8a You're receiving 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 Jul 30 11:11:46 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 30 Jul 2020 07:11:46 -0400 Subject: [Git][ghc/ghc][master] Clean up the inferred type variable restriction Message-ID: <5f22aaf238c8c_80b3f848c1e06f45878157@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - 14 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - + testsuite/tests/quantified-constraints/T18432.hs - testsuite/tests/quantified-constraints/all.T - testsuite/tests/typecheck/should_fail/ExplicitSpecificity4.hs → testsuite/tests/typecheck/should_compile/ExplicitSpecificity4.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T18455.hs - + testsuite/tests/typecheck/should_fail/T18455.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1628,6 +1628,12 @@ instance types, which makes things like the instance above become illegal. For the sake of consistency, we also disallow nested contexts, even though they don't have the same strange interaction with ScopedTypeVariables. +Just as we forbid nested `forall`s and contexts in normal instance +declarations, we also forbid them in SPECIALISE instance pragmas (#18455). +Unlike normal instance declarations, ScopedTypeVariables don't have any impact +on SPECIALISE instance pragmas, but we use the same validity checks for +SPECIALISE instance pragmas anyway to be consistent. + ----- -- Wrinkle: Derived instances ----- ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -43,7 +43,8 @@ import GHC.Rename.Fixity import GHC.Rename.Utils ( HsDocContext(..), mapFvRn, extendTyVarEnvFVRn , checkDupRdrNames, warnUnusedLocalBinds , checkUnusedRecordWildcard - , checkDupAndShadowedNames, bindLocalNamesFV ) + , checkDupAndShadowedNames, bindLocalNamesFV + , addNoNestedForallsContextsErr, checkInferredVars ) import GHC.Driver.Session import GHC.Unit.Module import GHC.Types.Name @@ -955,7 +956,7 @@ renameSig _ (IdSig _ x) renameSig ctxt sig@(TypeSig _ vs ty) = do { new_vs <- mapM (lookupSigOccRn ctxt sig) vs ; let doc = TypeSigCtx (ppr_sig_bndrs vs) - ; (new_ty, fvs) <- rnHsSigWcType doc Nothing ty + ; (new_ty, fvs) <- rnHsSigWcType doc ty ; return (TypeSig noExtField new_vs new_ty, fvs) } renameSig ctxt sig@(ClassOpSig _ is_deflt vs ty) @@ -963,20 +964,25 @@ renameSig ctxt sig@(ClassOpSig _ is_deflt vs ty) ; when (is_deflt && not defaultSigs_on) $ addErr (defaultSigErr sig) ; new_v <- mapM (lookupSigOccRn ctxt sig) vs - ; (new_ty, fvs) <- rnHsSigType ty_ctxt TypeLevel inf_msg ty + ; (new_ty, fvs) <- rnHsSigType ty_ctxt TypeLevel ty ; return (ClassOpSig noExtField is_deflt new_v new_ty, fvs) } where (v1:_) = vs ty_ctxt = GenericCtx (text "a class method signature for" <+> quotes (ppr v1)) - inf_msg = if is_deflt - then Just (text "A default type signature cannot contain inferred type variables") - else Nothing renameSig _ (SpecInstSig _ src ty) - = do { (new_ty, fvs) <- rnHsSigType SpecInstSigCtx TypeLevel inf_msg ty + = do { checkInferredVars doc inf_msg ty + ; (new_ty, fvs) <- rnHsSigType doc TypeLevel ty + -- Check if there are any nested `forall`s or contexts, which are + -- illegal in the type of an instance declaration (see + -- Note [No nested foralls or contexts in instance types] in + -- GHC.Hs.Type). + ; addNoNestedForallsContextsErr doc (text "SPECIALISE instance type") + (getLHsInstDeclHead new_ty) ; return (SpecInstSig noExtField src new_ty,fvs) } where + doc = SpecInstSigCtx inf_msg = Just (text "Inferred type variables are not allowed") -- {-# SPECIALISE #-} pragmas can refer to imported Ids @@ -993,7 +999,7 @@ renameSig ctxt sig@(SpecSig _ v tys inl) ty_ctxt = GenericCtx (text "a SPECIALISE signature for" <+> quotes (ppr v)) do_one (tys,fvs) ty - = do { (new_ty, fvs_ty) <- rnHsSigType ty_ctxt TypeLevel Nothing ty + = do { (new_ty, fvs_ty) <- rnHsSigType ty_ctxt TypeLevel ty ; return ( new_ty:tys, fvs_ty `plusFV` fvs) } renameSig ctxt sig@(InlineSig _ v s) @@ -1010,7 +1016,7 @@ renameSig ctxt sig@(MinimalSig _ s (L l bf)) renameSig ctxt sig@(PatSynSig _ vs ty) = do { new_vs <- mapM (lookupSigOccRn ctxt sig) vs - ; (ty', fvs) <- rnHsSigType ty_ctxt TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType ty_ctxt TypeLevel ty ; return (PatSynSig noExtField new_vs ty', fvs) } where ty_ctxt = GenericCtx (text "a pattern synonym signature for" ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -317,7 +317,7 @@ rnExpr (RecordUpd { rupd_expr = expr, rupd_flds = rbinds }) , fvExpr `plusFV` fvRbinds) } rnExpr (ExprWithTySig _ expr pty) - = do { (pty', fvTy) <- rnHsSigWcType ExprWithTySigCtx Nothing pty + = do { (pty', fvTy) <- rnHsSigWcType ExprWithTySigCtx pty ; (expr', fvExpr) <- bindSigTyVarsFV (hsWcScopedTvs pty') $ rnLExpr expr ; return (ExprWithTySig noExtField expr' pty', fvExpr `plusFV` fvTy) } ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -39,7 +39,6 @@ import GHC.Prelude import {-# SOURCE #-} GHC.Rename.Splice( rnSpliceType ) -import GHC.Core.Type import GHC.Driver.Session import GHC.Hs import GHC.Rename.Doc ( rnLHsDoc, rnMbLHsDoc ) @@ -68,7 +67,7 @@ import GHC.Data.FastString import GHC.Data.Maybe import qualified GHC.LanguageExtensions as LangExt -import Data.List ( nubBy, partition, find ) +import Data.List ( nubBy, partition ) import Control.Monad ( unless, when ) #include "HsVersions.h" @@ -124,19 +123,16 @@ data HsSigWcTypeScoping -- "GHC.Hs.Type". rnHsSigWcType :: HsDocContext - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. -> LHsSigWcType GhcPs -> RnM (LHsSigWcType GhcRn, FreeVars) -rnHsSigWcType doc inf_err (HsWC { hswc_body = HsIB { hsib_body = hs_ty }}) - = rn_hs_sig_wc_type BindUnlessForall doc inf_err hs_ty $ \nwcs imp_tvs body -> +rnHsSigWcType doc (HsWC { hswc_body = HsIB { hsib_body = hs_ty }}) + = rn_hs_sig_wc_type BindUnlessForall doc hs_ty $ \nwcs imp_tvs body -> let ib_ty = HsIB { hsib_ext = imp_tvs, hsib_body = body } wc_ty = HsWC { hswc_ext = nwcs, hswc_body = ib_ty } in pure (wc_ty, emptyFVs) rnHsPatSigType :: HsSigWcTypeScoping - -> HsDocContext -> Maybe SDoc + -> HsDocContext -> HsPatSigType GhcPs -> (HsPatSigType GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) @@ -147,10 +143,10 @@ rnHsPatSigType :: HsSigWcTypeScoping -- Wildcards are allowed -- -- See Note [Pattern signature binders and scoping] in GHC.Hs.Type -rnHsPatSigType scoping ctx inf_err sig_ty thing_inside +rnHsPatSigType scoping ctx sig_ty thing_inside = do { ty_sig_okay <- xoptM LangExt.ScopedTypeVariables ; checkErr ty_sig_okay (unexpectedPatSigTypeErr sig_ty) - ; rn_hs_sig_wc_type scoping ctx inf_err (hsPatSigType sig_ty) $ + ; rn_hs_sig_wc_type scoping ctx (hsPatSigType sig_ty) $ \nwcs imp_tvs body -> do { let sig_names = HsPSRn { hsps_nwcs = nwcs, hsps_imp_tvs = imp_tvs } sig_ty' = HsPS { hsps_ext = sig_names, hsps_body = body } @@ -158,16 +154,15 @@ rnHsPatSigType scoping ctx inf_err sig_ty thing_inside } } -- The workhorse for rnHsSigWcType and rnHsPatSigType. -rn_hs_sig_wc_type :: HsSigWcTypeScoping -> HsDocContext -> Maybe SDoc +rn_hs_sig_wc_type :: HsSigWcTypeScoping -> HsDocContext -> LHsType GhcPs -> ([Name] -- Wildcard names -> [Name] -- Implicitly bound type variable names -> LHsType GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) -rn_hs_sig_wc_type scoping ctxt inf_err hs_ty thing_inside - = do { check_inferred_vars ctxt inf_err hs_ty - ; free_vars <- filterInScopeM (extractHsTyRdrTyVars hs_ty) +rn_hs_sig_wc_type scoping ctxt hs_ty thing_inside + = do { free_vars <- filterInScopeM (extractHsTyRdrTyVars hs_ty) ; (nwc_rdrs', tv_rdrs) <- partition_nwcs free_vars ; let nwc_rdrs = nubL nwc_rdrs' ; implicit_bndrs <- case scoping of @@ -318,17 +313,13 @@ of the HsWildCardBndrs structure, and we are done. rnHsSigType :: HsDocContext -> TypeOrKind - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. -> LHsSigType GhcPs -> RnM (LHsSigType GhcRn, FreeVars) -- Used for source-language type signatures -- that cannot have wildcards -rnHsSigType ctx level inf_err (HsIB { hsib_body = hs_ty }) +rnHsSigType ctx level (HsIB { hsib_body = hs_ty }) = do { traceRn "rnHsSigType" (ppr hs_ty) ; rdr_env <- getLocalRdrEnv - ; check_inferred_vars ctx inf_err hs_ty ; vars0 <- forAllOrNothing (isLHsForAllTy hs_ty) $ filterInScope rdr_env $ extractHsTyRdrTyVars hs_ty @@ -415,26 +406,6 @@ type signature, since the type signature implicitly carries their binding sites. This is less precise, but more accurate. -} -check_inferred_vars :: HsDocContext - -> Maybe SDoc - -- ^ The error msg if the signature is not allowed to contain - -- manually written inferred variables. - -> LHsType GhcPs - -> RnM () -check_inferred_vars _ Nothing _ = return () -check_inferred_vars ctxt (Just msg) ty = - let bndrs = forallty_bndrs ty - in case find ((==) InferredSpec . hsTyVarBndrFlag) bndrs of - Nothing -> return () - Just _ -> addErr $ withHsDocContext ctxt msg - where - forallty_bndrs :: LHsType GhcPs -> [HsTyVarBndr Specificity GhcPs] - forallty_bndrs (L _ ty) = case ty of - HsParTy _ ty' -> forallty_bndrs ty' - HsForAllTy { hst_tele = HsForAllInvis { hsf_invis_bndrs = tvs }} - -> map unLoc tvs - _ -> [] - {- ****************************************************** * * LHsType and HsType ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -34,7 +34,8 @@ import GHC.Rename.Utils ( HsDocContext(..), mapFvRn, bindLocalNames , checkDupRdrNames, bindLocalNamesFV , checkShadowedRdrNames, warnUnusedTypePatterns , extendTyVarEnvFVRn, newLocalBndrsRn - , withHsDocContext ) + , withHsDocContext, noNestedForallsContextsErr + , addNoNestedForallsContextsErr, checkInferredVars ) import GHC.Rename.Unbound ( mkUnboundName, notInScopeErr ) import GHC.Rename.Names import GHC.Rename.Doc ( rnHsDoc, rnMbLHsDoc ) @@ -65,7 +66,6 @@ import GHC.Data.List.SetOps ( findDupsEq, removeDups, equivClasses ) import GHC.Data.Graph.Directed ( SCC, flattenSCC, flattenSCCs, Node(..) , stronglyConnCompFromEdgedVerticesUniq ) import GHC.Types.Unique.Set -import GHC.Data.Maybe ( whenIsJust ) import GHC.Data.OrdList import qualified GHC.LanguageExtensions as LangExt @@ -371,7 +371,7 @@ rnHsForeignDecl :: ForeignDecl GhcPs -> RnM (ForeignDecl GhcRn, FreeVars) rnHsForeignDecl (ForeignImport { fd_name = name, fd_sig_ty = ty, fd_fi = spec }) = do { topEnv :: HscEnv <- getTopEnv ; name' <- lookupLocatedTopBndrRn name - ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel ty -- Mark any PackageTarget style imports as coming from the current package ; let unitId = homeUnit $ hsc_dflags topEnv @@ -383,7 +383,7 @@ rnHsForeignDecl (ForeignImport { fd_name = name, fd_sig_ty = ty, fd_fi = spec }) rnHsForeignDecl (ForeignExport { fd_name = name, fd_sig_ty = ty, fd_fe = spec }) = do { name' <- lookupLocatedOccRn name - ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel ty ; return (ForeignExport { fd_e_ext = noExtField , fd_name = name', fd_sig_ty = ty' , fd_fe = spec } @@ -602,13 +602,14 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds , cid_sigs = uprags, cid_tyfam_insts = ats , cid_overlap_mode = oflag , cid_datafam_insts = adts }) - = do { (inst_ty', inst_fvs) <- rnHsSigType ctxt TypeLevel inf_err inst_ty + = do { checkInferredVars ctxt inf_err inst_ty + ; (inst_ty', inst_fvs) <- rnHsSigType ctxt TypeLevel inst_ty ; let (ktv_names, _, head_ty') = splitLHsInstDeclTy inst_ty' -- Check if there are any nested `forall`s or contexts, which are -- illegal in the type of an instance declaration (see -- Note [No nested foralls or contexts in instance types] in -- GHC.Hs.Type)... - mb_nested_msg = no_nested_foralls_contexts_err + mb_nested_msg = noNestedForallsContextsErr (text "Instance head") head_ty' -- ...then check if the instance head is actually headed by a -- class type constructor... @@ -628,17 +629,10 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds -- with an error message if there isn't one. To avoid excessive -- amounts of error messages, we will only report one of the errors -- from mb_nested_msg or eith_cls at a time. - ; cls <- case maybe eith_cls Left mb_nested_msg of - Right cls -> pure cls - Left (l, err_msg) -> do - -- The instance is malformed. We'd still like - -- to make *some* progress (rather than failing outright), so - -- we report an error and continue for as long as we can. - -- Importantly, this error should be thrown before we reach the - -- typechecker, lest we encounter different errors that are - -- hopelessly confusing (such as the one in #16114). - addErrAt l $ withHsDocContext ctxt err_msg - pure $ mkUnboundName (mkTcOccFS (fsLit "")) + ; cls <- case (mb_nested_msg, eith_cls) of + (Nothing, Right cls) -> pure cls + (Just err1, _) -> bail_out err1 + (_, Left err2) -> bail_out err2 -- Rename the bindings -- The typechecker (not the renamer) checks that all @@ -680,6 +674,15 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds ctxt = GenericCtx $ text "an instance declaration" inf_err = Just (text "Inferred type variables are not allowed") + -- The instance is malformed. We'd still like to make *some* progress + -- (rather than failing outright), so we report an error and continue for + -- as long as we can. Importantly, this error should be thrown before we + -- reach the typechecker, lest we encounter different errors that are + -- hopelessly confusing (such as the one in #16114). + bail_out (l, err_msg) = do + addErrAt l $ withHsDocContext ctxt err_msg + pure $ mkUnboundName (mkTcOccFS (fsLit "")) + rnFamInstEqn :: HsDocContext -> AssocTyFamInfo -> FreeKiTyVars @@ -1010,22 +1013,22 @@ rnSrcDerivDecl :: DerivDecl GhcPs -> RnM (DerivDecl GhcRn, FreeVars) rnSrcDerivDecl (DerivDecl _ ty mds overlap) = do { standalone_deriv_ok <- xoptM LangExt.StandaloneDeriving ; unless standalone_deriv_ok (addErr standaloneDerivErr) - ; (mds', ty', fvs) - <- rnLDerivStrategy ctxt mds $ rnHsSigWcType ctxt inf_err ty + ; checkInferredVars ctxt inf_err nowc_ty + ; (mds', ty', fvs) <- rnLDerivStrategy ctxt mds $ rnHsSigWcType ctxt ty -- Check if there are any nested `forall`s or contexts, which are -- illegal in the type of an instance declaration (see -- Note [No nested foralls or contexts in instance types] in -- GHC.Hs.Type). - ; whenIsJust (no_nested_foralls_contexts_err - (text "Standalone-derived instance head") - (getLHsInstDeclHead $ dropWildCards ty')) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext ctxt err_msg + ; addNoNestedForallsContextsErr ctxt + (text "Standalone-derived instance head") + (getLHsInstDeclHead $ dropWildCards ty') ; warnNoDerivStrat mds' loc ; return (DerivDecl noExtField ty' mds' overlap, fvs) } where ctxt = DerivDeclCtx inf_err = Just (text "Inferred type variables are not allowed") - loc = getLoc $ hsib_body $ hswc_body ty + loc = getLoc $ hsib_body nowc_ty + nowc_ty = dropWildCards ty standaloneDerivErr :: SDoc standaloneDerivErr @@ -1091,7 +1094,7 @@ bindRuleTmVars doc tyvs vars names thing_inside go ((L l (RuleBndrSig _ (L loc _) bsig)) : vars) (n : ns) thing_inside - = rnHsPatSigType bind_free_tvs doc Nothing bsig $ \ bsig' -> + = rnHsPatSigType bind_free_tvs doc bsig $ \ bsig' -> go vars ns $ \ vars' -> thing_inside (L l (RuleBndrSig noExtField (L loc n) bsig') : vars') @@ -1431,7 +1434,7 @@ rnStandaloneKindSignature tc_names (StandaloneKindSig _ v ki) ; unless standalone_ki_sig_ok $ addErr standaloneKiSigErr ; new_v <- lookupSigCtxtOccRn (TopSigCtxt tc_names) (text "standalone kind signature") v ; let doc = StandaloneKindSigCtx (ppr v) - ; (new_ki, fvs) <- rnHsSigType doc KindLevel Nothing ki + ; (new_ki, fvs) <- rnHsSigType doc KindLevel ki ; return (StandaloneKindSig noExtField new_v new_ki, fvs) } where @@ -1841,15 +1844,14 @@ rnLHsDerivingClause doc rn_clause_pred :: LHsSigType GhcPs -> RnM (LHsSigType GhcRn, FreeVars) rn_clause_pred pred_ty = do let inf_err = Just (text "Inferred type variables are not allowed") - ret@(pred_ty', _) <- rnHsSigType doc TypeLevel inf_err pred_ty + checkInferredVars doc inf_err pred_ty + ret@(pred_ty', _) <- rnHsSigType doc TypeLevel pred_ty -- Check if there are any nested `forall`s, which are illegal in a -- `deriving` clause. -- See Note [No nested foralls or contexts in instance types] -- (Wrinkle: Derived instances) in GHC.Hs.Type. - whenIsJust (no_nested_foralls_contexts_err - (text "Derived class type") - (getLHsInstDeclHead pred_ty')) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext doc err_msg + addNoNestedForallsContextsErr doc (text "Derived class type") + (getLHsInstDeclHead pred_ty') pure ret rnLDerivStrategy :: forall a. @@ -1883,7 +1885,8 @@ rnLDerivStrategy doc mds thing_inside AnyclassStrategy -> boring_case AnyclassStrategy NewtypeStrategy -> boring_case NewtypeStrategy ViaStrategy via_ty -> - do (via_ty', fvs1) <- rnHsSigType doc TypeLevel inf_err via_ty + do checkInferredVars doc inf_err via_ty + (via_ty', fvs1) <- rnHsSigType doc TypeLevel via_ty let HsIB { hsib_ext = via_imp_tvs , hsib_body = via_body } = via_ty' (via_exp_tv_bndrs, via_rho) = splitLHsForAllTyInvis_KP via_body @@ -1893,10 +1896,8 @@ rnLDerivStrategy doc mds thing_inside -- `via` type. -- See Note [No nested foralls or contexts in instance types] -- (Wrinkle: Derived instances) in GHC.Hs.Type. - whenIsJust (no_nested_foralls_contexts_err - (quotes (text "via") <+> text "type") - via_rho) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext doc err_msg + addNoNestedForallsContextsErr doc + (quotes (text "via") <+> text "type") via_rho (thing, fvs2) <- extendTyVarEnvFVRn via_tvs thing_inside pure (ViaStrategy via_ty', thing, fvs1 `plusFV` fvs2) @@ -2213,7 +2214,7 @@ rnConDecl (XConDecl (ConDeclGADTPrefixPs { con_gp_names = names, con_gp_ty = ty ; mb_doc' <- rnMbLHsDoc mb_doc ; let ctxt = ConDeclCtx new_names - ; (ty', fvs) <- rnHsSigType ctxt TypeLevel Nothing ty + ; (ty', fvs) <- rnHsSigType ctxt TypeLevel ty ; linearTypes <- xopt LangExt.LinearTypes <$> getDynFlags -- Now that operator precedence has been resolved, we can split the @@ -2232,10 +2233,8 @@ rnConDecl (XConDecl (ConDeclGADTPrefixPs { con_gp_names = names, con_gp_ty = ty -- Ensure that there are no nested `forall`s or contexts, per -- Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts) -- in GHC.Hs.Type. - ; whenIsJust (no_nested_foralls_contexts_err - (text "GADT constructor type signature") - res_ty) $ \(l, err_msg) -> - addErrAt l $ withHsDocContext ctxt err_msg + ; addNoNestedForallsContextsErr ctxt + (text "GADT constructor type signature") res_ty ; traceRn "rnConDecl (ConDeclGADTPrefixPs)" (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) @@ -2273,41 +2272,6 @@ rnConDeclDetails con doc (RecCon (L l fields)) -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn ; return (RecCon (L l new_fields), fvs) } --- | Examines a non-outermost type for @forall at s or contexts, which are assumed --- to be nested. Returns @'Just' err_msg@ if such a @forall@ or context is --- found, and returns @Nothing@ otherwise. --- --- This is currently used in two places: --- --- * In GADT constructor types (in 'rnConDecl'). --- See @Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts)@ --- in "GHC.Hs.Type". --- --- * In instance declaration types (in 'rnClsIntDecl' and 'rnSrcDerivDecl'). --- See @Note [No nested foralls or contexts in instance types]@ in --- "GHC.Hs.Type". -no_nested_foralls_contexts_err :: SDoc -> LHsType GhcRn -> Maybe (SrcSpan, SDoc) -no_nested_foralls_contexts_err what lty = - case ignoreParens lty of - L l (HsForAllTy { hst_tele = tele }) - | HsForAllVis{} <- tele - -- The only two places where this function is called correspond to - -- types of terms, so we give a slightly more descriptive error - -- message in the event that they contain visible dependent - -- quantification (currently only allowed in kinds). - -> Just (l, vcat [ text "Illegal visible, dependent quantification" <+> - text "in the type of a term" - , text "(GHC does not yet support this)" ]) - | HsForAllInvis{} <- tele - -> Just (l, nested_foralls_contexts_err) - L l (HsQualTy {}) - -> Just (l, nested_foralls_contexts_err) - _ -> Nothing - where - nested_foralls_contexts_err = - what <+> text "cannot contain nested" - <+> quotes forAllLit <> text "s or contexts" - ------------------------------------------------- -- | Brings pattern synonym names and also pattern synonym selectors ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -412,7 +412,7 @@ rnPatAndThen mk (SigPat x pat sig) ; return (SigPat x pat' sig' ) } where rnHsPatSigTypeAndThen :: HsPatSigType GhcPs -> CpsRn (HsPatSigType GhcRn) - rnHsPatSigTypeAndThen sig = CpsRn (rnHsPatSigType AlwaysBind PatCtx Nothing sig) + rnHsPatSigTypeAndThen sig = CpsRn (rnHsPatSigType AlwaysBind PatCtx sig) rnPatAndThen mk (LitPat x lit) | HsString src s <- lit ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -26,8 +26,10 @@ module GHC.Rename.Utils ( bindLocalNames, bindLocalNamesFV, - addNameClashErrRn, extendTyVarEnvFVRn + addNameClashErrRn, extendTyVarEnvFVRn, + checkInferredVars, + noNestedForallsContextsErr, addNoNestedForallsContextsErr ) where @@ -35,6 +37,7 @@ where import GHC.Prelude +import GHC.Core.Type import GHC.Hs import GHC.Types.Name.Reader import GHC.Driver.Types @@ -49,6 +52,7 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Types.Basic ( TopLevelFlag(..) ) import GHC.Data.List.SetOps ( removeDups ) +import GHC.Data.Maybe ( whenIsJust ) import GHC.Driver.Session import GHC.Data.FastString import Control.Monad @@ -176,6 +180,136 @@ checkShadowedOccs (global_env,local_env) get_loc_occ ns || xopt LangExt.RecordWildCards dflags) } is_shadowed_gre _other = return True +------------------------------------- +-- | Throw an error message if a user attempts to quantify an inferred type +-- variable in a place where specificity cannot be observed. For example, +-- @forall {a}. [a] -> [a]@ would be rejected to the inferred type variable +-- @{a}@, but @forall a. [a] -> [a]@ would be accepted. +-- See @Note [Unobservably inferred type variables]@. +checkInferredVars :: HsDocContext + -> Maybe SDoc + -- ^ The error msg if the signature is not allowed to contain + -- manually written inferred variables. + -> LHsSigType GhcPs + -> RnM () +checkInferredVars _ Nothing _ = return () +checkInferredVars ctxt (Just msg) ty = + let bndrs = forallty_bndrs (hsSigType ty) + in case find ((==) InferredSpec . hsTyVarBndrFlag) bndrs of + Nothing -> return () + Just _ -> addErr $ withHsDocContext ctxt msg + where + forallty_bndrs :: LHsType GhcPs -> [HsTyVarBndr Specificity GhcPs] + forallty_bndrs (L _ ty) = case ty of + HsParTy _ ty' -> forallty_bndrs ty' + HsForAllTy { hst_tele = HsForAllInvis { hsf_invis_bndrs = tvs }} + -> map unLoc tvs + _ -> [] + +{- +Note [Unobservably inferred type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +While GHC's parser allows the use of inferred type variables +(e.g., `forall {a}. <...>`) just about anywhere that type variable binders can +appear, there are some situations where the distinction between inferred and +specified type variables cannot be observed. For example, consider this +instance declaration: + + instance forall {a}. Eq (T a) where ... + +Making {a} inferred is pointless, as there is no way for user code to +"apply" an instance declaration in a way where the inferred/specified +distinction would make a difference. (Notably, there is no opportunity +for visible type application of an instance declaration.) Anyone who +writes such code is likely confused, so in an attempt to be helpful, +we emit an error message if a user writes code like this. The +checkInferredVars function is responsible for implementing this +restriction. + +It turns out to be somewhat cumbersome to enforce this restriction in +certain cases. Specifically: + +* Quantified constraints. In the type `f :: (forall {a}. C a) => Proxy Int`, + there is no way to observe that {a} is inferred. Nevertheless, actually + rejecting this code would be tricky, as we would need to reject + `forall {a}. <...>` as a constraint but *accept* other uses of + `forall {a}. <...>` as a type (e.g., `g :: (forall {a}. a -> a) -> b -> b`). + This is quite tedious to do in practice, so we don't bother. + +* Default method type signatures (#18432). These are tricky because inferred + type variables can appear nested, e.g., + + class C a where + m :: forall b. a -> b -> forall c. c -> c + default m :: forall b. a -> b -> forall {c}. c -> c + m _ _ = id + + Robustly checking for nested, inferred type variables ends up being a pain, + so we don't try to do this. + +For now, we simply allow inferred quantifiers to be specified here, +even though doing so is pointless. All we lose is a warning. + +Aside from the places where we already use checkInferredVars, most of +the other places where inferred vars don't make sense are in any case +already prohibited from having foralls /at all/. For example: + + instance forall a. forall {b}. Eq (Either a b) where ... + +Here the nested `forall {b}` is already prohibited. (See +Note [No nested foralls or contexts in instance types] in GHC.Hs.Type). +-} + +-- | Examines a non-outermost type for @forall at s or contexts, which are assumed +-- to be nested. For example, in the following declaration: +-- +-- @ +-- instance forall a. forall b. C (Either a b) +-- @ +-- +-- The outermost @forall a@ is fine, but the nested @forall b@ is not. We +-- invoke 'noNestedForallsContextsErr' on the type @forall b. C (Either a b)@ +-- to catch the nested @forall@ and create a suitable error message. +-- 'noNestedForallsContextsErr' returns @'Just' err_msg@ if such a @forall@ or +-- context is found, and returns @Nothing@ otherwise. +-- +-- This is currently used in the following places: +-- +-- * In GADT constructor types (in 'rnConDecl'). +-- See @Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts)@ +-- in "GHC.Hs.Type". +-- +-- * In instance declaration types (in 'rnClsIntDecl' and 'rnSrcDerivDecl' in +-- "GHC.Rename.Module" and 'renameSig' in "GHC.Rename.Bind"). +-- See @Note [No nested foralls or contexts in instance types]@ in +-- "GHC.Hs.Type". +noNestedForallsContextsErr :: SDoc -> LHsType GhcRn -> Maybe (SrcSpan, SDoc) +noNestedForallsContextsErr what lty = + case ignoreParens lty of + L l (HsForAllTy { hst_tele = tele }) + | HsForAllVis{} <- tele + -- The only two places where this function is called correspond to + -- types of terms, so we give a slightly more descriptive error + -- message in the event that they contain visible dependent + -- quantification (currently only allowed in kinds). + -> Just (l, vcat [ text "Illegal visible, dependent quantification" <+> + text "in the type of a term" + , text "(GHC does not yet support this)" ]) + | HsForAllInvis{} <- tele + -> Just (l, nested_foralls_contexts_err) + L l (HsQualTy {}) + -> Just (l, nested_foralls_contexts_err) + _ -> Nothing + where + nested_foralls_contexts_err = + what <+> text "cannot contain nested" + <+> quotes forAllLit <> text "s or contexts" + +-- | A common way to invoke 'noNestedForallsContextsErr'. +addNoNestedForallsContextsErr :: HsDocContext -> SDoc -> LHsType GhcRn -> RnM () +addNoNestedForallsContextsErr ctxt what lty = + whenIsJust (noNestedForallsContextsErr what lty) $ \(l, err_msg) -> + addErrAt l $ withHsDocContext ctxt err_msg {- ************************************************************************ ===================================== testsuite/tests/quantified-constraints/T18432.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE QuantifiedConstraints #-} +module Bug where + +import Data.Proxy + +class C a where + m :: Proxy a + +f :: (forall {a}. C a) => Proxy Int +f = m ===================================== testsuite/tests/quantified-constraints/all.T ===================================== @@ -29,3 +29,4 @@ test('T17267c', normal, compile_fail, ['']) test('T17267d', normal, compile_and_run, ['']) test('T17267e', normal, compile_fail, ['']) test('T17458', normal, compile_fail, ['']) +test('T18432', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/ExplicitSpecificity4.hs → testsuite/tests/typecheck/should_compile/ExplicitSpecificity4.hs ===================================== ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -712,6 +712,7 @@ test('T18129', expect_broken(18129), compile, ['']) test('T18185', normal, compile, ['']) test('ExplicitSpecificityA1', normal, compile, ['']) test('ExplicitSpecificityA2', normal, compile, ['']) +test('ExplicitSpecificity4', normal, compile, ['']) test('T17775-viewpats-a', normal, compile, ['']) test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_fail/T18455.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE RankNTypes #-} +module T18455 where + +class C a + +instance C (Either a b) where + {-# SPECIALISE instance forall a. forall b. C (Either a b) #-} ===================================== testsuite/tests/typecheck/should_fail/T18455.stderr ===================================== @@ -0,0 +1,4 @@ + +T18455.hs:7:37: error: + SPECIALISE instance type cannot contain nested ‘forall’s or contexts + In a SPECIALISE instance pragma ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -568,7 +568,6 @@ test('T18127a', normal, compile_fail, ['']) test('ExplicitSpecificity1', normal, compile_fail, ['']) test('ExplicitSpecificity2', normal, compile_fail, ['']) test('ExplicitSpecificity3', normal, compile_fail, ['']) -test('ExplicitSpecificity4', normal, compile_fail, ['']) test('ExplicitSpecificity5', normal, compile_fail, ['']) test('ExplicitSpecificity6', normal, compile_fail, ['']) test('ExplicitSpecificity7', normal, compile_fail, ['']) @@ -578,3 +577,4 @@ test('ExplicitSpecificity10', normal, compile_fail, ['']) test('T18357', normal, compile_fail, ['']) test('T18357a', normal, compile_fail, ['']) test('T18357b', normal, compile_fail, ['']) +test('T18455', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/01c948eba4bea2d2c8ad340e12c1e7b732b334f7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/01c948eba4bea2d2c8ad340e12c1e7b732b334f7 You're receiving 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 Jul 30 11:12:25 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 30 Jul 2020 07:12:25 -0400 Subject: [Git][ghc/ghc][master] Don't mark closed type family equations as occurrences Message-ID: <5f22ab193b8a8_80b116148a4588341@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - 11 changed files: - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/TyCl.hs - testsuite/tests/indexed-types/should_fail/Overlap5.stderr - testsuite/tests/rename/should_fail/T16002.stderr - testsuite/tests/th/T15362.hs - testsuite/tests/th/T15362.stderr - + testsuite/tests/typecheck/should_compile/T18470.hs - + testsuite/tests/typecheck/should_compile/T18470.stderr - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T11623.stderr Changes: ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -424,11 +424,11 @@ patchCCallTarget unit callTarget = rnSrcInstDecl :: InstDecl GhcPs -> RnM (InstDecl GhcRn, FreeVars) rnSrcInstDecl (TyFamInstD { tfid_inst = tfi }) - = do { (tfi', fvs) <- rnTyFamInstDecl NonAssocTyFamEqn tfi + = do { (tfi', fvs) <- rnTyFamInstDecl (NonAssocTyFamEqn NotClosedTyFam) tfi ; return (TyFamInstD { tfid_ext = noExtField, tfid_inst = tfi' }, fvs) } rnSrcInstDecl (DataFamInstD { dfid_inst = dfi }) - = do { (dfi', fvs) <- rnDataFamInstDecl NonAssocTyFamEqn dfi + = do { (dfi', fvs) <- rnDataFamInstDecl (NonAssocTyFamEqn NotClosedTyFam) dfi ; return (DataFamInstD { dfid_ext = noExtField, dfid_inst = dfi' }, fvs) } rnSrcInstDecl (ClsInstD { cid_inst = cid }) @@ -763,8 +763,12 @@ rnFamInstEqn doc atfi rhs_kvars all_nms = all_imp_var_names ++ hsLTyVarNames bndrs' ; warnUnusedTypePatterns all_nms nms_used - ; let all_fvs = (rhs_fvs `plusFV` pat_fvs) `addOneFV` unLoc tycon' - -- type instance => use, hence addOneFV + ; let eqn_fvs = rhs_fvs `plusFV` pat_fvs + -- See Note [Type family equations and occurrences] + all_fvs = case atfi of + NonAssocTyFamEqn ClosedTyFam + -> eqn_fvs + _ -> eqn_fvs `addOneFV` unLoc tycon' ; return (HsIB { hsib_ext = all_imp_var_names -- Note [Wildcards in family instances] , hsib_body @@ -779,14 +783,14 @@ rnFamInstEqn doc atfi rhs_kvars -- The parent class, if we are dealing with an associated type family -- instance. mb_cls = case atfi of - NonAssocTyFamEqn -> Nothing + NonAssocTyFamEqn _ -> Nothing AssocTyFamDeflt cls -> Just cls AssocTyFamInst cls _ -> Just cls -- The type variables from the instance head, if we are dealing with an -- associated type family instance. inst_tvs = case atfi of - NonAssocTyFamEqn -> [] + NonAssocTyFamEqn _ -> [] AssocTyFamDeflt _ -> [] AssocTyFamInst _ inst_tvs -> inst_tvs @@ -809,48 +813,62 @@ rnTyFamInstDecl :: AssocTyFamInfo -> TyFamInstDecl GhcPs -> RnM (TyFamInstDecl GhcRn, FreeVars) rnTyFamInstDecl atfi (TyFamInstDecl { tfid_eqn = eqn }) - = do { (eqn', fvs) <- rnTyFamInstEqn atfi NotClosedTyFam eqn + = do { (eqn', fvs) <- rnTyFamInstEqn atfi eqn ; return (TyFamInstDecl { tfid_eqn = eqn' }, fvs) } -- | Tracks whether we are renaming: -- -- 1. A type family equation that is not associated --- with a parent type class ('NonAssocTyFamEqn') +-- with a parent type class ('NonAssocTyFamEqn'). Examples: -- --- 2. An associated type family default declaration ('AssocTyFamDeflt') +-- @ +-- type family F a +-- type instance F Int = Bool -- NonAssocTyFamEqn NotClosed -- --- 3. An associated type family instance declaration ('AssocTyFamInst') +-- type family G a where +-- G Int = Bool -- NonAssocTyFamEqn Closed +-- @ +-- +-- 2. An associated type family default declaration ('AssocTyFamDeflt'). +-- Example: +-- +-- @ +-- class C a where +-- type A a +-- type instance A a = a -> a -- AssocTyFamDeflt C +-- @ +-- +-- 3. An associated type family instance declaration ('AssocTyFamInst'). +-- Example: +-- +-- @ +-- instance C a => C [a] where +-- type A [a] = Bool -- AssocTyFamInst C [a] +-- @ data AssocTyFamInfo = NonAssocTyFamEqn - | AssocTyFamDeflt Name -- Name of the parent class - | AssocTyFamInst Name -- Name of the parent class - [Name] -- Names of the tyvars of the parent instance decl + ClosedTyFamInfo -- Is this a closed type family? + | AssocTyFamDeflt + Name -- Name of the parent class + | AssocTyFamInst + Name -- Name of the parent class + [Name] -- Names of the tyvars of the parent instance decl -- | Tracks whether we are renaming an equation in a closed type family -- equation ('ClosedTyFam') or not ('NotClosedTyFam'). data ClosedTyFamInfo = NotClosedTyFam - | ClosedTyFam (Located RdrName) Name - -- The names (RdrName and Name) of the closed type family + | ClosedTyFam rnTyFamInstEqn :: AssocTyFamInfo - -> ClosedTyFamInfo -> TyFamInstEqn GhcPs -> RnM (TyFamInstEqn GhcRn, FreeVars) -rnTyFamInstEqn atfi ctf_info +rnTyFamInstEqn atfi eqn@(HsIB { hsib_body = FamEqn { feqn_tycon = tycon , feqn_rhs = rhs }}) - = do { let rhs_kvs = extractHsTyRdrTyVarsKindVars rhs - ; (eqn'@(HsIB { hsib_body = - FamEqn { feqn_tycon = L _ tycon' }}), fvs) - <- rnFamInstEqn (TySynCtx tycon) atfi rhs_kvs eqn rnTySyn - ; case ctf_info of - NotClosedTyFam -> pure () - ClosedTyFam fam_rdr_name fam_name -> - checkTc (fam_name == tycon') $ - withHsDocContext (TyFamilyCtx fam_rdr_name) $ - wrongTyFamName fam_name tycon' - ; pure (eqn', fvs) } + = rnFamInstEqn (TySynCtx tycon) atfi rhs_kvs eqn rnTySyn + where + rhs_kvs = extractHsTyRdrTyVarsKindVars rhs rnTyFamDefltDecl :: Name -> TyFamDefltDecl GhcPs @@ -998,6 +1016,51 @@ was previously bound by the `instance C (Maybe a)` part. (see #16116). In each case, the function which detects improperly bound variables on the RHS is GHC.Tc.Validity.checkValidFamPats. + +Note [Type family equations and occurrences] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In most data/type family equations, the type family name used in the equation +is treated as an occurrence. For example: + + module A where + type family F a + + module B () where + import B (F) + type instance F Int = Bool + +We do not want to warn about `F` being unused in the module `B`, as the +instance constitutes a use site for `F`. The exception to this rule is closed +type families, whose equations constitute a definition, not occurrences. For +example: + + module C () where + type family CF a where + CF Char = Float + +Here, we /do/ want to warn that `CF` is unused in the module `C`, as it is +defined but not used (#18470). + +GHC accomplishes this in rnFamInstEqn when determining the set of free +variables to return at the end. If renaming a data family or open type family +equation, we add the name of the type family constructor to the set of returned +free variables to ensure that the name is marked as an occurrence. If renaming +a closed type family equation, we avoid adding the type family constructor name +to the free variables. This is quite simple, but it is not a perfect solution. +Consider this example: + + module X () where + type family F a where + F Int = Bool + F Double = F Int + +At present, GHC will treat any use of a type family constructor on the RHS of a +type family equation as an occurrence. Since `F` is used on the RHS of the +second equation of `F`, it is treated as an occurrence, causing `F` not to be +warned about. This is not ideal, since `F` isn't exported—it really /should/ +cause a warning to be emitted. There is some discussion in #10089/#12920 about +how this limitation might be overcome, but until then, we stick to the +simplistic solution above, as it fixes the egregious bug in #18470. -} @@ -1948,7 +2011,7 @@ rnFamDecl mb_cls (FamilyDecl { fdLName = tycon, fdTyVars = tyvars ; injectivity' <- traverse (rnInjectivityAnn tyvars' res_sig') injectivity ; return ( (tyvars', res_sig', injectivity') , fv_kind ) } - ; (info', fv2) <- rn_info tycon' info + ; (info', fv2) <- rn_info info ; return (FamilyDecl { fdExt = noExtField , fdLName = tycon', fdTyVars = tyvars' , fdFixity = fixity @@ -1960,18 +2023,16 @@ rnFamDecl mb_cls (FamilyDecl { fdLName = tycon, fdTyVars = tyvars kvs = extractRdrKindSigVars res_sig ---------------------- - rn_info :: Located Name - -> FamilyInfo GhcPs -> RnM (FamilyInfo GhcRn, FreeVars) - rn_info (L _ fam_name) (ClosedTypeFamily (Just eqns)) + rn_info :: FamilyInfo GhcPs -> RnM (FamilyInfo GhcRn, FreeVars) + rn_info (ClosedTypeFamily (Just eqns)) = do { (eqns', fvs) - <- rnList (rnTyFamInstEqn NonAssocTyFamEqn (ClosedTyFam tycon fam_name)) + <- rnList (rnTyFamInstEqn (NonAssocTyFamEqn ClosedTyFam)) eqns -- no class context - eqns ; return (ClosedTypeFamily (Just eqns'), fvs) } - rn_info _ (ClosedTypeFamily Nothing) + rn_info (ClosedTypeFamily Nothing) = return (ClosedTypeFamily Nothing, emptyFVs) - rn_info _ OpenTypeFamily = return (OpenTypeFamily, emptyFVs) - rn_info _ DataFamily = return (DataFamily, emptyFVs) + rn_info OpenTypeFamily = return (OpenTypeFamily, emptyFVs) + rn_info DataFamily = return (DataFamily, emptyFVs) rnFamResultSig :: HsDocContext -> FamilyResultSig GhcPs @@ -2115,13 +2176,6 @@ are no data constructors we allow h98_style = True * * ***************************************************** -} ---------------- -wrongTyFamName :: Name -> Name -> SDoc -wrongTyFamName fam_tc_name eqn_tc_name - = hang (text "Mismatched type name in type family instance.") - 2 (vcat [ text "Expected:" <+> ppr fam_tc_name - , text " Actual:" <+> ppr eqn_tc_name ]) - ----------------- rnConDecls :: [LConDecl GhcPs] -> RnM ([LConDecl GhcRn], FreeVars) rnConDecls = mapFvRn (wrapLocFstM rnConDecl) ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -67,8 +67,8 @@ data AssocInstInfo } isNotAssociated :: AssocInstInfo -> Bool -isNotAssociated NotAssociated = True -isNotAssociated (InClsInst {}) = False +isNotAssociated (NotAssociated {}) = True +isNotAssociated (InClsInst {}) = False {- ******************************************************************* ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -2833,8 +2833,17 @@ kcTyFamInstEqn tc_fam_tc , text "feqn_pats =" <+> ppr hs_pats ]) -- this check reports an arity error instead of a kind error; easier for user ; let vis_pats = numVisibleArgs hs_pats + + -- First, check if we're dealing with a closed type family equation, and + -- if so, ensure that each equation's type constructor is for the right + -- type family. E.g. barf on + -- type family F a where { G Int = Bool } + ; checkTc (tc_fam_tc_name == eqn_tc_name) $ + wrongTyFamName tc_fam_tc_name eqn_tc_name + ; checkTc (vis_pats == vis_arity) $ wrongNumberOfParmsErr vis_arity + ; discardResult $ bindImplicitTKBndrs_Q_Tv imp_vars $ bindExplicitTKBndrs_Q_Tv AnyKind (mb_expl_bndrs `orElse` []) $ @@ -2848,7 +2857,7 @@ kcTyFamInstEqn tc_fam_tc } where vis_arity = length (tyConVisibleTyVars tc_fam_tc) - + tc_fam_tc_name = getName tc_fam_tc -------------------------- tcTyFamInstEqn :: TcTyCon -> AssocInstInfo -> LTyFamInstEqn GhcRn @@ -2858,22 +2867,22 @@ tcTyFamInstEqn :: TcTyCon -> AssocInstInfo -> LTyFamInstEqn GhcRn tcTyFamInstEqn fam_tc mb_clsinfo (L loc (HsIB { hsib_ext = imp_vars - , hsib_body = FamEqn { feqn_tycon = L _ eqn_tc_name - , feqn_bndrs = mb_expl_bndrs + , hsib_body = FamEqn { feqn_bndrs = mb_expl_bndrs , feqn_pats = hs_pats , feqn_rhs = hs_rhs_ty }})) - = ASSERT( getName fam_tc == eqn_tc_name ) - setSrcSpan loc $ + = setSrcSpan loc $ do { traceTc "tcTyFamInstEqn" $ vcat [ ppr fam_tc <+> ppr hs_pats , text "fam tc bndrs" <+> pprTyVars (tyConTyVars fam_tc) , case mb_clsinfo of - NotAssociated -> empty + NotAssociated {} -> empty InClsInst { ai_class = cls } -> text "class" <+> ppr cls <+> pprTyVars (classTyVars cls) ] -- First, check the arity of visible arguments -- If we wait until validity checking, we'll get kind errors -- below when an arity error will be much easier to understand. + -- Note that for closed type families, kcTyFamInstEqn has already + -- checked the arity previously. ; let vis_arity = length (tyConVisibleTyVars fam_tc) vis_pats = numVisibleArgs hs_pats ; checkTc (vis_pats == vis_arity) $ @@ -4919,6 +4928,12 @@ incoherentRoles = (text "Roles other than" <+> quotes (text "nominal") <+> text "for class parameters can lead to incoherence.") $$ (text "Use IncoherentInstances to allow this; bad role found") +wrongTyFamName :: Name -> Name -> SDoc +wrongTyFamName fam_tc_name eqn_tc_name + = hang (text "Mismatched type name in type family instance.") + 2 (vcat [ text "Expected:" <+> ppr fam_tc_name + , text " Actual:" <+> ppr eqn_tc_name ]) + addTyConCtxt :: TyCon -> TcM a -> TcM a addTyConCtxt tc = addTyConFlavCtxt name flav where ===================================== testsuite/tests/indexed-types/should_fail/Overlap5.stderr ===================================== @@ -1,6 +1,6 @@ Overlap5.hs:8:3: error: - Mismatched type name in type family instance. - Expected: F - Actual: G - In the declaration for type family ‘F’ + • Mismatched type name in type family instance. + Expected: F + Actual: G + • In the type family declaration for ‘F’ ===================================== testsuite/tests/rename/should_fail/T16002.stderr ===================================== @@ -1,6 +1,6 @@ T16002.hs:6:3: error: - Mismatched type name in type family instance. - Expected: B - Actual: A - In the declaration for type family ‘B’ + • Mismatched type name in type family instance. + Expected: B + Actual: A + • In the type family declaration for ‘B’ ===================================== testsuite/tests/th/T15362.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds #-} +{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds, TypeFamilies #-} module T15362 where ===================================== testsuite/tests/th/T15362.stderr ===================================== @@ -1,10 +1,6 @@ -T15362.hs:8:10: error: +T15362.hs:7:2: error: • Mismatched type name in type family instance. Expected: + Actual: Maybe - In the declaration for type family ‘+’ - • In the Template Haskell quotation - [d| type family a + b where - Maybe Zero b = b - Succ a + b = Succ (a + b) |] + • In the type family declaration for ‘+’ ===================================== testsuite/tests/typecheck/should_compile/T18470.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC -Wunused-top-binds #-} + +module T18470 () where + +type family Closed x where + Closed Int = Bool ===================================== testsuite/tests/typecheck/should_compile/T18470.stderr ===================================== @@ -0,0 +1,3 @@ + +T18470.hs:6:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] + Defined but not used: type constructor or class ‘Closed’ ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -718,3 +718,4 @@ test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) test('T17775-viewpats-d', normal, compile_fail, ['']) test('T18412', normal, compile, ['']) +test('T18470', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T11623.stderr ===================================== @@ -1,6 +1,6 @@ T11623.hs:5:23: error: - Mismatched type name in type family instance. - Expected: T - Actual: Maybe - In the declaration for type family ‘T’ + • Mismatched type name in type family instance. + Expected: T + Actual: Maybe + • In the type family declaration for ‘T’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d47324ce49b0c4f419823cbd7fd47e134a1b255a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d47324ce49b0c4f419823cbd7fd47e134a1b255a You're receiving 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 Jul 30 11:13:32 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 30 Jul 2020 07:13:32 -0400 Subject: [Git][ghc/ghc][master] Add two bangs to improve perf of flattening Message-ID: <5f22ab5c187e1_80b116148a458871d8@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 1 changed file: - compiler/GHC/Core/Coercion.hs Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -1891,7 +1891,9 @@ substForAllCoBndrUsingLC sym sco (LC subst lc_env) tv co -- -- For the inverse operation, see 'liftCoMatch' ty_co_subst :: LiftingContext -> Role -> Type -> Coercion -ty_co_subst lc role ty +ty_co_subst !lc role ty + -- !lc: making this function strict in lc allows callers to + -- pass its two components separately, rather than boxing them = go role ty where go :: Role -> Type -> Coercion @@ -2864,9 +2866,9 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs -- need a coercion (kind_co :: old_kind ~ new_kind). -- -- The bangs here have been observed to improve performance - -- significantly in optimized builds. - let kind_co = mkSymCo $ - liftCoSubst Nominal lc (tyCoBinderType binder) + -- significantly in optimized builds; see #18502 + let !kind_co = mkSymCo $ + liftCoSubst Nominal lc (tyCoBinderType binder) !casted_xi = xi `mkCastTy` kind_co casted_co = mkCoherenceLeftCo role xi kind_co co View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f71f69714255165d0fdc2790a588487ff9439dc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f71f69714255165d0fdc2790a588487ff9439dc You're receiving 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 Jul 30 11:12:57 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 30 Jul 2020 07:12:57 -0400 Subject: [Git][ghc/ghc][master] Remove an incorrect WARN in extendLocalRdrEnv Message-ID: <5f22ab39ab001_80b3f849a265454588426a@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 2 changed files: - compiler/GHC/Rename/Pat.hs - compiler/GHC/Types/Name/Reader.hs Changes: ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -236,19 +236,30 @@ newPatName (LetMk is_top fix_env) rdr_name do { name <- case is_top of NotTopLevel -> newLocalBndrRn rdr_name TopLevel -> newTopSrcBinder rdr_name - ; bindLocalNames [name] $ -- Do *not* use bindLocalNameFV here - -- See Note [View pattern usage] + ; bindLocalNames [name] $ + -- Do *not* use bindLocalNameFV here; + -- see Note [View pattern usage] + -- For the TopLevel case + -- see Note [bindLocalNames for an External name] addLocalFixities fix_env [name] $ thing_inside name }) - -- Note: the bindLocalNames is somewhat suspicious - -- because it binds a top-level name as a local name. - -- however, this binding seems to work, and it only exists for - -- the duration of the patterns and the continuation; - -- then the top-level name is added to the global env - -- before going on to the RHSes (see GHC.Rename.Module). +{- Note [bindLocalNames for an External name] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In the TopLevel case, the use of bindLocalNames here is somewhat +suspicious because it binds a top-level External name in the +LocalRdrEnv. c.f. Note [LocalRdrEnv] in GHC.Types.Name.Reader. + +However, this only happens when renaming the LHS (only) of a top-level +pattern binding. Even though this only the LHS, we need to bring the +binder into scope in the pattern itself in case the binder is used in +subsequent view patterns. A bit bizarre, something like + (x, Just y <- f x) = e + +Anyway, bindLocalNames does work, and the binding only exists for the +duration of the pattern; then the top-level name is added to the +global env before going on to the RHSes (see GHC.Rename.Module). -{- Note [View pattern usage] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -338,13 +338,24 @@ instance Ord RdrName where ************************************************************************ -} +{- Note [LocalRdrEnv] +~~~~~~~~~~~~~~~~~~~~~ +The LocalRdrEnv is used to store local bindings (let, where, lambda, case). + +* It is keyed by OccName, because we never use it for qualified names. + +* It maps the OccName to a Name. That Name is almost always an + Internal Name, but (hackily) it can be External too for top-level + pattern bindings. See Note [bindLocalNames for an External name] + in GHC.Rename.Pat + +* We keep the current mapping (lre_env), *and* the set of all Names in + scope (lre_in_scope). Reason: see Note [Splicing Exact names] in + GHC.Rename.Env. +-} + -- | Local Reader Environment --- --- This environment is used to store local bindings --- (@let@, @where@, lambda, @case@). --- It is keyed by OccName, because we never use it for qualified names --- We keep the current mapping, *and* the set of all Names in scope --- Reason: see Note [Splicing Exact names] in "GHC.Rename.Env" +-- See Note [LocalRdrEnv] data LocalRdrEnv = LRE { lre_env :: OccEnv Name , lre_in_scope :: NameSet } @@ -364,16 +375,15 @@ emptyLocalRdrEnv = LRE { lre_env = emptyOccEnv , lre_in_scope = emptyNameSet } extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv --- The Name should be a non-top-level thing +-- See Note [LocalRdrEnv] extendLocalRdrEnv lre@(LRE { lre_env = env, lre_in_scope = ns }) name - = WARN( isExternalName name, ppr name ) - lre { lre_env = extendOccEnv env (nameOccName name) name + = lre { lre_env = extendOccEnv env (nameOccName name) name , lre_in_scope = extendNameSet ns name } extendLocalRdrEnvList :: LocalRdrEnv -> [Name] -> LocalRdrEnv +-- See Note [LocalRdrEnv] extendLocalRdrEnvList lre@(LRE { lre_env = env, lre_in_scope = ns }) names - = WARN( any isExternalName names, ppr names ) - lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] + = lre { lre_env = extendOccEnvList env [(nameOccName n, n) | n <- names] , lre_in_scope = extendNameSetList ns names } lookupLocalRdrEnv :: LocalRdrEnv -> RdrName -> Maybe Name View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ebe2cf4538fa46994ef67663ac8fd5e579579803 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ebe2cf4538fa46994ef67663ac8fd5e579579803 You're receiving 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 Jul 30 11:44:19 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 30 Jul 2020 07:44:19 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: For `-fkeep-going` do not duplicate dependency edge code Message-ID: <5f22b2933ed8c_80b116148a45891795@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - bda03297 by Sylvain Henry at 2020-07-30T07:44:15-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 062234fd by Sylvain Henry at 2020-07-30T07:44:16-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 30 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Ppr/TyThing.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/indexed-types/should_fail/Overlap5.stderr - + testsuite/tests/quantified-constraints/T18432.hs - testsuite/tests/quantified-constraints/all.T - testsuite/tests/rename/should_compile/Makefile - + testsuite/tests/rename/should_compile/T18497.stdout - + testsuite/tests/rename/should_compile/T18497_Bar.hs - + testsuite/tests/rename/should_compile/T18497_Bar.hs-boot - + testsuite/tests/rename/should_compile/T18497_Foo.hs - + testsuite/tests/rename/should_compile/T18497_Foo.hs-boot - testsuite/tests/rename/should_compile/all.T - testsuite/tests/rename/should_fail/T16002.stderr - testsuite/tests/th/T15362.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2545583198d1eda0c21f62ebf704ee113df56bb8...062234fdaaa06b2de77095032cf4e7948b5a1a95 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2545583198d1eda0c21f62ebf704ee113df56bb8...062234fdaaa06b2de77095032cf4e7948b5a1a95 You're receiving 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 Jul 30 13:17:57 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 30 Jul 2020 09:17:57 -0400 Subject: [Git][ghc/ghc][ghc-8.10] 6 commits: Require SMP support in order to build a threaded stage1 Message-ID: <5f22c885b210b_80b104e15b45921594@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.10 at Glasgow Haskell Compiler / GHC Commits: 2e4fe920 by Stefan Schulze Frielinghaus at 2020-07-28T12:58:12-04:00 Require SMP support in order to build a threaded stage1 Fixes #18266 (cherry picked from commit fc0f6fbcd95f2dc69a8efabbee2d8a485c34cc47) - - - - - 4672b93e by Ben Gamari at 2020-07-29T22:59:54-04:00 base: Bump version for log1mexp fix - - - - - 9aa91006 by Ben Gamari at 2020-07-29T22:59:54-04:00 users-guide: Release notes for 8.10.2 - - - - - 7b82011a by Ben Gamari at 2020-07-29T22:59:54-04:00 Bump Cabal submodule - - - - - 750c51ba by Ben Gamari at 2020-07-29T22:59:54-04:00 Bump hsc2hs submodule to 0.68.7 - - - - - dbe09a23 by Ben Gamari at 2020-07-29T22:59:54-04:00 Release GHC 8.10.2 - - - - - 15 changed files: - configure.ac - docs/users_guide/8.10.2-notes.rst - libraries/Cabal - libraries/base/base.cabal - libraries/base/changelog.md - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - testsuite/tests/polykinds/T15592.stderr - testsuite/tests/polykinds/T15592b.stderr - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr - utils/hsc2hs Changes: ===================================== configure.ac ===================================== @@ -13,10 +13,10 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.10.1], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.10.2], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # 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 @@ -147,13 +147,17 @@ if test "$WithGhc" != ""; then BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command]) BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) + BOOTSTRAPPING_GHC_INFO_FIELD([SUPPORT_SMP_STAGE0],[Support SMP]) BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) dnl Check whether or not the bootstrapping GHC has a threaded RTS. This dnl determines whether or not we can have a threaded stage 1. dnl See Note [Linking ghc-bin against threaded stage0 RTS] in dnl hadrian/src/Settings/Packages.hs for details. - if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null; then + dnl SMP support which implies a registerised stage0 is also required (see issue 18266) + if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null && \ + test "$SUPPORT_SMP_STAGE0" = "YES" + then AC_SUBST(GhcThreadedRts, YES) else AC_SUBST(GhcThreadedRts, NO) ===================================== docs/users_guide/8.10.2-notes.rst ===================================== @@ -11,13 +11,26 @@ Highlights ---------- - A few important correctness fixes for the low-latency garbage collector. + Users of :rts-flag:`--nonmoving-gc` are strongly encouraged to upgrade + promptly. -Full details ------------- +- Fixes a bug in process creation on Windows (:ghc-ticket:`17926`). -Language -~~~~~~~~ +- Works around a Linux kernel bug in the implementation of ``timerfd``\s + (:ghc-ticket:`18033`). + +- Fixes a few specialiser regressions (:ghc-ticket:`17810`, + :ghc-ticket:`18120`) as well introduces a variety of miscellaneous + specialiser improvements (:ghc-ticket:`16473`, :ghc-ticket:`17930`, + :ghc-ticket:`17966`) + +- Fixes a potential loss of sharing due to left operator sections + (:ghc-ticket:`18151`). + +- Fix bootstrapping of GHC with the LLVM backend on x86-64 (:ghc-ticket:`17920`). +Full details +------------ Compiler ~~~~~~~~ @@ -25,20 +38,16 @@ Compiler - A simplifier panic manifesting when DWARF debug information is enabled has been fixed (:ghc-ticket:`18162`, :ghc-ticket:`17619`) -GHC API -~~~~~~~ - - -GHCi -~~~~ - Runtime system ~~~~~~~~~~~~~~ -- The RTS now allows the user to specify a minimum time between idle GCs with - the :rts-flag:`-Iw ⟨seconds⟩` flag. 8.10.1 contained a users guide reference - to this flag but did not include the associated implementation. + - The RTS now supports a flag, :rts-flag:`--copying-gc`, to counter-act the + effect of :rts-flag:`--nonmoving-gc`. + + - The RTS now allows the user to specify a minimum time between idle GCs with + the :rts-flag:`-Iw ⟨seconds⟩` flag. 8.10.1 contained a users guide reference + to this flag but did not include the associated implementation. - A memory leak in the cost-center profiler has been fixed (:ghc-ticket:`18348`) @@ -49,26 +58,40 @@ Runtime system - We now workaround a Linux kernel bug in the implementation of timerfd which could previously result in program crashes (:ghc-ticket:`18033`) -Template Haskell -~~~~~~~~~~~~~~~~ - - + - The cost center profiler's JSON output backend now escapes backslashes + correctly (:ghc-ticket:`18438`) -``ghc-prim`` library -~~~~~~~~~~~~~~~~~~~~ + - A variety of linker issues on ARM platforms have been fixed. - -``ghc`` library -~~~~~~~~~~~~~~~ - ``base`` library ~~~~~~~~~~~~~~~~ +- Fix a precision issue in the implementation of ``log1mexp`` + (:ghc-ticket:`17125`) + + Build system ~~~~~~~~~~~~ + - Fix a bug wherein GHC would link against the non-thread-safe unique supply + implementation when bootstrapping with an unregisterised compiler + (:ghc-ticket:`18024`) + +Known issues +------------ + +- A long-standing bug (:ghc-ticket:`16893`) which can cause some applications + of ``unsafeCoerce`` to segmentation fault is only partially fixed in this + release. This release only avoids this issue in the uses of ``unsafeCoerce`` + in ``Data.Typeable.Internal``, which was the proximate cause of + :ghc-ticket:`16893`. + + However, it is possible that this bug could manifest in user-code using + ``unsafeCoerce`` to perform dynamic type checks. See the :ghc-ticket:`ticket + <16893>` for details. + We expect that this issue will be fixed in the next major release of GHC. Included libraries ------------------ ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit b353baafe080e6aa6d542dd95658487b41e2254b +Subproject commit df65caf90ff79894dacecf73a642452aaabcc0a5 ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.14.0.0 +version: 4.14.1.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,6 +1,13 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.14.1.0* Jul 2020 + + * Bundled with GHC 8.10.2 + + * Fix a precision issue in `log1mexp` (#17125) + ## 4.14.0.0 *Jan 2020 + * Bundled with GHC 8.10.1 * Add a `TestEquality` instance for the `Compose` newtype. ===================================== testsuite/tests/dependent/should_compile/T14729.stderr ===================================== @@ -11,5 +11,5 @@ COERCION AXIOMS FAMILY INSTANCES type instance F Int = Bool -- Defined at T14729.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/dependent/should_compile/T15743.stderr ===================================== @@ -3,5 +3,5 @@ TYPE CONSTRUCTORS forall {k1} k2 (k3 :: k2). Proxy k3 -> k1 -> k2 -> * roles nominal nominal nominal phantom phantom phantom Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/dependent/should_compile/T15743e.stderr ===================================== @@ -52,5 +52,5 @@ DATA CONSTRUCTORS (d :: Proxy k5) (e :: Proxy k7). f c -> T k8 a b f c d e Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/indexed-types/should_compile/T15711.stderr ===================================== @@ -3,5 +3,5 @@ TYPE CONSTRUCTORS associated type family F{2} :: forall a. Maybe a -> * roles nominal nominal Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/indexed-types/should_compile/T15852.stderr ===================================== @@ -9,5 +9,5 @@ FAMILY INSTANCES data instance forall k1 k2 (j :: k1) (c :: k2). DF (Proxy c) -- Defined at T15852.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/polykinds/T15592.stderr ===================================== @@ -5,5 +5,5 @@ DATA CONSTRUCTORS MkT :: forall {k} k1 (f :: k1 -> k -> *) (a :: k1) (b :: k). f a b -> T f a b -> T f a b Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/polykinds/T15592b.stderr ===================================== @@ -4,5 +4,5 @@ TYPE CONSTRUCTORS forall k (f :: k -> *) (a :: k). f a -> * roles nominal nominal nominal nominal Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/typecheck/should_compile/T12763.stderr ===================================== @@ -8,5 +8,5 @@ COERCION AXIOMS CLASS INSTANCES instance C Int -- Defined at T12763.hs:9:10 Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-prim-0.6.1, - integer-gmp-1.0.2.0] +Dependent packages: [base-4.14.1.0, ghc-prim-0.6.1, + integer-gmp-1.0.3.0] ===================================== testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr ===================================== @@ -9,10 +9,10 @@ subsumption_sort_hole_fits.hs:2:5: warning: [-Wtyped-holes (in -Wdefault)] Valid hole fits include lines :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.14.0.0:Data.OldList’)) + (and originally defined in ‘base-4.14.1.0:Data.OldList’)) words :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.14.0.0:Data.OldList’)) + (and originally defined in ‘base-4.14.1.0:Data.OldList’)) read :: forall a. Read a => String -> a with read @[String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 ===================================== utils/hsc2hs ===================================== @@ -1 +1 @@ -Subproject commit ed109c719925e358f68b95970199c4b961de6817 +Subproject commit 24100ea521596922d3edc8370b3d9f7b845ae4cf View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5...dbe09a235cc1cd94215bbf7a43bcad01b253396f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5...dbe09a235cc1cd94215bbf7a43bcad01b253396f You're receiving 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 Jul 30 14:48:22 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 30 Jul 2020 10:48:22 -0400 Subject: [Git][ghc/ghc][ghc-8.10] 4 commits: Restore haskeline submodule to v0.8.0.0 Message-ID: <5f22ddb63e8bb_80b116148a459274ae@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.10 at Glasgow Haskell Compiler / GHC Commits: f34695e9 by Ben Gamari at 2020-07-30T10:48:10-04:00 Restore haskeline submodule to v0.8.0.0 It appears that this was incorrectly reverted in 4186c713e65dc5041d0b7a0e1d77f48edc763c3a. - - - - - 274989ff by Ben Gamari at 2020-07-30T10:48:10-04:00 users-guide: Mention LLVM version requirement - - - - - 484c4d89 by Ben Gamari at 2020-07-30T10:48:10-04:00 Use ld.gold to link on deb10 Otherwise we use ld.lld, which fails with ld.lld: error: -r and --export-dynamic may not be used together - - - - - bb0dae83 by Ben Gamari at 2020-07-30T10:48:10-04:00 Release GHC 8.10.2 - - - - - 4 changed files: - .gitlab-ci.yml - configure.ac - docs/users_guide/8.10.2-notes.rst - libraries/haskeline Changes: ===================================== .gitlab-ci.yml ===================================== @@ -655,6 +655,7 @@ validate-x86_64-linux-deb9-dwarf: variables: TEST_ENV: "x86_64-linux-deb10" BIN_DIST_PREP_TAR_COMP: "./ghc-x86_64-deb10-linux.tar.xz" + LD: "ld.gold" cache: key: linux-x86_64-deb10 ===================================== configure.ac ===================================== @@ -13,10 +13,10 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.10.1], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.10.2], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # 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 ===================================== docs/users_guide/8.10.2-notes.rst ===================================== @@ -6,6 +6,8 @@ Release notes for version 8.10.2 The significant changes to the various parts of the compiler are listed in the following sections. +Like previous releases in the 8.10 series, the :ghc-flag:`LLVM backend <-fllvm>` +of this release is to be used with LLVM 9. Highlights ---------- ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 98d69248d08389f349e12981da43797b8860ae67 +Subproject commit 463fc49d17bfab846cceba48bccc02ef285e6cba View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dbe09a235cc1cd94215bbf7a43bcad01b253396f...bb0dae833ec99d03eed9958e4dfcbef5970718cc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dbe09a235cc1cd94215bbf7a43bcad01b253396f...bb0dae833ec99d03eed9958e4dfcbef5970718cc You're receiving 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 Jul 30 14:48:46 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 30 Jul 2020 10:48:46 -0400 Subject: [Git][ghc/ghc] Pushed new tag ghc-8.10.2-rc2 Message-ID: <5f22ddced4ca1_80b104e15b459276ce@gitlab.haskell.org.mail> Ben Gamari pushed new tag ghc-8.10.2-rc2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-8.10.2-rc2 You're receiving 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 Jul 30 21:04:45 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 30 Jul 2020 17:04:45 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Fix minimal imports dump for boot files (fix #18497) Message-ID: <5f2335ed2e282_80b3f848c1e06f45976971@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9fa080e9 by Sylvain Henry at 2020-07-30T17:04:37-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - f412d075 by Sylvain Henry at 2020-07-30T17:04:39-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 6a1853af by Sylvain Henry at 2020-07-30T17:04:40-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 21 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Ppr/TyThing.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Types/Origin.hs - libraries/ghc-bignum/src/GHC/Num/BigNat/GMP.hs - testsuite/tests/lib/integer/all.T - testsuite/tests/lib/integer/integerPowMod.hs - testsuite/tests/lib/integer/integerPowMod.stdout - + testsuite/tests/numeric/should_run/T18515.hs - + testsuite/tests/numeric/should_run/T18515.stdout - testsuite/tests/numeric/should_run/all.T - testsuite/tests/rename/should_compile/Makefile - + testsuite/tests/rename/should_compile/T18497.stdout - + testsuite/tests/rename/should_compile/T18497_Bar.hs - + testsuite/tests/rename/should_compile/T18497_Bar.hs-boot - + testsuite/tests/rename/should_compile/T18497_Foo.hs - + testsuite/tests/rename/should_compile/T18497_Foo.hs-boot - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -87,9 +87,6 @@ import GHC.Utils.Binary import GHC.Types.Unique.Set import GHC.Types.Unique( mkAlphaTyVarUnique ) -import GHC.Driver.Session -import GHC.LanguageExtensions as LangExt - import Data.ByteString (ByteString) import qualified Data.ByteString.Builder as BSB import qualified Data.ByteString.Lazy as LBS @@ -1337,7 +1334,7 @@ The type of the constructor, with linear arrows replaced by unrestricted ones. Used when we don't want to introduce linear types to user (in holes and in types in hie used by haddock). -3. dataConDisplayType (depends on DynFlags): +3. dataConDisplayType (take a boolean indicating if -XLinearTypes is enabled): The type we'd like to show in error messages, :info and -ddump-types. Ideally, it should reflect the type written by the user; the function returns a type with arrows that would be required @@ -1384,9 +1381,9 @@ dataConNonlinearType (MkData { dcUserTyVarBinders = user_tvbs, mkVisFunTys arg_tys' $ res_ty -dataConDisplayType :: DynFlags -> DataCon -> Type -dataConDisplayType dflags dc - = if xopt LangExt.LinearTypes dflags +dataConDisplayType :: Bool -> DataCon -> Type +dataConDisplayType show_linear_types dc + = if show_linear_types then dataConWrapperType dc else dataConNonlinearType dc ===================================== compiler/GHC/Core/Ppr/TyThing.hs ===================================== @@ -166,7 +166,8 @@ pprTyThing :: ShowSub -> TyThing -> SDoc -- We pretty-print 'TyThing' via 'IfaceDecl' -- See Note [Pretty-printing TyThings] pprTyThing ss ty_thing - = sdocWithDynFlags (\dflags -> pprIfaceDecl ss' (tyThingToIfaceDecl dflags ty_thing)) + = sdocOption sdocLinearTypes $ \show_linear_types -> + pprIfaceDecl ss' (tyThingToIfaceDecl show_linear_types ty_thing) where ss' = case ss_how_much ss of ShowHeader (AltPpr Nothing) -> ss { ss_how_much = ShowHeader ppr' } ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -28,6 +28,7 @@ import GHC.Iface.Recomp import GHC.Iface.Load import GHC.CoreToIface +import qualified GHC.LanguageExtensions as LangExt import GHC.HsToCore.Usage ( mkUsageInfo, mkUsedNames, mkDependencies ) import GHC.Types.Id import GHC.Types.Annotations @@ -225,7 +226,8 @@ mkIface_ hsc_env = do let semantic_mod = canonicalizeHomeModule (hsc_dflags hsc_env) (moduleName this_mod) entities = typeEnvElts type_env - decls = [ tyThingToIfaceDecl (hsc_dflags hsc_env) entity + show_linear_types = xopt LangExt.LinearTypes (hsc_dflags hsc_env) + decls = [ tyThingToIfaceDecl show_linear_types entity | entity <- entities, let name = getName entity, not (isImplicitTyThing entity), @@ -376,12 +378,12 @@ so we may need to split up a single Avail into multiple ones. ************************************************************************ -} -tyThingToIfaceDecl :: DynFlags -> TyThing -> IfaceDecl +tyThingToIfaceDecl :: Bool -> TyThing -> IfaceDecl tyThingToIfaceDecl _ (AnId id) = idToIfaceDecl id tyThingToIfaceDecl _ (ATyCon tycon) = snd (tyConToIfaceDecl emptyTidyEnv tycon) tyThingToIfaceDecl _ (ACoAxiom ax) = coAxiomToIfaceDecl ax -tyThingToIfaceDecl dflags (AConLike cl) = case cl of - RealDataCon dc -> dataConToIfaceDecl dflags dc -- for ppr purposes only +tyThingToIfaceDecl show_linear_types (AConLike cl) = case cl of + RealDataCon dc -> dataConToIfaceDecl show_linear_types dc -- for ppr purposes only PatSynCon ps -> patSynToIfaceDecl ps -------------------------- @@ -397,10 +399,10 @@ idToIfaceDecl id ifIdInfo = toIfaceIdInfo (idInfo id) } -------------------------- -dataConToIfaceDecl :: DynFlags -> DataCon -> IfaceDecl -dataConToIfaceDecl dflags dataCon +dataConToIfaceDecl :: Bool -> DataCon -> IfaceDecl +dataConToIfaceDecl show_linear_types dataCon = IfaceId { ifName = getName dataCon, - ifType = toIfaceType (dataConDisplayType dflags dataCon), + ifType = toIfaceType (dataConDisplayType show_linear_types dataCon), ifIdDetails = IfVanillaId, ifIdInfo = [] } ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1234,11 +1234,11 @@ lookupChildren all_kids rdr_items ********************************************************* -} -reportUnusedNames :: TcGblEnv -> RnM () -reportUnusedNames gbl_env +reportUnusedNames :: TcGblEnv -> HscSource -> RnM () +reportUnusedNames gbl_env hsc_src = do { keep <- readTcRef (tcg_keep gbl_env) ; traceRn "RUN" (ppr (tcg_dus gbl_env)) - ; warnUnusedImportDecls gbl_env + ; warnUnusedImportDecls gbl_env hsc_src ; warnUnusedTopBinds $ unused_locals keep ; warnMissingSignatures gbl_env } where @@ -1360,8 +1360,8 @@ type ImportDeclUsage , [GlobalRdrElt] -- What *is* used (normalised) , [Name] ) -- What is imported but *not* used -warnUnusedImportDecls :: TcGblEnv -> RnM () -warnUnusedImportDecls gbl_env +warnUnusedImportDecls :: TcGblEnv -> HscSource -> RnM () +warnUnusedImportDecls gbl_env hsc_src = do { uses <- readMutVar (tcg_used_gres gbl_env) ; let user_imports = filterOut (ideclImplicit . unLoc) @@ -1383,7 +1383,7 @@ warnUnusedImportDecls gbl_env mapM_ (warnUnusedImport Opt_WarnUnusedImports fld_env) usage ; whenGOptM Opt_D_dump_minimal_imports $ - printMinimalImports usage } + printMinimalImports hsc_src usage } findImportUsage :: [LImportDecl GhcRn] -> [GlobalRdrElt] @@ -1619,9 +1619,9 @@ getMinimalImports = mapM mk_minimal all_non_overloaded = all (not . flIsOverloaded) -printMinimalImports :: [ImportDeclUsage] -> RnM () +printMinimalImports :: HscSource -> [ImportDeclUsage] -> RnM () -- See Note [Printing minimal imports] -printMinimalImports imports_w_usage +printMinimalImports hsc_src imports_w_usage = do { imports' <- getMinimalImports imports_w_usage ; this_mod <- getModule ; dflags <- getDynFlags @@ -1638,7 +1638,11 @@ printMinimalImports imports_w_usage | Just d <- dumpDir dflags = d basefn | otherwise = basefn where - basefn = moduleNameString (moduleName this_mod) ++ ".imports" + suffix = case hsc_src of + HsBootFile -> ".imports-boot" + HsSrcFile -> ".imports" + HsigFile -> ".imports" + basefn = moduleNameString (moduleName this_mod) ++ suffix to_ie_post_rn_var :: (HasOccName name) => Located name -> LIEWrappedName name ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -301,7 +301,7 @@ tcRnModuleTcRnM hsc_env mod_sum -- Do this /after/ typeinference, so that when reporting -- a function with no type signature we can give the -- inferred type - reportUnusedNames tcg_env + reportUnusedNames tcg_env hsc_src ; -- add extra source files to tcg_dependent_files addDependentFiles src_files ; tcg_env <- runTypecheckerPlugin mod_sum hsc_env tcg_env @@ -2973,8 +2973,8 @@ ppr_datacons debug type_env = ppr_things "DATA CONSTRUCTORS" ppr_dc wanted_dcs -- The filter gets rid of class data constructors where - ppr_dc dc = sdocWithDynFlags (\dflags -> - ppr dc <+> dcolon <+> ppr (dataConDisplayType dflags dc)) + ppr_dc dc = sdocOption sdocLinearTypes (\show_linear_types -> + ppr dc <+> dcolon <+> ppr (dataConDisplayType show_linear_types dc)) all_dcs = typeEnvDataCons type_env wanted_dcs | debug = all_dcs | otherwise = filterOut is_cls_dc all_dcs ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -4136,7 +4136,8 @@ checkValidDataCon dflags existential_ok tc con = hang herald 2 (text "on the" <+> speakNth n <+> text "argument of" <+> quotes (ppr con)) - data_con_display_type = dataConDisplayType dflags con + show_linear_types = xopt LangExt.LinearTypes dflags + data_con_display_type = dataConDisplayType show_linear_types con ------------------------------- checkNewDataCon :: DataCon -> TcM () @@ -4152,10 +4153,10 @@ checkNewDataCon con [ text "A newtype cannot have an unlifted argument type" , text "Perhaps you intended to use UnliftedNewtypes" ] - ; dflags <- getDynFlags + ; show_linear_types <- xopt LangExt.LinearTypes <$> getDynFlags ; let check_con what msg = - checkTc what (msg $$ ppr con <+> dcolon <+> ppr (dataConDisplayType dflags con)) + checkTc what (msg $$ ppr con <+> dcolon <+> ppr (dataConDisplayType show_linear_types con)) ; checkTc (ok_mult (scaledMult arg_ty1)) $ text "A newtype constructor must be linear" @@ -4843,10 +4844,10 @@ badGadtDecl tc_name badExistential :: DataCon -> SDoc badExistential con - = sdocWithDynFlags (\dflags -> + = sdocOption sdocLinearTypes (\show_linear_types -> hang (text "Data constructor" <+> quotes (ppr con) <+> text "has existential type variables, a context, or a specialised result type") - 2 (vcat [ ppr con <+> dcolon <+> ppr (dataConDisplayType dflags con) + 2 (vcat [ ppr con <+> dcolon <+> ppr (dataConDisplayType show_linear_types con) , parens $ text "Enable ExistentialQuantification or GADTs to allow this" ])) badStupidTheta :: Name -> SDoc ===================================== compiler/GHC/Tc/Types/Origin.hs ===================================== @@ -286,10 +286,10 @@ pprSigSkolInfo ctxt ty pprPatSkolInfo :: ConLike -> SDoc pprPatSkolInfo (RealDataCon dc) - = sdocWithDynFlags (\dflags -> + = sdocOption sdocLinearTypes (\show_linear_types -> sep [ text "a pattern with constructor:" , nest 2 $ ppr dc <+> dcolon - <+> pprType (dataConDisplayType dflags dc) <> comma ]) + <+> pprType (dataConDisplayType show_linear_types dc) <> comma ]) -- pprType prints forall's regardless of -fprint-explicit-foralls -- which is what we want here, since we might be saying -- type variable 't' is bound by ... ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat/GMP.hs ===================================== @@ -349,7 +349,8 @@ bignat_powmod -> State# RealWorld -> State# RealWorld bignat_powmod r b e m s = - ioVoid (integer_gmp_powm# r b (wordArraySize# b) e (wordArraySize# e) m (wordArraySize# m)) s + case ioInt# (integer_gmp_powm# r b (wordArraySize# b) e (wordArraySize# e) m (wordArraySize# m)) s of + (# s', n #) -> mwaSetSize# r (narrowGmpSize# n) s' ---------------------------------------------------------------------- ===================================== testsuite/tests/lib/integer/all.T ===================================== @@ -5,11 +5,11 @@ test('integerConstantFolding', normal, makefile_test, ['integerConstantFolding'] test('fromToInteger', [], makefile_test, ['fromToInteger']) test('IntegerConversionRules', [], makefile_test, ['IntegerConversionRules']) test('gcdInteger', normal, compile_and_run, ['']) +test('integerPowMod', [], compile_and_run, ['']) # skip ghci as it doesn't support unboxed tuples test('integerImportExport', [omit_ways(['ghci'])], compile_and_run, ['']) # Disable GMP only tests #test('integerGcdExt', [omit_ways(['ghci'])], compile_and_run, ['']) -#test('integerPowMod', [], compile_and_run, ['']) #test('integerGmpInternals', [], compile_and_run, ['']) ===================================== testsuite/tests/lib/integer/integerPowMod.hs ===================================== @@ -7,19 +7,12 @@ import Control.Monad import GHC.Word import GHC.Base -import qualified GHC.Integer.GMP.Internals as I - -powModSecInteger :: Integer -> Integer -> Integer -> Integer -powModSecInteger = I.powModSecInteger - -powModInteger :: Integer -> Integer -> Integer -> Integer -powModInteger = I.powModInteger +import GHC.Natural main :: IO () main = do - print $ powModInteger b e m - print $ powModInteger b e (m-1) - print $ powModSecInteger b e (m-1) + print $ powModNatural b e m + print $ powModNatural b e (m-1) where b = 2988348162058574136915891421498819466320163312926952423791023078876139 ===================================== testsuite/tests/lib/integer/integerPowMod.stdout ===================================== @@ -1,3 +1,2 @@ 1527229998585248450016808958343740453059 682382427572745901624116300491295556924 -682382427572745901624116300491295556924 ===================================== testsuite/tests/numeric/should_run/T18515.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE MagicHash #-} + +import GHC.Num.BigNat +import GHC.Num.Integer + +main :: IO () +main = + let b = integerToBigNatClamp# 251943445928310882947152017889649234 + e = integerToBigNatClamp# 503886891856621765894304035779298468 + m = integerToBigNatClamp# 503886891856621765894304035779298469 + r = integerFromBigNat# (bigNatPowMod b e m) + in print r ===================================== testsuite/tests/numeric/should_run/T18515.stdout ===================================== @@ -0,0 +1 @@ +1 ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -72,3 +72,4 @@ test('T17303', normal, compile_and_run, ['']) test('T18359', normal, compile_and_run, ['']) test('T18499', normal, compile_and_run, ['']) test('T18509', normal, compile_and_run, ['']) +test('T18515', normal, compile_and_run, ['']) ===================================== testsuite/tests/rename/should_compile/Makefile ===================================== @@ -56,3 +56,7 @@ T7969: '$(TEST_HC)' $(TEST_HC_OPTS) -c T7969a.hs '$(TEST_HC)' $(TEST_HC_OPTS) -c T7969.hs -ddump-minimal-imports cat T7969.imports + +T18497: + '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code T18497_Foo.hs T18497_Bar.hs -ddump-minimal-imports + cat T18497_Bar.imports-boot ===================================== testsuite/tests/rename/should_compile/T18497.stdout ===================================== @@ -0,0 +1,5 @@ +[1 of 4] Compiling T18497_Foo[boot] ( T18497_Foo.hs-boot, nothing ) +[2 of 4] Compiling T18497_Bar[boot] ( T18497_Bar.hs-boot, nothing ) +[3 of 4] Compiling T18497_Foo ( T18497_Foo.hs, nothing ) +[4 of 4] Compiling T18497_Bar ( T18497_Bar.hs, nothing ) +import {-# SOURCE #-} T18497_Foo ( X ) ===================================== testsuite/tests/rename/should_compile/T18497_Bar.hs ===================================== @@ -0,0 +1,14 @@ +module T18497_Bar where + +import T18497_Foo + +data Y = SomeY X | NoY + +blah :: Y +blah = NoY + +blip :: Y +blip = SomeY foo + +woop NoX = NoY +woop (SomeX y _) = y ===================================== testsuite/tests/rename/should_compile/T18497_Bar.hs-boot ===================================== @@ -0,0 +1,9 @@ +module T18497_Bar where + +import {-# SOURCE #-} T18497_Foo + +data Y + +blah :: Y + +woop :: X -> Y ===================================== testsuite/tests/rename/should_compile/T18497_Foo.hs ===================================== @@ -0,0 +1,8 @@ +module T18497_Foo where + +import {-# SOURCE #-} T18497_Bar + +data X = SomeX Y Y | NoX + +foo :: X +foo = SomeX blah (woop NoX) ===================================== testsuite/tests/rename/should_compile/T18497_Foo.hs-boot ===================================== @@ -0,0 +1,5 @@ +module T18497_Foo where + +data X + +foo :: X ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -174,3 +174,4 @@ test('T17244B', normal, compile, ['']) test('T17244C', normal, compile, ['']) test('T17832', [], multimod_compile, ['T17832M1', 'T17832M2']) test('T17837', normal, compile, ['']) +test('T18497', [], makefile_test, ['T18497']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/062234fdaaa06b2de77095032cf4e7948b5a1a95...6a1853aff6f8b74cead5ed67262458c5c74b0ff2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/062234fdaaa06b2de77095032cf4e7948b5a1a95...6a1853aff6f8b74cead5ed67262458c5c74b0ff2 You're receiving 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 Jul 31 02:54:55 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 30 Jul 2020 22:54:55 -0400 Subject: [Git][ghc/ghc][master] Fix minimal imports dump for boot files (fix #18497) Message-ID: <5f2387ff35f7e_80b3f849a25e690599148c@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7c274cd5 by Sylvain Henry at 2020-07-30T22:54:48-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 9 changed files: - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Module.hs - testsuite/tests/rename/should_compile/Makefile - + testsuite/tests/rename/should_compile/T18497.stdout - + testsuite/tests/rename/should_compile/T18497_Bar.hs - + testsuite/tests/rename/should_compile/T18497_Bar.hs-boot - + testsuite/tests/rename/should_compile/T18497_Foo.hs - + testsuite/tests/rename/should_compile/T18497_Foo.hs-boot - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1234,11 +1234,11 @@ lookupChildren all_kids rdr_items ********************************************************* -} -reportUnusedNames :: TcGblEnv -> RnM () -reportUnusedNames gbl_env +reportUnusedNames :: TcGblEnv -> HscSource -> RnM () +reportUnusedNames gbl_env hsc_src = do { keep <- readTcRef (tcg_keep gbl_env) ; traceRn "RUN" (ppr (tcg_dus gbl_env)) - ; warnUnusedImportDecls gbl_env + ; warnUnusedImportDecls gbl_env hsc_src ; warnUnusedTopBinds $ unused_locals keep ; warnMissingSignatures gbl_env } where @@ -1360,8 +1360,8 @@ type ImportDeclUsage , [GlobalRdrElt] -- What *is* used (normalised) , [Name] ) -- What is imported but *not* used -warnUnusedImportDecls :: TcGblEnv -> RnM () -warnUnusedImportDecls gbl_env +warnUnusedImportDecls :: TcGblEnv -> HscSource -> RnM () +warnUnusedImportDecls gbl_env hsc_src = do { uses <- readMutVar (tcg_used_gres gbl_env) ; let user_imports = filterOut (ideclImplicit . unLoc) @@ -1383,7 +1383,7 @@ warnUnusedImportDecls gbl_env mapM_ (warnUnusedImport Opt_WarnUnusedImports fld_env) usage ; whenGOptM Opt_D_dump_minimal_imports $ - printMinimalImports usage } + printMinimalImports hsc_src usage } findImportUsage :: [LImportDecl GhcRn] -> [GlobalRdrElt] @@ -1619,9 +1619,9 @@ getMinimalImports = mapM mk_minimal all_non_overloaded = all (not . flIsOverloaded) -printMinimalImports :: [ImportDeclUsage] -> RnM () +printMinimalImports :: HscSource -> [ImportDeclUsage] -> RnM () -- See Note [Printing minimal imports] -printMinimalImports imports_w_usage +printMinimalImports hsc_src imports_w_usage = do { imports' <- getMinimalImports imports_w_usage ; this_mod <- getModule ; dflags <- getDynFlags @@ -1638,7 +1638,11 @@ printMinimalImports imports_w_usage | Just d <- dumpDir dflags = d basefn | otherwise = basefn where - basefn = moduleNameString (moduleName this_mod) ++ ".imports" + suffix = case hsc_src of + HsBootFile -> ".imports-boot" + HsSrcFile -> ".imports" + HsigFile -> ".imports" + basefn = moduleNameString (moduleName this_mod) ++ suffix to_ie_post_rn_var :: (HasOccName name) => Located name -> LIEWrappedName name ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -301,7 +301,7 @@ tcRnModuleTcRnM hsc_env mod_sum -- Do this /after/ typeinference, so that when reporting -- a function with no type signature we can give the -- inferred type - reportUnusedNames tcg_env + reportUnusedNames tcg_env hsc_src ; -- add extra source files to tcg_dependent_files addDependentFiles src_files ; tcg_env <- runTypecheckerPlugin mod_sum hsc_env tcg_env ===================================== testsuite/tests/rename/should_compile/Makefile ===================================== @@ -56,3 +56,7 @@ T7969: '$(TEST_HC)' $(TEST_HC_OPTS) -c T7969a.hs '$(TEST_HC)' $(TEST_HC_OPTS) -c T7969.hs -ddump-minimal-imports cat T7969.imports + +T18497: + '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code T18497_Foo.hs T18497_Bar.hs -ddump-minimal-imports + cat T18497_Bar.imports-boot ===================================== testsuite/tests/rename/should_compile/T18497.stdout ===================================== @@ -0,0 +1,5 @@ +[1 of 4] Compiling T18497_Foo[boot] ( T18497_Foo.hs-boot, nothing ) +[2 of 4] Compiling T18497_Bar[boot] ( T18497_Bar.hs-boot, nothing ) +[3 of 4] Compiling T18497_Foo ( T18497_Foo.hs, nothing ) +[4 of 4] Compiling T18497_Bar ( T18497_Bar.hs, nothing ) +import {-# SOURCE #-} T18497_Foo ( X ) ===================================== testsuite/tests/rename/should_compile/T18497_Bar.hs ===================================== @@ -0,0 +1,14 @@ +module T18497_Bar where + +import T18497_Foo + +data Y = SomeY X | NoY + +blah :: Y +blah = NoY + +blip :: Y +blip = SomeY foo + +woop NoX = NoY +woop (SomeX y _) = y ===================================== testsuite/tests/rename/should_compile/T18497_Bar.hs-boot ===================================== @@ -0,0 +1,9 @@ +module T18497_Bar where + +import {-# SOURCE #-} T18497_Foo + +data Y + +blah :: Y + +woop :: X -> Y ===================================== testsuite/tests/rename/should_compile/T18497_Foo.hs ===================================== @@ -0,0 +1,8 @@ +module T18497_Foo where + +import {-# SOURCE #-} T18497_Bar + +data X = SomeX Y Y | NoX + +foo :: X +foo = SomeX blah (woop NoX) ===================================== testsuite/tests/rename/should_compile/T18497_Foo.hs-boot ===================================== @@ -0,0 +1,5 @@ +module T18497_Foo where + +data X + +foo :: X ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -174,3 +174,4 @@ test('T17244B', normal, compile, ['']) test('T17244C', normal, compile, ['']) test('T17832', [], multimod_compile, ['T17832M1', 'T17832M2']) test('T17837', normal, compile, ['']) +test('T18497', [], makefile_test, ['T18497']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7c274cd530cc42a26028050b75d56b3437e06ec1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7c274cd530cc42a26028050b75d56b3437e06ec1 You're receiving 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 Jul 31 02:55:31 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 30 Jul 2020 22:55:31 -0400 Subject: [Git][ghc/ghc][master] DynFlags: don't use sdocWithDynFlags in datacon ppr Message-ID: <5f23882394725_80b3f848a37384c59920cc@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 175cb5b4 by Sylvain Henry at 2020-07-30T22:55:25-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 6 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Ppr/TyThing.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Types/Origin.hs Changes: ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -87,9 +87,6 @@ import GHC.Utils.Binary import GHC.Types.Unique.Set import GHC.Types.Unique( mkAlphaTyVarUnique ) -import GHC.Driver.Session -import GHC.LanguageExtensions as LangExt - import Data.ByteString (ByteString) import qualified Data.ByteString.Builder as BSB import qualified Data.ByteString.Lazy as LBS @@ -1337,7 +1334,7 @@ The type of the constructor, with linear arrows replaced by unrestricted ones. Used when we don't want to introduce linear types to user (in holes and in types in hie used by haddock). -3. dataConDisplayType (depends on DynFlags): +3. dataConDisplayType (take a boolean indicating if -XLinearTypes is enabled): The type we'd like to show in error messages, :info and -ddump-types. Ideally, it should reflect the type written by the user; the function returns a type with arrows that would be required @@ -1384,9 +1381,9 @@ dataConNonlinearType (MkData { dcUserTyVarBinders = user_tvbs, mkVisFunTys arg_tys' $ res_ty -dataConDisplayType :: DynFlags -> DataCon -> Type -dataConDisplayType dflags dc - = if xopt LangExt.LinearTypes dflags +dataConDisplayType :: Bool -> DataCon -> Type +dataConDisplayType show_linear_types dc + = if show_linear_types then dataConWrapperType dc else dataConNonlinearType dc ===================================== compiler/GHC/Core/Ppr/TyThing.hs ===================================== @@ -166,7 +166,8 @@ pprTyThing :: ShowSub -> TyThing -> SDoc -- We pretty-print 'TyThing' via 'IfaceDecl' -- See Note [Pretty-printing TyThings] pprTyThing ss ty_thing - = sdocWithDynFlags (\dflags -> pprIfaceDecl ss' (tyThingToIfaceDecl dflags ty_thing)) + = sdocOption sdocLinearTypes $ \show_linear_types -> + pprIfaceDecl ss' (tyThingToIfaceDecl show_linear_types ty_thing) where ss' = case ss_how_much ss of ShowHeader (AltPpr Nothing) -> ss { ss_how_much = ShowHeader ppr' } ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -28,6 +28,7 @@ import GHC.Iface.Recomp import GHC.Iface.Load import GHC.CoreToIface +import qualified GHC.LanguageExtensions as LangExt import GHC.HsToCore.Usage ( mkUsageInfo, mkUsedNames, mkDependencies ) import GHC.Types.Id import GHC.Types.Annotations @@ -225,7 +226,8 @@ mkIface_ hsc_env = do let semantic_mod = canonicalizeHomeModule (hsc_dflags hsc_env) (moduleName this_mod) entities = typeEnvElts type_env - decls = [ tyThingToIfaceDecl (hsc_dflags hsc_env) entity + show_linear_types = xopt LangExt.LinearTypes (hsc_dflags hsc_env) + decls = [ tyThingToIfaceDecl show_linear_types entity | entity <- entities, let name = getName entity, not (isImplicitTyThing entity), @@ -376,12 +378,12 @@ so we may need to split up a single Avail into multiple ones. ************************************************************************ -} -tyThingToIfaceDecl :: DynFlags -> TyThing -> IfaceDecl +tyThingToIfaceDecl :: Bool -> TyThing -> IfaceDecl tyThingToIfaceDecl _ (AnId id) = idToIfaceDecl id tyThingToIfaceDecl _ (ATyCon tycon) = snd (tyConToIfaceDecl emptyTidyEnv tycon) tyThingToIfaceDecl _ (ACoAxiom ax) = coAxiomToIfaceDecl ax -tyThingToIfaceDecl dflags (AConLike cl) = case cl of - RealDataCon dc -> dataConToIfaceDecl dflags dc -- for ppr purposes only +tyThingToIfaceDecl show_linear_types (AConLike cl) = case cl of + RealDataCon dc -> dataConToIfaceDecl show_linear_types dc -- for ppr purposes only PatSynCon ps -> patSynToIfaceDecl ps -------------------------- @@ -397,10 +399,10 @@ idToIfaceDecl id ifIdInfo = toIfaceIdInfo (idInfo id) } -------------------------- -dataConToIfaceDecl :: DynFlags -> DataCon -> IfaceDecl -dataConToIfaceDecl dflags dataCon +dataConToIfaceDecl :: Bool -> DataCon -> IfaceDecl +dataConToIfaceDecl show_linear_types dataCon = IfaceId { ifName = getName dataCon, - ifType = toIfaceType (dataConDisplayType dflags dataCon), + ifType = toIfaceType (dataConDisplayType show_linear_types dataCon), ifIdDetails = IfVanillaId, ifIdInfo = [] } ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2973,8 +2973,8 @@ ppr_datacons debug type_env = ppr_things "DATA CONSTRUCTORS" ppr_dc wanted_dcs -- The filter gets rid of class data constructors where - ppr_dc dc = sdocWithDynFlags (\dflags -> - ppr dc <+> dcolon <+> ppr (dataConDisplayType dflags dc)) + ppr_dc dc = sdocOption sdocLinearTypes (\show_linear_types -> + ppr dc <+> dcolon <+> ppr (dataConDisplayType show_linear_types dc)) all_dcs = typeEnvDataCons type_env wanted_dcs | debug = all_dcs | otherwise = filterOut is_cls_dc all_dcs ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -4136,7 +4136,8 @@ checkValidDataCon dflags existential_ok tc con = hang herald 2 (text "on the" <+> speakNth n <+> text "argument of" <+> quotes (ppr con)) - data_con_display_type = dataConDisplayType dflags con + show_linear_types = xopt LangExt.LinearTypes dflags + data_con_display_type = dataConDisplayType show_linear_types con ------------------------------- checkNewDataCon :: DataCon -> TcM () @@ -4152,10 +4153,10 @@ checkNewDataCon con [ text "A newtype cannot have an unlifted argument type" , text "Perhaps you intended to use UnliftedNewtypes" ] - ; dflags <- getDynFlags + ; show_linear_types <- xopt LangExt.LinearTypes <$> getDynFlags ; let check_con what msg = - checkTc what (msg $$ ppr con <+> dcolon <+> ppr (dataConDisplayType dflags con)) + checkTc what (msg $$ ppr con <+> dcolon <+> ppr (dataConDisplayType show_linear_types con)) ; checkTc (ok_mult (scaledMult arg_ty1)) $ text "A newtype constructor must be linear" @@ -4843,10 +4844,10 @@ badGadtDecl tc_name badExistential :: DataCon -> SDoc badExistential con - = sdocWithDynFlags (\dflags -> + = sdocOption sdocLinearTypes (\show_linear_types -> hang (text "Data constructor" <+> quotes (ppr con) <+> text "has existential type variables, a context, or a specialised result type") - 2 (vcat [ ppr con <+> dcolon <+> ppr (dataConDisplayType dflags con) + 2 (vcat [ ppr con <+> dcolon <+> ppr (dataConDisplayType show_linear_types con) , parens $ text "Enable ExistentialQuantification or GADTs to allow this" ])) badStupidTheta :: Name -> SDoc ===================================== compiler/GHC/Tc/Types/Origin.hs ===================================== @@ -286,10 +286,10 @@ pprSigSkolInfo ctxt ty pprPatSkolInfo :: ConLike -> SDoc pprPatSkolInfo (RealDataCon dc) - = sdocWithDynFlags (\dflags -> + = sdocOption sdocLinearTypes (\show_linear_types -> sep [ text "a pattern with constructor:" , nest 2 $ ppr dc <+> dcolon - <+> pprType (dataConDisplayType dflags dc) <> comma ]) + <+> pprType (dataConDisplayType show_linear_types dc) <> comma ]) -- pprType prints forall's regardless of -fprint-explicit-foralls -- which is what we want here, since we might be saying -- type variable 't' is bound by ... View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/175cb5b4044e6f4ad2224f54115f42e7a8b08f9b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/175cb5b4044e6f4ad2224f54115f42e7a8b08f9b You're receiving 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 Jul 31 02:56:10 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 30 Jul 2020 22:56:10 -0400 Subject: [Git][ghc/ghc][master] Bignum: fix powMod for gmp backend (#18515) Message-ID: <5f23884a4e45c_80bf016abc5996650@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 380638a3 by Sylvain Henry at 2020-07-30T22:56:03-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 7 changed files: - libraries/ghc-bignum/src/GHC/Num/BigNat/GMP.hs - testsuite/tests/lib/integer/all.T - testsuite/tests/lib/integer/integerPowMod.hs - testsuite/tests/lib/integer/integerPowMod.stdout - + testsuite/tests/numeric/should_run/T18515.hs - + testsuite/tests/numeric/should_run/T18515.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat/GMP.hs ===================================== @@ -349,7 +349,8 @@ bignat_powmod -> State# RealWorld -> State# RealWorld bignat_powmod r b e m s = - ioVoid (integer_gmp_powm# r b (wordArraySize# b) e (wordArraySize# e) m (wordArraySize# m)) s + case ioInt# (integer_gmp_powm# r b (wordArraySize# b) e (wordArraySize# e) m (wordArraySize# m)) s of + (# s', n #) -> mwaSetSize# r (narrowGmpSize# n) s' ---------------------------------------------------------------------- ===================================== testsuite/tests/lib/integer/all.T ===================================== @@ -5,11 +5,11 @@ test('integerConstantFolding', normal, makefile_test, ['integerConstantFolding'] test('fromToInteger', [], makefile_test, ['fromToInteger']) test('IntegerConversionRules', [], makefile_test, ['IntegerConversionRules']) test('gcdInteger', normal, compile_and_run, ['']) +test('integerPowMod', [], compile_and_run, ['']) # skip ghci as it doesn't support unboxed tuples test('integerImportExport', [omit_ways(['ghci'])], compile_and_run, ['']) # Disable GMP only tests #test('integerGcdExt', [omit_ways(['ghci'])], compile_and_run, ['']) -#test('integerPowMod', [], compile_and_run, ['']) #test('integerGmpInternals', [], compile_and_run, ['']) ===================================== testsuite/tests/lib/integer/integerPowMod.hs ===================================== @@ -7,19 +7,12 @@ import Control.Monad import GHC.Word import GHC.Base -import qualified GHC.Integer.GMP.Internals as I - -powModSecInteger :: Integer -> Integer -> Integer -> Integer -powModSecInteger = I.powModSecInteger - -powModInteger :: Integer -> Integer -> Integer -> Integer -powModInteger = I.powModInteger +import GHC.Natural main :: IO () main = do - print $ powModInteger b e m - print $ powModInteger b e (m-1) - print $ powModSecInteger b e (m-1) + print $ powModNatural b e m + print $ powModNatural b e (m-1) where b = 2988348162058574136915891421498819466320163312926952423791023078876139 ===================================== testsuite/tests/lib/integer/integerPowMod.stdout ===================================== @@ -1,3 +1,2 @@ 1527229998585248450016808958343740453059 682382427572745901624116300491295556924 -682382427572745901624116300491295556924 ===================================== testsuite/tests/numeric/should_run/T18515.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE MagicHash #-} + +import GHC.Num.BigNat +import GHC.Num.Integer + +main :: IO () +main = + let b = integerToBigNatClamp# 251943445928310882947152017889649234 + e = integerToBigNatClamp# 503886891856621765894304035779298468 + m = integerToBigNatClamp# 503886891856621765894304035779298469 + r = integerFromBigNat# (bigNatPowMod b e m) + in print r ===================================== testsuite/tests/numeric/should_run/T18515.stdout ===================================== @@ -0,0 +1 @@ +1 ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -72,3 +72,4 @@ test('T17303', normal, compile_and_run, ['']) test('T18359', normal, compile_and_run, ['']) test('T18499', normal, compile_and_run, ['']) test('T18509', normal, compile_and_run, ['']) +test('T18515', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/380638a33691ba43fdcd2e18bca636750e5f66f1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/380638a33691ba43fdcd2e18bca636750e5f66f1 You're receiving 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 Jul 31 11:10:51 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 31 Jul 2020 07:10:51 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T8095-spj Message-ID: <5f23fc3bb102f_80b3f848a37384c60014fb@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T8095-spj at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T8095-spj You're receiving 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 Jul 31 15:51:22 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Fri, 31 Jul 2020 11:51:22 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/test-t17652 Message-ID: <5f243dfac22b7_80b3f849c1caa106015263@gitlab.haskell.org.mail> Vladislav Zavialov pushed new branch wip/test-t17652 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/test-t17652 You're receiving 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 Jul 31 15:58:57 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 31 Jul 2020 11:58:57 -0400 Subject: [Git][ghc/ghc][wip/T18323] 19 commits: Fix typo Message-ID: <5f243fc1a5026_80b3f848a37384c601684b@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18323 at Glasgow Haskell Compiler / GHC Commits: b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 7c274cd5 by Sylvain Henry at 2020-07-30T22:54:48-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 175cb5b4 by Sylvain Henry at 2020-07-30T22:55:25-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 380638a3 by Sylvain Henry at 2020-07-30T22:56:03-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 7f19e539 by Simon Peyton Jones at 2020-07-31T16:58:32+01:00 Add right-to-left rule for pattern bindings Fix #18323 by adding a few lines of code to handle non-recursive pattern bindings. see GHC.Tc.Gen.Bind Note [Special case for non-recursive pattern bindings] Alas, this confused the pattern-match overlap checker; see #18323. Note that this patch only affects pattern bindings like that for (x,y) in this program combine :: (forall a . [a] -> a) -> [forall a. a -> a] -> ((forall a . [a] -> a), [forall a. a -> a]) breaks = let (x,y) = combine head ids in x y True We need ImpredicativeTypes for those [forall a. a->a] types to be valid. And with ImpredicativeTypes the old, unprincipled "allow unification variables to unify with a polytype" story actually works quite well. So this test compiles fine (if delicatedly) with old GHCs; but not with QuickLook unless we add this patch - - - - - 30 changed files: - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr/TyThing.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3f406c0fabfc84a3044451f6fcbae4ba0d04f647...7f19e539c0a4c775478a26e172f681084781e017 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3f406c0fabfc84a3044451f6fcbae4ba0d04f647...7f19e539c0a4c775478a26e172f681084781e017 You're receiving 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 Jul 31 20:48:20 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 31 Jul 2020 16:48:20 -0400 Subject: [Git][ghc/ghc][ghc-8.10] gitlab-ci: Build ARMv7 and AArch64 on Debian 10, not Debian 9 Message-ID: <5f2483943a3af_80b3f849a25e69060390c1@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.10 at Glasgow Haskell Compiler / GHC Commits: 81134748 by Ben Gamari at 2020-07-31T16:47:01-04:00 gitlab-ci: Build ARMv7 and AArch64 on Debian 10, not Debian 9 - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -467,61 +467,61 @@ validate-x86_64-darwin: - toolchain ################################# -# aarch64-linux-deb9 +# aarch64-linux-deb10 ################################# -.build-aarch64-linux-deb9: +.build-aarch64-linux-deb10: extends: .validate-linux stage: full-build - image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb9:$DOCKER_REV" + image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV" allow_failure: true variables: - TEST_ENV: "aarch64-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "ghc-aarch64-linux-deb9.tar.xz" + TEST_ENV: "aarch64-linux-deb10" + BIN_DIST_PREP_TAR_COMP: "ghc-aarch64-linux-deb10.tar.xz" cache: - key: linux-aarch64-deb9 + key: linux-aarch64-deb10 tags: - aarch64-linux -validate-aarch64-linux-deb9: - extends: .build-aarch64-linux-deb9 +validate-aarch64-linux-deb10: + extends: .build-aarch64-linux-deb10 artifacts: when: always expire_in: 2 week -nightly-aarch64-linux-deb9: +nightly-aarch64-linux-deb10: <<: *nightly - extends: .build-aarch64-linux-deb9 + extends: .build-aarch64-linux-deb10 variables: TEST_TYPE: slowtest ################################# -# armv7-linux-deb9 +# armv7-linux-deb10 ################################# -.build-armv7-linux-deb9: +.build-armv7-linux-deb10: extends: .validate-linux stage: full-build - image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb9:$DOCKER_REV" + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV" variables: - TEST_ENV: "armv7-linux-deb9" - BIN_DIST_PREP_TAR_COMP: "ghc-armv7-linux-deb9.tar.xz" + TEST_ENV: "armv7-linux-deb10" + BIN_DIST_PREP_TAR_COMP: "ghc-armv7-linux-deb10.tar.xz" CONFIGURE_ARGS: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" cache: - key: linux-armv7-deb9 + key: linux-armv7-deb10 tags: - armv7-linux -validate-armv7-linux-deb9: - extends: .build-armv7-linux-deb9 +validate-armv7-linux-deb10: + extends: .build-armv7-linux-deb10 allow_failure: true artifacts: when: always expire_in: 2 week -nightly-armv7-linux-deb9: +nightly-armv7-linux-deb10: <<: *nightly - extends: .build-armv7-linux-deb9 + extends: .build-armv7-linux-deb10 variables: TEST_TYPE: slowtest View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/81134748910b940eff5701c733ae2daaaa88ad58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/81134748910b940eff5701c733ae2daaaa88ad58 You're receiving 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 Jul 31 21:36:05 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Fri, 31 Jul 2020 17:36:05 -0400 Subject: [Git][ghc/ghc][wip/disamb-td] 30 commits: Drop 32-bit Windows support Message-ID: <5f248ec5919b4_80b3f849a265454604005c@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/disamb-td at Glasgow Haskell Compiler / GHC Commits: aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 7c274cd5 by Sylvain Henry at 2020-07-30T22:54:48-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 175cb5b4 by Sylvain Henry at 2020-07-30T22:55:25-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 380638a3 by Sylvain Henry at 2020-07-30T22:56:03-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 734bd8cd by Vladislav Zavialov at 2020-08-01T00:27:47+03:00 Grammar for types and data/newtype constructors Before this patch, we parsed types into a reversed sequence of operators and operands. For example, (F x y + G a b * X) would be parsed as [X, *, b, a, G, +, y, x, F], using a simple grammar: tyapps : tyapp | tyapps tyapp tyapp : atype | PREFIX_AT atype | tyop | unpackedness Then we used a hand-written state machine to assemble this either into a type, using 'mergeOps', or into a constructor, using 'mergeDataCon'. This is due to a syntactic ambiguity: data T1 a = MkT1 a data T2 a = Ord a => MkT2 a In T1, what follows after the = sign is a data/newtype constructor declaration. However, in T2, what follows is a type (of kind Constraint). We don't know which of the two we are parsing until we encounter =>, and we cannot check for => without unlimited lookahead. This poses a few issues when it comes to e.g. infix operators: data I1 = Int :+ Bool :+ Char -- bad data I2 = Int :+ Bool :+ Char => MkI2 -- fine By this issue alone we are forced into parsing into an intermediate representation and doing a separate validation pass. However, should that intermediate representation be as low-level as a flat sequence of operators and operands? Before GHC Proposal #229, the answer was Yes, due to some particularly nasty corner cases: data T = ! A :+ ! B -- used to be fine, hard to parse data T = ! A :+ ! B => MkT -- bad However, now the answer is No, as this corner case is gone: data T = ! A :+ ! B -- bad data T = ! A :+ ! B => MkT -- bad This means we can write a proper grammar for types, overloading it in the DisambECP style, see Note [Ambiguous syntactic categories]. With this patch, we introduce a new class, DisambTD. Just like DisambECP is used to disambiguate between expressions, commands, and patterns, DisambTD is used to disambiguate between types and data/newtype constructors. This way, we get a proper, declarative grammar for constructors and types: infixtype : ftype | ftype tyop infixtype | unpackedness infixtype ftype : atype | tyop | ftype tyarg | ftype PREFIX_AT tyarg tyarg : atype | unpackedness atype And having a grammar for types means we are a step closer to using a single grammar for types and expressions. - - - - - 30 changed files: - .gitlab-ci.yml - aclocal.m4 - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr/TyThing.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Module.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/02139b3172aa01820c91431f7309727934bc2b74...734bd8cd1328825ff0c67b1272d0062177eb8583 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/02139b3172aa01820c91431f7309727934bc2b74...734bd8cd1328825ff0c67b1272d0062177eb8583 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: